1 diff -Nur rt2500-1.1.0-b4/CHANGELOG rt2500-cvs-2007061011/CHANGELOG
2 --- rt2500-1.1.0-b4/CHANGELOG 2006-06-17 22:12:57.000000000 +0200
3 +++ rt2500-cvs-2007061011/CHANGELOG 2007-06-08 20:09:53.000000000 +0200
5 -/***************************************************************************
6 - * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net *
8 - * This program is free software; you can redistribute it and/or modify *
9 - * it under the terms of the GNU General Public License as published by *
10 - * the Free Software Foundation; either version 2 of the License, or *
11 - * (at your option) any later version. *
13 - * This program is distributed in the hope that it will be useful, *
14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 - * GNU General Public License for more details. *
18 - * You should have received a copy of the GNU General Public License *
19 - * along with this program; if not, write to the *
20 - * Free Software Foundation, Inc., *
21 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23 - * Licensed under the GNU GPL *
24 - * Original code supplied under license from RaLink Inc, 2003. *
25 +/***************************************************************************
26 + * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net *
28 + * This program is free software; you can redistribute it and/or modify *
29 + * it under the terms of the GNU General Public License as published by *
30 + * the Free Software Foundation; either version 2 of the License, or *
31 + * (at your option) any later version. *
33 + * This program is distributed in the hope that it will be useful, *
34 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
35 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
36 + * GNU General Public License for more details. *
38 + * You should have received a copy of the GNU General Public License *
39 + * along with this program; if not, write to the *
40 + * Free Software Foundation, Inc., *
41 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
43 + * Licensed under the GNU GPL *
44 + * Original code supplied under license from RaLink Inc, 2003. *
45 ***************************************************************************/
48 Changelog for 802.11g rt2500 driver and RAConfig2500 Utility
50 - Version: 1.1.0-beta4
52 + * Forward compatibility with kernel 2.6.22 pci bus driver i/f changes
54 + * SIOCGIWSCAN returns EAGAIN until all channels scanned.
55 + * More cruft removal.
56 + * Updated base code to Ralink 1.4.6.6 driver version.
57 + * In-kernel compile support (Bug #1642144): Declare debug var
58 + as static. Implement as bit mask.
59 + * Fix to WPA RSN IE mismatched bug
60 + * Compatibility fixes for kernels >= 2.6.19
61 + * Fix essid truncation on kernels >= 2.6.19
63 + Version: 1.1.0-beta4
64 * Fix pre-up config panic (1307957)
65 * Fix noise levels in scan results (1246025)
66 * RFMON TX Support for aircrack
68 * Promisc/Monitor code missing node->AP packets (1009565)
69 * Channel set in RFMON before ifup now works (1254806)
70 * Fixes for suspend/resume
71 - * Enhancement for RaConfig to support non-ra? interfaces
72 + * Enhancement for RaConfig to support non-ra? interfaces
73 * Channel list updates after region change
74 - * TxPower changes to support dBm values
75 + * TxPower changes to support dBm values
76 * Pre-up panic for setting WirelessMode
77 * Cleanup of iwpriv syntax
78 * Fixes for SMP support (1099089)
80 * Power Saving Modes (1159331)
81 * Bridging with other interfaces
83 - Version: 1.1.0-beta3
84 + Version: 1.1.0-beta3
85 * PCI Management Cleanup
86 * Fix for RaConfig crashing on statistics (ChrisH)
87 * Big-Endian fix for RaConfig
89 * Fix iwconfig - Link Quality(means Channel Quality), Signal level and Noise level.
90 * Fix iwlist ra0 channel - print out
92 - Version: 1.1.0-beta2
93 + Version: 1.1.0-beta2
94 * Removed Kernel tainting
95 * Updated all file headers for this project
96 * kmalloc stability fixes to the MLME
97 * Cleanup on memory management functions (NDisFill/Move/Zero)
98 * Rollin of Robin Cornelius RFMon Patch
99 * RFMon support through iwconfig mode
100 - * Debugging and general logging cleanups
101 - * Rolling of changes in Ralink 1.4.5.0 release
102 + * Debugging and general logging cleanups
103 + * Rolling of changes in Ralink 1.4.5.0 release
105 * Spinlock changes for stability
106 * GCC 3.4 compilation
110 * Initial baseline code from Ralink (1.4.4.0)
115 diff -Nur rt2500-1.1.0-b4/LICENSE rt2500-cvs-2007061011/LICENSE
116 --- rt2500-1.1.0-b4/LICENSE 2006-06-17 22:12:58.000000000 +0200
117 +++ rt2500-cvs-2007061011/LICENSE 2007-05-29 05:57:52.000000000 +0200
119 - GNU GENERAL PUBLIC LICENSE
120 - Version 2, June 1991
122 - Copyright (C) 1989, 1991 Free Software Foundation, Inc.
123 - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
124 - Everyone is permitted to copy and distribute verbatim copies
125 - of this license document, but changing it is not allowed.
129 - The licenses for most software are designed to take away your
130 -freedom to share and change it. By contrast, the GNU General Public
131 -License is intended to guarantee your freedom to share and change free
132 -software--to make sure the software is free for all its users. This
133 -General Public License applies to most of the Free Software
134 -Foundation's software and to any other program whose authors commit to
135 -using it. (Some other Free Software Foundation software is covered by
136 -the GNU Library General Public License instead.) You can apply it to
139 - When we speak of free software, we are referring to freedom, not
140 -price. Our General Public Licenses are designed to make sure that you
141 -have the freedom to distribute copies of free software (and charge for
142 -this service if you wish), that you receive source code or can get it
143 -if you want it, that you can change the software or use pieces of it
144 -in new free programs; and that you know you can do these things.
146 - To protect your rights, we need to make restrictions that forbid
147 -anyone to deny you these rights or to ask you to surrender the rights.
148 -These restrictions translate to certain responsibilities for you if you
149 -distribute copies of the software, or if you modify it.
151 - For example, if you distribute copies of such a program, whether
152 -gratis or for a fee, you must give the recipients all the rights that
153 -you have. You must make sure that they, too, receive or can get the
154 -source code. And you must show them these terms so they know their
157 - We protect your rights with two steps: (1) copyright the software, and
158 -(2) offer you this license which gives you legal permission to copy,
159 -distribute and/or modify the software.
161 - Also, for each author's protection and ours, we want to make certain
162 -that everyone understands that there is no warranty for this free
163 -software. If the software is modified by someone else and passed on, we
164 -want its recipients to know that what they have is not the original, so
165 -that any problems introduced by others will not reflect on the original
166 -authors' reputations.
168 - Finally, any free program is threatened constantly by software
169 -patents. We wish to avoid the danger that redistributors of a free
170 -program will individually obtain patent licenses, in effect making the
171 -program proprietary. To prevent this, we have made it clear that any
172 -patent must be licensed for everyone's free use or not licensed at all.
174 - The precise terms and conditions for copying, distribution and
175 -modification follow.
177 - GNU GENERAL PUBLIC LICENSE
178 - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
180 - 0. This License applies to any program or other work which contains
181 -a notice placed by the copyright holder saying it may be distributed
182 -under the terms of this General Public License. The "Program", below,
183 -refers to any such program or work, and a "work based on the Program"
184 -means either the Program or any derivative work under copyright law:
185 -that is to say, a work containing the Program or a portion of it,
186 -either verbatim or with modifications and/or translated into another
187 -language. (Hereinafter, translation is included without limitation in
188 -the term "modification".) Each licensee is addressed as "you".
190 -Activities other than copying, distribution and modification are not
191 -covered by this License; they are outside its scope. The act of
192 -running the Program is not restricted, and the output from the Program
193 -is covered only if its contents constitute a work based on the
194 -Program (independent of having been made by running the Program).
195 -Whether that is true depends on what the Program does.
197 - 1. You may copy and distribute verbatim copies of the Program's
198 -source code as you receive it, in any medium, provided that you
199 -conspicuously and appropriately publish on each copy an appropriate
200 -copyright notice and disclaimer of warranty; keep intact all the
201 -notices that refer to this License and to the absence of any warranty;
202 -and give any other recipients of the Program a copy of this License
203 -along with the Program.
205 -You may charge a fee for the physical act of transferring a copy, and
206 -you may at your option offer warranty protection in exchange for a fee.
208 - 2. You may modify your copy or copies of the Program or any portion
209 -of it, thus forming a work based on the Program, and copy and
210 -distribute such modifications or work under the terms of Section 1
211 -above, provided that you also meet all of these conditions:
213 - a) You must cause the modified files to carry prominent notices
214 - stating that you changed the files and the date of any change.
216 - b) You must cause any work that you distribute or publish, that in
217 - whole or in part contains or is derived from the Program or any
218 - part thereof, to be licensed as a whole at no charge to all third
219 - parties under the terms of this License.
221 - c) If the modified program normally reads commands interactively
222 - when run, you must cause it, when started running for such
223 - interactive use in the most ordinary way, to print or display an
224 - announcement including an appropriate copyright notice and a
225 - notice that there is no warranty (or else, saying that you provide
226 - a warranty) and that users may redistribute the program under
227 - these conditions, and telling the user how to view a copy of this
228 - License. (Exception: if the Program itself is interactive but
229 - does not normally print such an announcement, your work based on
230 - the Program is not required to print an announcement.)
232 -These requirements apply to the modified work as a whole. If
233 -identifiable sections of that work are not derived from the Program,
234 -and can be reasonably considered independent and separate works in
235 -themselves, then this License, and its terms, do not apply to those
236 -sections when you distribute them as separate works. But when you
237 -distribute the same sections as part of a whole which is a work based
238 -on the Program, the distribution of the whole must be on the terms of
239 -this License, whose permissions for other licensees extend to the
240 -entire whole, and thus to each and every part regardless of who wrote it.
242 -Thus, it is not the intent of this section to claim rights or contest
243 -your rights to work written entirely by you; rather, the intent is to
244 -exercise the right to control the distribution of derivative or
245 -collective works based on the Program.
247 -In addition, mere aggregation of another work not based on the Program
248 -with the Program (or with a work based on the Program) on a volume of
249 -a storage or distribution medium does not bring the other work under
250 -the scope of this License.
252 - 3. You may copy and distribute the Program (or a work based on it,
253 -under Section 2) in object code or executable form under the terms of
254 -Sections 1 and 2 above provided that you also do one of the following:
256 - a) Accompany it with the complete corresponding machine-readable
257 - source code, which must be distributed under the terms of Sections
258 - 1 and 2 above on a medium customarily used for software interchange; or,
260 - b) Accompany it with a written offer, valid for at least three
261 - years, to give any third party, for a charge no more than your
262 - cost of physically performing source distribution, a complete
263 - machine-readable copy of the corresponding source code, to be
264 - distributed under the terms of Sections 1 and 2 above on a medium
265 - customarily used for software interchange; or,
267 - c) Accompany it with the information you received as to the offer
268 - to distribute corresponding source code. (This alternative is
269 - allowed only for noncommercial distribution and only if you
270 - received the program in object code or executable form with such
271 - an offer, in accord with Subsection b above.)
273 -The source code for a work means the preferred form of the work for
274 -making modifications to it. For an executable work, complete source
275 -code means all the source code for all modules it contains, plus any
276 -associated interface definition files, plus the scripts used to
277 -control compilation and installation of the executable. However, as a
278 -special exception, the source code distributed need not include
279 -anything that is normally distributed (in either source or binary
280 -form) with the major components (compiler, kernel, and so on) of the
281 -operating system on which the executable runs, unless that component
282 -itself accompanies the executable.
284 -If distribution of executable or object code is made by offering
285 -access to copy from a designated place, then offering equivalent
286 -access to copy the source code from the same place counts as
287 -distribution of the source code, even though third parties are not
288 -compelled to copy the source along with the object code.
290 - 4. You may not copy, modify, sublicense, or distribute the Program
291 -except as expressly provided under this License. Any attempt
292 -otherwise to copy, modify, sublicense or distribute the Program is
293 -void, and will automatically terminate your rights under this License.
294 -However, parties who have received copies, or rights, from you under
295 -this License will not have their licenses terminated so long as such
296 -parties remain in full compliance.
298 - 5. You are not required to accept this License, since you have not
299 -signed it. However, nothing else grants you permission to modify or
300 -distribute the Program or its derivative works. These actions are
301 -prohibited by law if you do not accept this License. Therefore, by
302 -modifying or distributing the Program (or any work based on the
303 -Program), you indicate your acceptance of this License to do so, and
304 -all its terms and conditions for copying, distributing or modifying
305 -the Program or works based on it.
307 - 6. Each time you redistribute the Program (or any work based on the
308 -Program), the recipient automatically receives a license from the
309 -original licensor to copy, distribute or modify the Program subject to
310 -these terms and conditions. You may not impose any further
311 -restrictions on the recipients' exercise of the rights granted herein.
312 -You are not responsible for enforcing compliance by third parties to
315 - 7. If, as a consequence of a court judgment or allegation of patent
316 -infringement or for any other reason (not limited to patent issues),
317 -conditions are imposed on you (whether by court order, agreement or
318 -otherwise) that contradict the conditions of this License, they do not
319 -excuse you from the conditions of this License. If you cannot
320 -distribute so as to satisfy simultaneously your obligations under this
321 -License and any other pertinent obligations, then as a consequence you
322 -may not distribute the Program at all. For example, if a patent
323 -license would not permit royalty-free redistribution of the Program by
324 -all those who receive copies directly or indirectly through you, then
325 -the only way you could satisfy both it and this License would be to
326 -refrain entirely from distribution of the Program.
328 -If any portion of this section is held invalid or unenforceable under
329 -any particular circumstance, the balance of the section is intended to
330 -apply and the section as a whole is intended to apply in other
333 -It is not the purpose of this section to induce you to infringe any
334 -patents or other property right claims or to contest validity of any
335 -such claims; this section has the sole purpose of protecting the
336 -integrity of the free software distribution system, which is
337 -implemented by public license practices. Many people have made
338 -generous contributions to the wide range of software distributed
339 -through that system in reliance on consistent application of that
340 -system; it is up to the author/donor to decide if he or she is willing
341 -to distribute software through any other system and a licensee cannot
344 -This section is intended to make thoroughly clear what is believed to
345 -be a consequence of the rest of this License.
347 - 8. If the distribution and/or use of the Program is restricted in
348 -certain countries either by patents or by copyrighted interfaces, the
349 -original copyright holder who places the Program under this License
350 -may add an explicit geographical distribution limitation excluding
351 -those countries, so that distribution is permitted only in or among
352 -countries not thus excluded. In such case, this License incorporates
353 -the limitation as if written in the body of this License.
355 - 9. The Free Software Foundation may publish revised and/or new versions
356 -of the General Public License from time to time. Such new versions will
357 -be similar in spirit to the present version, but may differ in detail to
358 -address new problems or concerns.
360 -Each version is given a distinguishing version number. If the Program
361 -specifies a version number of this License which applies to it and "any
362 -later version", you have the option of following the terms and conditions
363 -either of that version or of any later version published by the Free
364 -Software Foundation. If the Program does not specify a version number of
365 -this License, you may choose any version ever published by the Free Software
368 - 10. If you wish to incorporate parts of the Program into other free
369 -programs whose distribution conditions are different, write to the author
370 -to ask for permission. For software which is copyrighted by the Free
371 -Software Foundation, write to the Free Software Foundation; we sometimes
372 -make exceptions for this. Our decision will be guided by the two goals
373 -of preserving the free status of all derivatives of our free software and
374 -of promoting the sharing and reuse of software generally.
378 - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
379 -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
380 -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
381 -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
382 -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
383 -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
384 -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
385 -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
386 -REPAIR OR CORRECTION.
388 - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
389 -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
390 -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
391 -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
392 -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
393 -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
394 -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
395 -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
396 -POSSIBILITY OF SUCH DAMAGES.
398 - END OF TERMS AND CONDITIONS
400 - How to Apply These Terms to Your New Programs
402 - If you develop a new program, and you want it to be of the greatest
403 -possible use to the public, the best way to achieve this is to make it
404 -free software which everyone can redistribute and change under these terms.
406 - To do so, attach the following notices to the program. It is safest
407 -to attach them to the start of each source file to most effectively
408 -convey the exclusion of warranty; and each file should have at least
409 -the "copyright" line and a pointer to where the full notice is found.
411 - <one line to give the program's name and a brief idea of what it does.>
412 - Copyright (C) <year> <name of author>
414 - This program is free software; you can redistribute it and/or modify
415 - it under the terms of the GNU General Public License as published by
416 - the Free Software Foundation; either version 2 of the License, or
417 - (at your option) any later version.
419 - This program is distributed in the hope that it will be useful,
420 - but WITHOUT ANY WARRANTY; without even the implied warranty of
421 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
422 - GNU General Public License for more details.
424 - You should have received a copy of the GNU General Public License
425 - along with this program; if not, write to the Free Software
426 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
429 -Also add information on how to contact you by electronic and paper mail.
431 -If the program is interactive, make it output a short notice like this
432 -when it starts in an interactive mode:
434 - Gnomovision version 69, Copyright (C) year name of author
435 - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
436 - This is free software, and you are welcome to redistribute it
437 - under certain conditions; type `show c' for details.
439 -The hypothetical commands `show w' and `show c' should show the appropriate
440 -parts of the General Public License. Of course, the commands you use may
441 -be called something other than `show w' and `show c'; they could even be
442 -mouse-clicks or menu items--whatever suits your program.
444 -You should also get your employer (if you work as a programmer) or your
445 -school, if any, to sign a "copyright disclaimer" for the program, if
446 -necessary. Here is a sample; alter the names:
448 - Yoyodyne, Inc., hereby disclaims all copyright interest in the program
449 - `Gnomovision' (which makes passes at compilers) written by James Hacker.
451 - <signature of Ty Coon>, 1 April 1989
452 - Ty Coon, President of Vice
454 -This General Public License does not permit incorporating your program into
455 -proprietary programs. If your program is a subroutine library, you may
456 -consider it more useful to permit linking proprietary applications with the
457 -library. If this is what you want to do, use the GNU Library General
458 + GNU GENERAL PUBLIC LICENSE
459 + Version 2, June 1991
461 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
462 + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
463 + Everyone is permitted to copy and distribute verbatim copies
464 + of this license document, but changing it is not allowed.
468 + The licenses for most software are designed to take away your
469 +freedom to share and change it. By contrast, the GNU General Public
470 +License is intended to guarantee your freedom to share and change free
471 +software--to make sure the software is free for all its users. This
472 +General Public License applies to most of the Free Software
473 +Foundation's software and to any other program whose authors commit to
474 +using it. (Some other Free Software Foundation software is covered by
475 +the GNU Library General Public License instead.) You can apply it to
478 + When we speak of free software, we are referring to freedom, not
479 +price. Our General Public Licenses are designed to make sure that you
480 +have the freedom to distribute copies of free software (and charge for
481 +this service if you wish), that you receive source code or can get it
482 +if you want it, that you can change the software or use pieces of it
483 +in new free programs; and that you know you can do these things.
485 + To protect your rights, we need to make restrictions that forbid
486 +anyone to deny you these rights or to ask you to surrender the rights.
487 +These restrictions translate to certain responsibilities for you if you
488 +distribute copies of the software, or if you modify it.
490 + For example, if you distribute copies of such a program, whether
491 +gratis or for a fee, you must give the recipients all the rights that
492 +you have. You must make sure that they, too, receive or can get the
493 +source code. And you must show them these terms so they know their
496 + We protect your rights with two steps: (1) copyright the software, and
497 +(2) offer you this license which gives you legal permission to copy,
498 +distribute and/or modify the software.
500 + Also, for each author's protection and ours, we want to make certain
501 +that everyone understands that there is no warranty for this free
502 +software. If the software is modified by someone else and passed on, we
503 +want its recipients to know that what they have is not the original, so
504 +that any problems introduced by others will not reflect on the original
505 +authors' reputations.
507 + Finally, any free program is threatened constantly by software
508 +patents. We wish to avoid the danger that redistributors of a free
509 +program will individually obtain patent licenses, in effect making the
510 +program proprietary. To prevent this, we have made it clear that any
511 +patent must be licensed for everyone's free use or not licensed at all.
513 + The precise terms and conditions for copying, distribution and
514 +modification follow.
516 + GNU GENERAL PUBLIC LICENSE
517 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
519 + 0. This License applies to any program or other work which contains
520 +a notice placed by the copyright holder saying it may be distributed
521 +under the terms of this General Public License. The "Program", below,
522 +refers to any such program or work, and a "work based on the Program"
523 +means either the Program or any derivative work under copyright law:
524 +that is to say, a work containing the Program or a portion of it,
525 +either verbatim or with modifications and/or translated into another
526 +language. (Hereinafter, translation is included without limitation in
527 +the term "modification".) Each licensee is addressed as "you".
529 +Activities other than copying, distribution and modification are not
530 +covered by this License; they are outside its scope. The act of
531 +running the Program is not restricted, and the output from the Program
532 +is covered only if its contents constitute a work based on the
533 +Program (independent of having been made by running the Program).
534 +Whether that is true depends on what the Program does.
536 + 1. You may copy and distribute verbatim copies of the Program's
537 +source code as you receive it, in any medium, provided that you
538 +conspicuously and appropriately publish on each copy an appropriate
539 +copyright notice and disclaimer of warranty; keep intact all the
540 +notices that refer to this License and to the absence of any warranty;
541 +and give any other recipients of the Program a copy of this License
542 +along with the Program.
544 +You may charge a fee for the physical act of transferring a copy, and
545 +you may at your option offer warranty protection in exchange for a fee.
547 + 2. You may modify your copy or copies of the Program or any portion
548 +of it, thus forming a work based on the Program, and copy and
549 +distribute such modifications or work under the terms of Section 1
550 +above, provided that you also meet all of these conditions:
552 + a) You must cause the modified files to carry prominent notices
553 + stating that you changed the files and the date of any change.
555 + b) You must cause any work that you distribute or publish, that in
556 + whole or in part contains or is derived from the Program or any
557 + part thereof, to be licensed as a whole at no charge to all third
558 + parties under the terms of this License.
560 + c) If the modified program normally reads commands interactively
561 + when run, you must cause it, when started running for such
562 + interactive use in the most ordinary way, to print or display an
563 + announcement including an appropriate copyright notice and a
564 + notice that there is no warranty (or else, saying that you provide
565 + a warranty) and that users may redistribute the program under
566 + these conditions, and telling the user how to view a copy of this
567 + License. (Exception: if the Program itself is interactive but
568 + does not normally print such an announcement, your work based on
569 + the Program is not required to print an announcement.)
571 +These requirements apply to the modified work as a whole. If
572 +identifiable sections of that work are not derived from the Program,
573 +and can be reasonably considered independent and separate works in
574 +themselves, then this License, and its terms, do not apply to those
575 +sections when you distribute them as separate works. But when you
576 +distribute the same sections as part of a whole which is a work based
577 +on the Program, the distribution of the whole must be on the terms of
578 +this License, whose permissions for other licensees extend to the
579 +entire whole, and thus to each and every part regardless of who wrote it.
581 +Thus, it is not the intent of this section to claim rights or contest
582 +your rights to work written entirely by you; rather, the intent is to
583 +exercise the right to control the distribution of derivative or
584 +collective works based on the Program.
586 +In addition, mere aggregation of another work not based on the Program
587 +with the Program (or with a work based on the Program) on a volume of
588 +a storage or distribution medium does not bring the other work under
589 +the scope of this License.
591 + 3. You may copy and distribute the Program (or a work based on it,
592 +under Section 2) in object code or executable form under the terms of
593 +Sections 1 and 2 above provided that you also do one of the following:
595 + a) Accompany it with the complete corresponding machine-readable
596 + source code, which must be distributed under the terms of Sections
597 + 1 and 2 above on a medium customarily used for software interchange; or,
599 + b) Accompany it with a written offer, valid for at least three
600 + years, to give any third party, for a charge no more than your
601 + cost of physically performing source distribution, a complete
602 + machine-readable copy of the corresponding source code, to be
603 + distributed under the terms of Sections 1 and 2 above on a medium
604 + customarily used for software interchange; or,
606 + c) Accompany it with the information you received as to the offer
607 + to distribute corresponding source code. (This alternative is
608 + allowed only for noncommercial distribution and only if you
609 + received the program in object code or executable form with such
610 + an offer, in accord with Subsection b above.)
612 +The source code for a work means the preferred form of the work for
613 +making modifications to it. For an executable work, complete source
614 +code means all the source code for all modules it contains, plus any
615 +associated interface definition files, plus the scripts used to
616 +control compilation and installation of the executable. However, as a
617 +special exception, the source code distributed need not include
618 +anything that is normally distributed (in either source or binary
619 +form) with the major components (compiler, kernel, and so on) of the
620 +operating system on which the executable runs, unless that component
621 +itself accompanies the executable.
623 +If distribution of executable or object code is made by offering
624 +access to copy from a designated place, then offering equivalent
625 +access to copy the source code from the same place counts as
626 +distribution of the source code, even though third parties are not
627 +compelled to copy the source along with the object code.
629 + 4. You may not copy, modify, sublicense, or distribute the Program
630 +except as expressly provided under this License. Any attempt
631 +otherwise to copy, modify, sublicense or distribute the Program is
632 +void, and will automatically terminate your rights under this License.
633 +However, parties who have received copies, or rights, from you under
634 +this License will not have their licenses terminated so long as such
635 +parties remain in full compliance.
637 + 5. You are not required to accept this License, since you have not
638 +signed it. However, nothing else grants you permission to modify or
639 +distribute the Program or its derivative works. These actions are
640 +prohibited by law if you do not accept this License. Therefore, by
641 +modifying or distributing the Program (or any work based on the
642 +Program), you indicate your acceptance of this License to do so, and
643 +all its terms and conditions for copying, distributing or modifying
644 +the Program or works based on it.
646 + 6. Each time you redistribute the Program (or any work based on the
647 +Program), the recipient automatically receives a license from the
648 +original licensor to copy, distribute or modify the Program subject to
649 +these terms and conditions. You may not impose any further
650 +restrictions on the recipients' exercise of the rights granted herein.
651 +You are not responsible for enforcing compliance by third parties to
654 + 7. If, as a consequence of a court judgment or allegation of patent
655 +infringement or for any other reason (not limited to patent issues),
656 +conditions are imposed on you (whether by court order, agreement or
657 +otherwise) that contradict the conditions of this License, they do not
658 +excuse you from the conditions of this License. If you cannot
659 +distribute so as to satisfy simultaneously your obligations under this
660 +License and any other pertinent obligations, then as a consequence you
661 +may not distribute the Program at all. For example, if a patent
662 +license would not permit royalty-free redistribution of the Program by
663 +all those who receive copies directly or indirectly through you, then
664 +the only way you could satisfy both it and this License would be to
665 +refrain entirely from distribution of the Program.
667 +If any portion of this section is held invalid or unenforceable under
668 +any particular circumstance, the balance of the section is intended to
669 +apply and the section as a whole is intended to apply in other
672 +It is not the purpose of this section to induce you to infringe any
673 +patents or other property right claims or to contest validity of any
674 +such claims; this section has the sole purpose of protecting the
675 +integrity of the free software distribution system, which is
676 +implemented by public license practices. Many people have made
677 +generous contributions to the wide range of software distributed
678 +through that system in reliance on consistent application of that
679 +system; it is up to the author/donor to decide if he or she is willing
680 +to distribute software through any other system and a licensee cannot
683 +This section is intended to make thoroughly clear what is believed to
684 +be a consequence of the rest of this License.
686 + 8. If the distribution and/or use of the Program is restricted in
687 +certain countries either by patents or by copyrighted interfaces, the
688 +original copyright holder who places the Program under this License
689 +may add an explicit geographical distribution limitation excluding
690 +those countries, so that distribution is permitted only in or among
691 +countries not thus excluded. In such case, this License incorporates
692 +the limitation as if written in the body of this License.
694 + 9. The Free Software Foundation may publish revised and/or new versions
695 +of the General Public License from time to time. Such new versions will
696 +be similar in spirit to the present version, but may differ in detail to
697 +address new problems or concerns.
699 +Each version is given a distinguishing version number. If the Program
700 +specifies a version number of this License which applies to it and "any
701 +later version", you have the option of following the terms and conditions
702 +either of that version or of any later version published by the Free
703 +Software Foundation. If the Program does not specify a version number of
704 +this License, you may choose any version ever published by the Free Software
707 + 10. If you wish to incorporate parts of the Program into other free
708 +programs whose distribution conditions are different, write to the author
709 +to ask for permission. For software which is copyrighted by the Free
710 +Software Foundation, write to the Free Software Foundation; we sometimes
711 +make exceptions for this. Our decision will be guided by the two goals
712 +of preserving the free status of all derivatives of our free software and
713 +of promoting the sharing and reuse of software generally.
717 + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
718 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
719 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
720 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
721 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
722 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
723 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
724 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
725 +REPAIR OR CORRECTION.
727 + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
728 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
729 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
730 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
731 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
732 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
733 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
734 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
735 +POSSIBILITY OF SUCH DAMAGES.
737 + END OF TERMS AND CONDITIONS
739 + How to Apply These Terms to Your New Programs
741 + If you develop a new program, and you want it to be of the greatest
742 +possible use to the public, the best way to achieve this is to make it
743 +free software which everyone can redistribute and change under these terms.
745 + To do so, attach the following notices to the program. It is safest
746 +to attach them to the start of each source file to most effectively
747 +convey the exclusion of warranty; and each file should have at least
748 +the "copyright" line and a pointer to where the full notice is found.
750 + <one line to give the program's name and a brief idea of what it does.>
751 + Copyright (C) <year> <name of author>
753 + This program is free software; you can redistribute it and/or modify
754 + it under the terms of the GNU General Public License as published by
755 + the Free Software Foundation; either version 2 of the License, or
756 + (at your option) any later version.
758 + This program is distributed in the hope that it will be useful,
759 + but WITHOUT ANY WARRANTY; without even the implied warranty of
760 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
761 + GNU General Public License for more details.
763 + You should have received a copy of the GNU General Public License
764 + along with this program; if not, write to the Free Software
765 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
768 +Also add information on how to contact you by electronic and paper mail.
770 +If the program is interactive, make it output a short notice like this
771 +when it starts in an interactive mode:
773 + Gnomovision version 69, Copyright (C) year name of author
774 + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
775 + This is free software, and you are welcome to redistribute it
776 + under certain conditions; type `show c' for details.
778 +The hypothetical commands `show w' and `show c' should show the appropriate
779 +parts of the General Public License. Of course, the commands you use may
780 +be called something other than `show w' and `show c'; they could even be
781 +mouse-clicks or menu items--whatever suits your program.
783 +You should also get your employer (if you work as a programmer) or your
784 +school, if any, to sign a "copyright disclaimer" for the program, if
785 +necessary. Here is a sample; alter the names:
787 + Yoyodyne, Inc., hereby disclaims all copyright interest in the program
788 + `Gnomovision' (which makes passes at compilers) written by James Hacker.
790 + <signature of Ty Coon>, 1 April 1989
791 + Ty Coon, President of Vice
793 +This General Public License does not permit incorporating your program into
794 +proprietary programs. If your program is a subroutine library, you may
795 +consider it more useful to permit linking proprietary applications with the
796 +library. If this is what you want to do, use the GNU Library General
797 Public License instead of this License.
798 \ Kein Zeilenumbruch am Dateiende.
799 diff -Nur rt2500-1.1.0-b4/Module/Makefile rt2500-cvs-2007061011/Module/Makefile
800 --- rt2500-1.1.0-b4/Module/Makefile 2006-06-17 22:12:58.000000000 +0200
801 +++ rt2500-cvs-2007061011/Module/Makefile 2007-05-29 05:54:38.000000000 +0200
803 -###########################################################################
804 -# RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com #
806 -# This program is free software; you can redistribute it and/or modify #
807 -# it under the terms of the GNU General Public License as published by #
808 -# the Free Software Foundation; either version 2 of the License, or #
809 -# (at your option) any later version. #
811 -# This program is distributed in the hope that it will be useful, #
812 -# but WITHOUT ANY WARRANTY; without even the implied warranty of #
813 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
814 -# GNU General Public License for more details. #
816 -# You should have received a copy of the GNU General Public License #
817 -# along with this program; if not, write to the #
818 -# Free Software Foundation, Inc., #
819 -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
821 -# Licensed under the GNU GPL #
822 -# Original code supplied under license from RaLink Inc, 2004. #
823 -###########################################################################
825 -###########################################################################
826 -# Module Name: Makefile
828 -# Abstract: Makefile for rt2500 kernel module
832 -# -------- ----------- -----------------------------
833 -# MarkW 8th Dec 04 Rewrite of Makefile
834 +###########################################################################
835 +# RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com #
837 +# This program is free software; you can redistribute it and/or modify #
838 +# it under the terms of the GNU General Public License as published by #
839 +# the Free Software Foundation; either version 2 of the License, or #
840 +# (at your option) any later version. #
842 +# This program is distributed in the hope that it will be useful, #
843 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
844 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
845 +# GNU General Public License for more details. #
847 +# You should have received a copy of the GNU General Public License #
848 +# along with this program; if not, write to the #
849 +# Free Software Foundation, Inc., #
850 +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
852 +# Licensed under the GNU GPL #
853 +# Original code supplied under license from RaLink Inc, 2004. #
854 +###########################################################################
856 +###########################################################################
857 +# Module Name: Makefile
859 +# Abstract: Makefile for rt2500 kernel module
863 +# -------- ----------- -----------------------------
864 +# MarkW 8th Dec 04 Rewrite of Makefile
865 # AmirS 1st Jan 05 Update for gmake compat
866 # MarkW 20th Jan 05 Fixed permissions on directory
867 # MichalL 5th Mar 05 Module installation fixes
868 # MarkW 29th Jul 05 Allow install dir override
869 -###########################################################################
870 +###########################################################################
876 MODULE_NAME := rt2500
880 #KERNDIR=/usr/src/linux-2.6
881 #MODDIR=/lib/modules/2.6.12/extra
884 $(LD) $(EXTRA_LDFLAGS) -r -o $@ $($(MODULE_NAME)-objs)
887 -KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(PWD) $(KERNEL_OUTPUT)
888 +KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(CURDIR) $(KERNEL_OUTPUT)
891 @$(MAKE) $(KBUILD_PARAMS) modules; \
892 @@ -110,22 +110,29 @@
897 + @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-I$(src) -DRT2500_DBG -DRT2X00DEBUGFS' modules; \
898 + if ! [ -f $(MODULE_OBJECT) ]; then \
899 + echo "$(MODULE_OBJECT) failed to build!"; \
904 @rm -f $(RESMAN_GLUE_OBJS) $(RESMAN_CORE_OBJS) .*.{cmd,flags}
905 @rm -f $(MODULE_NAME).{o,ko,mod.{o,c}} built-in.o $(VERSION_HEADER) *~
906 - @rm -fr .tmp_versions
907 + @rm -fr .tmp_versions Module.symvers
910 -ifeq ($(PATCHLEVEL),4)
911 - if ! [ -f $(MODULE_OBJECT) ]; then \
913 + @if ! [ -f $(MODULE_OBJECT) ]; then \
916 +ifeq ($(PATCHLEVEL),4)
917 @echo "install '$(MODULE_OBJECT)' to $(MODULE_ROOT)"
918 install -m 755 -o 0 -g 0 -d $(MODULE_ROOT)
919 install -m 644 -o 0 -g 0 $(MODULE_OBJECT) $(MODULE_ROOT)
923 - echo "2.6 module install"
924 + @echo "2.6 module install"
925 make $(KBUILD_PARAMS) modules_install
929 install -m 755 -o 0 -g 0 -d $(MODULE_ROOT)
930 install -m 644 -o 0 -g 0 $(MODULE_OBJECT) $(MODULE_ROOT)
934 @if ! grep -q 'wlan0' /etc/modprobe.conf ; then \
935 echo "append 'alias wlan0 rt2500' to /etc/modprobe.conf"; \
936 echo "alias wlan0 rt2500" >> /etc/modprobe.conf ; \
937 diff -Nur rt2500-1.1.0-b4/Module/README rt2500-cvs-2007061011/Module/README
938 --- rt2500-1.1.0-b4/Module/README 2006-06-17 22:12:58.000000000 +0200
939 +++ rt2500-cvs-2007061011/Module/README 2007-05-29 05:54:39.000000000 +0200
941 Installation instructions for the rt2500 Module
943 ======================================================================
947 For 2.4 or 2.6 series kernel:
948 a. $tar -xvzf rt2500-x.x.x.tar.gz
951 b. $make # compile driver source code
953 -c. $make install # installs kernel module driver
954 +c. $make install # installs kernel module driver
956 +(read end of file for FedoraCore3 specific information)
958 -(read end of file for FedoraCore3 specific information)
960 ======================================================================
965 b. run 'qmake -o Makefile raconfig2500.pro'
966 If qmake command is not found in your system, you can download
967 - the QT tool 'qt-x11-free-3.2.1' or later at
968 + the QT tool 'qt-x11-free-3.2.1' or later at
969 http://www.trolltech.com/
971 - (qmake comes with RedHat 7.3 or later QT Package)
973 + (qmake comes with RedHat 7.3 or later QT Package)
975 c. run 'make" to compile the utility source code.
978 d. After all, an execution file would be generated "RaConfig2500"
979 run "RaConfig2500" to config the driver as you want
983 ======================================================================
987 -RT2500 driver can be configured via following interfaces,
988 +RT2500 driver can be configured via following interfaces,
989 i.e. (i)"iwconfig" command, (ii)"iwpriv" command, (iii) configuration
990 file, (iv) RaConfig2500
992 -i) iwconfig comes with kernel.
993 +i) iwconfig comes with kernel.
994 ii) iwpriv usage, please refer to file "iwpriv_usage.txt" for details.
995 iii)copy configuration file "RT2500STA.dat" to
996 /etc/Wireless/RT2500STA/RT2500STA.dat.
998 iv) RT2500 provides API : RaConfig2500, please go to directory
999 ./Utility and refer to how-to-compile.txt
1003 Configuration File : RT2500STA.dat
1005 # Copy this file to /etc/Wireless/RT2500STA/RT2500STA.dat
1009 # Use "vi -b RT2500STA.dat" to modify settings according to your need.
1012 # 1.) set NetworkType to "Adhoc" for using Adhoc-mode, otherwise
1013 # using as Infrastructure-mode.
1014 # 2.) set Channel to "0" for auto-select on Infrastructure mode.
1018 -----------------------------------------------
1019 -syntax is 'Param'='Value' and described below.
1020 +syntax is 'Param'='Value' and described below.
1022 1. CountryRegion=value
1024 @@ -125,13 +125,14 @@
1025 OPEN For Open System
1026 SHARED For Shared key system
1029 + WPANONE For pre-shared key in adhoc mode
1030 + WPAPSK For pre-shared key in infrastructure mode
1033 NONE :For AuthMode=OPEN
1034 WEP :For AuthMode=OPEN or AuthMode=SHARED
1035 - TKIP :For AuthMode=WPAPSK
1036 - AES :For AuthMode=WPAPSK
1037 + TKIP :For AuthMode=WPAPSK or AuthMode=WPANONE
1038 + AES :For AuthMode=WPAPSK or AuthMode=WPANONE
1039 8. DefaultKeyID=value
1048 5: 6 Mbps //WirelessMode must be 0
1049 6: 9 Mbps //WirelessMode must be 0
1050 7: 12 Mbps //WirelessMode must be 0
1051 @@ -210,13 +211,13 @@
1055 - 0: Tx MAX rate will be 11Mbps in Adhoc mode.
1056 - 1: Tx MAX rate will be 54Mbps in Adhoc mode.
1057 + 0: Tx MAX rate will be 11Mbps in Adhoc mode.
1058 + 1: Tx MAX rate will be 54Mbps in Adhoc mode.
1060 24. StaWithEtherBridge=value
1062 - 0: Disable sta with ethernet to wireless bridge.
1063 - 1: Enable sta with ethernet to wireless bridge.
1064 + 0: Disable sta with ethernet to wireless bridge.
1065 + 1: Enable sta with ethernet to wireless bridge.
1069 @@ -224,25 +225,25 @@
1070 If you want for rt2500 driver to auto-load at boot time:
1071 A) choose ra0 for first RT2500 WLAN card, ra1 for second RT2500 WLAN
1074 -B) create(edit) 'ifcfg-ra0' file in /etc/sysconfig/network-scripts/,
1076 +B) create(edit) 'ifcfg-ra0' file in /etc/sysconfig/network-scripts/,
1077 edit( or add the line) in /etc/modules.conf:
1080 -C) edit(create) the file /etc/sysconfig/network-scripts/ifcfg-ra0
1083 +C) edit(create) the file /etc/sysconfig/network-scripts/ifcfg-ra0
1090 if you use dhcp, add this line too .
1093 -*D) To ease the Default Gateway setting,
1094 +*D) To ease the Default Gateway setting,
1098 in /etc/sysconfig/network
1101 INFORMATION FOR FEDORA CORE 3 USERS (USE AT YOUR OWN RISK !!!)
1102 ======================================================================
1103 While this information is directed to Fedora Core 3 users, there is no
1105 alias added to modprobe.conf (2.6 kernels) or modules.conf
1108 -Start 'system-config-network',
1109 -New->Wireless connection,
1110 +Start 'system-config-network',
1111 +New->Wireless connection,
1112 Select 'RaLink Ralink RT2500 802.11 Cardbus Reference Card (wlan0)'
1113 If it does not appear, well then it didn't work for you :)
1115 diff -Nur rt2500-1.1.0-b4/Module/TESTING rt2500-cvs-2007061011/Module/TESTING
1116 --- rt2500-1.1.0-b4/Module/TESTING 2006-06-17 22:12:58.000000000 +0200
1117 +++ rt2500-cvs-2007061011/Module/TESTING 2007-05-29 05:54:39.000000000 +0200
1119 -Below is information on how you can help out the team with testing
1120 -of the rt2500 kernel module.
1121 +Below are the steps you need to follow to help out the team with
1122 +testing/debugging of the rt2500 kernel module:
1124 -1. Get the latest source from the CVS tree. Easiest way todo this is to
1125 -get the nightly tarball from our website at
1126 - http://rt2x00.serialmonkey.com/rt2500-cvs-daily.tar.gz
1128 -2. Enable module debugging. Todo this run 'make clean' to remove any
1129 -compiled objects you have and then run 'make debug'.
1130 -This will recompile the Module with debugging turned on and reinstall
1131 -it over your existing module.
1133 -3. Install the module as per the INSTALL instructions.
1136 -4. Ensure there are no compies of the module in memory.
1140 -5. Load the module with full debug enabled using the commands
1141 - modprobe rt2500 debug=1
1143 -6. Check the output of your syslog (most likely /var/log/messages).
1144 -If you don't see any debug you need to add the following line to
1145 -your /etc/syslog.conf and reboot.
1146 - kern.* /var/log/debug
1148 -7. Any bugs/issues you find please report the following information
1149 -to the rt2400-devel mailing list
1150 - * Steps to reproduce
1151 - * The whole contents of your debugging output
1152 - * Your hardware architecture (i.e. x86, AMD64, Sparc)
1153 - * Your kernel version (i.e. 2.4.25 or 2.6.4)
1154 - * Your rt2400 hardware manufacturer and model
1155 - * Anything else you may think will help us resolve the issue
1156 - (even a patch if you are so inclined)
1158 -8. Sign up to the rt2400-devel mailing list and watch out for requests
1159 -for testing. Whenever we do major changes to the source and always
1160 -just before a release we will call for testing to be done before we
1161 -make the general release.
1163 +1. Get the latest source from the CVS tree.
1164 + Easiest way to do this is to download the hourly tarball from our website:
1165 + http://rt2x00.serialmonkey.com/rt2500-cvs-daily.tar.gz
1166 + Alternatively, you can anonymously check out the current CVS code:
1167 + $ cvs -d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400 login
1168 + $ cvs -z3 -d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400 \
1169 + co -P source/rt2500
1171 +2. Compile the module with debug logging:
1175 +3. Ensure there are no copies of the module left in memory:
1176 + # ifconfig ra0 down
1179 +4. Load the module with full debug enabled:
1180 + # insmod rt2500.ko debug=31
1181 + Then proceed as usual (config, ifup, etc)...
1183 +5. Check the debug output.
1184 + It is located in your system log file (most likely /var/log/debug or
1185 + /var/log/syslog). If you don't see any debug you probably need to add the
1186 + following line to your /etc/syslog.conf and reboot:
1187 + kern.=debug /var/log/debug
1188 + If you system hard-locks before it's able to log anything interesting
1189 + in these files, you'll have to rely on the netconsole module to remotely
1190 + log your kernel messages to another box (see netconsole.txt in your
1191 + kernel sources Documentation folder).
1193 +6. Report the following to the rt2400-devel mailing list (or rt2500 forum):
1194 + * Steps to reproduce the bug
1195 + * The _whole_content_ of your debugging output
1196 + * Your module details, i.e. the output of:
1197 + # modinfo rt2500.ko
1198 + * Your kernel details, i.e. the output of:
1200 + * Your rt2500 hardware manufacturer, model and revision
1201 + * Anything else you think may help us resolve the issue (even a patch if
1202 + you are so inclined)
1204 +7. Monitor the mailing list (or forum thread) for replies/further queries. :-)
1207 +Whenever we do major changes to the source - and always just before a release -
1208 +we will call for testing to be done before we make the general release. You're
1209 +very much welcome to help us with this testing and report any success/issue you
1210 +experience with this code.
1215 -AS PER STEP 7 ABOVE. Please provide the whole debug output. The last
1216 -few lines are hardly any good. If it's large (which it will be) then
1217 -GZip it and either upload it somewhere and give it a link or email
1218 -it directly to the developer you are working with.
1219 +AS PER STEP 6 ABOVE: Please provide the *whole* debug output! The last few lines
1220 +are hardly any good.
1221 +If it's large (which it will be) then GZip it. Either attach it to your forum
1222 +post or, if you're going to report via the mailing list, upload it somewhere and
1223 +give a link to it (or email it directly to the developer you are working with).
1227 diff -Nur rt2500-1.1.0-b4/Module/assoc.c rt2500-cvs-2007061011/Module/assoc.c
1228 --- rt2500-1.1.0-b4/Module/assoc.c 2006-06-17 22:12:58.000000000 +0200
1229 +++ rt2500-cvs-2007061011/Module/assoc.c 2007-03-21 05:25:34.000000000 +0100
1231 -/***************************************************************************
1232 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
1234 - * This program is free software; you can redistribute it and/or modify *
1235 - * it under the terms of the GNU General Public License as published by *
1236 - * the Free Software Foundation; either version 2 of the License, or *
1237 - * (at your option) any later version. *
1239 - * This program is distributed in the hope that it will be useful, *
1240 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
1241 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
1242 - * GNU General Public License for more details. *
1244 - * You should have received a copy of the GNU General Public License *
1245 - * along with this program; if not, write to the *
1246 - * Free Software Foundation, Inc., *
1247 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
1249 - * Licensed under the GNU GPL *
1250 - * Original code supplied under license from RaLink Inc, 2004. *
1251 - ***************************************************************************/
1253 - /***************************************************************************
1254 - * Module Name: assoc.c
1258 - * Revision History:
1260 - * -------- ----------- -----------------------------
1261 - * MarkW 8th Dec 04 Baseline code
1262 +/***************************************************************************
1263 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
1265 + * This program is free software; you can redistribute it and/or modify *
1266 + * it under the terms of the GNU General Public License as published by *
1267 + * the Free Software Foundation; either version 2 of the License, or *
1268 + * (at your option) any later version. *
1270 + * This program is distributed in the hope that it will be useful, *
1271 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
1272 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
1273 + * GNU General Public License for more details. *
1275 + * You should have received a copy of the GNU General Public License *
1276 + * along with this program; if not, write to the *
1277 + * Free Software Foundation, Inc., *
1278 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
1280 + * Licensed under the GNU GPL *
1281 + * Original code supplied under license from RaLink Inc, 2004. *
1282 + ***************************************************************************/
1284 + /***************************************************************************
1285 + * Module Name: assoc.c
1289 + * Revision History:
1291 + * -------- ----------- -----------------------------
1292 + * MarkW 8th Dec 04 Baseline code
1293 * MarkW 5th Jun 05 Fix no-SSID broadcasting assoc.
1294 - ***************************************************************************/
1295 + ***************************************************************************/
1297 #include "rt_config.h"
1301 UCHAR CipherSuiteWpaPskAesLen = (sizeof(CipherSuiteWpaPskAes) / sizeof(UCHAR));
1305 ==========================================================================
1308 association state machine init, including state transition and timer init
1311 S - pointer to the association state machine
1313 - The state machine looks like the following
1315 + The state machine looks like the following
1317 ASSOC_IDLE ASSOC_WAIT_RSP REASSOC_WAIT_RSP DISASSOC_WAIT_RSP
1318 MT2_MLME_ASSOC_REQ mlme_assoc_req_action invalid_state_when_assoc invalid_state_when_assoc invalid_state_when_assoc
1319 MT2_MLME_REASSOC_REQ mlme_reassoc_req_action invalid_state_when_reassoc invalid_state_when_reassoc invalid_state_when_reassoc
1321 ==========================================================================
1323 VOID AssocStateMachineInit(
1324 - IN PRTMP_ADAPTER pAd,
1325 - IN STATE_MACHINE *S,
1326 - OUT STATE_MACHINE_FUNC Trans[])
1327 + IN PRTMP_ADAPTER pAd,
1328 + IN STATE_MACHINE *S,
1329 + OUT STATE_MACHINE_FUNC Trans[])
1331 StateMachineInit(S, (STATE_MACHINE_FUNC*)Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, (STATE_MACHINE_FUNC)Drop, ASSOC_IDLE, ASSOC_MACHINE_BASE);
1334 StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)MlmeDisassocReqAction);
1335 StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
1336 // StateMachineSetAction(S, ASSOC_IDLE, MT2_CLS3ERR, (STATE_MACHINE_FUNC)Cls3errAction);
1340 StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
1341 StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
1342 @@ -151,14 +151,14 @@
1344 ==========================================================================
1346 - Association timeout procedure. After association timeout, this function
1347 + Association timeout procedure. After association timeout, this function
1348 will be called and it will put a message into the MLME queue
1350 Standard timer parameters
1351 ==========================================================================
1354 - IN unsigned long data)
1355 + IN unsigned long data)
1357 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
1358 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - enqueue MT2_ASSOC_TIMEOUT \n");
1359 @@ -169,14 +169,14 @@
1361 ==========================================================================
1363 - Reassociation timeout procedure. After reassociation timeout, this
1364 + Reassociation timeout procedure. After reassociation timeout, this
1365 function will be called and put a message into the MLME queue
1367 Standard timer parameters
1368 ==========================================================================
1370 VOID ReassocTimeout(
1371 - IN unsigned long data)
1372 + IN unsigned long data)
1374 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
1375 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - enqueue MT2_REASSOC_TIMEOUT \n");
1376 @@ -187,14 +187,14 @@
1378 ==========================================================================
1380 - Disassociation timeout procedure. After disassociation timeout, this
1381 + Disassociation timeout procedure. After disassociation timeout, this
1382 function will be called and put a message into the MLME queue
1384 Standard timer parameters
1385 ==========================================================================
1387 VOID DisassocTimeout(
1388 - IN unsigned long data)
1389 + IN unsigned long data)
1391 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
1392 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - enqueue MT2_DISASSOC_TIMEOUT \n");
1394 ==========================================================================
1396 VOID MlmeAssocReqAction(
1397 - IN PRTMP_ADAPTER pAd,
1398 - IN MLME_QUEUE_ELEM *Elem)
1399 + IN PRTMP_ADAPTER pAd,
1400 + IN MLME_QUEUE_ELEM *Elem)
1405 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Block Assoc request durning WPA block period!\n");
1406 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1407 MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_STATE_MACHINE_REJECT);
1410 // check sanity first
1411 - else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, &ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
1412 + else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, &ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
1414 RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer);
1415 COPY_MAC_ADDR(&pAd->Mlme.AssocAux.Addr, &ApAddr);
1416 @@ -255,23 +255,23 @@
1417 pAd->Mlme.AssocAux.ListenIntv = ListenIntv;
1419 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
1420 - if (NStatus != NDIS_STATUS_SUCCESS)
1421 + if (NStatus != NDIS_STATUS_SUCCESS)
1423 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeAssocReqAction() allocate memory failed \n");
1424 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1425 MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_FAIL_NO_RESOURCE);
1430 // Add by James 03/06/27
1431 pAd->PortCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); //+ sizeof(NDIS_802_11_FIXED_IEs); // Filled in assoc request
1432 pAd->PortCfg.AssocInfo.AvailableRequestFixedIEs =
1433 NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL | NDIS_802_11_AI_REQFI_CURRENTAPADDRESS;
1434 pAd->PortCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo;
1435 - pAd->PortCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
1436 + pAd->PortCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
1437 memcpy(pAd->PortCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, &AssocHdr, sizeof(NDIS_802_11_MAC_ADDRESS));
1438 pAd->PortCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); // No request Variables IEs
1443 memcpy(pAd->PortCfg.ReqVarIEs + VarIesOffset, &SsidIe, 1);
1448 - 1, &pAd->Mlme.SyncAux.SsidLen,
1449 + 1, &pAd->Mlme.SyncAux.SsidLen,
1450 pAd->Mlme.SyncAux.SsidLen, pAd->Mlme.SyncAux.Ssid,
1452 1, &pAd->PortCfg.SupRateLen,
1453 @@ -310,11 +310,11 @@
1454 MakeOutgoingFrame(OutBuffer + FrameLen, &tmp,
1456 1, &pAd->PortCfg.ExtRateLen,
1457 - pAd->PortCfg.ExtRateLen, pAd->PortCfg.ExtRate,
1458 + pAd->PortCfg.ExtRateLen, pAd->PortCfg.ExtRate,
1464 if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) && (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled))
1466 MakeOutgoingFrame(OutBuffer + FrameLen, &tmp,
1468 CipherSuiteWpaTkipLen, &CipherSuiteWpaTkip[0],
1473 // Add by James 03/06/27
1475 memcpy(pAd->PortCfg.ReqVarIEs + VarIesOffset, &WpaIe, 1);
1478 // OffsetResponseIEs follow ReqVarIE
1479 pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;
1480 - // End Add by James
1481 + // End Add by James
1485 else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) && (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled))
1487 MakeOutgoingFrame(OutBuffer + FrameLen, &tmp,
1489 CipherSuiteWpaAesLen, &CipherSuiteWpaAes[0],
1494 // Add by James 03/06/27
1496 memcpy(pAd->PortCfg.ReqVarIEs + VarIesOffset, &WpaIe, 1);
1499 // OffsetResponseIEs follow ReqVarIE
1500 pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;
1501 - // End Add by James
1502 + // End Add by James
1504 else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK) && (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled))
1508 // OffsetResponseIEs follow ReqVarIE
1509 pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;
1510 - // End Add by James
1511 + // End Add by James
1513 else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK) && (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled))
1517 // OffsetResponseIEs follow ReqVarIE
1518 pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;
1519 - // End Add by James
1520 + // End Add by James
1524 @@ -429,14 +429,14 @@
1526 // OffsetResponseIEs follow ReqVarIE
1527 pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;
1528 - // End Add by James
1529 + // End Add by James
1531 MiniportMMRequest(pAd, OutBuffer, FrameLen);
1534 RTMPSetTimer(pAd, &pAd->Mlme.AssocAux.AssocTimer, Timeout);
1535 pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
1541 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n");
1542 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1545 mlme reassoc req handling procedure
1550 -# SSID (Adapter->PortCfg.ssid[])
1551 -# BSSID (AP address, Adapter->PortCfg.bssid)
1553 ==========================================================================
1555 VOID MlmeReassocReqAction(
1556 - IN PRTMP_ADAPTER pAd,
1557 - IN MLME_QUEUE_ELEM *Elem)
1558 + IN PRTMP_ADAPTER pAd,
1559 + IN MLME_QUEUE_ELEM *Elem)
1563 @@ -479,14 +479,14 @@
1564 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Block ReAssoc request durning WPA block period!\n");
1565 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1566 MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_STATE_MACHINE_REJECT);
1569 // the parameters are the same as the association
1570 - else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, &ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
1571 + else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, &ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
1573 RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer);
1575 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
1576 - if(NStatus != NDIS_STATUS_SUCCESS)
1577 + if(NStatus != NDIS_STATUS_SUCCESS)
1579 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeReassocReqAction() allocate memory failed \n");
1580 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1583 ETH_ALEN, &pAd->PortCfg.Bssid,
1585 - 1, &pAd->PortCfg.SsidLen,
1586 - pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
1587 + 1, &pAd->PortCfg.SsidLen,
1588 + pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
1590 1, &pAd->PortCfg.SupRateLen,
1591 pAd->PortCfg.SupRateLen, pAd->PortCfg.SupRate,
1592 @@ -520,16 +520,16 @@
1593 MakeOutgoingFrame(OutBuffer + FrameLen, &tmp,
1595 1, &pAd->PortCfg.ExtRateLen,
1596 - pAd->PortCfg.ExtRateLen, pAd->PortCfg.ExtRate,
1597 + pAd->PortCfg.ExtRateLen, pAd->PortCfg.ExtRate,
1601 MiniportMMRequest(pAd, OutBuffer, FrameLen);
1604 RTMPSetTimer(pAd, &pAd->Mlme.AssocAux.ReassocTimer, Timeout); /* in mSec */
1605 pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
1611 DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n");
1612 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1614 ==========================================================================
1616 VOID MlmeDisassocReqAction(
1617 - IN PRTMP_ADAPTER pAd,
1618 - IN MLME_QUEUE_ELEM *Elem)
1619 + IN PRTMP_ADAPTER pAd,
1620 + IN MLME_QUEUE_ELEM *Elem)
1622 MLME_DISASSOC_REQ_STRUCT *DisassocReq;
1624 @@ -560,25 +560,25 @@
1625 DisassocReq = (MLME_DISASSOC_REQ_STRUCT *)(Elem->Msg);
1627 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
1628 - if (NStatus != NDIS_STATUS_SUCCESS)
1629 + if (NStatus != NDIS_STATUS_SUCCESS)
1631 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - MlmeDisassocReqAction() allocate memory failed\n");
1632 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1633 MlmeCntlConfirm(pAd, MT2_DISASSOC_CONF, MLME_FAIL_NO_RESOURCE);
1638 RTMPCancelTimer(&pAd->Mlme.AssocAux.DisassocTimer);
1641 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Send DISASSOC request\n");
1642 MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, &pAd->PortCfg.Bssid, &pAd->PortCfg.Bssid);
1643 - MakeOutgoingFrame(OutBuffer, &FrameLen,
1644 - sizeof(MACHDR), &DisassocHdr,
1645 - 2, &DisassocReq->Reason,
1646 + MakeOutgoingFrame(OutBuffer, &FrameLen,
1647 + sizeof(MACHDR), &DisassocHdr,
1648 + 2, &DisassocReq->Reason,
1650 MiniportMMRequest(pAd, OutBuffer, FrameLen);
1651 memset(&(pAd->PortCfg.Bssid), 0, ETH_ALEN);
1654 pAd->PortCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
1655 COPY_MAC_ADDR(&pAd->PortCfg.DisassocSta, &DisassocReq->Addr);
1657 @@ -595,31 +595,31 @@
1658 ==========================================================================
1660 VOID PeerAssocRspAction(
1661 - IN PRTMP_ADAPTER pAd,
1662 - IN MLME_QUEUE_ELEM *Elem)
1663 + IN PRTMP_ADAPTER pAd,
1664 + IN MLME_QUEUE_ELEM *Elem)
1666 USHORT CapabilityInfo, Status, Aid;
1667 UCHAR Rates[MAX_LEN_OF_SUPPORTED_RATES], RatesLen;
1669 BOOLEAN ExtendedRateIeExist;
1671 - if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &CapabilityInfo, &Status, &Aid, Rates, &RatesLen, &ExtendedRateIeExist))
1672 + if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &CapabilityInfo, &Status, &Aid, Rates, &RatesLen, &ExtendedRateIeExist))
1674 // The frame is for me ?
1675 - if(MAC_ADDR_EQUAL(&Addr2, &pAd->Mlme.AssocAux.Addr))
1676 + if(MAC_ADDR_EQUAL(&Addr2, &pAd->Mlme.AssocAux.Addr))
1678 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status);
1679 RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer);
1680 - if(Status == MLME_SUCCESS)
1681 + if(Status == MLME_SUCCESS)
1683 // go to procedure listed on page 376
1684 // Mask out unnecessary capability information
1685 CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; // pAd->PortCfg.SupportedCapabilityInfo;
1686 AssocPostProc(pAd, &Addr2, CapabilityInfo, Aid, Rates, RatesLen, ExtendedRateIeExist);
1689 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1690 MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, Status);
1697 ==========================================================================
1699 VOID PeerReassocRspAction(
1700 - IN PRTMP_ADAPTER pAd,
1701 - IN MLME_QUEUE_ELEM *Elem)
1702 + IN PRTMP_ADAPTER pAd,
1703 + IN MLME_QUEUE_ELEM *Elem)
1705 USHORT CapabilityInfo;
1707 @@ -647,24 +647,24 @@
1709 BOOLEAN ExtendedRateIeExist;
1711 - if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &CapabilityInfo, &Status, &Aid, Rates, &RatesLen, &ExtendedRateIeExist))
1712 + if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &CapabilityInfo, &Status, &Aid, Rates, &RatesLen, &ExtendedRateIeExist))
1714 if(MAC_ADDR_EQUAL(&Addr2, &pAd->Mlme.AssocAux.Addr)) // The frame is for me ?
1716 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status);
1717 RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer);
1719 - if(Status == MLME_SUCCESS)
1721 + if(Status == MLME_SUCCESS)
1723 // Mask out unnecessary capability information
1724 CapabilityInfo &= SUPPORTED_CAPABILITY_INFO; // pAd->PortCfg.SupportedCapabilityInfo;
1725 // go to procedure listed on page 376
1726 AssocPostProc(pAd, &Addr2, CapabilityInfo, Aid, Rates, RatesLen, ExtendedRateIeExist);
1730 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1731 MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, Status);
1737 @@ -675,28 +675,28 @@
1739 ==========================================================================
1741 - procedures on IEEE 802.11/1999 p.376
1742 + procedures on IEEE 802.11/1999 p.376
1744 ==========================================================================
1747 - IN PRTMP_ADAPTER pAd,
1748 - IN PMACADDR Addr2,
1749 - IN USHORT CapabilityInfo,
1752 + IN PRTMP_ADAPTER pAd,
1753 + IN PMACADDR Addr2,
1754 + IN USHORT CapabilityInfo,
1758 - IN BOOLEAN ExtendedRateIeExist)
1759 + IN BOOLEAN ExtendedRateIeExist)
1762 UCHAR RateIe = IE_SUPP_RATES;
1765 - // 2003/12/11 - skip the following because experiment show that we can not
1766 + // 2003/12/11 - skip the following because experiment show that we can not
1767 // trust the "privacy" bit in AssocRsp. We can only trust "Privacy" bit specified in
1768 // BEACON and ProbeRsp.
1769 // pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(CapabilityInfo);
1772 pAd->PortCfg.Aid = Aid;
1773 memcpy(pAd->PortCfg.SupportedRates, Rates, RatesLen);
1774 pAd->PortCfg.SupportedRatesLen = RatesLen;
1777 // Set New WPA information
1778 Idx = BssTableSearch(&pAd->PortCfg.BssTab, Addr2);
1779 - if (Idx == BSS_NOT_FOUND)
1780 + if (Idx == BSS_NOT_FOUND)
1782 DBGPRINT(RT_DEBUG_ERROR, "ASSOC - Can't find BSS after receiving Assoc response\n");
1786 memcpy(pAd->PortCfg.ResVarIEs + VarIesOffset, pAd->PortCfg.BssTab.BssEntry[Idx].VarIEs, pAd->PortCfg.BssTab.BssEntry[Idx].VarIELen);
1787 VarIesOffset += pAd->PortCfg.BssTab.BssEntry[Idx].VarIELen;
1790 // Set Variable IEs Length
1791 pAd->PortCfg.ResVarIELen = VarIesOffset;
1792 pAd->PortCfg.AssocInfo.ResponseIELength = VarIesOffset;
1793 @@ -747,22 +747,22 @@
1795 ==========================================================================
1797 - left part of IEEE 802.11/1999 p.374
1798 + left part of IEEE 802.11/1999 p.374
1800 Elem - MLME message containing the received frame
1801 ==========================================================================
1803 VOID PeerDisassocAction(
1804 - IN PRTMP_ADAPTER pAd,
1805 - IN MLME_QUEUE_ELEM *Elem)
1806 + IN PRTMP_ADAPTER pAd,
1807 + IN MLME_QUEUE_ELEM *Elem)
1812 - if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Reason))
1813 + if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Reason))
1815 - if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(&pAd->PortCfg.Bssid, &Addr2))
1817 + if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(&pAd->PortCfg.Bssid, &Addr2))
1820 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1823 ==========================================================================
1825 VOID AssocTimeoutAction(
1826 - IN PRTMP_ADAPTER pAd,
1827 - IN MLME_QUEUE_ELEM *Elem)
1828 + IN PRTMP_ADAPTER pAd,
1829 + IN MLME_QUEUE_ELEM *Elem)
1831 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - AssocTimeoutAction\n");
1832 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1834 ==========================================================================
1836 VOID ReassocTimeoutAction(
1837 - IN PRTMP_ADAPTER pAd,
1838 - IN MLME_QUEUE_ELEM *Elem)
1839 + IN PRTMP_ADAPTER pAd,
1840 + IN MLME_QUEUE_ELEM *Elem)
1842 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - ReassocTimeoutAction\n");
1843 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1845 ==========================================================================
1847 VOID DisassocTimeoutAction(
1848 - IN PRTMP_ADAPTER pAd,
1849 - IN MLME_QUEUE_ELEM *Elem)
1850 + IN PRTMP_ADAPTER pAd,
1851 + IN MLME_QUEUE_ELEM *Elem)
1853 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - DisassocTimeoutAction\n");
1854 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1855 @@ -825,30 +825,30 @@
1858 VOID InvalidStateWhenAssoc(
1859 - IN PRTMP_ADAPTER pAd,
1860 - IN MLME_QUEUE_ELEM *Elem)
1861 + IN PRTMP_ADAPTER pAd,
1862 + IN MLME_QUEUE_ELEM *Elem)
1864 - DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenAssoc(state=%d), reset ASSOC state machine\n",
1865 + DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenAssoc(state=%d), reset ASSOC state machine\n",
1866 pAd->Mlme.AssocMachine.CurrState);
1867 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1868 MlmeCntlConfirm(pAd, MT2_ASSOC_CONF, MLME_STATE_MACHINE_REJECT);
1871 VOID InvalidStateWhenReassoc(
1872 - IN PRTMP_ADAPTER pAd,
1873 - IN MLME_QUEUE_ELEM *Elem)
1874 + IN PRTMP_ADAPTER pAd,
1875 + IN MLME_QUEUE_ELEM *Elem)
1877 - DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenReassoc(state=%d), reset ASSOC state machine\n",
1878 + DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenReassoc(state=%d), reset ASSOC state machine\n",
1879 pAd->Mlme.AssocMachine.CurrState);
1880 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1881 MlmeCntlConfirm(pAd, MT2_REASSOC_CONF, MLME_STATE_MACHINE_REJECT);
1884 VOID InvalidStateWhenDisassociate(
1885 - IN PRTMP_ADAPTER pAd,
1886 - IN MLME_QUEUE_ELEM *Elem)
1887 + IN PRTMP_ADAPTER pAd,
1888 + IN MLME_QUEUE_ELEM *Elem)
1890 - DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenDisassoc(state=%d), reset ASSOC state machine\n",
1891 + DBGPRINT(RT_DEBUG_TRACE, "ASSOC - InvalidStateWhenDisassoc(state=%d), reset ASSOC state machine\n",
1892 pAd->Mlme.AssocMachine.CurrState);
1893 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1894 MlmeCntlConfirm(pAd, MT2_DISASSOC_CONF, MLME_STATE_MACHINE_REJECT);
1895 @@ -858,15 +858,15 @@
1896 ==========================================================================
1898 right part of IEEE 802.11/1999 page 374
1901 This event should never cause ASSOC state machine perform state
1902 transition, and has no relationship with CNTL machine. So we separate
1903 this routine as a service outside of ASSOC state transition table.
1904 ==========================================================================
1907 - IN PRTMP_ADAPTER pAd,
1908 - IN PMACADDR pAddr)
1909 + IN PRTMP_ADAPTER pAd,
1910 + IN PMACADDR pAddr)
1913 CHAR *OutBuffer = NULL;
1914 @@ -875,19 +875,19 @@
1915 USHORT Reason = REASON_CLS3ERR;
1917 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
1918 - if (NStatus != NDIS_STATUS_SUCCESS)
1919 + if (NStatus != NDIS_STATUS_SUCCESS)
1923 DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Class 3 Error, Send DISASSOC frame\n");
1924 MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, &pAd->PortCfg.Bssid);
1925 - MakeOutgoingFrame(OutBuffer, &FrameLen,
1926 - sizeof(MACHDR), &DisassocHdr,
1928 + MakeOutgoingFrame(OutBuffer, &FrameLen,
1929 + sizeof(MACHDR), &DisassocHdr,
1932 MiniportMMRequest(pAd, OutBuffer, FrameLen);
1934 pAd->PortCfg.DisassocReason = REASON_CLS3ERR;
1935 COPY_MAC_ADDR(&pAd->PortCfg.DisassocSta, pAddr);
1940 diff -Nur rt2500-1.1.0-b4/Module/auth.c rt2500-cvs-2007061011/Module/auth.c
1941 --- rt2500-1.1.0-b4/Module/auth.c 2006-06-17 22:12:58.000000000 +0200
1942 +++ rt2500-cvs-2007061011/Module/auth.c 2007-05-06 11:13:44.000000000 +0200
1944 -/***************************************************************************
1945 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
1947 - * This program is free software; you can redistribute it and/or modify *
1948 - * it under the terms of the GNU General Public License as published by *
1949 - * the Free Software Foundation; either version 2 of the License, or *
1950 - * (at your option) any later version. *
1952 - * This program is distributed in the hope that it will be useful, *
1953 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
1954 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
1955 - * GNU General Public License for more details. *
1957 - * You should have received a copy of the GNU General Public License *
1958 - * along with this program; if not, write to the *
1959 - * Free Software Foundation, Inc., *
1960 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
1962 - * Licensed under the GNU GPL *
1963 - * Original code supplied under license from RaLink Inc, 2004. *
1964 - ***************************************************************************/
1966 - /***************************************************************************
1967 - * Module Name: auth.c
1971 - * Revision History:
1973 - * -------- ----------- -----------------------------
1974 - * MarkW 8th Dec 04 Baseline code
1975 - ***************************************************************************/
1976 +/***************************************************************************
1977 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
1979 + * This program is free software; you can redistribute it and/or modify *
1980 + * it under the terms of the GNU General Public License as published by *
1981 + * the Free Software Foundation; either version 2 of the License, or *
1982 + * (at your option) any later version. *
1984 + * This program is distributed in the hope that it will be useful, *
1985 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
1986 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
1987 + * GNU General Public License for more details. *
1989 + * You should have received a copy of the GNU General Public License *
1990 + * along with this program; if not, write to the *
1991 + * Free Software Foundation, Inc., *
1992 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
1994 + * Licensed under the GNU GPL *
1995 + * Original code supplied under license from RaLink Inc, 2004. *
1996 + ***************************************************************************/
1998 + /***************************************************************************
1999 + * Module Name: auth.c
2003 + * Revision History:
2005 + * -------- ----------- -----------------------------
2006 + * MarkW 8th Dec 04 Baseline code
2007 + ***************************************************************************/
2009 #include "rt_config.h"
2012 Sm - pointer to the auth state machine
2014 The state machine looks like this
2017 AUTH_REQ_IDLE AUTH_WAIT_SEQ2 AUTH_WAIT_SEQ4
2018 MT2_MLME_AUTH_REQ mlme_auth_req_action invalid_state_when_auth invalid_state_when_auth
2019 MT2_MLME_DEAUTH_REQ mlme_deauth_req_action mlme_deauth_req_action mlme_deauth_req_action
2023 void AuthStateMachineInit(
2024 - IN PRTMP_ADAPTER pAd,
2025 - IN STATE_MACHINE *Sm,
2026 - OUT STATE_MACHINE_FUNC Trans[])
2027 + IN PRTMP_ADAPTER pAd,
2028 + IN STATE_MACHINE *Sm,
2029 + OUT STATE_MACHINE_FUNC Trans[])
2031 StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_AUTH_STATE, MAX_AUTH_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_REQ_IDLE, AUTH_MACHINE_BASE);
2035 StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)MlmeAuthReqAction);
2036 // StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_DEAUTH_REQ, (STATE_MACHINE_FUNC)MlmeDeauthReqAction);
2038 // StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_CLS2ERR, (STATE_MACHINE_FUNC)Cls2errAction);
2039 StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq2Action);
2040 StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
2044 StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
2045 // StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_DEAUTH_REQ, (STATE_MACHINE_FUNC)MlmeDeauthReqAction);
2046 // StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_CLS2ERR, (STATE_MACHINE_FUNC)Cls2errAction);
2047 StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq4Action);
2048 StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
2051 RTMPInitTimer(pAd, &pAd->Mlme.AuthAux.AuthTimer, AuthTimeout);
2055 IN unsigned long data)
2057 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
2060 DBGPRINT(RT_DEBUG_TRACE,"AUTH - AuthTimeout\n");
2061 MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
2064 ==========================================================================
2066 VOID MlmeAuthReqAction(
2067 - IN PRTMP_ADAPTER pAd,
2068 - IN MLME_QUEUE_ELEM *Elem)
2069 + IN PRTMP_ADAPTER pAd,
2070 + IN MLME_QUEUE_ELEM *Elem)
2073 USHORT Alg, Seq, Status;
2074 @@ -121,16 +121,15 @@
2075 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2076 MlmeCntlConfirm(pAd, MT2_AUTH_CONF, MLME_STATE_MACHINE_REJECT);
2078 - else if(MlmeAuthReqSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr, &Timeout, &Alg))
2079 + else if(MlmeAuthReqSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr, &Timeout, &Alg))
2082 - RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer);
2083 + RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer);
2084 pAd->Mlme.AuthAux.Addr = Addr;
2085 pAd->Mlme.AuthAux.Alg = Alg;
2086 pAd->PortCfg.Mauth = FALSE;
2088 Status = MLME_SUCCESS;
2091 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
2092 if(NStatus != NDIS_STATUS_SUCCESS)
2094 @@ -142,18 +141,18 @@
2096 DBGPRINT(RT_DEBUG_TRACE, "AUTH - Send AUTH request seq#1 (Alg=%d)...\n", Alg);
2097 MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, &Addr, &pAd->PortCfg.Bssid);
2098 - MakeOutgoingFrame(OutBuffer, &FrameLen,
2099 - MAC_HDR_LEN, &AuthHdr,
2103 + MakeOutgoingFrame(OutBuffer, &FrameLen,
2104 + MAC_HDR_LEN, &AuthHdr,
2109 MiniportMMRequest(pAd, OutBuffer, FrameLen);
2111 RTMPSetTimer(pAd, &pAd->Mlme.AuthAux.AuthTimer, Timeout);
2112 pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
2118 printk(KERN_ERR DRV_NAME "AUTH - MlmeAuthReqAction() sanity check failed. BUG!!!!!\n");
2119 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2121 ==========================================================================
2123 VOID PeerAuthRspAtSeq2Action(
2124 - IN PRTMP_ADAPTER pAd,
2125 - IN MLME_QUEUE_ELEM *Elem)
2126 + IN PRTMP_ADAPTER pAd,
2127 + IN MLME_QUEUE_ELEM *Elem)
2130 USHORT Seq, Status, RemoteStatus, Alg;
2131 @@ -180,21 +179,21 @@
2132 NDIS_STATUS NStatus;
2135 - if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Alg, &Seq, &Status, ChlgText))
2136 + if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Alg, &Seq, &Status, ChlgText))
2138 - if (MAC_ADDR_EQUAL(&pAd->Mlme.AuthAux.Addr, &Addr2) && Seq == 2)
2139 + if (MAC_ADDR_EQUAL(&pAd->Mlme.AuthAux.Addr, &Addr2) && Seq == 2)
2141 DBGPRINT(RT_DEBUG_TRACE, "AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n", Alg, Status);
2142 RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer);
2144 - if (Status == MLME_SUCCESS)
2146 + if (Status == MLME_SUCCESS)
2148 - if (pAd->Mlme.AuthAux.Alg == Ndis802_11AuthModeOpen)
2149 + if (pAd->Mlme.AuthAux.Alg == Ndis802_11AuthModeOpen)
2151 pAd->PortCfg.Mauth = TRUE;
2152 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2153 MlmeCntlConfirm(pAd, MT2_AUTH_CONF, MLME_SUCCESS);
2158 // 2. shared key, need to be challenged
2160 MlmeCntlConfirm(pAd, MT2_AUTH_CONF, MLME_FAIL_NO_RESOURCE);
2165 DBGPRINT(RT_DEBUG_TRACE, "AUTH - Send AUTH request seq#3...\n");
2166 MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, &Addr2, &pAd->PortCfg.Bssid);
2169 RTMPEncryptData(pAd, Element, CyperChlgText + 10, 2);
2170 RTMPEncryptData(pAd, ChlgText, CyperChlgText + 12, 128);
2171 RTMPSetICV(pAd, CyperChlgText + 140);
2172 - MakeOutgoingFrame(OutBuffer, &FrameLen,
2173 - MAC_HDR_LEN, &AuthHdr,
2174 - CIPHER_TEXT_LEN + 16, CyperChlgText,
2175 + MakeOutgoingFrame(OutBuffer, &FrameLen,
2176 + MAC_HDR_LEN, &AuthHdr,
2177 + CIPHER_TEXT_LEN + 16, CyperChlgText,
2179 MiniportMMRequest(pAd, OutBuffer, FrameLen);
2182 RTMPSetTimer(pAd, &pAd->Mlme.AuthAux.AuthTimer, AUTH_TIMEOUT);
2183 pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ4;
2190 pAd->PortCfg.AuthFailReason = Status;
2191 COPY_MAC_ADDR(&pAd->PortCfg.AuthFailSta, &Addr2);
2192 @@ -267,29 +266,29 @@
2193 ==========================================================================
2195 VOID PeerAuthRspAtSeq4Action(
2196 - IN PRTMP_ADAPTER pAd,
2197 - IN MLME_QUEUE_ELEM *Elem)
2198 + IN PRTMP_ADAPTER pAd,
2199 + IN MLME_QUEUE_ELEM *Elem)
2202 USHORT Alg, Seq, Status;
2203 CHAR ChlgText[CIPHER_TEXT_LEN];
2205 - if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Alg, &Seq, &Status, ChlgText))
2206 + if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Alg, &Seq, &Status, ChlgText))
2208 - if(MAC_ADDR_EQUAL(&(pAd->Mlme.AuthAux.Addr), &Addr2) && Seq == 4)
2209 + if(MAC_ADDR_EQUAL(&(pAd->Mlme.AuthAux.Addr), &Addr2) && Seq == 4)
2211 DBGPRINT(RT_DEBUG_TRACE, "AUTH - Receive AUTH_RSP seq#4 to me\n");
2212 RTMPCancelTimer(&pAd->Mlme.AuthAux.AuthTimer);
2214 - if(Status == MLME_SUCCESS)
2216 + if(Status == MLME_SUCCESS)
2218 pAd->PortCfg.Mauth = TRUE;
2224 pAd->PortCfg.AuthFailReason = Status;
2225 pAd->PortCfg.AuthFailSta = Addr2;
2229 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2230 MlmeCntlConfirm(pAd, MT2_AUTH_CONF, Status);
2232 ==========================================================================
2234 VOID MlmeDeauthReqAction(
2235 - IN PRTMP_ADAPTER pAd,
2236 - IN MLME_QUEUE_ELEM *Elem)
2237 + IN PRTMP_ADAPTER pAd,
2238 + IN MLME_QUEUE_ELEM *Elem)
2240 MLME_DEAUTH_REQ_STRUCT *Info;
2242 @@ -329,12 +328,12 @@
2244 DBGPRINT(RT_DEBUG_TRACE, "AUTH - Send DE-AUTH request...\n");
2245 MgtMacHeaderInit(pAd, &Hdr, SUBTYPE_DEAUTH, 0, &Info->Addr, &pAd->PortCfg.Bssid);
2246 - MakeOutgoingFrame(OutBuffer, &FrameLen,
2247 - sizeof(MACHDR), &Hdr,
2249 + MakeOutgoingFrame(OutBuffer, &FrameLen,
2250 + sizeof(MACHDR), &Hdr,
2253 MiniportMMRequest(pAd, OutBuffer, FrameLen);
2256 pAd->PortCfg.DeauthReason = Info->Reason;
2257 COPY_MAC_ADDR(&pAd->PortCfg.DeauthSta, &Info->Addr);
2258 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2260 ==========================================================================
2262 VOID AuthTimeoutAction(
2263 - IN PRTMP_ADAPTER pAd,
2264 - IN MLME_QUEUE_ELEM *Elem)
2265 + IN PRTMP_ADAPTER pAd,
2266 + IN MLME_QUEUE_ELEM *Elem)
2268 DBGPRINT(RT_DEBUG_TRACE, "AUTH - AuthTimeoutAction\n");
2269 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2271 ==========================================================================
2273 VOID InvalidStateWhenAuth(
2274 - IN PRTMP_ADAPTER pAd,
2275 - IN MLME_QUEUE_ELEM *Elem)
2276 + IN PRTMP_ADAPTER pAd,
2277 + IN MLME_QUEUE_ELEM *Elem)
2279 DBGPRINT(RT_DEBUG_TRACE, "AUTH - InvalidStateWhenAuth (state=%d), reset AUTH state machine\n", pAd->Mlme.AuthMachine.CurrState);
2280 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
2281 @@ -379,24 +378,24 @@
2282 ==========================================================================
2285 - IN PRTMP_ADAPTER pAd,
2286 - IN PMACADDR pAddr)
2287 + IN PRTMP_ADAPTER pAd,
2288 + IN PMACADDR pAddr)
2291 UCHAR *OutBuffer = NULL;
2292 NDIS_STATUS NStatus;
2294 USHORT Reason = REASON_CLS2ERR;
2297 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
2298 if (NStatus != NDIS_STATUS_SUCCESS)
2301 DBGPRINT(RT_DEBUG_TRACE, "AUTH - Class 2 error, Send DEAUTH frame...\n");
2302 MgtMacHeaderInit(pAd, &Hdr, SUBTYPE_DEAUTH, 0, pAddr, &pAd->PortCfg.Bssid);
2303 - MakeOutgoingFrame(OutBuffer, &FrameLen,
2304 - sizeof(MACHDR), &Hdr,
2306 + MakeOutgoingFrame(OutBuffer, &FrameLen,
2307 + sizeof(MACHDR), &Hdr,
2310 MiniportMMRequest(pAd, OutBuffer, FrameLen);
2312 diff -Nur rt2500-1.1.0-b4/Module/auth_rsp.c rt2500-cvs-2007061011/Module/auth_rsp.c
2313 --- rt2500-1.1.0-b4/Module/auth_rsp.c 2006-06-17 22:12:58.000000000 +0200
2314 +++ rt2500-cvs-2007061011/Module/auth_rsp.c 2007-03-21 05:25:34.000000000 +0100
2316 -/***************************************************************************
2317 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
2319 - * This program is free software; you can redistribute it and/or modify *
2320 - * it under the terms of the GNU General Public License as published by *
2321 - * the Free Software Foundation; either version 2 of the License, or *
2322 - * (at your option) any later version. *
2324 - * This program is distributed in the hope that it will be useful, *
2325 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
2326 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
2327 - * GNU General Public License for more details. *
2329 - * You should have received a copy of the GNU General Public License *
2330 - * along with this program; if not, write to the *
2331 - * Free Software Foundation, Inc., *
2332 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
2334 - * Licensed under the GNU GPL *
2335 - * Original code supplied under license from RaLink Inc, 2004. *
2336 - ***************************************************************************/
2338 - /***************************************************************************
2339 - * Module Name: auth_rsp.c
2343 - * Revision History:
2345 - * -------- ----------- -----------------------------
2346 - * MarkW 8th Dec 04 Baseline code
2347 - ***************************************************************************/
2348 +/***************************************************************************
2349 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
2351 + * This program is free software; you can redistribute it and/or modify *
2352 + * it under the terms of the GNU General Public License as published by *
2353 + * the Free Software Foundation; either version 2 of the License, or *
2354 + * (at your option) any later version. *
2356 + * This program is distributed in the hope that it will be useful, *
2357 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
2358 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
2359 + * GNU General Public License for more details. *
2361 + * You should have received a copy of the GNU General Public License *
2362 + * along with this program; if not, write to the *
2363 + * Free Software Foundation, Inc., *
2364 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
2366 + * Licensed under the GNU GPL *
2367 + * Original code supplied under license from RaLink Inc, 2004. *
2368 + ***************************************************************************/
2370 + /***************************************************************************
2371 + * Module Name: auth_rsp.c
2375 + * Revision History:
2377 + * -------- ----------- -----------------------------
2378 + * MarkW 8th Dec 04 Baseline code
2379 + ***************************************************************************/
2381 #include "rt_config.h"
2385 Sm - the state machine
2387 - the state machine looks like the following
2389 + the state machine looks like the following
2391 AUTH_RSP_IDLE AUTH_RSP_WAIT_CHAL
2392 MT2_AUTH_CHALLENGE_TIMEOUT auth_rsp_challenge_timeout_action auth_rsp_challenge_timeout_action
2393 MT2_PEER_AUTH_ODD peer_auth_at_auth_rsp_idle_action peer_auth_at_auth_rsp_wait_action
2395 ==========================================================================
2397 VOID AuthRspStateMachineInit(
2398 - IN PRTMP_ADAPTER pAd,
2399 - IN PSTATE_MACHINE Sm,
2400 - IN STATE_MACHINE_FUNC Trans[])
2401 + IN PRTMP_ADAPTER pAd,
2402 + IN PSTATE_MACHINE Sm,
2403 + IN STATE_MACHINE_FUNC Trans[])
2408 ==========================================================================
2410 VOID AuthRspChallengeTimeout(
2411 - IN unsigned long data)
2412 + IN unsigned long data)
2414 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
2417 DBGPRINT(RT_DEBUG_TRACE,"AUTH_RSP - AuthRspChallengeTimeout \n");
2418 MlmeEnqueue(&pAd->Mlme.Queue, AUTH_RSP_STATE_MACHINE, MT2_AUTH_CHALLENGE_TIMEOUT, 0, NULL);
2421 ==========================================================================
2423 VOID PeerAuthSimpleRspGenAndSend(
2424 - IN PRTMP_ADAPTER pAd,
2430 + IN PRTMP_ADAPTER pAd,
2439 @@ -118,11 +118,11 @@
2441 DBGPRINT(RT_DEBUG_TRACE, "Send AUTH response (seq#2)...\n");
2442 MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, &Hdr->Addr2, &pAd->PortCfg.Bssid);
2443 - MakeOutgoingFrame(OutBuffer, &FrameLen,
2444 - sizeof(MACHDR), &AuthHdr,
2448 + MakeOutgoingFrame(OutBuffer, &FrameLen,
2449 + sizeof(MACHDR), &AuthHdr,
2454 MiniportMMRequest(pAd, OutBuffer, FrameLen);
2457 ==========================================================================
2459 VOID PeerDeauthAction(
2460 - IN PRTMP_ADAPTER pAd,
2461 - IN PMLME_QUEUE_ELEM Elem)
2462 + IN PRTMP_ADAPTER pAd,
2463 + IN PMLME_QUEUE_ELEM Elem)
2467 diff -Nur rt2500-1.1.0-b4/Module/connect.c rt2500-cvs-2007061011/Module/connect.c
2468 --- rt2500-1.1.0-b4/Module/connect.c 2006-06-17 22:12:58.000000000 +0200
2469 +++ rt2500-cvs-2007061011/Module/connect.c 2007-03-21 05:25:34.000000000 +0100
2471 -/***************************************************************************
2472 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
2474 - * This program is free software; you can redistribute it and/or modify *
2475 - * it under the terms of the GNU General Public License as published by *
2476 - * the Free Software Foundation; either version 2 of the License, or *
2477 - * (at your option) any later version. *
2479 - * This program is distributed in the hope that it will be useful, *
2480 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
2481 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
2482 - * GNU General Public License for more details. *
2484 - * You should have received a copy of the GNU General Public License *
2485 - * along with this program; if not, write to the *
2486 - * Free Software Foundation, Inc., *
2487 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
2489 - * Licensed under the GNU GPL *
2490 - * Original code supplied under license from RaLink Inc, 2004. *
2491 - ***************************************************************************/
2493 - /***************************************************************************
2494 - * Module Name: connect.c
2498 - * Revision History:
2500 - * -------- ----------- -----------------------------
2501 - * MarkW 8th Dec 04 Baseline code
2502 - * Ivo (rt2400) 15th Dec 04 Timing ESSID set
2503 - ***************************************************************************/
2504 +/***************************************************************************
2505 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
2507 + * This program is free software; you can redistribute it and/or modify *
2508 + * it under the terms of the GNU General Public License as published by *
2509 + * the Free Software Foundation; either version 2 of the License, or *
2510 + * (at your option) any later version. *
2512 + * This program is distributed in the hope that it will be useful, *
2513 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
2514 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
2515 + * GNU General Public License for more details. *
2517 + * You should have received a copy of the GNU General Public License *
2518 + * along with this program; if not, write to the *
2519 + * Free Software Foundation, Inc., *
2520 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
2522 + * Licensed under the GNU GPL *
2523 + * Original code supplied under license from RaLink Inc, 2004. *
2524 + ***************************************************************************/
2526 + /***************************************************************************
2527 + * Module Name: connect.c
2531 + * Revision History:
2533 + * -------- ----------- -----------------------------
2534 + * MarkW 8th Dec 04 Baseline code
2535 + * Ivo (rt2400) 15th Dec 04 Timing ESSID set
2536 + ***************************************************************************/
2538 #include "rt_config.h"
2541 ==========================================================================
2544 - IN PRTMP_ADAPTER pAd,
2545 - IN STATE_MACHINE *S,
2546 - OUT STATE_MACHINE_FUNC Trans[])
2547 + IN PRTMP_ADAPTER pAd,
2548 + IN STATE_MACHINE *S,
2549 + OUT STATE_MACHINE_FUNC Trans[])
2551 - // Control state machine differs from other state machines, the interface
2552 + // Control state machine differs from other state machines, the interface
2553 // follows the standard interface
2554 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
2557 ==========================================================================
2559 VOID MlmeCntlMachinePerformAction(
2560 - IN PRTMP_ADAPTER pAd,
2561 - IN STATE_MACHINE *S,
2562 - IN MLME_QUEUE_ELEM *Elem)
2563 + IN PRTMP_ADAPTER pAd,
2564 + IN STATE_MACHINE *S,
2565 + IN MLME_QUEUE_ELEM *Elem)
2567 switch (Elem->MsgType)
2573 - switch(pAd->Mlme.CntlMachine.CurrState)
2574 + switch(pAd->Mlme.CntlMachine.CurrState)
2577 CntlIdleProc(pAd, Elem);
2578 @@ -105,17 +105,17 @@
2579 case CNTL_WAIT_JOIN:
2580 CntlWaitJoinProc(pAd, Elem);
2584 // CNTL_WAIT_REASSOC is the only state in CNTL machine that does
2585 - // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
2586 - // Therefore not protected by NDIS's "only one outstanding OID request"
2587 + // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
2588 + // Therefore not protected by NDIS's "only one outstanding OID request"
2589 // rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
2590 // Current approach is to block new SET request at RTMPSetInformation()
2591 // when CntlMachine.CurrState is not CNTL_IDLE
2592 case CNTL_WAIT_REASSOC:
2593 CntlWaitReassocProc(pAd, Elem);
2597 case CNTL_WAIT_START:
2598 CntlWaitStartProc(pAd, Elem);
2603 case CNTL_WAIT_OID_LIST_SCAN:
2604 - if(Elem->MsgType == MT2_SCAN_CONF)
2605 + if(Elem->MsgType == MT2_SCAN_CONF)
2607 // Resume TxRing after SCANING complete. We hope the out-of-service time
2608 // won't be too long to let upper layer time-out the waiting frames
2610 if (pAd->MediaState == NdisMediaStateDisconnected)
2611 MlmeAutoReconnectLastSSID(pAd);
2615 case CNTL_WAIT_OID_DISASSOC:
2616 - if (Elem->MsgType == MT2_DISASSOC_CONF)
2617 + if (Elem->MsgType == MT2_DISASSOC_CONF)
2621 @@ -169,11 +169,11 @@
2622 ==========================================================================
2625 - IN PRTMP_ADAPTER pAd,
2626 - IN MLME_QUEUE_ELEM *Elem)
2627 + IN PRTMP_ADAPTER pAd,
2628 + IN MLME_QUEUE_ELEM *Elem)
2630 MLME_DISASSOC_REQ_STRUCT DisassocReq;
2633 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
2635 if (pAd->Mlme.CntlAux.CurrReqIsFromNdis)
2640 - switch(Elem->MsgType)
2641 + switch(Elem->MsgType)
2643 case OID_802_11_DISASSOCIATE:
2644 DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
2646 case MT2_MLME_ROAMING_REQ:
2647 CntlMlmeRoamingProc(pAd, Elem);
2652 DBGPRINT(RT_DEBUG_TRACE, "CNTL - Illegal message in CntlIdleProc(MsgType=%d)\n",Elem->MsgType);
2655 // for best SCANNING reult;
2656 AsicRestoreBbpSensibility(pAd);
2658 - // record current BSS if network is connected.
2659 + // record current BSS if network is connected.
2660 // 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
2661 if (pAd->MediaState == NdisMediaStateConnected) // if (INFRA_ON(pAd) || ADHOC_ON(pAd))
2663 @@ -230,19 +230,19 @@
2664 memcpy(&CurrBss, &pAd->PortCfg.BssTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
2666 // 2003-2-20 reset this RSSI to a low value but not zero. In normal case, the coming SCAN
2667 - // should return a correct RSSI to overwrite this. If no BEEACON received after SCAN,
2668 + // should return a correct RSSI to overwrite this. If no BEEACON received after SCAN,
2669 // at least we still report a "greater than 0" RSSI since we claim it's CONNECTED.
2670 CurrBss.Rssi = 18; // about -82 dB
2675 // clean up previous SCAN result, add current BSS back to table if any
2676 - BssTableInit(&pAd->PortCfg.BssTab);
2677 + BssTableInit(&pAd->PortCfg.BssTab);
2678 if (BssIdx != BSS_NOT_FOUND)
2680 - // DDK Note: If the NIC is associated with a particular BSSID and SSID
2681 - // that are not contained in the list of BSSIDs generated by this scan, the
2682 - // BSSID description of the currently associated BSSID and SSID should be
2683 + // DDK Note: If the NIC is associated with a particular BSSID and SSID
2684 + // that are not contained in the list of BSSIDs generated by this scan, the
2685 + // BSSID description of the currently associated BSSID and SSID should be
2686 // appended to the list of BSSIDs in the NIC's database.
2687 // To ensure this, we append this BSS as the first entry in SCAN result
2688 memcpy(&pAd->PortCfg.BssTab.BssEntry[0], &CurrBss, sizeof(BSS_ENTRY));
2691 BroadSsid[0] = '\0';
2692 ScanParmFill(pAd, &ScanReq, BroadSsid, 0, BSS_ANY, SCAN_PASSIVE);
2693 - MlmeEnqueue(&pAd->Mlme.Queue, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
2694 + MlmeEnqueue(&pAd->Mlme.Queue, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
2695 sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
2696 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
2698 @@ -262,15 +262,15 @@
2699 ==========================================================================
2701 VOID CntlOidSsidProc(
2702 - IN PRTMP_ADAPTER pAd,
2703 - IN MLME_QUEUE_ELEM * Elem)
2704 + IN PRTMP_ADAPTER pAd,
2705 + IN MLME_QUEUE_ELEM * Elem)
2707 NDIS_802_11_SSID *OidSsid = (NDIS_802_11_SSID *)Elem->Msg;
2708 MLME_DISASSOC_REQ_STRUCT DisassocReq;
2712 - // record the desired SSID and all matching BSSes into CntlAux.SsidBssTab for
2714 + // record the desired SSID and all matching BSSes into CntlAux.SsidBssTab for
2715 // later-on iteration. Sort by RSSI order
2716 memcpy(pAd->Mlme.CntlAux.Ssid, OidSsid->Ssid, OidSsid->SsidLength);
2717 pAd->Mlme.CntlAux.SsidLen = (UCHAR)OidSsid->SsidLength;
2718 @@ -286,11 +286,11 @@
2719 if (((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
2720 (pAd->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
2722 - // For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
2723 + // For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
2724 // connection process
2725 DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP...\n");
2726 DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
2727 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2728 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2729 sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
2730 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
2733 // Config has changed, we have to reconnect the same AP
2734 DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP Because config changed...\n");
2735 DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
2736 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2737 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2738 sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
2739 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
2741 @@ -313,24 +313,24 @@
2744 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
2747 - else if (INFRA_ON(pAd))
2750 + else if (INFRA_ON(pAd))
2752 // case 1. active association existent
2753 // roaming is done within miniport driver, nothing to do with configuration
2754 - // utility. so upon a new SET(OID_802_11_SSID) is received, we just
2755 - // disassociate with the current (or previous) associated AP, if any,
2756 - // then perform a new association with this new SSID, no matter the
2757 + // utility. so upon a new SET(OID_802_11_SSID) is received, we just
2758 + // disassociate with the current (or previous) associated AP, if any,
2759 + // then perform a new association with this new SSID, no matter the
2760 // new/old SSID are the same or npt.
2761 DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP...\n");
2762 DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
2763 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2764 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2765 sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
2766 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
2773 DBGPRINT(RT_DEBUG_TRACE, "CNTL - drop current ADHOC\n");
2776 IterateOnBssTab(pAd);
2783 @@ -365,18 +365,18 @@
2784 ==========================================================================
2786 VOID CntlOidRTBssidProc(
2787 - IN PRTMP_ADAPTER pAd,
2788 - IN MLME_QUEUE_ELEM * Elem)
2789 + IN PRTMP_ADAPTER pAd,
2790 + IN MLME_QUEUE_ELEM * Elem)
2793 MACADDR *pOidBssid = (MACADDR *)Elem->Msg;
2794 MLME_DISASSOC_REQ_STRUCT DisassocReq;
2795 MLME_JOIN_REQ_STRUCT JoinReq;
2798 COPY_MAC_ADDR(&pAd->Mlme.CntlAux.Bssid, pOidBssid);
2799 BssIdx = BssTableSearch(&pAd->PortCfg.BssTab, pOidBssid);
2801 - if (BssIdx == BSS_NOT_FOUND)
2803 + if (BssIdx == BSS_NOT_FOUND)
2805 DBGPRINT(RT_DEBUG_TRACE, "CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n");
2806 if (pAd->Mlme.CntlAux.CurrReqIsFromNdis)
2809 // Add SSID into Mlme.CntlAux for site surey joining hidden SSID
2810 pAd->Mlme.CntlAux.SsidLen = pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0].SsidLen;
2811 - memcpy(pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0].Ssid, pAd->Mlme.CntlAux.SsidLen);
2812 + memcpy(pAd->Mlme.CntlAux.Ssid, pAd->Mlme.CntlAux.SsidBssTab.BssEntry[0].Ssid, pAd->Mlme.CntlAux.SsidLen);
2814 // 2002-11-26 skip the following checking. i.e. if user wants to re-connect to same AP
2815 // we just follow normal procedure. The reason of user doing this may because he/she changed
2816 @@ -412,15 +412,15 @@
2819 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
2827 // disassoc from current AP first
2828 DBGPRINT(RT_DEBUG_TRACE, "CNTL - disassociate with current AP ...\n");
2829 DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
2830 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2831 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
2832 sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
2834 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
2836 pAd->MediaState = NdisMediaStateDisconnected;
2837 DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event C!\n");
2841 // No active association, join the BSS immediately
2842 DBGPRINT(RT_DEBUG_TRACE, "CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n",
2843 pOidBssid->Octet[0],pOidBssid->Octet[1],pOidBssid->Octet[2],
2844 @@ -444,27 +444,27 @@
2846 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
2852 // Roaming is the only external request triggering CNTL state machine
2853 -// despite of other "SET OID" operation. All "SET OID" related oerations
2854 +// despite of other "SET OID" operation. All "SET OID" related oerations
2855 // happen in sequence, because no other SET OID will be sent to this device
2856 // until the the previous SET operation is complete (successful o failed).
2857 // So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
2858 // or been corrupted by other "SET OID"?
2859 VOID CntlMlmeRoamingProc(
2860 - IN PRTMP_ADAPTER pAd,
2861 - IN MLME_QUEUE_ELEM *Elem)
2862 + IN PRTMP_ADAPTER pAd,
2863 + IN MLME_QUEUE_ELEM *Elem)
2867 // AP in different channel may show lower RSSI than actual value??
2868 // should we add a weighting factor to compensate it?
2869 DBGPRINT(RT_DEBUG_TRACE,"CNTL - Roaming in CntlAux.RoamTab...\n");
2870 BssTableSortByRssi(&pAd->Mlme.CntlAux.RoamTab);
2871 pAd->Mlme.CntlAux.RoamIdx=0;
2872 IterateOnBssTab2(pAd);
2878 @@ -473,17 +473,17 @@
2879 ==========================================================================
2881 VOID CntlWaitDisassocProc(
2882 - IN PRTMP_ADAPTER pAd,
2883 - IN MLME_QUEUE_ELEM *Elem)
2884 + IN PRTMP_ADAPTER pAd,
2885 + IN MLME_QUEUE_ELEM *Elem)
2887 MLME_START_REQ_STRUCT StartReq;
2889 - if (Elem->MsgType == MT2_DISASSOC_CONF)
2891 + if (Elem->MsgType == MT2_DISASSOC_CONF)
2893 DBGPRINT(RT_DEBUG_TRACE, "CNTL - Dis-associate successful\n");
2896 - // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
2897 + // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
2898 if ((pAd->Mlme.CntlAux.SsidBssTab.BssNr==0) && (pAd->PortCfg.BssType == BSS_INDEP))
2900 DBGPRINT(RT_DEBUG_TRACE, "CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd->Mlme.CntlAux.Ssid);
2901 @@ -505,16 +505,16 @@
2902 ==========================================================================
2904 VOID CntlWaitJoinProc(
2905 - IN PRTMP_ADAPTER pAd,
2906 - IN MLME_QUEUE_ELEM *Elem)
2907 + IN PRTMP_ADAPTER pAd,
2908 + IN MLME_QUEUE_ELEM *Elem)
2911 MLME_AUTH_REQ_STRUCT AuthReq;
2913 - if (Elem->MsgType == MT2_JOIN_CONF)
2914 + if (Elem->MsgType == MT2_JOIN_CONF)
2916 memcpy(&Reason, Elem->Msg, sizeof(USHORT));
2917 - if (Reason == MLME_SUCCESS)
2918 + if (Reason == MLME_SUCCESS)
2920 // 1. joined an IBSS, we are pretty much done here
2921 if (pAd->PortCfg.BssType == BSS_INDEP)
2925 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
2928 // 2. joined a new INFRA network, start from authentication
2932 // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
2933 if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeShared) ||
2936 AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.Bssid, Ndis802_11AuthModeOpen);
2938 - MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
2939 + MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
2940 sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
2942 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH;
2944 // 3. failed, try next BSS
2945 pAd->Mlme.CntlAux.BssIdx++;
2946 IterateOnBssTab(pAd);
2952 @@ -560,18 +560,18 @@
2953 ==========================================================================
2955 VOID CntlWaitStartProc(
2956 - IN PRTMP_ADAPTER pAd,
2957 - IN MLME_QUEUE_ELEM *Elem)
2958 + IN PRTMP_ADAPTER pAd,
2959 + IN MLME_QUEUE_ELEM *Elem)
2963 - if (Elem->MsgType == MT2_START_CONF)
2964 + if (Elem->MsgType == MT2_START_CONF)
2966 memcpy(&Result, Elem->Msg, sizeof(USHORT));
2967 - if (Result == MLME_SUCCESS)
2968 + if (Result == MLME_SUCCESS)
2970 DBGPRINT(RT_DEBUG_TRACE, "CNTL - We have started a new ADHOC network\n");
2971 - DBGPRINT(RT_DEBUG_TRACE, "CNTL - BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n",
2972 + DBGPRINT(RT_DEBUG_TRACE, "CNTL - BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n",
2973 pAd->PortCfg.Bssid.Octet[0],
2974 pAd->PortCfg.Bssid.Octet[1],
2975 pAd->PortCfg.Bssid.Octet[2],
2976 @@ -601,29 +601,29 @@
2977 ==========================================================================
2979 VOID CntlWaitAuthProc(
2980 - IN PRTMP_ADAPTER pAd,
2981 - IN MLME_QUEUE_ELEM *Elem)
2982 + IN PRTMP_ADAPTER pAd,
2983 + IN MLME_QUEUE_ELEM *Elem)
2986 MLME_ASSOC_REQ_STRUCT AssocReq;
2987 MLME_AUTH_REQ_STRUCT AuthReq;
2989 - if (Elem->MsgType == MT2_AUTH_CONF)
2990 + if (Elem->MsgType == MT2_AUTH_CONF)
2992 memcpy(&Reason, Elem->Msg, sizeof(USHORT));
2993 - if (Reason == MLME_SUCCESS)
2994 + if (Reason == MLME_SUCCESS)
2996 DBGPRINT(RT_DEBUG_TRACE, "CNTL - AUTH OK\n");
2997 - AssocParmFill(pAd, &AssocReq, &pAd->PortCfg.Bssid, pAd->PortCfg.CapabilityInfo,
2998 + AssocParmFill(pAd, &AssocReq, &pAd->PortCfg.Bssid, pAd->PortCfg.CapabilityInfo,
2999 ASSOC_TIMEOUT, pAd->PortCfg.DefaultListenCount);
3000 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
3001 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
3002 sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
3004 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
3009 - // This fail may because of the AP already keep us in its MAC table without
3010 + // This fail may because of the AP already keep us in its MAC table without
3011 // ageing-out. The previous authentication attempt must have let it remove us.
3012 // so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
3013 DBGPRINT(RT_DEBUG_TRACE, "CNTL - AUTH FAIL, try again...\n");
3015 AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.Bssid, Ndis802_11AuthModeOpen);
3018 - MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
3019 + MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
3020 sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
3022 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
3023 @@ -652,26 +652,26 @@
3024 ==========================================================================
3026 VOID CntlWaitAuthProc2(
3027 - IN PRTMP_ADAPTER pAd,
3028 - IN MLME_QUEUE_ELEM *Elem)
3029 + IN PRTMP_ADAPTER pAd,
3030 + IN MLME_QUEUE_ELEM *Elem)
3033 MLME_ASSOC_REQ_STRUCT AssocReq;
3034 MLME_AUTH_REQ_STRUCT AuthReq;
3036 - if (Elem->MsgType == MT2_AUTH_CONF)
3037 + if (Elem->MsgType == MT2_AUTH_CONF)
3039 memcpy(&Reason, Elem->Msg, sizeof(USHORT));
3040 - if (Reason == MLME_SUCCESS)
3041 + if (Reason == MLME_SUCCESS)
3043 DBGPRINT(RT_DEBUG_TRACE, "CNTL - AUTH OK\n");
3044 - AssocParmFill(pAd, &AssocReq, &pAd->PortCfg.Bssid, pAd->PortCfg.CapabilityInfo,
3045 + AssocParmFill(pAd, &AssocReq, &pAd->PortCfg.Bssid, pAd->PortCfg.CapabilityInfo,
3046 ASSOC_TIMEOUT, pAd->PortCfg.DefaultListenCount);
3047 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
3048 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
3049 sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
3051 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
3056 if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) &&
3057 @@ -679,12 +679,12 @@
3059 DBGPRINT(RT_DEBUG_TRACE, "CNTL - AUTH FAIL, try OPEN system...\n");
3060 AuthParmFill(pAd, &AuthReq, &pAd->PortCfg.Bssid, Ndis802_11AuthModeOpen);
3061 - MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
3062 + MlmeEnqueue(&pAd->Mlme.Queue, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
3063 sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
3065 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
3070 // not success, try next BSS
3071 DBGPRINT(RT_DEBUG_TRACE, "CNTL - AUTH FAIL, give up; try next BSS\n");
3073 IterateOnBssTab(pAd);
3081 @@ -702,15 +702,15 @@
3082 ==========================================================================
3084 VOID CntlWaitAssocProc(
3085 - IN PRTMP_ADAPTER pAd,
3086 - IN MLME_QUEUE_ELEM *Elem)
3087 + IN PRTMP_ADAPTER pAd,
3088 + IN MLME_QUEUE_ELEM *Elem)
3092 - if (Elem->MsgType == MT2_ASSOC_CONF)
3093 + if (Elem->MsgType == MT2_ASSOC_CONF)
3095 memcpy(&Reason, Elem->Msg, sizeof(USHORT));
3096 - if (Reason == MLME_SUCCESS)
3097 + if (Reason == MLME_SUCCESS)
3099 DBGPRINT(RT_DEBUG_TRACE, "CNTL - Association successful on BSS #%d\n",pAd->Mlme.CntlAux.BssIdx);
3100 LinkUp(pAd, BSS_INFRA);
3104 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
3110 // not success, try next BSS
3111 DBGPRINT(RT_DEBUG_TRACE, "CNTL - Association fails on BSS #%d\n",pAd->Mlme.CntlAux.BssIdx);
3112 @@ -735,21 +735,21 @@
3113 ==========================================================================
3115 VOID CntlWaitReassocProc(
3116 - IN PRTMP_ADAPTER pAd,
3117 - IN MLME_QUEUE_ELEM *Elem)
3118 + IN PRTMP_ADAPTER pAd,
3119 + IN MLME_QUEUE_ELEM *Elem)
3123 - if (Elem->MsgType == MT2_REASSOC_CONF)
3124 + if (Elem->MsgType == MT2_REASSOC_CONF)
3126 memcpy(&Result, Elem->Msg, sizeof(USHORT));
3127 - if (Result == MLME_SUCCESS)
3128 + if (Result == MLME_SUCCESS)
3130 BSS_ENTRY *pBss = &pAd->Mlme.CntlAux.RoamTab.BssEntry[pAd->Mlme.CntlAux.RoamIdx];
3132 // COPY_MAC_ADDR(&pAd->PortCfg.Bssid, &pBss->Bssid);
3133 // AsicSetBssid(pAd, &pAd->PortCfg.Bssid);
3136 // The following steps are supposed to be done after JOIN in normal procedure
3137 // But since this RE-ASSOC skips the JOIN procedure, we have to do it after
3138 // RE-ASSOC succeeds. If RE-ASSOC fails, then stay at original AP without any change
3139 @@ -768,14 +768,14 @@
3140 pAd->PortCfg.CfpDurRemain = pBss->CfpDurRemaining;
3141 pAd->PortCfg.CfpCount = pBss->CfpCount;
3145 // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
3147 DBGPRINT(RT_DEBUG_TRACE, "CNTL - Re-assocition successful on BSS #%d\n", pAd->Mlme.CntlAux.RoamIdx);
3148 LinkUp(pAd, BSS_INFRA);
3149 - pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
3152 + pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
3156 // reassoc failed, try to pick next BSS in the BSS Table
3157 DBGPRINT(RT_DEBUG_TRACE, "CNTL - Re-assocition fails on BSS #%d\n", pAd->Mlme.CntlAux.RoamIdx);
3161 IN PRTMP_ADAPTER pAd,
3168 DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! Set to short preamble!!!\n");
3169 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
3173 pAd->PortCfg.BssType = BssType;
3174 if (BssType == BSS_INDEP)
3176 @@ -856,11 +856,11 @@
3178 // the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically
3179 // due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here
3183 ComposeNullFrame(pAd);
3184 AsicEnableBssSync(pAd);
3187 // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
3188 // should wait until at least 2 active nodes in this BSSID.
3189 pAd->MediaState = NdisMediaStateConnected;
3191 ==========================================================================
3194 - IN PRTMP_ADAPTER pAd)
3195 + IN PRTMP_ADAPTER pAd)
3197 DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! LINK DOWN !!!\n");
3200 DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event A!\n");
3201 BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid));
3203 - // restore back to -
3204 + // restore back to -
3205 // 1. long slot (20 us) or short slot (9 us) time
3206 // 2. turn on/off RTS/CTS and/or CTS-to-self protection
3207 // 3. short preamble
3209 ==========================================================================
3211 VOID MlmeCntlConfirm(
3212 - IN PRTMP_ADAPTER pAd,
3215 + IN PRTMP_ADAPTER pAd,
3219 MlmeEnqueue(&pAd->Mlme.Queue, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg);
3221 @@ -983,16 +983,16 @@
3222 ==========================================================================
3224 VOID IterateOnBssTab(
3225 - IN PRTMP_ADAPTER pAd)
3226 + IN PRTMP_ADAPTER pAd)
3228 MLME_START_REQ_STRUCT StartReq;
3229 MLME_JOIN_REQ_STRUCT JoinReq;
3232 BssIdx = pAd->Mlme.CntlAux.BssIdx;
3233 - if (BssIdx < pAd->Mlme.CntlAux.SsidBssTab.BssNr)
3234 + if (BssIdx < pAd->Mlme.CntlAux.SsidBssTab.BssNr)
3236 - DBGPRINT(RT_DEBUG_TRACE, "CNTL - Trying BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n",
3237 + DBGPRINT(RT_DEBUG_TRACE, "CNTL - Trying BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n",
3238 pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[0],
3239 pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[1],
3240 pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[2],
3241 @@ -1018,12 +1018,12 @@
3242 DBGPRINT(RT_DEBUG_TRACE, "CNTL - All BSS fail; reply NDIS_STATUS_NOT_ACCEPTED\n");
3244 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
3249 // for re-association only
3250 VOID IterateOnBssTab2(
3251 - IN PRTMP_ADAPTER pAd)
3252 + IN PRTMP_ADAPTER pAd)
3254 MLME_REASSOC_REQ_STRUCT ReassocReq;
3256 @@ -1034,19 +1034,19 @@
3258 if (BssIdx < pAd->Mlme.CntlAux.RoamTab.BssNr)
3260 - DBGPRINT(RT_DEBUG_TRACE, "CNTL - try BSS #%d %02x:%02x:%02x:%02x:%02x:%02x ...\n",
3261 + DBGPRINT(RT_DEBUG_TRACE, "CNTL - try BSS #%d %02x:%02x:%02x:%02x:%02x:%02x ...\n",
3262 BssIdx, pBss->Bssid.Octet[0],pBss->Bssid.Octet[1],pBss->Bssid.Octet[2],
3263 pBss->Bssid.Octet[3],pBss->Bssid.Octet[4],pBss->Bssid.Octet[5]);
3265 AsicSwitchChannel(pAd, pBss->Channel);
3266 AsicLockChannel(pAd, pBss->Channel);
3269 // reassociate message has the same structure as associate message
3270 - AssocParmFill(pAd, &ReassocReq, &pBss->Bssid, pBss->CapabilityInfo,
3271 + AssocParmFill(pAd, &ReassocReq, &pBss->Bssid, pBss->CapabilityInfo,
3272 ASSOC_TIMEOUT, pAd->PortCfg.DefaultListenCount);
3273 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
3274 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
3275 sizeof(MLME_REASSOC_REQ_STRUCT), &ReassocReq);
3278 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
3281 @@ -1055,7 +1055,7 @@
3282 AsicSwitchChannel(pAd, pAd->PortCfg.Channel);
3283 AsicLockChannel(pAd, pAd->PortCfg.Channel);
3284 pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
3290 @@ -1064,9 +1064,9 @@
3291 ==========================================================================
3294 - IN PRTMP_ADAPTER pAd,
3295 - IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
3297 + IN PRTMP_ADAPTER pAd,
3298 + IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
3301 JoinReq->BssIdx = BssIdx;
3303 @@ -1077,12 +1077,12 @@
3304 ==========================================================================
3307 - IN PRTMP_ADAPTER pAd,
3308 - IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
3310 - IN USHORT CapabilityInfo,
3312 - IN USHORT ListenIntv)
3313 + IN PRTMP_ADAPTER pAd,
3314 + IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
3316 + IN USHORT CapabilityInfo,
3318 + IN USHORT ListenIntv)
3320 COPY_MAC_ADDR(&AssocReq->Addr, Addr);
3321 // Add mask to support 802.11b mode only
3322 @@ -1097,12 +1097,12 @@
3323 ==========================================================================
3326 - IN PRTMP_ADAPTER pAd,
3327 - IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
3331 - IN UCHAR ScanType)
3332 + IN PRTMP_ADAPTER pAd,
3333 + IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
3337 + IN UCHAR ScanType)
3339 ScanReq->SsidLen = SsidLen;
3340 memcpy(ScanReq->Ssid, Ssid, SsidLen);
3341 @@ -1116,10 +1116,10 @@
3342 ==========================================================================
3344 VOID DisassocParmFill(
3345 - IN PRTMP_ADAPTER pAd,
3346 - IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
3349 + IN PRTMP_ADAPTER pAd,
3350 + IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
3354 COPY_MAC_ADDR(&DisassocReq->Addr, Addr);
3355 DisassocReq->Reason = Reason;
3356 @@ -1131,12 +1131,12 @@
3357 ==========================================================================
3360 - IN PRTMP_ADAPTER pAd,
3361 - IN OUT MLME_START_REQ_STRUCT *StartReq,
3364 + IN PRTMP_ADAPTER pAd,
3365 + IN OUT MLME_START_REQ_STRUCT *StartReq,
3369 - memcpy(StartReq->Ssid, Ssid, SsidLen);
3370 + memcpy(StartReq->Ssid, Ssid, SsidLen);
3371 StartReq->SsidLen = SsidLen;
3374 @@ -1146,10 +1146,10 @@
3375 ==========================================================================
3378 - IN PRTMP_ADAPTER pAd,
3379 - IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
3382 + IN PRTMP_ADAPTER pAd,
3383 + IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
3387 COPY_MAC_ADDR(&AuthReq->Addr, Addr);
3389 @@ -1187,9 +1187,9 @@
3390 ==========================================================================
3392 ULONG MakeIbssBeacon(
3393 - IN PRTMP_ADAPTER pAd)
3394 + IN PRTMP_ADAPTER pAd)
3396 - UCHAR SsidIe = IE_SSID, DsIe = IE_DS_PARM, IbssIe = IE_IBSS_PARM, SuppIe = IE_SUPP_RATES,
3397 + UCHAR SsidIe = IE_SSID, DsIe = IE_DS_PARM, IbssIe = IE_IBSS_PARM, SuppIe = IE_SUPP_RATES,
3398 DsLen = 1, IbssLen = 2;
3399 UCHAR ExtRateIe = IE_EXT_SUPP_RATES, ExtRatesLen;
3400 UCHAR ErpIe[3] = {IE_ERP, 1, 0x04};
3401 @@ -1244,28 +1244,28 @@
3403 // compose IBSS beacon frame
3404 MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, &pAd->PortCfg.Broadcast, &pAd->PortCfg.Bssid);
3405 - Privacy = (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
3406 - (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
3407 + Privacy = (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
3408 + (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
3409 (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled);
3410 CapabilityInfo = CAP_GENERATE(0, 1, 0, 0, Privacy, (pAd->PortCfg.WindowsTxPreamble == Rt802_11PreambleShort));
3411 if (SupportedRatesLen <= 8)
3413 MakeOutgoingFrame(pBeaconFrame, &FrameLen,
3414 - MAC_HDR_LEN, &BcnHdr,
3415 + MAC_HDR_LEN, &BcnHdr,
3416 TIMESTAMP_LEN, &FakeTimestamp,
3417 2, &pAd->PortCfg.BeaconPeriod,
3420 - 1, &pAd->PortCfg.SsidLen,
3422 + 1, &pAd->PortCfg.SsidLen,
3423 pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
3426 1, &SupportedRatesLen,
3427 - SupportedRatesLen, SupportedRates,
3430 + SupportedRatesLen, SupportedRates,
3433 1, &pAd->PortCfg.Channel,
3438 2, &pAd->PortCfg.AtimWin,
3441 @@ -1274,21 +1274,21 @@
3442 ExtRatesLen = SupportedRatesLen - 8;
3443 SupportedRatesLen = 8;
3444 MakeOutgoingFrame(pBeaconFrame, &FrameLen,
3445 - MAC_HDR_LEN, &BcnHdr,
3446 + MAC_HDR_LEN, &BcnHdr,
3447 TIMESTAMP_LEN, &FakeTimestamp,
3448 2, &pAd->PortCfg.BeaconPeriod,
3451 - 1, &pAd->PortCfg.SsidLen,
3453 + 1, &pAd->PortCfg.SsidLen,
3454 pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
3457 1, &SupportedRatesLen,
3458 - SupportedRatesLen, SupportedRates,
3461 + SupportedRatesLen, SupportedRates,
3464 1, &pAd->PortCfg.Channel,
3469 2, &pAd->PortCfg.AtimWin,
3472 @@ -1301,7 +1301,7 @@
3475 UCHAR WpaIe = IE_WPA;
3478 if (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) // Tkip
3480 MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
3481 @@ -1325,7 +1325,7 @@
3482 RTMPFrameEndianChange(pAd, pBeaconFrame, DIR_WRITE, FALSE);
3485 - RTMPWriteTxDescriptor(pTxD, FALSE, CIPHER_NONE, FALSE, FALSE, TRUE, SHORT_RETRY, IFS_NEW_BACKOFF,
3486 + RTMPWriteTxDescriptor(pTxD, FALSE, CIPHER_NONE, FALSE, FALSE, TRUE, SHORT_RETRY, IFS_NEW_BACKOFF,
3487 pAd->PortCfg.MlmeRate, 4, FrameLen, pAd->PortCfg.TxPreambleInUsed, 0);
3489 DBGPRINT(RT_DEBUG_TRACE, "MakeIbssBeacon (len=%d)\n", FrameLen);
3490 diff -Nur rt2500-1.1.0-b4/Module/eeprom.c rt2500-cvs-2007061011/Module/eeprom.c
3491 --- rt2500-1.1.0-b4/Module/eeprom.c 2006-06-17 22:12:58.000000000 +0200
3492 +++ rt2500-cvs-2007061011/Module/eeprom.c 2007-03-21 05:25:34.000000000 +0100
3494 -/***************************************************************************
3495 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
3497 - * This program is free software; you can redistribute it and/or modify *
3498 - * it under the terms of the GNU General Public License as published by *
3499 - * the Free Software Foundation; either version 2 of the License, or *
3500 - * (at your option) any later version. *
3502 - * This program is distributed in the hope that it will be useful, *
3503 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
3504 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
3505 - * GNU General Public License for more details. *
3507 - * You should have received a copy of the GNU General Public License *
3508 - * along with this program; if not, write to the *
3509 - * Free Software Foundation, Inc., *
3510 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
3512 - * Licensed under the GNU GPL *
3513 - * Original code supplied under license from RaLink Inc, 2004. *
3514 - ***************************************************************************/
3516 - /***************************************************************************
3517 - * Module Name: eeprom.c
3521 - * Revision History:
3523 - * -------- ----------- -----------------------------
3524 - * MarkW 8th Dec 04 Baseline code
3525 - ***************************************************************************/
3526 +/***************************************************************************
3527 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
3529 + * This program is free software; you can redistribute it and/or modify *
3530 + * it under the terms of the GNU General Public License as published by *
3531 + * the Free Software Foundation; either version 2 of the License, or *
3532 + * (at your option) any later version. *
3534 + * This program is distributed in the hope that it will be useful, *
3535 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
3536 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
3537 + * GNU General Public License for more details. *
3539 + * You should have received a copy of the GNU General Public License *
3540 + * along with this program; if not, write to the *
3541 + * Free Software Foundation, Inc., *
3542 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
3544 + * Licensed under the GNU GPL *
3545 + * Original code supplied under license from RaLink Inc, 2004. *
3546 + ***************************************************************************/
3548 + /***************************************************************************
3549 + * Module Name: eeprom.c
3553 + * Revision History:
3555 + * -------- ----------- -----------------------------
3556 + * MarkW 8th Dec 04 Baseline code
3557 + ***************************************************************************/
3559 #include "rt_config.h"
3562 RaiseClock(pAd, &x);
3563 LowerClock(pAd, &x);
3565 - // output the read_opcode and register number in that order
3566 + // output the read_opcode and register number in that order
3567 ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
3568 ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
3570 diff -Nur rt2500-1.1.0-b4/Module/iwpriv_usage.txt rt2500-cvs-2007061011/Module/iwpriv_usage.txt
3571 --- rt2500-1.1.0-b4/Module/iwpriv_usage.txt 2006-06-17 22:12:58.000000000 +0200
3572 +++ rt2500-cvs-2007061011/Module/iwpriv_usage.txt 2007-01-09 12:47:14.000000000 +0100
3575 -This file provides some basic examples on the configuration of the driver using standard linux wireless tools. Where possible iwconfig should be used to adjust settings. Some settings are currently not avaiable via iwconfig and these include WPA, for these functions it is currently necessary to use iwpriv.
3578 -Configuration Examples
3579 -===================================================================
3580 --------------------------------------------------------------------------------------------------------
3581 -Example I: Config STA to link with AP which is OPEN/NONE(Authentication/Encryption)
3582 - 1. iwconfig ra0 mode managed
3583 - 2. iwconfig ra0 key open
3584 - 3. iwconfig ra0 key off
3585 - 4. iwconfig ra0 essid "AP's SSID"
3587 -Example II: Config STA to link with AP which is SHARED/WEP(Authentication/Encryption)
3588 - 1. iwconfig ra0 mode managed
3589 - 2. iwconfig ra0 key restricted
3590 - 3. iwconfig ra0 Key [1] "s:AP's wep key"
3591 - 4. iwconfig ra0 key [1]
3592 - 5. iwconfig ra0 essid "AP's SSID"
3594 -Example III: Config STA to create/link as adhoc mode
3595 - 1. iwconfig ra0 mode ad-hoc
3596 - 2. iwconfig ra0 key off
3597 - 4. iwconfig ra0 essid "AP's SSID"
3599 -Example IV: Config STA to link with AP which is WPAPSK/TKIP(Authentication/Encryption)
3600 - 1. iwconfig ra0 mode managed
3601 - 2. iwpriv ra0 set AuthMode=WPAPSK
3602 - 3. iwpriv ra0 set EncrypType=TKIP
3603 - 4. iwpriv ra0 set WPAPSK="AP's wpa-preshared key"
3604 - 5. iwconfig ra0 essid "AP's SSID"
3606 -Example V: Config STA to link with AP which is WPAPSK/AES(Authentication/Encryption)
3607 - 1. iwconfig ra0 mode managed
3608 - 2. iwpriv ra0 set AuthMode=WPAPSK
3609 - 3. iwpriv ra0 set EncrypType=AES
3610 - 5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key"
3611 - 6. iwconfig ra0 essid "AP's SSID"
3617 -This is detailed explanation of each parameters for iwpriv.
3618 -Before reading this document, make sure you already read README.
3620 --------------------------------------------------------------------------------------------------------
3622 - iwpriv ra0 set [parameters]=[val]
3626 -[parameters] [val] range explaination
3627 ------------------ ----------------------- ---------------------------------------------
3628 -CountryRegion {0~7} Set country region
3629 - 0: use 1 ~ 11 Channel
3630 - 1: use 1 ~ 11 Channel
3631 - 2: use 1 ~ 13 Channel
3632 - 3: use 10, 11 Channel
3633 - 4: use 10 ~ 13 Channel
3635 - 6: use 1 ~ 14 Channel
3636 - 7: use 3 ~ 9 Channel
3638 -WirelessMode {0~2} Set Wireless Mode
3639 - 0:11b/g mixed, 1:11B only
3641 -TxRate {0~12} Set TxRate
3642 - 0:Auto, 1:1Mbps, 2:2Mbps, 3:5.5Mbps, 4:11Mbps,
3643 - 5:6Mbps, 6:9Mbps, 7:12Mbps, 8:18Mbps, 9:24Mbps,
3644 - 10:36Mbps, 11:48Mbps, 12:54Mbps
3646 -BGProtection {0~2} Set 11B/11G Protection
3647 - 0:Auto, 1:Always on, 2:Always off
3649 -TxPreamble {0~2} Set TxPreamble
3650 - 0:Preamble Long, 1:Preamble Short, 2:Auto
3652 -TxBurst {0,1} Set TxBurst Enable or Disable
3653 - 0:Disable, 1:Enable
3655 -TurboRate {0,1} Set TurboRate Enable or Disable
3656 - 0:Disable, 1:Enable
3658 -AdhocOfdm {0, 1} Set Adhoc mode tx rate
3659 - 0: adhere WIFI spec., 1: violate WIFI spec.
3660 - (802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode)
3661 - AuthMode {OPEN,SHARED,WPAPSK} Set Authentication mode
3663 -EncrypType {NONE,WEP,TKIP,AES} Set Encryption Type
3665 -WPAPSK {8~63 ASCII or 64 HEX characters} WPA Pre-Shared Key
3667 -ApClient {0,1} Set ApClient mode
3668 - 0:Disable, 1:Enable
3672 -This is detailed explanation of each parameters for iwlist.
3674 --------------------------------------------------------------------------------------------------------
3676 -iwlist ra0 scanning ; list the result after scanning(site survey)
3681 -----------------------------------------------------------------------------------------------------------------------------------
3687 -*** PLEASE DO NOT USE THESE FUNCTIONS, THIS IS FOR HISTORICAL REFERENCE ONLY ***
3688 -As the configuration utility still uses some iwpriv commands they have not been
3689 -removed from the driver yet. These commands are likely to dissapear if the utility is
3692 -** ALL THESE COMMANDS HAVE A IWCONFIG REPLACEMENT, USE IT ****
3694 -SSID {0~z, less than 32 characters} Set SoftAP SSID
3696 -Channel {1~14} depends on country region Set Channel
3698 -RTSThreshold {1~2347} Set RTS Threshold
3700 -FragThreshold {256~2346} Set Fragment Threshold
3702 -NetworkType {Infra,Adhoc} Set Network type
3704 -DefaultKeyID {1~4} Set Default Key ID
3706 -Key1 {5 ascii characters or Set Key1 String
3708 - 13 ascii characters or
3711 -Key2 {5 ascii characters or Set Key2 String
3713 - 13 ascii characters or
3716 -Key3 {5 ascii characters or Set Key3 String
3718 - 13 ascii characters or
3721 -Key4 {5 ascii characters or Set Key4 String
3723 - 13 ascii characters or
3725 +This file provides some basic examples on the configuration of the
3726 +driver using standard linux wireless tools. Where possible iwconfig
3727 +should be used to adjust settings. Some settings are currently not
3728 +avaiable via iwconfig and these include WPA, for these functions it is
3729 +currently necessary to use iwpriv.
3732 +Configuration Examples
3733 +======================================================================
3734 +----------------------------------------------------------------------
3735 +Example I: STA with AP using OPEN/NONE(Authentication/Encryption)
3736 + 1. iwconfig ra0 mode managed
3737 + 2. iwconfig ra0 key open
3738 + 3. iwconfig ra0 key off
3739 + 4. iwconfig ra0 essid "AP's SSID"
3741 +Example II: STA with AP using SHARED/WEP(Authentication/Encryption)
3742 + 1. iwconfig ra0 mode managed
3743 + 2. iwconfig ra0 key restricted
3744 + 3. iwconfig ra0 Key [1] "s:AP's wep key"
3745 + 4. iwconfig ra0 key [1]
3746 + 5. iwconfig ra0 essid "AP's SSID"
3748 +Example III: STA using adhoc mode
3749 + 1. iwconfig ra0 mode ad-hoc
3750 + 2. iwconfig ra0 key off
3751 + 4. iwconfig ra0 essid "STA's SSID"
3753 +Example IV: STA with AP using WPAPSK/TKIP(Authentication/Encryption)
3754 + 1. iwconfig ra0 mode managed
3755 + 2. iwpriv ra0 set AuthMode=WPAPSK
3756 + 3. iwpriv ra0 set EncrypType=TKIP
3757 + 4. iwpriv ra0 set WPAPSK="AP's wpa-preshared key"
3758 + 5. iwconfig ra0 essid "AP's SSID"
3760 +Example V: STA with AP using WPAPSK/AES(Authentication/Encryption)
3761 + 1. iwconfig ra0 mode managed
3762 + 2. iwpriv ra0 set AuthMode=WPAPSK
3763 + 3. iwpriv ra0 set EncrypType=AES
3764 + 5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key"
3765 + 6. iwconfig ra0 essid "AP's SSID"
3771 +This is detailed explanation of each parameters for iwpriv.
3772 +Before reading this document, make sure you already read README.
3774 +----------------------------------------------------------------------
3776 + iwpriv ra0 set [parameters]=[val]
3780 +[parameters] [val] range explanation
3781 +------------ -------------------- ---------------------
3782 +CountryRegion {0~7} Set country region
3783 + 0: use 1 ~ 11 Channel
3784 + 1: use 1 ~ 11 Channel
3785 + 2: use 1 ~ 13 Channel
3786 + 3: use 10, 11 Channel
3787 + 4: use 10 ~ 13 Channel
3789 + 6: use 1 ~ 14 Channel
3790 + 7: use 3 ~ 9 Channel
3792 +WirelessMode {0~2} Set Wireless Mode
3793 + 0:11b/g mixed, 1:11B only
3795 +TxRate {0~12} Set TxRate
3796 + 0:Auto, 1:1Mbps, 2:2Mbps,
3797 + 3:5.5Mbps, 4:11Mbps, 5:6Mbps,
3798 + 6:9Mbps, 7:12Mbps, 8:18Mbps,
3799 + 9:24Mbps, 10:36Mbps,
3800 + 11:48Mbps, 12:54Mbps
3802 +BGProtection {0~2} Set 11B/11G Protection
3803 + 0:Auto, 1:Always on,
3806 +TxPreamble {0~2} Set TxPreamble
3811 +TxBurst {0,1} Enable/Disable
3812 + 0:Disable, 1:Enable
3814 +TurboRate {0,1} Enable/Disable
3815 + 0:Disable, 1:Enable
3817 +AdhocOfdm {0, 1} Adhoc mode OFDM
3818 + 0: Disallow 1: Allow
3820 +AuthMode {OPEN,SHARED,WPAPSK} Authentication mode
3822 +EncrypType {NONE,WEP,TKIP,AES} Encryption Type
3824 +WPAPSK {8~63 ASCII or 64 HEX characters}
3825 + WPA Pre-Shared Key
3827 +ApClient {0,1} Set ApClient mode
3828 + 0:Disable, 1:Enable
3832 +This is detailed explanation of each parameters for iwlist.
3834 +----------------------------------------------------------------------
3836 +iwlist ra0 scanning; list the result after scanning(site survey)
3841 +----------------------------------------------------------------------
3847 +*** PLEASE DO NOT USE THESE FUNCTIONS, THIS IS FOR HISTORICAL
3848 + REFERENCE ONLY ***
3849 +As the configuration utility still uses some iwpriv commands they have
3850 +not been removed from the driver yet. These commands are likely to
3851 +dissapear if the utility is updated.
3853 +** ALL THESE COMMANDS HAVE A IWCONFIG REPLACEMENT, USE IT ****
3855 +SSID {0~z, less than 32 characters} Set SoftAP SSID
3857 +Channel {1~14} depends on country region Set Channel
3859 +RTSThreshold {1~2347} Set RTS Threshold
3861 +FragThreshold {256~2346} Set Fragment Threshold
3863 +NetworkType {Infra,Adhoc} Set Network type
3865 +DefaultKeyID {1~4} Set Default Key ID
3867 +Key1 {5 ascii characters or Set Key1 String
3869 + 13 ascii characters or
3872 +Key2 {5 ascii characters or Set Key2 String
3874 + 13 ascii characters or
3877 +Key3 {5 ascii characters or Set Key3 String
3879 + 13 ascii characters or
3882 +Key4 {5 ascii characters or Set Key4 String
3884 + 13 ascii characters or
3886 diff -Nur rt2500-1.1.0-b4/Module/load rt2500-cvs-2007061011/Module/load
3887 --- rt2500-1.1.0-b4/Module/load 2006-06-17 22:12:58.000000000 +0200
3888 +++ rt2500-cvs-2007061011/Module/load 1970-01-01 01:00:00.000000000 +0100
3890 -/sbin/insmod rt2500.o
3891 -/sbin/ifconfig ra0 inet 192.168.1.234 up
3892 -/sbin/route add default gw 192.168.1.1
3893 \ Kein Zeilenumbruch am Dateiende.
3894 diff -Nur rt2500-1.1.0-b4/Module/md5.c rt2500-cvs-2007061011/Module/md5.c
3895 --- rt2500-1.1.0-b4/Module/md5.c 2006-06-17 22:12:58.000000000 +0200
3896 +++ rt2500-cvs-2007061011/Module/md5.c 2007-05-29 05:49:17.000000000 +0200
3898 -/***************************************************************************
3899 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
3901 - * This program is free software; you can redistribute it and/or modify *
3902 - * it under the terms of the GNU General Public License as published by *
3903 - * the Free Software Foundation; either version 2 of the License, or *
3904 - * (at your option) any later version. *
3906 - * This program is distributed in the hope that it will be useful, *
3907 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
3908 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
3909 - * GNU General Public License for more details. *
3911 - * You should have received a copy of the GNU General Public License *
3912 - * along with this program; if not, write to the *
3913 - * Free Software Foundation, Inc., *
3914 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
3916 - * Licensed under the GNU GPL *
3917 - * Original code supplied under license from RaLink Inc, 2004. *
3918 +/***************************************************************************
3919 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
3921 + * This program is free software; you can redistribute it and/or modify *
3922 + * it under the terms of the GNU General Public License as published by *
3923 + * the Free Software Foundation; either version 2 of the License, or *
3924 + * (at your option) any later version. *
3926 + * This program is distributed in the hope that it will be useful, *
3927 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
3928 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
3929 + * GNU General Public License for more details. *
3931 + * You should have received a copy of the GNU General Public License *
3932 + * along with this program; if not, write to the *
3933 + * Free Software Foundation, Inc., *
3934 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
3936 + * Licensed under the GNU GPL *
3937 + * Original code supplied under license from RaLink Inc, 2004. *
3938 * This MD5 code is based on code from Dynamics -- HUT Mobile IP *
3939 * Copyright (C) 1998-2001, Dynamics group *
3940 - ***************************************************************************/
3941 + ***************************************************************************/
3943 - /***************************************************************************
3944 + /***************************************************************************
3945 * Module Name: md5.c
3948 * Abstract: contain MD5 and AES cipher algorithm
3950 - * Revision History:
3952 - * -------- ----------- -----------------------------
3953 - * JanL 28th Oct 03 Initial code
3954 - * MarkW 8th Dec 04 Baseline code
3955 - ***************************************************************************/
3957 + * Revision History:
3959 + * -------- ----------- -----------------------------
3960 + * JanL 28th Oct 03 Initial code
3961 + * MarkW 8th Dec 04 Baseline code
3962 + ***************************************************************************/
3964 #include "rt_config.h"
3967 * md5_mac() determines the message authentication code by using secure hash
3968 * MD5(key | data | key).
3970 -void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
3971 +void md5_mac(UCHAR *key, ULONG key_len, UCHAR *data, ULONG data_len,
3977 * hmac_md5() determines the message authentication code using HMAC-MD5.
3978 * This implementation is based on the sample code presented in RFC 2104.
3980 -void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
3981 +void hmac_md5(UCHAR *key, ULONG key_len, UCHAR *data, ULONG data_len,
3985 - u8 k_ipad[65]; /* inner padding - key XORd with ipad */
3986 - u8 k_opad[65]; /* outer padding - key XORd with opad */
3988 + UCHAR k_ipad[65]; /* inner padding - key XORd with ipad */
3989 + UCHAR k_opad[65]; /* outer padding - key XORd with opad */
3993 //assert(key != NULL && data != NULL && mac != NULL);
3994 @@ -128,25 +130,6 @@
3995 MD5Final(mac, &context); /* finish up 2nd pass */
3999 -/* ===== start - public domain MD5 implementation ===== */
4001 - * This code implements the MD5 message-digest algorithm.
4002 - * The algorithm is due to Ron Rivest. This code was
4003 - * written by Colin Plumb in 1993, no copyright is claimed.
4004 - * This code is in the public domain; do with it what you wish.
4006 - * Equivalent code is available from RSA Data Security, Inc.
4007 - * This code has been tested against that, and is equivalent,
4008 - * except that you don't need to include two pages of legalese
4009 - * with every copy.
4011 - * To compute the message digest of a chunk of bytes, declare an
4012 - * MD5Context structure, pass it to MD5Init, call MD5Update as
4013 - * needed on buffers full of bytes, and then call MD5Final, which
4014 - * will fill a supplied 16-byte array with the digest.
4018 #define byteReverse(buf, len) /* Nothing */
4020 @@ -160,588 +143,808 @@
4024 +/* ========================== MD5 implementation =========================== */
4025 +// four base functions for MD5
4026 +#define MD5_F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
4027 +#define MD5_F2(x, y, z) (((x) & (z)) | ((y) & (~z)))
4028 +#define MD5_F3(x, y, z) ((x) ^ (y) ^ (z))
4029 +#define MD5_F4(x, y, z) ((y) ^ ((x) | (~z)))
4030 +#define CYCLIC_LEFT_SHIFT(w, s) (((w) << (s)) | ((w) >> (32-(s))))
4032 +#define MD5Step(f, w, x, y, z, data, t, s) \
4033 + ( w += f(x, y, z) + data + t, w = (CYCLIC_LEFT_SHIFT(w, s)) & 0xffffffff, w += x )
4036 - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
4037 - * initialization constants.
4038 + * Function Description:
4039 + * Initiate MD5 Context satisfied in RFC 1321
4042 + * pCtx Pointer to MD5 context
4047 -void MD5Init(struct MD5Context *ctx)
4048 +VOID MD5Init(MD5_CTX *pCtx)
4050 - ctx->buf[0] = 0x67452301;
4051 - ctx->buf[1] = 0xefcdab89;
4052 - ctx->buf[2] = 0x98badcfe;
4053 - ctx->buf[3] = 0x10325476;
4054 + pCtx->Buf[0] = 0x67452301;
4055 + pCtx->Buf[1] = 0xefcdab89;
4056 + pCtx->Buf[2] = 0x98badcfe;
4057 + pCtx->Buf[3] = 0x10325476;
4061 + pCtx->LenInBitCount[0] = 0;
4062 + pCtx->LenInBitCount[1] = 0;
4066 - * Update context to reflect the concatenation of another buffer full
4068 + * Function Description:
4069 + * Update MD5 Context, allow of an arrary of octets as the next portion
4073 + * pCtx Pointer to MD5 context
4074 + * pData Pointer to input data
4075 + * LenInBytes The length of input data (unit: byte)
4081 + * Called after MD5Init or MD5Update(itself)
4083 -void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len)
4084 +VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, ULONG LenInBytes)
4091 - /* Update bitcount */
4092 + temp = pCtx->LenInBitCount[0];
4095 - if ((ctx->bits[0] = t + ((u32) len << 3)) < t)
4096 - ctx->bits[1]++; /* Carry from low to high */
4097 - ctx->bits[1] += len >> 29;
4099 - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
4101 - /* Handle any leading odd-sized chunks */
4104 - unsigned char *p = (unsigned char *) ctx->in + t;
4108 - memcpy(p, buf, len);
4111 - memcpy(p, buf, t);
4112 - byteReverse(ctx->in, 16);
4113 - MD5Transform(ctx->buf, (u32 *) ctx->in);
4117 - /* Process data in 64-byte chunks */
4118 + pCtx->LenInBitCount[0] =
4119 + (ULONG) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
4121 - while (len >= 64) {
4122 - memcpy(ctx->in, buf, 64);
4123 - byteReverse(ctx->in, 16);
4124 - MD5Transform(ctx->buf, (u32 *) ctx->in);
4128 + if (pCtx->LenInBitCount[0] < temp)
4129 + pCtx->LenInBitCount[1]++; //carry in
4131 + pCtx->LenInBitCount[1] += LenInBytes >> 29;
4134 + temp = (temp >> 3) & 0x3f;
4136 + // process lacks of 64-byte data
4138 + UCHAR *pAds = (UCHAR *) pCtx->Input + temp;
4140 + if ((temp + LenInBytes) < 64) {
4141 + memcpy(pAds, (UCHAR *) pData, LenInBytes);
4145 - /* Handle any remaining bytes of data. */
4146 + memcpy(pAds, (UCHAR *) pData, 64 - temp);
4147 + byteReverse(pCtx->Input, 16);
4148 + MD5Transform(pCtx->Buf, (ULONG *) pCtx->Input);
4150 - memcpy(ctx->in, buf, len);
4151 + pData += 64 - temp;
4152 + LenInBytes -= 64 - temp;
4153 + } // end of if (temp)
4155 + TfTimes = (LenInBytes >> 6);
4157 + for (i = TfTimes; i > 0; i--) {
4158 + memcpy(pCtx->Input, (UCHAR *) pData, 64);
4159 + byteReverse(pCtx->Input, 16);
4160 + MD5Transform(pCtx->Buf, (ULONG *) pCtx->Input);
4165 + // buffering lacks of 64-byte data
4167 + memcpy(pCtx->Input, (UCHAR *) pData, LenInBytes);
4171 - * Final wrapup - pad to 64-byte boundary with the bit pattern
4172 - * 1 0* (64-bit count of bits processed, MSB-first)
4173 + * Function Description:
4174 + * Append padding bits and length of original message in the tail
4175 + * The message digest has to be completed in the end
4178 + * Digest Output of Digest-Message for MD5
4179 + * pCtx Pointer to MD5 context
4185 + * Called after MD5Update
4187 -void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
4188 +VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
4193 - /* Compute number of bytes mod 64 */
4194 - count = (ctx->bits[0] >> 3) & 0x3F;
4196 - /* Set the first char of padding to 0x80. This is safe since there is
4197 - always at least one byte free */
4198 - p = ctx->in + count;
4201 - /* Bytes of padding needed to make 64 bytes */
4202 - count = 64 - 1 - count;
4204 - /* Pad out to 56 mod 64 */
4206 - /* Two lots of padding: Pad the first block to 64 bytes */
4207 - memset(p, 0, count);
4208 - byteReverse(ctx->in, 16);
4209 - MD5Transform(ctx->buf, (u32 *) ctx->in);
4211 - /* Now fill the next block with 56 bytes */
4212 - memset(ctx->in, 0, 56);
4214 - /* Pad block to 56 bytes */
4215 - memset(p, 0, count - 8);
4217 - byteReverse(ctx->in, 14);
4219 + UCHAR PadLenInBytes;
4220 + UCHAR *pAppend = 0;
4223 + Remainder = (UCHAR) ((pCtx->LenInBitCount[0] >> 3) & 0x3f);
4225 + PadLenInBytes = (Remainder < 56) ? (56 - Remainder) : (120 - Remainder);
4227 + pAppend = (UCHAR *) pCtx->Input + Remainder;
4229 + // padding bits without crossing block(64-byte based) boundary
4230 + if (Remainder < 56) {
4234 + memset((UCHAR *) pCtx->Input + Remainder + 1, 0,
4237 + // add data-length field, from low to high
4238 + for (i = 0; i < 4; i++) {
4239 + pCtx->Input[56 + i] =
4241 + LenInBitCount[0] >> (i << 3)) & 0xff);
4242 + pCtx->Input[60 + i] =
4244 + LenInBitCount[1] >> (i << 3)) & 0xff);
4247 + byteReverse(pCtx->Input, 16);
4248 + MD5Transform(pCtx->Buf, (ULONG *) pCtx->Input);
4251 + // padding bits with crossing block(64-byte based) boundary
4253 + // the first block ===
4257 + memset((UCHAR *) pCtx->Input + Remainder + 1, 0,
4258 + (64 - Remainder - 1));
4259 + PadLenInBytes -= (64 - Remainder - 1);
4261 + byteReverse(pCtx->Input, 16);
4262 + MD5Transform(pCtx->Buf, (ULONG *) pCtx->Input);
4264 + // the second block ===
4265 + memset((UCHAR *) pCtx->Input, 0, PadLenInBytes);
4267 + // add data-length field
4268 + for (i = 0; i < 4; i++) {
4269 + pCtx->Input[56 + i] =
4271 + LenInBitCount[0] >> (i << 3)) & 0xff);
4272 + pCtx->Input[60 + i] =
4274 + LenInBitCount[1] >> (i << 3)) & 0xff);
4277 + byteReverse(pCtx->Input, 16);
4278 + MD5Transform(pCtx->Buf, (ULONG *) pCtx->Input);
4281 + memcpy((UCHAR *) Digest, (ULONG *) pCtx->Buf, 16); // output
4282 + byteReverse((UCHAR *) Digest, 4);
4283 + memset(pCtx, 0, sizeof(pCtx)); // memory free
4286 - /* Append length in bits and transform */
4287 - ((u32 *) ctx->in)[14] = ctx->bits[0];
4288 - ((u32 *) ctx->in)[15] = ctx->bits[1];
4290 + * Function Description:
4291 + * The central algorithm of MD5, consists of four rounds and sixteen
4295 + * Buf Buffers of four states (output: 16 bytes)
4296 + * Mes Input data (input: 64 bytes)
4302 + * Called by MD5Update or MD5Final
4304 +VOID MD5Transform(ULONG Buf[4], ULONG Mes[16])
4306 + ULONG Reg[4], Temp;
4309 - MD5Transform(ctx->buf, (u32 *) ctx->in);
4310 - byteReverse((unsigned char *) ctx->buf, 4);
4311 - memcpy(digest, ctx->buf, 16);
4312 - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
4313 + static UCHAR LShiftVal[16] = {
4320 + // [equal to 4294967296*abs(sin(index))]
4321 + static ULONG MD5Table[64] = {
4322 + 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
4323 + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
4324 + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
4325 + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
4327 + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
4328 + 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
4329 + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
4330 + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
4332 + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
4333 + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
4334 + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
4335 + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
4337 + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
4338 + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
4339 + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
4340 + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
4343 + for (i = 0; i < 4; i++)
4346 + // 64 steps in MD5 algorithm
4347 + for (i = 0; i < 16; i++) {
4348 + MD5Step(MD5_F1, Reg[0], Reg[1], Reg[2], Reg[3], Mes[i],
4349 + MD5Table[i], LShiftVal[i & 0x3]);
4351 + // one-word right shift
4358 + for (i = 16; i < 32; i++) {
4359 + MD5Step(MD5_F2, Reg[0], Reg[1], Reg[2], Reg[3],
4360 + Mes[(5 * (i & 0xf) + 1) & 0xf], MD5Table[i],
4361 + LShiftVal[(0x1 << 2) + (i & 0x3)]);
4363 + // one-word right shift
4370 + for (i = 32; i < 48; i++) {
4371 + MD5Step(MD5_F3, Reg[0], Reg[1], Reg[2], Reg[3],
4372 + Mes[(3 * (i & 0xf) + 5) & 0xf], MD5Table[i],
4373 + LShiftVal[(0x1 << 3) + (i & 0x3)]);
4375 + // one-word right shift
4382 + for (i = 48; i < 64; i++) {
4383 + MD5Step(MD5_F4, Reg[0], Reg[1], Reg[2], Reg[3],
4384 + Mes[(7 * (i & 0xf)) & 0xf], MD5Table[i],
4385 + LShiftVal[(0x3 << 2) + (i & 0x3)]);
4387 + // one-word right shift
4395 + // (temporary)output
4396 + for (i = 0; i < 4; i++)
4402 +/* ========================= SHA-1 implementation ========================== */
4403 +// four base functions for SHA-1
4404 +#define SHA1_F1(b, c, d) (((b) & (c)) | ((~b) & (d)))
4405 +#define SHA1_F2(b, c, d) ((b) ^ (c) ^ (d))
4406 +#define SHA1_F3(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
4408 +#define SHA1Step(f, a, b, c, d, e, w, k) \
4409 + ( e += ( f(b, c, d) + w + k + CYCLIC_LEFT_SHIFT(a, 5)) & 0xffffffff, \
4410 + b = CYCLIC_LEFT_SHIFT(b, 30) )
4412 -/* The four core functions - F1 is optimized somewhat */
4414 -/* #define F1(x, y, z) (x & y | ~x & z) */
4415 -#define F1(x, y, z) (z ^ (x & (y ^ z)))
4416 -#define F2(x, y, z) F1(z, x, y)
4417 -#define F3(x, y, z) (x ^ y ^ z)
4418 -#define F4(x, y, z) (y ^ (x | ~z))
4419 +//Initiate SHA-1 Context satisfied in RFC 3174
4420 +VOID SHAInit(SHA_CTX * pCtx)
4422 + pCtx->Buf[0] = 0x67452301;
4423 + pCtx->Buf[1] = 0xefcdab89;
4424 + pCtx->Buf[2] = 0x98badcfe;
4425 + pCtx->Buf[3] = 0x10325476;
4426 + pCtx->Buf[4] = 0xc3d2e1f0;
4428 -/* This is the central step in the MD5 algorithm. */
4429 -#define MD5STEP(f, w, x, y, z, data, s) \
4430 - ( w += f(x, y, z) + data, w =( w<<s | w>>(32-s))&0xffffffff, w += x )
4431 + pCtx->LenInBitCount[0] = 0;
4432 + pCtx->LenInBitCount[1] = 0;
4436 - * The core of the MD5 algorithm, this alters an existing MD5 hash to
4437 - * reflect the addition of 16 longwords of new data. MD5Update blocks
4438 - * the data and converts bytes into longwords for this routine.
4439 + * Function Description:
4440 + * Update SHA-1 Context, allow of an arrary of octets as the next
4441 + * portion of the message
4444 + * pCtx Pointer to SHA-1 context
4445 + * pData Pointer to input data
4446 + * LenInBytes The length of input data (unit: byte)
4449 + * error indicate more than pow(2,64) bits of data
4452 + * Called after SHAInit or SHAUpdate(itself)
4454 -void MD5Transform(u32 buf[4], u32 in[16])
4455 +UCHAR SHAUpdate(SHA_CTX * pCtx, UCHAR * pData, ULONG LenInBytes)
4457 - register u32 a, b, c, d;
4459 + ULONG temp1, temp2;
4463 + temp1 = pCtx->LenInBitCount[0];
4464 + temp2 = pCtx->LenInBitCount[1];
4466 + pCtx->LenInBitCount[0] =
4467 + (ULONG) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
4468 + if (pCtx->LenInBitCount[0] < temp1)
4469 + pCtx->LenInBitCount[1]++; //carry in
4471 + pCtx->LenInBitCount[1] =
4472 + (ULONG) (pCtx->LenInBitCount[1] + (LenInBytes >> 29));
4473 + if (pCtx->LenInBitCount[1] < temp2)
4474 + return (err); //check total length of original data
4477 + temp1 = (temp1 >> 3) & 0x3f;
4479 + // process lacks of 64-byte data
4481 + UCHAR *pAds = (UCHAR *) pCtx->Input + temp1;
4483 + if ((temp1 + LenInBytes) < 64) {
4484 + memcpy(pAds, (UCHAR *) pData, LenInBytes);
4488 + memcpy(pAds, (UCHAR *) pData, 64 - temp1);
4489 + byteReverse((UCHAR *) pCtx->Input, 16);
4491 + memset((UCHAR *) pCtx->Input + 64, 0, 16);
4492 + SHATransform(pCtx->Buf, (ULONG *) pCtx->Input);
4494 + pData += 64 - temp1;
4495 + LenInBytes -= 64 - temp1;
4496 + } // end of if (temp1)
4498 + TfTimes = (LenInBytes >> 6);
4500 + for (i = TfTimes; i > 0; i--) {
4501 + memcpy(pCtx->Input, (UCHAR *) pData, 64);
4502 + byteReverse((UCHAR *) pCtx->Input, 16);
4504 + memset((UCHAR *) pCtx->Input + 64, 0, 16);
4505 + SHATransform(pCtx->Buf, (ULONG *) pCtx->Input);
4510 + // buffering lacks of 64-byte data
4512 + memcpy(pCtx->Input, (UCHAR *) pData, LenInBytes);
4519 - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
4520 - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
4521 - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
4522 - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
4523 - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
4524 - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
4525 - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
4526 - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
4527 - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
4528 - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
4529 - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
4530 - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
4531 - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
4532 - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
4533 - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
4534 - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
4536 - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
4537 - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
4538 - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
4539 - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
4540 - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
4541 - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
4542 - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
4543 - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
4544 - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
4545 - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
4546 - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
4547 - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
4548 - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
4549 - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
4550 - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
4551 - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
4553 - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
4554 - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
4555 - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
4556 - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
4557 - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
4558 - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
4559 - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
4560 - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
4561 - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
4562 - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
4563 - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
4564 - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
4565 - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
4566 - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
4567 - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
4568 - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
4570 - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
4571 - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
4572 - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
4573 - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
4574 - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
4575 - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
4576 - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
4577 - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
4578 - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
4579 - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
4580 - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
4581 - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
4582 - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
4583 - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
4584 - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
4585 - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
4595 -void SHAInit(SHA_CTX *ctx) {
4599 - ctx->sizeHi = ctx->sizeLo = 0;
4601 - /* Initialize H with the magic constants (see FIPS180 for constants)
4603 - ctx->H[0] = 0x67452301L;
4604 - ctx->H[1] = 0xefcdab89L;
4605 - ctx->H[2] = 0x98badcfeL;
4606 - ctx->H[3] = 0x10325476L;
4607 - ctx->H[4] = 0xc3d2e1f0L;
4609 - for (i = 0; i < 80; i++)
4613 -#define SHA_ROTL(X,n) ((((X) << (n)) | ((X) >> (32-(n)))) & 0xffffffffL)
4615 -void SHAHashBlock(SHA_CTX *ctx) {
4617 - unsigned long A,B,C,D,E,TEMP;
4619 - for (t = 16; t <= 79; t++)
4620 - ctx->W[t] = SHA_ROTL(ctx->W[t-3] ^ ctx->W[t-8] ^ ctx->W[t-14] ^ ctx->W[t-16], 1);
4628 - for (t = 0; t <= 19; t++) {
4629 - TEMP = (SHA_ROTL(A,5) + (((C^D)&B)^D) + E + ctx->W[t] + 0x5a827999L) & 0xffffffffL;
4630 - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP;
4632 - for (t = 20; t <= 39; t++) {
4633 - TEMP = (SHA_ROTL(A,5) + (B^C^D) + E + ctx->W[t] + 0x6ed9eba1L) & 0xffffffffL;
4634 - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP;
4636 - for (t = 40; t <= 59; t++) {
4637 - TEMP = (SHA_ROTL(A,5) + ((B&C)|(D&(B|C))) + E + ctx->W[t] + 0x8f1bbcdcL) & 0xffffffffL;
4638 - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP;
4640 - for (t = 60; t <= 79; t++) {
4641 - TEMP = (SHA_ROTL(A,5) + (B^C^D) + E + ctx->W[t] + 0xca62c1d6L) & 0xffffffffL;
4642 - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP;
4650 +// Append padding bits and length of original message in the tail
4651 +// The message digest has to be completed in the end
4652 +VOID SHAFinal(SHA_CTX * pCtx, UCHAR Digest[20])
4655 + UCHAR PadLenInBytes;
4656 + UCHAR *pAppend = 0;
4659 + Remainder = (UCHAR) ((pCtx->LenInBitCount[0] >> 3) & 0x3f);
4661 + pAppend = (UCHAR *) pCtx->Input + Remainder;
4663 + PadLenInBytes = (Remainder < 56) ? (56 - Remainder) : (120 - Remainder);
4665 + // padding bits without crossing block(64-byte based) boundary
4666 + if (Remainder < 56) {
4670 + memset((UCHAR *) pCtx->Input + Remainder + 1, 0,
4673 + // add data-length field, from high to low
4674 + for (i = 0; i < 4; i++) {
4675 + pCtx->Input[56 + i] =
4677 + LenInBitCount[1] >> ((3 - i) << 3)) &
4679 + pCtx->Input[60 + i] =
4681 + LenInBitCount[0] >> ((3 - i) << 3)) &
4685 + byteReverse((UCHAR *) pCtx->Input, 16);
4686 + memset((UCHAR *) pCtx->Input + 64, 0, 14);
4687 + SHATransform(pCtx->Buf, (ULONG *) pCtx->Input);
4690 + // padding bits with crossing block(64-byte based) boundary
4692 + // the first block ===
4696 + memset((UCHAR *) pCtx->Input + Remainder + 1, 0,
4697 + (64 - Remainder - 1));
4698 + PadLenInBytes -= (64 - Remainder - 1);
4700 + byteReverse((UCHAR *) pCtx->Input, 16);
4701 + memset((UCHAR *) pCtx->Input + 64, 0, 16);
4702 + SHATransform(pCtx->Buf, (ULONG *) pCtx->Input);
4704 + // the second block ===
4705 + memset((UCHAR *) pCtx->Input, 0, PadLenInBytes);
4707 + // add data-length field
4708 + for (i = 0; i < 4; i++) {
4709 + pCtx->Input[56 + i] =
4711 + LenInBitCount[1] >> ((3 - i) << 3)) &
4713 + pCtx->Input[60 + i] =
4715 + LenInBitCount[0] >> ((3 - i) << 3)) &
4719 + byteReverse((UCHAR *) pCtx->Input, 16);
4720 + memset((UCHAR *) pCtx->Input + 64, 0, 16);
4721 + SHATransform(pCtx->Buf, (ULONG *) pCtx->Input);
4724 + //Output, bytereverse
4725 + for (i = 0; i < 20; i++) {
4726 + Digest[i] = (UCHAR) (pCtx->Buf[i >> 2] >> 8 * (3 - (i & 0x3)));
4729 + memset(pCtx, 0, sizeof(pCtx)); // memory free
4732 -void SHAUpdate(SHA_CTX *ctx, unsigned char *dataIn, int len)
4733 +// The central algorithm of SHA-1, consists of four rounds and
4734 +// twenty steps per round
4735 +VOID SHATransform(ULONG Buf[5], ULONG Mes[20])
4739 - /* Read the data into W and process blocks as they get full
4741 - for (i = 0; i < len; i++) {
4742 - ctx->W[ctx->lenW / 4] <<= 8;
4743 - ctx->W[ctx->lenW / 4] |= (unsigned long)dataIn[i];
4744 - if ((++ctx->lenW) % 64 == 0) {
4745 - SHAHashBlock(ctx);
4749 - ctx->sizeHi += (ctx->sizeLo < 8);
4751 + ULONG Reg[5], Temp;
4755 + static ULONG SHA1Table[4] = { 0x5a827999, 0x6ed9eba1,
4756 + 0x8f1bbcdc, 0xca62c1d6
4765 + //the first octet of a word is stored in the 0th element, bytereverse
4766 + for (i = 0; i < 16; i++) {
4767 + W[i] = (Mes[i] >> 24) & 0xff;
4768 + W[i] |= (Mes[i] >> 8) & 0xff00;
4769 + W[i] |= (Mes[i] << 8) & 0xff0000;
4770 + W[i] |= (Mes[i] << 24) & 0xff000000;
4773 + for (i = 0; i < 64; i++)
4775 + CYCLIC_LEFT_SHIFT(W[i] ^ W[2 + i] ^ W[8 + i] ^ W[13 + i],
4778 + // 80 steps in SHA-1 algorithm
4779 + for (i = 0; i < 80; i++) {
4781 + SHA1Step(SHA1_F1, Reg[0], Reg[1], Reg[2], Reg[3],
4782 + Reg[4], W[i], SHA1Table[0]);
4784 + else if (i >= 20 && i < 40)
4785 + SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3],
4786 + Reg[4], W[i], SHA1Table[1]);
4788 + else if (i >= 40 && i < 60)
4789 + SHA1Step(SHA1_F3, Reg[0], Reg[1], Reg[2], Reg[3],
4790 + Reg[4], W[i], SHA1Table[2]);
4793 + SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3],
4794 + Reg[4], W[i], SHA1Table[3]);
4796 + // one-word right shift
4804 + } // end of for-loop
4806 + // (temporary)output
4807 + for (i = 0; i < 5; i++)
4812 -void SHAFinal(SHA_CTX *ctx, unsigned char hashout[20]) {
4813 - unsigned char pad0x80 = 0x80;
4814 - unsigned char pad0x00 = 0x00;
4815 - unsigned char padlen[8];
4818 - /* Pad with a binary 1 (e.g. 0x80), then zeroes, then length
4820 - padlen[0] = (unsigned char)((ctx->sizeHi >> 24) & 255);
4821 - padlen[1] = (unsigned char)((ctx->sizeHi >> 16) & 255);
4822 - padlen[2] = (unsigned char)((ctx->sizeHi >> 8) & 255);
4823 - padlen[3] = (unsigned char)((ctx->sizeHi >> 0) & 255);
4824 - padlen[4] = (unsigned char)((ctx->sizeLo >> 24) & 255);
4825 - padlen[5] = (unsigned char)((ctx->sizeLo >> 16) & 255);
4826 - padlen[6] = (unsigned char)((ctx->sizeLo >> 8) & 255);
4827 - padlen[7] = (unsigned char)((ctx->sizeLo >> 0) & 255);
4828 - SHAUpdate(ctx, &pad0x80, 1);
4829 - while (ctx->lenW != 56)
4830 - SHAUpdate(ctx, &pad0x00, 1);
4831 - SHAUpdate(ctx, padlen, 8);
4835 - for (i = 0; i < 20; i++) {
4836 - hashout[i] = (unsigned char)(ctx->H[i / 4] >> 24);
4837 - ctx->H[i / 4] <<= 8;
4841 - * Re-initialize the context (also zeroizes contents)
4845 +/* ========================= AES En/Decryption ========================== */
4849 -static uint32 FSb[256] =
4851 - 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
4852 - 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
4853 - 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
4854 - 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
4855 - 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC,
4856 - 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
4857 - 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A,
4858 - 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
4859 - 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
4860 - 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
4861 - 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B,
4862 - 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
4863 - 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85,
4864 - 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
4865 - 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
4866 - 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
4867 - 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17,
4868 - 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
4869 - 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88,
4870 - 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
4871 - 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
4872 - 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
4873 - 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9,
4874 - 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
4875 - 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6,
4876 - 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
4877 - 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
4878 - 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
4879 - 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94,
4880 - 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
4881 - 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68,
4882 - 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
4883 +static uint32 FSb[256] = {
4884 + 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
4885 + 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
4886 + 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
4887 + 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
4888 + 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC,
4889 + 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
4890 + 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A,
4891 + 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
4892 + 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
4893 + 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
4894 + 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B,
4895 + 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
4896 + 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85,
4897 + 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
4898 + 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
4899 + 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
4900 + 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17,
4901 + 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
4902 + 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88,
4903 + 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
4904 + 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
4905 + 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
4906 + 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9,
4907 + 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
4908 + 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6,
4909 + 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
4910 + 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
4911 + 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
4912 + 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94,
4913 + 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
4914 + 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68,
4915 + 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
4923 - V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \
4924 - V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \
4925 - V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \
4926 - V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \
4927 - V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \
4928 - V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \
4929 - V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \
4930 - V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \
4931 - V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \
4932 - V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \
4933 - V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \
4934 - V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \
4935 - V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \
4936 - V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \
4937 - V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \
4938 - V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \
4939 - V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \
4940 - V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \
4941 - V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \
4942 - V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \
4943 - V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \
4944 - V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \
4945 - V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \
4946 - V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \
4947 - V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \
4948 - V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \
4949 - V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \
4950 - V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \
4951 - V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \
4952 - V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \
4953 - V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \
4954 - V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \
4955 - V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \
4956 - V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \
4957 - V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \
4958 - V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \
4959 - V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \
4960 - V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \
4961 - V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \
4962 - V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \
4963 - V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \
4964 - V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \
4965 - V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \
4966 - V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \
4967 - V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \
4968 - V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \
4969 - V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \
4970 - V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \
4971 - V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \
4972 - V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \
4973 - V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \
4974 - V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \
4975 - V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \
4976 - V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \
4977 - V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \
4978 - V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \
4979 - V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \
4980 - V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \
4981 - V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \
4982 - V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \
4983 - V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \
4984 - V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \
4985 - V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \
4986 - V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A)
4987 + V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \
4988 + V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \
4989 + V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \
4990 + V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \
4991 + V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \
4992 + V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \
4993 + V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \
4994 + V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \
4995 + V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \
4996 + V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \
4997 + V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \
4998 + V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \
4999 + V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \
5000 + V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \
5001 + V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \
5002 + V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \
5003 + V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \
5004 + V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \
5005 + V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \
5006 + V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \
5007 + V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \
5008 + V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \
5009 + V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \
5010 + V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \
5011 + V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \
5012 + V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \
5013 + V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \
5014 + V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \
5015 + V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \
5016 + V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \
5017 + V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \
5018 + V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \
5019 + V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \
5020 + V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \
5021 + V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \
5022 + V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \
5023 + V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \
5024 + V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \
5025 + V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \
5026 + V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \
5027 + V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \
5028 + V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \
5029 + V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \
5030 + V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \
5031 + V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \
5032 + V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \
5033 + V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \
5034 + V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \
5035 + V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \
5036 + V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \
5037 + V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \
5038 + V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \
5039 + V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \
5040 + V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \
5041 + V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \
5042 + V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \
5043 + V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \
5044 + V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \
5045 + V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \
5046 + V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \
5047 + V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \
5048 + V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \
5049 + V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \
5050 + V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A)
5052 -#define V(a,b,c,d) 0x##a##b##c##d
5053 +#define V(a,b,c,d) 0x##a##b##c##d
5054 static uint32 FT0[256] = { FT };
5058 -#define V(a,b,c,d) 0x##d##a##b##c
5059 +#define V(a,b,c,d) 0x##d##a##b##c
5060 static uint32 FT1[256] = { FT };
5064 -#define V(a,b,c,d) 0x##c##d##a##b
5065 +#define V(a,b,c,d) 0x##c##d##a##b
5066 static uint32 FT2[256] = { FT };
5070 -#define V(a,b,c,d) 0x##b##c##d##a
5071 +#define V(a,b,c,d) 0x##b##c##d##a
5072 static uint32 FT3[256] = { FT };
5080 -static uint32 RSb[256] =
5082 - 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38,
5083 - 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
5084 - 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
5085 - 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
5086 - 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D,
5087 - 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
5088 - 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2,
5089 - 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
5090 - 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
5091 - 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
5092 - 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA,
5093 - 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
5094 - 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A,
5095 - 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
5096 - 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
5097 - 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
5098 - 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA,
5099 - 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
5100 - 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85,
5101 - 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
5102 - 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
5103 - 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
5104 - 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20,
5105 - 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
5106 - 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31,
5107 - 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
5108 - 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
5109 - 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
5110 - 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0,
5111 - 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
5112 - 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26,
5113 - 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
5114 +static uint32 RSb[256] = {
5115 + 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38,
5116 + 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
5117 + 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
5118 + 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
5119 + 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D,
5120 + 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
5121 + 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2,
5122 + 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
5123 + 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
5124 + 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
5125 + 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA,
5126 + 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
5127 + 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A,
5128 + 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
5129 + 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
5130 + 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
5131 + 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA,
5132 + 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
5133 + 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85,
5134 + 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
5135 + 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
5136 + 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
5137 + 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20,
5138 + 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
5139 + 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31,
5140 + 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
5141 + 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
5142 + 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
5143 + 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0,
5144 + 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
5145 + 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26,
5146 + 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
5154 - V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \
5155 - V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \
5156 - V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \
5157 - V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \
5158 - V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \
5159 - V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \
5160 - V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \
5161 - V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \
5162 - V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \
5163 - V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \
5164 - V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \
5165 - V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \
5166 - V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \
5167 - V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \
5168 - V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \
5169 - V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \
5170 - V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \
5171 - V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \
5172 - V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \
5173 - V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \
5174 - V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \
5175 - V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \
5176 - V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \
5177 - V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \
5178 - V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \
5179 - V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \
5180 - V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \
5181 - V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \
5182 - V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \
5183 - V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \
5184 - V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \
5185 - V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \
5186 - V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \
5187 - V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \
5188 - V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \
5189 - V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \
5190 - V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \
5191 - V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \
5192 - V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \
5193 - V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \
5194 - V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \
5195 - V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \
5196 - V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \
5197 - V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \
5198 - V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \
5199 - V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \
5200 - V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \
5201 - V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \
5202 - V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \
5203 - V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \
5204 - V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \
5205 - V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \
5206 - V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \
5207 - V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \
5208 - V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \
5209 - V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \
5210 - V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \
5211 - V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \
5212 - V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \
5213 - V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \
5214 - V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \
5215 - V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \
5216 - V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \
5217 - V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42)
5218 + V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \
5219 + V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \
5220 + V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \
5221 + V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \
5222 + V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \
5223 + V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \
5224 + V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \
5225 + V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \
5226 + V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \
5227 + V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \
5228 + V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \
5229 + V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \
5230 + V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \
5231 + V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \
5232 + V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \
5233 + V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \
5234 + V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \
5235 + V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \
5236 + V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \
5237 + V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \
5238 + V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \
5239 + V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \
5240 + V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \
5241 + V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \
5242 + V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \
5243 + V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \
5244 + V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \
5245 + V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \
5246 + V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \
5247 + V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \
5248 + V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \
5249 + V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \
5250 + V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \
5251 + V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \
5252 + V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \
5253 + V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \
5254 + V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \
5255 + V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \
5256 + V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \
5257 + V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \
5258 + V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \
5259 + V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \
5260 + V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \
5261 + V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \
5262 + V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \
5263 + V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \
5264 + V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \
5265 + V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \
5266 + V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \
5267 + V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \
5268 + V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \
5269 + V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \
5270 + V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \
5271 + V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \
5272 + V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \
5273 + V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \
5274 + V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \
5275 + V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \
5276 + V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \
5277 + V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \
5278 + V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \
5279 + V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \
5280 + V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \
5281 + V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42)
5283 -#define V(a,b,c,d) 0x##a##b##c##d
5284 +#define V(a,b,c,d) 0x##a##b##c##d
5285 static uint32 RT0[256] = { RT };
5289 -#define V(a,b,c,d) 0x##d##a##b##c
5290 +#define V(a,b,c,d) 0x##d##a##b##c
5291 static uint32 RT1[256] = { RT };
5295 -#define V(a,b,c,d) 0x##c##d##a##b
5296 +#define V(a,b,c,d) 0x##c##d##a##b
5297 static uint32 RT2[256] = { RT };
5301 -#define V(a,b,c,d) 0x##b##c##d##a
5302 +#define V(a,b,c,d) 0x##b##c##d##a
5303 static uint32 RT3[256] = { RT };
5309 /* round constants */
5311 -static uint32 RCON[10] =
5313 - 0x01000000, 0x02000000, 0x04000000, 0x08000000,
5314 - 0x10000000, 0x20000000, 0x40000000, 0x80000000,
5315 - 0x1B000000, 0x36000000
5316 +static uint32 RCON[10] = {
5317 + 0x01000000, 0x02000000, 0x04000000, 0x08000000,
5318 + 0x10000000, 0x20000000, 0x40000000, 0x80000000,
5319 + 0x1B000000, 0x36000000
5322 -/* key schedule tables */
5323 +/* key schedule tables */
5325 static int KT_init = 1;
5327 @@ -750,451 +953,445 @@
5328 static uint32 KT2[256];
5329 static uint32 KT3[256];
5331 -/* platform-independant 32-bit integer manipulation macros */
5332 +/* platform-independant 32-bit integer manipulation macros */
5334 +#define GET_UINT32(n,b,i) \
5336 + (n) = ( (uint32) (b)[(i) ] << 24 ) \
5337 + | ( (uint32) (b)[(i) + 1] << 16 ) \
5338 + | ( (uint32) (b)[(i) + 2] << 8 ) \
5339 + | ( (uint32) (b)[(i) + 3] ); \
5342 -#define GET_UINT32(n,b,i) \
5344 - (n) = ( (uint32) (b)[(i) ] << 24 ) \
5345 - | ( (uint32) (b)[(i) + 1] << 16 ) \
5346 - | ( (uint32) (b)[(i) + 2] << 8 ) \
5347 - | ( (uint32) (b)[(i) + 3] ); \
5350 -#define PUT_UINT32(n,b,i) \
5352 - (b)[(i) ] = (uint8) ( (n) >> 24 ); \
5353 - (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \
5354 - (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \
5355 - (b)[(i) + 3] = (uint8) ( (n) ); \
5356 +#define PUT_UINT32(n,b,i) \
5358 + (b)[(i) ] = (uint8) ( (n) >> 24 ); \
5359 + (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \
5360 + (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \
5361 + (b)[(i) + 3] = (uint8) ( (n) ); \
5364 /* AES key scheduling routine */
5366 -int aes_set_key( aes_context *ctx, uint8 *key, int nbits )
5367 +int aes_set_key(aes_context * ctx, uint8 * key, int nbits)
5374 - case 128: ctx->nr = 10; break;
5375 - case 192: ctx->nr = 12; break;
5376 - case 256: ctx->nr = 14; break;
5377 - default : return( 1 );
5382 - for( i = 0; i < (nbits >> 5); i++ )
5384 - GET_UINT32( RK[i], key, i * 4 );
5387 - /* setup encryption round keys */
5393 - for( i = 0; i < 10; i++, RK += 4 )
5395 - RK[4] = RK[0] ^ RCON[i] ^
5396 - ( FSb[ (uint8) ( RK[3] >> 16 ) ] << 24 ) ^
5397 - ( FSb[ (uint8) ( RK[3] >> 8 ) ] << 16 ) ^
5398 - ( FSb[ (uint8) ( RK[3] ) ] << 8 ) ^
5399 - ( FSb[ (uint8) ( RK[3] >> 24 ) ] );
5401 - RK[5] = RK[1] ^ RK[4];
5402 - RK[6] = RK[2] ^ RK[5];
5403 - RK[7] = RK[3] ^ RK[6];
5409 - for( i = 0; i < 8; i++, RK += 6 )
5411 - RK[6] = RK[0] ^ RCON[i] ^
5412 - ( FSb[ (uint8) ( RK[5] >> 16 ) ] << 24 ) ^
5413 - ( FSb[ (uint8) ( RK[5] >> 8 ) ] << 16 ) ^
5414 - ( FSb[ (uint8) ( RK[5] ) ] << 8 ) ^
5415 - ( FSb[ (uint8) ( RK[5] >> 24 ) ] );
5417 - RK[7] = RK[1] ^ RK[6];
5418 - RK[8] = RK[2] ^ RK[7];
5419 - RK[9] = RK[3] ^ RK[8];
5420 - RK[10] = RK[4] ^ RK[9];
5421 - RK[11] = RK[5] ^ RK[10];
5427 - for( i = 0; i < 7; i++, RK += 8 )
5429 - RK[8] = RK[0] ^ RCON[i] ^
5430 - ( FSb[ (uint8) ( RK[7] >> 16 ) ] << 24 ) ^
5431 - ( FSb[ (uint8) ( RK[7] >> 8 ) ] << 16 ) ^
5432 - ( FSb[ (uint8) ( RK[7] ) ] << 8 ) ^
5433 - ( FSb[ (uint8) ( RK[7] >> 24 ) ] );
5435 - RK[9] = RK[1] ^ RK[8];
5436 - RK[10] = RK[2] ^ RK[9];
5437 - RK[11] = RK[3] ^ RK[10];
5440 - ( FSb[ (uint8) ( RK[11] >> 24 ) ] << 24 ) ^
5441 - ( FSb[ (uint8) ( RK[11] >> 16 ) ] << 16 ) ^
5442 - ( FSb[ (uint8) ( RK[11] >> 8 ) ] << 8 ) ^
5443 - ( FSb[ (uint8) ( RK[11] ) ] );
5445 - RK[13] = RK[5] ^ RK[12];
5446 - RK[14] = RK[6] ^ RK[13];
5447 - RK[15] = RK[7] ^ RK[14];
5452 - /* setup decryption round keys */
5458 - for( i = 0; i < 256; i++ )
5460 - KT0[i] = RT0[ FSb[i] ];
5461 - KT1[i] = RT1[ FSb[i] ];
5462 - KT2[i] = RT2[ FSb[i] ];
5463 - KT3[i] = RT3[ FSb[i] ];
5481 + for (i = 0; i < (nbits >> 5); i++) {
5482 + GET_UINT32(RK[i], key, i * 4);
5485 + /* setup encryption round keys */
5490 + for (i = 0; i < 10; i++, RK += 4) {
5491 + RK[4] = RK[0] ^ RCON[i] ^
5492 + (FSb[(uint8) (RK[3] >> 16)] << 24) ^
5493 + (FSb[(uint8) (RK[3] >> 8)] << 16) ^
5494 + (FSb[(uint8) (RK[3])] << 8) ^
5495 + (FSb[(uint8) (RK[3] >> 24)]);
5497 + RK[5] = RK[1] ^ RK[4];
5498 + RK[6] = RK[2] ^ RK[5];
5499 + RK[7] = RK[3] ^ RK[6];
5505 + for (i = 0; i < 8; i++, RK += 6) {
5506 + RK[6] = RK[0] ^ RCON[i] ^
5507 + (FSb[(uint8) (RK[5] >> 16)] << 24) ^
5508 + (FSb[(uint8) (RK[5] >> 8)] << 16) ^
5509 + (FSb[(uint8) (RK[5])] << 8) ^
5510 + (FSb[(uint8) (RK[5] >> 24)]);
5512 + RK[7] = RK[1] ^ RK[6];
5513 + RK[8] = RK[2] ^ RK[7];
5514 + RK[9] = RK[3] ^ RK[8];
5515 + RK[10] = RK[4] ^ RK[9];
5516 + RK[11] = RK[5] ^ RK[10];
5522 + for (i = 0; i < 7; i++, RK += 8) {
5523 + RK[8] = RK[0] ^ RCON[i] ^
5524 + (FSb[(uint8) (RK[7] >> 16)] << 24) ^
5525 + (FSb[(uint8) (RK[7] >> 8)] << 16) ^
5526 + (FSb[(uint8) (RK[7])] << 8) ^
5527 + (FSb[(uint8) (RK[7] >> 24)]);
5529 + RK[9] = RK[1] ^ RK[8];
5530 + RK[10] = RK[2] ^ RK[9];
5531 + RK[11] = RK[3] ^ RK[10];
5534 + (FSb[(uint8) (RK[11] >> 24)] << 24) ^
5535 + (FSb[(uint8) (RK[11] >> 16)] << 16) ^
5536 + (FSb[(uint8) (RK[11] >> 8)] << 8) ^
5537 + (FSb[(uint8) (RK[11])]);
5539 + RK[13] = RK[5] ^ RK[12];
5540 + RK[14] = RK[6] ^ RK[13];
5541 + RK[15] = RK[7] ^ RK[14];
5546 + /* setup decryption round keys */
5549 + for (i = 0; i < 256; i++) {
5550 + KT0[i] = RT0[FSb[i]];
5551 + KT1[i] = RT1[FSb[i]];
5552 + KT2[i] = RT2[FSb[i]];
5553 + KT3[i] = RT3[FSb[i]];
5566 + for (i = 1; i < ctx->nr; i++) {
5569 + *SK++ = KT0[(uint8) (*RK >> 24)] ^
5570 + KT1[(uint8) (*RK >> 16)] ^
5571 + KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
5574 + *SK++ = KT0[(uint8) (*RK >> 24)] ^
5575 + KT1[(uint8) (*RK >> 16)] ^
5576 + KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
5579 + *SK++ = KT0[(uint8) (*RK >> 24)] ^
5580 + KT1[(uint8) (*RK >> 16)] ^
5581 + KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
5584 + *SK++ = KT0[(uint8) (*RK >> 24)] ^
5585 + KT1[(uint8) (*RK >> 16)] ^
5586 + KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
5607 - for( i = 1; i < ctx->nr; i++ )
5611 - *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
5612 - KT1[ (uint8) ( *RK >> 16 ) ] ^
5613 - KT2[ (uint8) ( *RK >> 8 ) ] ^
5614 - KT3[ (uint8) ( *RK ) ]; RK++;
5616 - *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
5617 - KT1[ (uint8) ( *RK >> 16 ) ] ^
5618 - KT2[ (uint8) ( *RK >> 8 ) ] ^
5619 - KT3[ (uint8) ( *RK ) ]; RK++;
5621 - *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
5622 - KT1[ (uint8) ( *RK >> 16 ) ] ^
5623 - KT2[ (uint8) ( *RK >> 8 ) ] ^
5624 - KT3[ (uint8) ( *RK ) ]; RK++;
5626 - *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
5627 - KT1[ (uint8) ( *RK >> 16 ) ] ^
5628 - KT2[ (uint8) ( *RK >> 8 ) ] ^
5629 - KT3[ (uint8) ( *RK ) ]; RK++;
5643 -/* AES 128-bit block encryption routine */
5644 +/* AES 128-bit block encryption routine */
5646 -void aes_encrypt(aes_context *ctx, uint8 input[16], uint8 output[16] )
5647 +void aes_encrypt(aes_context * ctx, uint8 input[16], uint8 output[16])
5649 - uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
5650 + uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
5653 - GET_UINT32( X0, input, 0 ); X0 ^= RK[0];
5654 - GET_UINT32( X1, input, 4 ); X1 ^= RK[1];
5655 - GET_UINT32( X2, input, 8 ); X2 ^= RK[2];
5656 - GET_UINT32( X3, input, 12 ); X3 ^= RK[3];
5658 -#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
5662 - X0 = RK[0] ^ FT0[ (uint8) ( Y0 >> 24 ) ] ^ \
5663 - FT1[ (uint8) ( Y1 >> 16 ) ] ^ \
5664 - FT2[ (uint8) ( Y2 >> 8 ) ] ^ \
5665 - FT3[ (uint8) ( Y3 ) ]; \
5667 - X1 = RK[1] ^ FT0[ (uint8) ( Y1 >> 24 ) ] ^ \
5668 - FT1[ (uint8) ( Y2 >> 16 ) ] ^ \
5669 - FT2[ (uint8) ( Y3 >> 8 ) ] ^ \
5670 - FT3[ (uint8) ( Y0 ) ]; \
5672 - X2 = RK[2] ^ FT0[ (uint8) ( Y2 >> 24 ) ] ^ \
5673 - FT1[ (uint8) ( Y3 >> 16 ) ] ^ \
5674 - FT2[ (uint8) ( Y0 >> 8 ) ] ^ \
5675 - FT3[ (uint8) ( Y1 ) ]; \
5677 - X3 = RK[3] ^ FT0[ (uint8) ( Y3 >> 24 ) ] ^ \
5678 - FT1[ (uint8) ( Y0 >> 16 ) ] ^ \
5679 - FT2[ (uint8) ( Y1 >> 8 ) ] ^ \
5680 - FT3[ (uint8) ( Y2 ) ]; \
5683 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */
5684 - AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */
5685 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */
5686 - AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */
5687 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */
5688 - AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */
5689 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */
5690 - AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */
5691 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */
5693 - if( ctx->nr > 10 )
5695 - AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */
5696 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */
5699 - if( ctx->nr > 12 )
5701 - AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */
5702 - AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */
5709 + GET_UINT32(X0, input, 0);
5711 + GET_UINT32(X1, input, 4);
5713 + GET_UINT32(X2, input, 8);
5715 + GET_UINT32(X3, input, 12);
5718 +#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
5722 + X0 = RK[0] ^ FT0[ (uint8) ( Y0 >> 24 ) ] ^ \
5723 + FT1[ (uint8) ( Y1 >> 16 ) ] ^ \
5724 + FT2[ (uint8) ( Y2 >> 8 ) ] ^ \
5725 + FT3[ (uint8) ( Y3 ) ]; \
5727 + X1 = RK[1] ^ FT0[ (uint8) ( Y1 >> 24 ) ] ^ \
5728 + FT1[ (uint8) ( Y2 >> 16 ) ] ^ \
5729 + FT2[ (uint8) ( Y3 >> 8 ) ] ^ \
5730 + FT3[ (uint8) ( Y0 ) ]; \
5732 + X2 = RK[2] ^ FT0[ (uint8) ( Y2 >> 24 ) ] ^ \
5733 + FT1[ (uint8) ( Y3 >> 16 ) ] ^ \
5734 + FT2[ (uint8) ( Y0 >> 8 ) ] ^ \
5735 + FT3[ (uint8) ( Y1 ) ]; \
5737 + X3 = RK[3] ^ FT0[ (uint8) ( Y3 >> 24 ) ] ^ \
5738 + FT1[ (uint8) ( Y0 >> 16 ) ] ^ \
5739 + FT2[ (uint8) ( Y1 >> 8 ) ] ^ \
5740 + FT3[ (uint8) ( Y2 ) ]; \
5743 - X0 = RK[0] ^ ( FSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^
5744 - ( FSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^
5745 - ( FSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^
5746 - ( FSb[ (uint8) ( Y3 ) ] );
5747 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 1 */
5748 + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 2 */
5749 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 3 */
5750 + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 4 */
5751 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 5 */
5752 + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 6 */
5753 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 7 */
5754 + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 8 */
5755 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 9 */
5757 + if (ctx->nr > 10) {
5758 + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 10 */
5759 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 11 */
5762 + if (ctx->nr > 12) {
5763 + AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 12 */
5764 + AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 13 */
5771 + X0 = RK[0] ^ (FSb[(uint8) (Y0 >> 24)] << 24) ^
5772 + (FSb[(uint8) (Y1 >> 16)] << 16) ^
5773 + (FSb[(uint8) (Y2 >> 8)] << 8) ^ (FSb[(uint8) (Y3)]);
5775 + X1 = RK[1] ^ (FSb[(uint8) (Y1 >> 24)] << 24) ^
5776 + (FSb[(uint8) (Y2 >> 16)] << 16) ^
5777 + (FSb[(uint8) (Y3 >> 8)] << 8) ^ (FSb[(uint8) (Y0)]);
5779 + X2 = RK[2] ^ (FSb[(uint8) (Y2 >> 24)] << 24) ^
5780 + (FSb[(uint8) (Y3 >> 16)] << 16) ^
5781 + (FSb[(uint8) (Y0 >> 8)] << 8) ^ (FSb[(uint8) (Y1)]);
5783 + X3 = RK[3] ^ (FSb[(uint8) (Y3 >> 24)] << 24) ^
5784 + (FSb[(uint8) (Y0 >> 16)] << 16) ^
5785 + (FSb[(uint8) (Y1 >> 8)] << 8) ^ (FSb[(uint8) (Y2)]);
5787 + PUT_UINT32(X0, output, 0);
5788 + PUT_UINT32(X1, output, 4);
5789 + PUT_UINT32(X2, output, 8);
5790 + PUT_UINT32(X3, output, 12);
5793 - X1 = RK[1] ^ ( FSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^
5794 - ( FSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^
5795 - ( FSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^
5796 - ( FSb[ (uint8) ( Y0 ) ] );
5797 +/* AES 128-bit block decryption routine */
5799 - X2 = RK[2] ^ ( FSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^
5800 - ( FSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^
5801 - ( FSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^
5802 - ( FSb[ (uint8) ( Y1 ) ] );
5803 +void aes_decrypt(aes_context * ctx, uint8 input[16], uint8 output[16])
5805 + uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
5807 - X3 = RK[3] ^ ( FSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^
5808 - ( FSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^
5809 - ( FSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^
5810 - ( FSb[ (uint8) ( Y2 ) ] );
5813 - PUT_UINT32( X0, output, 0 );
5814 - PUT_UINT32( X1, output, 4 );
5815 - PUT_UINT32( X2, output, 8 );
5816 - PUT_UINT32( X3, output, 12 );
5817 + GET_UINT32(X0, input, 0);
5819 + GET_UINT32(X1, input, 4);
5821 + GET_UINT32(X2, input, 8);
5823 + GET_UINT32(X3, input, 12);
5826 +#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
5830 + X0 = RK[0] ^ RT0[ (uint8) ( Y0 >> 24 ) ] ^ \
5831 + RT1[ (uint8) ( Y3 >> 16 ) ] ^ \
5832 + RT2[ (uint8) ( Y2 >> 8 ) ] ^ \
5833 + RT3[ (uint8) ( Y1 ) ]; \
5835 + X1 = RK[1] ^ RT0[ (uint8) ( Y1 >> 24 ) ] ^ \
5836 + RT1[ (uint8) ( Y0 >> 16 ) ] ^ \
5837 + RT2[ (uint8) ( Y3 >> 8 ) ] ^ \
5838 + RT3[ (uint8) ( Y2 ) ]; \
5840 + X2 = RK[2] ^ RT0[ (uint8) ( Y2 >> 24 ) ] ^ \
5841 + RT1[ (uint8) ( Y1 >> 16 ) ] ^ \
5842 + RT2[ (uint8) ( Y0 >> 8 ) ] ^ \
5843 + RT3[ (uint8) ( Y3 ) ]; \
5845 + X3 = RK[3] ^ RT0[ (uint8) ( Y3 >> 24 ) ] ^ \
5846 + RT1[ (uint8) ( Y2 >> 16 ) ] ^ \
5847 + RT2[ (uint8) ( Y1 >> 8 ) ] ^ \
5848 + RT3[ (uint8) ( Y0 ) ]; \
5851 -/* AES 128-bit block decryption routine */
5852 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 1 */
5853 + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 2 */
5854 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 3 */
5855 + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 4 */
5856 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 5 */
5857 + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 6 */
5858 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 7 */
5859 + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 8 */
5860 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 9 */
5862 + if (ctx->nr > 10) {
5863 + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 10 */
5864 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 11 */
5867 + if (ctx->nr > 12) {
5868 + AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3); /* round 12 */
5869 + AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3); /* round 13 */
5876 + X0 = RK[0] ^ (RSb[(uint8) (Y0 >> 24)] << 24) ^
5877 + (RSb[(uint8) (Y3 >> 16)] << 16) ^
5878 + (RSb[(uint8) (Y2 >> 8)] << 8) ^ (RSb[(uint8) (Y1)]);
5880 + X1 = RK[1] ^ (RSb[(uint8) (Y1 >> 24)] << 24) ^
5881 + (RSb[(uint8) (Y0 >> 16)] << 16) ^
5882 + (RSb[(uint8) (Y3 >> 8)] << 8) ^ (RSb[(uint8) (Y2)]);
5884 + X2 = RK[2] ^ (RSb[(uint8) (Y2 >> 24)] << 24) ^
5885 + (RSb[(uint8) (Y1 >> 16)] << 16) ^
5886 + (RSb[(uint8) (Y0 >> 8)] << 8) ^ (RSb[(uint8) (Y3)]);
5888 + X3 = RK[3] ^ (RSb[(uint8) (Y3 >> 24)] << 24) ^
5889 + (RSb[(uint8) (Y2 >> 16)] << 16) ^
5890 + (RSb[(uint8) (Y1 >> 8)] << 8) ^ (RSb[(uint8) (Y0)]);
5892 + PUT_UINT32(X0, output, 0);
5893 + PUT_UINT32(X1, output, 4);
5894 + PUT_UINT32(X2, output, 8);
5895 + PUT_UINT32(X3, output, 12);
5898 -void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] )
5899 +void hmac_sha1(unsigned char *text, int text_len, unsigned char *key,
5900 + int key_len, unsigned char *digest)
5902 - uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
5906 - GET_UINT32( X0, input, 0 ); X0 ^= RK[0];
5907 - GET_UINT32( X1, input, 4 ); X1 ^= RK[1];
5908 - GET_UINT32( X2, input, 8 ); X2 ^= RK[2];
5909 - GET_UINT32( X3, input, 12 ); X3 ^= RK[3];
5911 -#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
5915 - X0 = RK[0] ^ RT0[ (uint8) ( Y0 >> 24 ) ] ^ \
5916 - RT1[ (uint8) ( Y3 >> 16 ) ] ^ \
5917 - RT2[ (uint8) ( Y2 >> 8 ) ] ^ \
5918 - RT3[ (uint8) ( Y1 ) ]; \
5920 - X1 = RK[1] ^ RT0[ (uint8) ( Y1 >> 24 ) ] ^ \
5921 - RT1[ (uint8) ( Y0 >> 16 ) ] ^ \
5922 - RT2[ (uint8) ( Y3 >> 8 ) ] ^ \
5923 - RT3[ (uint8) ( Y2 ) ]; \
5925 - X2 = RK[2] ^ RT0[ (uint8) ( Y2 >> 24 ) ] ^ \
5926 - RT1[ (uint8) ( Y1 >> 16 ) ] ^ \
5927 - RT2[ (uint8) ( Y0 >> 8 ) ] ^ \
5928 - RT3[ (uint8) ( Y3 ) ]; \
5930 - X3 = RK[3] ^ RT0[ (uint8) ( Y3 >> 24 ) ] ^ \
5931 - RT1[ (uint8) ( Y2 >> 16 ) ] ^ \
5932 - RT2[ (uint8) ( Y1 >> 8 ) ] ^ \
5933 - RT3[ (uint8) ( Y0 ) ]; \
5936 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */
5937 - AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */
5938 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */
5939 - AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */
5940 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */
5941 - AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */
5942 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */
5943 - AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */
5944 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */
5946 - if( ctx->nr > 10 )
5948 - AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */
5949 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */
5952 - if( ctx->nr > 12 )
5954 - AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */
5955 - AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */
5958 + unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */
5959 + unsigned char k_opad[65]; /* outer padding - key XORd with opad */
5962 + /* if key is longer than 64 bytes reset it to key=SHA1(key) */
5963 + if (key_len > 64) {
5967 + SHAUpdate(&tctx, key, key_len);
5968 + SHAFinal(&tctx, key);
5974 + * the HMAC_SHA1 transform looks like:
5976 + * SHA1(K XOR opad, SHA1(K XOR ipad, text))
5978 + * where K is an n byte key
5979 + * ipad is the byte 0x36 repeated 64 times
5980 + * opad is the byte 0x5c repeated 64 times
5981 + * and text is the data being protected
5984 + /* start out by storing key in pads */
5985 + memset(k_ipad, 0, sizeof k_ipad);
5986 + memset(k_opad, 0, sizeof k_opad);
5987 + memcpy(k_ipad, key, key_len);
5988 + memcpy(k_opad, key, key_len);
5990 + /* XOR key with ipad and opad values */
5991 + for (i = 0; i < 64; i++) {
5992 + k_ipad[i] ^= 0x36;
5993 + k_opad[i] ^= 0x5c;
5996 + /* perform inner SHA1 */
5997 + SHAInit(&context); /* init context for 1st pass */
5998 + SHAUpdate(&context, k_ipad, 64); /* start with inner pad */
5999 + SHAUpdate(&context, text, text_len); /* then text of datagram */
6000 + SHAFinal(&context, digest); /* finish up 1st pass */
6002 + /* perform outer SHA1 */
6003 + SHAInit(&context); /* init context for 2nd pass */
6004 + SHAUpdate(&context, k_opad, 64); /* start with outer pad */
6005 + SHAUpdate(&context, digest, 20); /* then results of 1st hash */
6006 + SHAFinal(&context, digest); /* finish up 2nd pass */
6011 +* F(P, S, c, i) = U1 xor U2 xor ... Uc
6012 +* U1 = PRF(P, S || Int(i))
6014 +* Uc = PRF(P, Uc-1)
6018 +void F(char *password, unsigned char *ssid, int ssidlength, int iterations,
6019 + int count, unsigned char *output)
6021 + unsigned char digest[36], digest1[SHA_DIGEST_LEN];
6024 - X0 = RK[0] ^ ( RSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^
6025 - ( RSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^
6026 - ( RSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^
6027 - ( RSb[ (uint8) ( Y1 ) ] );
6029 - X1 = RK[1] ^ ( RSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^
6030 - ( RSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^
6031 - ( RSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^
6032 - ( RSb[ (uint8) ( Y2 ) ] );
6034 - X2 = RK[2] ^ ( RSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^
6035 - ( RSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^
6036 - ( RSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^
6037 - ( RSb[ (uint8) ( Y3 ) ] );
6039 - X3 = RK[3] ^ ( RSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^
6040 - ( RSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^
6041 - ( RSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^
6042 - ( RSb[ (uint8) ( Y0 ) ] );
6044 - PUT_UINT32( X0, output, 0 );
6045 - PUT_UINT32( X1, output, 4 );
6046 - PUT_UINT32( X2, output, 8 );
6047 - PUT_UINT32( X3, output, 12 );
6050 -void hmac_sha1(unsigned char *text, int text_len, unsigned char *key, int key_len, unsigned char *digest)
6053 - unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */
6054 - unsigned char k_opad[65]; /* outer padding - key XORd with opad */
6057 - /* if key is longer than 64 bytes reset it to key=SHA1(key) */
6063 - SHAUpdate(&tctx, key, key_len);
6064 - SHAFinal(&tctx, key);
6070 - * the HMAC_SHA1 transform looks like:
6072 - * SHA1(K XOR opad, SHA1(K XOR ipad, text))
6074 - * where K is an n byte key
6075 - * ipad is the byte 0x36 repeated 64 times
6076 - * opad is the byte 0x5c repeated 64 times
6077 - * and text is the data being protected
6080 - /* start out by storing key in pads */
6081 - memset(k_ipad, 0, sizeof k_ipad);
6082 - memset(k_opad, 0, sizeof k_opad);
6083 - memcpy(k_ipad, key, key_len);
6084 - memcpy(k_opad, key, key_len);
6086 - /* XOR key with ipad and opad values */
6087 - for (i = 0; i < 64; i++)
6089 - k_ipad[i] ^= 0x36;
6090 - k_opad[i] ^= 0x5c;
6093 - /* perform inner SHA1*/
6094 - SHAInit(&context); /* init context for 1st pass */
6095 - SHAUpdate(&context, k_ipad, 64); /* start with inner pad */
6096 - SHAUpdate(&context, text, text_len); /* then text of datagram */
6097 - SHAFinal(&context, digest); /* finish up 1st pass */
6099 - /* perform outer SHA1 */
6100 - SHAInit(&context); /* init context for 2nd pass */
6101 - SHAUpdate(&context, k_opad, 64); /* start with outer pad */
6102 - SHAUpdate(&context, digest, 20); /* then results of 1st hash */
6103 - SHAFinal(&context, digest); /* finish up 2nd pass */
6105 + /* U1 = PRF(P, S || int(i)) */
6106 + memcpy(digest, ssid, ssidlength);
6107 + digest[ssidlength] = (unsigned char)((count >> 24) & 0xff);
6108 + digest[ssidlength + 1] = (unsigned char)((count >> 16) & 0xff);
6109 + digest[ssidlength + 2] = (unsigned char)((count >> 8) & 0xff);
6110 + digest[ssidlength + 3] = (unsigned char)(count & 0xff);
6111 + hmac_sha1(digest, ssidlength + 4, (unsigned char *)password, (int)strlen(password), digest1); // for WPA update
6114 + memcpy(output, digest1, SHA_DIGEST_LEN);
6116 + for (i = 1; i < iterations; i++) {
6117 + /* Un = PRF(P, Un-1) */
6118 + hmac_sha1(digest1, SHA_DIGEST_LEN, (unsigned char *)password, (int)strlen(password), digest); // for WPA update
6119 + memcpy(digest1, digest, SHA_DIGEST_LEN);
6121 + /* output = output xor Un */
6122 + for (j = 0; j < SHA_DIGEST_LEN; j++) {
6123 + output[j] ^= digest[j];
6129 -* F(P, S, c, i) = U1 xor U2 xor ... Uc
6130 -* U1 = PRF(P, S || Int(i))
6132 -* Uc = PRF(P, Uc-1)
6135 -void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output)
6137 - unsigned char digest[36], digest1[SHA_DIGEST_LEN];
6140 - /* U1 = PRF(P, S || int(i)) */
6141 - memcpy(digest, ssid, ssidlength);
6142 - digest[ssidlength] = (unsigned char)((count>>24) & 0xff);
6143 - digest[ssidlength+1] = (unsigned char)((count>>16) & 0xff);
6144 - digest[ssidlength+2] = (unsigned char)((count>>8) & 0xff);
6145 - digest[ssidlength+3] = (unsigned char)(count & 0xff);
6146 - hmac_sha1(digest, ssidlength+4, (unsigned char*) password, (int) strlen(password), digest1); // for WPA update
6149 - memcpy(output, digest1, SHA_DIGEST_LEN);
6151 - for (i = 1; i < iterations; i++)
6153 - /* Un = PRF(P, Un-1) */
6154 - hmac_sha1(digest1, SHA_DIGEST_LEN, (unsigned char*) password, (int) strlen(password), digest); // for WPA update
6155 - memcpy(digest1, digest, SHA_DIGEST_LEN);
6157 - /* output = output xor Un */
6158 - for (j = 0; j < SHA_DIGEST_LEN; j++)
6160 - output[j] ^= digest[j];
6165 -* password - ascii string up to 63 characters in length
6166 -* ssid - octet string up to 32 octets
6167 -* ssidlength - length of ssid in octets
6168 -* output must be 40 octets in length and outputs 256 bits of key
6170 -int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output)
6172 - if ((strlen(password) > 63) || (ssidlength > 32))
6175 - F(password, ssid, ssidlength, 4096, 1, output);
6176 - F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]);
6178 +* password - ascii string up to 63 characters in length
6179 +* ssid - octet string up to 32 octets
6180 +* ssidlength - length of ssid in octets
6181 +* output must be 40 octets in length and outputs 256 bits of key
6183 +int PasswordHash(char *password, unsigned char *ssid, int ssidlength,
6184 + unsigned char *output)
6186 + if ((strlen(password) > 63) || (ssidlength > 32))
6189 + F(password, ssid, ssidlength, 4096, 1, output);
6190 + F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]);
6193 diff -Nur rt2500-1.1.0-b4/Module/md5.h rt2500-cvs-2007061011/Module/md5.h
6194 --- rt2500-1.1.0-b4/Module/md5.h 2006-06-17 22:12:58.000000000 +0200
6195 +++ rt2500-cvs-2007061011/Module/md5.h 2007-05-29 05:49:17.000000000 +0200
6197 -/***************************************************************************
6198 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
6200 - * This program is free software; you can redistribute it and/or modify *
6201 - * it under the terms of the GNU General Public License as published by *
6202 - * the Free Software Foundation; either version 2 of the License, or *
6203 - * (at your option) any later version. *
6205 - * This program is distributed in the hope that it will be useful, *
6206 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
6207 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
6208 - * GNU General Public License for more details. *
6210 - * You should have received a copy of the GNU General Public License *
6211 - * along with this program; if not, write to the *
6212 - * Free Software Foundation, Inc., *
6213 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
6215 - * Licensed under the GNU GPL *
6216 - * Original code supplied under license from RaLink Inc, 2004. *
6217 +/***************************************************************************
6218 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
6220 + * This program is free software; you can redistribute it and/or modify *
6221 + * it under the terms of the GNU General Public License as published by *
6222 + * the Free Software Foundation; either version 2 of the License, or *
6223 + * (at your option) any later version. *
6225 + * This program is distributed in the hope that it will be useful, *
6226 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
6227 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
6228 + * GNU General Public License for more details. *
6230 + * You should have received a copy of the GNU General Public License *
6231 + * along with this program; if not, write to the *
6232 + * Free Software Foundation, Inc., *
6233 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
6235 + * Licensed under the GNU GPL *
6236 + * Original code supplied under license from RaLink Inc, 2004. *
6237 * This MD5 code is based on code from Dynamics -- HUT Mobile IP *
6238 * Copyright (C) 1998-2001, Dynamics group *
6239 - ***************************************************************************/
6240 + ***************************************************************************/
6242 - /***************************************************************************
6243 + /***************************************************************************
6244 * Module Name: md5.h
6247 * Abstract: contain MD5 and AES cipher algorithm
6249 - * Revision History:
6251 - * -------- ----------- -----------------------------
6252 - * MarkW 8th Dec 04 Baseline code
6253 - ***************************************************************************/
6255 + * Revision History:
6257 + * -------- ----------- -----------------------------
6258 + * MarkW 8th Dec 04 Baseline code
6259 + ***************************************************************************/
6266 #define MD5_MAC_LEN 16
6267 #define SHA_DIGEST_LEN 20
6269 -struct MD5Context {
6274 +typedef struct _MD5_CTX {
6275 + ULONG Buf[4]; // buffers of four states
6276 + UCHAR Input[64]; // input message
6277 + ULONG LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
6280 +VOID MD5Init(MD5_CTX * pCtx);
6281 +VOID MD5Update(MD5_CTX * pCtx, UCHAR * pData, ULONG LenInBytes);
6282 +VOID MD5Final(UCHAR Digest[16], MD5_CTX * pCtx);
6283 +VOID MD5Transform(ULONG Buf[4], ULONG Mes[16]);
6285 +void md5_mac(UCHAR * key, ULONG key_len, UCHAR * data, ULONG data_len,
6287 +void hmac_md5(UCHAR * key, ULONG key_len, UCHAR * data, ULONG data_len,
6290 +#endif // __MD5_H__
6292 +/******************************************************************************/
6294 +VOID SHAInit(SHA_CTX * pCtx);
6295 +UCHAR SHAUpdate(SHA_CTX * pCtx, UCHAR * pData, ULONG LenInBytes);
6296 +VOID SHAFinal(SHA_CTX * pCtx, UCHAR Digest[20]);
6297 +VOID SHATransform(ULONG Buf[5], ULONG Mes[20]);
6299 +void hmac_sha1(unsigned char *text, int text_len, unsigned char *key,
6300 + int key_len, unsigned char *digest);
6301 +void F(char *password, unsigned char *ssid, int ssidlength, int iterations,
6302 + int count, unsigned char *output);
6303 +int PasswordHash(char *password, unsigned char *ssid, int ssidlength,
6304 + unsigned char *output);
6306 +/******************************************************************************/
6310 -void MD5Init(struct MD5Context *context);
6311 -void MD5Update(struct MD5Context *context, unsigned char *buf, unsigned len);
6312 -void MD5Final(unsigned char digest[16], struct MD5Context *context);
6313 -void MD5Transform(u32 buf[4], u32 in[16]);
6315 -typedef struct MD5Context MD5_CTX;
6318 -void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
6319 -void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
6327 -#define uint8 unsigned char
6329 +#define uint8 unsigned char
6333 -#define uint32 unsigned long int
6335 +#define uint32 unsigned long int
6340 - uint32 erk[64]; /* encryption round keys */
6341 - uint32 drk[64]; /* decryption round keys */
6342 - int nr; /* number of rounds */
6346 -int aes_set_key( aes_context *ctx, uint8 *key, int nbits );
6347 -void aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
6348 -void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
6351 -void SHAInit(SHA_CTX *ctx);
6352 -void SHAUpdate(SHA_CTX *ctx, unsigned char *dataIn, int len);
6353 -void SHAFinal(SHA_CTX *ctx, unsigned char hashout[20]);
6354 -void SHAHashBlock(SHA_CTX *ctx);
6355 -void hmac_sha1(unsigned char *text, int text_len, unsigned char *key, int key_len, unsigned char *digest);
6356 -void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);
6357 -int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);
6361 + uint32 erk[64]; /* encryption round keys */
6362 + uint32 drk[64]; /* decryption round keys */
6363 + int nr; /* number of rounds */
6366 +int aes_set_key(aes_context * ctx, uint8 * key, int nbits);
6367 +void aes_encrypt(aes_context * ctx, uint8 input[16], uint8 output[16]);
6368 +void aes_decrypt(aes_context * ctx, uint8 input[16], uint8 output[16]);
6371 diff -Nur rt2500-1.1.0-b4/Module/mlme.c rt2500-cvs-2007061011/Module/mlme.c
6372 --- rt2500-1.1.0-b4/Module/mlme.c 2006-06-17 22:12:58.000000000 +0200
6373 +++ rt2500-cvs-2007061011/Module/mlme.c 2007-05-15 21:41:34.000000000 +0200
6375 -/***************************************************************************
6376 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
6378 - * This program is free software; you can redistribute it and/or modify *
6379 - * it under the terms of the GNU General Public License as published by *
6380 - * the Free Software Foundation; either version 2 of the License, or *
6381 - * (at your option) any later version. *
6383 - * This program is distributed in the hope that it will be useful, *
6384 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
6385 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
6386 - * GNU General Public License for more details. *
6388 - * You should have received a copy of the GNU General Public License *
6389 - * along with this program; if not, write to the *
6390 - * Free Software Foundation, Inc., *
6391 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
6393 - * Licensed under the GNU GPL *
6394 - * Original code supplied under license from RaLink Inc, 2004. *
6395 - ***************************************************************************/
6396 +/***************************************************************************
6397 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
6399 + * This program is free software; you can redistribute it and/or modify *
6400 + * it under the terms of the GNU General Public License as published by *
6401 + * the Free Software Foundation; either version 2 of the License, or *
6402 + * (at your option) any later version. *
6404 + * This program is distributed in the hope that it will be useful, *
6405 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
6406 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
6407 + * GNU General Public License for more details. *
6409 + * You should have received a copy of the GNU General Public License *
6410 + * along with this program; if not, write to the *
6411 + * Free Software Foundation, Inc., *
6412 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
6414 + * Licensed under the GNU GPL *
6415 + * Original code supplied under license from RaLink Inc, 2004. *
6416 + ***************************************************************************/
6418 - /***************************************************************************
6419 + /***************************************************************************
6420 * Module Name: mlme.c
6424 - * Revision History:
6426 - * -------- ----------- -----------------------------
6427 - * MarkW 8th Dec 04 Baseline code
6431 + * Revision History:
6433 + * -------- ----------- -----------------------------
6434 + * MarkW 8th Dec 04 Baseline code
6435 * MarkW 8th Dec 04 kmalloc ATOMIC fixes
6436 - * RobinC 10th Dec 04 RFMON Support
6437 - * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
6438 - * Ivo (rt2400) 15th Dec 04 Uninitialised timer
6439 + * RobinC 10th Dec 04 RFMON Support
6440 + * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
6441 + * Ivo (rt2400) 15th Dec 04 Uninitialised timer
6442 * MarkW 17th Dec 04 Monitor mode through iwconfig
6443 * BrunoH 3rd Feb 04 Fix for 802.11b adhoc association
6444 - * JohnC 19th Mar 04 Fixes for quality reporting
6445 + * JohnC 19th Mar 04 Fixes for quality reporting
6446 * MarkW 13th Jun 05 Fix to allow adhoc network creation
6447 - ***************************************************************************/
6448 + ***************************************************************************/
6450 #include "rt_config.h"
6453 -// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than
6454 -// this value, then it's quaranteed capable of operating in 36 mbps TX rate in
6455 +// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than
6456 +// this value, then it's quaranteed capable of operating in 36 mbps TX rate in
6457 // clean environment.
6458 // TxRate: 1 2 5.5 11 6 9 12 18 24 36 48 54 72 100
6459 CHAR RssiSafeLevelForTxRate[] ={ -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 };
6463 UCHAR Phy11BNextRateDownward[] = {RATE_1, RATE_1, RATE_2, RATE_5_5};
6464 UCHAR Phy11BNextRateUpward[] = {RATE_2, RATE_5_5, RATE_11, RATE_11};
6468 USHORT OldRateUpPER[] = { 40, 40, 40, 40, 30, 30, 30, 30, 20, 20, 10, 10 }; // in percentage
6469 USHORT OldRateDownPER[] = { 45, 45, 45, 45, 35, 35, 35, 35, 25, 25, 25, 12 }; // in percentage
6472 UCHAR RateIdToMbps[] = { 1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 72, 100};
6473 USHORT RateIdTo500Kbps[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144, 200};
6476 RTMP_RF_REGS RF2522RegTable[] = {
6477 // ch R1 R2 R3(TX0~4=0) R4
6478 {1, 0x94002050, 0x940c1fda, 0x94000101, 0},
6479 @@ -144,10 +144,10 @@
6480 {14, 0x94032020, 0x94000d1a, 0x94000101, 0x94000a03}
6482 #define NUM_OF_2524_CHNL (sizeof(RF2524RegTable) / sizeof(RTMP_RF_REGS))
6485 RTMP_RF_REGS RF2525RegTable[] = {
6486 // ch R1 R2 R3(TX0~4=0) R4
6487 - {1, 0x94022020, 0x94080c9e, 0x94060111, 0x94000a1b}, // {1, 0x94022010, 0x9408062e, 0x94060111, 0x94000a23},
6488 + {1, 0x94022020, 0x94080c9e, 0x94060111, 0x94000a1b}, // {1, 0x94022010, 0x9408062e, 0x94060111, 0x94000a23},
6489 {2, 0x94022020, 0x94080ca2, 0x94060111, 0x94000a1b},
6490 {3, 0x94022020, 0x94080ca6, 0x94060111, 0x94000a1b},
6491 {4, 0x94022020, 0x94080caa, 0x94060111, 0x94000a1b},
6492 @@ -157,15 +157,15 @@
6493 {8, 0x94022020, 0x94080cba, 0x94060111, 0x94000a1b},
6494 {9, 0x94022020, 0x94080cbe, 0x94060111, 0x94000a1b},
6495 {10, 0x94022020, 0x94080d02, 0x94060111, 0x94000a1b},
6496 - {11, 0x94022020, 0x94080d06, 0x94060111, 0x94000a1b}, // {11, 0x94022010, 0x94080682, 0x94060111, 0x94000a23},
6497 + {11, 0x94022020, 0x94080d06, 0x94060111, 0x94000a1b}, // {11, 0x94022010, 0x94080682, 0x94060111, 0x94000a23},
6498 {12, 0x94022020, 0x94080d0a, 0x94060111, 0x94000a1b},
6499 - {13, 0x94022020, 0x94080d0e, 0x94060111, 0x94000a1b}, // {13, 0x94022010, 0x94080686, 0x94060111, 0x94000a23},
6500 + {13, 0x94022020, 0x94080d0e, 0x94060111, 0x94000a1b}, // {13, 0x94022010, 0x94080686, 0x94060111, 0x94000a23},
6501 {14, 0x94022020, 0x94080d1a, 0x94060111, 0x94000a03}
6503 #define NUM_OF_2525_CHNL (sizeof(RF2525RegTable) / sizeof(RTMP_RF_REGS))
6505 RTMP_RF_REGS RF2525HBOffsetRegTable[] = {
6506 - {1, 0x94022020, 0x94080cbe, 0x94060111, 0x94000a1b},
6507 + {1, 0x94022020, 0x94080cbe, 0x94060111, 0x94000a1b},
6508 {2, 0x94022020, 0x94080d02, 0x94060111, 0x94000a1b},
6509 {3, 0x94022020, 0x94080d06, 0x94060111, 0x94000a1b},
6510 {4, 0x94022020, 0x94080d0a, 0x94060111, 0x94000a1b},
6512 {8, 0x94022020, 0x94080d1a, 0x94060111, 0x94000a1b},
6513 {9, 0x94022020, 0x94080d1e, 0x94060111, 0x94000a1b},
6514 {10, 0x94022020, 0x94080d22, 0x94060111, 0x94000a1b},
6515 - {11, 0x94022020, 0x94080d26, 0x94060111, 0x94000a1b},
6516 + {11, 0x94022020, 0x94080d26, 0x94060111, 0x94000a1b},
6517 {12, 0x94022020, 0x94080d2a, 0x94060111, 0x94000a1b},
6518 - {13, 0x94022020, 0x94080d2e, 0x94060111, 0x94000a1b},
6519 + {13, 0x94022020, 0x94080d2e, 0x94060111, 0x94000a1b},
6520 {14, 0x94022020, 0x94080d3a, 0x94060111, 0x94000a03}
6524 {8, 0x94022020, 0x94081192, 0x94060111, 0x94000a0b},
6525 {9, 0x94022020, 0x94081196, 0x94060111, 0x94000a0b},
6526 {10, 0x94022020, 0x9408119a, 0x94060111, 0x94000a0b},
6527 - {11, 0x94022020, 0x9408119e, 0x94060111, 0x94000a0b},
6528 + {11, 0x94022020, 0x9408119e, 0x94060111, 0x94000a0b},
6529 {12, 0x94022020, 0x940811a2, 0x94060111, 0x94000a0b},
6530 {13, 0x94022020, 0x940811a6, 0x94060111, 0x94000a0b},
6531 {14, 0x94022020, 0x940811ae, 0x94060111, 0x94000a1b}
6533 {8, 0x94022010, 0x940808aa, 0x94060111, 0x94000a07},
6534 {9, 0x94022010, 0x940808aa, 0x94060111, 0x94000a1b},
6535 {10, 0x94022010, 0x940808ae, 0x94060111, 0x94000a07},
6536 - {11, 0x94022010, 0x940808ae, 0x94060111, 0x94000a1b},
6537 + {11, 0x94022010, 0x940808ae, 0x94060111, 0x94000a1b},
6538 {12, 0x94022010, 0x940808b2, 0x94060111, 0x94000a07},
6539 {13, 0x94022010, 0x940808b2, 0x94060111, 0x94000a1b},
6540 {14, 0x94022010, 0x940808b6, 0x94060111, 0x94000a23}
6542 {14, 0x94022020, 0x940011ae, 0x94000101, 0x94000a1b},
6544 // still lack of MMAC(Japan) ch 34,38,42,46
6547 {36, 0x94022010, 0x94018896, 0x94000101, 0x94000a1f},
6548 {40, 0x94022010, 0x9401889a, 0x94000101, 0x94000a1f},
6549 {44, 0x94022010, 0x9401889e, 0x94000101, 0x94000a1f},
6551 {66, 0x94022010, 0x940188aa, 0x94000101, 0x94000a1f},
6552 {60, 0x94022010, 0x940188ae, 0x94000101, 0x94000a1f},
6553 {64, 0x94022010, 0x940188b2, 0x94000101, 0x94000a1f},
6556 {100, 0x94022010, 0x94008802, 0x94000101, 0x94000a0f},
6557 {104, 0x94022010, 0x94008806, 0x94000101, 0x94000a0f},
6558 {108, 0x94022010, 0x9400880a, 0x94000101, 0x94000a0f},
6560 {132, 0x94022010, 0x94008822, 0x94000101, 0x94000a0f},
6561 {136, 0x94022010, 0x94008826, 0x94000101, 0x94000a0f},
6562 {140, 0x94022010, 0x9400882a, 0x94000101, 0x94000a0f},
6565 {149, 0x94022020, 0x940090a6, 0x94000101, 0x94000a07},
6566 {153, 0x94022020, 0x940090ae, 0x94000101, 0x94000a07},
6567 {157, 0x94022020, 0x940090b6, 0x94000101, 0x94000a07},
6568 @@ -270,14 +270,14 @@
6570 ==========================================================================
6572 - initialize the MLME task and its data structure (queue, spinlock,
6573 + initialize the MLME task and its data structure (queue, spinlock,
6574 timer, state machines).
6576 always return NDIS_STATUS_SUCCESS
6577 ==========================================================================
6579 NDIS_STATUS MlmeInit(
6580 - IN PRTMP_ADAPTER pAd)
6581 + IN PRTMP_ADAPTER pAd)
6583 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
6588 DBGPRINT(RT_DEBUG_TRACE, "--> MLME Initialize\n");
6594 pAd->Mlme.Running = FALSE;
6595 spin_lock_init(&pAd->Mlme.TaskLock);
6596 @@ -298,10 +298,10 @@
6597 // init state machines
6598 ASSERT(ASSOC_FUNC_SIZE == MAX_ASSOC_MSG * MAX_ASSOC_STATE);
6599 AssocStateMachineInit(pAd, &pAd->Mlme.AssocMachine, pAd->Mlme.AssocFunc);
6602 ASSERT(AUTH_FUNC_SIZE == MAX_AUTH_MSG * MAX_AUTH_STATE);
6603 AuthStateMachineInit(pAd, &pAd->Mlme.AuthMachine, pAd->Mlme.AuthFunc);
6606 ASSERT(AUTH_RSP_FUNC_SIZE == MAX_AUTH_RSP_MSG * MAX_AUTH_RSP_STATE);
6607 AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine, pAd->Mlme.AuthRspFunc);
6611 ASSERT(WPA_PSK_FUNC_SIZE == MAX_WPA_PSK_MSG * MAX_WPA_PSK_STATE);
6612 WpaPskStateMachineInit(pAd,&pAd->Mlme.WpaPskMachine,pAd->Mlme.WpaPskFunc);
6614 - // Since we are using switch/case to implement it, the init is different from the above
6616 + // Since we are using switch/case to implement it, the init is different from the above
6617 // state machine init
6618 MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
6623 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MLME_INITIALIZED);
6626 DBGPRINT(RT_DEBUG_TRACE, "<-- MLME Initialize\n");
6629 @@ -347,83 +347,70 @@
6630 Mlme has to be initialized, and there are something inside the queue
6632 This function is invoked from MPSetInformation and MPReceive;
6633 - This task guarantee only one MlmeHandler will run.
6634 + This task guarantee only one MlmeHandler will run.
6635 ==========================================================================
6638 - IN PRTMP_ADAPTER pAd)
6640 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
6641 - schedule_work(&pAd->mlme_work);
6644 -VOID MlmeWork(void *vpAd)
6645 + IN PRTMP_ADAPTER pAd)
6647 - PRTMP_ADAPTER pAd = vpAd;
6649 MLME_QUEUE_ELEM *Elem = NULL;
6650 unsigned long flags;
6653 // Only accept MLME and Frame from peer side, no other (control/data) frame should
6654 // get into this state machine
6656 - spin_lock_irqsave(&pAd->Mlme.TaskLock,flags);
6657 - if(pAd->Mlme.Running)
6658 + spin_lock_irqsave(&pAd->Mlme.TaskLock, flags);
6659 + if(pAd->Mlme.Running)
6661 - spin_unlock_irqrestore(&pAd->Mlme.TaskLock,flags);
6662 + spin_unlock_irqrestore(&pAd->Mlme.TaskLock, flags);
6669 pAd->Mlme.Running = TRUE;
6671 - spin_unlock_irqrestore(&pAd->Mlme.TaskLock,flags);
6672 + spin_unlock_irqrestore(&pAd->Mlme.TaskLock, flags);
6675 + spin_lock_irqsave(&pAd->Mlme.Queue.Lock, flags);
6676 + if (!MlmeDequeue(&pAd->Mlme.Queue, &Elem)) {
6677 + spin_unlock_irqrestore(&pAd->Mlme.Queue.Lock, flags);
6680 + spin_unlock_irqrestore(&pAd->Mlme.Queue.Lock, flags);
6682 + if (pAd->PortCfg.BssType == BSS_MONITOR)
6685 - while (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
6687 //From message type, determine which state machine I should drive
6688 - if (pAd->PortCfg.BssType != BSS_MONITOR)
6689 + switch (Elem->Machine)
6691 - // if dequeue success
6692 - switch (Elem->Machine)
6694 - case ASSOC_STATE_MACHINE:
6695 - StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem);
6697 - case AUTH_STATE_MACHINE:
6698 - StateMachinePerformAction(pAd, &pAd->Mlme.AuthMachine, Elem);
6700 - case AUTH_RSP_STATE_MACHINE:
6701 - StateMachinePerformAction(pAd, &pAd->Mlme.AuthRspMachine, Elem);
6703 - case SYNC_STATE_MACHINE:
6704 - StateMachinePerformAction(pAd, &pAd->Mlme.SyncMachine, Elem);
6706 - case MLME_CNTL_STATE_MACHINE:
6707 - MlmeCntlMachinePerformAction(pAd, &pAd->Mlme.CntlMachine, Elem);
6709 - case WPA_PSK_STATE_MACHINE:
6710 - StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);
6713 - DBGPRINT(RT_DEBUG_TRACE, "ERROR: Illegal machine in MlmeHandler()\n");
6715 - } // end of switch
6716 + case ASSOC_STATE_MACHINE:
6717 + StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem);
6719 + case AUTH_STATE_MACHINE:
6720 + StateMachinePerformAction(pAd, &pAd->Mlme.AuthMachine, Elem);
6722 + case AUTH_RSP_STATE_MACHINE:
6723 + StateMachinePerformAction(pAd, &pAd->Mlme.AuthRspMachine, Elem);
6725 + case SYNC_STATE_MACHINE:
6726 + StateMachinePerformAction(pAd, &pAd->Mlme.SyncMachine, Elem);
6728 + case MLME_CNTL_STATE_MACHINE:
6729 + MlmeCntlMachinePerformAction(pAd, &pAd->Mlme.CntlMachine, Elem);
6731 + case WPA_PSK_STATE_MACHINE:
6732 + StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);
6735 + DBGPRINT(RT_DEBUG_TRACE, "ERROR: Illegal machine in MlmeHandler()\n");
6737 + } // end of switch
6739 - // free MLME element
6740 - Elem->Occupied = FALSE;
6746 - printk(KERN_ERR DRV_NAME "ERROR: empty Elem in MlmeQueue\n");
6750 - /* something wrong - avoid locking up the computer solid */
6752 + // free MLME element
6753 + Elem->Occupied = FALSE;
6757 spin_lock_irqsave(&pAd->Mlme.TaskLock,flags);
6759 ==========================================================================
6762 - IN PRTMP_ADAPTER pAd)
6763 + IN PRTMP_ADAPTER pAd)
6765 MLME_DISASSOC_REQ_STRUCT DisReq;
6766 MLME_QUEUE_ELEM *MsgElem;
6770 DBGPRINT(RT_DEBUG_TRACE, "==> MlmeHalt\n");
6772 - if (INFRA_ON(pAd) && !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
6774 + if (INFRA_ON(pAd) && !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
6776 COPY_MAC_ADDR(&DisReq.Addr, &pAd->PortCfg.Bssid);
6777 DisReq.Reason = REASON_DISASSOC_STA_LEAVING;
6779 // disable BEACON generation and other BEACON related hardware timers
6780 AsicDisableSync(pAd);
6784 // Cancel pending timers
6785 RTMPCancelTimer(&pAd->Mlme.AssocAux.AssocTimer);
6786 RTMPCancelTimer(&pAd->Mlme.AssocAux.ReassocTimer);
6789 RTMPCancelTimer(&pAd->PortCfg.RxAnt.RxAntDiversityTimer);
6793 MlmeQueueDestroy(&pAd->Mlme.Queue);
6794 StateMachineDestroy(&pAd->Mlme.AssocMachine);
6795 StateMachineDestroy(&pAd->Mlme.AuthMachine);
6796 @@ -506,11 +493,11 @@
6797 //NdisFreeSpinLock(&pAd->Mlme.Queue.Lock);
6798 //NdisFreeSpinLock(&pAd->Mlme.TaskLock);
6799 // NdisFreeSpinLock(&pAd->PortCfg.MacTab.Lock);
6802 MlmeFreeMemoryHandler(pAd); //Free MLME memory handler
6804 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MLME_INITIALIZED);
6807 DBGPRINT(RT_DEBUG_TRACE, "<== MlmeHalt\n");
6810 @@ -519,42 +506,33 @@
6811 ==========================================================================
6813 This routine is executed periodically to -
6814 - 1. Decide if it's a right time to turn on PwrMgmt bit of all
6815 + 1. Decide if it's a right time to turn on PwrMgmt bit of all
6817 2. Calculate ChannelQuality based on statistics of the last
6818 - period, so that TX rate won't toggling very frequently between a
6819 + period, so that TX rate won't toggling very frequently between a
6820 successful TX and a failed TX.
6821 - 3. If the calculated ChannelQuality indicated current connection not
6822 + 3. If the calculated ChannelQuality indicated current connection not
6823 healthy, then a ROAMing attempt is tried here.
6824 ==========================================================================
6826 #define ADHOC_BEACON_LOST_TIME (10*HZ) // 4 sec
6827 VOID MlmePeriodicExec(
6828 - IN unsigned long data)
6829 + IN unsigned long data)
6831 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
6835 - if (pAd->PortCfg.BssType == BSS_MONITOR)
6837 - RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
6841 - if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
6843 - RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
6847 - if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS))
6849 - RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
6850 + if ((pAd->PortCfg.BssType == BSS_MONITOR)
6851 + || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)
6852 + || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)
6853 + || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)
6855 + RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
6859 - // check every 2 second. If rcv-beacon less than 5 in the past 2 second, then AvgRSSI is no longer a
6860 + // check every 2 second. If rcv-beacon less than 5 in the past 2 second, then AvgRSSI is no longer a
6861 // valid indication of the distance between this AP and its clients.
6862 if (pAd->MediaState == NdisMediaStateConnected)
6866 pAd->PortCfg.NumOfAvgRssiSample = 0;
6872 if (pAd->RalinkCounters.MgmtRingFullCount >= 2)
6875 pAd->RalinkCounters.MgmtRingFullCount = 0;
6879 if ((pAd->PortCfg.bBlockAssoc == TRUE) && (pAd->PortCfg.LastMicErrorTime + (60 * HZ) < Now32))
6881 pAd->PortCfg.bBlockAssoc = FALSE;
6882 @@ -600,11 +578,11 @@
6888 // danamic tune BBP R17 to find a balance between sensibility and noise isolation
6889 - // 2003-12-05 For 2560C and before, to avoid collision with MAC ASIC, limit
6890 + // 2003-12-05 For 2560C and before, to avoid collision with MAC ASIC, limit
6891 // BBP R17 tuning to be within 20 seconds after LINK UP. 2560D (R0=4) and
6892 - // after can always enable R17 tuning
6893 + // after can always enable R17 tuning
6894 if (pAd->PortCfg.Rt2560Version >= RT2560_VER_D)
6896 else if ((pAd->MediaState == NdisMediaStateConnected) && (pAd->Mlme.PeriodicRound <= 20))
6897 @@ -642,23 +620,23 @@
6898 if (pAd->PortCfg.MicErrCnt >= 3)
6900 MLME_DISASSOC_REQ_STRUCT DisassocReq;
6903 // disassoc from current AP first
6904 DBGPRINT(RT_DEBUG_TRACE, "MLME - disassociate with current AP after sending second continuous EAPOL frame\n");
6905 DisassocParmFill(pAd, &DisassocReq, &pAd->PortCfg.Bssid, REASON_MIC_FAILURE);
6906 - MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
6907 + MlmeEnqueue(&pAd->Mlme.Queue, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
6908 sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
6910 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
6911 pAd->PortCfg.bBlockAssoc = TRUE;
6918 // send out a NULL frame every 10 sec. for what??? inform "PwrMgmt" bit?
6919 if ((pAd->Mlme.PeriodicRound % 10) == 8)
6920 EnqueueNullFrame(pAd, pAd->PortCfg.TxRate);
6923 if (CQI_IS_BAD(pAd->Mlme.ChannelQuality))
6925 pAd->RalinkCounters.BadCQIAutoRecoveryCount ++;
6927 else if (CQI_IS_FAIR(pAd->Mlme.ChannelQuality) || CQI_IS_POOR(pAd->Mlme.ChannelQuality))
6929 // perform aggresive roaming only when SECURITY OFF or WEP64/128;
6930 - // WPA and WPA-PSK has no aggresive roaming because re-negotiation
6931 + // WPA and WPA-PSK has no aggresive roaming because re-negotiation
6932 // between 802.1x supplicant and authenticator/AAA server is required
6933 // but can't be guaranteed.
6934 if (pAd->PortCfg.AuthMode < Ndis802_11AuthModeWPA)
6936 // minimum BEACON to tell the peer I'm alive.
6937 // drawback is that this BEACON won't well align at TBTT boundary.
6938 RTMP_IO_READ32(pAd, CSR15, &Csr15.word); // read-n-clear "BcnSent" bit
6939 - if (Csr15.field.BeaconSent == 0)
6940 + if (Csr15.field.BeaconSent == 0)
6941 EnqueueBeaconFrame(pAd); // software send BEACON
6944 @@ -697,14 +675,14 @@
6945 (pAd->PortCfg.MaxDesiredRate > RATE_11) &&
6946 ((pAd->PortCfg.Last11bBeaconRxTime + (5 * HZ)) < Now32))
6948 - DBGPRINT(RT_DEBUG_TRACE, "last 11B peer left, update Tx rates\n");
6949 + DBGPRINT(RT_DEBUG_TRACE, "last 11B peer left, update Tx rates\n");
6950 memcpy(pAd->PortCfg.SupportedRates, pAd->PortCfg.IbssConfig.SupportedRates, MAX_LEN_OF_SUPPORTED_RATES);
6951 pAd->PortCfg.SupportedRatesLen = pAd->PortCfg.IbssConfig.SupportedRatesLen;
6952 MlmeUpdateTxRates(pAd, FALSE);
6953 MakeIbssBeacon(pAd); // supported rates changed
6958 #ifndef SINGLE_ADHOC_LINKUP
6959 // If all peers leave, and this STA becomes the last one in this IBSS, then change MediaState
6960 // to DISCONNECTED. But still holding this IBSS (i.e. sending BEACON) so that other STAs can
6962 if ((pAd->PortCfg.LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < Now32) &&
6963 (pAd->MediaState == NdisMediaStateConnected))
6965 - DBGPRINT(RT_DEBUG_TRACE, "MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n");
6966 + DBGPRINT(RT_DEBUG_TRACE, "MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n");
6968 pAd->MediaState = NdisMediaStateDisconnected;
6969 // clean up previous SCAN result, add current BSS back to table if any
6971 if ((pAd->PortCfg.BssTab.BssNr==0) && (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
6973 MLME_SCAN_REQ_STRUCT ScanReq;
6976 if ((pAd->PortCfg.LastScanTime + 10 * HZ) < Now32)
6978 DBGPRINT(RT_DEBUG_TRACE, "CNTL - No matching BSS, start a new scan\n");
6981 else if (pAd->PortCfg.BssType == BSS_INDEP) // Quit the forever scan when in a very clean room
6982 MlmeAutoRecoverNetwork(pAd);
6983 - //MlmeAutoReconnectLastSSID(pAd);
6984 + //MlmeAutoReconnectLastSSID(pAd);
6986 else if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
6991 MlmeAutoReconnectLastSSID(pAd);
6994 DBGPRINT(RT_DEBUG_INFO, "pAd->PortCfg.AutoReconnect is TRUE\n");
6999 RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
7004 IN PRTMP_ADAPTER pAd)
7006 @@ -783,17 +761,17 @@
7008 // tell CNTL state machine NOT to call NdisMSetInformationComplete() after completing
7009 // this request, because this request is initiated by driver itself.
7010 - pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7012 - MlmeEnqueue(&pAd->Mlme.Queue,
7013 - MLME_CNTL_STATE_MACHINE,
7014 - OID_802_11_BSSID_LIST_SCAN,
7016 + pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7018 + MlmeEnqueue(&pAd->Mlme.Queue,
7019 + MLME_CNTL_STATE_MACHINE,
7020 + OID_802_11_BSSID_LIST_SCAN,
7028 VOID MlmeAutoRecoverNetwork(
7029 IN PRTMP_ADAPTER pAd)
7031 @@ -808,18 +786,18 @@
7033 // tell CNTL state machine NOT to call NdisMSetInformationComplete() after completing
7034 // this request, because this request is initiated by driver itself.
7035 - pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7037 - MlmeEnqueue(&pAd->Mlme.Queue,
7038 - MLME_CNTL_STATE_MACHINE,
7040 - sizeof(NDIS_802_11_SSID),
7041 + pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7043 + MlmeEnqueue(&pAd->Mlme.Queue,
7044 + MLME_CNTL_STATE_MACHINE,
7046 + sizeof(NDIS_802_11_SSID),
7054 VOID MlmeAutoReconnectLastSSID(
7055 IN PRTMP_ADAPTER pAd)
7057 @@ -833,12 +811,12 @@
7058 DBGPRINT(RT_DEBUG_TRACE, "Driver auto reconnect to last OID_802_11_SSID setting - %s\n", pAd->Mlme.CntlAux.Ssid);
7060 // We will only try this attemp once, therefore change the AutoReconnect flag afterwards.
7061 - pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7063 - MlmeEnqueue(&pAd->Mlme.Queue,
7064 - MLME_CNTL_STATE_MACHINE,
7066 - sizeof(NDIS_802_11_SSID),
7067 + pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7069 + MlmeEnqueue(&pAd->Mlme.Queue,
7070 + MLME_CNTL_STATE_MACHINE,
7072 + sizeof(NDIS_802_11_SSID),
7076 @@ -867,17 +845,17 @@
7077 for (i = 0; i < pBssTab->BssNr; i++)
7079 pBss = &pBssTab->BssEntry[i];
7081 - if ((pBssTab->BssEntry[i].LastBeaconRxTime + BEACON_LOST_TIME) < Now32)
7083 + if ((pBssTab->BssEntry[i].LastBeaconRxTime + BEACON_LOST_TIME) < Now32)
7084 continue; // AP disappear
7085 if (pBss->Rssi <= RSSI_THRESHOLD_FOR_ROAMING)
7086 continue; // RSSI too weak. forget it.
7087 if (MAC_ADDR_EQUAL(&pBssTab->BssEntry[i].Bssid, &pAd->PortCfg.Bssid))
7088 continue; // skip current AP
7089 - if (CQI_IS_FAIR(pAd->Mlme.ChannelQuality) && (pAd->PortCfg.LastRssi + RSSI_DELTA > pBss->Rssi))
7090 + if (CQI_IS_FAIR(pAd->Mlme.ChannelQuality) && (pAd->PortCfg.LastRssi + RSSI_DELTA > pBss->Rssi))
7091 continue; // we're still okay, only AP with stronger RSSI is eligible for roaming
7093 - // AP passing all above rules is put into roaming candidate table
7094 + // AP passing all above rules is put into roaming candidate table
7095 memcpy(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
7096 pRoamTab->BssNr += 1;
7098 @@ -889,23 +867,23 @@
7100 // tell CNTL state machine NOT to call NdisMSetInformationComplete() after completing
7101 // this request, because this request is initiated by driver itself, not from NDIS.
7102 - pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7104 + pAd->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
7106 pAd->RalinkCounters.PoorCQIRoamingCount ++;
7107 DBGPRINT(RT_DEBUG_TRACE, "MMCHK - Roaming attempt #%d\n", pAd->RalinkCounters.PoorCQIRoamingCount);
7108 MlmeEnqueue(&pAd->Mlme.Queue, MLME_CNTL_STATE_MACHINE, MT2_MLME_ROAMING_REQ, 0, NULL);
7117 ==========================================================================
7119 - This routine calculates TxPER, RxPER of the past N-sec period. And
7120 - according to the calculation result, ChannelQuality is calculated here
7121 - to decide if current AP is still doing the job.
7122 + This routine calculates TxPER, RxPER of the past N-sec period. And
7123 + according to the calculation result, ChannelQuality is calculated here
7124 + to decide if current AP is still doing the job.
7126 If ChannelQuality is not good, a ROAMing attempt may be tried later.
7128 @@ -923,11 +901,11 @@
7130 // monitor TX counters change for the past period
7132 - TxFailCnt = pAd->WlanCounters.FailedCount.vv.LowPart -
7133 + TxFailCnt = pAd->WlanCounters.FailedCount.vv.LowPart -
7134 pAd->Mlme.PrevWlanCounters.FailedCount.vv.LowPart;
7135 - TxRetryCnt = pAd->WlanCounters.RetryCount.vv.LowPart -
7136 + TxRetryCnt = pAd->WlanCounters.RetryCount.vv.LowPart -
7137 pAd->Mlme.PrevWlanCounters.RetryCount.vv.LowPart;
7138 - TxOkCnt = pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart -
7139 + TxOkCnt = pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart -
7140 pAd->Mlme.PrevWlanCounters.TransmittedFragmentCount.vv.LowPart;
7141 TxCnt = TxOkCnt + TxFailCnt;
7143 @@ -947,16 +925,16 @@
7144 pAd->WlanCounters.FCSErrorCount.vv.LowPart += ((Cnt0 & 0x0000ffff) >> 7);
7145 if (pAd->WlanCounters.FCSErrorCount.vv.LowPart < OldFcsCount)
7146 pAd->WlanCounters.FCSErrorCount.vv.HighPart++;
7149 // Add FCS error count to private counters
7150 OldFcsCount = pAd->RalinkCounters.RealFcsErrCount.vv.LowPart;
7151 pAd->RalinkCounters.RealFcsErrCount.vv.LowPart += Cnt0;
7152 if (pAd->RalinkCounters.RealFcsErrCount.vv.LowPart < OldFcsCount)
7153 pAd->RalinkCounters.RealFcsErrCount.vv.HighPart++;
7155 - RxOkCnt = pAd->WlanCounters.ReceivedFragmentCount.vv.LowPart -
7157 + RxOkCnt = pAd->WlanCounters.ReceivedFragmentCount.vv.LowPart -
7158 pAd->Mlme.PrevWlanCounters.ReceivedFragmentCount.vv.LowPart;
7159 - RxFailCnt = pAd->RalinkCounters.RealFcsErrCount.vv.LowPart -
7160 + RxFailCnt = pAd->RalinkCounters.RealFcsErrCount.vv.LowPart -
7161 pAd->Mlme.PrevWlanCounters.FCSErrorCount.vv.LowPart;
7162 RxCnt = RxOkCnt + RxFailCnt;
7166 // decide ChannelQuality based on: 1)last BEACON received time, 2)last RSSI, 3)TxPER, and 4)RxPER
7168 - // This value also decides when all roaming fails (or no roaming candidates at
7169 - // all), should this STA stay with original AP, or a LinkDown signal
7170 + // This value also decides when all roaming fails (or no roaming candidates at
7171 + // all), should this STA stay with original AP, or a LinkDown signal
7172 // is indicated to NDIS
7174 if (INFRA_ON(pAd) &&
7176 // Ignore lost beacon if traffic still goes well
7177 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) && (TxOkCnt < 2))
7179 - DBGPRINT(RT_DEBUG_TRACE, "BEACON lost for more than %d sec with TxOkCnt=%d, let CQI = 0\n", BEACON_LOST_TIME/HZ, TxOkCnt);
7180 + DBGPRINT(RT_DEBUG_TRACE, "BEACON lost for more than %d sec with TxOkCnt=%d, let CQI = 0\n", BEACON_LOST_TIME/HZ, TxOkCnt);
7181 pAd->Mlme.ChannelQuality = 0;
7182 // Lost AP, send disconnect & link down event
7184 @@ -986,19 +964,19 @@
7187 // ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER (RSSI 0..100), (TxPER 100..0), (RxPER 100..0)
7188 - pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * pAd->PortCfg.LastRssi +
7189 - TX_WEIGHTING * (100 - TxPRR) +
7190 + pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * pAd->PortCfg.LastRssi +
7191 + TX_WEIGHTING * (100 - TxPRR) +
7192 RX_WEIGHTING* (100 - RxPER)) / 100;
7193 if (pAd->Mlme.ChannelQuality >= 100)
7194 pAd->Mlme.ChannelQuality = 100;
7198 // latch current WLAN counters for next check-for-roaming usage
7199 memcpy(&pAd->Mlme.PrevWlanCounters, &pAd->WlanCounters, sizeof(COUNTER_802_11));
7200 // make sure copy the real FCS counts into previous mlme counter structure.
7201 pAd->Mlme.PrevWlanCounters.FCSErrorCount = pAd->RalinkCounters.RealFcsErrCount;
7203 - DBGPRINT(RT_DEBUG_INFO, "MMCHK - CQI= %d, (Tx Fail=%d/Retry=%d/Total=%d, Rx Fail=%d/Total=%d, RSSI=%d dbm)\n",
7205 + DBGPRINT(RT_DEBUG_INFO, "MMCHK - CQI= %d, (Tx Fail=%d/Retry=%d/Total=%d, Rx Fail=%d/Total=%d, RSSI=%d dbm)\n",
7206 pAd->Mlme.ChannelQuality, TxFailCnt, TxRetryCnt, TxCnt, RxFailCnt, RxCnt, pAd->PortCfg.LastRssi - pAd->PortCfg.RssiToDbm);
7209 @@ -1006,13 +984,13 @@
7211 ==========================================================================
7213 - This routine calculates the acumulated TxPER of eaxh TxRate. And
7214 - according to the calculation result, change PortCfg.TxRate which
7215 - is the stable TX Rate we expect the Radio situation could sustained.
7216 + This routine calculates the acumulated TxPER of eaxh TxRate. And
7217 + according to the calculation result, change PortCfg.TxRate which
7218 + is the stable TX Rate we expect the Radio situation could sustained.
7220 - PortCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate}
7221 + PortCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate}
7226 call this routine every second
7227 ==========================================================================
7228 @@ -1032,9 +1010,9 @@
7230 if (pAd->PortCfg.EnableAutoRateSwitching == FALSE)
7234 // if no traffic in the past 1-sec period, don't change TX rate,
7235 - // but clear all bad history. because the bad history may affect the next
7236 + // but clear all bad history. because the bad history may affect the next
7237 // Chariot throughput test
7238 if (TxTotalCnt == 0)
7240 @@ -1043,7 +1021,7 @@
7241 memset(pAd->DrsCounters.PER, 0, MAX_LEN_OF_SUPPORTED_RATES);
7246 // decide the next upgrade rate and downgrade rate, if any
7247 if (pAd->PortCfg.PhyMode == PHY_11BG_MIXED)
7249 @@ -1062,7 +1040,7 @@
7251 else // PHY_11ABG_MIXED
7253 - if (pAd->PortCfg.Channel > 14)
7254 + if (pAd->PortCfg.Channel > 14)
7256 UpRate = Phy11ANextRateUpward[CurrRate];
7257 DownRate = Phy11ANextRateDownward[CurrRate];
7258 @@ -1081,7 +1059,7 @@
7259 if (TxTotalCnt > 15)
7261 TxErrorRatio = ((pAd->DrsCounters.OneSecTxRetryOkCount + pAd->DrsCounters.OneSecTxFailCount) *100) / TxTotalCnt;
7264 // 2560D and after has implemented ASIC-based OFDM rate switching,
7265 // but not 2560C & before. thus software use different PER for rate switching
7266 if (pAd->PortCfg.Rt2560Version >= RT2560_VER_D)
7267 @@ -1106,20 +1084,20 @@
7268 fUpgradeQuality = TRUE;
7269 if (pAd->DrsCounters.TxQuality[CurrRate])
7270 pAd->DrsCounters.TxQuality[CurrRate] --; // quality very good in CurrRate
7273 if (pAd->DrsCounters.TxRateUpPenalty)
7274 pAd->DrsCounters.TxRateUpPenalty --;
7275 else if (pAd->DrsCounters.TxQuality[UpRate])
7276 pAd->DrsCounters.TxQuality[UpRate] --; // may improve next UP rate's quality
7283 // if not enough TX samples, decide by heuristic rules
7289 // Downgrade TX quality upon any TX failure in the past second
7290 if (pAd->DrsCounters.OneSecTxFailCount)
7292 @@ -1155,22 +1133,22 @@
7294 if (pAd->DrsCounters.fNoisyEnvironment)
7296 - DBGPRINT(RT_DEBUG_TRACE,"DRS(noisy):");
7297 + DBGPRINT(RT_DEBUG_TRACE,"DRS(noisy):");
7301 - DBGPRINT(RT_DEBUG_TRACE,"DRS:");
7302 + DBGPRINT(RT_DEBUG_TRACE,"DRS:");
7304 - DBGPRINT(RT_DEBUG_TRACE, "Qty[%d]=%d PER=%d%% %d-sec, Qty[%d]=%d, Pty=%d\n",
7305 + DBGPRINT(RT_DEBUG_TRACE, "Qty[%d]=%d PER=%d%% %d-sec, Qty[%d]=%d, Pty=%d\n",
7306 RateIdToMbps[CurrRate], pAd->DrsCounters.TxQuality[CurrRate],
7308 pAd->DrsCounters.CurrTxRateStableTime,
7309 RateIdToMbps[UpRate], pAd->DrsCounters.TxQuality[UpRate],
7310 pAd->DrsCounters.TxRateUpPenalty);
7313 // 2004-3-13 special case: Claim noisy environment
7314 - // decide if there was a false "rate down" in the past 2 sec due to noisy
7315 - // environment. if so, we would rather switch back to the higher TX rate.
7316 + // decide if there was a false "rate down" in the past 2 sec due to noisy
7317 + // environment. if so, we would rather switch back to the higher TX rate.
7319 // 1. there's a higher rate available, AND
7320 // 2. there was a rate-down happened, AND
7321 @@ -1179,8 +1157,8 @@
7322 if ((UpRate != CurrRate) &&
7323 (pAd->DrsCounters.LastSecTxRateChangeAction == 2) &&
7324 (TxTotalCnt > 15) && // this line is to prevent the case that not enough TX sample causing PER=0%
7325 - (pAd->DrsCounters.PER[CurrRate] < 75) &&
7326 - ((pAd->DrsCounters.PER[CurrRate] > 20) || (pAd->DrsCounters.fNoisyEnvironment)) &&
7327 + (pAd->DrsCounters.PER[CurrRate] < 75) &&
7328 + ((pAd->DrsCounters.PER[CurrRate] > 20) || (pAd->DrsCounters.fNoisyEnvironment)) &&
7329 ((pAd->DrsCounters.PER[CurrRate]+5) > pAd->DrsCounters.PER[UpRate]))
7331 // we believe this is a noisy environment. better stay at UpRate
7332 @@ -1218,12 +1196,12 @@
7334 if (JumpUpRate > pAd->PortCfg.MaxTxRate)
7335 JumpUpRate = pAd->PortCfg.MaxTxRate;
7338 DBGPRINT(RT_DEBUG_TRACE,"DRS: #### leave Noisy environment ####, RSSI=%d, JumpUpRate=%d\n",
7340 pAd->PortCfg.AvgRssi - RSSI_TO_DBM_OFFSET, RateIdToMbps[JumpUpRate]);
7344 if (JumpUpRate > CurrRate)
7346 pAd->PortCfg.TxRate = JumpUpRate;
7347 @@ -1231,15 +1209,15 @@
7351 - // we're going to upgrade CurrRate to UpRate at next few seconds,
7352 - // but before that, we'd better try a NULL frame @ UpRate and
7353 + // we're going to upgrade CurrRate to UpRate at next few seconds,
7354 + // but before that, we'd better try a NULL frame @ UpRate and
7355 // see if UpRate is stable or not. If this NULL frame fails, it will
7356 // downgrade TxQuality[CurrRate], so that STA won't switch to
7357 // to UpRate in the next second
7358 // 2004-04-07 requested by David Tung - sent test frames only in OFDM rates
7359 - if (fUpgradeQuality &&
7361 - (UpRate != CurrRate) &&
7362 + if (fUpgradeQuality &&
7364 + (UpRate != CurrRate) &&
7365 (UpRate > RATE_11) &&
7366 (pAd->DrsCounters.TxQuality[CurrRate] <= 1) &&
7367 (pAd->DrsCounters.TxQuality[UpRate] <= 1))
7368 @@ -1260,16 +1238,16 @@
7370 pAd->PortCfg.TxRate = DownRate;
7372 - else if ((pAd->DrsCounters.TxQuality[CurrRate] <= 0) &&
7373 + else if ((pAd->DrsCounters.TxQuality[CurrRate] <= 0) &&
7374 (pAd->DrsCounters.TxQuality[UpRate] <=0) &&
7375 (CurrRate != UpRate))
7377 pAd->PortCfg.TxRate = UpRate;
7385 // if rate-up happen, clear all bad history of all TX rates
7386 if (pAd->PortCfg.TxRate > CurrRate)
7388 @@ -1291,7 +1269,7 @@
7389 pAd->DrsCounters.TxRateUpPenalty = 2; // add 2 sec penalty
7391 pAd->DrsCounters.TxRateUpPenalty = 0; // no penalty
7394 pAd->DrsCounters.CurrTxRateStableTime = 0;
7395 pAd->DrsCounters.LastSecTxRateChangeAction = 2; // rate DOWN
7396 pAd->DrsCounters.TxQuality[pAd->PortCfg.TxRate] = 0;
7397 @@ -1299,7 +1277,7 @@
7400 pAd->DrsCounters.LastSecTxRateChangeAction = 0; // rate no change
7403 // reset all OneSecxxx counters
7404 pAd->DrsCounters.OneSecTxFailCount = 0;
7405 pAd->DrsCounters.OneSecTxOkCount = 0;
7406 @@ -1309,10 +1287,10 @@
7408 ==========================================================================
7410 - This routine is executed periodically inside MlmePeriodicExec() after
7411 + This routine is executed periodically inside MlmePeriodicExec() after
7412 association with an AP.
7413 It checks if PortCfg.Psm is consistent with user policy (recorded in
7414 - PortCfg.WindowsPowerMode). If not, enforce user policy. However,
7415 + PortCfg.WindowsPowerMode). If not, enforce user policy. However,
7416 there're some conditions to consider:
7417 1. we don't support power-saving in ADHOC mode, so Psm=PWR_ACTIVE all
7418 the time when Mibss==TRUE
7419 @@ -1334,7 +1312,7 @@
7420 // 4. CNTL state machine is not doing SCANning
7421 // 5. no TX SUCCESS event for the past period
7422 PowerMode = pAd->PortCfg.WindowsPowerMode;
7425 if (INFRA_ON(pAd) &&
7426 (PowerMode != Ndis802_11PowerModeCAM) &&
7427 (pAd->PortCfg.Psm == PWR_ACTIVE) &&
7428 @@ -1344,21 +1322,21 @@
7429 MlmeSetPsmBit(pAd, PWR_SAVE);
7430 EnqueueNullFrame(pAd, pAd->PortCfg.TxRate);
7434 // latch current count for next-time comparison
7435 pAd->Mlme.PrevTxCnt = pAd->WlanCounters.TransmittedFragmentCount.vv.LowPart;
7440 - IN PRTMP_ADAPTER pAd,
7441 + IN PRTMP_ADAPTER pAd,
7444 TXCSR7_STRUC txcsr7;
7448 - pAd->PortCfg.Psm = psm;
7450 + pAd->PortCfg.Psm = psm;
7452 DBGPRINT(RT_DEBUG_TRACE, "MMCHK - change PSM bit to %d <<<\n", psm);
7453 if (psm == PWR_SAVE)
7455 @@ -1373,14 +1351,14 @@
7458 VOID MlmeSetTxPreamble(
7459 - IN PRTMP_ADAPTER pAd,
7460 + IN PRTMP_ADAPTER pAd,
7461 IN USHORT TxPreamble)
7463 ULONG Plcp1MCsr = 0x00700400; // 0x13c, ACK/CTS PLCP at 1 Mbps
7464 ULONG Plcp2MCsr = 0x00380401; // 0x140, ACK/CTS PLCP at 2 Mbps
7465 ULONG Plcp5MCsr = 0x00150402; // 0x144, ACK/CTS PLCP at 5.5 Mbps
7466 ULONG Plcp11MCsr = 0x000b8403; // 0x148, ACK/CTS PLCP at 11 Mbps
7469 if (TxPreamble == Rt802_11PreambleShort)
7471 DBGPRINT(RT_DEBUG_TRACE, "MlmeSetTxPreamble (= SHORT PREAMBLE)\n");
7472 @@ -1401,7 +1379,7 @@
7473 RTMP_IO_WRITE32(pAd, PLCP5MCSR, Plcp5MCsr);
7474 RTMP_IO_WRITE32(pAd, PLCP11MCSR, Plcp11MCsr);
7478 VOID MlmeUpdateTxRates(
7479 IN PRTMP_ADAPTER pAd,
7481 @@ -1436,14 +1414,14 @@
7483 // 2003-12-10 802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode
7484 if ((pAd->PortCfg.BssType == BSS_INDEP) &&
7485 - (pAd->PortCfg.PhyMode == PHY_11BG_MIXED) &&
7486 + (pAd->PortCfg.PhyMode == PHY_11BG_MIXED) &&
7487 (pAd->PortCfg.AdhocMode == 0) &&
7488 (MaxDesire > RATE_11))
7489 MaxDesire = RATE_11;
7492 pAd->PortCfg.MaxDesiredRate = MaxDesire;
7494 - // Auto rate switching is enabled only if more than one DESIRED RATES are
7496 + // Auto rate switching is enabled only if more than one DESIRED RATES are
7497 // specified; otherwise disabled
7499 pAd->PortCfg.EnableAutoRateSwitching = FALSE;
7500 @@ -1455,66 +1433,66 @@
7502 switch (pAd->PortCfg.SupportedRates[i] & 0x7f)
7504 - case 2: Rate = RATE_1;
7505 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7506 - BasicRateBitmap |= 0x0001;
7507 + case 2: Rate = RATE_1;
7508 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7509 + BasicRateBitmap |= 0x0001;
7511 - case 4: Rate = RATE_2;
7512 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7513 - BasicRateBitmap |= 0x0002;
7514 + case 4: Rate = RATE_2;
7515 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7516 + BasicRateBitmap |= 0x0002;
7520 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7521 - BasicRateBitmap |= 0x0004;
7524 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7525 + BasicRateBitmap |= 0x0004;
7529 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7530 - BasicRateBitmap |= 0x0008;
7533 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7534 + BasicRateBitmap |= 0x0008;
7538 -// if (pAd->PortCfg.SupportedRates[i] & 0x80)
7539 - BasicRateBitmap |= 0x0010;
7542 +// if (pAd->PortCfg.SupportedRates[i] & 0x80)
7543 + BasicRateBitmap |= 0x0010;
7547 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7548 - BasicRateBitmap |= 0x0020;
7551 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7552 + BasicRateBitmap |= 0x0020;
7556 -// if (pAd->PortCfg.SupportedRates[i] & 0x80)
7557 - BasicRateBitmap |= 0x0040;
7560 +// if (pAd->PortCfg.SupportedRates[i] & 0x80)
7561 + BasicRateBitmap |= 0x0040;
7565 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7566 - BasicRateBitmap |= 0x0080;
7569 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7570 + BasicRateBitmap |= 0x0080;
7574 -// if (pAd->PortCfg.SupportedRates[i] & 0x80)
7575 - BasicRateBitmap |= 0x0100;
7578 +// if (pAd->PortCfg.SupportedRates[i] & 0x80)
7579 + BasicRateBitmap |= 0x0100;
7583 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7584 - BasicRateBitmap |= 0x0200;
7587 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7588 + BasicRateBitmap |= 0x0200;
7592 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7593 - BasicRateBitmap |= 0x0400;
7596 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7597 + BasicRateBitmap |= 0x0400;
7601 - if (pAd->PortCfg.SupportedRates[i] & 0x80)
7602 - BasicRateBitmap |= 0x0800;
7605 + if (pAd->PortCfg.SupportedRates[i] & 0x80)
7606 + BasicRateBitmap |= 0x0800;
7614 if (MaxSupport < Rate) MaxSupport = Rate;
7615 @@ -1530,7 +1508,7 @@
7616 pAd->PortCfg.ExpectedACKRate[i] = CurrBasicRate;
7617 DBGPRINT(RT_DEBUG_INFO,"Expected ACK rate[%d] = %d Mbps\n", RateIdToMbps[i], RateIdToMbps[CurrBasicRate]);
7621 // max tx rate = min {max desire rate, max supported rate}
7622 if (MaxSupport < MaxDesire)
7623 pAd->PortCfg.MaxTxRate = MaxSupport;
7624 @@ -1547,13 +1525,13 @@
7626 if (pAd->PortCfg.Channel > 14)
7627 pAd->PortCfg.TxRate = RATE_6; // 802.11a
7631 short dbm = pAd->PortCfg.AvgRssi - pAd->PortCfg.RssiToDbm;
7632 if (bLinkUp == TRUE && pAd->PortCfg.MaxTxRate >= RATE_24)
7633 pAd->PortCfg.TxRate = RATE_24;
7635 - pAd->PortCfg.TxRate = pAd->PortCfg.MaxTxRate;
7636 + pAd->PortCfg.TxRate = pAd->PortCfg.MaxTxRate;
7638 pAd->PortCfg.TxRate = RATE_11;
7639 else if ((dbm < -70) && (pAd->PortCfg.TxRate > RATE_24))
7640 @@ -1568,7 +1546,7 @@
7641 case PHY_11BG_MIXED:
7643 pAd->PortCfg.MlmeRate = RATE_2;
7646 pAd->PortCfg.RtsRate = RATE_11;
7648 pAd->PortCfg.RtsRate = RATE_2;
7649 @@ -1595,10 +1573,10 @@
7650 pAd->PortCfg.RtsRate = RATE_2;
7654 - DBGPRINT(RT_DEBUG_TRACE, " MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, Rate Switching =%d)\n",
7656 + DBGPRINT(RT_DEBUG_TRACE, " MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, Rate Switching =%d)\n",
7657 RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport], RateIdToMbps[pAd->PortCfg.MaxTxRate], pAd->PortCfg.EnableAutoRateSwitching);
7658 - DBGPRINT(RT_DEBUG_TRACE, " MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04x)\n",
7659 + DBGPRINT(RT_DEBUG_TRACE, " MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04x)\n",
7660 RateIdToMbps[pAd->PortCfg.TxRate], RateIdToMbps[pAd->PortCfg.RtsRate], BasicRateBitmap);
7663 @@ -1623,14 +1601,14 @@
7665 ASIC_LED_ACT_OFF(pAd);
7669 // Clean up old bss table
7670 BssTableInit(&pAd->PortCfg.BssTab);
7674 IN PRTMP_ADAPTER pAd)
7678 RTMP_IO_WRITE32(pAd, PWRCSR0, 0x3f3b3100);
7680 @@ -1665,12 +1643,12 @@
7684 - IN BSS_TABLE *Tab)
7685 + IN BSS_TABLE *Tab)
7690 - for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++)
7691 + for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++)
7693 memset(&Tab->BssEntry[i], 0, sizeof(BSS_ENTRY));
7695 @@ -1678,23 +1656,23 @@
7697 /*! \brief search the BSS table by SSID
7698 * \param p_tab pointer to the bss table
7699 - * \param ssid SSID string
7700 + * \param ssid SSID string
7701 * \return index of the table, BSS_NOT_FOUND if not in the table
7704 * \note search by sequential search
7706 ULONG BssTableSearch(
7707 - IN BSS_TABLE *Tab,
7708 - IN PMACADDR Bssid)
7709 + IN BSS_TABLE *Tab,
7710 + IN PMACADDR Bssid)
7714 - for (i = 0; i < Tab->BssNr; i++)
7716 + for (i = 0; i < Tab->BssNr; i++)
7718 //printf("comparing %s and %s\n", p_tab->bss[i].ssid, ssid);
7719 - if (MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid))
7721 + if (MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid))
7726 @@ -1702,15 +1680,15 @@
7729 VOID BssTableDeleteEntry(
7730 - IN OUT BSS_TABLE *Tab,
7731 - IN PMACADDR Bssid)
7732 + IN OUT BSS_TABLE *Tab,
7733 + IN PMACADDR Bssid)
7737 - for (i = 0; i < Tab->BssNr; i++)
7739 + for (i = 0; i < Tab->BssNr; i++)
7741 //printf("comparing %s and %s\n", p_tab->bss[i].ssid, ssid);
7742 - if (MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid))
7743 + if (MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid))
7745 for (j = i; j < Tab->BssNr - 1; j++)
7747 @@ -1724,36 +1702,63 @@
7749 UCHAR ZeroSsid[32] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
7750 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
7752 +static NDIS_802_11_WEP_STATUS setWepStatus(
7753 + IN USHORT mask, // Peer cipher capability set
7754 + IN NDIS_802_11_WEP_STATUS WepStatus) // local cipher selection
7756 + static const unsigned char transtoieee[] = {
7757 + CIPHER_TYPE_WEP104,0,0,0,CIPHER_TYPE_TKIP,0,CIPHER_TYPE_CCMP,0
7759 + static const unsigned char transtondis[] = {
7760 + Ndis802_11EncryptionDisabled, Ndis802_11WEPEnabled,
7761 + Ndis802_11Encryption2Enabled, Ndis802_11WEPKeyAbsent,
7762 + Ndis802_11Encryption3Enabled, Ndis802_11WEPEnabled
7764 + NDIS_802_11_WEP_STATUS wepstatus = Ndis802_11WEPDisabled;
7765 + USHORT suite = transtoieee[WepStatus];
7767 + DBGPRINT(RT_DEBUG_TRACE, " - (%s) mask 0x%04x wepstatus %d ieee %d\n",
7768 + __FUNCTION__, mask, WepStatus, suite);
7770 + if (suite && (mask & 0x01 << suite)) {
7771 + wepstatus = transtondis[suite];
7775 +} /* End setWepStatus () */
7785 - IN PRTMP_ADAPTER pAd,
7786 - OUT BSS_ENTRY *pBss,
7787 - IN MACADDR *pBssid,
7791 - IN USHORT BeaconPeriod,
7792 + IN PRTMP_ADAPTER pAd,
7793 + OUT BSS_ENTRY *pBss,
7794 + IN MACADDR *pBssid,
7798 + IN USHORT BeaconPeriod,
7800 - IN CF_PARM *pCfParm,
7801 - IN USHORT AtimWin,
7802 - IN USHORT CapabilityInfo,
7804 + IN CF_PARM *pCfParm,
7805 + IN USHORT AtimWin,
7806 + IN USHORT CapabilityInfo,
7809 IN BOOLEAN ExtendedRateIeExist,
7813 IN LARGE_INTEGER TimeStamp,
7814 - IN PNDIS_802_11_VARIABLE_IEs pVIE)
7815 + IN USHORT VarIELen, // Length of all saved IEs.
7816 + IN PNDIS_802_11_VARIABLE_IEs pVIE)
7818 COPY_MAC_ADDR(&pBss->Bssid, pBssid);
7819 // Default Hidden SSID to be TRUE, it will be turned to FALSE after coping SSID
7824 // For hidden SSID AP, it might send beacon with SSID len equal to 0
7825 @@ -1769,17 +1774,17 @@
7827 pBss->BssType = BssType;
7828 pBss->BeaconPeriod = BeaconPeriod;
7829 - if (BssType == BSS_INFRA)
7830 + if (BssType == BSS_INFRA)
7835 pBss->CfpCount = pCfParm->CfpCount;
7836 pBss->CfpPeriod = pCfParm->CfpPeriod;
7837 pBss->CfpMaxDuration = pCfParm->CfpMaxDuration;
7838 pBss->CfpDurRemaining = pCfParm->CfpDurRemaining;
7845 pBss->AtimWin = AtimWin;
7847 @@ -1801,15 +1806,23 @@
7848 pBss->FixIEs.Capabilities = CapabilityInfo;
7850 // New for microsoft Variable IEs
7851 - if (pVIE->Length != 0)
7852 + pBss->VarIELen = VarIELen;
7853 + if (VarIELen != 0)
7855 - pBss->VarIELen = pVIE->Length + 2;
7856 - memcpy(pBss->VarIEs, pVIE, pBss->VarIELen);
7857 - pBss->WepStatus = BssCipherParse(pBss->VarIEs);
7858 + memcpy(pBss->VarIEs, pVIE, VarIELen);
7859 + pBss->CipherCap = BssCipherParse((PBEACON_EID_STRUCT)pBss->VarIEs,
7861 + if (pBss->CipherCap & (0x01 << CIPHER_TYPE_GRP)) {
7862 + pBss->WepStatus = setWepStatus(pBss->CipherCap >> 8,
7863 + pAd->PortCfg.WepStatus);
7866 + pBss->WepStatus = setWepStatus(pBss->CipherCap,
7867 + pAd->PortCfg.WepStatus);
7872 - pBss->VarIELen = 0;
7873 // No SSN ID, if security is on, this is WEP algorithm
7875 pBss->WepStatus = Ndis802_11WEPEnabled;
7876 @@ -1817,9 +1830,11 @@
7878 pBss->WepStatus = Ndis802_11WEPDisabled;
7880 + DBGPRINT(RT_DEBUG_TRACE, "%s: Ndis WepStatus (Local=%d, Remote=%d)\n",
7881 + __FUNCTION__, pAd->PortCfg.WepStatus, pBss->WepStatus);
7886 * \brief insert an entry into the bss table
7887 * \param p_tab The BSS table
7888 * \param Bssid BSSID
7889 @@ -1840,17 +1855,17 @@
7890 * \note If SSID is identical, the old entry will be replaced by the new one
7892 ULONG BssTableSetEntry(
7893 - IN PRTMP_ADAPTER pAd,
7894 - OUT BSS_TABLE *Tab,
7895 - IN MACADDR *Bssid,
7899 - IN USHORT BeaconPeriod,
7900 - IN BOOLEAN CfExist,
7901 - IN CF_PARM *CfParm,
7902 - IN USHORT AtimWin,
7903 - IN USHORT CapabilityInfo,
7904 + IN PRTMP_ADAPTER pAd,
7905 + OUT BSS_TABLE *Tab,
7906 + IN MACADDR *Bssid,
7910 + IN USHORT BeaconPeriod,
7911 + IN BOOLEAN CfExist,
7912 + IN CF_PARM *CfParm,
7913 + IN USHORT AtimWin,
7914 + IN USHORT CapabilityInfo,
7917 IN BOOLEAN ExtendedRateIeExist,
7918 @@ -1858,50 +1873,52 @@
7921 IN LARGE_INTEGER TimeStamp,
7922 + IN USHORT VarIELen, // Length of all saved IEs.
7923 IN PNDIS_802_11_VARIABLE_IEs pVIE)
7927 Idx = BssTableSearch(Tab, Bssid);
7928 - if (Idx == BSS_NOT_FOUND)
7929 + if (Idx == BSS_NOT_FOUND)
7931 if (Tab->BssNr >= MAX_LEN_OF_BSS_TABLE)
7932 return BSS_NOT_FOUND;
7936 BssEntrySet(pAd, &Tab->BssEntry[Idx], Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
7937 CfExist, CfParm, AtimWin, CapabilityInfo, Rates, RatesLen, ExtendedRateIeExist,
7938 - ChannelNo, Rssi, Noise, TimeStamp, pVIE);
7939 + ChannelNo, Rssi, Noise, TimeStamp, VarIELen, pVIE);
7945 BssEntrySet(pAd, &Tab->BssEntry[Idx], Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
7946 CfExist, CfParm, AtimWin, CapabilityInfo, Rates, RatesLen, ExtendedRateIeExist,
7947 - ChannelNo, Rssi, Noise, TimeStamp, pVIE);
7948 + ChannelNo, Rssi, Noise, TimeStamp, VarIELen, pVIE);
7955 VOID BssTableSsidSort(
7956 - IN PRTMP_ADAPTER pAd,
7957 - OUT BSS_TABLE *OutTab,
7960 + IN PRTMP_ADAPTER pAd,
7961 + OUT BSS_TABLE *OutTab,
7966 BssTableInit(OutTab);
7968 - for (i = 0; i < pAd->PortCfg.BssTab.BssNr; i++)
7969 + for (i = 0; i < pAd->PortCfg.BssTab.BssNr; i++)
7971 BSS_ENTRY *pInBss = &pAd->PortCfg.BssTab.BssEntry[i];
7973 - if ((pInBss->BssType == pAd->PortCfg.BssType) &&
7975 + if ((pInBss->BssType == pAd->PortCfg.BssType) &&
7976 ((pInBss->SsidLen==SsidLen) && RTMPEqualMemory(pInBss->Ssid, Ssid, (ULONG) SsidLen)))
7978 BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
7980 - // Bss Type matched, SSID matched.
7981 + // Bss Type matched, SSID matched.
7982 // We will check wepstatus for qualification Bss
7983 if (pAd->PortCfg.WepStatus != pInBss->WepStatus)
7985 @@ -1911,24 +1928,24 @@
7986 // CCX also require not even try to connect it!!
7991 // copy matching BSS from InTab to OutTab
7992 memcpy(pOutBss, pInBss, sizeof(BSS_ENTRY));
7997 else if ((pInBss->BssType == pAd->PortCfg.BssType) && (SsidLen == 0))
7999 BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
8001 - // Bss Type matched, SSID matched.
8002 + // Bss Type matched, SSID matched.
8003 // We will check wepstatus for qualification Bss
8004 if (pAd->PortCfg.WepStatus != pInBss->WepStatus)
8008 // copy matching BSS from InTab to OutTab
8009 memcpy(pOutBss, pInBss, sizeof(BSS_ENTRY));
8015 @@ -1937,36 +1954,36 @@
8016 // Add for hidden SSID. But we have to verify the security suite too.
8017 BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
8019 - // Bss Type matched, SSID matched.
8020 + // Bss Type matched, SSID matched.
8021 // We will check wepstatus for qualification Bss
8022 if (pAd->PortCfg.WepStatus != pInBss->WepStatus)
8026 // copy matching BSS from InTab to OutTab
8027 memcpy(pOutBss, pInBss, sizeof(BSS_ENTRY));
8035 if (OutTab->BssNr >= MAX_LEN_OF_BSS_TABLE)
8042 BssTableSortByRssi(OutTab);
8045 VOID BssTableSortByRssi(
8046 - IN OUT BSS_TABLE *OutTab)
8047 + IN OUT BSS_TABLE *OutTab)
8052 - for (i = 0; i < OutTab->BssNr - 1; i++)
8053 + for (i = 0; i < OutTab->BssNr - 1; i++)
8055 - for (j = i+1; j < OutTab->BssNr; j++)
8056 + for (j = i+1; j < OutTab->BssNr; j++)
8058 - if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi)
8059 + if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi)
8061 memcpy(&TmpBss, &OutTab->BssEntry[j], sizeof(BSS_ENTRY));
8062 memcpy(&OutTab->BssEntry[j], &OutTab->BssEntry[i], sizeof(BSS_ENTRY));
8063 @@ -1976,34 +1993,178 @@
8067 -NDIS_802_11_WEP_STATUS BssCipherParse(
8068 - IN PUCHAR pCipher)
8070 + * ============================================================================
8072 + * Scan cipher suite list and return cipher capability set.
8073 + * ============================================================================
8075 +static USHORT scan_csl(
8076 + IN suite_list_t *psl,
8077 + IN USHORT curtype)
8079 - PBEACON_EID_STRUCT pEid;
8081 + USHORT ciphertype = curtype; // Cipher "capability set"
8084 + DBGPRINT(RT_DEBUG_TRACE, " - scan %d pair cipher(s)\n", psl->count);
8086 + for (i = 0, j = psl->count; i < j; i++) {
8088 - pEid = (PBEACON_EID_STRUCT) pCipher;
8089 + if (psl->suite[i].type < NUM_CIPHER_TYPES) {
8090 + ciphertype |= 0x01 << psl->suite[i].type;
8093 + DBGPRINT(RT_DEBUG_ERROR, " - invalid pair cipher type %d\n",
8094 + psl->suite[i].type);
8096 + DBGPRINT(RT_DEBUG_TRACE, " - (pair) CipherType now=0x%04x\n",
8099 + return ciphertype;
8101 - // Double check sanity information, although it should be done at peer beacon sanity check already.
8102 - if (pEid->Eid != IE_WPA)
8103 - return (Ndis802_11WEPDisabled);
8105 - // Double check Var IE length, it must be no less than 0x16
8106 - if (pEid->Len < 0x16)
8107 - return (Ndis802_11WEPDisabled);
8109 - // Skip OUI, version, and multicast suite
8110 - // This part should be improved in the future when AP supported multiple cipher suite.
8111 - // For now, it's OK since almost all APs have fixed cipher suite supported.
8112 - pTmp = (PUCHAR) pEid->Octet;
8115 - if (*pTmp == 4) // AES
8116 - return (Ndis802_11Encryption3Enabled);
8117 - else if (*pTmp == 2) // TKIP
8118 - return (Ndis802_11Encryption2Enabled);
8119 +} /* End scan_csl () */
8121 +USHORT BssCipherParse(
8122 + IN PBEACON_EID_STRUCT pEid,
8123 + IN USHORT VarIELen) // Length of all saved IEs.
8125 + USHORT ciphertype = 0;
8126 + PBEACON_EID_STRUCT ptEid;
8129 + DBGPRINT(RT_DEBUG_TRACE, "%s: using VarIELen=%d\n", __FUNCTION__, VarIELen);
8131 + // Handle the stinerman problem (a too-short WPA IE followed by
8132 + // a long-enough WPA IE from an AP), the onishin/dacull problem
8133 + // (a RSN - WPA2 - IE followed by a WPA1 IE from an AP), and the
8134 + // holtzmichel problem (a WPA1 IE followed by a WPA2 IE). We end
8135 + // up using the *last* one we find. This may (or may not) really
8136 + // be the thing to do. - bb
8137 + for (ptEid = pEid, len = 0; len < VarIELen;
8138 + len += ptEid->Len + 2,
8139 + ptEid = (PBEACON_EID_STRUCT)((UCHAR *)pEid + len)) {
8141 + DBGPRINT(RT_DEBUG_TRACE, " - examining IE=%d, Len=%d\n",
8142 + ptEid->Eid, ptEid->Len);
8144 + switch (ptEid->Eid) {
8146 + DBGPRINT(RT_DEBUG_ERROR, " - Not a WPA/WPA2 IE=%d, Len=%d\n",
8147 + ptEid->Eid, ptEid->Len);
8151 + #define p ((PRSN_EID_STRUCT)ptEid)
8153 + // Double check Var IE length, it must be no less than 0x16
8154 + // Silently ignore if not
8155 + if (ptEid->Len < 0x16) {
8156 + DBGPRINT(RT_DEBUG_ERROR, " - Len %d too short\n",
8160 + // Skip OUI, version, and multicast suite
8161 + // This part should be improved in the future when AP
8162 + // supported multiple cipher suite. For now, it's OK since
8163 + // almost all APs have fixed cipher suite supported.
8164 + // (The future is now - bb)
8165 + if (p->Multicast[3] < NUM_CIPHER_TYPES) {
8166 + ciphertype |= 0x100 << p->Multicast[3];
8169 + DBGPRINT(RT_DEBUG_ERROR,
8170 + " - IE_WPA invalid group cipher %d\n",
8173 + DBGPRINT(RT_DEBUG_TRACE, " - WPA CipherType now=0x%04x\n",
8176 - return (Ndis802_11WEPDisabled);
8177 + if (p->Length >= sizeof(RSN_EID_STRUCT) -
8178 + offsetof(RSN_EID_STRUCT, Oui)) {
8179 + suite_list_p psl = (suite_list_p)((UCHAR *)p +
8180 + offsetof(RSN_EID_STRUCT, Count));
8182 + if (psl->count * sizeof(suite_sel_t) +
8183 + offsetof(RSN_EID_STRUCT,Count) -
8184 + offsetof(RSN_EID_STRUCT,Oui) >
8186 + DBGPRINT(RT_DEBUG_ERROR,
8187 + " - malformed WPA pair cipher count "
8188 + "(needs %d bytes, %d bytes avail)\n",
8189 + psl->count*sizeof(suite_sel_t) +
8190 + offsetof(RSN_EID_STRUCT,Count) -
8191 + offsetof(RSN_EID_STRUCT,Oui),
8195 + ciphertype = scan_csl(psl, ciphertype);
8198 + ciphertype |= 0x01; // Indicate use group cipher
8203 + case IE_RSN: { // 802.11i pp. 27 - 32
8204 + #define p ((rsn_ie_p)ptEid)
8206 + if (p->length == sizeof(p->version)) {
8207 + ciphertype = 0x01 | 0x100 << CIPHER_TYPE_CCMP;
8210 + if (p->length >= sizeof(p->version) + sizeof(p->gcsuite)) {
8212 + // Right now, we use the group cipher suite since it
8213 + // appears (to me, at any rate) that that's what is
8214 + // being used from the WPA IE.
8215 + // (SWAG - cf. RSN_EID_STRUCT - is that WPA_IE is RSN_IE
8216 + // with 4 bytes in front of the version tag. So we
8217 + // use the group cipher suite ala case IE_WPA above.)
8218 + // cf. the Holtzmichel problem: Looks like the Sinus 154
8219 + // Basic 3 includes either 3 pairwise cipher suites, or
8220 + // 1 pairwise cipher suite, 1 AKM suite, and an RSN
8221 + // capabilities field, because the len is 20.
8222 + if (p->gcsuite.type < NUM_CIPHER_TYPES) {
8223 + ciphertype |= 0x100 << p->gcsuite.type;
8226 + DBGPRINT(RT_DEBUG_ERROR,
8227 + " - IE_RSN invalid group cipher %d\n",
8230 + DBGPRINT(RT_DEBUG_TRACE,
8231 + " - (grp) CipherType now=0x%04x\n", ciphertype);
8233 + if (p->length > sizeof(p->version) + sizeof(p->gcsuite)) {
8234 + suite_list_p psl = (suite_list_p)((UCHAR *)p +
8235 + offsetof(rsn_ie_t, version) +
8236 + sizeof(ie_version_t) + sizeof(suite_sel_t));
8238 + if (psl->count * sizeof(suite_sel_t) +
8239 + sizeof(ie_version_t) + sizeof(suite_sel_t) >
8241 + DBGPRINT(RT_DEBUG_ERROR,
8242 + " - malformed RSN pair cipher count "
8243 + "(needs %d bytes, %d bytes avail)\n",
8244 + psl->count*sizeof(suite_sel_t) +
8245 + sizeof(ie_version_t) + sizeof(suite_sel_t),
8249 + ciphertype = scan_csl(psl, ciphertype);
8252 + ciphertype |= 0x01; // Indicate use group cipher
8256 + } /* End case IE_RSN */
8257 + } /* End switch EID */
8258 + } /* End for () */
8260 + DBGPRINT(RT_DEBUG_TRACE, "%s: return CipherType=0x%04x\n",
8261 + __FUNCTION__, ciphertype);
8262 + return ciphertype;
8265 // ===========================================================================================
8266 @@ -2017,16 +2178,16 @@
8269 VOID MacAddrRandomBssid(
8270 - IN PRTMP_ADAPTER pAd,
8271 - OUT MACADDR *Addr)
8272 + IN PRTMP_ADAPTER pAd,
8273 + OUT MACADDR *Addr)
8277 - for (i = 0; i < ETH_ALEN; i++)
8278 + for (i = 0; i < ETH_ALEN; i++)
8280 Addr->Octet[i] = RandomByte(pAd);
8284 Addr->Octet[0] = (Addr->Octet[0] & 0xfe) | 0x02; // the first 2 bits must be 01xxxxxxxx
8287 @@ -2042,12 +2203,12 @@
8288 * \note this function initializes the following field
8290 VOID MgtMacHeaderInit(
8291 - IN PRTMP_ADAPTER pAd,
8292 - IN OUT PMACHDR Hdr,
8296 - IN PMACADDR Bssid)
8297 + IN PRTMP_ADAPTER pAd,
8298 + IN OUT PMACHDR Hdr,
8302 + IN PMACADDR Bssid)
8304 memset(Hdr, 0, sizeof(MACHDR));
8305 Hdr->Type = BTYPE_MGMT;
8306 @@ -2063,8 +2224,8 @@
8307 // ===========================================================================================
8309 /*!***************************************************************************
8310 - * This routine build an outgoing frame, and fill all information specified
8311 - * in argument list to the frame body. The actual frame size is the summation
8312 + * This routine build an outgoing frame, and fill all information specified
8313 + * in argument list to the frame body. The actual frame size is the summation
8316 * Buffer - pointer to a pre-allocated memory segment
8317 @@ -2073,12 +2234,12 @@
8318 * function will FAIL!!!
8320 * Size of the buffer
8323 * MakeOutgoingFrame(Buffer, output_length, 2, &fc, 2, &dur, 6, p_addr1, 6,p_addr2, END_OF_ARGS);
8324 ****************************************************************************/
8325 ULONG MakeOutgoingFrame(
8327 - OUT ULONG *FrameLen, ...)
8329 + OUT ULONG *FrameLen, ...)
8333 @@ -2088,10 +2249,10 @@
8334 // calculates the total length
8336 va_start(Args, FrameLen);
8340 leng = va_arg(Args, int);
8341 - if (leng == END_OF_ARGS)
8342 + if (leng == END_OF_ARGS)
8346 @@ -2117,7 +2278,7 @@
8347 * \note Because this is done only once (at the init stage), no need to be locked
8349 NDIS_STATUS MlmeQueueInit(
8350 - IN MLME_QUEUE *Queue)
8351 + IN MLME_QUEUE *Queue)
8355 @@ -2127,7 +2288,7 @@
8359 - for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++)
8360 + for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++)
8362 Queue->Entry[i].Occupied = FALSE;
8363 Queue->Entry[i].MsgLen = 0;
8364 @@ -2150,11 +2311,11 @@
8365 * \note The message has to be initialized
8367 BOOLEAN MlmeEnqueue(
8368 - OUT MLME_QUEUE *Queue,
8373 + OUT MLME_QUEUE *Queue,
8380 unsigned long flags;
8381 @@ -2164,30 +2325,25 @@
8382 DBGPRINT(RT_DEBUG_ERROR, "MlmeEnqueueForRecv mlme frame too large, size = %d \n", MsgLen);
8386 - spin_lock_irqsave(&(Queue->Lock), flags);
8387 - if (MlmeQueueFull(Queue))
8390 + spin_lock_irqsave(&Queue->Lock, flags);
8391 + if (Queue->Num == MAX_LEN_OF_MLME_QUEUE) {
8392 + spin_unlock_irqrestore(&Queue->Lock, flags);
8393 printk(KERN_ERR DRV_NAME "MlmeEnqueue full, msg dropped and may corrupt MLME\n");
8394 - spin_unlock_irqrestore(&(Queue->Lock), flags);
8398 - Tail = Queue->Tail;
8400 + Tail = Queue->Tail++;
8401 + Queue->Tail %= MAX_LEN_OF_MLME_QUEUE;
8403 - if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
8407 + spin_unlock_irqrestore(&Queue->Lock, flags);
8408 DBGPRINT(RT_DEBUG_INFO, "MlmeEnqueue, num=%d\n",Queue->Num);
8411 Queue->Entry[Tail].Occupied = TRUE;
8412 Queue->Entry[Tail].Machine = Machine;
8413 Queue->Entry[Tail].MsgType = MsgType;
8414 Queue->Entry[Tail].MsgLen = MsgLen;
8415 - memcpy(Queue->Entry[Tail].Msg, Msg, MsgLen);
8416 - spin_unlock_irqrestore(&(Queue->Lock), flags);
8418 + memcpy(Queue->Entry[Tail].Msg, Msg, MsgLen);
8422 @@ -2203,14 +2359,14 @@
8425 BOOLEAN MlmeEnqueueForRecv(
8426 - IN PRTMP_ADAPTER pAd,
8427 - OUT MLME_QUEUE *Queue,
8428 - IN ULONG TimeStampHigh,
8429 + IN PRTMP_ADAPTER pAd,
8430 + OUT MLME_QUEUE *Queue,
8431 + IN ULONG TimeStampHigh,
8432 IN ULONG TimeStampLow,
8442 MACFRAME *Fr = (MACFRAME *)Msg;
8443 @@ -2225,31 +2381,25 @@
8447 - if (!MsgTypeSubst(Fr, &Machine, &MsgType))
8448 + if (!MsgTypeSubst(Fr, &Machine, &MsgType))
8450 DBGPRINT(RT_DEBUG_ERROR, "MlmeEnqueueForRecv (drop mgmt->subtype=%d)\n",Fr->Hdr.SubType);
8454 - spin_lock_irqsave(&(Queue->Lock), flags);
8455 - if (MlmeQueueFull(Queue))
8457 + spin_lock_irqsave(&Queue->Lock, flags);
8458 + if (Queue->Num == MAX_LEN_OF_MLME_QUEUE) {
8459 + spin_unlock_irqrestore(&Queue->Lock, flags);
8460 DBGPRINT(RT_DEBUG_ERROR, "MlmeEnqueueForRecv (queue full error) \n");
8461 - spin_unlock_irqrestore(&(Queue->Lock), flags);
8465 - // OK, we got all the informations, it is time to put things into queue
8466 - Tail = Queue->Tail;
8468 + Tail = Queue->Tail++;
8469 + Queue->Tail %= MAX_LEN_OF_MLME_QUEUE;
8471 - if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
8476 + spin_unlock_irqrestore(&Queue->Lock, flags);
8477 DBGPRINT(RT_DEBUG_INFO, "MlmeEnqueueForRecv, num=%d\n",Queue->Num);
8480 + // OK, we got all the informations, it is time to put things into queue
8481 Queue->Entry[Tail].Occupied = TRUE;
8482 Queue->Entry[Tail].Machine = Machine;
8483 Queue->Entry[Tail].MsgType = MsgType;
8484 @@ -2258,8 +2408,8 @@
8485 Queue->Entry[Tail].TimeStamp.vv.HighPart = TimeStampHigh;
8486 Queue->Entry[Tail].Rssi = Rssi;
8487 Queue->Entry[Tail].Noise = (Noise > BBP_R17_DYNAMIC_UP_BOUND) ? BBP_R17_DYNAMIC_UP_BOUND : ((ULONG) Noise);
8488 - memcpy(Queue->Entry[Tail].Msg, Msg, MsgLen);
8489 - spin_unlock_irqrestore(&(Queue->Lock), flags);
8491 + memcpy(Queue->Entry[Tail].Msg, Msg, MsgLen);
8495 @@ -2267,6 +2417,7 @@
8498 /*! \brief Dequeue a message from the MLME Queue
8499 + * WARNING: Must be call with Mlme.Queue.Lock held
8500 * \param *Queue The MLME Queue
8501 * \param *Elem The message dequeued from MLME Queue
8502 * \return TRUE if the Elem contains something, FALSE otherwise
8503 @@ -2274,23 +2425,14 @@
8506 BOOLEAN MlmeDequeue(
8507 - IN MLME_QUEUE *Queue,
8508 - OUT MLME_QUEUE_ELEM **Elem)
8509 + IN MLME_QUEUE *Queue,
8510 + OUT MLME_QUEUE_ELEM **Elem)
8512 - unsigned long flags;
8513 - spin_lock_irqsave(&(Queue->Lock), flags);
8514 - if (Queue->Num == 0) {
8515 - spin_unlock_irqrestore(&(Queue->Lock),flags);
8516 + if (Queue->Num == 0)
8519 - *Elem = &(Queue->Entry[Queue->Head]);
8520 + *Elem = &Queue->Entry[Queue->Head++];
8521 + Queue->Head %= MAX_LEN_OF_MLME_QUEUE;
8524 - if (Queue->Head == MAX_LEN_OF_MLME_QUEUE)
8528 - spin_unlock_irqrestore(&(Queue->Lock), flags);
8529 DBGPRINT(RT_DEBUG_INFO, "MlmeDequeue, num=%d\n",Queue->Num);
8532 @@ -2308,29 +2450,27 @@
8533 DBGPRINT(RT_DEBUG_ERROR, "Failure to initialize mlme.\n");
8534 // Continue the reset procedure...
8538 spin_lock_irqsave(&pAd->Mlme.TaskLock, flags);
8539 - if(pAd->Mlme.Running)
8540 + if(pAd->Mlme.Running)
8542 spin_unlock_irqrestore(&pAd->Mlme.TaskLock, flags);
8549 pAd->Mlme.Running = TRUE;
8551 spin_unlock_irqrestore(&pAd->Mlme.TaskLock, flags);
8553 // Remove all Mlme queues elements
8554 - while (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
8556 - //From message type, determine which state machine I should drive
8558 - // free MLME element
8559 - Elem->Occupied = FALSE;
8563 + spin_lock_irqsave(&pAd->Mlme.Queue.Lock, flags);
8564 + while (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) {
8565 + // free MLME element
8566 + Elem->Occupied = FALSE;
8569 + spin_unlock_irqrestore(&pAd->Mlme.Queue.Lock, flags);
8571 // Cancel all timer events
8572 // Be careful to cancel new added timer
8573 @@ -2356,54 +2496,22 @@
8574 pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
8575 pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
8576 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
8579 // Remove running state
8580 spin_lock_irqsave(&pAd->Mlme.TaskLock, flags);
8581 pAd->Mlme.Running = FALSE;
8582 spin_unlock_irqrestore(&pAd->Mlme.TaskLock, flags);
8585 -/*! \brief test if the MLME Queue is empty
8586 - * \param *Queue The MLME Queue
8587 - * \return TRUE if the Queue is empty, FALSE otherwise
8591 -BOOLEAN MlmeQueueEmpty(
8592 - IN MLME_QUEUE *Queue)
8596 - Ans = (Queue->Num == 0);
8601 -/*! \brief test if the MLME Queue is full
8602 - * \param *Queue The MLME Queue
8603 - * \return TRUE if the Queue is empty, FALSE otherwise
8607 -BOOLEAN MlmeQueueFull(
8608 - IN MLME_QUEUE *Queue)
8612 - Ans = (Queue->Num == MAX_LEN_OF_MLME_QUEUE);
8617 /*! \brief The destructor of MLME Queue
8623 * \note Clear Mlme Queue, Set Queue->Num to Zero.
8625 VOID MlmeQueueDestroy(
8626 - IN MLME_QUEUE *Queue)
8627 + IN MLME_QUEUE *Queue)
8629 unsigned long flags;
8630 spin_lock_irqsave(&(Queue->Lock), flags);
8631 @@ -2422,22 +2530,22 @@
8634 BOOLEAN MsgTypeSubst(
8645 // The only data type will pass to this function is EAPOL frame
8646 - if (Fr->Hdr.Type == BTYPE_DATA)
8648 + if (Fr->Hdr.Type == BTYPE_DATA)
8650 *Machine = WPA_PSK_STATE_MACHINE;
8651 EAPType = *((UCHAR*)Fr + LENGTH_802_11 + LENGTH_802_1_H + 1);
8652 return(WpaMsgTypeSubst(EAPType, MsgType));
8655 - switch (Fr->Hdr.SubType)
8656 + switch (Fr->Hdr.SubType)
8658 case SUBTYPE_ASSOC_REQ:
8659 *Machine = ASSOC_STATE_MACHINE;
8660 @@ -2478,17 +2586,17 @@
8662 // get the sequence number from payload 24 Mac Header + 2 bytes algorithm
8663 memcpy(&Seq, &Fr->Octet[2], sizeof(USHORT));
8664 - if (Seq == 1 || Seq == 3)
8665 + if (Seq == 1 || Seq == 3)
8667 *Machine = AUTH_RSP_STATE_MACHINE;
8668 *MsgType = MT2_PEER_AUTH_ODD;
8670 - else if (Seq == 2 || Seq == 4)
8672 + else if (Seq == 2 || Seq == 4)
8674 *Machine = AUTH_STATE_MACHINE;
8675 *MsgType = MT2_PEER_AUTH_EVEN;
8683 @@ -2510,25 +2618,25 @@
8684 // ===========================================================================================
8686 /*! \brief Initialize the state machine.
8687 - * \param *S pointer to the state machine
8688 + * \param *S pointer to the state machine
8689 * \param Trans State machine transition function
8690 - * \param StNr number of states
8691 - * \param MsgNr number of messages
8692 - * \param DefFunc default function, when there is invalid state/message combination
8693 - * \param InitState initial state of the state machine
8694 + * \param StNr number of states
8695 + * \param MsgNr number of messages
8696 + * \param DefFunc default function, when there is invalid state/message combination
8697 + * \param InitState initial state of the state machine
8698 * \param Base StateMachine base, internal use only
8699 * \pre p_sm should be a legal pointer
8703 VOID StateMachineInit(
8704 - IN STATE_MACHINE *S,
8705 - IN STATE_MACHINE_FUNC Trans[],
8708 - IN STATE_MACHINE_FUNC DefFunc,
8709 - IN ULONG InitState,
8711 + IN STATE_MACHINE *S,
8712 + IN STATE_MACHINE_FUNC Trans[],
8715 + IN STATE_MACHINE_FUNC DefFunc,
8716 + IN ULONG InitState,
8721 @@ -2538,22 +2646,22 @@
8724 S->TransFunc = Trans;
8727 // init all state transition to default function
8728 - for (i = 0; i < StNr; i++)
8729 + for (i = 0; i < StNr; i++)
8731 - for (j = 0; j < MsgNr; j++)
8732 + for (j = 0; j < MsgNr; j++)
8734 S->TransFunc[i * MsgNr + j] = DefFunc;
8739 // set the starting state
8740 S->CurrState = InitState;
8744 -/*! \brief This function fills in the function pointer into the cell in the state machine
8745 +/*! \brief This function fills in the function pointer into the cell in the state machine
8746 * \param *S pointer to the state machine
8748 * \param Msg incoming message
8749 @@ -2562,20 +2670,20 @@
8752 VOID StateMachineSetAction(
8753 - IN STATE_MACHINE *S,
8756 - IN STATE_MACHINE_FUNC Func)
8757 + IN STATE_MACHINE *S,
8760 + IN STATE_MACHINE_FUNC Func)
8765 MsgIdx = Msg - S->Base;
8767 - if (St < S->NrState && MsgIdx < S->NrMsg)
8768 + if (St < S->NrState && MsgIdx < S->NrMsg)
8770 // boundary checking before setting the action
8771 S->TransFunc[St * S->NrMsg + MsgIdx] = Func;
8776 /*! \brief The destructor of the state machine
8777 @@ -2583,7 +2691,7 @@
8778 * \note doing nothing at this moment, may need to do something if the implementation changed
8781 -StateMachineDestroy(IN STATE_MACHINE *S)
8782 +StateMachineDestroy(IN STATE_MACHINE *S)
8786 @@ -2594,9 +2702,9 @@
8789 VOID StateMachinePerformAction(
8790 - IN PRTMP_ADAPTER pAd,
8791 - IN STATE_MACHINE *S,
8792 - IN MLME_QUEUE_ELEM *Elem)
8793 + IN PRTMP_ADAPTER pAd,
8794 + IN STATE_MACHINE *S,
8795 + IN MLME_QUEUE_ELEM *Elem)
8797 (*(S->TransFunc[S->CurrState * S->NrMsg + Elem->MsgType - S->Base]))(pAd, Elem);
8799 @@ -2604,14 +2712,14 @@
8801 ==========================================================================
8803 - The drop function, when machine executes this, the message is simply
8804 - ignored. This function does nothing, the message is freed in
8805 + The drop function, when machine executes this, the message is simply
8806 + ignored. This function does nothing, the message is freed in
8807 StateMachinePerformAction()
8808 ==========================================================================
8811 - IN PRTMP_ADAPTER pAd,
8812 - IN MLME_QUEUE_ELEM *Elem)
8813 + IN PRTMP_ADAPTER pAd,
8814 + IN MLME_QUEUE_ELEM *Elem)
8817 if ((Elem->MsgType == MT2_PEER_BEACON) ||
8818 @@ -2622,7 +2730,7 @@
8820 DBGPRINT(RT_DEBUG_TRACE, ("Warn:>>Drop Msg=%d<<\n",Elem->MsgType));
8826 // ===========================================================================================
8827 @@ -2635,12 +2743,12 @@
8828 ==========================================================================
8831 - IN PRTMP_ADAPTER pAd,
8833 + IN PRTMP_ADAPTER pAd,
8838 pAd->Mlme.ShiftReg = 1;
8841 pAd->Mlme.ShiftReg = Seed;
8844 @@ -2650,21 +2758,21 @@
8845 ==========================================================================
8848 - IN PRTMP_ADAPTER pAd)
8849 + IN PRTMP_ADAPTER pAd)
8856 - for (i = 0; i < 8; i++)
8857 + for (i = 0; i < 8; i++)
8859 - if (pAd->Mlme.ShiftReg & 0x00000001)
8860 + if (pAd->Mlme.ShiftReg & 0x00000001)
8862 pAd->Mlme.ShiftReg = ((pAd->Mlme.ShiftReg ^ LFSR_MASK) >> 1) | 0x80000000;
8869 pAd->Mlme.ShiftReg = pAd->Mlme.ShiftReg >> 1;
8871 @@ -2681,17 +2789,17 @@
8872 ==========================================================================
8874 VOID AsicSwitchChannel(
8875 - IN PRTMP_ADAPTER pAd,
8877 + IN PRTMP_ADAPTER pAd,
8884 // TODO: need to update E2PROM format to add 802.11a channel's TX power calibration values
8885 - if (Channel <= 14)
8886 + if (Channel <= 14)
8887 R3 = pAd->PortCfg.ChannelTxPower[Channel - 1];
8890 R3 = pAd->PortCfg.ChannelTxPower[0];
8892 if (R3 > 31) R3 = 31;
8893 @@ -2706,10 +2814,10 @@
8894 Value = (Value > 31) ? 31 : Value;
8895 Value = (Value < 0) ? 0 : Value;
8899 // Krellan: Save value for readout to user
8900 pAd->PortCfg.TxPowerDriver = R3;
8903 R3 = R3 << 9; // shift TX power control to correct RF R3 bit position
8905 switch (pAd->PortCfg.RfType)
8906 @@ -2772,7 +2880,7 @@
8913 for (index = 0; index < NUM_OF_2525_CHNL; index++)
8915 @@ -2800,7 +2908,7 @@
8922 for (index = 0; index < NUM_OF_2525E_CHNL; index++)
8924 @@ -2820,7 +2928,7 @@
8931 for (index = 0; index < NUM_OF_5222_CHNL; index++)
8933 @@ -2846,12 +2954,12 @@
8936 DBGPRINT(RT_DEBUG_INFO, "AsicSwitchChannel(RF=%d) to #%d, TXPwr=%d, R1=0x%08x, R2=0x%08x, R3=0x%08x, R4=0x%08x\n",
8937 - pAd->PortCfg.RfType,
8938 - pAd->PortCfg.LatchRfRegs.Channel,
8939 + pAd->PortCfg.RfType,
8940 + pAd->PortCfg.LatchRfRegs.Channel,
8941 pAd->PortCfg.TxPower,
8942 - pAd->PortCfg.LatchRfRegs.R1,
8943 - pAd->PortCfg.LatchRfRegs.R2,
8944 - pAd->PortCfg.LatchRfRegs.R3,
8945 + pAd->PortCfg.LatchRfRegs.R1,
8946 + pAd->PortCfg.LatchRfRegs.R2,
8947 + pAd->PortCfg.LatchRfRegs.R3,
8948 pAd->PortCfg.LatchRfRegs.R4);
8951 @@ -2865,8 +2973,8 @@
8952 ==========================================================================
8954 VOID AsicLockChannel(
8955 - IN PRTMP_ADAPTER pAd,
8957 + IN PRTMP_ADAPTER pAd,
8962 @@ -2899,14 +3007,14 @@
8964 pAd->PortCfg.LatchRfRegs.R1 &= 0xfffdffff; // RF R1.bit17 "tune_en1" OFF
8965 pAd->PortCfg.LatchRfRegs.R3 &= 0xfffffeff; // RF R3.bit8 "tune_en2" OFF
8966 - RTMP_RF_IO_WRITE32(pAd, pAd->PortCfg.LatchRfRegs.R1);
8967 - RTMP_RF_IO_WRITE32(pAd, pAd->PortCfg.LatchRfRegs.R3);
8968 + RTMP_RF_IO_WRITE32(pAd, pAd->PortCfg.LatchRfRegs.R1);
8969 + RTMP_RF_IO_WRITE32(pAd, pAd->PortCfg.LatchRfRegs.R3);
8970 DBGPRINT(RT_DEBUG_INFO, "AsicRfTuningExec(R1=0x%x,R3=0x%x)\n",pAd->PortCfg.LatchRfRegs.R1,pAd->PortCfg.LatchRfRegs.R3);
8975 pAd->PortCfg.LatchRfRegs.R3 &= 0xfffffeff; // RF R3.bit8 "tune_en2" OFF
8976 - RTMP_RF_IO_WRITE32(pAd, pAd->PortCfg.LatchRfRegs.R3);
8977 + RTMP_RF_IO_WRITE32(pAd, pAd->PortCfg.LatchRfRegs.R3);
8978 DBGPRINT(RT_DEBUG_INFO, "AsicRfTuningExec(R3=0x%x)\n",pAd->PortCfg.LatchRfRegs.R3);
8981 @@ -2929,16 +3037,16 @@
8982 ==========================================================================
8984 VOID AsicAdjustTxPower(
8985 - IN PRTMP_ADAPTER pAd)
8986 + IN PRTMP_ADAPTER pAd)
8988 ULONG R3, Channel, CurrTxPwr;
8991 if ((pAd->PortCfg.Channel >= 1) && (pAd->PortCfg.Channel <= 14))
8992 Channel = pAd->PortCfg.Channel;
8995 Channel = 1; // don't have calibration info for 11A, temporarily use Channel 1
8998 // get TX Power base from E2PROM
8999 R3 = pAd->PortCfg.ChannelTxPower[Channel - 1];
9000 if (R3 > 31) R3 = 31;
9001 @@ -2948,7 +3056,7 @@
9002 Value = (Value > 31) ? 31 : Value;
9003 Value = (Value < 0) ? 0 : Value;
9007 // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
9008 // We lower TX power here according to the percentage specified from UI
9009 if (pAd->PortCfg.TxPowerAuto == TRUE) // AUTO TX POWER control
9010 @@ -2959,10 +3067,10 @@
9011 // low TX power upon very-short distance to AP to solve some vendor's AP RX problem
9012 // in this case, no TSSI compensation is required.
9014 - if ((pAd->DrsCounters.fNoisyEnvironment == FALSE) &&
9015 + if ((pAd->DrsCounters.fNoisyEnvironment == FALSE) &&
9016 (pAd->PortCfg.AvgRssi > (pAd->PortCfg.RssiToDbm - RSSI_FOR_LOWEST_TX_POWER)))
9017 R3 -= LOWEST_TX_POWER_DELTA;
9018 - else if ((pAd->DrsCounters.fNoisyEnvironment == FALSE) &&
9019 + else if ((pAd->DrsCounters.fNoisyEnvironment == FALSE) &&
9020 (pAd->PortCfg.AvgRssi > (pAd->PortCfg.RssiToDbm - RSSI_FOR_LOW_TX_POWER)))
9021 R3 -= LOW_TX_POWER_DELTA;
9023 @@ -2973,7 +3081,7 @@
9025 if (R3 > 31) R3 = 31;
9029 // 2 exclusive rules applied on CCK rates only -
9030 // 1. always plus 2 db for CCK
9031 // 2. adjust TX Power based on TSSI
9032 @@ -2986,10 +3094,10 @@
9033 R3 += 2; // plus 2 db
9034 if (R3 > 31) R3 = 31;
9037 - // Auto calibrate Tx AGC if bAutoTxAgc is TRUE and TX rate is CCK,
9039 + // Auto calibrate Tx AGC if bAutoTxAgc is TRUE and TX rate is CCK,
9040 // because E2PROM's TSSI reference is valid only in CCK range.
9044 UCHAR R1,TxPowerRef, TssiRef;
9046 @@ -3005,7 +3113,7 @@
9047 // Need R3 adjustment. However, we have to make sure there is only
9048 // plus / minus 5 variation allowed
9052 R3 = (R3 < (ULONG) (TxPowerRef + 5)) ? (R3 + 1) : R3;
9055 @@ -3020,7 +3128,7 @@
9063 else // fixed AUTO TX power
9064 @@ -3035,7 +3143,7 @@
9066 // Krellan: Save value for readout to user
9067 pAd->PortCfg.TxPowerDriver = R3;
9070 // compare the desired R3.TxPwr value with current R3, if not equal
9072 CurrTxPwr = (pAd->PortCfg.LatchRfRegs.R3 >> 9) & 0x0000001f;
9073 @@ -3058,8 +3166,8 @@
9074 ==========================================================================
9076 VOID AsicSleepThenAutoWakeup(
9077 - IN PRTMP_ADAPTER pAd,
9078 - IN USHORT TbttNumToNextWakeUp)
9079 + IN PRTMP_ADAPTER pAd,
9080 + IN USHORT TbttNumToNextWakeUp)
9083 PWRCSR1_STRUC Pwrcsr1;
9084 @@ -3067,9 +3175,9 @@
9085 // we have decided to SLEEP, so at least do it for a BEACON period.
9086 if (TbttNumToNextWakeUp==0)
9087 TbttNumToNextWakeUp=1;
9090 // PWRCSR0 remains untouched
9093 // set CSR20 for next wakeup
9095 Csr20.field.NumBcnBeforeWakeup = TbttNumToNextWakeUp - 1;
9096 @@ -3141,17 +3249,17 @@
9097 ==========================================================================
9100 - IN PRTMP_ADAPTER pAd,
9101 - IN MACADDR *Bssid)
9102 + IN PRTMP_ADAPTER pAd,
9103 + IN MACADDR *Bssid)
9107 - Addr4 = (ULONG)(Bssid->Octet[0]) |
9108 - (ULONG)(Bssid->Octet[1] << 8) |
9109 + Addr4 = (ULONG)(Bssid->Octet[0]) |
9110 + (ULONG)(Bssid->Octet[1] << 8) |
9111 (ULONG)(Bssid->Octet[2] << 16) |
9112 (ULONG)(Bssid->Octet[3] << 24);
9113 RTMP_IO_WRITE32(pAd, CSR5, Addr4);
9116 Addr4 = (ULONG)(Bssid->Octet[4]) | (ULONG)(Bssid->Octet[5] << 8);
9117 RTMP_IO_WRITE32(pAd, CSR6, Addr4);
9119 @@ -3162,7 +3270,7 @@
9120 ==========================================================================
9122 VOID AsicDisableSync(
9123 - IN PRTMP_ADAPTER pAd)
9124 + IN PRTMP_ADAPTER pAd)
9126 // TIMECSR_STRUC TimeCsr;
9127 DBGPRINT(RT_DEBUG_TRACE, "--->Disable TSF synchronization\n");
9128 @@ -3174,7 +3282,7 @@
9129 RTMP_IO_WRITE32(pAd, CSR14, 0x00000000);
9134 RTMP_IO_READ32(pAd, TIMECSR, &TimeCsr.word);
9136 // restore to 33 PCI-tick-per-Usec. for 2560a only where PCI-clock is used as TSF timing source
9137 @@ -3192,7 +3300,7 @@
9138 ==========================================================================
9140 VOID AsicEnableBssSync(
9141 - IN PRTMP_ADAPTER pAd)
9142 + IN PRTMP_ADAPTER pAd)
9146 @@ -3201,14 +3309,14 @@
9149 DBGPRINT(RT_DEBUG_TRACE, "--->AsicEnableBssSync(INFRA mode)\n");
9152 RTMP_IO_WRITE32(pAd, CSR14, 0x00000000);
9156 Csr12.field.BeaconInterval = pAd->PortCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
9157 Csr12.field.CfpMaxDuration = pAd->PortCfg.CfpMaxDuration << 4; // ASIC register in units of 1/16 TU
9158 RTMP_IO_WRITE32(pAd, CSR12, Csr12.word);
9162 Csr13.field.CfpPeriod = pAd->PortCfg.CfpDurRemain << 4; // ASIC register in units of 1/16 TU
9163 RTMP_IO_WRITE32(pAd, CSR13, Csr13.word);
9164 @@ -3218,14 +3326,14 @@
9165 Bcncsr1.field.BeaconCwMin = 5;
9166 RTMP_IO_WRITE32(pAd, BCNCSR1, Bcncsr1.word);
9168 - IsApPc = (CAP_IS_CF_POLLABLE_ON(pAd->PortCfg.CapabilityInfo) &&
9169 + IsApPc = (CAP_IS_CF_POLLABLE_ON(pAd->PortCfg.CapabilityInfo) &&
9170 CAP_IS_CF_POLL_REQ_ON(pAd->PortCfg.CapabilityInfo));
9171 IsApPc = FALSE; // TODO: not support so far
9175 Csr14.field.TsfCount = 1;
9176 Csr14.field.TsfSync = 1; // sync TSF in INFRASTRUCTURE mode
9180 Csr14.field.CfpCntPreload = pAd->PortCfg.CfpCount;
9181 Csr14.field.Tcfp = 1;
9182 @@ -3234,13 +3342,13 @@
9183 // Csr14.field.TbcnPreload = (pAd->PortCfg.BeaconPeriod - 30) << 4; // TODO: ???? 1 TU ???
9184 Csr14.field.Tbcn = 1;
9185 RTMP_IO_WRITE32(pAd, CSR14, Csr14.word);
9191 ==========================================================================
9195 BEACON frame in shared memory should be built ok before this routine
9196 can be called. Otherwise, a garbage frame maybe transmitted out every
9198 @@ -3254,7 +3362,7 @@
9200 // BCNCSR_STRUC Bcncsr;
9201 BCNCSR1_STRUC Bcncsr1;
9204 DBGPRINT(RT_DEBUG_TRACE, "--->AsicEnableIbssSync(ADHOC mode)\n");
9206 RTMP_IO_WRITE32(pAd, CSR14, 0x00000000);
9207 @@ -3279,7 +3387,7 @@
9208 Bcncsr1.field.Preload = 700; // 24 + ((MAC_HDR_LEN << 4) / RateIdTo500Kbps[pAd->PortCfg.MlmeRate]);
9210 RTMP_IO_WRITE32(pAd, BCNCSR1, Bcncsr1.word);
9214 Csr14.field.TsfCount = 1;
9215 Csr14.field.TsfSync = 2; // sync TSF in IBSS mode
9216 @@ -3289,16 +3397,16 @@
9219 VOID AsicLedPeriodicExec(
9220 - IN unsigned long data)
9221 + IN unsigned long data)
9223 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
9224 ULONG LedCsr = 0x0000461E; // 0x0000461E;
9227 pAd->PortCfg.LedCntl.fOdd = ! pAd->PortCfg.LedCntl.fOdd;
9229 - if (INFRA_ON(pAd) || ADHOC_ON(pAd))
9230 + if (INFRA_ON(pAd) || ADHOC_ON(pAd))
9231 LedCsr |= 0x00010000; // enable hardwired TX activity LED
9232 - if (pAd->PortCfg.LedCntl.fOdd && pAd->PortCfg.LedCntl.fRxActivity)
9233 + if (pAd->PortCfg.LedCntl.fOdd && pAd->PortCfg.LedCntl.fRxActivity)
9234 LedCsr |= 0x00020000; // turn on software-based RX activity LED
9235 pAd->PortCfg.LedCntl.fRxActivity = FALSE;
9237 @@ -3315,17 +3423,17 @@
9238 // pAd->PortCfg.CurrentRxAntenna
9239 // 0xff: diversity, 0:antenna A, 1:antenna B
9241 - IN PRTMP_ADAPTER pAd)
9242 + IN PRTMP_ADAPTER pAd)
9244 UCHAR RxValue, TxValue;
9248 RTMPCancelTimer(&pAd->PortCfg.RxAnt.RxAntDiversityTimer);
9249 pAd->PortCfg.RxAnt.AvgRssi[0] = (-95 + 120) << 3; // reset Ant-A's RSSI history
9250 pAd->PortCfg.RxAnt.AvgRssi[1] = (-95 + 120) << 3; // reset Ant-B's RSSI history
9252 pAd->PortCfg.RxAnt.PrimaryInUsed = TRUE;
9255 if (pAd->PortCfg.CurrentRxAntenna == 0xff) // Diversity
9257 pAd->PortCfg.RxAnt.PrimaryRxAnt = 1; // assume ant-B
9258 @@ -3344,7 +3452,7 @@
9260 DBGPRINT(RT_DEBUG_TRACE,"AntDiv - set RxAnt=%d, primary=%d, second=%d\n",
9261 pAd->PortCfg.CurrentRxAntenna, pAd->PortCfg.RxAnt.PrimaryRxAnt, pAd->PortCfg.RxAnt.SecondaryRxAnt);
9264 // use primary antenna
9265 RTMP_IO_READ32(pAd, BBPCSR1, &Bbpcsr1);
9266 TxValue = pAd->PortCfg.BbpWriteLatch[BBP_Tx_Configure];
9267 @@ -3352,34 +3460,34 @@
9268 if (pAd->PortCfg.RxAnt.PrimaryRxAnt == 0) // ant-A
9270 TxValue = (TxValue & 0xFC) | 0x00;
9273 Bbpcsr1 = (Bbpcsr1 & 0xFFFCFFFC) | 0x00000000;
9277 TxValue = (TxValue & 0xFC) | 0x02;
9280 Bbpcsr1 = (Bbpcsr1 & 0xFFFCFFFC) | 0x00020002;
9282 RTMP_IO_WRITE32(pAd, BBPCSR1, Bbpcsr1);
9283 //RTMP_BBP_IO_WRITE32_BY_REG_ID(pAd, BBP_Tx_Configure, TxValue);
9284 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAd, BBP_Rx_Configure, RxValue);
9289 // switch to secondary RxAnt for a while to collect it's average RSSI
9290 -// also set a timeout routine to DO the actual evaluation. If evaluation
9291 +// also set a timeout routine to DO the actual evaluation. If evaluation
9292 // result shows a much better RSSI using secondary RxAnt, then a official
9293 // RX antenna switch is performed.
9294 VOID AsicEvaluateSecondaryRxAnt(
9295 - IN PRTMP_ADAPTER pAd)
9296 + IN PRTMP_ADAPTER pAd)
9298 UCHAR RxValue, TxValue;
9301 if (pAd->PortCfg.CurrentRxAntenna != 0xff)
9305 pAd->PortCfg.RxAnt.PrimaryInUsed = FALSE;
9306 pAd->PortCfg.RxAnt.FirstPktArrivedWhenEvaluate = FALSE;
9307 pAd->PortCfg.RxAnt.RcvPktNumWhenEvaluate = 0;
9308 @@ -3387,16 +3495,16 @@
9309 // pAd->PortCfg.RxAnt.AvgRssi[pAd->PortCfg.RxAnt.SecondaryRxAnt] = 0;
9311 DBGPRINT(RT_DEBUG_TRACE,"AntDiv - evaluate Ant #%d\n", pAd->PortCfg.RxAnt.SecondaryRxAnt);
9314 // temporarily switch to secondary antenna
9315 RxValue = pAd->PortCfg.BbpWriteLatch[BBP_Rx_Configure];
9316 TxValue = pAd->PortCfg.BbpWriteLatch[BBP_Tx_Configure];
9317 RTMP_IO_READ32(pAd, BBPCSR1, &Bbpcsr1);
9320 if (pAd->PortCfg.RxAnt.SecondaryRxAnt == 0) // ant-A
9322 TxValue = (TxValue & 0xFC) | 0x00;
9325 Bbpcsr1 = (Bbpcsr1 & 0xFFFCFFFC) | 0x00000000;
9328 @@ -3411,7 +3519,7 @@
9330 // a one-shot timer to end the evalution
9331 if (pAd->MediaState == NdisMediaStateConnected)
9332 - RTMPSetTimer(pAd, &pAd->PortCfg.RxAnt.RxAntDiversityTimer, 150);
9333 + RTMPSetTimer(pAd, &pAd->PortCfg.RxAnt.RxAntDiversityTimer, 150);
9335 RTMPSetTimer(pAd, &pAd->PortCfg.RxAnt.RxAntDiversityTimer, 300);
9337 @@ -3419,17 +3527,17 @@
9338 // this timeout routine collect AvgRssi[SecondaryRxAnt] and decide if
9339 // SecondaryRxAnt is much better than PrimaryRxAnt
9340 VOID AsicRxAntEvalTimeout(
9341 - IN unsigned long data)
9342 + IN unsigned long data)
9344 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
9348 DBGPRINT(RT_DEBUG_TRACE,"AntDiv - AsicRxAntEvalTimeout, \n");
9349 // Do nothing if the driver is starting halt state.
9350 // This might happen when timer already been fired before cancel timer with mlmehalt
9351 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
9355 if (pAd->PortCfg.RxAnt.PrimaryInUsed == TRUE)
9358 @@ -3445,7 +3553,7 @@
9359 pAd->PortCfg.RxAnt.PrimaryRxAnt = pAd->PortCfg.RxAnt.SecondaryRxAnt;
9360 pAd->PortCfg.RxAnt.SecondaryRxAnt = temp;
9361 pAd->PortCfg.LastAvgRssi = (pAd->PortCfg.RxAnt.AvgRssi[pAd->PortCfg.RxAnt.SecondaryRxAnt] >> 3) - pAd->PortCfg.RssiToDbm;
9364 DBGPRINT(RT_DEBUG_TRACE,"AntDiv - Switch to Ant #%d, RSSI[0,1]=<%d, %d>\n",
9365 pAd->PortCfg.RxAnt.PrimaryRxAnt, pAd->PortCfg.RxAnt.AvgRssi[0], pAd->PortCfg.RxAnt.AvgRssi[1]);
9367 @@ -3453,7 +3561,7 @@
9369 UCHAR RxValue, TxValue;
9373 // end of evaluation, swicth back to primary antenna
9374 RxValue = pAd->PortCfg.BbpWriteLatch[BBP_Rx_Configure];
9375 TxValue = pAd->PortCfg.BbpWriteLatch[BBP_Tx_Configure];
9376 @@ -3461,7 +3569,7 @@
9377 if (pAd->PortCfg.RxAnt.PrimaryRxAnt == 0) // ant-A
9379 TxValue = (TxValue & 0xFC) | 0x00;
9382 Bbpcsr1 = (Bbpcsr1 & 0xFFFCFFFC) | 0x00000000;
9385 @@ -3491,7 +3599,7 @@
9387 VOID AsicSetSlotTime(
9388 IN PRTMP_ADAPTER pAd,
9389 - IN BOOLEAN UseShortSlotTime)
9390 + IN BOOLEAN UseShortSlotTime)
9394 @@ -3499,7 +3607,7 @@
9397 pAd->PortCfg.ShortSlotInUsed = UseShortSlotTime;
9400 PhyMode = pAd->PortCfg.PhyMode;
9401 if (PhyMode == PHY_11ABG_MIXED)
9403 @@ -3527,7 +3635,7 @@
9405 Csr19.field.EIFS = 60; // roughly = SIFS + ACK @6Mbps
9406 RTMP_IO_WRITE32(pAd, CSR19, Csr19.word);
9410 // force using short SLOT time for FAE to demo performance only
9411 if (pAd->PortCfg.EnableTxBurst == 1)
9412 @@ -3543,7 +3651,7 @@
9413 ==========================================================================
9415 This routine is used for 2560a only where 2560a still use non-accurate
9416 - PCI-clock as TSF 1-usec source. we have to dynamically change tick-per-usec
9417 + PCI-clock as TSF 1-usec source. we have to dynamically change tick-per-usec
9418 to avoid ADHOC synchronization issue with SYMBOL 11b card
9419 ==========================================================================
9421 @@ -3575,7 +3683,7 @@
9423 ==========================================================================
9425 - danamic tune BBP R17 to find a balance between sensibility and
9426 + danamic tune BBP R17 to find a balance between sensibility and
9428 ==========================================================================
9430 @@ -3586,13 +3694,13 @@
9432 ULONG FalseCcaUpperThreshold = pAd->PortCfg.BbpTuning.FalseCcaUpperThreshold << 7;
9433 int dbm = pAd->PortCfg.AvgRssi - pAd->PortCfg.RssiToDbm;
9436 if ((! pAd->PortCfg.BbpTuningEnable) || (pAd->PortCfg.BbpTuning.VgcDelta==0))
9440 R17 = pAd->PortCfg.BbpWriteLatch[17];
9442 - if ((pAd->PortCfg.Rt2560Version >= RT2560_VER_D) &&
9443 + if ((pAd->PortCfg.Rt2560Version >= RT2560_VER_D) &&
9444 (pAd->MediaState == NdisMediaStateConnected))
9447 @@ -3609,7 +3717,7 @@
9450 // Rule 1. "special big-R17 for short-distance" when not SCANNING
9451 - else if ((dbm >= RSSI_FOR_LOW_SENSIBILITY) &&
9452 + else if ((dbm >= RSSI_FOR_LOW_SENSIBILITY) &&
9453 (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
9455 if (R17 != BBP_R17_LOW_SENSIBILITY)
9456 @@ -3621,7 +3729,7 @@
9459 // Rule 2. "special mid-R17 for mid-distance" when not SCANNING
9460 - else if ((dbm >= RSSI_FOR_MID_SENSIBILITY) &&
9461 + else if ((dbm >= RSSI_FOR_MID_SENSIBILITY) &&
9462 (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
9464 if (R17 != BBP_R17_MID_SENSIBILITY)
9465 @@ -3632,7 +3740,7 @@
9466 DBGPRINT(RT_DEBUG_INFO, "RSSI = %d dbm, fixed R17 at 0x%x\n", dbm, R17);
9469 - // Rule 3. leave "short or mid-distance" condition, restore R17 to the
9470 + // Rule 3. leave "short or mid-distance" condition, restore R17 to the
9471 // dynamic tuning range <E2PROM-6, BBP_R17_DYNAMIC_UP_BOUND>
9472 else if (R17 >= BBP_R17_MID_SENSIBILITY)
9474 @@ -3642,13 +3750,13 @@
9480 // Rule 3. otherwise, R17 is currenly in dyanmic tuning range: <E2PROM-6, BBP_R17_DYNAMIC_UP_BOUND>.
9481 // Keep dynamic tuning based on False CCA conter
9484 RTMP_IO_READ32(pAd, CNT3, &Value);
9485 pAd->PrivateInfo.CCAErrCnt = (Value & 0x0000ffff);
9486 - DBGPRINT(RT_DEBUG_INFO, "CCA flase alarm = %d, Avg RSSI= %d dbm\n",
9487 + DBGPRINT(RT_DEBUG_INFO, "CCA flase alarm = %d, Avg RSSI= %d dbm\n",
9488 pAd->PrivateInfo.CCAErrCnt, dbm);
9490 if ((pAd->PrivateInfo.CCAErrCnt > FalseCcaUpperThreshold) &&
9491 @@ -3697,7 +3805,7 @@
9499 ========================================================================
9500 @@ -3714,7 +3822,7 @@
9501 DBGPRINT(RT_DEBUG_INFO, "==> MlmeFreeMemory\n");
9502 spin_lock(&pAd->MemLock);
9503 if (pAd->Mlme.MemHandler.MemRunning)
9506 //Mlme memory handler is busy.
9507 //Move it to the Pending array for later free
9508 pAd->Mlme.MemHandler.MemFreePending[pAd->Mlme.MemHandler.PendingCount++] = (PULONG) AllocVa;
9509 @@ -3738,7 +3846,7 @@
9510 while (pMlmeMemoryStruct)
9512 if (pMlmeMemoryStruct->AllocVa == (PVOID) pAd->Mlme.MemHandler.MemFreePending[Index])
9515 //Found virtual address in the in-used link list
9516 //Remove it from the memory in-used link list, and move it to the unused link list
9517 if (pPrevious == NULL)
9518 @@ -3865,7 +3973,7 @@
9519 pAd->Mlme.MemHandler.MemRunning = FALSE;
9520 spin_unlock(&pAd->MemLock);
9522 - DBGPRINT(RT_DEBUG_INFO, "<== MlmeFreeMemory [IN:%d][UN:%d][Pending:%d]\n",
9523 + DBGPRINT(RT_DEBUG_INFO, "<== MlmeFreeMemory [IN:%d][UN:%d][Pending:%d]\n",
9524 pAd->Mlme.MemHandler.InUseCount, pAd->Mlme.MemHandler.UnUseCount, pAd->Mlme.MemHandler.PendingCount);
9527 @@ -3883,7 +3991,7 @@
9530 NDIS_STATUS_RESOURCES
9535 ========================================================================
9536 @@ -3911,7 +4019,7 @@
9539 if (pAd->Mlme.MemHandler.pUnUseHead == NULL)
9540 - { //There are no available memory for caller use
9541 + { //There are no available memory for caller use
9542 Status = NDIS_STATUS_RESOURCES;
9543 pAd->Mlme.MemHandler.MemRunning = FALSE;
9544 spin_unlock(&pAd->MemLock);
9545 @@ -3963,7 +4071,7 @@
9548 NDIS_STATUS_RESOURCES
9553 ========================================================================
9554 @@ -3994,7 +4102,7 @@
9556 if (Number > MAX_MLME_HANDLER_MEMORY)
9557 Number = MAX_MLME_HANDLER_MEMORY;
9560 for (i = 0; i < Number; i++)
9562 //Allocate a nonpaged memory for link list use.
9563 diff -Nur rt2500-1.1.0-b4/Module/mlme.h rt2500-cvs-2007061011/Module/mlme.h
9564 --- rt2500-1.1.0-b4/Module/mlme.h 2006-06-17 22:12:58.000000000 +0200
9565 +++ rt2500-cvs-2007061011/Module/mlme.h 2007-03-21 05:25:34.000000000 +0100
9567 -/***************************************************************************
9568 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
9570 - * This program is free software; you can redistribute it and/or modify *
9571 - * it under the terms of the GNU General Public License as published by *
9572 - * the Free Software Foundation; either version 2 of the License, or *
9573 - * (at your option) any later version. *
9575 - * This program is distributed in the hope that it will be useful, *
9576 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9577 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
9578 - * GNU General Public License for more details. *
9580 - * You should have received a copy of the GNU General Public License *
9581 - * along with this program; if not, write to the *
9582 - * Free Software Foundation, Inc., *
9583 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
9585 - * Licensed under the GNU GPL *
9586 - * Original code supplied under license from RaLink Inc, 2004. *
9587 - ***************************************************************************/
9588 +/***************************************************************************
9589 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
9591 + * This program is free software; you can redistribute it and/or modify *
9592 + * it under the terms of the GNU General Public License as published by *
9593 + * the Free Software Foundation; either version 2 of the License, or *
9594 + * (at your option) any later version. *
9596 + * This program is distributed in the hope that it will be useful, *
9597 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9598 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
9599 + * GNU General Public License for more details. *
9601 + * You should have received a copy of the GNU General Public License *
9602 + * along with this program; if not, write to the *
9603 + * Free Software Foundation, Inc., *
9604 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
9606 + * Licensed under the GNU GPL *
9607 + * Original code supplied under license from RaLink Inc, 2004. *
9608 + ***************************************************************************/
9610 - /***************************************************************************
9611 + /***************************************************************************
9612 * Module Name: mlme.h
9616 - * Revision History:
9618 - * -------- ----------- -----------------------------
9619 - * John 28th Aug 03 Initial code
9620 - * MarkW 8th Dec 04 Baseline code
9621 - ***************************************************************************/
9625 + * Revision History:
9627 + * -------- ----------- -----------------------------
9628 + * John 28th Aug 03 Initial code
9629 + * MarkW 8th Dec 04 Baseline code
9630 + ***************************************************************************/
9637 -// maximum supported capability information -
9638 +// maximum supported capability information -
9639 // ESS, IBSS, Privacy, Short Preamble, Short Slot
9640 #define SUPPORTED_CAPABILITY_INFO 0x0433
9644 #define RSSI_TO_DBM_OFFSET 120 // for RT2530 RSSI-115 = dBm
9645 #define RSSI_FOR_MID_TX_POWER 55 // -55 db is considered mid-distance
9646 -#define RSSI_FOR_LOW_TX_POWER 45 // -45 db is considered very short distance and
9647 +#define RSSI_FOR_LOW_TX_POWER 45 // -45 db is considered very short distance and
9648 // eligible to use a lower TX power
9649 #define RSSI_FOR_LOWEST_TX_POWER 30
9650 #define MID_TX_POWER_DELTA 0 // -3 db from full TX power upon mid-distance to AP
9652 #define TX_FER_TOO_HIGH(TxFER) ((TxFER) > 15) // consider rate down if FER>15%
9653 #define TX_FER_VERY_LOW(TxFER) ((TxFER) < 7) // consider rate up if FER<7%
9654 #define FAIR_FER 10 // any value between TOO_HIGH and VERY_LOW
9655 -#define DRS_TX_QUALITY_WORST_BOUND 3
9656 +#define DRS_TX_QUALITY_WORST_BOUND 3
9657 #define DRS_PENALTY 8
9659 // Ralink timer control block
9660 @@ -329,13 +329,14 @@
9661 USHORT CfpDurRemaining;
9663 CHAR Ssid[MAX_LEN_OF_SSID];
9666 ULONG LastBeaconRxTime; // OS's timestamp
9668 // New for microsoft WPA support
9669 + USHORT CipherCap; // Pair (0:7), Group (8:15) cipher cap
9670 NDIS_802_11_FIXED_IEs FixIEs;
9671 NDIS_802_11_WEP_STATUS WepStatus;
9672 - UCHAR VarIELen; // Length of next VIE include EID & Length
9673 + USHORT VarIELen; // Length of all saved IEs.
9674 UCHAR VarIEs[MAX_VIE_LEN];
9675 } BSS_ENTRY, *PBSS_ENTRY;
9680 BOOLEAN CurrReqIsFromNdis; // TRUE - then we should call NdisMSetInformationComplete()
9681 - // FALSE - req is from driver itself.
9682 + // FALSE - req is from driver itself.
9683 // no NdisMSetInformationComplete() is required
9684 } CNTL_AUX, *PCNTL_AUX;
9687 USHORT CapabilityInfo;
9689 CHAR Ssid[MAX_LEN_OF_SSID];
9692 RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
9693 } ASSOC_AUX, *PASSOC_AUX;
9695 @@ -482,10 +483,10 @@
9696 typedef struct PACKED _BEACON_EID_STRUCT {
9701 } BEACON_EID_STRUCT,*PBEACON_EID_STRUCT;
9703 -// New for WPA cipher suite
9704 +// New for WPA cipher suite
9705 typedef struct PACKED _RSN_EID_STRUCT {
9708 @@ -497,6 +498,98 @@
9711 } RSN_EID_STRUCT, *PRSN_EID_STRUCT;
9712 +#define MIN_WPA_KEYDATA_LEN (4 + sizeof(ie_version_t) + sizeof(suite_sel_t) + \
9713 + 2*sizeof(suite_list_t))
9716 +/* Country Information Element (802.11d pp. 4, 5) */
9718 +typedef struct country_subelement {
9719 + unsigned char first_chan,
9721 + signed char max_tx_pwr; // in dBm
9722 +} PACKED country_subelement_t, *country_subelement_p;
9724 +typedef struct country_string { // (all alpha)
9725 + UCHAR co[2]; // ISO/IEC 3166-1 country code
9726 + UCHAR env; // ' '/'O'/'I' - 802.11d pp. 19
9727 +} PACKED country_string_t, *country_string_p;
9729 +typedef struct country_ie {
9732 + country_string_t cs;
9733 + country_subelement_t chans[1];
9734 + UCHAR pad[0]; // may or may not be present
9735 +} PACKED country_ie_t, *country_ie_p;
9738 +/* WPA2 (cf. 802.11i pp. 27 ff.) */
9741 +#define wtohs(x) (le16_to_cpu(x))// sic (802.11 is "native" little-endian)
9742 +#define htows(x) (cpu_to_le16(x))// i.e. opposite of internet byte order
9745 +typedef USHORT ie_version_t;
9746 +typedef USHORT ie_count_t;
9747 +typedef UCHAR ie_oui_t[3]; // Organizationally Unique Identifier
9748 +typedef UCHAR pmkid_t[16], *pmkid_p;// 802.11i pp. 76
9750 +typedef struct rsncap {
9752 + USHORT Reserved:10;
9753 + USHORT GTKSAReplayCounter:2; // 0/2/4/16 replay counters
9754 + USHORT PTKSAReplayCounter:2;
9755 + USHORT NoPairwise:1; // WEP key 0 and pairwise key n/a
9756 + USHORT PreAuth:1; // AP STA supports pre-authentication
9758 + USHORT PreAuth:1; // AP STA supports pre-authentication
9759 + USHORT NoPairwise:1; // WEP key 0 and pairwise key n/a
9760 + USHORT PTKSAReplayCounter:2;
9761 + USHORT GTKSAReplayCounter:2; // 0/2/4/16 replay counters
9762 + USHORT Reserved:10;
9764 +} PACKED rsncap_t, *rsncap_p;
9766 +typedef struct suite_sel {
9769 +} PACKED suite_sel_t, *suite_sel_p;
9771 +/* Cipher suite selectors - 802.11i pp. 28, 29 */
9772 +#define CIPHER_TYPE_GRP 0
9773 +#define CIPHER_TYPE_WEP40 1
9774 +#define CIPHER_TYPE_TKIP 2
9775 +#define CIPHER_TYPE_RES 3
9776 +#define CIPHER_TYPE_CCMP 4
9777 +#define CIPHER_TYPE_WEP104 5
9778 +#define NUM_CIPHER_TYPES 6
9780 +/* Authentication and Key Management suite selectors - 802.11i pp. 30 */
9781 +#define AKM_TYPE_802_1X 1
9782 +#define AKM_TYPE_PSK 2
9784 +typedef struct suite_list {
9786 + suite_sel_t suite[1];
9787 +} PACKED suite_list_t, *suite_list_p;
9789 +typedef struct pmkid_list {
9792 +} PACKED pmkid_list_t, *pmkid_list_p;
9794 +typedef struct rsn_ie {
9797 + ie_version_t version;
9799 + // Optional fields
9800 + suite_sel_t gcsuite; // Group Cipher Suite
9801 +} PACKED rsn_ie_t, *rsn_ie_p;
9802 +#define MIN_RSN_KEYDATA_LEN (sizeof(ie_version_t) + sizeof(suite_sel_t) + \
9803 + 2*sizeof(suite_list_t))
9805 extern UCHAR RateIdToMbps[];
9806 extern USHORT RateIdTo500Kbps[];
9807 diff -Nur rt2500-1.1.0-b4/Module/oid.h rt2500-cvs-2007061011/Module/oid.h
9808 --- rt2500-1.1.0-b4/Module/oid.h 2006-06-17 22:12:58.000000000 +0200
9809 +++ rt2500-cvs-2007061011/Module/oid.h 2007-03-21 05:25:34.000000000 +0100
9811 -/***************************************************************************
9812 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
9814 - * This program is free software; you can redistribute it and/or modify *
9815 - * it under the terms of the GNU General Public License as published by *
9816 - * the Free Software Foundation; either version 2 of the License, or *
9817 - * (at your option) any later version. *
9819 - * This program is distributed in the hope that it will be useful, *
9820 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9821 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
9822 - * GNU General Public License for more details. *
9824 - * You should have received a copy of the GNU General Public License *
9825 - * along with this program; if not, write to the *
9826 - * Free Software Foundation, Inc., *
9827 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
9829 - * Licensed under the GNU GPL *
9830 - * Original code supplied under license from RaLink Inc, 2004. *
9831 - ***************************************************************************/
9832 +/***************************************************************************
9833 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
9835 + * This program is free software; you can redistribute it and/or modify *
9836 + * it under the terms of the GNU General Public License as published by *
9837 + * the Free Software Foundation; either version 2 of the License, or *
9838 + * (at your option) any later version. *
9840 + * This program is distributed in the hope that it will be useful, *
9841 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9842 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
9843 + * GNU General Public License for more details. *
9845 + * You should have received a copy of the GNU General Public License *
9846 + * along with this program; if not, write to the *
9847 + * Free Software Foundation, Inc., *
9848 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
9850 + * Licensed under the GNU GPL *
9851 + * Original code supplied under license from RaLink Inc, 2004. *
9852 + ***************************************************************************/
9854 - /***************************************************************************
9855 + /***************************************************************************
9856 * Module Name: oid.h
9860 - * Revision History:
9862 - * -------- ----------- -----------------------------
9863 - * MarkW 8th Dec 04 Baseline code
9864 - * RobinC 10th Dec 04 RFMON Support
9865 - ***************************************************************************/
9869 + * Revision History:
9871 + * -------- ----------- -----------------------------
9872 + * MarkW 8th Dec 04 Baseline code
9873 + * RobinC 10th Dec 04 RFMON Support
9874 + * RomainB 31st Dec 06 RFMON getter
9875 + ***************************************************************************/
9880 #define RTPRIV_IOCTL_BBP SIOCIWFIRSTPRIV + 0x03
9881 #define RTPRIV_IOCTL_MAC SIOCIWFIRSTPRIV + 0x05
9882 #define RTPRIV_IOCTL_E2P SIOCIWFIRSTPRIV + 0x07
9883 -#define RTPRIV_IOCTL_RFMONTX SIOCIWFIRSTPRIV + 0x0D
9884 +#define RTPRIV_IOCTL_SET_RFMONTX SIOCIWFIRSTPRIV + 0x0C
9885 +#define RTPRIV_IOCTL_GET_RFMONTX SIOCIWFIRSTPRIV + 0x0D
9887 #define OID_GET_SET_TOGGLE 0x8000
9890 // Added new types for OFDM 5G and 2.4G
9891 typedef enum _NDIS_802_11_NETWORK_TYPE
9899 Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
9901 typedef struct _NDIS_802_11_CONFIGURATION_FH
9903 ULONG Length; // Length of structure
9904 - ULONG HopPattern; // As defined by 802.11, MSB set
9905 + ULONG HopPattern; // As defined by 802.11, MSB set
9906 ULONG HopSet; // to one if non-802.11
9907 ULONG DwellTime; // units are Kusec
9908 } NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
9910 typedef struct _NDIS_802_11_KEY
9912 ULONG Length; // Length of this structure
9915 ULONG KeyLength; // length of key in bytes
9916 NDIS_802_11_MAC_ADDRESS BSSID;
9917 NDIS_802_11_KEY_RSC KeyRSC;
9919 typedef struct _NDIS_802_11_REMOVE_KEY
9921 ULONG Length; // Length of this structure
9923 - NDIS_802_11_MAC_ADDRESS BSSID;
9925 + NDIS_802_11_MAC_ADDRESS BSSID;
9926 } NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
9928 typedef struct PACKED _NDIS_802_11_WEP
9930 typedef UCHAR NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; // Set of 8 data rates
9931 typedef UCHAR NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; // Set of 16 data rates
9933 -typedef struct PACKED _NDIS_802_11_SSID
9934 +typedef struct PACKED _NDIS_802_11_SSID
9936 ULONG SsidLength; // length of SSID field below, in bytes;
9937 // this can be zero.
9938 @@ -338,14 +340,14 @@
9939 NDIS_WLAN_BSSID_EX Bssid[1];
9940 } NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
9942 -typedef struct _NDIS_802_11_FIXED_IEs
9943 +typedef struct _NDIS_802_11_FIXED_IEs
9946 USHORT BeaconInterval;
9947 USHORT Capabilities;
9948 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
9950 -typedef struct _NDIS_802_11_VARIABLE_IEs
9951 +typedef struct _NDIS_802_11_VARIABLE_IEs
9954 UCHAR Length; // Number of bytes in data field
9956 NDIS_802_11_STATUS_INDICATION Status;
9957 NDIS_802_11_AUTHENTICATION_REQUEST Request[1];
9958 } NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
9961 typedef struct _NDIS_802_11_TEST
9964 diff -Nur rt2500-1.1.0-b4/Module/rt2560.h rt2500-cvs-2007061011/Module/rt2560.h
9965 --- rt2500-1.1.0-b4/Module/rt2560.h 2006-06-17 22:12:58.000000000 +0200
9966 +++ rt2500-cvs-2007061011/Module/rt2560.h 2007-03-21 05:25:34.000000000 +0100
9968 -/***************************************************************************
9969 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
9971 - * This program is free software; you can redistribute it and/or modify *
9972 - * it under the terms of the GNU General Public License as published by *
9973 - * the Free Software Foundation; either version 2 of the License, or *
9974 - * (at your option) any later version. *
9976 - * This program is distributed in the hope that it will be useful, *
9977 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9978 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
9979 - * GNU General Public License for more details. *
9981 - * You should have received a copy of the GNU General Public License *
9982 - * along with this program; if not, write to the *
9983 - * Free Software Foundation, Inc., *
9984 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
9986 - * Licensed under the GNU GPL *
9987 - * Original code supplied under license from RaLink Inc, 2004. *
9988 - ***************************************************************************/
9989 +/***************************************************************************
9990 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
9992 + * This program is free software; you can redistribute it and/or modify *
9993 + * it under the terms of the GNU General Public License as published by *
9994 + * the Free Software Foundation; either version 2 of the License, or *
9995 + * (at your option) any later version. *
9997 + * This program is distributed in the hope that it will be useful, *
9998 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9999 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10000 + * GNU General Public License for more details. *
10002 + * You should have received a copy of the GNU General Public License *
10003 + * along with this program; if not, write to the *
10004 + * Free Software Foundation, Inc., *
10005 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
10007 + * Licensed under the GNU GPL *
10008 + * Original code supplied under license from RaLink Inc, 2004. *
10009 + ***************************************************************************/
10011 - /***************************************************************************
10012 + /***************************************************************************
10013 * Module Name: rt2560.h
10016 * Abstract: RT2560 ASIC related definition & structures
10018 - * Revision History:
10020 - * -------- ----------- -----------------------------
10021 - * MarkW 8th Dec 04 Baseline code
10022 - * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
10023 - ***************************************************************************/
10025 + * Revision History:
10027 + * -------- ----------- -----------------------------
10028 + * MarkW 8th Dec 04 Baseline code
10029 + * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
10030 + ***************************************************************************/
10032 #ifndef __RT2560_H__
10033 #define __RT2560_H__
10034 @@ -370,10 +370,10 @@
10044 // Word 10 - 11 Reserved, not necessary to put into the structure.
10047 @@ -676,7 +676,7 @@
10051 -} CSR11_STRUC, *PCSR11_STRUC;
10052 +} CSR11_STRUC, *PCSR11_STRUC;
10055 // CSR12: Synchronization configuration register 0
10056 @@ -869,7 +869,7 @@
10057 // =================================================================================
10060 -// TXCSR0 <0x0060> : TX Control Register
10061 +// TXCSR0 <0x0060> : TX Control Register
10063 typedef union _TXCSR0_STRUC {
10065 @@ -880,13 +880,13 @@
10066 ULONG KickAtim:1; // Kick ATIM ring
10067 ULONG KickTx:1; // Kick Tx ring
10069 - ULONG KickTx:1; // Kick Tx ring
10070 + ULONG KickTx:1; // Kick Tx ring
10071 ULONG KickAtim:1; // Kick ATIM ring
10072 ULONG KickPrio:1; // Kick priority ring
10073 ULONG Abort:1; // Abort all transmit related ring operation
10079 } TXCSR0_STRUC, *PTXCSR0_STRUC;
10081 @@ -1184,7 +1184,7 @@
10082 ULONG BbpDesireState:2;
10085 - ULONG SetState:1;
10086 + ULONG SetState:1;
10087 ULONG BbpDesireState:2;
10088 ULONG RfDesireState:2;
10089 ULONG BbpCurrState:2;
10090 @@ -1304,13 +1304,13 @@
10093 ULONG WriteControl:1; // 1: Write BBP, 0: Read BBP
10094 - ULONG Busy:1; // 1: ASIC is busy execute BBP programming.
10095 + ULONG Busy:1; // 1: ASIC is busy execute BBP programming.
10096 ULONG RegNum:7; // Selected BBP register
10097 ULONG Value:8; // Register value to program into BBP
10099 ULONG Value:8; // Register value to program into BBP
10100 ULONG RegNum:7; // Selected BBP register
10101 - ULONG Busy:1; // 1: ASIC is busy execute BBP programming.
10102 + ULONG Busy:1; // 1: ASIC is busy execute BBP programming.
10103 ULONG WriteControl:1; // 1: Write BBP, 0: Read BBP
10106 diff -Nur rt2500-1.1.0-b4/Module/rt2x00debug.h rt2500-cvs-2007061011/Module/rt2x00debug.h
10107 --- rt2500-1.1.0-b4/Module/rt2x00debug.h 1970-01-01 01:00:00.000000000 +0100
10108 +++ rt2500-cvs-2007061011/Module/rt2x00debug.h 2007-02-20 20:02:18.000000000 +0100
10111 + Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
10112 + <http://rt2x00.serialmonkey.com>
10114 + This program is free software; you can redistribute it and/or modify
10115 + it under the terms of the GNU General Public License as published by
10116 + the Free Software Foundation; either version 2 of the License, or
10117 + (at your option) any later version.
10119 + This program is distributed in the hope that it will be useful,
10120 + but WITHOUT ANY WARRANTY; without even the implied warranty of
10121 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10122 + GNU General Public License for more details.
10124 + You should have received a copy of the GNU General Public License
10125 + along with this program; if not, write to the
10126 + Free Software Foundation, Inc.,
10127 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
10131 + Module: rt2x00debug
10132 + Abstract: Data structures for the rt2x00debug module.
10133 + Supported chipsets: RT2460, RT2560, RT2570,
10134 + rt2561, rt2561s, rt2661 & rt2573.
10137 +typedef void (debug_access_t)(void *dev, const unsigned long word, void *data);
10139 +struct rt2x00debug_reg {
10140 + debug_access_t *read;
10141 + debug_access_t *write;
10143 + unsigned int word_size;
10144 + unsigned int length;
10147 +struct rt2x00debug {
10149 + * Name of the interface.
10151 + char intf_name[16];
10154 + * Reference to the modules structure.
10156 + struct module *owner;
10159 + * Driver module information
10162 + char *mod_version;
10165 + * Register access information.
10167 + struct rt2x00debug_reg reg_csr;
10168 + struct rt2x00debug_reg reg_eeprom;
10169 + struct rt2x00debug_reg reg_bbp;
10172 + * Pointer to driver structure where
10173 + * this debugfs entry belongs to.
10178 + * Pointer to rt2x00debug private data,
10179 + * individual driver should not touch this.
10184 +extern int rt2x00debug_register(struct rt2x00debug *debug);
10185 +extern void rt2x00debug_deregister(struct rt2x00debug *debug);
10186 diff -Nur rt2500-1.1.0-b4/Module/rt_config.h rt2500-cvs-2007061011/Module/rt_config.h
10187 --- rt2500-1.1.0-b4/Module/rt_config.h 2006-06-17 22:12:58.000000000 +0200
10188 +++ rt2500-cvs-2007061011/Module/rt_config.h 2007-06-10 18:35:24.000000000 +0200
10190 -/***************************************************************************
10191 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
10193 - * This program is free software; you can redistribute it and/or modify *
10194 - * it under the terms of the GNU General Public License as published by *
10195 - * the Free Software Foundation; either version 2 of the License, or *
10196 - * (at your option) any later version. *
10198 - * This program is distributed in the hope that it will be useful, *
10199 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10200 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10201 - * GNU General Public License for more details. *
10203 - * You should have received a copy of the GNU General Public License *
10204 - * along with this program; if not, write to the *
10205 - * Free Software Foundation, Inc., *
10206 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
10208 - * Licensed under the GNU GPL *
10209 - * Original code supplied under license from RaLink Inc, 2004. *
10210 - ***************************************************************************/
10211 +/***************************************************************************
10212 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
10214 + * This program is free software; you can redistribute it and/or modify *
10215 + * it under the terms of the GNU General Public License as published by *
10216 + * the Free Software Foundation; either version 2 of the License, or *
10217 + * (at your option) any later version. *
10219 + * This program is distributed in the hope that it will be useful, *
10220 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10221 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10222 + * GNU General Public License for more details. *
10224 + * You should have received a copy of the GNU General Public License *
10225 + * along with this program; if not, write to the *
10226 + * Free Software Foundation, Inc., *
10227 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
10229 + * Licensed under the GNU GPL *
10230 + * Original code supplied under license from RaLink Inc, 2004. *
10231 + ***************************************************************************/
10233 - /***************************************************************************
10234 + /***************************************************************************
10235 * Module Name: rt_config.h
10238 * Abstract: Central header file for all includes
10240 - * Revision History:
10242 - * -------- ----------- -----------------------------
10243 - * RoryC 21st Dec 02 Initial code
10244 - * MarkW 8th Dec 04 Baseline code
10245 - ***************************************************************************/
10247 + * Revision History:
10249 + * -------- ----------- -----------------------------
10250 + * RoryC 21st Dec 02 Initial code
10251 + * MarkW 8th Dec 04 Baseline code
10252 + ***************************************************************************/
10254 #ifndef __RT_CONFIG_H__
10255 #define __RT_CONFIG_H__
10256 @@ -39,14 +39,14 @@
10257 #define NIC_DEVICE_NAME "RT2500STA"
10259 #define DRV_NAME "rt2500"
10260 -#define DRV_VERSION "1.1.0 BETA4"
10261 -#define DRV_RELDATE "2006/06/18"
10262 +#define DRV_VERSION "1.1.0 CVS"
10263 +#define DRV_RELDATE "2007061011"
10264 #define DRV_VERSION_MAJOR 1
10265 -#define DRV_VERSION_MINOR 1
10266 +#define DRV_VERSION_MINOR 1
10267 #define DRV_VERSION_SUB 0
10268 -#define DRV_BUILD_YEAR 2006
10269 -#define DRV_BUILD_MONTH 06
10270 -#define DRV_BUILD_DAY 18
10271 +#define DRV_BUILD_YEAR 2007
10272 +#define DRV_BUILD_MONTH 05
10273 +#define DRV_BUILD_DAY 13
10275 /* Operational parameters that are set at compile time. */
10276 #if !defined(__OPTIMIZE__) || !defined(__KERNEL__)
10278 #error You must compile this driver with "-O".
10281 -#include <linux/config.h> //can delete
10282 #include <linux/module.h>
10283 #include <linux/version.h>
10284 #include <linux/kernel.h>
10286 #include <linux/skbuff.h>
10287 #include <linux/init.h> //can delete
10288 #include <linux/delay.h> // can delete
10289 -#include <linux/ethtool.h>
10290 #include <linux/wireless.h>
10291 #include <linux/proc_fs.h>
10292 #include <linux/delay.h>
10295 // The type definition has to be placed before including rt2460.h
10298 +#define CHAR signed char
10301 +#define SHORT short
10305 @@ -144,6 +142,7 @@
10306 #include "rtmp_type.h"
10307 #include "rtmp_def.h"
10308 #include "rt2560.h"
10309 +#include "rt2x00debug.h"
10313 @@ -156,7 +155,7 @@
10317 -#ifdef RTMP_EMBEDDED
10318 +#if 1 //#ifdef RTMP_EMBEDDED
10320 #define GFP_KERNEL (GFP_DMA | GFP_ATOMIC)
10322 diff -Nur rt2500-1.1.0-b4/Module/rtmp.h rt2500-cvs-2007061011/Module/rtmp.h
10323 --- rt2500-1.1.0-b4/Module/rtmp.h 2006-06-17 22:12:58.000000000 +0200
10324 +++ rt2500-cvs-2007061011/Module/rtmp.h 2007-06-08 20:09:53.000000000 +0200
10326 -/***************************************************************************
10327 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
10329 - * This program is free software; you can redistribute it and/or modify *
10330 - * it under the terms of the GNU General Public License as published by *
10331 - * the Free Software Foundation; either version 2 of the License, or *
10332 - * (at your option) any later version. *
10334 - * This program is distributed in the hope that it will be useful, *
10335 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10336 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10337 - * GNU General Public License for more details. *
10339 - * You should have received a copy of the GNU General Public License *
10340 - * along with this program; if not, write to the *
10341 - * Free Software Foundation, Inc., *
10342 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
10344 - * Licensed under the GNU GPL *
10345 - * Original code supplied under license from RaLink Inc, 2004. *
10346 - ***************************************************************************/
10347 +/***************************************************************************
10348 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
10350 + * This program is free software; you can redistribute it and/or modify *
10351 + * it under the terms of the GNU General Public License as published by *
10352 + * the Free Software Foundation; either version 2 of the License, or *
10353 + * (at your option) any later version. *
10355 + * This program is distributed in the hope that it will be useful, *
10356 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10357 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10358 + * GNU General Public License for more details. *
10360 + * You should have received a copy of the GNU General Public License *
10361 + * along with this program; if not, write to the *
10362 + * Free Software Foundation, Inc., *
10363 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
10365 + * Licensed under the GNU GPL *
10366 + * Original code supplied under license from RaLink Inc, 2004. *
10367 + ***************************************************************************/
10369 - /***************************************************************************
10370 + /***************************************************************************
10371 * Module Name: rt_config.h
10374 * Abstract: Central header file for all includes
10376 - * Revision History:
10378 - * -------- ----------- -----------------------------
10379 - * RoryC 21st Dec 02 Initial code
10380 - * MarkW 8th Dec 04 Baseline code
10382 + * Revision History:
10384 + * -------- ----------- -----------------------------
10385 + * RoryC 21st Dec 02 Initial code
10386 + * MarkW 8th Dec 04 Baseline code
10387 * MarkW (rt2400) 8th Dec 04 Promisc mode support
10388 * Flavio (rt2400) 8th Dec 04 Elegant irqreturn_t handling
10389 * RobinC 10th Dec 04 RFMON Support
10390 - * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
10391 - * MarkW (rt2400) 15th Dec 04 Spinlock fix
10392 + * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
10393 + * MarkW (rt2400) 15th Dec 04 Spinlock fix
10394 * Ivo (rt2400) 15th Dec 04 Debug level switching
10395 * GregorG 29th Mar 05 Big endian fixes
10396 - ***************************************************************************/
10397 + * RomainB 31st Dec 06 RFMON getter
10398 + ***************************************************************************/
10403 #endif /*(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) */
10404 #endif /* pci_name */
10406 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
10407 +#define pci_module_init pci_register_driver
10410 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
10411 +#define skb_reset_mac_header(skb) (skb->mac.raw = skb->data)
10414 // Krellan: Limit range of user TxPower settings from -31 to +0 dBm.
10415 // We could accept -31 to +31 dBm, relative to 0 dBm which is defined
10416 @@ -87,21 +95,40 @@
10418 // MACRO for debugging information
10422 -#define DBGPRINT(Level, fmt, args...) \
10423 - if(debug){printk(Level DRV_NAME ": " fmt, ## args);}
10424 +extern VOID rt2500_setdbg(long);
10425 +extern INT rt2500_dbgprint(int, const char *, ...);
10426 +#define DBGPRINT(mask, fmt, args...) \
10427 + (rt2500_dbgprint(mask, KERN_DEBUG DRV_NAME ": " fmt, ## args))
10429 +/* Do not enclose in parentheses ()! */
10430 +#define DBGENTER DBGPRINT(RT_DEBUG_TRACE, "==> %s\n", __FUNCTION__)
10431 +#define DBGRETURN DBGPRINT(RT_DEBUG_TRACE, "<== %s\n", __FUNCTION__)
10433 +#define DBGHEXSTR(level, prefix, src, len) \
10435 + char buf[128]; /* allows 64 bytes/512 bits */ \
10437 + unsigned char *p; \
10440 + j = len < sizeof(buf)/2? len: sizeof(buf)/2 - 1; \
10442 + for (p = (unsigned char *)(src), i = 0; i < j; i++) { \
10443 + sprintf(&buf[i*2], "%02x", *p++); \
10445 + DBGPRINT(level, prefix "%s\n", buf); \
10451 #define DBGPRINT(Level, fmt, args...) \
10453 +#define DBGHEXSTR(level, prefix, src, len) \
10458 -// spin_lock enhanced for Nested spin lock
10461 -extern unsigned long IrqFlags;
10463 // Assert MACRO to make sure program running
10466 @@ -145,12 +172,12 @@
10467 // ULONG Register_Offset,
10470 -#ifdef RTMP_EMBEDDED
10471 +#if 0 //#ifdef RTMP_EMBEDDED
10472 #define RTMP_IO_READ32(_A, _R, _pV) (*_pV = PCIMemRead32(__mem_pci(_A->CSRBaseAddress+_R)))
10473 #define RTMP_IO_WRITE32(_A, _R, _V) (PCIMemWrite32(__mem_pci(_A->CSRBaseAddress+_R),_V))
10475 -#define RTMP_IO_READ32(_A, _R, _pV) (*_pV = readl( (void*) (_A->CSRBaseAddress + _R) ) )
10476 -#define RTMP_IO_WRITE32(_A, _R, _V) (writel(_V, (void*) (_A->CSRBaseAddress + _R) ) )
10477 +#define RTMP_IO_READ32(_A, _R, _pV) (*_pV = readl((void*)(_A->CSRBaseAddress + _R) ) )
10478 +#define RTMP_IO_WRITE32(_A, _R, _V) (writel(_V, (void*)(_A->CSRBaseAddress + _R) ) )
10482 @@ -363,7 +390,7 @@
10483 ULONG RxRingErrCount;
10484 ULONG EncryptCount;
10486 - ULONG TxRingErrCount;
10487 + ULONG TxRingErrCount;
10488 LARGE_INTEGER RealFcsErrCount;
10489 } COUNTER_RALINK, *PCOUNTER_RALINK;
10491 @@ -400,10 +427,10 @@
10492 typedef struct _WPA_KEY {
10493 UCHAR KeyLen; // Key length for each key, 0: entry is invalid
10494 UCHAR Key[16]; // right now we implement 4 keys, 128 bits max
10497 + UCHAR RxMic[8]; // Message Integrity Code
10498 + UCHAR TxMic[8]; // MIC
10499 NDIS_802_11_MAC_ADDRESS BssId; // For pairwise key only
10500 - UCHAR TxTsc[6]; // 48bit TSC value
10501 + UCHAR TxTsc[6]; // 48bit TKIP Sequence Counter value
10502 UCHAR RxTsc[6]; // 48bit TSC value
10503 UCHAR Type; // Indicate Pairwise / Group
10504 } WPA_KEY, *PWPA_KEY;
10505 @@ -413,7 +440,7 @@
10514 @@ -436,38 +463,36 @@
10525 } TKIP_IV, *PTKIP_IV;
10528 -typedef struct _IV_CONTROL_
10529 +typedef struct PACKED _IV_CONTROL_
10572 } TKIP_IV, *PTKIP_IV;
10573 @@ -499,7 +524,7 @@
10575 typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
10576 BOOLEAN PrimaryInUsed;
10577 - BOOLEAN FirstPktArrivedWhenEvaluate;
10578 + BOOLEAN FirstPktArrivedWhenEvaluate;
10579 UCHAR PrimaryRxAnt; // 0:Ant-A, 1:Ant-B
10580 UCHAR SecondaryRxAnt; // 0:Ant-A, 1:Ant-B
10581 UCHAR CurrentRxAnt; // 0:Ant-A, 1:Ant-B
10582 @@ -535,7 +560,7 @@
10584 NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
10585 NDIS_802_11_WEP_STATUS WepStatus;
10588 // MIB:ieee802dot11.dot11smt(1).dot11WEPDefaultKeysTable(3)
10589 WEP_KEY SharedKey[SHARE_KEY_NO]; // Keep for backward compatiable
10590 WPA_KEY PairwiseKey[PAIRWISE_KEY_NO];
10591 @@ -566,8 +591,8 @@
10592 // MIB:ieee802dot11.dot11mac(2).dot11OperationTable(1)
10593 USHORT RtsThreshold; // in units of BYTE
10594 USHORT FragmentThreshold;
10595 - BOOLEAN bFragmentZeroDisable; // Microsoft use 0 as disable
10597 + BOOLEAN bFragmentZeroDisable; // Microsoft use 0 as disable
10599 // MIB:ieee802dot11.dot11phy(4).dot11PhyAntennaTable(2)
10600 UCHAR CurrentTxAntenna;
10601 UCHAR CurrentRxAntenna;
10602 @@ -582,19 +607,19 @@
10603 UCHAR TxPowerDriver; // Driver's last TxPower setting written to hardware, in raw units
10604 int TxPowerUser; // User's desired fixed TxPower setting, in dBm
10605 BOOLEAN TxPowerAuto; // 1 - enable auto TxPower; 0 - fixed
10608 // MIB:ieee802dot11.dot11phy(4).dot11PhyDSSSTable(5)
10609 UCHAR Channel; // current (I)BSS channel used in the station
10610 UCHAR CountryRegion; // Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel
10613 // MIB:ieee802dot11.dot11phy(4).dot11AntennasListTable(8)
10614 BOOLEAN AntennaSupportTx;
10615 BOOLEAN AntennaSupportRx;
10616 BOOLEAN AntennaSupportDiversityRx;
10618 // Use user changed MAC
10619 - BOOLEAN bLocalAdminMAC;
10621 + BOOLEAN bLocalAdminMAC;
10623 // MIB:ieee802dot11.dot11phy(4).dot11SupportedDataRatesTxTable(9)
10624 // MIB:ieee802dot11.dot11phy(4).dot11SupportedDataRatesRxTable(10)
10625 UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES]; // Supported rates
10626 @@ -661,7 +686,7 @@
10627 UCHAR ChannelList[MAX_LEN_OF_CHANNELS]; // list all supported channels for site survey
10628 UCHAR ChannelListNum; // number of channel in ChannelList[]
10629 BOOLEAN bShowHiddenSSID;
10632 // configuration to be used when this STA starts a new ADHOC network
10633 IBSS_CONFIG IbssConfig;
10635 @@ -679,7 +704,7 @@
10637 RALINK_TIMER_STRUCT RfTuningTimer;
10638 STA_WITH_ETHER_BRIDGE StaWithEtherBridge;
10641 // New for WPA, windows want us to to keep association information and
10642 // Fixed IEs from last association response
10643 NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
10644 @@ -700,7 +725,7 @@
10645 ULONG BGProtectionInUsed; // 0: not in-used, 1: in-used
10646 ULONG ShortSlotInUsed; // 0: not in-used, 1: in-used
10647 USHORT TxPreambleInUsed; // Rt802_11PreambleLong, Rt802_11PreambleShort
10650 // PCI clock adjustment round
10651 UCHAR PciAdjustmentRound;
10653 @@ -718,8 +743,8 @@
10656 ULONG SystemErrorBitmap; // b0: E2PROM version error
10658 - // This soft Rx Antenna Diversity mechanism is used only when user set
10660 + // This soft Rx Antenna Diversity mechanism is used only when user set
10661 // RX Antenna = DIVERSITY ON
10662 SOFT_RX_ANT_DIVERSITY RxAnt;
10664 @@ -753,13 +778,13 @@
10665 STATE_MACHINE_FUNC CntlFunc[CNTL_FUNC_SIZE], AssocFunc[ASSOC_FUNC_SIZE];
10666 STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE], AuthRspFunc[AUTH_RSP_FUNC_SIZE];
10667 STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE], WpaPskFunc[WPA_PSK_FUNC_SIZE];
10670 ASSOC_AUX AssocAux;
10672 AUTH_RSP_AUX AuthRspAux;
10677 COUNTER_802_11 PrevWlanCounters;
10678 ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
10680 @@ -770,7 +795,7 @@
10686 RALINK_TIMER_STRUCT PeriodicTimer;
10687 ULONG PeriodicRound;
10689 @@ -849,7 +874,7 @@
10690 typedef struct PACKED _TUPLE_CACHE {
10696 } TUPLE_CACHE, *PTUPLE_CACHE;
10698 @@ -872,7 +897,7 @@
10699 typedef struct PACKED _TKIP_KEY_INFO {
10700 UINT nBytesInM; // # bytes in M for MICKEY
10704 ULONG K0; // for MICKEY Low
10705 ULONG K1; // for MICKEY Hig
10706 ULONG L; // Current state for MICKEY
10707 @@ -937,12 +962,14 @@
10709 typedef struct _RTMP_ADAPTER
10711 - char nickn[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
10712 + char nickn[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
10715 unsigned long CSRBaseAddress; // PCI MMIO Base Address, all access will use
10716 // NdisReadRegisterXx or NdisWriteRegisterXx
10718 + struct rt2x00debug debug;
10721 UCHAR PermanentAddress[ETH_ALEN]; // Factory default MAC address
10722 UCHAR CurrentAddress[ETH_ALEN]; // User changed MAC address
10723 @@ -958,7 +985,7 @@
10724 struct ring_desc BeaconRing; // Beacon Ring, only one
10726 MGMT_STRUC MgmtRing[MGMT_RING_SIZE]; // management ring size
10729 ULONG CurRxIndex; // Next RxD read pointer
10730 ULONG CurDecryptIndex; // Next RxD decrypt read pointer
10731 ULONG CurTxIndex; // Next TxD write pointer
10732 @@ -985,17 +1012,17 @@
10733 struct sk_buff_head TxSwQueue0; // Tx software priority queue 0 mapped to 0.1
10734 struct sk_buff_head TxSwQueue1; // Tx software priority queue 1 mapped to 2.3
10735 struct sk_buff_head TxSwQueue2; // Tx software priority queue 2 mapped to 4.5
10736 - struct sk_buff_head TxSwQueue3;
10737 + struct sk_buff_head TxSwQueue3;
10739 USHORT Sequence; // Current sequence number
10741 TUPLE_CACHE TupleCache[MAX_CLIENT]; // Maximum number of tuple caches, only useful in Ad-Hoc
10742 UCHAR TupleCacheLastUpdateIndex; // 0..MAX_CLIENT-1
10743 FRAGMENT_FRAME FragFrame; // Frame storage for fragment frame
10746 // For MiniportTransferData
10747 PUCHAR pRxData; // Pointer to current RxRing offset / fragment frame offset
10750 // Counters for 802.3 & generic.
10751 // Add 802.11 specific counters later
10752 COUNTER_802_3 Counters; // 802.3 counters
10753 @@ -1021,11 +1048,11 @@
10754 BOOLEAN bAcceptBroadcast;
10755 BOOLEAN bAcceptAllMulticast;
10756 BOOLEAN bAcceptPromiscuous;
10759 // Control to check Tx hang
10761 //PQUEUE_ENTRY FirstEntryInQueue; // The first packet in Tx queue
10764 // Control disconnect / connect event generation
10765 ULONG LinkDownTime;
10767 @@ -1044,7 +1071,7 @@
10769 BOOLEAN bNetDeviceStopQueue;
10770 BOOLEAN NeedSwapToLittleEndian;
10773 #if WIRELESS_EXT >= 12
10774 struct iw_statistics iw_stats;
10776 @@ -1054,9 +1081,6 @@
10778 #endif //#ifdef RALINK_ATE
10780 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
10781 - struct work_struct mlme_work;
10783 } RTMP_ADAPTER, *PRTMP_ADAPTER;
10786 @@ -1064,10 +1088,9 @@
10788 typedef struct _SHA_CTX
10793 - ULONG sizeHi, sizeLo;
10794 + ULONG Buf[5]; // buffers of five states
10795 + UCHAR Input[80]; // input message
10796 + ULONG LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
10800 @@ -1085,7 +1108,7 @@
10801 IN PRTMP_ADAPTER pAd)
10803 // 0xFF37 : Txdone & Rxdone, 0xFF07: Txdonw, Rxdone, PrioDone, AtimDone,
10804 - RTMP_IO_WRITE32(pAd, CSR8, 0xFE14);
10805 + RTMP_IO_WRITE32(pAd, CSR8, 0xFE14);
10806 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
10809 @@ -1096,10 +1119,16 @@
10811 IN struct net_device *net_dev);
10813 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
10814 irqreturn_t RTMPIsr(
10816 - IN VOID *dev_instance,
10818 + IN VOID *dev_instance,
10819 IN struct pt_regs *rgs);
10821 +irqreturn_t RTMPIsr(
10823 + IN VOID *dev_instance);
10827 IN unsigned long data);
10828 @@ -1108,16 +1137,16 @@
10829 IN struct net_device *net_dev);
10831 INT RTMPSendPackets(
10832 - IN struct sk_buff *skb,
10833 + IN struct sk_buff *skb,
10834 IN struct net_device *net_dev);
10837 - IN struct pci_dev *pPci_Dev,
10838 + IN struct pci_dev *pPci_Dev,
10839 IN const struct pci_device_id *ent);
10842 - IN struct net_device *net_dev,
10843 - IN OUT struct ifreq *rq,
10844 + IN struct net_device *net_dev,
10845 + IN OUT struct ifreq *rq,
10848 VOID RTMPRingCleanUp(
10849 @@ -1179,7 +1208,7 @@
10850 INT RTMPGetKeyParameter(
10858 @@ -1187,7 +1216,7 @@
10859 IN PRTMP_ADAPTER pAd);
10861 #define RTMPEqualMemory(p1,p2,n) (memcmp((p1),(p2),(n)) == 0)
10864 ULONG RTMPCompareMemory(
10867 @@ -1244,7 +1273,7 @@
10868 NDIS_STATUS RTMPSendPacket(
10869 IN PRTMP_ADAPTER pAdapter,
10870 IN struct sk_buff *skb);
10873 //VOID RTMPDeQueuePacket(
10874 // IN PRTMP_ADAPTER pAdapter,
10875 // IN PQUEUE_HEADER pQueue);
10876 @@ -1320,8 +1349,8 @@
10879 NDIS_STATUS RTMPApplyPacketFilter(
10880 - IN PRTMP_ADAPTER pAdapter,
10881 - IN PRXD_STRUC pRxD,
10882 + IN PRTMP_ADAPTER pAdapter,
10883 + IN PRXD_STRUC pRxD,
10884 IN PHEADER_802_11 pHeader);
10886 struct sk_buff_head* RTMPCheckTxSwQueue(
10887 @@ -1329,20 +1358,20 @@
10888 OUT UCHAR *AccessCategory);
10890 VOID RTMPReportMicError(
10891 - IN PRTMP_ADAPTER pAdapter,
10892 + IN PRTMP_ADAPTER pAdapter,
10893 IN PWPA_KEY pWpaKey);
10895 // Private routines in rtmp_wep.c
10897 VOID RTMPInitWepEngine(
10898 - IN PRTMP_ADAPTER pAdapter,
10899 + IN PRTMP_ADAPTER pAdapter,
10906 VOID RTMPEncryptData(
10907 - IN PRTMP_ADAPTER pAdapter,
10908 + IN PRTMP_ADAPTER pAdapter,
10912 @@ -1366,7 +1395,7 @@
10914 VOID ARCFOUR_DECRYPT(
10915 IN PARCFOURCONTEXT Ctx,
10921 @@ -1394,18 +1423,18 @@
10922 IN PRTMP_ADAPTER pAd);
10924 VOID AsicSwitchChannel(
10925 - IN PRTMP_ADAPTER pAdapter,
10926 + IN PRTMP_ADAPTER pAdapter,
10929 VOID AsicLockChannel(
10930 - IN PRTMP_ADAPTER pAd,
10931 + IN PRTMP_ADAPTER pAd,
10932 IN UCHAR Channel) ;
10934 VOID AsicRfTuningExec(
10935 IN unsigned long data);
10937 VOID AsicSleepThenAutoWakeup(
10938 - IN PRTMP_ADAPTER pAdapter,
10939 + IN PRTMP_ADAPTER pAdapter,
10940 IN USHORT TbttNumToNextWakeUp);
10942 VOID AsicForceSleep(
10943 @@ -1415,7 +1444,7 @@
10944 IN PRTMP_ADAPTER pAdapter);
10947 - IN PRTMP_ADAPTER pAdapter,
10948 + IN PRTMP_ADAPTER pAdapter,
10949 IN MACADDR *Bssid);
10951 VOID AsicDisableSync(
10952 @@ -1453,16 +1482,16 @@
10953 IN PRTMP_ADAPTER pAd);
10955 VOID MacAddrRandomBssid(
10956 - IN PRTMP_ADAPTER pAdapter,
10957 + IN PRTMP_ADAPTER pAdapter,
10958 OUT PMACADDR Addr);
10960 VOID MgtMacHeaderInit(
10961 - IN PRTMP_ADAPTER pAdapter,
10962 - IN OUT PMACHDR Hdr,
10963 - IN UCHAR Subtype,
10965 -// IN UCHAR AddrType,
10967 + IN PRTMP_ADAPTER pAdapter,
10968 + IN OUT PMACHDR Hdr,
10969 + IN UCHAR Subtype,
10971 +// IN UCHAR AddrType,
10973 IN PMACADDR Bssid);
10976 @@ -1475,66 +1504,69 @@
10977 IN BSS_TABLE *Tab);
10979 ULONG BssTableSearch(
10980 - IN BSS_TABLE *Tab,
10981 + IN BSS_TABLE *Tab,
10982 IN PMACADDR Bssid);
10984 VOID BssTableDeleteEntry(
10985 - IN OUT BSS_TABLE *Tab,
10986 + IN OUT BSS_TABLE *Tab,
10987 IN PMACADDR Bssid);
10990 - IN PRTMP_ADAPTER pAdapter,
10991 - OUT BSS_ENTRY *Bss,
10992 - IN MACADDR *Bssid,
10994 - IN UCHAR SsidLen,
10995 - IN UCHAR BssType,
10996 + IN PRTMP_ADAPTER pAdapter,
10997 + OUT BSS_ENTRY *Bss,
10998 + IN MACADDR *Bssid,
11000 + IN UCHAR SsidLen,
11001 + IN UCHAR BssType,
11002 IN USHORT BeaconPeriod,
11003 - IN BOOLEAN CfExist,
11004 - IN CF_PARM *CfParm,
11005 - IN USHORT AtimWin,
11006 - IN USHORT CapabilityInfo,
11007 - IN UCHAR Rates[],
11008 + IN BOOLEAN CfExist,
11009 + IN CF_PARM *CfParm,
11010 + IN USHORT AtimWin,
11011 + IN USHORT CapabilityInfo,
11012 + IN UCHAR Rates[],
11014 IN BOOLEAN ExtendedRateIeExist,
11018 IN LARGE_INTEGER TimeStamp,
11019 + IN USHORT VarIELen, // Length of all saved IEs.
11020 IN PNDIS_802_11_VARIABLE_IEs pVIE);
11022 ULONG BssTableSetEntry(
11023 - IN PRTMP_ADAPTER pAdapter,
11024 - OUT BSS_TABLE *Tab,
11025 - IN MACADDR *Bssid,
11027 - IN UCHAR SsidLen,
11028 - IN UCHAR BssType,
11029 - IN USHORT BeaconPeriod,
11030 - IN BOOLEAN CfExist,
11031 - IN CF_PARM *CfParm,
11032 - IN USHORT AtimWin,
11033 - IN USHORT CapabilityInfo,
11034 - IN UCHAR Rates[],
11035 + IN PRTMP_ADAPTER pAdapter,
11036 + OUT BSS_TABLE *Tab,
11037 + IN MACADDR *Bssid,
11039 + IN UCHAR SsidLen,
11040 + IN UCHAR BssType,
11041 + IN USHORT BeaconPeriod,
11042 + IN BOOLEAN CfExist,
11043 + IN CF_PARM *CfParm,
11044 + IN USHORT AtimWin,
11045 + IN USHORT CapabilityInfo,
11046 + IN UCHAR Rates[],
11048 IN BOOLEAN ExtendedRateIeExist,
11052 IN LARGE_INTEGER TimeStamp,
11053 + IN USHORT VarIELen, // Length of all saved IEs.
11054 IN PNDIS_802_11_VARIABLE_IEs pVIE);
11056 VOID BssTableSsidSort(
11057 - IN PRTMP_ADAPTER pAd,
11058 - OUT BSS_TABLE *OutTab,
11060 + IN PRTMP_ADAPTER pAd,
11061 + OUT BSS_TABLE *OutTab,
11065 VOID BssTableSortByRssi(
11066 IN OUT BSS_TABLE *OutTab);
11068 -NDIS_802_11_WEP_STATUS BssCipherParse(
11069 - IN PUCHAR pCipher);
11070 +USHORT BssCipherParse(
11071 + IN PBEACON_EID_STRUCT pEid,
11072 + IN USHORT VarIELen); // Length of all saved IEs.
11074 NDIS_STATUS MlmeQueueInit(
11075 IN MLME_QUEUE *Queue);
11076 @@ -1543,70 +1575,64 @@
11077 IN MLME_QUEUE *Queue);
11079 BOOLEAN MlmeEnqueue(
11080 - OUT MLME_QUEUE *Queue,
11081 - IN ULONG Machine,
11082 - IN ULONG MsgType,
11084 + OUT MLME_QUEUE *Queue,
11085 + IN ULONG Machine,
11086 + IN ULONG MsgType,
11090 BOOLEAN MlmeEnqueueForRecv(
11091 - IN PRTMP_ADAPTER pAdapter,
11092 - OUT MLME_QUEUE *Queue,
11093 - IN ULONG TimeStampHigh,
11094 - IN ULONG TimeStampLow,
11096 + IN PRTMP_ADAPTER pAdapter,
11097 + OUT MLME_QUEUE *Queue,
11098 + IN ULONG TimeStampHigh,
11099 + IN ULONG TimeStampLow,
11106 BOOLEAN MlmeDequeue(
11107 - IN MLME_QUEUE *Queue,
11108 + IN MLME_QUEUE *Queue,
11109 OUT MLME_QUEUE_ELEM **Elem);
11111 VOID MlmeRestartStateMachine(
11112 IN PRTMP_ADAPTER pAd);
11114 -BOOLEAN MlmeQueueEmpty(
11115 - IN MLME_QUEUE *Queue);
11117 -BOOLEAN MlmeQueueFull(
11118 - IN MLME_QUEUE *Queue);
11120 BOOLEAN MsgTypeSubst(
11122 - OUT INT *Machine,
11124 + OUT INT *Machine,
11127 VOID StateMachineInit(
11128 - IN STATE_MACHINE *Sm,
11129 - IN STATE_MACHINE_FUNC Trans[],
11132 - IN STATE_MACHINE_FUNC DefFunc,
11133 - IN ULONG InitState,
11134 + IN STATE_MACHINE *Sm,
11135 + IN STATE_MACHINE_FUNC Trans[],
11138 + IN STATE_MACHINE_FUNC DefFunc,
11139 + IN ULONG InitState,
11142 VOID StateMachineSetAction(
11143 - IN STATE_MACHINE *S,
11146 + IN STATE_MACHINE *S,
11149 IN STATE_MACHINE_FUNC F);
11151 VOID StateMachinePerformAction(
11152 - IN PRTMP_ADAPTER pAdapter,
11153 - IN STATE_MACHINE *S,
11154 + IN PRTMP_ADAPTER pAdapter,
11155 + IN STATE_MACHINE *S,
11156 IN MLME_QUEUE_ELEM *Elem);
11159 - IN PRTMP_ADAPTER pAdapter,
11160 + IN PRTMP_ADAPTER pAdapter,
11161 IN MLME_QUEUE_ELEM *Elem);
11163 VOID StateMachineDestroy(
11164 IN STATE_MACHINE *Sm);
11166 VOID AssocStateMachineInit(
11167 - IN PRTMP_ADAPTER pAdapter,
11168 - IN STATE_MACHINE *Sm,
11169 + IN PRTMP_ADAPTER pAdapter,
11170 + IN STATE_MACHINE *Sm,
11171 OUT STATE_MACHINE_FUNC Trans[]);
11173 VOID ReassocTimeout(
11174 @@ -1620,43 +1646,43 @@
11176 //----------------------------------------------
11177 VOID MlmeDisassocReqAction(
11178 - IN PRTMP_ADAPTER pAdapter,
11179 + IN PRTMP_ADAPTER pAdapter,
11180 IN MLME_QUEUE_ELEM *Elem);
11182 VOID MlmeAssocReqAction(
11183 - IN PRTMP_ADAPTER pAdapter,
11184 + IN PRTMP_ADAPTER pAdapter,
11185 IN MLME_QUEUE_ELEM *Elem);
11187 VOID MlmeReassocReqAction(
11188 - IN PRTMP_ADAPTER pAdapter,
11189 + IN PRTMP_ADAPTER pAdapter,
11190 IN MLME_QUEUE_ELEM *Elem);
11192 VOID MlmeDisassocReqAction(
11193 - IN PRTMP_ADAPTER pAdapter,
11194 + IN PRTMP_ADAPTER pAdapter,
11195 IN MLME_QUEUE_ELEM *Elem);
11197 VOID PeerAssocRspAction(
11198 - IN PRTMP_ADAPTER pAdapter,
11199 + IN PRTMP_ADAPTER pAdapter,
11200 IN MLME_QUEUE_ELEM *Elem);
11202 VOID PeerReassocRspAction(
11203 - IN PRTMP_ADAPTER pAdapter,
11204 + IN PRTMP_ADAPTER pAdapter,
11205 IN MLME_QUEUE_ELEM *Elem);
11207 VOID PeerDisassocAction(
11208 - IN PRTMP_ADAPTER pAdapter,
11209 + IN PRTMP_ADAPTER pAdapter,
11210 IN MLME_QUEUE_ELEM *Elem);
11212 VOID DisassocTimeoutAction(
11213 - IN PRTMP_ADAPTER pAdapter,
11214 + IN PRTMP_ADAPTER pAdapter,
11215 IN MLME_QUEUE_ELEM *Elem);
11217 VOID AssocTimeoutAction(
11218 - IN PRTMP_ADAPTER pAdapter,
11219 + IN PRTMP_ADAPTER pAdapter,
11220 IN MLME_QUEUE_ELEM *Elem);
11222 VOID ReassocTimeoutAction(
11223 - IN PRTMP_ADAPTER pAdapter,
11224 + IN PRTMP_ADAPTER pAdapter,
11225 IN MLME_QUEUE_ELEM *Elem);
11227 VOID Cls3errAction(
11228 @@ -1682,60 +1708,60 @@
11229 IN PRTMP_ADAPTER pAdapter);
11231 VOID AssocPostProc(
11232 - IN PRTMP_ADAPTER pAdapter,
11233 - IN MACADDR *Addr2,
11234 - IN USHORT CapabilityInfo,
11236 - IN UCHAR Rates[],
11237 + IN PRTMP_ADAPTER pAdapter,
11238 + IN MACADDR *Addr2,
11239 + IN USHORT CapabilityInfo,
11241 + IN UCHAR Rates[],
11243 IN BOOLEAN ExtendedRateIeExist);
11245 VOID AuthStateMachineInit(
11246 - IN PRTMP_ADAPTER pAdapter,
11247 - IN PSTATE_MACHINE sm,
11248 + IN PRTMP_ADAPTER pAdapter,
11249 + IN PSTATE_MACHINE sm,
11250 OUT STATE_MACHINE_FUNC Trans[]);
11253 IN unsigned long data);
11255 VOID MlmeAuthReqAction(
11256 - IN PRTMP_ADAPTER pAdapter,
11257 + IN PRTMP_ADAPTER pAdapter,
11258 IN MLME_QUEUE_ELEM *Elem);
11260 VOID PeerAuthRspAtSeq2Action(
11261 - IN PRTMP_ADAPTER pAdapter,
11262 + IN PRTMP_ADAPTER pAdapter,
11263 IN MLME_QUEUE_ELEM *Elem);
11265 VOID PeerAuthRspAtSeq4Action(
11266 - IN PRTMP_ADAPTER pAdapter,
11267 + IN PRTMP_ADAPTER pAdapter,
11268 IN MLME_QUEUE_ELEM *Elem);
11270 VOID AuthTimeoutAction(
11271 - IN PRTMP_ADAPTER pAdapter,
11272 + IN PRTMP_ADAPTER pAdapter,
11273 IN MLME_QUEUE_ELEM *Elem);
11275 VOID Cls2errAction(
11276 - IN PRTMP_ADAPTER pAdapter,
11277 + IN PRTMP_ADAPTER pAdapter,
11278 IN PMACADDR pAddr);
11280 VOID MlmeDeauthReqAction(
11281 - IN PRTMP_ADAPTER pAdapter,
11282 + IN PRTMP_ADAPTER pAdapter,
11283 IN MLME_QUEUE_ELEM *Elem);
11285 VOID InvalidStateWhenAuth(
11286 - IN PRTMP_ADAPTER pAdapter,
11287 + IN PRTMP_ADAPTER pAdapter,
11288 IN MLME_QUEUE_ELEM *Elem);
11290 //VOID MlmeDeauthReqProc(
11291 -// IN PRTMP_ADAPTER pAdapter,
11292 -// IN MACADDR *Addr,
11293 +// IN PRTMP_ADAPTER pAdapter,
11294 +// IN MACADDR *Addr,
11295 // IN USHORT Reason);
11297 //=============================================
11299 VOID AuthRspStateMachineInit(
11300 - IN PRTMP_ADAPTER pAdapter,
11301 - IN PSTATE_MACHINE Sm,
11302 + IN PRTMP_ADAPTER pAdapter,
11303 + IN PSTATE_MACHINE Sm,
11304 IN STATE_MACHINE_FUNC Trans[]);
11307 @@ -1743,34 +1769,34 @@
11308 IN unsigned long data);
11310 VOID AuthRspChallengeTimeoutAction(
11311 - IN PRTMP_ADAPTER pAdapter,
11312 + IN PRTMP_ADAPTER pAdapter,
11313 IN MLME_QUEUE_ELEM *Elem);
11315 VOID PeerAuthAtAuthRspIdleAction(
11316 - IN PRTMP_ADAPTER pAdapter,
11317 + IN PRTMP_ADAPTER pAdapter,
11318 IN MLME_QUEUE_ELEM *Elem);
11320 VOID PeerAuthAtAuthRspWaitAction(
11321 - IN PRTMP_ADAPTER pAdapter,
11322 + IN PRTMP_ADAPTER pAdapter,
11323 IN MLME_QUEUE_ELEM *Elem);
11325 VOID PeerDeauthAction(
11326 - IN PRTMP_ADAPTER pAdaptor,
11327 + IN PRTMP_ADAPTER pAdaptor,
11328 IN MLME_QUEUE_ELEM *Elem);
11330 VOID PeerAuthSimpleRspGenAndSend(
11331 - IN PRTMP_ADAPTER pAdapter,
11335 - IN USHORT Reason,
11336 + IN PRTMP_ADAPTER pAdapter,
11340 + IN USHORT Reason,
11343 //========================================
11345 VOID SyncStateMachineInit(
11346 - IN PRTMP_ADAPTER pAdapter,
11347 - IN STATE_MACHINE *Sm,
11348 + IN PRTMP_ADAPTER pAdapter,
11349 + IN STATE_MACHINE *Sm,
11350 OUT STATE_MACHINE_FUNC Trans[]);
11352 VOID BeaconTimeout(
11353 @@ -1783,23 +1809,23 @@
11354 IN unsigned long data);
11356 VOID MlmeScanReqAction(
11357 - IN PRTMP_ADAPTER pAdapter,
11358 + IN PRTMP_ADAPTER pAdapter,
11359 IN MLME_QUEUE_ELEM *Elem);
11361 VOID InvalidStateWhenScan(
11362 - IN PRTMP_ADAPTER pAdapter,
11363 + IN PRTMP_ADAPTER pAdapter,
11364 IN MLME_QUEUE_ELEM *Elem);
11366 VOID InvalidStateWhenJoin(
11367 - IN PRTMP_ADAPTER pAdapter,
11368 + IN PRTMP_ADAPTER pAdapter,
11369 IN MLME_QUEUE_ELEM *Elem);
11371 VOID InvalidStateWhenStart(
11372 - IN PRTMP_ADAPTER pAdapter,
11373 + IN PRTMP_ADAPTER pAdapter,
11374 IN MLME_QUEUE_ELEM *Elem);
11377 - IN PRTMP_ADAPTER pAdapter,
11378 + IN PRTMP_ADAPTER pAdapter,
11379 IN MLME_QUEUE_ELEM *Elem);
11381 VOID EnqueueProbeRequest(
11382 @@ -1808,61 +1834,61 @@
11383 //=========================================
11386 - IN PRTMP_ADAPTER pAdapter,
11387 - IN STATE_MACHINE *S,
11388 + IN PRTMP_ADAPTER pAdapter,
11389 + IN STATE_MACHINE *S,
11390 OUT STATE_MACHINE_FUNC Trans[]);
11392 VOID MlmeCntlMachinePerformAction(
11393 - IN PRTMP_ADAPTER pAdapter,
11394 - IN STATE_MACHINE *S,
11395 + IN PRTMP_ADAPTER pAdapter,
11396 + IN STATE_MACHINE *S,
11397 IN MLME_QUEUE_ELEM *Elem);
11400 - IN PRTMP_ADAPTER pAdapter,
11401 + IN PRTMP_ADAPTER pAdapter,
11402 IN MLME_QUEUE_ELEM *Elem);
11404 VOID CntlOidScanProc(
11405 - IN PRTMP_ADAPTER pAdapter,
11406 + IN PRTMP_ADAPTER pAdapter,
11407 IN MLME_QUEUE_ELEM *Elem);
11409 VOID CntlOidSsidProc(
11410 - IN PRTMP_ADAPTER pAdapter,
11411 + IN PRTMP_ADAPTER pAdapter,
11412 IN MLME_QUEUE_ELEM * Elem);
11414 VOID CntlOidRTBssidProc(
11415 - IN PRTMP_ADAPTER pAdapter,
11416 + IN PRTMP_ADAPTER pAdapter,
11417 IN MLME_QUEUE_ELEM *Elem);
11419 VOID CntlMlmeRoamingProc(
11420 - IN PRTMP_ADAPTER pAdapter,
11421 + IN PRTMP_ADAPTER pAdapter,
11422 IN MLME_QUEUE_ELEM *Elem);
11424 VOID CntlWaitDisassocProc(
11425 - IN PRTMP_ADAPTER pAdapter,
11426 + IN PRTMP_ADAPTER pAdapter,
11427 IN MLME_QUEUE_ELEM *Elem);
11429 VOID CntlWaitJoinProc(
11430 - IN PRTMP_ADAPTER pAdapter,
11431 + IN PRTMP_ADAPTER pAdapter,
11432 IN MLME_QUEUE_ELEM *Elem);
11434 VOID CntlWaitReassocProc(
11435 - IN PRTMP_ADAPTER pAdapter,
11436 + IN PRTMP_ADAPTER pAdapter,
11437 IN MLME_QUEUE_ELEM *Elem);
11439 VOID CntlWaitStartProc(
11440 - IN PRTMP_ADAPTER pAdapter,
11441 + IN PRTMP_ADAPTER pAdapter,
11442 IN MLME_QUEUE_ELEM *Elem);
11444 VOID CntlWaitAuthProc(
11445 - IN PRTMP_ADAPTER pAdapter,
11446 + IN PRTMP_ADAPTER pAdapter,
11447 IN MLME_QUEUE_ELEM *Elem);
11449 VOID CntlWaitAuthProc2(
11450 - IN PRTMP_ADAPTER pAdapter,
11451 + IN PRTMP_ADAPTER pAdapter,
11452 IN MLME_QUEUE_ELEM *Elem);
11454 VOID CntlWaitAssocProc(
11455 - IN PRTMP_ADAPTER pAdapter,
11456 + IN PRTMP_ADAPTER pAdapter,
11457 IN MLME_QUEUE_ELEM *Elem);
11460 @@ -1873,8 +1899,8 @@
11461 IN PRTMP_ADAPTER pAdapter);
11463 VOID MlmeCntlConfirm(
11464 - IN PRTMP_ADAPTER pAdapter,
11465 - IN ULONG MsgType,
11466 + IN PRTMP_ADAPTER pAdapter,
11467 + IN ULONG MsgType,
11470 VOID IterateOnBssTab(
11471 @@ -1884,42 +1910,42 @@
11472 IN PRTMP_ADAPTER pAdapter);;
11475 - IN PRTMP_ADAPTER pAdapter,
11476 - IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
11477 + IN PRTMP_ADAPTER pAdapter,
11478 + IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
11481 VOID AssocParmFill(
11482 - IN PRTMP_ADAPTER pAdapter,
11483 - IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
11484 - IN MACADDR *Addr,
11485 - IN USHORT CapabilityInfo,
11486 - IN ULONG Timeout,
11487 + IN PRTMP_ADAPTER pAdapter,
11488 + IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
11489 + IN MACADDR *Addr,
11490 + IN USHORT CapabilityInfo,
11491 + IN ULONG Timeout,
11492 IN USHORT ListenIntv);
11495 - IN PRTMP_ADAPTER pAdapter,
11496 - IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
11498 - IN UCHAR SsidLen,
11499 - IN UCHAR BssType,
11500 - IN UCHAR ScanType);
11501 + IN PRTMP_ADAPTER pAdapter,
11502 + IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
11504 + IN UCHAR SsidLen,
11505 + IN UCHAR BssType,
11506 + IN UCHAR ScanType);
11508 VOID DisassocParmFill(
11509 - IN PRTMP_ADAPTER pAdapter,
11510 - IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
11511 - IN MACADDR *Addr,
11512 + IN PRTMP_ADAPTER pAdapter,
11513 + IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
11514 + IN MACADDR *Addr,
11517 VOID StartParmFill(
11518 - IN PRTMP_ADAPTER pAdapter,
11519 - IN OUT MLME_START_REQ_STRUCT *StartReq,
11521 + IN PRTMP_ADAPTER pAdapter,
11522 + IN OUT MLME_START_REQ_STRUCT *StartReq,
11527 - IN PRTMP_ADAPTER pAdapter,
11528 - IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
11529 - IN MACADDR *Addr,
11530 + IN PRTMP_ADAPTER pAdapter,
11531 + IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
11532 + IN MACADDR *Addr,
11535 VOID EnqueuePsPoll(
11536 @@ -1933,39 +1959,39 @@
11539 VOID MlmeJoinReqAction(
11540 - IN PRTMP_ADAPTER pAdapter,
11541 + IN PRTMP_ADAPTER pAdapter,
11542 IN MLME_QUEUE_ELEM *Elem);
11544 VOID MlmeScanReqAction(
11545 - IN PRTMP_ADAPTER pAdapter,
11546 + IN PRTMP_ADAPTER pAdapter,
11547 IN MLME_QUEUE_ELEM *Elem);
11549 VOID MlmeStartReqAction(
11550 - IN PRTMP_ADAPTER pAdapter,
11551 + IN PRTMP_ADAPTER pAdapter,
11552 IN MLME_QUEUE_ELEM *Elem);
11554 VOID ScanTimeoutAction(
11555 - IN PRTMP_ADAPTER pAdapter,
11556 + IN PRTMP_ADAPTER pAdapter,
11557 IN MLME_QUEUE_ELEM *Elem);
11559 VOID BeaconTimeoutAtJoinAction(
11560 - IN PRTMP_ADAPTER pAdapter,
11561 + IN PRTMP_ADAPTER pAdapter,
11562 IN MLME_QUEUE_ELEM *Elem);
11564 VOID PeerBeaconAtScanAction(
11565 - IN PRTMP_ADAPTER pAdapter,
11566 + IN PRTMP_ADAPTER pAdapter,
11567 IN MLME_QUEUE_ELEM *Elem);
11569 VOID PeerBeaconAtJoinAction(
11570 - IN PRTMP_ADAPTER pAdapter,
11571 + IN PRTMP_ADAPTER pAdapter,
11572 IN MLME_QUEUE_ELEM *Elem);
11575 - IN PRTMP_ADAPTER pAdapter,
11576 + IN PRTMP_ADAPTER pAdapter,
11577 IN MLME_QUEUE_ELEM *Elem);
11579 VOID PeerProbeReqAction(
11580 - IN PRTMP_ADAPTER pAd,
11581 + IN PRTMP_ADAPTER pAd,
11582 IN MLME_QUEUE_ELEM *Elem);
11584 VOID ScanNextChannel(
11585 @@ -1975,142 +2001,143 @@
11586 IN PRTMP_ADAPTER pAdapter);
11588 BOOLEAN MlmeScanReqSanity(
11589 - IN PRTMP_ADAPTER pAdapter,
11592 - OUT UCHAR *BssType,
11594 - OUT UCHAR *SsidLen,
11595 + IN PRTMP_ADAPTER pAdapter,
11598 + OUT UCHAR *BssType,
11600 + OUT UCHAR *SsidLen,
11601 OUT UCHAR *ScanType);
11603 BOOLEAN PeerBeaconAndProbeRspSanity(
11604 - IN PRTMP_ADAPTER pAdapter,
11607 - OUT MACADDR *Addr2,
11608 - OUT MACADDR *Bssid,
11610 - OUT UCHAR *SsidLen,
11611 - OUT UCHAR *BssType,
11612 - OUT USHORT *BeaconPeriod,
11613 - OUT UCHAR *Channel,
11614 - OUT LARGE_INTEGER *Timestamp,
11615 - OUT BOOLEAN *CfExist,
11617 - OUT USHORT *AtimWin,
11618 - OUT USHORT *CapabilityInfo,
11619 - OUT UCHAR Rate[],
11620 + IN PRTMP_ADAPTER pAdapter,
11623 + OUT MACADDR *Addr2,
11624 + OUT MACADDR *Bssid,
11626 + OUT UCHAR *SsidLen,
11627 + OUT UCHAR *BssType,
11628 + OUT USHORT *BeaconPeriod,
11629 + OUT UCHAR *Channel,
11630 + OUT LARGE_INTEGER *Timestamp,
11631 + OUT BOOLEAN *CfExist,
11633 + OUT USHORT *AtimWin,
11634 + OUT USHORT *CapabilityInfo,
11635 + OUT UCHAR Rate[],
11636 OUT UCHAR *RateLen,
11637 OUT BOOLEAN *ExtendedRateIeExist,
11639 - OUT UCHAR *DtimCount,
11640 - OUT UCHAR *DtimPeriod,
11641 - OUT UCHAR *BcastFlag,
11642 - OUT UCHAR *MessageToMe,
11643 + OUT UCHAR *DtimCount,
11644 + OUT UCHAR *DtimPeriod,
11645 + OUT UCHAR *BcastFlag,
11646 + OUT UCHAR *MessageToMe,
11648 OUT UCHAR SupRate[],
11649 OUT UCHAR *SupRateLen,
11650 OUT UCHAR ExtRate[],
11651 OUT UCHAR *ExtRateLen,
11652 + OUT USHORT *VarIELen, // Length of all saved IEs.
11653 OUT PNDIS_802_11_VARIABLE_IEs pVIE);
11655 //BOOLEAN JoinParmSanity(
11656 -// IN PRTMP_ADAPTER pAdapter,
11658 -// IN ULONG MsgLen,
11659 +// IN PRTMP_ADAPTER pAdapter,
11661 +// IN ULONG MsgLen,
11662 // OUT ULONG *BssIdx,
11663 -// OUT UCHAR SupportedRates[],
11664 +// OUT UCHAR SupportedRates[],
11665 // OUT UCHAR *SupportedRatesLen);
11667 BOOLEAN MlmeAssocReqSanity(
11668 IN PRTMP_ADAPTER pAdapter,
11671 - OUT MACADDR *ApAddr,
11672 - OUT USHORT *CapabilityInfo,
11673 - OUT ULONG *Timeout,
11676 + OUT MACADDR *ApAddr,
11677 + OUT USHORT *CapabilityInfo,
11678 + OUT ULONG *Timeout,
11679 OUT USHORT *ListenIntv);
11681 BOOLEAN MlmeAuthReqSanity(
11682 - IN PRTMP_ADAPTER pAdapter,
11685 - OUT MACADDR *Addr,
11686 - OUT ULONG *Timeout,
11687 + IN PRTMP_ADAPTER pAdapter,
11690 + OUT MACADDR *Addr,
11691 + OUT ULONG *Timeout,
11694 BOOLEAN MlmeStartReqSanity(
11695 - IN PRTMP_ADAPTER pAdapter,
11699 + IN PRTMP_ADAPTER pAdapter,
11703 OUT UCHAR *Ssidlen);
11705 BOOLEAN PeerAuthSanity(
11706 - IN PRTMP_ADAPTER pAdapter,
11709 - OUT MACADDR *Addr,
11712 - OUT USHORT *Status,
11713 + IN PRTMP_ADAPTER pAdapter,
11716 + OUT MACADDR *Addr,
11719 + OUT USHORT *Status,
11720 OUT CHAR ChlgText[]);
11722 BOOLEAN PeerAssocRspSanity(
11723 - IN PRTMP_ADAPTER pAdapter,
11726 - OUT MACADDR *Addr2,
11727 - OUT USHORT *CapabilityInfo,
11728 - OUT USHORT *Status,
11730 - OUT UCHAR Rates[],
11731 + IN PRTMP_ADAPTER pAdapter,
11734 + OUT MACADDR *Addr2,
11735 + OUT USHORT *CapabilityInfo,
11736 + OUT USHORT *Status,
11738 + OUT UCHAR Rates[],
11739 OUT UCHAR *RatesLen,
11740 OUT BOOLEAN *ExtendedRateIeExist);
11742 BOOLEAN PeerDisassocSanity(
11743 - IN PRTMP_ADAPTER pAdapter,
11746 - OUT MACADDR *Addr2,
11747 + IN PRTMP_ADAPTER pAdapter,
11750 + OUT MACADDR *Addr2,
11751 OUT USHORT *Reason);
11753 BOOLEAN PeerDeauthSanity(
11754 - IN PRTMP_ADAPTER pAdapter,
11757 - OUT MACADDR *Addr2,
11758 + IN PRTMP_ADAPTER pAdapter,
11761 + OUT MACADDR *Addr2,
11762 OUT USHORT *Reason);
11764 BOOLEAN PeerProbeReqSanity(
11765 - IN PRTMP_ADAPTER pAdapter,
11768 + IN PRTMP_ADAPTER pAdapter,
11771 OUT MACADDR *Addr2,
11773 - OUT UCHAR *SsidLen);
11774 -// OUT UCHAR Rates[],
11776 + OUT UCHAR *SsidLen);
11777 +// OUT UCHAR Rates[],
11778 // OUT UCHAR *RatesLen);
11783 - OUT UCHAR *TimLen,
11784 - OUT UCHAR *BcastFlag,
11785 - OUT UCHAR *DtimCount,
11786 - OUT UCHAR *DtimPeriod,
11789 + OUT UCHAR *TimLen,
11790 + OUT UCHAR *BcastFlag,
11791 + OUT UCHAR *DtimCount,
11792 + OUT UCHAR *DtimPeriod,
11793 OUT UCHAR *MessageToMe);
11798 OUT UCHAR *Legacy);
11800 ULONG MakeOutgoingFrame(
11801 - OUT CHAR *Buffer,
11802 + OUT CHAR *Buffer,
11803 OUT ULONG *Length, ...);
11806 - IN PRTMP_ADAPTER pAdapter,
11807 + IN PRTMP_ADAPTER pAdapter,
11811 @@ -2129,26 +2156,26 @@
11812 IN PRTMP_ADAPTER pAdapter);
11814 VOID MlmeCheckForRoaming(
11815 - IN PRTMP_ADAPTER pAdapter,
11816 + IN PRTMP_ADAPTER pAdapter,
11819 VOID MlmeCheckDynamicTxRateSwitching(
11820 IN PRTMP_ADAPTER pAd);
11822 VOID MlmeCheckChannelQuality(
11823 - IN PRTMP_ADAPTER pAdapter,
11824 + IN PRTMP_ADAPTER pAdapter,
11827 VOID MlmeCheckForPsmChange(
11828 - IN PRTMP_ADAPTER pAdapter,
11829 + IN PRTMP_ADAPTER pAdapter,
11832 VOID MlmeSetPsmBit(
11833 - IN PRTMP_ADAPTER pAdapter,
11834 + IN PRTMP_ADAPTER pAdapter,
11837 VOID MlmeSetTxPreamble(
11838 - IN PRTMP_ADAPTER pAdapter,
11839 + IN PRTMP_ADAPTER pAdapter,
11840 IN USHORT TxPreamble);
11842 VOID MlmeUpdateTxRates(
11843 @@ -2214,7 +2241,7 @@
11846 IN PRTMP_ADAPTER pAd);
11849 USHORT RTMP_EEPROM_READ16(
11850 IN PRTMP_ADAPTER pAd,
11852 @@ -2223,16 +2250,16 @@
11853 IN PRTMP_ADAPTER pAd,
11858 UCHAR ChannelSanity(
11859 - IN PRTMP_ADAPTER pAd,
11860 + IN PRTMP_ADAPTER pAd,
11864 // Prototypes of function definition in rtmp_tkip.c
11866 VOID RTMPInitTkipEngine(
11867 - IN PRTMP_ADAPTER pAdapter,
11868 + IN PRTMP_ADAPTER pAdapter,
11872 @@ -2242,14 +2269,14 @@
11875 VOID RTMPInitMICEngine(
11876 - IN PRTMP_ADAPTER pAdapter,
11877 + IN PRTMP_ADAPTER pAdapter,
11881 IN PUCHAR pMICKey);
11883 BOOLEAN RTMPTkipCompareMICValue(
11884 - IN PRTMP_ADAPTER pAdapter,
11885 + IN PRTMP_ADAPTER pAdapter,
11889 @@ -2272,12 +2299,12 @@
11893 -VOID RTMPTkipAppend(
11894 - IN PTKIP_KEY_INFO pTkip,
11895 +VOID RTMPTkipAppend(
11896 + IN PTKIP_KEY_INFO pTkip,
11900 -VOID RTMPTkipGetMIC(
11901 +VOID RTMPTkipGetMIC(
11902 IN PTKIP_KEY_INFO pTkip);
11904 NDIS_STATUS RTMPWPAAddKeyProc(
11905 @@ -2292,7 +2319,7 @@
11906 IN PRTMP_ADAPTER pAdapter);
11908 VOID RTMPSetPhyMode(
11909 - IN PRTMP_ADAPTER pAdapter,
11910 + IN PRTMP_ADAPTER pAdapter,
11913 VOID RTMPSetDesiredRates(
11914 @@ -2313,102 +2340,102 @@
11915 // Prototypes of function definition for *iwpriv* in rtmp_info.c
11917 INT Set_CountryRegion_Proc(
11918 - IN PRTMP_ADAPTER pAdapter,
11919 + IN PRTMP_ADAPTER pAdapter,
11923 - IN PRTMP_ADAPTER pAdapter,
11924 + IN PRTMP_ADAPTER pAdapter,
11927 INT Set_WirelessMode_Proc(
11928 - IN PRTMP_ADAPTER pAdapter,
11929 + IN PRTMP_ADAPTER pAdapter,
11932 INT Set_TxRate_Proc(
11933 - IN PRTMP_ADAPTER pAdapter,
11934 + IN PRTMP_ADAPTER pAdapter,
11937 INT Set_AdhocModeRate_Proc(
11938 - IN PRTMP_ADAPTER pAdapter,
11939 + IN PRTMP_ADAPTER pAdapter,
11942 INT Set_Channel_Proc(
11943 - IN PRTMP_ADAPTER pAdapter,
11945 + IN PRTMP_ADAPTER pAdapter,
11950 INT Set_Debug_Proc(
11951 - IN PRTMP_ADAPTER pAdapter,
11952 + IN PRTMP_ADAPTER pAdapter,
11956 INT Set_BGProtection_Proc(
11957 - IN PRTMP_ADAPTER pAdapter,
11958 + IN PRTMP_ADAPTER pAdapter,
11961 INT Set_TxPreamble_Proc(
11962 - IN PRTMP_ADAPTER pAdapter,
11963 + IN PRTMP_ADAPTER pAdapter,
11966 INT Set_StaWithEtherBridge_Proc(
11967 - IN PRTMP_ADAPTER pAdapter,
11968 + IN PRTMP_ADAPTER pAdapter,
11971 INT Set_RTSThreshold_Proc(
11972 - IN PRTMP_ADAPTER pAdapter,
11973 + IN PRTMP_ADAPTER pAdapter,
11976 INT Set_FragThreshold_Proc(
11977 - IN PRTMP_ADAPTER pAdapter,
11978 + IN PRTMP_ADAPTER pAdapter,
11981 INT Set_TxBurst_Proc(
11982 - IN PRTMP_ADAPTER pAdapter,
11983 + IN PRTMP_ADAPTER pAdapter,
11986 INT Set_TurboRate_Proc(
11987 - IN PRTMP_ADAPTER pAdapter,
11988 + IN PRTMP_ADAPTER pAdapter,
11991 INT Set_NetworkType_Proc(
11992 - IN PRTMP_ADAPTER pAdapter,
11993 + IN PRTMP_ADAPTER pAdapter,
11997 INT Set_AuthMode_Proc(
11998 - IN PRTMP_ADAPTER pAdapter,
11999 + IN PRTMP_ADAPTER pAdapter,
12002 INT Set_EncrypType_Proc(
12003 - IN PRTMP_ADAPTER pAdapter,
12004 + IN PRTMP_ADAPTER pAdapter,
12007 INT Set_DefaultKeyID_Proc(
12008 - IN PRTMP_ADAPTER pAdapter,
12009 + IN PRTMP_ADAPTER pAdapter,
12013 - IN PRTMP_ADAPTER pAdapter,
12014 + IN PRTMP_ADAPTER pAdapter,
12018 - IN PRTMP_ADAPTER pAdapter,
12019 + IN PRTMP_ADAPTER pAdapter,
12023 - IN PRTMP_ADAPTER pAdapter,
12024 + IN PRTMP_ADAPTER pAdapter,
12028 - IN PRTMP_ADAPTER pAdapter,
12029 + IN PRTMP_ADAPTER pAdapter,
12032 INT Set_WPAPSK_Proc(
12033 - IN PRTMP_ADAPTER pAdapter,
12034 + IN PRTMP_ADAPTER pAdapter,
12037 INT Set_WPANONE_Proc(
12038 - IN PRTMP_ADAPTER pAdapter,
12039 + IN PRTMP_ADAPTER pAdapter,
12043 @@ -2425,10 +2452,14 @@
12044 IN struct iwreq *wrq);
12047 -int RTMPIoctlRFMONTX(
12048 - IN OUT PRTMP_ADAPTER pAdapter,
12049 +int RTMPIoctlSetRFMONTX(
12050 + IN PRTMP_ADAPTER pAdapter,
12051 IN struct iwreq *wrq);
12053 +int RTMPIoctlGetRFMONTX(
12054 + IN PRTMP_ADAPTER pAdapter,
12055 + OUT struct iwreq *wrq);
12058 // prototype in wpa.c
12060 @@ -2437,31 +2468,31 @@
12061 OUT ULONG *MsgType);
12063 VOID WpaPskStateMachineInit(
12064 - IN PRTMP_ADAPTER pAd,
12065 - IN STATE_MACHINE *S,
12066 + IN PRTMP_ADAPTER pAd,
12067 + IN STATE_MACHINE *S,
12068 OUT STATE_MACHINE_FUNC Trans[]);
12070 VOID WpaEAPOLKeyAction(
12071 - IN PRTMP_ADAPTER pAdapter,
12072 + IN PRTMP_ADAPTER pAdapter,
12073 IN MLME_QUEUE_ELEM *Elem);
12075 VOID WpaPairMsg1Action(
12076 - IN PRTMP_ADAPTER pAdapter,
12077 + IN PRTMP_ADAPTER pAdapter,
12078 IN MLME_QUEUE_ELEM *Elem);
12080 VOID WpaPairMsg3Action(
12081 - IN PRTMP_ADAPTER pAdapter,
12082 - IN MLME_QUEUE_ELEM *Elem);
12083 + IN PRTMP_ADAPTER pAdapter,
12084 + IN MLME_QUEUE_ELEM *Elem);
12086 VOID WpaGroupMsg1Action(
12087 - IN PRTMP_ADAPTER pAdapter,
12088 + IN PRTMP_ADAPTER pAdapter,
12089 IN MLME_QUEUE_ELEM *Elem);
12091 VOID WpaMacHeaderInit(
12092 - IN PRTMP_ADAPTER pAd,
12093 - IN OUT PHEADER_802_11 Hdr,
12095 - IN PMACADDR pAddr1);
12096 + IN PRTMP_ADAPTER pAd,
12097 + IN OUT PHEADER_802_11 Hdr,
12099 + IN PMACADDR pAddr1);
12101 VOID WpaHardEncrypt(
12102 IN PRTMP_ADAPTER pAdapter,
12103 @@ -2495,15 +2526,15 @@
12107 - IN PRTMP_ADAPTER pAd,
12108 + IN PRTMP_ADAPTER pAd,
12109 OUT UCHAR *random);
12111 -VOID AES_GTK_KEY_UNWRAP(
12112 +VOID AES_GTK_KEY_UNWRAP(
12114 OUT UCHAR *plaintext,
12115 IN UCHAR *ciphertext);
12117 -ULONG RTMPTkipGetUInt32(
12118 +ULONG RTMPTkipGetUInt32(
12119 IN PUCHAR pMICKey);
12122 @@ -2512,39 +2543,39 @@
12126 - IN PRTMP_ADAPTER pAdapter,
12127 + IN PRTMP_ADAPTER pAdapter,
12130 INT Set_ATE_DA_Proc(
12131 - IN PRTMP_ADAPTER pAdapter,
12132 + IN PRTMP_ADAPTER pAdapter,
12135 INT Set_ATE_SA_Proc(
12136 - IN PRTMP_ADAPTER pAdapter,
12137 + IN PRTMP_ADAPTER pAdapter,
12140 INT Set_ATE_BSSID_Proc(
12141 - IN PRTMP_ADAPTER pAdapter,
12142 + IN PRTMP_ADAPTER pAdapter,
12145 INT Set_ATE_CHANNEL_Proc(
12146 - IN PRTMP_ADAPTER pAdapter,
12147 + IN PRTMP_ADAPTER pAdapter,
12150 INT Set_ATE_TX_POWER_Proc(
12151 - IN PRTMP_ADAPTER pAdapter,
12152 + IN PRTMP_ADAPTER pAdapter,
12155 INT Set_ATE_TX_LENGTH_Proc(
12156 - IN PRTMP_ADAPTER pAdapter,
12157 + IN PRTMP_ADAPTER pAdapter,
12160 INT Set_ATE_TX_COUNT_Proc(
12161 - IN PRTMP_ADAPTER pAdapter,
12162 + IN PRTMP_ADAPTER pAdapter,
12165 INT Set_ATE_TX_RATE_Proc(
12166 - IN PRTMP_ADAPTER pAdapter,
12167 + IN PRTMP_ADAPTER pAdapter,
12170 VOID RTMPStationStop(
12171 @@ -2559,11 +2590,15 @@
12174 VOID RTMPFrameEndianChange(
12175 - IN PRTMP_ADAPTER pAdapter,
12177 + IN PRTMP_ADAPTER pAdapter,
12180 IN BOOLEAN FromRxDoneInt);
12182 +VOID WriteBackToDescriptor(IN PUCHAR Dest,
12184 + IN BOOLEAN DoEncrypt, IN ULONG DescriptorType);
12186 VOID RTMPDescriptorEndianChange(
12188 IN ULONG DescriptorType);
12189 diff -Nur rt2500-1.1.0-b4/Module/rtmp_data.c rt2500-cvs-2007061011/Module/rtmp_data.c
12190 --- rt2500-1.1.0-b4/Module/rtmp_data.c 2006-06-17 22:12:58.000000000 +0200
12191 +++ rt2500-cvs-2007061011/Module/rtmp_data.c 2007-06-08 20:09:53.000000000 +0200
12193 -/***************************************************************************
12194 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
12196 - * This program is free software; you can redistribute it and/or modify *
12197 - * it under the terms of the GNU General Public License as published by *
12198 - * the Free Software Foundation; either version 2 of the License, or *
12199 - * (at your option) any later version. *
12201 - * This program is distributed in the hope that it will be useful, *
12202 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12203 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12204 - * GNU General Public License for more details. *
12206 - * You should have received a copy of the GNU General Public License *
12207 - * along with this program; if not, write to the *
12208 - * Free Software Foundation, Inc., *
12209 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
12211 - * Licensed under the GNU GPL *
12212 - * Original code supplied under license from RaLink Inc, 2004. *
12213 - ***************************************************************************/
12214 +/***************************************************************************
12215 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
12217 + * This program is free software; you can redistribute it and/or modify *
12218 + * it under the terms of the GNU General Public License as published by *
12219 + * the Free Software Foundation; either version 2 of the License, or *
12220 + * (at your option) any later version. *
12222 + * This program is distributed in the hope that it will be useful, *
12223 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12224 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12225 + * GNU General Public License for more details. *
12227 + * You should have received a copy of the GNU General Public License *
12228 + * along with this program; if not, write to the *
12229 + * Free Software Foundation, Inc., *
12230 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
12232 + * Licensed under the GNU GPL *
12233 + * Original code supplied under license from RaLink Inc, 2004. *
12234 + ***************************************************************************/
12236 - /***************************************************************************
12237 + /***************************************************************************
12238 * Module Name: rtmp_data.c
12241 * Abstract: Data path subroutines
12243 - * Revision History:
12245 - * -------- ----------- -----------------------------
12247 + * Revision History:
12249 + * -------- ----------- -----------------------------
12250 * John 25th Feb 03 Modify for rt2560
12251 - * MarkW 8th Dec 04 Baseline code
12252 + * MarkW 8th Dec 04 Baseline code
12253 * MarkW (rt2400) 8th Dec 04 Promisc mode support
12254 * RobinC 10th Dec 04 RFMON Support
12255 - * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
12256 + * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
12257 * MarkW 17th Dec 04 Monitor mode through iwconfig
12258 * MarkW 19th Feb 05 Fixes to incoming byte count
12259 * GregorG 29th Mar 05 Big endian fixes
12260 - ***************************************************************************/
12261 + ***************************************************************************/
12263 #include "rt_config.h"
12265 @@ -46,12 +46,12 @@
12267 static UCHAR IPX[] = {0x81, 0x37};
12268 static UCHAR APPLE_TALK[] = {0x80, 0xf3};
12269 -static UCHAR PlcpSignal[12] = {
12270 +static UCHAR PlcpSignal[12] = {
12271 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec
12272 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14
12273 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14
12274 static UINT _11G_RATES[12] = { 0, 0, 0, 0, 6, 9, 12, 18, 24, 36, 48, 54 };
12277 #define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _RxAnt, _rssi) \
12280 @@ -84,16 +84,16 @@
12282 Routine Description:
12283 Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound
12287 pRxD Pointer to the Rx descriptor
12291 NDIS_STATUS_SUCCESS No err
12292 NDIS_STATUS_FAILURE Error
12298 ========================================================================
12300 inline NDIS_STATUS RTMPCheckRxDescriptor(
12301 @@ -102,7 +102,7 @@
12304 return(NDIS_STATUS_FAILURE);
12309 return(NDIS_STATUS_FAILURE);
12310 @@ -120,15 +120,15 @@
12312 Routine Description:
12313 Endian conversion of Tx/Rx descriptor .
12317 pAdapter Pointer to our adapter
12318 pData Pointer to Tx/Rx descriptor
12319 DescriptorType Direction of the frame
12327 Call this function when read or update descriptor
12328 ========================================================================
12329 @@ -143,12 +143,26 @@
12330 *(ULONG *)pData = SWAP32(*(ULONG *)pData); // Byte 0; this must be swapped last
12333 +VOID WriteBackToDescriptor(IN PUCHAR Dest,
12335 + IN BOOLEAN DoEncrypt, IN ULONG DescriptorType)
12340 + p1 = ((PULONG) Dest) + 1;
12341 + p2 = ((PULONG) Src) + 1;
12342 + for (i = 1; i < RING_DESCRIPTOR_SIZE / 4; i++)
12344 + *(PULONG) Dest = *(PULONG) Src;
12348 ========================================================================
12350 Routine Description:
12351 Endian conversion of all kinds of 802.11 frames .
12355 pAdapter Pointer to our adapter
12356 pData Pointer to the 802.11 frame structure
12357 @@ -157,14 +171,14 @@
12364 Call this function when read or update buffer data
12365 ========================================================================
12367 VOID RTMPFrameEndianChange(
12368 - IN PRTMP_ADAPTER pAdapter,
12370 + IN PRTMP_ADAPTER pAdapter,
12373 IN BOOLEAN FromRxDoneInt)
12375 @@ -182,7 +196,7 @@
12377 // swab 16 bit fields - Duration/ID field
12378 *(USHORT *)(pMacHdr + 2) = SWAP16(*(USHORT *)(pMacHdr + 2));
12381 // swab 16 bit fields - Sequence Control field
12382 *(USHORT *)(pMacHdr + 22) = SWAP16(*(USHORT *)(pMacHdr + 22));
12384 @@ -210,7 +224,7 @@
12385 // swab 16 bit fields - Status Code field
12387 *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
12390 // swab 16 bit fields - AID field
12392 *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
12393 @@ -271,6 +285,7 @@
12394 *(USHORT *)pData = SWAP16(*(USHORT *)pData);
12401 @@ -353,14 +368,14 @@
12402 pAdapter->RalinkCounters.RxRingErrCount++;
12408 if(pAdapter->ate.Mode == ATE_RXFRAME)
12412 #endif //#ifdef RALINK_ATE
12415 // Point to Rx ring buffer where stores the real data frame
12416 pData = (PUCHAR) (pAdapter->RxRing[pAdapter->CurRxIndex].va_data_addr);
12417 // Cast to 802.11 header for flags checking
12418 @@ -372,11 +387,11 @@
12420 // Check for all RxD errors
12421 Status = RTMPCheckRxDescriptor(pRxD);
12424 // Apply packet filtering rule based on microsoft requirements.
12425 if (Status == NDIS_STATUS_SUCCESS)
12426 Status = RTMPApplyPacketFilter(pAdapter, pRxD, pHeader);
12429 // Add receive counters
12430 if (Status == NDIS_STATUS_SUCCESS)
12432 @@ -394,7 +409,7 @@
12433 // Increase general counters
12434 pAdapter->Counters.RxErrors++;
12438 // Check for retry bit, if this bit is on, search the cache with SA & sequence
12439 // as index, if matched, discard this frame, otherwise, update cache
12440 // This check only apply to unicast data & management frames
12441 @@ -453,7 +468,7 @@
12447 // Drop frame from AP while we are in Ad-hoc mode or not associated
12448 if (pHeader->Controlhead.Frame.FrDs)
12450 @@ -471,11 +486,11 @@
12456 // Good data frame appears, increase the counters
12457 INC_COUNTER(pAdapter->WlanCounters.ReceivedFragmentCount);
12458 - pAdapter->RalinkCounters.ReceivedByteCount += pRxD->DataByteCnt;
12460 + pAdapter->RalinkCounters.ReceivedByteCount += pRxD->DataByteCnt;
12462 // Process Multicast data frame
12465 @@ -486,18 +501,18 @@
12467 // Init WPA Key to NULL
12468 pWpaKey = (PWPA_KEY) NULL;
12471 // Find the WPA key, either Group or Pairwise Key
12472 if ((pAdapter->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pHeader->Controlhead.Frame.Wep))
12477 // First lookup the DA, if it's a group address, use GROUP key
12478 if (pRxD->Bcast || pRxD->Mcast)
12482 idx = (*(pData + 3) & 0xc0) >> 6;
12483 - if ((pAdapter->PortCfg.GroupKey[idx].KeyLen != 0) &&
12484 + if ((pAdapter->PortCfg.GroupKey[idx].KeyLen != 0) &&
12485 ((INFRA_ON(pAdapter) && (NdisEqualMemory(&pHeader->Controlhead.Addr2, &pAdapter->PortCfg.Bssid, 6))) ||
12486 (ADHOC_ON(pAdapter) && (NdisEqualMemory(&pHeader->Addr3, &pAdapter->PortCfg.Bssid, 6)))))
12488 @@ -520,15 +535,15 @@
12494 // Use default Group Key if there is no Pairwise key present
12495 if ((pWpaKey == NULL) && (pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0))
12497 - pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId];
12498 + pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId];
12499 pWpaKey->Type = GROUP_KEY;
12500 DBGPRINT(RT_DEBUG_INFO, "Rx Use Group Key\n");
12507 @@ -542,16 +557,16 @@
12508 Status = NDIS_STATUS_FAILURE;
12515 // Filter out Bcast frame which AP relayed for us
12516 if (pHeader->Controlhead.Frame.FrDs && RTMPEqualMemory(&pHeader->Addr3, pAdapter->CurrentAddress, 6))
12518 Status = NDIS_STATUS_FAILURE;
12525 // WEP encrypted frame
12526 if (pHeader->Controlhead.Frame.Wep)
12528 @@ -560,27 +575,27 @@
12530 KeyIdx = (*(pData + 3) & 0xc0) >> 6;
12531 memcpy((PUCHAR) &pRxD->Iv, pData, 4); //Get WEP IV
12532 - memcpy(pRxD->Key, pAdapter->PortCfg.SharedKey[KeyIdx].Key, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen);
12533 + memcpy(pRxD->Key, pAdapter->PortCfg.SharedKey[KeyIdx].Key, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen);
12534 if (pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen == 5)
12535 pRxD->CipherAlg = CIPHER_WEP64;
12537 - pRxD->CipherAlg = CIPHER_WEP128;
12538 + pRxD->CipherAlg = CIPHER_WEP128;
12540 else if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL)) // TKIP
12545 memcpy((PUCHAR) &pRxD->Iv, pData, 4); //Get WEP IV
12546 // Swap EIV byte order, due to ASIC's bug.
12547 Eiv_Tmp[0] = *(pData + 7);
12548 Eiv_Tmp[1] = *(pData + 6);
12549 Eiv_Tmp[2] = *(pData + 5);
12550 - Eiv_Tmp[3] = *(pData + 4);
12551 + Eiv_Tmp[3] = *(pData + 4);
12552 memcpy((PUCHAR) &pRxD->Eiv, Eiv_Tmp, 4); //Get WEP EIV
12553 // Copy TA into RxD
12554 memcpy(pRxD->TA, &pHeader->Controlhead.Addr2, 6);
12555 KeyIdx = (*(pData + 3) & 0xc0) >> 6;
12556 - memcpy(pRxD->Key, pWpaKey->Key, 16);
12557 + memcpy(pRxD->Key, pWpaKey->Key, 16);
12558 pRxD->CipherAlg = CIPHER_TKIP;
12560 else if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption3Enabled) && (pWpaKey != NULL)) // AES
12561 @@ -588,9 +603,9 @@
12562 memcpy((PUCHAR) &pRxD->Iv, pData, 4); //Get WEP IV
12563 memcpy((PUCHAR) &pRxD->Eiv, (pData + 4), 4); //Get WEP EIV
12564 // Copy TA into RxD
12565 - memcpy(pRxD->TA, &pHeader->Controlhead.Addr2, 6);
12566 + memcpy(pRxD->TA, &pHeader->Controlhead.Addr2, 6);
12567 KeyIdx = (*(pData + 3) & 0xc0) >> 6;
12568 - memcpy(pRxD->Key, pWpaKey->Key, 16);
12569 + memcpy(pRxD->Key, pWpaKey->Key, 16);
12570 pRxD->CipherAlg = CIPHER_AES;
12573 @@ -606,17 +621,17 @@
12574 pRxD->CipherAlg = CIPHER_NONE;
12579 // Begin process unicast to me frame
12580 else if (pRxD->U2M || pAdapter->bAcceptPromiscuous == TRUE)
12582 - // Send PS-Poll for AP to send next data frame
12583 + // Send PS-Poll for AP to send next data frame
12584 if ((pHeader->Controlhead.Frame.MoreData) && INFRA_ON(pAdapter) && (pAdapter->PortCfg.Psm == PWR_SAVE))
12586 EnqueuePsPoll(pAdapter);
12587 DBGPRINT(RT_DEBUG_TRACE, "Sending PS-POLL\n");
12592 // Begin frame processing
12594 @@ -634,11 +649,11 @@
12595 KeyIdx = (*(pData + 3) & 0xc0) >> 6;
12597 memcpy((PUCHAR) &pRxD->Iv, pData, 4); //Get WEP IV
12598 - memcpy(pRxD->Key, pAdapter->PortCfg.SharedKey[KeyIdx].Key, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen);
12599 + memcpy(pRxD->Key, pAdapter->PortCfg.SharedKey[KeyIdx].Key, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen);
12600 if (pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen == 5)
12601 pRxD->CipherAlg = CIPHER_WEP64;
12603 - pRxD->CipherAlg = CIPHER_WEP128;
12604 + pRxD->CipherAlg = CIPHER_WEP128;
12606 else if ((pAdapter->PortCfg.PrivacyFilter == Ndis802_11PrivFilter8021xWEP) &&
12607 (pHeader->Frag == 0))
12608 @@ -659,18 +674,18 @@
12609 if (pHeader->Controlhead.Frame.Wep)
12614 memcpy((PUCHAR) &pRxD->Iv, pData, 4); //Get WEP IV
12615 // Swap EIV byte order, due to ASIC's bug.
12616 Eiv_Tmp[0] = *(pData + 7);
12617 Eiv_Tmp[1] = *(pData + 6);
12618 Eiv_Tmp[2] = *(pData + 5);
12619 - Eiv_Tmp[3] = *(pData + 4);
12620 + Eiv_Tmp[3] = *(pData + 4);
12621 memcpy((PUCHAR) &pRxD->Eiv, Eiv_Tmp, 4); //Get WEP EIV
12622 KeyIdx = (*(pData + 3) & 0xc0) >> 6;
12623 // Copy TA into RxD
12624 memcpy(pRxD->TA, &pHeader->Controlhead.Addr2, 6);
12625 - memcpy(pRxD->Key, pWpaKey->Key, 16);
12626 + memcpy(pRxD->Key, pWpaKey->Key, 16);
12627 pRxD->CipherAlg = CIPHER_TKIP;
12629 else if ((pAdapter->PortCfg.PrivacyFilter == Ndis802_11PrivFilter8021xWEP) &&
12630 @@ -694,9 +709,9 @@
12631 memcpy((PUCHAR) &pRxD->Iv, pData, 4); //Get WEP IV
12632 memcpy((PUCHAR) &pRxD->Eiv, (pData + 4), 4); //Get WEP EIV
12633 // Copy TA into RxD
12634 - memcpy(pRxD->TA, &pHeader->Controlhead.Addr2, 6);
12635 + memcpy(pRxD->TA, &pHeader->Controlhead.Addr2, 6);
12636 KeyIdx = (*(pData + 3) & 0xc0) >> 6;
12637 - memcpy(pRxD->Key, pWpaKey->Key, 16);
12638 + memcpy(pRxD->Key, pWpaKey->Key, 16);
12639 pRxD->CipherAlg = CIPHER_AES;
12641 else if ((pAdapter->PortCfg.PrivacyFilter == Ndis802_11PrivFilter8021xWEP) &&
12642 @@ -719,7 +734,7 @@
12643 Status = NDIS_STATUS_FAILURE;
12648 else // Not encryptrd frames
12650 pRxD->CipherAlg = CIPHER_NONE;
12651 @@ -756,13 +771,14 @@
12653 pRxD->IvOffset = LENGTH_802_11;
12657 pRxD->CipherOwner = DESC_OWN_NIC;
12660 RTMPFrameEndianChange(pAdapter, (PUCHAR)pHeader, DIR_WRITE, TRUE);
12661 RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);
12663 + //*pDestRxD = RxD;
12664 + WriteBackToDescriptor((PUCHAR)pDestRxD, (PUCHAR)pRxD, TRUE, TYPE_RXD);
12667 pAdapter->CurRxIndex++;
12668 @@ -771,9 +787,9 @@
12669 pAdapter->CurRxIndex = 0;
12674 pAdapter->RalinkCounters.RxCount ++;
12677 } while (Count < MAX_RX_PROCESS);
12679 // Kick Decrypt Control Register, based on ASIC's implementation
12680 @@ -810,10 +826,10 @@
12683 unsigned long irqflag;
12686 // Make sure Tx ring resource won't be used by other threads
12687 spin_lock_irqsave(&pAdapter->TxRingLock, irqflag);
12693 @@ -832,22 +848,22 @@
12696 RTMPHardTransmitDone(
12701 pAdapter->TxRing[pAdapter->NextTxDoneIndex].FrameType);
12704 // It might happend with no Ndis packet to indicate back to upper layer
12705 // Clear for NdisSendComplete request
12706 pTxD->Valid = FALSE;
12709 // Increase Total transmit byte counter after real data sent out
12710 pAdapter->RalinkCounters.TransmittedByteCount += pTxD->DataByteCnt;
12714 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
12719 pAdapter->NextTxDoneIndex++;
12720 if (pAdapter->NextTxDoneIndex >= TX_RING_SIZE)
12722 @@ -885,16 +901,16 @@
12724 // Make sure to release Tx ring resource
12725 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
12728 if(pAdapter->bNetDeviceStopQueue)
12730 DBGPRINT(RT_DEBUG_TRACE, "NetDevice start queue!!!\n\n");
12731 pAdapter->bNetDeviceStopQueue = FALSE;
12732 netif_start_queue(pAdapter->net_dev);
12736 // Some Tx ring resource freed, check for pending send frame for hard transmit
12737 - if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
12738 + if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
12739 (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) &&
12740 (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)))
12742 @@ -932,10 +948,10 @@
12745 unsigned long irqflag;
12748 // Make sure Prio ring resource won't be used by other threads
12749 - spin_lock_irqsave(&pAdapter->PrioRingLock, irqflag);
12751 + spin_lock_irqsave(&pAdapter->PrioRingLock, irqflag);
12756 @@ -957,16 +973,16 @@
12762 // No need to put in reply for MLME
12763 RTMPHardTransmitDone(
12768 pAdapter->PrioRing[pAdapter->NextPrioDoneIndex].FrameType);
12771 // It might happend with no Ndis packet to indicate back to upper layer
12772 - pTxD->Valid = FALSE;
12774 + pTxD->Valid = FALSE;
12776 // Increase Total transmit byte counter after real data sent out
12777 pAdapter->RalinkCounters.TransmittedByteCount += pTxD->DataByteCnt;
12779 @@ -983,11 +999,11 @@
12780 } while (++Count < MAX_TX_PROCESS);
12782 // Make sure to release Prio ring resource
12783 - spin_unlock_irqrestore(&pAdapter->PrioRingLock, irqflag);
12785 + spin_unlock_irqrestore(&pAdapter->PrioRingLock, irqflag);
12787 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
12792 spin_lock_irqsave(&pAdapter->PrioRingLock, irqflag);
12793 if (pAdapter->PushMgmtIndex != pAdapter->PopMgmtIndex)
12794 @@ -1008,7 +1024,7 @@
12800 spin_unlock_irqrestore(&pAdapter->PrioRingLock, irqflag);
12803 @@ -1033,12 +1049,12 @@
12805 // PTXD_STRUC pTxD;
12809 // Make sure Atim ring resource won't be used by other threads
12810 //spin_lock_irqsave(&pAdapter->AtimRingLock);
12813 // Did not support ATIM, remove everything.
12816 // Make sure to release Atim ring resource
12817 //spin_unlock_irqrestore(&pAdapter->AtimRingLock);
12819 @@ -1083,10 +1099,10 @@
12821 struct sk_buff *skb;
12822 unsigned long irqflag;
12825 // Make sure Rx ring resource won't be used by other threads
12826 spin_lock_irqsave(&pAdapter->RxRingLock, irqflag);
12829 RTMP_IO_READ32(pAdapter, SECCSR0, &RegValue);
12830 HwDecryptIndex = RegValue - pAdapter->RxRing[0].pa_addr;
12831 do_div(HwDecryptIndex, RING_DESCRIPTOR_SIZE);
12832 @@ -1104,11 +1120,11 @@
12834 RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);
12838 // In case of false alarm or processed at last instance
12839 if ((pRxD->Owner != DESC_OWN_HOST) || (pRxD->CipherOwner != DESC_OWN_HOST))
12843 // Point to Rx ring buffer where stores the real data frame
12844 pData = (PUCHAR) (pAdapter->RxRing[pAdapter->CurDecryptIndex].va_data_addr);
12845 // Cast to 802.11 header for flags checking
12846 @@ -1117,15 +1133,18 @@
12848 RTMPFrameEndianChange(pAdapter, (PUCHAR)pHeader, DIR_READ, FALSE);
12850 - // Driver will check the decrypt algorithm and decide whether this ICV is true or not
12851 + // Driver will check the decrypt algorithm and decide whether this ICV is true or not
12852 if ((pRxD->IcvError == 1) && (pRxD->CipherAlg == CIPHER_NONE))
12853 pRxD->IcvError = 0;
12856 // Since we already process header at RxDone interrupt, there is no need to proces
12857 // header sanity again, the only thing we have to check is icv_err bit
12858 - if (pRxD->IcvError == 1)
12859 + //if (pRxD->IcvError == 1)
12860 + if ((pRxD->IcvError == 1) && (pRxD->CipherAlg != CIPHER_NONE))
12862 - DBGPRINT(RT_DEBUG_TRACE,"Rx DecryptDone - ICV error (len %d)\n", pRxD->DataByteCnt);
12863 + DBGPRINT(RT_DEBUG_TRACE,
12864 + "Rx DecryptDone - ICV error (CipherAlg=%d) (len %d)\n",
12865 + pRxD->CipherAlg, pRxD->DataByteCnt);
12866 pRxD->Drop =1; // Drop frame with icv error
12868 // Saved data pointer for management frame which will pass to MLME block
12869 @@ -1135,7 +1154,7 @@
12871 struct sk_buff *skb;
12872 wlan_ng_prism2_header *ph;
12875 if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL)
12877 if (pAdapter->PortCfg.MallowRFMONTx == TRUE)
12878 @@ -1196,12 +1215,12 @@
12880 skb->dev = pAdapter->net_dev;
12881 memcpy(skb_put(skb, pRxD->DataByteCnt), pData, pRxD->DataByteCnt);
12882 - skb->mac.raw = skb->data;
12883 + skb_reset_mac_header(skb);
12884 skb->pkt_type = PACKET_OTHERHOST;
12885 skb->protocol = htons(ETH_P_802_2);
12886 skb->ip_summed = CHECKSUM_NONE;
12893 @@ -1211,7 +1230,7 @@
12894 // The total available payload should exclude 24-byte 802.11 Header
12895 // If Security is enabled, IV, EIV, ICV size is excluded by ASIC
12896 PacketSize = (USHORT) pRxD->DataByteCnt - LENGTH_802_11;
12899 // Find the WPA key, either Group or Pairwise Key
12900 // Although the data has been decrypted by ASIC,
12901 // driver has to calculate the RxMIC which required the key.
12902 @@ -1221,7 +1240,7 @@
12903 if ((pAdapter->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pHeader->Controlhead.Frame.Wep))
12908 // First lookup the DA, if it's a group address, use GROUP key
12909 if (pRxD->Bcast || pRxD->Mcast)
12911 @@ -1231,7 +1250,7 @@
12913 idx = (pRxD->Iv & 0xc0000000) >> 30;
12915 - if ((pAdapter->PortCfg.GroupKey[idx].KeyLen != 0) &&
12916 + if ((pAdapter->PortCfg.GroupKey[idx].KeyLen != 0) &&
12917 ((INFRA_ON(pAdapter) && (NdisEqualMemory(&pHeader->Controlhead.Addr2, &pAdapter->PortCfg.Bssid, 6))) ||
12918 (ADHOC_ON(pAdapter) && (NdisEqualMemory(&pHeader->Addr3, &pAdapter->PortCfg.Bssid, 6)))))
12920 @@ -1254,22 +1273,22 @@
12926 // Use default Group Key if there is no Pairwise key present
12927 if ((pWpaKey == NULL) && (pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0))
12929 - pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId];
12930 + pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.GroupKey[pAdapter->PortCfg.DefaultKeyId];
12931 pWpaKey->Type = GROUP_KEY;
12932 DBGPRINT(RT_DEBUG_INFO, "Rx Use Group Key\n");
12938 // If there is no WPA key matched, this frame should be dropped
12939 if (pWpaKey == NULL)
12945 // Start of main loop to parse receiving frames.
12946 // The sequence will be Type first, then subtype...
12947 @@ -1287,10 +1306,10 @@
12948 pSrcMac = (PUCHAR) &(pHeader->Addr3);
12950 pSrcMac = (PUCHAR) &(pHeader->Controlhead.Addr2);
12953 // Process Broadcast & Multicast data frame
12954 if (pRxD->Bcast || pRxD->Mcast)
12957 // For TKIP frame, calculate the MIC value
12958 if (pRxD->CipherAlg == CIPHER_TKIP)
12960 @@ -1302,7 +1321,7 @@
12961 Status = NDIS_STATUS_FAILURE;
12966 // Minus MIC length
12968 if (RTMPTkipCompareMICValue(
12969 @@ -1313,7 +1332,7 @@
12971 PacketSize) == FALSE)
12973 - DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error\n");
12974 + DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error\n");
12975 RTMPReportMicError(pAdapter, pWpaKey);
12976 Status = NDIS_STATUS_FAILURE;
12978 @@ -1329,21 +1348,17 @@
12979 // Rx TSC has done one full cycle, since re-key is done by transmitter
12980 // We did not do anything for Rx path
12984 // build 802.3 header and decide if remove the 8-byte LLC/SNAP encapsulation
12985 CONVERT_TO_802_3(Header802_3, pDestMac, pSrcMac, pData, PacketSize);
12988 pAdapter->PortCfg.LedCntl.fRxActivity = TRUE; // for RX ACTIVITY LED
12990 // For miniportTransferData
12991 pAdapter->pRxData = pData;
12994 // Acknolwdge upper layer the received frame
12995 -#ifdef RTMP_EMBEDDED
12996 if ((skb = __dev_alloc_skb(PacketSize + LENGTH_802_3 + 2, GFP_DMA|GFP_ATOMIC)) != NULL)
12998 - if ((skb = dev_alloc_skb(PacketSize + LENGTH_802_3 + 2)) != NULL)
13001 skb->dev = pAdapter->net_dev;
13002 skb_reserve(skb, 2); // 16 byte align the IP header
13003 @@ -1354,10 +1369,10 @@
13004 pAdapter->net_dev->last_rx = jiffies;
13005 pAdapter->stats.rx_packets++;
13009 DBGPRINT(RT_DEBUG_INFO, "!!! Broadcast Ethenet rx Indicated !!!\n");
13013 // Begin process unicast to me frame
13014 else if (pRxD->U2M || pAdapter->bAcceptPromiscuous == TRUE)
13016 @@ -1383,12 +1398,12 @@
13017 else if (pRxD->BBR0 == 110)
13018 pAdapter->LastRxRate = 3;
13022 if (pHeader->Frag == 0) // First or Only fragment
13024 // For TKIP frame, calculate the MIC value
13025 if ((pHeader->Controlhead.Frame.MoreFrag == FALSE) &&
13026 - (pRxD->CipherAlg == CIPHER_TKIP) &&
13027 + (pRxD->CipherAlg == CIPHER_TKIP) &&
13028 (pHeader->Controlhead.Frame.Wep))
13030 if (pWpaKey == NULL)
13031 @@ -1407,17 +1422,17 @@
13033 PacketSize) == FALSE)
13035 - DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error\n");
13036 + DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error\n");
13037 RTMPReportMicError(pAdapter, pWpaKey);
13038 Status = NDIS_STATUS_FAILURE;
13044 pAdapter->FragFrame.Flags &= 0xFFFFFFFE;
13047 // Check for encapsulation other than RFC1042 & Bridge tunnel
13048 - if ((!RTMPEqualMemory(SNAP_802_1H, pData, 6)) &&
13049 + if ((!RTMPEqualMemory(SNAP_802_1H, pData, 6)) &&
13050 (!RTMPEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6)))
13052 LLC_Len[0] = PacketSize / 256;
13053 @@ -1427,13 +1442,13 @@
13056 char *pProto = pData + 6;
13059 // Remove 802.11 H header & reconstruct 802.3 header
13060 // pData += (LENGTH_802_1_H - LENGTH_802_3_TYPE);
13061 // Check for EAPOL frame when driver supplicant enabled
13062 // TODO: It is not strickly correct. There is no fragment handling. It might damage driver
13063 // TODO: But for WPAPSK, it's not likely fragment on EAPOL frame will happen
13064 - if (RTMPEqualMemory(EAPOL, pProto, 2) && ((pAdapter->PortCfg.WpaState != SS_NOTUSE)))
13065 + if (RTMPEqualMemory(EAPOL, pProto, 2) && ((pAdapter->PortCfg.WpaState != SS_NOTUSE)))
13067 RTMP_IO_READ32(pAdapter, CSR17, &High32TSF); // TSF value
13068 RTMP_IO_READ32(pAdapter, CSR16, &Low32TSF); // TSF vlaue
13069 @@ -1441,16 +1456,16 @@
13070 // Enqueue this frame to MLME engine
13071 MlmeEnqueueForRecv(
13073 - &pAdapter->Mlme.Queue,
13075 + &pAdapter->Mlme.Queue,
13078 - (UCHAR)pRxD->BBR1, (UCHAR)pAdapter->PortCfg.LastR17Value,
13081 + (UCHAR)pRxD->BBR1, (UCHAR)pAdapter->PortCfg.LastR17Value,
13087 - if ((RTMPEqualMemory(IPX, pProto, 2) || RTMPEqualMemory(APPLE_TALK, pProto, 2)) &&
13088 + if ((RTMPEqualMemory(IPX, pProto, 2) || RTMPEqualMemory(APPLE_TALK, pProto, 2)) &&
13089 RTMPEqualMemory(SNAP_802_1H, pData, 6))
13091 // preserved the LLC/SNAP filed
13092 @@ -1468,21 +1483,17 @@
13093 pAdapter->FragFrame.Flags |= 0x01;
13098 // One & The only fragment
13099 if (pHeader->Controlhead.Frame.MoreFrag == FALSE)
13101 // For miniportTransferData
13102 pAdapter->pRxData = pData;
13105 pAdapter->PortCfg.LedCntl.fRxActivity = TRUE; // for RX ACTIVITY LED
13107 // Acknowledge upper layer the received frame
13108 -#ifdef RTMP_EMBEDDED
13109 if ((skb = __dev_alloc_skb(PacketSize + LENGTH_802_3 + 2, GFP_DMA|GFP_ATOMIC)) != NULL)
13111 - if ((skb = dev_alloc_skb(PacketSize + LENGTH_802_3 + 2)) != NULL)
13114 skb->dev = pAdapter->net_dev;
13115 skb_reserve(skb, 2); // 16 byte align the IP header
13116 @@ -1499,7 +1510,7 @@
13118 // Increase general counters
13119 pAdapter->Counters.GoodReceives++;
13123 // First fragment of fragmented frames
13125 @@ -1516,7 +1527,7 @@
13128 // No LLC-SNAP header in except the first fragment frame
13131 if ((pHeader->Sequence != pAdapter->FragFrame.Sequence) ||
13132 (pHeader->Frag != (pAdapter->FragFrame.LastFrag + 1)))
13134 @@ -1525,7 +1536,7 @@
13135 memset(&pAdapter->FragFrame, 0, sizeof(FRAGMENT_FRAME));
13136 Status = NDIS_STATUS_FAILURE;
13140 else if ((pAdapter->FragFrame.RxSize + PacketSize) > MAX_FRAME_SIZE)
13142 // Fragment frame is too large, it exeeds the maximum frame size.
13143 @@ -1535,12 +1546,12 @@
13144 Status = NDIS_STATUS_FAILURE;
13149 // concatenate this fragment into the re-assembly buffer
13150 memcpy(&pAdapter->FragFrame.Buffer[LENGTH_802_3 + pAdapter->FragFrame.RxSize], pData, PacketSize);
13151 pAdapter->FragFrame.RxSize += PacketSize;
13152 pAdapter->FragFrame.LastFrag = pHeader->Frag; // Update fragment number
13156 if (pHeader->Controlhead.Frame.MoreFrag == FALSE)
13158 @@ -1555,7 +1566,7 @@
13160 // Minus MIC length
13161 pAdapter->FragFrame.RxSize -= 8;
13164 if (pAdapter->FragFrame.Flags & 0x00000001)
13166 // originally there's an LLC/SNAP field in the first fragment
13167 @@ -1563,9 +1574,9 @@
13168 // this LLC/SNAP field upon calculating TKIP MIC
13169 // Copy LLC data to the position in front of real data for MIC calculation
13170 memcpy(&pAdapter->FragFrame.Buffer[LENGTH_802_3 - LENGTH_802_1_H],
13171 - pAdapter->FragFrame.Header_LLC,
13172 + pAdapter->FragFrame.Header_LLC,
13174 - pData = (PUCHAR) &pAdapter->FragFrame.Buffer[LENGTH_802_3 - LENGTH_802_1_H];
13175 + pData = (PUCHAR) &pAdapter->FragFrame.Buffer[LENGTH_802_3 - LENGTH_802_1_H];
13176 PacketSize = (USHORT)pAdapter->FragFrame.RxSize + LENGTH_802_1_H;
13177 //cketSize = (USHORT)pAdapter->FragFrame.RxSize + 8;
13179 @@ -1583,29 +1594,25 @@
13181 PacketSize) == FALSE)
13183 - DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error 2\n");
13184 + DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error 2\n");
13185 RTMPReportMicError(pAdapter, pWpaKey);
13186 Status = NDIS_STATUS_FAILURE;
13192 // Getting RxTSC from Rx descriptor
13196 // for RX ACTIVITY LED
13197 - pAdapter->PortCfg.LedCntl.fRxActivity = TRUE;
13198 + pAdapter->PortCfg.LedCntl.fRxActivity = TRUE;
13200 // For miniportTransferData
13201 pAdapter->pRxData = &pAdapter->FragFrame.Buffer[LENGTH_802_3];
13203 memcpy(pAdapter->FragFrame.Buffer, pAdapter->FragFrame.Header802_3, LENGTH_802_3);
13204 // Acknowledge upper layer the received frame
13205 -#ifdef RTMP_EMBEDDED
13206 if ((skb = __dev_alloc_skb(pAdapter->FragFrame.RxSize + LENGTH_802_3 + 2, GFP_DMA|GFP_ATOMIC)) != NULL)
13208 - if ((skb = dev_alloc_skb(pAdapter->FragFrame.RxSize + LENGTH_802_3 + 2)) != NULL)
13211 skb->dev = pAdapter->net_dev;
13212 skb_reserve(skb, 2); /* 16 byte align the IP header */
13213 @@ -1619,7 +1626,7 @@
13215 // Increase general counters
13216 pAdapter->Counters.GoodReceives++;
13219 // Clear Fragment frame contents
13220 memset(&pAdapter->FragFrame, 0, sizeof(FRAGMENT_FRAME));
13221 DBGPRINT(RT_DEBUG_INFO, "!!! Frame with Fragment Indicated !!!\n");
13222 @@ -1627,42 +1634,42 @@
13229 // Read required regsiter for MLME engine
13230 RTMP_IO_READ32(pAdapter, CSR17, &High32TSF); // TSF value
13231 RTMP_IO_READ32(pAdapter, CSR16, &Low32TSF); // TSF vlaue
13234 // Enqueue this frame to MLME engine
13235 MlmeEnqueueForRecv(
13237 - &pAdapter->Mlme.Queue,
13239 + &pAdapter->Mlme.Queue,
13243 - (UCHAR)pAdapter->PortCfg.LastR17Value,
13244 - pRxD->DataByteCnt,
13246 + (UCHAR)pAdapter->PortCfg.LastR17Value,
13247 + pRxD->DataByteCnt,
13263 pAdapter->CurDecryptIndex++;
13264 if (pAdapter->CurDecryptIndex >= RX_RING_SIZE)
13266 pAdapter->CurDecryptIndex = 0;
13271 pAdapter->RalinkCounters.DecryptCount ++;
13274 // Clear Cipherowner bit & Rx Owner bit for all drop & non-drop frames
13275 pRxD->CipherOwner = DESC_OWN_HOST;
13276 pRxD->Owner = DESC_OWN_NIC;
13277 @@ -1673,7 +1680,7 @@
13279 //} while (Count < RX_RING_SIZE);
13280 //} while (pAdapter->CurDecryptIndex != HwDecryptIndex);
13283 // Make sure to release Rx ring resource
13284 spin_unlock_irqrestore(&pAdapter->RxRingLock, irqflag);
13286 @@ -1706,10 +1713,10 @@
13288 ULONGLONG HwEncryptIndex;
13289 unsigned long irqflag;
13292 // Make sure Prio ring resource won't be used by other threads
13293 - spin_lock_irqsave(&pAdapter->TxRingLock, irqflag);
13295 + spin_lock_irqsave(&pAdapter->TxRingLock, irqflag);
13297 RTMP_IO_READ32(pAdapter, SECCSR1, &RegValue);
13298 HwEncryptIndex = RegValue - pAdapter->TxRing[0].pa_addr;
13299 do_div(HwEncryptIndex, RING_DESCRIPTOR_SIZE);
13300 @@ -1749,17 +1756,18 @@
13301 *pTmp = Eiv_Tmp[3];
13302 *(pTmp + 1) = Eiv_Tmp[2];
13303 *(pTmp + 2) = Eiv_Tmp[1];
13304 - *(pTmp + 3) = Eiv_Tmp[0];
13305 + *(pTmp + 3) = Eiv_Tmp[0];
13307 // Sanity Check, CurTxIndex should equal to NextEncryptDoneIndex
13308 // ASSERT(pAdapter->CurTxIndex == pAdapter->NextEncryptDoneIndex);
13311 pTxD->Valid = TRUE;
13312 pTxD->Owner = DESC_OWN_NIC;
13315 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
13317 + //*pDestTxD = TxD;
13318 + WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
13321 pAdapter->NextEncryptDoneIndex++;
13322 @@ -1778,9 +1786,9 @@
13324 // Kick Tx Control Register at the end of all ring buffer preparation
13325 RTMP_IO_WRITE32(pAdapter, TXCSR0, 0x1);
13328 // Make sure to release Tx ring resource
13329 - spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
13330 + spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
13334 @@ -1854,7 +1862,7 @@
13335 INC_COUNTER(pAdapter->WlanCounters.RTSSuccessCount);
13340 // Increase general counters
13341 pAdapter->Counters.GoodTransmits++;
13342 INC_COUNTER(pAdapter->WlanCounters.TransmittedFragmentCount);
13343 @@ -1865,22 +1873,22 @@
13344 pAdapter->DrsCounters.OneSecTxOkCount ++;
13349 case SUCCESS_WITH_RETRY: // Success with some retry
13350 // DBGPRINT(RT_DEBUG_INFO, "TX Success with retry(=%d)<<<\n",pTxD->RetryCount);
13351 // Increase 802.11 counters
13352 INC_COUNTER(pAdapter->WlanCounters.RetryCount);
13353 INC_COUNTER(pAdapter->WlanCounters.ACKFailureCount);
13354 INC_COUNTER(pAdapter->WlanCounters.TransmittedFragmentCount);
13357 // Increase general counters
13358 pAdapter->Counters.GoodTransmits++;
13361 if (pTxD->RetryCount > 1)
13363 // Increase 802.11 counters
13364 INC_COUNTER(pAdapter->WlanCounters.MultipleRetryCount);
13367 // Increase general counters
13368 pAdapter->Counters.MoreCollisions++;
13370 @@ -1889,7 +1897,7 @@
13371 // Increase general counters
13372 pAdapter->Counters.OneCollision++;
13378 INC_COUNTER(pAdapter->WlanCounters.RTSSuccessCount);
13379 @@ -1901,7 +1909,7 @@
13381 if (pTxD->TxRate > pAdapter->PortCfg.TxRate)
13383 - // DRS - must be NULL frame retried @ UpRate; downgrade
13384 + // DRS - must be NULL frame retried @ UpRate; downgrade
13385 // TxQuality[UpRate] so that not upgrade TX rate
13386 pAdapter->DrsCounters.TxQuality[pTxD->TxRate] += 2;
13387 if (pAdapter->DrsCounters.TxQuality[pTxD->TxRate] > DRS_TX_QUALITY_WORST_BOUND)
13388 @@ -1917,10 +1925,10 @@
13389 // Increase 802.11 counters
13390 INC_COUNTER(pAdapter->WlanCounters.FailedCount);
13391 INC_COUNTER(pAdapter->WlanCounters.ACKFailureCount);
13394 // Increase general counters
13395 pAdapter->Counters.TxErrors++;
13400 INC_COUNTER(pAdapter->WlanCounters.RTSFailureCount);
13401 @@ -1932,7 +1940,7 @@
13403 if (pTxD->TxRate > pAdapter->PortCfg.TxRate)
13405 - // DRS - must be NULL frame failed @ UpRate; downgrade
13406 + // DRS - must be NULL frame failed @ UpRate; downgrade
13407 // TxQuality[UpRate] so that not upgrade TX rate
13408 pAdapter->DrsCounters.TxQuality[pTxD->TxRate] = DRS_TX_QUALITY_WORST_BOUND;
13410 @@ -1942,35 +1950,35 @@
13417 // DBGPRINT(RT_DEBUG_WARN, ("TX Failed (INVALID)<<<\n"));
13418 // Increase general counters
13419 pAdapter->Counters.TxErrors++;
13424 INC_COUNTER(pAdapter->WlanCounters.RTSFailureCount);
13433 // DBGPRINT(RT_DEBUG_ERROR, ("TX Failed (other=%d)<<<\n",pTxD->TxResult));
13434 // Increase 802.11 counters
13435 INC_COUNTER(pAdapter->WlanCounters.FailedCount);
13436 INC_COUNTER(pAdapter->WlanCounters.ACKFailureCount);
13439 // Increase general counters
13440 pAdapter->Counters.TxErrors++;
13445 INC_COUNTER(pAdapter->WlanCounters.RTSFailureCount);
13453 @@ -1980,19 +1988,19 @@
13454 Routine Description:
13455 API for MLME to transmit management frame to AP (BSS Mode)
13456 or station (IBSS Mode)
13460 pAdapter Pointer to our adapter
13461 Buffer Pointer to memory of outgoing frame
13462 Length Size of outgoing management frame
13466 NDIS_STATUS_FAILURE
13467 NDIS_STATUS_PENDING
13468 NDIS_STATUS_SUCCESS
13473 ========================================================================
13475 NDIS_STATUS MiniportMMRequest(
13476 @@ -2001,28 +2009,28 @@
13480 - NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
13481 + NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
13482 unsigned long irqflag;
13484 DBGPRINT(RT_DEBUG_INFO, "---> MiniportMMRequest\n");
13485 // Check management ring free avaliability
13486 pMgmt = (PMGMT_STRUC) &pAdapter->MgmtRing[pAdapter->PushMgmtIndex];
13489 // This management cell has been occupied
13490 - if (pMgmt->Valid == TRUE)
13491 + if (pMgmt->Valid == TRUE)
13493 // No Management ring buffer avaliable
13494 MlmeFreeMemory(pAdapter, pBuffer);
13495 - Status = NDIS_STATUS_FAILURE;
13496 + Status = NDIS_STATUS_FAILURE;
13497 DBGPRINT(RT_DEBUG_WARN, "<--- MiniportMMRequest (error:: MgmtRing full)\n");
13498 pAdapter->RalinkCounters.MgmtRingFullCount++;
13503 // Insert this request into software managemnet ring
13506 - pMgmt->pBuffer = pBuffer;
13507 + pMgmt->pBuffer = pBuffer;
13508 pMgmt->Length = Length;
13509 pMgmt->Valid = TRUE;
13510 pAdapter->PushMgmtIndex++;
13511 @@ -2031,19 +2039,19 @@
13513 pAdapter->PushMgmtIndex = 0;
13519 // Null pBuffer, no need to free memory buffer.
13520 // This should not happen
13521 DBGPRINT(RT_DEBUG_WARN, "<--- MiniportMMRequest (error:: NULL msg)\n");
13522 - Status = NDIS_STATUS_FAILURE;
13523 + Status = NDIS_STATUS_FAILURE;
13528 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
13532 // Check Free priority queue
13533 spin_lock_irqsave(&pAdapter->PrioRingLock, irqflag);
13534 if (RTMPFreeDescriptorRequest(pAdapter, PRIO_RING, 1) == NDIS_STATUS_SUCCESS)
13535 @@ -2076,21 +2084,21 @@
13536 ========================================================================
13538 Routine Description:
13539 - Copy frame from waiting queue into relative ring buffer and set
13540 + Copy frame from waiting queue into relative ring buffer and set
13541 appropriate ASIC register to kick hardware transmit function
13545 pAdapter Pointer to our adapter
13546 pBuffer Pointer to memory of outgoing frame
13547 Length Size of outgoing management frame
13551 NDIS_STATUS_FAILURE
13552 NDIS_STATUS_PENDING
13553 NDIS_STATUS_SUCCESS
13558 ========================================================================
13560 VOID MlmeHardTransmit(
13561 @@ -2103,15 +2111,15 @@
13562 PTXD_STRUC pDestTxD;
13567 PHEADER_802_11 pHeader_802_11;
13568 BOOLEAN AckRequired, InsertTimestamp;
13571 DBGPRINT(RT_DEBUG_INFO, "MlmeHardTransmit\n");
13574 // Make sure Prio ring resource won't be used by other threads
13576 - pDest = (PUCHAR) pAdapter->PrioRing[pAdapter->CurPrioIndex].va_data_addr;
13578 + pDest = (PUCHAR) pAdapter->PrioRing[pAdapter->CurPrioIndex].va_data_addr;
13580 pTxD = (PTXD_STRUC) pAdapter->PrioRing[pAdapter->CurPrioIndex].va_addr;
13582 @@ -2120,7 +2128,7 @@
13584 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
13588 if (pTxD->Owner == DESC_OWN_NIC)
13590 // Descriptor owned by NIC. No descriptor avaliable
13591 @@ -2138,10 +2146,10 @@
13592 // The buffer shouldn't be NULL
13596 - // outgoing frame always wakeup PHY to prevent frame lost
13598 + // outgoing frame always wakeup PHY to prevent frame lost
13599 AsicForceWakeup(pAdapter);
13602 pHeader_802_11 = (PHEADER_802_11) pBuffer;
13603 pHeader_802_11->Controlhead.Frame.PwrMgt = 0; // (pAdapter->PortCfg.Psm == PWR_SAVE);
13604 InsertTimestamp = FALSE;
13605 @@ -2175,7 +2183,7 @@
13606 RTMPFrameEndianChange(pAdapter, (PUCHAR)pBuffer, DIR_WRITE, FALSE);
13608 memcpy(pDest, pBuffer, Length);
13611 // Initialize Priority Descriptor
13612 // For inter-frame gap, the number is for this frame and next frame
13613 // For MLME rate, we will fix as 2Mb to match other vendor's implement
13614 @@ -2193,28 +2201,28 @@
13616 pAdapter->CurPrioIndex = 0;
13620 // Kick priority ring transmit
13621 RTMP_IO_WRITE32(pAdapter,TXCSR0,0x4);
13624 // Make sure to release Prio ring resource
13628 ========================================================================
13630 Routine Description:
13631 This routine is used to en-queue outgoing packets when
13632 there is no enough shread memory
13636 pAdapter Pointer to our adapter
13637 pPacket Pointer to send packet
13646 ========================================================================
13648 NDIS_STATUS RTMPSendPacket(
13649 @@ -2225,51 +2233,42 @@
13650 UINT AllowFragSize;
13651 UCHAR NumberOfFrag;
13653 - NDIS_STATUS Status = NDIS_STATUS_FAILURE;
13657 struct sk_buff_head *pTxQueue = NULL;
13659 UCHAR AccessCategory;
13660 unsigned long irqflag;
13662 - DBGPRINT(RT_DEBUG_INFO, "<==== RTMPSendPacket\n");
13664 - // Init priority value
13666 - AccessCategory = 0;
13670 - Priority = skb->priority;
13671 - // 802.11e/d4.4 June, 2003
13672 - if (Priority <=2)
13673 - AccessCategory = 0;
13674 - else if (Priority == 3)
13675 - AccessCategory = 1;
13676 - else if (Priority <= 5)
13677 - AccessCategory = 2;
13679 - AccessCategory = 3;
13680 - DBGPRINT(RT_DEBUG_INFO, "Priority = %d, AC = %d\n", Priority, AccessCategory);
13682 + DBGPRINT(RT_DEBUG_INFO, "====> RTMPSendPacket\n");
13685 + return NDIS_STATUS_SUCCESS;
13687 + Priority = skb->priority;
13688 + // 802.11e/d4.4 June, 2003
13689 + if (Priority <=2)
13690 + AccessCategory = 0;
13691 + else if (Priority == 3)
13692 + AccessCategory = 1;
13693 + else if (Priority <= 5)
13694 + AccessCategory = 2;
13696 + AccessCategory = 3;
13697 + DBGPRINT(RT_DEBUG_INFO, "Priority = %d, AC = %d\n", Priority,
13700 // For TKIP, MIC value is treated as payload, it might be fragmented through
13701 // different MPDUs.
13702 if (pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled)
13704 skb->data_len += 8;
13707 pVirtualAddress = (PVOID)skb->data;
13709 // Check for virtual address allocation, it might fail !!!
13710 if (pVirtualAddress == NULL)
13712 - // Resourece is low, system did not allocation virtual address
13713 + // Resource is low, system did not allocate virtual address
13714 // return NDIS_STATUS_FAILURE directly to upper layer
13717 + return NDIS_STATUS_FAILURE;
13719 // Store Ethernet MAC address when APClinet mode on
13720 if ((pAdapter->PortCfg.StaWithEtherBridge.Enable)
13721 @@ -2296,7 +2295,7 @@
13722 pAdapter->CurrentAddress[3] = StaMacReg0.field.Byte3;
13723 pAdapter->CurrentAddress[4] = StaMacReg1.field.Byte4;
13724 pAdapter->CurrentAddress[5] = StaMacReg1.field.Byte5;
13727 RTMP_IO_WRITE32(pAdapter, CSR3, StaMacReg0.word);
13728 RTMP_IO_WRITE32(pAdapter, CSR4, StaMacReg1.word);
13730 @@ -2304,7 +2303,7 @@
13731 pAdapter->PortCfg.StaWithEtherBridge.EtherMacAddr.Octet[0],pAdapter->PortCfg.StaWithEtherBridge.EtherMacAddr.Octet[1],pAdapter->PortCfg.StaWithEtherBridge.EtherMacAddr.Octet[2],
13732 pAdapter->PortCfg.StaWithEtherBridge.EtherMacAddr.Octet[3],pAdapter->PortCfg.StaWithEtherBridge.EtherMacAddr.Octet[4],pAdapter->PortCfg.StaWithEtherBridge.EtherMacAddr.Octet[5]);
13737 // Check for multicast or broadcast (First byte of DA)
13739 @@ -2322,37 +2321,30 @@
13740 NumberOfFrag = ((skb->data_len - LENGTH_802_3 + LENGTH_802_1_H) / AllowFragSize) + 1;
13741 // Minus 1 if the size just match to allowable fragment size
13742 if (((skb->data_len - LENGTH_802_3 + LENGTH_802_1_H) % AllowFragSize) == 0)
13748 - // Check for requirement of RTS
13749 + // Check for requirement of RTS
13750 if (NumberOfFrag > 1)
13752 // If multiple fragment required, RTS is required only for the first fragment
13753 // if the fragment size large than RTS threshold
13754 RTSRequired = (pAdapter->PortCfg.FragmentThreshold > pAdapter->PortCfg.RtsThreshold) ? 1 : 0;
13758 RTSRequired = (skb->data_len > pAdapter->PortCfg.RtsThreshold) ? 1 : 0;
13760 - DBGPRINT(RT_DEBUG_INFO, "Number of fragments include RTS :%d\n", NumberOfFrag + RTSRequired);
13761 + DBGPRINT(RT_DEBUG_INFO,
13762 + "Number of fragments include RTS :%d\n",
13763 + NumberOfFrag + RTSRequired);
13765 + // RTS/CTS may also be required in order to protect OFDM frame
13766 + if ((pAdapter->PortCfg.TxRate >= RATE_FIRST_OFDM_RATE) && pAdapter->PortCfg.BGProtectionInUsed)
13769 - // RTS/CTS may also be required in order to protect OFDM frame
13770 - if ((pAdapter->PortCfg.TxRate >= RATE_FIRST_OFDM_RATE) && pAdapter->PortCfg.BGProtectionInUsed)
13773 // Save framnet number to Ndis packet reserved field
13774 RTMP_SET_PACKET_FRAGMENTS(skb, NumberOfFrag);
13776 // Save RTS requirement to Ndis packet reserved field
13777 RTMP_SET_PACKET_RTS(skb, RTSRequired);
13779 - // Make sure SendTxWait queue resource won't be used by other threads
13780 - spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13782 // Select the right priority queue
13783 // There should be no else statement since it should always fall within 0-3
13784 if (AccessCategory== 0)
13785 @@ -2363,56 +2355,49 @@
13786 pTxQueue = &pAdapter->TxSwQueue2;
13787 else if (AccessCategory== 3)
13788 pTxQueue = &pAdapter->TxSwQueue3;
13792 // For infrastructure mode, enqueue this frame immediately to sendwaitqueue
13793 // For Ad-hoc mode, check the DA power state, then decide which queue to enqueue
13795 - if (INFRA_ON(pAdapter))
13797 - // In infrastructure mode, simply enqueue the packet into Tx waiting queue.
13798 - DBGPRINT(RT_DEBUG_INFO, "Infrastructure -> Enqueue one frame\n");
13800 - // Enqueue Ndis packet to end of Tx wait queue
13801 - skb_queue_tail(pTxQueue, skb);
13802 - Status = NDIS_STATUS_SUCCESS;
13806 - // In IBSS mode, power state of destination should be considered.
13807 - PsMode = PWR_ACTIVE; // Faked
13808 - if (PsMode == PWR_ACTIVE)
13810 - DBGPRINT(RT_DEBUG_INFO,"Ad-Hoc -> Enqueue one frame\n");
13812 + if (INFRA_ON(pAdapter)) {
13813 + // In infrastructure mode, simply enqueue the packet into Tx waiting queue.
13814 + DBGPRINT(RT_DEBUG_INFO,
13815 + "<=== RTMPSendPacket Infrastructure -> Enqueue one frame\n");
13816 // Enqueue Ndis packet to end of Tx wait queue
13817 + spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13818 skb_queue_tail(pTxQueue, skb);
13819 - Status = NDIS_STATUS_SUCCESS;
13821 + spin_unlock_irqrestore(&pAdapter->TxSwQueueLock, irqflag);
13822 + return NDIS_STATUS_SUCCESS;
13825 + // Ad-hoc mode (power state of destination might be considered).
13826 + DBGPRINT(RT_DEBUG_INFO,
13827 + "<=== RTMPSendPacket Ad-Hoc -> Enqueue one frame\n");
13828 + // Enqueue Ndis packet to end of Tx wait queue
13829 + spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13830 + skb_queue_tail(pTxQueue, skb);
13831 spin_unlock_irqrestore(&pAdapter->TxSwQueueLock, irqflag);
13833 + return NDIS_STATUS_SUCCESS;
13837 ========================================================================
13839 Routine Description:
13840 - To do the enqueue operation and extract the first item of waiting
13841 - list. If a number of available shared memory segments could meet
13842 + To do the enqueue operation and extract the first item of waiting
13843 + list. If a number of available shared memory segments could meet
13844 the request of extracted item, the extracted item will be fragmented
13845 into shared memory segments.
13849 pAdapter Pointer to our adapter
13850 pQueue Pointer to Waiting Queue
13859 ========================================================================
13861 VOID RTMPDeQueuePacket(
13862 @@ -2424,69 +2409,64 @@
13863 struct sk_buff_head *pQueue;
13864 UCHAR AccessCategory;
13865 struct sk_buff *skb;
13866 - unsigned long irqflag;
13868 - // Make sure SendTxWait queue resource won't be used by other threads
13869 - spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13870 + unsigned long irqflag;
13872 - while (Count < MAX_TX_PROCESS)
13873 - // Check queue before dequeue
13874 - // while ((pQueue->Head != NULL) && (Count < MAX_TX_PROCESS))
13876 + while (Count < MAX_TX_PROCESS) {
13877 // Reset is in progress, stop immediately
13878 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS))
13881 pQueue = RTMPCheckTxSwQueue(pAdapter, &AccessCategory);
13886 // Dequeue the first entry from head of queue list
13887 + spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13888 skb = skb_dequeue(pQueue);
13889 + spin_unlock_irqrestore(&pAdapter->TxSwQueueLock, irqflag);
13895 // RTS or CTS-to-self for B/G protection mode has been set already.
13896 - // There is no need to re-do it here.
13897 + // There is no need to re-do it here.
13898 // Total fragment required = number of fragment + RST if required
13899 FragmentRequired = RTMP_GET_PACKET_FRAGMENTS(skb) + RTMP_GET_PACKET_RTS(skb);
13901 - if (RTMPFreeDescriptorRequest(pAdapter, TX_RING, FragmentRequired) == NDIS_STATUS_SUCCESS)
13903 - // Avaliable ring descriptors are enough for this frame
13904 - // Call hard transmit
13905 - Status = RTMPHardEncrypt(pAdapter, skb, FragmentRequired, pAdapter->PortCfg.EnableTxBurst, AccessCategory);
13907 - if (Status == NDIS_STATUS_FAILURE)
13909 - // Packet failed due to various Ndis Packet error
13910 - dev_kfree_skb_irq(skb);
13913 - else if (Status == NDIS_STATUS_RESOURCES)
13915 - // Not enough free tx ring, it might happen due to free descriptor inquery might be not correct
13916 - // It also might change to NDIS_STATUS_FAILURE to simply drop the frame
13917 - // Put the frame back into head of queue
13918 - skb_queue_head(pQueue, skb);
13925 + if (RTMPFreeDescriptorRequest(pAdapter, TX_RING,
13926 + FragmentRequired) != NDIS_STATUS_SUCCESS) {
13927 + spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13928 skb_queue_head(pQueue, skb);
13929 + spin_unlock_irqrestore(&pAdapter->TxSwQueueLock, irqflag);
13930 pAdapter->PrivateInfo.TxRingFullCnt++;
13931 - DBGPRINT(RT_DEBUG_INFO,"RTMPDequeuePacket --> Not enough free Tx Ring descriptor (CurEncryptIndex=%d,CurTxIndex=%d, NextTxDoneIndex=%d)!!!\n",
13932 - pAdapter->CurEncryptIndex, pAdapter->CurTxIndex, pAdapter->NextTxDoneIndex);
13933 + DBGPRINT(RT_DEBUG_INFO,
13934 + "RTMPDequeuePacket --> Not enough free Tx Ring descriptor (CurEncryptIndex=%d,CurTxIndex=%d, NextTxDoneIndex=%d)!!!\n",
13935 + pAdapter->CurEncryptIndex,
13936 + pAdapter->CurTxIndex,
13937 + pAdapter->NextTxDoneIndex);
13940 + // Available ring descriptors are enough for this frame
13941 + // Call hard transmit
13942 + Status = RTMPHardEncrypt(pAdapter, skb, FragmentRequired, pAdapter->PortCfg.EnableTxBurst, AccessCategory);
13943 + if (Status == NDIS_STATUS_FAILURE) {
13944 + // Packet failed due to various Ndis Packet error
13945 + dev_kfree_skb_irq(skb);
13947 + } else if (Status == NDIS_STATUS_RESOURCES) {
13948 + // Not enough free tx ring, it might happen due to free descriptor inquery might be not correct
13949 + // It also might change to NDIS_STATUS_FAILURE to simply drop the frame
13950 + // Put the frame back into head of queue
13951 + spin_lock_irqsave(&pAdapter->TxSwQueueLock, irqflag);
13952 + skb_queue_head(pQueue, skb);
13953 + spin_unlock_irqrestore(&pAdapter->TxSwQueueLock, irqflag);
13960 - // Release TxSwQueue0 resources
13961 - spin_unlock_irqrestore(&pAdapter->TxSwQueueLock, irqflag);
13966 ========================================================================
13967 @@ -2494,17 +2474,17 @@
13968 Routine Description:
13969 This subroutine will scan through releative ring descriptor to find
13970 out avaliable free ring descriptor and compare with request size.
13974 pAdapter Pointer to our adapter
13975 RingType Selected Ring
13979 NDIS_STATUS_FAILURE Not enough free descriptor
13980 NDIS_STATUS_SUCCESS Enough free descriptor
13985 ========================================================================
13987 NDIS_STATUS RTMPFreeDescriptorRequest(
13988 @@ -2557,18 +2537,18 @@
13994 } while (FreeNumber < NumberRequired); // Quit here ! Free number is enough !
13997 if (FreeNumber >= NumberRequired)
13999 Status = NDIS_STATUS_SUCCESS;
14003 // Make sure to release Tx ring resource
14004 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
14009 Index = pAdapter->CurPrioIndex;
14011 @@ -2581,7 +2561,7 @@
14013 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14017 // While Owner bit is NIC, obviously ASIC still need it.
14018 // If valid bit is TRUE, indicate that TxDone has not process yet
14019 // We should not use it until TxDone finish cleanup job
14020 @@ -2594,26 +2574,26 @@
14027 if (Index >= PRIO_RING_SIZE) // Wrap around issue
14033 } while (FreeNumber < NumberRequired); // Quit here ! Free number is enough !
14036 if (FreeNumber >= NumberRequired)
14038 Status = NDIS_STATUS_SUCCESS;
14052 @@ -2631,7 +2611,7 @@
14055 unsigned long irqflag;
14058 if (pBuffer == NULL)
14061 @@ -2642,19 +2622,19 @@
14062 MlmeFreeMemory(pAdapter, pBuffer);
14067 // WPA 802.1x secured port control
14068 - if (((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
14069 + if (((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
14070 (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
14071 - (pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
14072 + (pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
14074 MlmeFreeMemory(pAdapter, pBuffer);
14080 FrameGap = IFS_BACKOFF; // Default frame gap mode
14082 - // outgoing frame always wakeup PHY to prevent frame lost and
14083 + // outgoing frame always wakeup PHY to prevent frame lost and
14084 // turn off PSM bit to improve performance
14085 AsicForceWakeup(pAdapter);
14087 @@ -2664,13 +2644,13 @@
14088 DBGPRINT(RT_DEBUG_TRACE,("Drop Null frame due to Tx queue not empty!\n"));
14094 // Make sure Tx ring resource won't be used by other threads
14095 spin_lock_irqsave(&pAdapter->TxRingLock, irqflag);
14098 // Get the Tx Ring descriptor & Dma Buffer address
14099 - pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14100 + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14102 pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
14104 @@ -2679,11 +2659,11 @@
14106 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14110 if ((pTxD->Owner == DESC_OWN_HOST) && (pTxD->CipherOwn == DESC_OWN_HOST) && (pTxD->Valid == FALSE))
14112 HEADER_802_11 *pHeader_802_11;
14115 DBGPRINT(RT_DEBUG_TRACE, "SYNC - send NULL Frame @%d Mbps...\n", RateIdToMbps[TxRate]);
14117 RTMPFrameEndianChange(pAdapter, (PUCHAR)pBuffer, DIR_WRITE, FALSE);
14118 @@ -2693,14 +2673,14 @@
14120 pHeader_802_11 = (PHEADER_802_11) pDest;
14121 pHeader_802_11->Controlhead.Frame.PwrMgt = (pAdapter->PortCfg.Psm == PWR_SAVE);
14125 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14130 - RTMPWriteTxDescriptor(pTxD, TRUE, CIPHER_NONE, TRUE, FALSE, FALSE, LONG_RETRY, IFS_BACKOFF,
14131 + RTMPWriteTxDescriptor(pTxD, TRUE, CIPHER_NONE, TRUE, FALSE, FALSE, LONG_RETRY, IFS_BACKOFF,
14132 TxRate, 4, Length, pAdapter->PortCfg.TxPreambleInUsed, 0);
14134 // Increase & maintain Tx Ring Index
14135 @@ -2709,13 +2689,13 @@
14137 pAdapter->CurEncryptIndex = 0;
14141 pAdapter->RalinkCounters.EncryptCount++;
14143 // Kick Encrypt Control Register at the end of all ring buffer preparation
14144 RTMP_IO_WRITE32(pAdapter, SECCSR1, 0x1);
14149 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
14151 MlmeFreeMemory(pAdapter, pBuffer);
14152 @@ -2725,20 +2705,20 @@
14153 ========================================================================
14155 Routine Description:
14156 - Copy frame from waiting queue into relative ring buffer and set
14157 + Copy frame from waiting queue into relative ring buffer and set
14158 appropriate ASIC register to kick hardware encryption before really
14163 pAdapter Pointer to our adapter
14164 PNDIS_PACKET Pointer to outgoing Ndis frame
14165 NumberOfFrag Number of fragment required
14174 ========================================================================
14176 NDIS_STATUS RTMPHardEncrypt(
14177 @@ -2794,7 +2774,7 @@
14178 if (pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE)
14180 pAdapter->TxRing[pAdapter->CurEncryptIndex].FrameType = BTYPE_DATA;
14181 - pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14182 + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14183 pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
14184 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
14185 memcpy(pDest,skb->data,skb->len);
14186 @@ -2812,25 +2792,25 @@
14187 FrameGap = IFS_SIFS;
14189 FrameGap = IFS_BACKOFF; // Default frame gap mode
14191 - // outgoing frame always wakeup PHY to prevent frame lost and
14193 + // outgoing frame always wakeup PHY to prevent frame lost and
14194 // turn off PSM bit to improve performance
14195 if (pAdapter->PortCfg.Psm == PWR_SAVE)
14197 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
14199 AsicForceWakeup(pAdapter);
14202 // Sequence Number is identical for all fragments belonged to the same frame
14203 // Sequence is 0 - 4095
14204 pAdapter->Sequence = ((pAdapter->Sequence) + 1) & (MAX_SEQ_NUMBER);
14207 AckRate = pAdapter->PortCfg.ExpectedACKRate[pAdapter->PortCfg.TxRate];
14208 AckDuration = RTMPCalcDuration(pAdapter, AckRate, 14);
14210 pVirtualAddress = skb->data;
14211 NdisBufferLength = skb->len;
14214 if ((*((PUCHAR) pVirtualAddress) & 0x01) != 0) // Multicast or Broadcast
14216 INC_COUNTER(pAdapter->WlanCounters.MulticastTransmittedFrameCount);
14217 @@ -2843,7 +2823,7 @@
14218 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
14219 return (NDIS_STATUS_FAILURE);
14224 // Start making 802.11 frame header
14226 @@ -2855,14 +2835,14 @@
14227 memcpy(&Header_802_11.Addr3, (PUCHAR) pVirtualAddress, ETH_ALEN);
14228 Header_802_11.Controlhead.Frame.ToDs = 1;
14233 // Address 1 - DA, Address 2 - this STA, Address 3 - BSSID
14234 memcpy(&Header_802_11.Controlhead.Addr1, (PUCHAR) pVirtualAddress, ETH_ALEN);
14235 memcpy(&Header_802_11.Addr3, &pAdapter->PortCfg.Bssid, ETH_ALEN);
14237 memcpy(&Header_802_11.Controlhead.Addr2, pAdapter->CurrentAddress, ETH_ALEN);
14240 Header_802_11.Sequence = pAdapter->Sequence; // Sequence number
14241 Header_802_11.Controlhead.Frame.Type = BTYPE_DATA; // Frame type
14242 Header_802_11.Controlhead.Frame.PwrMgt = (pAdapter->PortCfg.Psm == PWR_SAVE);
14243 @@ -2878,9 +2858,9 @@
14246 EAPOLFrame = FALSE;
14249 // WPA 802.1x secured port control
14250 - if (((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
14251 + if (((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
14252 (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
14253 ((pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAdapter->PortCfg.MicErrCnt >= 2)) &&
14254 (EAPOLFrame == FALSE))
14255 @@ -2889,28 +2869,28 @@
14256 // Make sure to release Tx ring resource
14257 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
14258 return (NDIS_STATUS_FAILURE);
14263 MICFrag = FALSE; // Flag to indicate MIC shall spread into two MPDUs
14268 pSrc = (PUCHAR) pVirtualAddress;
14269 Protocol = *(pSrc + 12) * 256 + *(pSrc + 13);
14270 if (Protocol > 1500) // CHeck for LLC encaped
14272 pEncap = SNAP_802_1H;
14274 - if (RTMPEqualMemory(IPX, pSrc + 12, 2) ||
14275 + if (RTMPEqualMemory(IPX, pSrc + 12, 2) ||
14276 RTMPEqualMemory(APPLE_TALK, pSrc + 12, 2))
14278 pEncap = SNAP_BRIDGE_TUNNEL;
14282 - if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) &&
14283 + if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) &&
14284 (pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0))
14285 - EncryptionOverhead = 8; // WEP: IV + ICV
14286 + EncryptionOverhead = 8; // WEP: IV + ICV
14287 else if (pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled)
14288 EncryptionOverhead = 12; // TKIP: IV + EIV + ICV, MIC already added to TotalPacketLength
14289 else if (pAdapter->PortCfg.WepStatus == Ndis802_11Encryption3Enabled)
14290 @@ -2925,11 +2905,11 @@
14292 PCONTROL_HEADER pControlHeader;
14293 ULONG NextFragSize;
14296 // RTS-protected frame should use LONG_RETRY (=4), other frames use SHORT_RETRY (=7)
14297 RetryMode = LONG_RETRY;
14299 - pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14301 + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14303 pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
14305 @@ -2938,7 +2918,7 @@
14307 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14311 if ((pTxD->Owner == DESC_OWN_NIC) || (pTxD->CipherOwn == DESC_OWN_NIC))
14313 // Descriptor owned by NIC. No descriptor avaliable
14314 @@ -2961,11 +2941,11 @@
14315 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14320 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
14321 return (NDIS_STATUS_RESOURCES);
14325 pAdapter->TxRing[pAdapter->CurEncryptIndex].FrameType = BTYPE_CNTL;
14326 pControlHeader = (PCONTROL_HEADER) pDest;
14327 memset(pControlHeader, 0, sizeof(CONTROL_HEADER));
14328 @@ -2987,27 +2967,32 @@
14330 pControlHeader->Duration = 2 * (pAdapter->PortCfg.Dsifs)
14331 + RTMPCalcDuration(pAdapter, pAdapter->PortCfg.TxRate, NextFragSize + EncryptionOverhead)
14335 // Write Tx descriptor
14336 // Don't kick tx start until all frames are prepared
14337 // RTS has to set more fragment bit for fragment burst
14338 - // RTS did not encrypt
14339 + // RTS did not encrypt
14340 if (pAdapter->PortCfg.BGProtectionInUsed == 1)
14342 DBGPRINT(RT_DEBUG_TRACE,"Making CTS-to-self Frame\n");
14343 - pControlHeader->Frame.Subtype = SUBTYPE_CTS;
14344 + pControlHeader->Frame.Subtype = SUBTYPE_CTS;
14345 memcpy(&pControlHeader->Addr1, pAdapter->CurrentAddress, ETH_ALEN);
14348 - RTMPFrameEndianChange(pAdapter, (PUCHAR)pControlHeader, DIR_WRITE, FALSE);
14349 - RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14352 + // Write Tx descriptor
14353 + // Don't kick tx start until all frames are prepared
14354 + // CTS has to set more fragment bit for fragment burst
14355 + // CTS did not encrypt
14356 + // CTS-to-self will never receive ACK
14357 + RTMPFrameEndianChange(pAdapter, (PUCHAR)pControlHeader,
14358 + DIR_WRITE, FALSE);
14359 + RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14367 RTMPWriteTxDescriptor(pTxD, TRUE, CIPHER_NONE, FALSE, FALSE, FALSE, SHORT_RETRY,
14368 FrameGap, pAdapter->PortCfg.RtsRate, 4, 10, Rt802_11PreambleShort,
14370 @@ -3019,42 +3004,51 @@
14374 - DBGPRINT(RT_DEBUG_TRACE,"Making RTS Frame\n");
14375 - pControlHeader->Frame.Subtype = SUBTYPE_RTS;
14376 - if (INFRA_ON(pAdapter))
14377 - memcpy(&pControlHeader->Addr1, &pAdapter->PortCfg.Bssid, ETH_ALEN);
14379 - memcpy(&pControlHeader->Addr1, (PUCHAR) pVirtualAddress, ETH_ALEN);
14380 - memcpy(&pControlHeader->Addr2, pAdapter->CurrentAddress, ETH_ALEN);
14381 + DBGPRINT(RT_DEBUG_TRACE,"Making RTS Frame\n");
14382 + pControlHeader->Frame.Subtype = SUBTYPE_RTS;
14383 + if (INFRA_ON(pAdapter))
14384 + memcpy(&pControlHeader->Addr1,
14385 + &pAdapter->PortCfg.Bssid, ETH_ALEN);
14387 + memcpy(&pControlHeader->Addr1,
14388 + (PUCHAR) pVirtualAddress, ETH_ALEN);
14389 + memcpy(&pControlHeader->Addr2,
14390 + pAdapter->CurrentAddress, ETH_ALEN);
14392 + // Write Tx descriptor
14393 + // Don't kick tx start until all frames are prepared
14394 + // RTS has to set more fragment bit for fragment burst
14395 + // RTS did not encrypt
14398 - RTMPFrameEndianChange(pAdapter, (PUCHAR)pControlHeader, DIR_WRITE, FALSE);
14399 - RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14402 + RTMPFrameEndianChange(pAdapter, (PUCHAR)pControlHeader,
14403 + DIR_WRITE, FALSE);
14404 + RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14408 RTMPWriteTxDescriptor(pTxD, TRUE, CIPHER_NONE, TRUE, TRUE, FALSE, SHORT_RETRY,
14409 FrameGap, pAdapter->PortCfg.RtsRate, 4, sizeof(CONTROL_HEADER),
14410 pAdapter->PortCfg.TxPreambleInUsed, AccessCategory);
14415 FrameGap = IFS_SIFS; // Init frame gap for coming data after RTS
14419 // Increase & maintain Tx Ring Index
14420 pAdapter->CurEncryptIndex++;
14421 if (pAdapter->CurEncryptIndex >= TX_RING_SIZE)
14423 pAdapter->CurEncryptIndex = 0;
14425 - pAdapter->RalinkCounters.EncryptCount++;
14426 + pAdapter->RalinkCounters.EncryptCount++;
14429 // Find the WPA key, either Group or Pairwise Key
14430 if (pAdapter->PortCfg.AuthMode >= Ndis802_11AuthModeWPA)
14435 pWpaKey = (PWPA_KEY) NULL;
14436 // First lookup the DA, if it's a group address, use GROUP key
14437 if (Header_802_11.Controlhead.Addr1.Octet[0] & 0x01)
14438 @@ -3101,17 +3095,17 @@
14440 // Get the Tx Ring descriptor & Dma Buffer address
14442 - pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14443 + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14444 pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
14446 - pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14447 + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
14448 pOriginDest = pDest;
14449 pDestTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
14452 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14456 if ((pTxD->Owner == DESC_OWN_NIC) || (pTxD->CipherOwn == DESC_OWN_NIC))
14458 // Descriptor owned by NIC. No descriptor avaliable
14459 @@ -3127,12 +3121,14 @@
14460 // This should not happen since caller guaranteed.
14461 // Make sure to release Tx ring resource
14462 pTxD->Valid = FALSE;
14466 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14468 + //*pDestTxD = TxD;
14469 + WriteBackToDescriptor((PUCHAR)pDestRxD, (PUCHAR)pRxD, FALSE,
14474 pAdapter->RalinkCounters.TxRingErrCount++;
14475 spin_unlock_irqrestore(&pAdapter->TxRingLock, irqflag);
14476 return (NDIS_STATUS_RESOURCES);
14477 @@ -3144,7 +3140,7 @@
14478 Header_802_11.Frag = 0; // Start of fragment burst / Single Frame
14480 Header_802_11.Frag++; // Rest of fragmented frames.
14483 // Maximum allowable payload with one ring buffer, bound by fragment size
14484 FreeFragSize = pAdapter->PortCfg.FragmentThreshold - LENGTH_CRC;
14486 @@ -3155,12 +3151,12 @@
14488 ULONG NextFragSize;
14489 Header_802_11.Controlhead.Frame.MoreFrag = 1;
14492 if (NumberRequired == 2)
14493 NextFragSize = RemainSize - pAdapter->PortCfg.FragmentThreshold + LENGTH_802_11 + LENGTH_802_11 + LENGTH_CRC;
14495 NextFragSize = pAdapter->PortCfg.FragmentThreshold;
14498 Header_802_11.Controlhead.Duration = 3 * pAdapter->PortCfg.Dsifs
14500 + RTMPCalcDuration(pAdapter, pAdapter->PortCfg.TxRate, NextFragSize + EncryptionOverhead);
14501 @@ -3168,7 +3164,7 @@
14502 else // this is the last or only fragment
14504 Header_802_11.Controlhead.Frame.MoreFrag = 0;
14507 if (Header_802_11.Controlhead.Addr1.Octet[0] & 0x01) // multicast/broadcast
14508 Header_802_11.Controlhead.Duration = 0;
14510 @@ -3183,7 +3179,7 @@
14511 Header_802_11.Controlhead.Frame.Wep = 1;
14512 else if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption3Enabled) && (pWpaKey != NULL))
14513 Header_802_11.Controlhead.Frame.Wep = 1;
14517 // Copy 802.11 header to Tx ring buffer
14519 @@ -3191,12 +3187,15 @@
14520 pDest += sizeof(Header_802_11);
14521 FreeFragSize -= sizeof(Header_802_11);
14523 - DBGPRINT(RT_DEBUG_TRACE,"pWpaKey = %s\n", pWpaKey == NULL ? "NULL" : "not NULL");
14524 + DBGPRINT(RT_DEBUG_INFO, "pWpaKey = %s\n",
14525 + pWpaKey == NULL ? "NULL" : "not NULL");
14527 if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) && (EAPOLFrame == FALSE) &&
14528 (pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen != 0))
14530 - DBGPRINT(RT_DEBUG_TRACE,"Ndis802_11Encryption1Enabled::DefaultKeyId = %d\n", pAdapter->PortCfg.DefaultKeyId);
14531 + DBGPRINT(RT_DEBUG_INFO,
14532 + "Ndis802_11Encryption1Enabled::DefaultKeyId = %d\n",
14533 + pAdapter->PortCfg.DefaultKeyId);
14534 // Prepare IV, IV offset, Key for Hardware encryption
14537 @@ -3216,12 +3215,14 @@
14540 pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].Key,
14541 - pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen);
14542 + pAdapter->PortCfg.SharedKey[pAdapter->PortCfg.DefaultKeyId].KeyLen);
14544 else if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pWpaKey != NULL))
14547 - DBGPRINT(RT_DEBUG_TRACE,"Ndis802_11Encryption2Enabled::DefaultKeyId = %d\n", pAdapter->PortCfg.DefaultKeyId);
14548 + DBGPRINT(RT_DEBUG_INFO,
14549 + "Ndis802_11Encryption2Enabled::DefaultKeyId = %d\n",
14550 + pAdapter->PortCfg.DefaultKeyId);
14551 // Prepare 8 bytes TKIP encapsulation for MPDU
14554 @@ -3232,31 +3233,20 @@
14555 tkipIv.IV16.field.rc2 = *pWpaKey->TxTsc;
14556 tkipIv.IV16.field.ExtIV = 1;// 0: non-extended IV, 1: extended IV
14557 tkipIv.IV16.field.KeyID = pAdapter->PortCfg.DefaultKeyId;
14558 - tkipIv.IV32 = *(PULONG)(pWpaKey->TxTsc + 2);
14559 -#if 0 //jett, 2004-1222 ------------------
14560 -#if BIG_ENDIAN == TRUE
14561 - pTxD->Iv = (tkipIv.IV16.field.rc0 << 24) | (tkipIv.IV16.field.rc1 << 16) | (tkipIv.IV16.field.rc2 << 8) | (tkipIv.IV16.field.CONTROL.Byte);
14564 -#ifdef RTMP_EMBEDDED
14565 - pTxD->Iv = (tkipIv.IV16.field.CONTROL.Byte << 24) | (tkipIv.IV16.field.rc2 << 16) | (tkipIv.IV16.field.rc1 << 8) | (tkipIv.IV16.field.rc0);
14567 - pTxD->Iv = tkipIv.IV16.word;
14569 -#else //----------------------------------
14570 + //tkipIv.IV32 = *(PULONG)(pWpaKey->TxTsc + 2);
14571 + memcpy(&tkipIv.IV32, &pWpaKey->TxTsc[2], 4);
14573 - pTxD->Iv = SWAP32(tkipIv.IV16.word);
14574 + pTxD->Iv = SWAP32(tkipIv.IV16.word);
14576 - pTxD->Iv = tkipIv.IV16.word;
14577 + pTxD->Iv = tkipIv.IV16.word;
14579 -#endif //----------------------------------
14581 *((PUCHAR) &pTxD->Eiv) = *((PUCHAR) &tkipIv.IV32 + 3);
14582 *((PUCHAR) &pTxD->Eiv + 1) = *((PUCHAR) &tkipIv.IV32 + 2);
14583 *((PUCHAR) &pTxD->Eiv + 2) = *((PUCHAR) &tkipIv.IV32 + 1);
14584 *((PUCHAR) &pTxD->Eiv + 3) = *((PUCHAR) &tkipIv.IV32);
14588 // Increase TxTsc value for next transmission
14589 while (++pWpaKey->TxTsc[i] == 0x0)
14591 @@ -3264,13 +3254,13 @@
14598 pTxD->IvOffset = LENGTH_802_11;
14601 memcpy(pTxD->Key, pWpaKey->Key, 16);
14604 // Set Cipher suite
14605 CipherAlg = CIPHER_TKIP;
14607 @@ -3279,15 +3269,20 @@
14611 + DBGPRINT(RT_DEBUG_INFO,
14612 + "Ndis802_11Encryption3Enabled::DefaultKeyId = %d\n",
14613 + pAdapter->PortCfg.DefaultKeyId);
14616 pTmp = (PUCHAR) &Iv16;
14617 *pTmp = pWpaKey->TxTsc[0];
14618 *(pTmp + 1) = pWpaKey->TxTsc[1];
14620 *(pTmp + 3) = (pAdapter->PortCfg.DefaultKeyId << 6) | 0x20;
14622 - Iv32 = *(PULONG)(&pWpaKey->TxTsc[2]);
14625 + //Iv32 = *(PULONG)(&pWpaKey->TxTsc[2]);
14626 + memcpy(&Iv32, &pWpaKey->TxTsc[2], 4);
14628 // Increase TxTsc value for next transmission
14629 while (++pWpaKey->TxTsc[i] == 0x0)
14631 @@ -3300,7 +3295,7 @@
14632 // TODO: TSC has done one full cycle, do re-keying stuff follow specs
14633 // Should send a special event microsoft defined to request re-key
14637 memcpy(&pTxD->Iv, &Iv16, 4); // Copy IV
14638 memcpy(&pTxD->Eiv, &Iv32, 4); // Copy EIV
14639 pTxD->IvOffset = LENGTH_802_11; // Set IV offset
14640 @@ -3308,8 +3303,11 @@
14641 CipherAlg = CIPHER_AES; // Set Cipher suite
14645 + DBGPRINT(RT_DEBUG_TRACE,"Ndis802_11EncryptionDisabled\n");
14646 CipherAlg = CIPHER_NONE;
14651 // Only the first fragment required LLC-SNAP header !!!
14653 @@ -3332,7 +3330,7 @@
14654 pSrc = (PUCHAR) pVirtualAddress;
14655 memcpy(pDest, pSrc + 12, 2);
14659 // Exclude 802.3 header size, we will recalculate the size at
14660 // the end of fragment preparation.
14661 NdisBufferLength -= LENGTH_802_3;
14662 @@ -3346,11 +3344,11 @@
14663 // Calculate MSDU MIC Value
14664 RTMPCalculateMICValue(pAdapter, skb, pEncap, 0, pWpaKey);
14668 pSrc = (PUCHAR) pVirtualAddress + LENGTH_802_3;
14669 NdisBufferLength -= LENGTH_802_3;
14673 // Start copying payload
14676 @@ -3375,23 +3373,25 @@
14677 pDest += NdisBufferLength;
14678 FreeFragSize -= NdisBufferLength;
14682 // No more buffer descriptor
14683 // Add MIC value if needed
14684 - if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
14685 + if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
14686 (MICFrag == FALSE) &&
14691 NdisBufferLength = 8; // Set length to MIC length
14692 - DBGPRINT(RT_DEBUG_INFO, "Calculated TX MIC value =");
14693 - for (i = 0; i < 8; i++)
14695 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Tx.MIC[i]);
14697 - DBGPRINT(RT_DEBUG_INFO, "\n");
14699 + DBGPRINT(RT_DEBUG_INFO,
14700 + "--- TX MIC=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
14701 + pAdapter->PrivateInfo.Tx.MIC[0],
14702 + pAdapter->PrivateInfo.Tx.MIC[1],
14703 + pAdapter->PrivateInfo.Tx.MIC[2],
14704 + pAdapter->PrivateInfo.Tx.MIC[3],
14705 + pAdapter->PrivateInfo.Tx.MIC[4],
14706 + pAdapter->PrivateInfo.Tx.MIC[5],
14707 + pAdapter->PrivateInfo.Tx.MIC[6],
14708 + pAdapter->PrivateInfo.Tx.MIC[7]);
14710 if (FreeFragSize >= NdisBufferLength)
14712 memcpy(pDest, pAdapter->PrivateInfo.Tx.MIC, NdisBufferLength);
14713 @@ -3413,7 +3413,7 @@
14716 } while (FALSE); // End of copying payload
14719 // Real packet size, No 802.1H header for fragments except the first one.
14720 if ((StartOfFrame == TRUE) && (Encapped == TRUE))
14722 @@ -3425,7 +3425,7 @@
14725 RemainSize = RemainSize - BytesCopied;
14728 if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) && (Header_802_11.Controlhead.Frame.Wep == 1))
14730 // IV + ICV which ASIC added after encryption done
14731 @@ -3441,7 +3441,7 @@
14732 // IV + EIV + HW MIC
14737 // Prepare Tx descriptors before kicking tx.
14738 // The BBP register index in Tx descriptor has to be configured too.
14740 @@ -3453,12 +3453,12 @@
14741 if (Header_802_11.Controlhead.Addr1.Octet[0] & 0x01)
14743 // Multicast, retry bit is off
14744 - RTMPWriteTxDescriptor(pTxD, TRUE, CipherAlg, FALSE, FALSE, FALSE, RetryMode, FrameGap,
14745 + RTMPWriteTxDescriptor(pTxD, TRUE, CipherAlg, FALSE, FALSE, FALSE, RetryMode, FrameGap,
14746 pAdapter->PortCfg.TxRate, 4, TxSize, pAdapter->PortCfg.TxPreambleInUsed, AccessCategory);
14750 - RTMPWriteTxDescriptor(pTxD, TRUE, CipherAlg, TRUE, FALSE, FALSE, RetryMode, FrameGap,
14751 + RTMPWriteTxDescriptor(pTxD, TRUE, CipherAlg, TRUE, FALSE, FALSE, RetryMode, FrameGap,
14752 pAdapter->PortCfg.TxRate, 4, TxSize, pAdapter->PortCfg.TxPreambleInUsed, AccessCategory);
14755 @@ -3467,23 +3467,23 @@
14756 StartOfFrame = FALSE;
14757 FrameGap = IFS_SIFS;
14761 // Increase & maintain Tx Ring Index
14762 pAdapter->CurEncryptIndex++;
14763 if (pAdapter->CurEncryptIndex >= TX_RING_SIZE)
14765 pAdapter->CurEncryptIndex = 0;
14769 pAdapter->RalinkCounters.EncryptCount++;
14772 } while (NumberRequired > 0);
14774 skip_packet_handling:
14777 // Kick Encrypt Control Register at the end of all ring buffer preparation
14778 RTMP_IO_WRITE32(pAdapter, SECCSR1, 0x1);
14781 // Acknowledge protocol send complete of pending packet.
14782 dev_kfree_skb_irq(skb);
14784 @@ -3497,19 +3497,19 @@
14785 ========================================================================
14787 Routine Description:
14788 - Calculates the duration which is required to transmit out frames
14789 + Calculates the duration which is required to transmit out frames
14790 with given size and specified rate.
14794 pAdapter Pointer to our adapter
14796 Size Frame size in units of byte
14800 Duration number in units of usec
14805 ========================================================================
14807 USHORT RTMPCalcDuration(
14808 @@ -3525,7 +3525,7 @@
14809 Duration = 96; // 72+24 preamble+plcp
14811 Duration = 192; // 144+48 preamble+plcp
14814 Duration += (USHORT)((Size << 4) / RateIdTo500Kbps[Rate]);
14815 if ((Size << 4) % RateIdTo500Kbps[Rate])
14817 @@ -3537,18 +3537,18 @@
14818 if ((11 + Size * 4) % RateIdTo500Kbps[Rate])
14823 return (USHORT)Duration;
14829 ========================================================================
14832 Routine Description:
14833 - Calculates the duration which is required to transmit out frames
14834 + Calculates the duration which is required to transmit out frames
14835 with given size and specified rate.
14839 pTxD Pointer to transmit descriptor
14840 Ack Setting for Ack requirement bit
14841 @@ -3560,10 +3560,10 @@
14842 Length Frame length
14843 TxPreamble Short or Long preamble when using CCK rates
14844 AccessCategory - 0-3, according to 802.11e/d4.4 June/2003
14851 ========================================================================
14853 VOID RTMPWriteTxDescriptor(
14854 @@ -3624,7 +3624,7 @@
14860 if (Rate < RATE_FIRST_OFDM_RATE)
14863 @@ -3671,7 +3671,7 @@
14864 pTxD->PlcpLengthHigh = Length / 64; // high 6-bit of total byte count
14865 pTxD->PlcpLengthLow = Length % 64; // low 6-bit of total byte count
14869 if (DoEncrypt == TRUE) // Do encryption only
14871 pTxD->Owner = DESC_OWN_HOST;
14872 @@ -3687,8 +3687,10 @@
14873 pTxD->Owner = DESC_OWN_NIC;
14876 - RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14877 - *pSourceTxD = *pTxD;
14878 + RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
14879 + //*pSourceTxD = *pTxD;
14880 + WriteBackToDescriptor((PUCHAR) pSourceTxD, (PUCHAR) pTxD, FALSE,
14885 @@ -3697,17 +3699,17 @@
14887 Routine Description:
14888 Search tuple cache for receive duplicate frame from unicast frames.
14892 pAdapter Pointer to our adapter
14893 pHeader 802.11 header of receiving frame
14897 TRUE found matched tuple cache
14898 FALSE no matched found
14903 ========================================================================
14905 BOOLEAN RTMPSearchTupleCache(
14906 @@ -3720,12 +3722,12 @@
14908 if (pAdapter->TupleCache[Index].Valid == FALSE)
14912 if (RTMPEqualMemory(&pAdapter->TupleCache[Index].MAC, &pHeader->Controlhead.Addr2, 6) &&
14913 (pAdapter->TupleCache[Index].Sequence == pHeader->Sequence) &&
14914 (pAdapter->TupleCache[Index].Frag == pHeader->Frag))
14916 -// DBGPRINT(RT_DEBUG_TRACE,("DUPCHECK - duplicate frame hit entry %d\n", Index));
14917 +// DBGPRINT(RT_DEBUG_TRACE,("DUPCHECK - duplicate frame hit entry %d\n", Index));
14921 @@ -3737,16 +3739,16 @@
14923 Routine Description:
14924 Update tuple cache for new received unicast frames.
14928 pAdapter Pointer to our adapter
14929 pHeader 802.11 header of receiving frame
14939 ========================================================================
14941 VOID RTMPUpdateTupleCache(
14942 @@ -3765,7 +3767,7 @@
14943 pAdapter->TupleCache[Index].Frag = pHeader->Frag;
14944 pAdapter->TupleCache[Index].Valid = TRUE;
14945 pAdapter->TupleCacheLastUpdateIndex = Index;
14946 - DBGPRINT(RT_DEBUG_INFO,"DUPCHECK - Add Entry %d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
14947 + DBGPRINT(RT_DEBUG_INFO,"DUPCHECK - Add Entry %d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
14948 Index, pAdapter->TupleCache[Index].MAC.Octet[0], pAdapter->TupleCache[Index].MAC.Octet[1],
14949 pAdapter->TupleCache[Index].MAC.Octet[2], pAdapter->TupleCache[Index].MAC.Octet[3],
14950 pAdapter->TupleCache[Index].MAC.Octet[4], pAdapter->TupleCache[Index].MAC.Octet[5]);
14951 @@ -3794,7 +3796,7 @@
14952 pAdapter->TupleCache[Index].Sequence = pHeader->Sequence;
14953 pAdapter->TupleCache[Index].Frag = pHeader->Frag;
14954 pAdapter->TupleCache[Index].Valid = TRUE;
14955 - DBGPRINT(RT_DEBUG_INFO,"DUPCHECK - replace Entry %d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
14956 + DBGPRINT(RT_DEBUG_INFO,"DUPCHECK - replace Entry %d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
14957 Index, pAdapter->TupleCache[Index].MAC.Octet[0], pAdapter->TupleCache[Index].MAC.Octet[1],
14958 pAdapter->TupleCache[Index].MAC.Octet[2], pAdapter->TupleCache[Index].MAC.Octet[3],
14959 pAdapter->TupleCache[Index].MAC.Octet[4], pAdapter->TupleCache[Index].MAC.Octet[5]);
14960 @@ -3806,15 +3808,15 @@
14962 Routine Description:
14963 Suspend MSDU transmission
14967 pAdapter Pointer to our adapter
14977 ========================================================================
14979 VOID RTMPSuspendMsduTransmission(
14980 @@ -3829,15 +3831,15 @@
14982 Routine Description:
14983 Resume MSDU transmission
14987 pAdapter Pointer to our adapter
14997 ========================================================================
14999 VOID RTMPResumeMsduTransmission(
15000 @@ -3863,40 +3865,40 @@
15001 Routine Description:
15002 Apply packet filter policy, return NDIS_STATUS_FAILURE if this frame
15007 pAdapter Pointer to our adapter
15008 pRxD Pointer to the Rx descriptor
15009 pHeader Pointer to the 802.11 frame header
15013 NDIS_STATUS_SUCCESS Accept frame
15014 NDIS_STATUS_FAILURE Drop Frame
15018 Maganement frame should bypass this filtering rule.
15021 ========================================================================
15023 NDIS_STATUS RTMPApplyPacketFilter(
15024 - IN PRTMP_ADAPTER pAdapter,
15025 - IN PRXD_STRUC pRxD,
15026 + IN PRTMP_ADAPTER pAdapter,
15027 + IN PRXD_STRUC pRxD,
15028 IN PHEADER_802_11 pHeader)
15033 // 0. Management frame should bypass all these filtering rules.
15034 if (pHeader->Controlhead.Frame.Type == BTYPE_MGMT)
15036 return(NDIS_STATUS_SUCCESS);
15040 // 0.1 Drop all Rx frames if MIC countermeasures kicks in
15041 if (pAdapter->PortCfg.MicErrCnt >= 2)
15043 return(NDIS_STATUS_FAILURE);
15047 // 1. Drop unicast to me packet if NDIS_PACKET_TYPE_DIRECTED is FALSE
15050 @@ -3905,7 +3907,7 @@
15051 return(NDIS_STATUS_FAILURE);
15056 // 2. Drop broadcast packet if NDIS_PACKET_TYPE_BROADCAST is FALSE
15057 else if (pRxD->Bcast)
15059 @@ -3914,7 +3916,7 @@
15060 return(NDIS_STATUS_FAILURE);
15065 // 3. Drop multicast packet if NDIS_PACKET_TYPE_ALL_MULTICAST is false
15066 // and NDIS_PACKET_TYPE_MULTICAST is false.
15067 // If NDIS_PACKET_TYPE_MULTICAST is true, but NDIS_PACKET_TYPE_ALL_MULTICAST is false.
15068 @@ -3964,8 +3966,8 @@
15070 return(NDIS_STATUS_FAILURE);
15073 - return(NDIS_STATUS_SUCCESS);
15075 + return(NDIS_STATUS_SUCCESS);
15079 @@ -3973,15 +3975,15 @@
15081 Routine Description:
15082 Check and fine the packet waiting in SW queue with highest priority
15086 pAdapter Pointer to our adapter
15090 pQueue Pointer to Waiting Queue
15095 ========================================================================
15097 struct sk_buff_head* RTMPCheckTxSwQueue(
15098 @@ -4019,20 +4021,20 @@
15100 Routine Description:
15101 Process MIC error indication and record MIC error timer.
15105 pAdapter Pointer to our adapter
15106 pWpaKey Pointer to the WPA key structure
15116 ========================================================================
15118 VOID RTMPReportMicError(
15119 - IN PRTMP_ADAPTER pAdapter,
15120 + IN PRTMP_ADAPTER pAdapter,
15121 IN PWPA_KEY pWpaKey)
15124 @@ -4044,7 +4046,7 @@
15126 // 0. Set Status to indicate auth error
15127 Report.Status.StatusType = Ndis802_11StatusType_Authentication;
15130 // 1. Check for Group or Pairwise MIC error
15131 if (pWpaKey->Type == PAIRWISE_KEY)
15132 Report.Request.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
15133 @@ -4069,13 +4071,13 @@
15134 if ((pAdapter->PortCfg.LastMicErrorTime + (60 * HZ)) < Now)
15136 // Update Last MIC error time, this did not violate two MIC errors within 60 seconds
15137 - pAdapter->PortCfg.LastMicErrorTime = Now;
15138 + pAdapter->PortCfg.LastMicErrorTime = Now;
15142 - pAdapter->PortCfg.LastMicErrorTime = Now;
15143 + pAdapter->PortCfg.LastMicErrorTime = Now;
15144 // Violate MIC error counts, MIC countermeasures kicks in
15145 - pAdapter->PortCfg.MicErrCnt++;
15146 + pAdapter->PortCfg.MicErrCnt++;
15147 // We shall block all reception
15148 // We shall clean all Tx ring and disassoicate from AP after next EAPOL frame
15149 RTMPRingCleanUp(pAdapter, TX_RING);
15150 diff -Nur rt2500-1.1.0-b4/Module/rtmp_def.h rt2500-cvs-2007061011/Module/rtmp_def.h
15151 --- rt2500-1.1.0-b4/Module/rtmp_def.h 2006-06-17 22:12:58.000000000 +0200
15152 +++ rt2500-cvs-2007061011/Module/rtmp_def.h 2007-03-21 05:25:35.000000000 +0100
15154 -/***************************************************************************
15155 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
15157 - * This program is free software; you can redistribute it and/or modify *
15158 - * it under the terms of the GNU General Public License as published by *
15159 - * the Free Software Foundation; either version 2 of the License, or *
15160 - * (at your option) any later version. *
15162 - * This program is distributed in the hope that it will be useful, *
15163 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15164 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15165 - * GNU General Public License for more details. *
15167 - * You should have received a copy of the GNU General Public License *
15168 - * along with this program; if not, write to the *
15169 - * Free Software Foundation, Inc., *
15170 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
15172 - * Licensed under the GNU GPL *
15173 - * Original code supplied under license from RaLink Inc, 2004. *
15174 - ***************************************************************************/
15175 +/***************************************************************************
15176 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
15178 + * This program is free software; you can redistribute it and/or modify *
15179 + * it under the terms of the GNU General Public License as published by *
15180 + * the Free Software Foundation; either version 2 of the License, or *
15181 + * (at your option) any later version. *
15183 + * This program is distributed in the hope that it will be useful, *
15184 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15185 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15186 + * GNU General Public License for more details. *
15188 + * You should have received a copy of the GNU General Public License *
15189 + * along with this program; if not, write to the *
15190 + * Free Software Foundation, Inc., *
15191 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
15193 + * Licensed under the GNU GPL *
15194 + * Original code supplied under license from RaLink Inc, 2004. *
15195 + ***************************************************************************/
15197 - /***************************************************************************
15198 + /***************************************************************************
15199 * Module Name: rtmp_def.h
15202 * Abstract: Miniport related definition header
15204 - * Revision History:
15206 - * -------- ----------- -----------------------------
15207 - * PaulL 1st Aug 02 Initial code
15208 - * MarkW 8th Dec 04 Baseline code
15209 - ***************************************************************************/
15211 + * Revision History:
15213 + * -------- ----------- -----------------------------
15214 + * PaulL 1st Aug 02 Initial code
15215 + * MarkW 8th Dec 04 Baseline code
15216 + ***************************************************************************/
15218 #ifndef __RTMP_DEF_H__
15219 #define __RTMP_DEF_H__
15220 @@ -38,11 +38,12 @@
15222 // Debug information verbosity: lower values indicate higher urgency
15224 -#define RT_DEBUG_ERROR KERN_ERR
15225 -#define RT_DEBUG_WARN KERN_WARNING
15226 -#define RT_DEBUG_TRACE KERN_NOTICE
15227 -#define RT_DEBUG_INFO KERN_INFO
15228 -#define RT_DEBUG_LOUD KERN_DEBUG
15229 +#define RT_DEBUG_OFF 0
15230 +#define RT_DEBUG_ERROR 1
15231 +#define RT_DEBUG_WARN 2
15232 +#define RT_DEBUG_TRACE 4
15233 +#define RT_DEBUG_INFO 8
15234 +#define RT_DEBUG_LOUD 16
15237 // update the driver version number every time you release a new driver
15238 @@ -190,8 +191,8 @@
15239 #define HASH_TABLE_SIZE 256
15240 #define MAX_LEN_OF_MLME_BUFFER 1024
15241 #define MAX_FRAME_LEN 2338
15242 -#define MAX_VIE_LEN 128 // New for WPA cipher suite variable IE sizes.
15243 -#define MAX_MLME_HANDLER_MEMORY 20 //each them cantains MAX_LEN_OF_MLME_BUFFER size
15244 +#define MAX_VIE_LEN 257 // sum of WPAx IEs
15245 +#define MAX_MLME_HANDLER_MEMORY 20 //each them cantains MAX_LEN_OF_MLME_BUFFER size
15246 #define MAX_INI_BUFFER_SIZE 1024
15248 #define MAX_TX_POWER_LEVEL 100 /* mW */
15249 @@ -265,7 +266,7 @@
15250 #define MLME_SUCCESS 0
15251 #define MLME_UNSPECIFY_FAIL 1
15252 #define MLME_CANNOT_SUPPORT_CAP 10
15253 -#define MLME_REASSOC_DENY_ASSOC_EXIST 11
15254 +#define MLME_REASSOC_DENY_ASSOC_EXIST 11
15255 #define MLME_ASSOC_DENY_OUT_SCOPE 12
15256 #define MLME_ALG_NOT_SUPPORT 13
15257 #define MLME_SEQ_NR_OUT_OF_SEQUENCE 14
15258 @@ -317,7 +318,7 @@
15260 #define MT2_MLME_ASSOC_REQ 0
15261 #define MT2_MLME_REASSOC_REQ 1
15262 -#define MT2_MLME_DISASSOC_REQ 2
15263 +#define MT2_MLME_DISASSOC_REQ 2
15264 #define MT2_PEER_DISASSOC_REQ 3
15265 #define MT2_PEER_ASSOC_REQ 4
15266 #define MT2_PEER_ASSOC_RSP 5
15267 diff -Nur rt2500-1.1.0-b4/Module/rtmp_info.c rt2500-cvs-2007061011/Module/rtmp_info.c
15268 --- rt2500-1.1.0-b4/Module/rtmp_info.c 2006-06-17 22:12:58.000000000 +0200
15269 +++ rt2500-cvs-2007061011/Module/rtmp_info.c 2007-05-31 22:45:43.000000000 +0200
15271 -/***************************************************************************
15272 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
15274 - * This program is free software; you can redistribute it and/or modify *
15275 - * it under the terms of the GNU General Public License as published by *
15276 - * the Free Software Foundation; either version 2 of the License, or *
15277 - * (at your option) any later version. *
15279 - * This program is distributed in the hope that it will be useful, *
15280 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15281 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15282 - * GNU General Public License for more details. *
15284 - * You should have received a copy of the GNU General Public License *
15285 - * along with this program; if not, write to the *
15286 - * Free Software Foundation, Inc., *
15287 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
15289 - * Licensed under the GNU GPL *
15290 - * Original code supplied under license from RaLink Inc, 2004. *
15291 - ***************************************************************************/
15292 +/***************************************************************************
15293 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
15295 + * This program is free software; you can redistribute it and/or modify *
15296 + * it under the terms of the GNU General Public License as published by *
15297 + * the Free Software Foundation; either version 2 of the License, or *
15298 + * (at your option) any later version. *
15300 + * This program is distributed in the hope that it will be useful, *
15301 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15302 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15303 + * GNU General Public License for more details. *
15305 + * You should have received a copy of the GNU General Public License *
15306 + * along with this program; if not, write to the *
15307 + * Free Software Foundation, Inc., *
15308 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
15310 + * Licensed under the GNU GPL *
15311 + * Original code supplied under license from RaLink Inc, 2004. *
15312 + ***************************************************************************/
15314 - /***************************************************************************
15315 + /***************************************************************************
15316 * Module Name: rtmp_info.c
15318 - * Abstract: IOCTL related subroutines
15320 - * Revision History:
15322 - * -------- ----------- -----------------------------
15323 - * RoryC 3rd Jan 03 Initial code
15324 - * MarkW 8th Dec 04 Baseline code
15326 + * Abstract: IOCTL related subroutines
15328 + * Revision History:
15330 + * -------- ----------- -----------------------------
15331 + * RoryC 3rd Jan 03 Initial code
15332 + * MarkW 8th Dec 04 Baseline code
15333 * RobinC 10th Dec 04 RFMON Support
15334 - * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
15335 + * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
15336 * MarkW 15th Dec 04 Removed debug iwpriv
15337 * RobinC 16th Dec 04 Fix for range values
15338 * RobinC 16th Dec 04 support ifpreup scripts
15339 * RobinC 17th Dec 04 Link Quality reporting
15340 * MarkW 17th Dec 04 iwconfig frequency fix
15341 - * MarkW 17th Dec 04 Monitor mode through iwconfig
15342 + * MarkW 17th Dec 04 Monitor mode through iwconfig
15343 * MarkW 22nd Dec 04 RSSI reporting for iwlist scanning
15344 * MarkW 31st Jan 05 if pre-up fix for RaConfig
15345 * LuisCorreia 23rd Feb 05 fix unknown IOCTL's
15346 * MarkW 9th Mar 05 Quality reporting in scan for current
15347 * MarkW 9th Jun 05 Fix channel change for ADHOC mode
15348 - ***************************************************************************/
15349 + * RomainB 31st Dec 06 RFMON getter
15350 + ***************************************************************************/
15352 #include "rt_config.h"
15353 #include <net/iw_handler.h>
15354 @@ -154,7 +155,7 @@
15357 struct iw_priv_args privtab[] = {
15358 -{ RTPRIV_IOCTL_SET,
15359 +{ RTPRIV_IOCTL_SET,
15360 IW_PRIV_TYPE_CHAR | 1024, 0,
15362 { RTPRIV_IOCTL_BBP,
15363 @@ -166,9 +167,12 @@
15364 { RTPRIV_IOCTL_E2P,
15365 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
15367 -{ RTPRIV_IOCTL_RFMONTX,
15368 - IW_PRIV_TYPE_INT | 2, IW_PRIV_TYPE_CHAR | sizeof (char),
15370 +{ RTPRIV_IOCTL_SET_RFMONTX,
15371 + IW_PRIV_TYPE_INT | 2, 0,
15373 +{ RTPRIV_IOCTL_GET_RFMONTX,
15374 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
15379 @@ -198,6 +202,9 @@
15380 {"Key4", Set_Key4_Proc},
15381 {"WPAPSK", Set_WPAPSK_Proc},
15382 {"WPANONE", Set_WPANONE_Proc},
15384 + {"Debug", Set_Debug_Proc},
15388 {"ATE", Set_ATE_Proc }, // set ATE Mode to: STOP, TXCONT, TXCARR, TXFRAME, RXFRAME
15389 @@ -233,7 +240,13 @@
15393 - DBGPRINT(RT_DEBUG_TRACE,"0. rtusb_ioctl_giwrange\n");
15394 + //check if the interface is down
15395 + if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
15396 + DBGPRINT(RT_DEBUG_TRACE, "INFO::Network is down!\n");
15397 + return -ENETDOWN;
15400 + DBGPRINT(RT_DEBUG_TRACE,"0. rt_ioctl_giwrange\n");
15401 data->length = sizeof(struct iw_range);
15402 memset(range, 0, sizeof(struct iw_range));
15404 @@ -266,7 +279,7 @@
15406 range->freq[val].i = chan;
15407 MAP_CHANNEL_ID_TO_KHZ(range->freq[val].i, range->freq[val].m);
15408 - range->freq[val].m*=100;
15409 + range->freq[val].m*=100;
15410 range->freq[val].e = 1;
15413 @@ -335,8 +348,8 @@
15418 - while ((this_char = strsep(&extra, ",")) != NULL)
15420 + while ((this_char = strsep(&extra, ",")) != NULL)
15424 @@ -349,8 +362,8 @@
15426 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
15428 - if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
15430 + if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
15432 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
15433 { //FALSE:Set private failed then return Invalid argument
15435 @@ -382,6 +395,13 @@
15436 PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
15437 int Status = NDIS_STATUS_SUCCESS;
15438 BOOLEAN StateMachineTouched = FALSE;
15440 + //check if the interface is down
15441 + if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
15442 + DBGPRINT(RT_DEBUG_TRACE, "INFO::Network is down!\n");
15443 + return -ENETDOWN;
15446 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
15448 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_MLME_INITIALIZED))
15449 @@ -390,7 +410,7 @@
15452 if ((pAdapter->MediaState == NdisMediaStateConnected) &&
15453 - ((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
15454 + ((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
15455 (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
15456 (pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
15458 @@ -413,15 +433,17 @@
15459 pAdapter->PortCfg.IgnoredScanNumber = 0;
15460 pAdapter->PortCfg.LastScanTime = Now;
15462 - MlmeEnqueue(&pAdapter->Mlme.Queue,
15463 - MLME_CNTL_STATE_MACHINE,
15464 - OID_802_11_BSSID_LIST_SCAN,
15466 + MlmeEnqueue(&pAdapter->Mlme.Queue,
15467 + MLME_CNTL_STATE_MACHINE,
15468 + OID_802_11_BSSID_LIST_SCAN,
15472 Status = NDIS_STATUS_SUCCESS;
15473 StateMachineTouched = TRUE;
15475 + if(StateMachineTouched) // Upper layer sent a MLME-related operations
15476 + MlmeHandler(pAdapter);
15480 @@ -437,7 +459,19 @@
15482 struct iw_event iwe;
15484 - for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
15485 + //check if the interface is down
15486 + if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
15487 + DBGPRINT(RT_DEBUG_TRACE, "INFO::Network is down!\n");
15488 + return -ENETDOWN;
15490 + if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)){
15492 + * Still scanning, indicate the caller should try again.
15494 + DBGPRINT(RT_DEBUG_TRACE, "%s: still scanning\n", __FUNCTION__);
15497 + for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
15499 if (current_ev >= end_buf)
15501 @@ -511,25 +545,25 @@
15502 iwe.u.qual.qual = pAdapter->Mlme.ChannelQuality;
15504 iwe.u.qual.qual = 0;
15505 - iwe.u.qual.level = pAdapter->PortCfg.BssTab.BssEntry[i].Rssi - RSSI_TO_DBM_OFFSET; // signal level (dBm)
15506 + iwe.u.qual.level = pAdapter->PortCfg.BssTab.BssEntry[i].Rssi - RSSI_TO_DBM_OFFSET; // signal level (dBm)
15507 iwe.u.qual.noise = pAdapter->PortCfg.BssTab.BssEntry[i].Noise;
15508 - //iwe.u.qual.noise = (pAdapter->PortCfg.LastR17Value > BBP_R17_DYNAMIC_UP_BOUND) ? BBP_R17_DYNAMIC_UP_BOUND : ((ULONG) pAdapter->PortCfg.LastR17Value); // // noise level (dBm)
15509 + //iwe.u.qual.noise = (pAdapter->PortCfg.LastR17Value > BBP_R17_DYNAMIC_UP_BOUND) ? BBP_R17_DYNAMIC_UP_BOUND : ((ULONG) pAdapter->PortCfg.LastR17Value); // // noise level (dBm)
15511 - current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_QUAL_LEN);
15512 + current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_QUAL_LEN);
15515 //================================
15516 memset(&iwe, 0, sizeof(iwe));
15518 data->length = current_ev - extra;
15519 - DBGPRINT(RT_DEBUG_TRACE,"rtusb_ioctl_giwscan. %d BSS returned\n",pAdapter->PortCfg.BssTab.BssNr);
15520 + DBGPRINT(RT_DEBUG_TRACE,"rt_ioctl_giwscan. %d BSS returned\n",pAdapter->PortCfg.BssTab.BssNr);
15524 static const iw_handler rt_handler[] =
15526 (iw_handler) NULL, /* SIOCSIWCOMMIT */
15527 - (iw_handler) NULL, /* SIOCGIWNAME 1 */
15528 + (iw_handler) NULL, /* SIOCGIWNAME 1 */
15529 (iw_handler) NULL, /* SIOCSIWNWID */
15530 (iw_handler) NULL, /* SIOCGIWNWID */
15531 (iw_handler) NULL, /* SIOCSIWFREQ */
15532 @@ -641,9 +675,11 @@
15535 case OID_802_11_BSSID_LIST_SCAN:
15536 + if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_MLME_INITIALIZED))
15539 - TxTotalCnt = pAdapter->DrsCounters.OneSecTxOkCount +
15540 - pAdapter->DrsCounters.OneSecTxRetryOkCount +
15541 + TxTotalCnt = pAdapter->DrsCounters.OneSecTxOkCount +
15542 + pAdapter->DrsCounters.OneSecTxRetryOkCount +
15543 pAdapter->DrsCounters.OneSecTxFailCount;
15544 DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", TxTotalCnt);
15545 // For XP WZC, we will allow scan every 10 times, roughly 10 minutes.
15546 @@ -657,9 +693,9 @@
15547 pAdapter->PortCfg.IgnoredScanNumber++;
15552 if ((pAdapter->MediaState == NdisMediaStateConnected) &&
15553 - ((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
15554 + ((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
15555 (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
15556 (pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
15558 @@ -682,10 +718,10 @@
15559 pAdapter->PortCfg.IgnoredScanNumber = 0;
15560 pAdapter->PortCfg.LastScanTime = Now;
15562 - MlmeEnqueue(&pAdapter->Mlme.Queue,
15563 - MLME_CNTL_STATE_MACHINE,
15564 - OID_802_11_BSSID_LIST_SCAN,
15566 + MlmeEnqueue(&pAdapter->Mlme.Queue,
15567 + MLME_CNTL_STATE_MACHINE,
15568 + OID_802_11_BSSID_LIST_SCAN,
15572 Status = NDIS_STATUS_SUCCESS;
15573 @@ -710,13 +746,13 @@
15575 MlmeRestartStateMachine(pAdapter);
15576 DBGPRINT(RT_DEBUG_TRACE, "!!! MLME busy, reset MLME state machine !!!\n");
15579 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
15580 // this request, because this request is initiated by NDIS.
15581 - pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15582 + pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15584 - MlmeEnqueue(&pAdapter->Mlme.Queue,
15585 - MLME_CNTL_STATE_MACHINE,
15586 + MlmeEnqueue(&pAdapter->Mlme.Queue,
15587 + MLME_CNTL_STATE_MACHINE,
15589 sizeof(NDIS_802_11_SSID),
15591 @@ -746,11 +782,11 @@
15593 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
15594 // this request, because this request is initiated by NDIS.
15595 - pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15596 + pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15598 - MlmeEnqueue(&pAdapter->Mlme.Queue,
15599 - MLME_CNTL_STATE_MACHINE,
15600 - OID_802_11_BSSID,
15601 + MlmeEnqueue(&pAdapter->Mlme.Queue,
15602 + MLME_CNTL_STATE_MACHINE,
15603 + OID_802_11_BSSID,
15604 sizeof(NDIS_802_11_MAC_ADDRESS),
15606 Status = NDIS_STATUS_SUCCESS;
15607 @@ -906,7 +942,7 @@
15610 case OID_802_11_AUTHENTICATION_MODE:
15611 - if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
15612 + if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
15616 @@ -941,7 +977,7 @@
15620 - if (BssType == Ndis802_11IBSS)
15621 + if (BssType == Ndis802_11IBSS)
15623 if (pAdapter->PortCfg.BssType != BSS_INDEP)
15625 @@ -951,7 +987,7 @@
15626 pAdapter->PortCfg.BssType = BSS_INDEP;
15627 DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_INFRASTRUCTURE_MODE (AD-HOC)\n");
15629 - else if (BssType == Ndis802_11Infrastructure)
15630 + else if (BssType == Ndis802_11Infrastructure)
15632 if (pAdapter->PortCfg.BssType != BSS_INFRA)
15634 @@ -1028,7 +1064,7 @@
15637 // save user's policy here, but not change PortCfg.Psm immediately
15638 - if (PowerMode == Ndis802_11PowerModeCAM)
15639 + if (PowerMode == Ndis802_11PowerModeCAM)
15641 // clear PSM bit immediately
15642 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
15643 @@ -1037,7 +1073,7 @@
15644 pAdapter->PortCfg.WindowsPowerMode = PowerMode;
15645 pAdapter->PortCfg.WindowsBatteryPowerMode = PowerMode;
15647 - else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
15648 + else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
15650 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
15651 // to exclude certain situations.
15652 @@ -1048,7 +1084,7 @@
15653 pAdapter->PortCfg.RecvDtim = TRUE; // FALSE;
15654 pAdapter->PortCfg.DefaultListenCount = 5;
15656 - else if (PowerMode == Ndis802_11PowerModeFast_PSP)
15657 + else if (PowerMode == Ndis802_11PowerModeFast_PSP)
15659 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
15660 // to exclude certain situations.
15661 @@ -1236,6 +1272,8 @@
15662 Status = -EOPNOTSUPP;
15665 + if(StateMachineTouched) // Upper layer sent a MLME-related operations
15666 + MlmeHandler(pAdapter);
15670 @@ -1305,8 +1343,8 @@
15671 DBGPRINT(RT_DEBUG_TRACE, "Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->PortCfg.BssTab.BssNr);
15672 // Claculate total buffer size required
15673 BssBufSize = sizeof(ULONG);
15675 - for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
15677 + for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
15679 // Align pointer to 4 bytes boundary.
15680 Padding = 4 - (pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen & 0x0003);
15681 @@ -1328,13 +1366,13 @@
15682 memset(pBuf, 0, BssBufSize);
15683 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
15684 pBssidList->NumberOfItems = pAdapter->PortCfg.BssTab.BssNr;
15687 // Calculate total buffer length
15688 BssLen = 4; // Consist of NumberOfItems
15689 // Point to start of NDIS_WLAN_BSSID_EX
15690 // pPtr = pBuf + sizeof(ULONG);
15691 pPtr = (PUCHAR) &pBssidList->Bssid[0];
15692 - for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
15693 + for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
15695 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
15696 memcpy(&pBss->MacAddress, &pAdapter->PortCfg.BssTab.BssEntry[i].Bssid, ETH_ALEN);
15697 @@ -1348,7 +1386,7 @@
15698 memcpy(pBss->Ssid.Ssid, pAdapter->PortCfg.BssTab.BssEntry[i].Ssid, pAdapter->PortCfg.BssTab.BssEntry[i].SsidLen);
15700 pBss->Privacy = pAdapter->PortCfg.BssTab.BssEntry[i].Privacy;
15701 - pBss->Rssi = pAdapter->PortCfg.BssTab.BssEntry[i].Rssi - pAdapter->PortCfg.RssiToDbm;
15702 + pBss->Rssi = pAdapter->PortCfg.BssTab.BssEntry[i].Rssi - pAdapter->PortCfg.RssiToDbm;
15703 pBss->NetworkTypeInUse = Ndis802_11DS;
15704 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
15705 pBss->Configuration.BeaconPeriod = pAdapter->PortCfg.BssTab.BssEntry[i].BeaconPeriod;
15706 @@ -1356,7 +1394,7 @@
15708 MAP_CHANNEL_ID_TO_KHZ(pAdapter->PortCfg.BssTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
15710 - if (pAdapter->PortCfg.BssTab.BssEntry[i].BssType == BSS_INFRA)
15711 + if (pAdapter->PortCfg.BssTab.BssEntry[i].BssType == BSS_INFRA)
15712 pBss->InfrastructureMode = Ndis802_11Infrastructure;
15714 pBss->InfrastructureMode = Ndis802_11IBSS;
15715 @@ -1370,12 +1408,12 @@
15717 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
15718 memcpy(pBss->IEs, &pAdapter->PortCfg.BssTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
15719 - pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs);
15720 + pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
15724 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen;
15725 - pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs);
15726 + pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
15727 memcpy(pBss->IEs, &pAdapter->PortCfg.BssTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
15728 memcpy(pPtr, pAdapter->PortCfg.BssTab.BssEntry[i].VarIEs, pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen);
15729 pPtr += pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen;
15730 @@ -1385,7 +1423,7 @@
15734 - pBss->Length = sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen + Padding;
15735 + pBss->Length = sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen + Padding;
15736 BssLen += pBss->Length;
15738 wrq->u.data.length = BssLen;
15739 @@ -1451,11 +1489,11 @@
15740 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
15741 if(copy_to_user(wrq->u.data.pointer, &Configuration, wrq->u.data.length))
15743 - DBGPRINT(RT_DEBUG_TRACE, "Query::OID_802_11_CONFIGURATION(BeaconPeriod=%d,AtimW=%d,Channel=%d) \n",
15744 + DBGPRINT(RT_DEBUG_TRACE, "Query::OID_802_11_CONFIGURATION(BeaconPeriod=%d,AtimW=%d,Channel=%d) \n",
15745 Configuration.BeaconPeriod, Configuration.ATIMWindow, pAdapter->PortCfg.Channel);
15747 case OID_802_11_RSSI:
15748 - ulInfo = pAdapter->PortCfg.LastRssi - pAdapter->PortCfg.RssiToDbm;
15749 + ulInfo = pAdapter->PortCfg.LastRssi - pAdapter->PortCfg.RssiToDbm;
15750 wrq->u.data.length = sizeof(ulInfo);
15751 if(copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
15753 @@ -1484,7 +1522,7 @@
15754 Statistics.FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
15755 Statistics.ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
15756 Statistics.MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
15759 Statistics.FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
15761 Statistics.FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
15762 @@ -1611,8 +1649,8 @@
15766 - IN struct net_device *net_dev,
15767 - IN OUT struct ifreq *rq,
15768 + IN struct net_device *net_dev,
15769 + IN OUT struct ifreq *rq,
15772 PRTMP_ADAPTER pAdapter= net_dev->priv;
15773 @@ -1624,16 +1662,17 @@
15774 NDIS_802_11_RTS_THRESHOLD RtsThresh;
15775 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
15776 NDIS_802_11_MAC_ADDRESS Bssid;
15777 - INT Status = NDIS_STATUS_SUCCESS;
15778 + INT Status = NDIS_STATUS_SUCCESS;
15780 BOOLEAN StateMachineTouched = FALSE;
15781 int i, chan = -1, index = 0, len = 0;
15787 DBGPRINT(RT_DEBUG_TRACE, "IOCTL::SIOCGIWNAME\n");
15788 - strcpy(wrq->u.name, "RT2500 Wireless"); //Less then 16 bytes.
15789 + strcpy(wrq->u.name, "RT2500 Wireless"); //Less then 16 bytes.
15791 case SIOCSIWESSID: //Set ESSID
15792 erq = &wrq->u.essid;
15793 @@ -1646,30 +1685,36 @@
15797 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
15798 + Length = erq->length - 1; // minux null character.
15800 + Length = erq->length;
15803 if(RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
15805 - if (copy_from_user(Ssid.Ssid, erq->pointer, (erq->length - 1)))
15806 + if (copy_from_user(Ssid.Ssid, erq->pointer, Length))
15811 - Ssid.SsidLength = erq->length - 1; //minus null character.
15812 + Ssid.SsidLength = Length;
15814 // This SEEMS to be needed to actual work RobinC when iface
15816 - if (copy_from_user(pAdapter->PortCfg.Ssid, erq->pointer, (erq->length - 1)))
15817 + if (copy_from_user(pAdapter->PortCfg.Ssid, erq->pointer, Length))
15822 - pAdapter->PortCfg.SsidLen = erq->length - 1; //minus null character.
15823 + pAdapter->PortCfg.SsidLen = Length;
15825 - memcpy(pAdapter->Mlme.CntlAux.Ssid, pAdapter->PortCfg.Ssid, pAdapter->PortCfg.SsidLen);
15826 - pAdapter->Mlme.CntlAux.SsidLen = pAdapter->PortCfg.SsidLen;
15827 + memcpy(pAdapter->Mlme.CntlAux.Ssid, pAdapter->PortCfg.Ssid, pAdapter->PortCfg.SsidLen);
15828 + pAdapter->Mlme.CntlAux.SsidLen = pAdapter->PortCfg.SsidLen;
15832 - Ssid.SsidLength = 0; // ANY ssid
15833 + Ssid.SsidLength = 0; // ANY ssid
15837 @@ -1686,10 +1731,10 @@
15839 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
15840 // this request, because this request is initiated by NDIS.
15841 - pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15842 + pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15844 - MlmeEnqueue(&pAdapter->Mlme.Queue,
15845 - MLME_CNTL_STATE_MACHINE,
15846 + MlmeEnqueue(&pAdapter->Mlme.Queue,
15847 + MLME_CNTL_STATE_MACHINE,
15849 sizeof(NDIS_802_11_SSID),
15851 @@ -1708,7 +1753,7 @@
15853 DBGPRINT(RT_DEBUG_TRACE, "ioctl::SIOCGIWESSID (Len=%d, ssid=%s...)\n", erq->length, pAdapter->PortCfg.Ssid);
15855 - case SIOCGIWNWID: // get network id
15856 + case SIOCGIWNWID: // get network id
15857 Status = -EOPNOTSUPP;
15859 case SIOCSIWNWID: // set network id (the cell)
15860 @@ -1717,14 +1762,14 @@
15861 case SIOCSIWFREQ: // set channel/frequency (Hz)
15862 frq = &wrq->u.freq;
15863 if((frq->e == 0) && (frq->m <= 1000))
15864 - chan = frq->m; // Setting by channel number
15865 + chan = frq->m; // Setting by channel number
15867 - MAP_KHZ_TO_CHANNEL_ID( (frq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
15868 + MAP_KHZ_TO_CHANNEL_ID( (frq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
15869 pAdapter->PortCfg.IbssConfig.Channel = chan;
15870 DBGPRINT(RT_DEBUG_TRACE, "ioctl::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->PortCfg.IbssConfig.Channel);
15871 if(RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE) && (pAdapter->PortCfg.BssType == BSS_MONITOR || pAdapter->PortCfg.BssType == BSS_INDEP))
15873 - pAdapter->PortCfg.Channel = chan;
15874 + pAdapter->PortCfg.Channel = chan;
15875 AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel);
15876 AsicLockChannel(pAdapter, pAdapter->PortCfg.Channel);
15878 @@ -1822,7 +1867,7 @@
15879 if(wrq->u.encoding.pointer)
15881 wrq->u.encoding.length = pAdapter->PortCfg.SharedKey[index].KeyLen;
15882 - if(copy_to_user(wrq->u.encoding.pointer,
15883 + if(copy_to_user(wrq->u.encoding.pointer,
15884 pAdapter->PortCfg.SharedKey[index].Key,
15885 pAdapter->PortCfg.SharedKey[index].KeyLen))
15887 @@ -1843,14 +1888,15 @@
15888 len = WEP_LARGE_KEY_LEN;
15890 memset(pAdapter->PortCfg.SharedKey[index].Key, 0x00, MAX_LEN_OF_KEY);
15891 - if(copy_from_user(pAdapter->PortCfg.SharedKey[index].Key,
15892 + if(copy_from_user(pAdapter->PortCfg.SharedKey[index].Key,
15893 wrq->u.encoding.pointer, len)){
15897 pAdapter->PortCfg.SharedKey[index].KeyLen = len <= WEP_SMALL_KEY_LEN ? WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;
15899 - pAdapter->PortCfg.DefaultKeyId = (UCHAR) index;
15901 + pAdapter->PortCfg.DefaultKeyId = (UCHAR) index;
15902 if (wrq->u.encoding.flags & IW_ENCODE_DISABLED)
15903 pAdapter->PortCfg.WepStatus = Ndis802_11WEPDisabled;
15905 @@ -1858,7 +1904,7 @@
15907 if (wrq->u.encoding.flags & IW_ENCODE_RESTRICTED)
15908 pAdapter->PortCfg.AuthMode = Ndis802_11AuthModeShared;
15909 - if (wrq->u.encoding.flags & IW_ENCODE_OPEN)
15910 + if (wrq->u.encoding.flags & IW_ENCODE_OPEN)
15911 pAdapter->PortCfg.AuthMode = Ndis802_11AuthModeOpen;
15913 if(pAdapter->PortCfg.WepStatus == Ndis802_11WEPDisabled)
15914 @@ -1905,11 +1951,11 @@
15916 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
15917 // this request, because this request is initiated by NDIS.
15918 - pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15919 + pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
15921 - MlmeEnqueue(&pAdapter->Mlme.Queue,
15922 - MLME_CNTL_STATE_MACHINE,
15923 - OID_802_11_BSSID,
15924 + MlmeEnqueue(&pAdapter->Mlme.Queue,
15925 + MLME_CNTL_STATE_MACHINE,
15926 + OID_802_11_BSSID,
15927 sizeof(NDIS_802_11_MAC_ADDRESS),
15929 Status = NDIS_STATUS_SUCCESS;
15930 @@ -1928,13 +1974,13 @@
15931 BssType = Ndis802_11Infrastructure;
15932 wrq->u.mode = IW_MODE_INFRA;
15934 -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
15935 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
15936 else if (pAdapter->PortCfg.BssType == BSS_MONITOR)
15938 BssType = Ndis802_11Monitor;
15939 wrq->u.mode = IW_MODE_MONITOR;
15945 BssType = Ndis802_11AutoUnknown;
15946 @@ -1963,7 +2009,7 @@
15947 pAdapter->PortCfg.BssType = BSS_INFRA;
15948 DBGPRINT(RT_DEBUG_TRACE, "ioctl::SIOCSIWMODE (INFRA)\n");
15950 -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
15951 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
15952 else if (wrq->u.mode == IW_MODE_MONITOR)
15954 if (pAdapter->PortCfg.BssType != BSS_MONITOR)
15955 @@ -1974,7 +2020,7 @@
15956 pAdapter->PortCfg.BssType = BSS_MONITOR;
15957 DBGPRINT(RT_DEBUG_TRACE, "ioctl::SIOCSIWMODE (MONITOR)\n");
15964 @@ -1999,7 +2045,7 @@
15968 - pAdapter->net_dev->type = 1;
15969 + pAdapter->net_dev->type = 1;
15970 RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x7e);
15973 @@ -2013,23 +2059,23 @@
15974 Status = -EOPNOTSUPP;
15976 case SIOCGIWTXPOW: //get transmit power (dBm)
15977 -#if WIRELESS_EXT >= 17
15978 +#if WIRELESS_EXT >= 17
15979 // Krellan: Get TxPower in dBm now, not percentage
15982 UCHAR Channel = pAdapter->PortCfg.Channel;
15985 // Krellan: This code comes from AsicSwitchChannel(),
15986 // as we must know the channel we are currently on,
15987 // in order to get the correct EEPROM-recommended
15988 // value to establish as 0 dBm.
15989 - if (Channel <= 14)
15990 + if (Channel <= 14)
15991 R3 = pAdapter->PortCfg.ChannelTxPower[Channel - 1];
15994 R3 = pAdapter->PortCfg.ChannelTxPower[0];
15996 if (R3 > 31) R3 = 31;
15999 wrq->u.txpower.value = pAdapter->PortCfg.TxPowerDriver - R3;
16000 wrq->u.txpower.flags = IW_TXPOW_DBM;
16001 wrq->u.txpower.fixed = !(pAdapter->PortCfg.TxPowerAuto);
16002 @@ -2061,7 +2107,7 @@
16005 Value = wrq->u.txpower.value;
16008 if (Value < MIN_TXPOWER_DBM || Value > MAX_TXPOWER_DBM)
16011 @@ -2107,14 +2153,14 @@
16014 case RTPRIV_IOCTL_SET:
16020 if( !access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) )
16023 - while ((this_char = strsep((char**)&wrq->u.data.pointer, ",")) != NULL)
16024 + while ((this_char = strsep((char**)&wrq->u.data.pointer, ",")) != NULL)
16028 @@ -2127,8 +2173,8 @@
16030 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
16032 - if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
16034 + if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
16036 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
16037 { //FALSE:Set private failed then return Invalid argument
16039 @@ -2161,8 +2207,12 @@
16043 - case RTPRIV_IOCTL_RFMONTX:
16044 - Status = RTMPIoctlRFMONTX(pAdapter, wrq);
16045 + case RTPRIV_IOCTL_SET_RFMONTX:
16046 + Status = RTMPIoctlSetRFMONTX(pAdapter, wrq);
16049 + case RTPRIV_IOCTL_GET_RFMONTX:
16050 + Status = RTMPIoctlGetRFMONTX(pAdapter, wrq);
16054 @@ -2181,7 +2231,7 @@
16055 UCHAR BCAST[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
16057 ========================================================================
16060 Routine Description:
16061 Add WPA key process
16063 @@ -2193,7 +2243,7 @@
16064 NDIS_SUCCESS Add key successfully
16069 ========================================================================
16071 NDIS_STATUS RTMPWPAAddKeyProc(
16072 @@ -2228,7 +2278,7 @@
16073 // 1. KeyIdx must be 0, otherwise, return NDIS_STATUS_INVALID_DATA
16075 return(NDIS_STATUS_FAILURE);
16078 // 2. Check bTx, it must be true, otherwise, return NDIS_STATUS_INVALID_DATA
16079 if (bTxKey == FALSE)
16080 return(NDIS_STATUS_FAILURE);
16081 @@ -2236,7 +2286,7 @@
16082 // 3. If BSSID is not all 0xff, return NDIS_STATUS_INVALID_DATA
16083 if (NdisEqualMemory(pKey->BSSID, BCAST, 6))
16084 return(NDIS_STATUS_FAILURE);
16087 // 4. Selct RxMic / TxMic based on Supp / Authenticator
16088 if (pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPANone)
16090 @@ -2277,16 +2327,16 @@
16092 if (bKeyRSC == TRUE)
16094 - memcpy(&pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc, &pKey->KeyRSC, 6);
16095 + memcpy(&pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc, &pKey->KeyRSC, 6);
16099 - memset(pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc, 0, 6);
16100 + memset(pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc, 0, 6);
16103 // 7. Copy information into Pairwise Key structure.
16104 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
16105 - pAdapter->PortCfg.PairwiseKey[PairwiseIdx].KeyLen = 16;
16106 + pAdapter->PortCfg.PairwiseKey[PairwiseIdx].KeyLen = 16;
16107 memcpy(pAdapter->PortCfg.PairwiseKey[PairwiseIdx].Key, &pKey->KeyMaterial, 16);
16108 memcpy(pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxMic, pRxMic, 8);
16109 memcpy(pAdapter->PortCfg.PairwiseKey[PairwiseIdx].TxMic, pTxMic, 8);
16110 @@ -2300,36 +2350,43 @@
16111 pAdapter->PortCfg.PairwiseKey[PairwiseIdx].TxTsc[5] = 0;
16112 Status = NDIS_STATUS_SUCCESS;
16114 - DBGPRINT(RT_DEBUG_INFO, "TKIP Key = ");
16116 + printk("Pairwise Key (Index-%d) = ", PairwiseIdx);
16117 for (i = 0; i < 16; i++)
16119 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].Key[i]);
16121 + pAdapter->PortCfg.PairwiseKey[PairwiseIdx].Key[i]);
16123 - DBGPRINT(RT_DEBUG_INFO, "\n");
16124 - DBGPRINT(RT_DEBUG_INFO, "TKIP Rx MIC Key = ");
16126 + printk("PairwiseKey Rx MIC Key = ");
16127 for (i = 0; i < 8; i++)
16129 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxMic[i]);
16131 + pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxMic[i]);
16133 - DBGPRINT(RT_DEBUG_INFO, "\n");
16134 - DBGPRINT(RT_DEBUG_INFO, "TKIP Tx MIC Key = ");
16136 + printk("PairwiseKey Tx MIC Key = ");
16137 for (i = 0; i < 8; i++)
16139 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].TxMic[i]);
16141 + pAdapter->PortCfg.PairwiseKey[PairwiseIdx].TxMic[i]);
16143 - DBGPRINT(RT_DEBUG_INFO, "\n");
16144 - DBGPRINT(RT_DEBUG_INFO, "TKIP RxTSC = ");
16146 + printk("RxTSC = ");
16147 for (i = 0; i < 6; i++)
16149 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc[i]);
16151 + pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc[i]);
16153 - DBGPRINT(RT_DEBUG_INFO, "\n");
16154 - DBGPRINT(RT_DEBUG_INFO, "BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
16155 - pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]);
16158 + printk("BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
16159 + pKey->BSSID[0], pKey->BSSID[1], pKey->BSSID[2],
16160 + pKey->BSSID[3], pKey->BSSID[4], pKey->BSSID[5]);
16165 + DBGPRINT(RT_DEBUG_TRACE, "Ready to set Group key\n");
16166 // 1. Check BSSID, if not current BSSID or Bcast, return NDIS_STATUS_INVALID_DATA
16167 if ((!NdisEqualMemory(&pKey->BSSID, &BCAST, 6)) &&
16168 (!NdisEqualMemory(&pKey->BSSID, &pAdapter->PortCfg.Bssid, 6)))
16169 @@ -2374,7 +2431,7 @@
16171 // 6. Copy information into Group Key structure.
16172 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
16173 - pAdapter->PortCfg.GroupKey[KeyIdx].KeyLen = 16;
16174 + pAdapter->PortCfg.GroupKey[KeyIdx].KeyLen = 16;
16175 memcpy(pAdapter->PortCfg.GroupKey[KeyIdx].Key, &pKey->KeyMaterial, 16);
16176 memcpy(pAdapter->PortCfg.GroupKey[KeyIdx].RxMic, pRxMic, 8);
16177 memcpy(pAdapter->PortCfg.GroupKey[KeyIdx].TxMic, pTxMic, 8);
16178 @@ -2397,33 +2454,35 @@
16179 memcpy(pAdapter->PortCfg.SharedKey[KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
16182 - DBGPRINT(RT_DEBUG_INFO, "TKIP Key = ");
16184 + printk("GroupKey Key (Index-%d) = ", KeyIdx);
16185 for (i = 0; i < 16; i++)
16187 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].Key[i]);
16188 + printk("%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].Key[i]);
16190 - DBGPRINT(RT_DEBUG_INFO, "\n");
16191 - DBGPRINT(RT_DEBUG_INFO, "TKIP Rx MIC Key = ");
16193 + printk("GroupKey Rx MIC Key = ");
16194 for (i = 0; i < 8; i++)
16196 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxMic[i]);
16197 + printk("%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxMic[i]);
16199 - DBGPRINT(RT_DEBUG_INFO, "\n");
16200 - DBGPRINT(RT_DEBUG_INFO, "TKIP Tx MIC Key = ");
16202 + printk("GroupKey Tx MIC Key = ");
16203 for (i = 0; i < 8; i++)
16205 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].TxMic[i]);
16206 + printk("%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].TxMic[i]);
16208 - DBGPRINT(RT_DEBUG_INFO, "\n");
16209 - DBGPRINT(RT_DEBUG_INFO, "TKIP RxTSC = ");
16211 + printk("RxTSC = ");
16212 for (i = 0; i < 6; i++)
16214 - DBGPRINT(RT_DEBUG_INFO, "%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxTsc[i]);
16215 + printk("%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxTsc[i]);
16217 - DBGPRINT(RT_DEBUG_INFO, "\n");
16218 - DBGPRINT(RT_DEBUG_INFO, "BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
16219 - pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]);
16222 + printk("BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
16223 + pKey->BSSID[0], pKey->BSSID[1], pKey->BSSID[2],
16224 + pKey->BSSID[3], pKey->BSSID[4], pKey->BSSID[5]);
16229 @@ -2499,7 +2558,7 @@
16236 // c. If no pairwise supported, delete Group Key 0.
16237 // The will be false since we do support pairwise keys.
16238 @@ -2545,7 +2604,7 @@
16244 ========================================================================
16246 VOID RTMPWPARemoveAllKeys(
16247 @@ -2562,7 +2621,7 @@
16249 pAdapter->PortCfg.PairwiseKey[i].KeyLen = 0;
16253 for (i = 0; i < GROUP_KEY_NO; i++)
16255 pAdapter->PortCfg.GroupKey[i].KeyLen = 0;
16256 @@ -2578,7 +2637,7 @@
16258 pAdapter Pointer to our adapter
16262 ========================================================================
16264 VOID RTMPSetPhyMode(
16265 @@ -2586,7 +2645,7 @@
16271 DBGPRINT(RT_DEBUG_TRACE,"RTMPSetPhyMode(=%d)\n", phymode);
16273 // the selected phymode must be supported by the RF IC encoded in E2PROM
16274 @@ -2611,7 +2670,7 @@
16275 if (i == pAdapter->PortCfg.ChannelListNum)
16276 pAdapter->PortCfg.IbssConfig.Channel = FirstChannel(pAdapter);
16277 pAdapter->PortCfg.Channel = pAdapter->PortCfg.IbssConfig.Channel;
16280 AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel);
16281 AsicLockChannel(pAdapter, pAdapter->PortCfg.Channel);
16283 @@ -2859,7 +2918,7 @@
16284 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
16285 MlmeUpdateTxRates(pAdapter, FALSE);
16289 ==========================================================================
16292 @@ -2868,7 +2927,7 @@
16293 ==========================================================================
16295 INT Set_CountryRegion_Proc(
16296 - IN PRTMP_ADAPTER pAdapter,
16297 + IN PRTMP_ADAPTER pAdapter,
16301 @@ -2886,7 +2945,7 @@
16307 ==========================================================================
16310 @@ -2895,7 +2954,7 @@
16311 ==========================================================================
16314 - IN PRTMP_ADAPTER pAdapter,
16315 + IN PRTMP_ADAPTER pAdapter,
16318 NDIS_802_11_SSID Ssid, *pSsid=NULL;
16319 @@ -2904,8 +2963,8 @@
16322 /* Protect against oops if net is down, this will not work with if-preup
16323 - use iwconfig properly */
16324 - printk("'iwpriv <dev> set essid' is deprecated, please use 'iwconfg <dev> essid' instead\n");
16325 + use iwconfig properly */
16326 + printk("'iwpriv <dev> set essid' is deprecated, please use 'iwconfg <dev> essid' instead\n");
16327 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
16330 @@ -2916,8 +2975,8 @@
16331 Ssid.SsidLength = strlen(arg);
16338 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
16340 MlmeRestartStateMachine(pAdapter);
16341 @@ -2925,10 +2984,10 @@
16343 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
16344 // this request, because this request is initiated by NDIS.
16345 - pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
16346 + pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE;
16348 - MlmeEnqueue(&pAdapter->Mlme.Queue,
16349 - MLME_CNTL_STATE_MACHINE,
16350 + MlmeEnqueue(&pAdapter->Mlme.Queue,
16351 + MLME_CNTL_STATE_MACHINE,
16353 sizeof(NDIS_802_11_SSID),
16355 @@ -2944,7 +3003,7 @@
16361 ==========================================================================
16364 @@ -2953,26 +3012,24 @@
16365 ==========================================================================
16367 INT Set_WirelessMode_Proc(
16368 - IN PRTMP_ADAPTER pAdapter,
16369 + IN PRTMP_ADAPTER pAdapter,
16372 ULONG WirelessMode;
16373 int success = TRUE;
16375 WirelessMode = simple_strtol(arg, 0, 10);
16376 + DBGPRINT(RT_DEBUG_TRACE, "Set_WirelessMode_Proc::(=%d)\n", WirelessMode);
16378 if ((WirelessMode == PHY_11BG_MIXED) || (WirelessMode == PHY_11B) ||
16379 (WirelessMode == PHY_11A) || (WirelessMode == PHY_11ABG_MIXED))
16381 RTMPSetPhyMode(pAdapter, WirelessMode);
16382 - DBGPRINT(RT_DEBUG_TRACE, "Set_WirelessMode_Proc::(=%d)\n", WirelessMode);
16391 ==========================================================================
16394 @@ -2981,7 +3038,7 @@
16395 ==========================================================================
16397 INT Set_TxRate_Proc(
16398 - IN PRTMP_ADAPTER pAdapter,
16399 + IN PRTMP_ADAPTER pAdapter,
16403 @@ -2996,7 +3053,7 @@
16404 RTMPSetDesiredRates(pAdapter, (LONG) (rate_mapping[TxRate-1] * 1000000));
16409 ==========================================================================
16411 Set AdhocMode support Rate can or can not exceed 11Mbps against WiFi spec.
16412 @@ -3005,7 +3062,7 @@
16413 ==========================================================================
16415 INT Set_AdhocModeRate_Proc(
16416 - IN PRTMP_ADAPTER pAdapter,
16417 + IN PRTMP_ADAPTER pAdapter,
16421 @@ -3017,13 +3074,13 @@
16422 else if (AdhocMode == 0)
16423 pAdapter->PortCfg.AdhocMode = 0;
16425 - return FALSE; //Invalid argument
16426 + return FALSE; //Invalid argument
16428 DBGPRINT(RT_DEBUG_TRACE, "Set_AdhocModeRate_Proc::(AdhocMode=%d)\n", pAdapter->PortCfg.AdhocMode);
16434 ==========================================================================
16437 @@ -3032,7 +3089,7 @@
16438 ==========================================================================
16440 INT Set_Channel_Proc(
16441 - IN PRTMP_ADAPTER pAdapter,
16442 + IN PRTMP_ADAPTER pAdapter,
16445 int success = TRUE;
16446 @@ -3051,7 +3108,32 @@
16452 + ==========================================================================
16454 + For Debug information
16456 + TRUE if all parameters are OK, FALSE otherwise
16457 + ==========================================================================
16460 +INT Set_Debug_Proc(
16461 + IN PRTMP_ADAPTER pAdapter,
16465 + DBGPRINT(RT_DEBUG_TRACE, "**************************************************************\n");
16466 + DBGPRINT(RT_DEBUG_TRACE, "==> Set_Debug_Proc arg=%s\n", arg);
16469 + rt2500_setdbg(simple_strtoul(arg, 0, 0));
16471 + DBGPRINT(RT_DEBUG_TRACE, "<== Set_Debug_Proc\n");
16472 + DBGPRINT(RT_DEBUG_TRACE, "**************************************************************\n");
16477 ==========================================================================
16479 Set 11B/11G Protection
16480 @@ -3060,7 +3142,7 @@
16481 ==========================================================================
16483 INT Set_BGProtection_Proc(
16484 - IN PRTMP_ADAPTER pAdapter,
16485 + IN PRTMP_ADAPTER pAdapter,
16489 @@ -3074,15 +3156,15 @@
16491 case 2: //Always OFF
16492 pAdapter->PortCfg.UseBGProtection = 2;
16494 - default: //Invalid argument
16496 + default: //Invalid argument
16499 DBGPRINT(RT_DEBUG_TRACE, "Set_BGProtection_Proc::(BGProtection=%d)\n", pAdapter->PortCfg.UseBGProtection);
16505 ==========================================================================
16507 Set StaWithEtherBridge function on/off
16508 @@ -3091,7 +3173,7 @@
16509 ==========================================================================
16511 INT Set_StaWithEtherBridge_Proc(
16512 - IN PRTMP_ADAPTER pAdapter,
16513 + IN PRTMP_ADAPTER pAdapter,
16517 @@ -3103,14 +3185,14 @@
16519 pAdapter->PortCfg.StaWithEtherBridge.Enable = TRUE;
16521 - default: //Invalid argument
16522 + default: //Invalid argument
16525 DBGPRINT(RT_DEBUG_TRACE, "Set_StaWithEtherBridge_Proc::(StaWithEtherBridge=%d)\n", pAdapter->PortCfg.StaWithEtherBridge.Enable);
16531 ==========================================================================
16534 @@ -3119,7 +3201,7 @@
16535 ==========================================================================
16537 INT Set_TxPreamble_Proc(
16538 - IN PRTMP_ADAPTER pAdapter,
16539 + IN PRTMP_ADAPTER pAdapter,
16542 RT_802_11_PREAMBLE Preamble;
16543 @@ -3138,7 +3220,7 @@
16544 pAdapter->PortCfg.WindowsTxPreamble = Preamble;
16545 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
16547 - default: //Invalid argument
16548 + default: //Invalid argument
16552 @@ -3146,7 +3228,7 @@
16558 ==========================================================================
16561 @@ -3155,15 +3237,15 @@
16562 ==========================================================================
16564 INT Set_RTSThreshold_Proc(
16565 - IN PRTMP_ADAPTER pAdapter,
16566 + IN PRTMP_ADAPTER pAdapter,
16573 NDIS_802_11_RTS_THRESHOLD RtsThresh;
16575 - printk("'iwpriv <dev> set RTSThreshold' is deprecated, please use 'iwconfg <dev> rts' instead\n");
16577 + printk("'iwpriv <dev> set RTSThreshold' is deprecated, please use 'iwconfg <dev> rts' instead\n");
16579 RtsThresh = simple_strtol(arg, 0, 10);
16581 if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
16582 @@ -3176,7 +3258,7 @@
16583 DBGPRINT(RT_DEBUG_TRACE, "Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAdapter->PortCfg.RtsThreshold);
16588 ==========================================================================
16590 Set Fragment Threshold
16591 @@ -3185,14 +3267,14 @@
16592 ==========================================================================
16594 INT Set_FragThreshold_Proc(
16595 - IN PRTMP_ADAPTER pAdapter,
16596 + IN PRTMP_ADAPTER pAdapter,
16599 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
16601 - printk("'iwpriv <dev> set FragThreshold' is deprecated, please use 'iwconfg <dev> frag' instead\n");
16604 + printk("'iwpriv <dev> set FragThreshold' is deprecated, please use 'iwconfg <dev> frag' instead\n");
16607 FragThresh = simple_strtol(arg, 0, 10);
16609 if ( (FragThresh >= MIN_FRAG_THRESHOLD) && (FragThresh <= MAX_FRAG_THRESHOLD))
16610 @@ -3200,7 +3282,7 @@
16611 else if (FragThresh == 0)
16612 pAdapter->PortCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
16614 - return FALSE; //Invalid argument
16615 + return FALSE; //Invalid argument
16617 if (pAdapter->PortCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
16618 pAdapter->PortCfg.bFragmentZeroDisable = TRUE;
16619 @@ -3211,7 +3293,7 @@
16625 ==========================================================================
16628 @@ -3220,7 +3302,7 @@
16629 ==========================================================================
16631 INT Set_TxBurst_Proc(
16632 - IN PRTMP_ADAPTER pAdapter,
16633 + IN PRTMP_ADAPTER pAdapter,
16637 @@ -3232,13 +3314,13 @@
16638 else if (TxBurst == 0)
16639 pAdapter->PortCfg.EnableTxBurst = FALSE;
16641 - return FALSE; //Invalid argument
16643 + return FALSE; //Invalid argument
16645 DBGPRINT(RT_DEBUG_TRACE, "Set_TxBurst_Proc::(TxBurst=%d)\n", pAdapter->PortCfg.EnableTxBurst);
16651 ==========================================================================
16653 Set TurboRate Enable or Disable
16654 @@ -3247,7 +3329,7 @@
16655 ==========================================================================
16657 INT Set_TurboRate_Proc(
16658 - IN PRTMP_ADAPTER pAdapter,
16659 + IN PRTMP_ADAPTER pAdapter,
16663 @@ -3259,13 +3341,13 @@
16664 else if (TurboRate == 0)
16665 pAdapter->PortCfg.EnableTurboRate = FALSE;
16667 - return FALSE; //Invalid argument
16669 + return FALSE; //Invalid argument
16671 DBGPRINT(RT_DEBUG_TRACE, "Set_TurboRate_Proc::(TurboRate=%d)\n", pAdapter->PortCfg.EnableTurboRate);
16677 ==========================================================================
16679 Set Short Slot Time Enable or Disable
16680 @@ -3274,7 +3356,7 @@
16681 ==========================================================================
16683 INT Set_ShortSlot_Proc(
16684 - IN PRTMP_ADAPTER pAdapter,
16685 + IN PRTMP_ADAPTER pAdapter,
16689 @@ -3286,14 +3368,14 @@
16690 else if (ShortSlot == 0)
16691 pAdapter->PortCfg.UseShortSlotTime = FALSE;
16693 - return FALSE; //Invalid argument
16694 + return FALSE; //Invalid argument
16696 DBGPRINT(RT_DEBUG_TRACE, "Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAdapter->PortCfg.UseShortSlotTime);
16703 ==========================================================================
16705 Set Network Type(Infrastructure/Adhoc mode)
16706 @@ -3302,17 +3384,17 @@
16707 ==========================================================================
16709 INT Set_NetworkType_Proc(
16710 - IN PRTMP_ADAPTER pAdapter,
16711 + IN PRTMP_ADAPTER pAdapter,
16715 - printk("'iwpriv <dev> set NetworkType' is deprecated, please use 'iwconfg <dev> mode' instead\n");
16717 + printk("'iwpriv <dev> set NetworkType' is deprecated, please use 'iwconfg <dev> mode' instead\n");
16719 if (strcmp(arg, "Adhoc") == 0)
16720 pAdapter->PortCfg.BssType = BSS_INDEP;
16721 else //Default Infrastructure mode
16722 pAdapter->PortCfg.BssType = BSS_INFRA;
16725 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
16726 pAdapter->PortCfg.WpaState = SS_NOTUSE;
16728 @@ -3321,7 +3403,7 @@
16734 ==========================================================================
16736 Set Authentication mode
16737 @@ -3330,7 +3412,7 @@
16738 ==========================================================================
16740 INT Set_AuthMode_Proc(
16741 - IN PRTMP_ADAPTER pAdapter,
16742 + IN PRTMP_ADAPTER pAdapter,
16745 if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
16746 @@ -3344,7 +3426,7 @@
16747 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
16748 pAdapter->PortCfg.AuthMode = Ndis802_11AuthModeWPANone;
16753 pAdapter->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
16755 @@ -3353,7 +3435,7 @@
16761 ==========================================================================
16763 Set Encryption Type
16764 @@ -3362,7 +3444,7 @@
16765 ==========================================================================
16767 INT Set_EncrypType_Proc(
16768 - IN PRTMP_ADAPTER pAdapter,
16769 + IN PRTMP_ADAPTER pAdapter,
16772 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
16773 @@ -3380,7 +3462,7 @@
16779 ==========================================================================
16782 @@ -3389,24 +3471,24 @@
16783 ==========================================================================
16785 INT Set_DefaultKeyID_Proc(
16786 - IN PRTMP_ADAPTER pAdapter,
16787 + IN PRTMP_ADAPTER pAdapter,
16792 - printk("'iwpriv <dev> set DefaultKeyID' is deprecated, please use 'iwconfg <dev> key' instead\n");
16795 + printk("'iwpriv <dev> set DefaultKeyID' is deprecated, please use 'iwconfg <dev> key' instead\n");
16797 KeyIdx = simple_strtol(arg, 0, 10);
16798 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
16799 pAdapter->PortCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
16801 - return FALSE; //Invalid argument
16802 + return FALSE; //Invalid argument
16804 DBGPRINT(RT_DEBUG_TRACE, "Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->PortCfg.DefaultKeyId);
16810 ==========================================================================
16813 @@ -3415,22 +3497,22 @@
16814 ==========================================================================
16817 - IN PRTMP_ADAPTER pAdapter,
16818 + IN PRTMP_ADAPTER pAdapter,
16824 - printk("'iwpriv <dev> set Key1' is deprecated, please use 'iwconfg <dev> key [1] ' instead\n");
16826 + printk("'iwpriv <dev> set Key1' is deprecated, please use 'iwconfg <dev> key [1] ' instead\n");
16828 KeyLen = strlen(arg);
16832 case 5: //wep 40 Ascii type
16833 pAdapter->PortCfg.SharedKey[0].KeyLen = KeyLen;
16834 - memcpy(pAdapter->PortCfg.SharedKey[0].Key, arg, KeyLen);
16835 - DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii");
16836 + memcpy(pAdapter->PortCfg.SharedKey[0].Key, arg, KeyLen);
16837 + DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii");
16839 case 10: //wep 40 Hex type
16840 for(i=0; i < KeyLen; i++)
16841 @@ -3440,12 +3522,12 @@
16843 pAdapter->PortCfg.SharedKey[0].KeyLen = KeyLen / 2 ;
16844 AtoH(arg, pAdapter->PortCfg.SharedKey[0].Key, KeyLen / 2);
16845 - DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex");
16846 + DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex");
16848 case 13: //wep 104 Ascii type
16849 pAdapter->PortCfg.SharedKey[0].KeyLen = KeyLen;
16850 - memcpy(pAdapter->PortCfg.SharedKey[0].Key, arg, KeyLen);
16851 - DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii");
16852 + memcpy(pAdapter->PortCfg.SharedKey[0].Key, arg, KeyLen);
16853 + DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii");
16855 case 26: //wep 104 Hex type
16856 for(i=0; i < KeyLen; i++)
16857 @@ -3455,16 +3537,16 @@
16859 pAdapter->PortCfg.SharedKey[0].KeyLen = KeyLen / 2 ;
16860 AtoH(arg, pAdapter->PortCfg.SharedKey[0].Key, KeyLen / 2);
16861 - DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex");
16862 + DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex");
16864 - default: //Invalid argument
16865 - DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::Invalid argument (=%s)\n", arg);
16866 + default: //Invalid argument
16867 + DBGPRINT(RT_DEBUG_TRACE, "Set_Key1_Proc::Invalid argument (=%s)\n", arg);
16875 ==========================================================================
16878 @@ -3473,15 +3555,15 @@
16879 ==========================================================================
16882 - IN PRTMP_ADAPTER pAdapter,
16883 + IN PRTMP_ADAPTER pAdapter,
16889 - printk("'iwpriv <dev> set Key2' is deprecated, please use 'iwconfg <dev> key [2] ' instead\n");
16890 + printk("'iwpriv <dev> set Key2' is deprecated, please use 'iwconfg <dev> key [2] ' instead\n");
16894 KeyLen = strlen(arg);
16897 @@ -3503,7 +3585,7 @@
16899 case 13: //wep 104 Ascii type
16900 pAdapter->PortCfg.SharedKey[1].KeyLen = KeyLen;
16901 - memcpy(pAdapter->PortCfg.SharedKey[1].Key, arg, KeyLen);
16902 + memcpy(pAdapter->PortCfg.SharedKey[1].Key, arg, KeyLen);
16903 DBGPRINT(RT_DEBUG_TRACE, "Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii");
16905 case 26: //wep 104 Hex type
16906 @@ -3516,14 +3598,14 @@
16907 AtoH(arg, pAdapter->PortCfg.SharedKey[1].Key, KeyLen / 2);
16908 DBGPRINT(RT_DEBUG_TRACE, "Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex");
16910 - default: //Invalid argument
16911 + default: //Invalid argument
16912 DBGPRINT(RT_DEBUG_TRACE, "Set_Key2_Proc::Invalid argument (=%s)\n", arg);
16920 ==========================================================================
16923 @@ -3532,13 +3614,13 @@
16924 ==========================================================================
16927 - IN PRTMP_ADAPTER pAdapter,
16928 + IN PRTMP_ADAPTER pAdapter,
16934 - printk("'iwpriv <dev> set Key3' is deprecated, please use 'iwconfg <dev> key [3] ' instead\n");
16935 + printk("'iwpriv <dev> set Key3' is deprecated, please use 'iwconfg <dev> key [3] ' instead\n");
16937 KeyLen = strlen(arg);
16939 @@ -3574,14 +3656,14 @@
16940 AtoH(arg, pAdapter->PortCfg.SharedKey[2].Key, KeyLen / 2);
16941 DBGPRINT(RT_DEBUG_TRACE, "Set_Key3_Proc::(Key3=%s and type=%s)\n", arg, "Hex");
16943 - default: //Invalid argument
16944 + default: //Invalid argument
16945 DBGPRINT(RT_DEBUG_TRACE, "Set_Key3_Proc::Invalid argument (=%s)\n", arg);
16953 ==========================================================================
16956 @@ -3590,21 +3672,21 @@
16957 ==========================================================================
16960 - IN PRTMP_ADAPTER pAdapter,
16961 + IN PRTMP_ADAPTER pAdapter,
16967 - printk("'iwpriv <dev> set Key4' is deprecated, please use 'iwconfg <dev> key [4] ' instead\n");
16969 + printk("'iwpriv <dev> set Key4' is deprecated, please use 'iwconfg <dev> key [4] ' instead\n");
16971 KeyLen = strlen(arg);
16975 case 5: //wep 40 Ascii type
16976 pAdapter->PortCfg.SharedKey[3].KeyLen = KeyLen;
16977 - memcpy(pAdapter->PortCfg.SharedKey[3].Key, arg, KeyLen);
16978 + memcpy(pAdapter->PortCfg.SharedKey[3].Key, arg, KeyLen);
16979 DBGPRINT(RT_DEBUG_TRACE, "Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii");
16981 case 10: //wep 40 Hex type
16982 @@ -3632,14 +3714,14 @@
16983 AtoH(arg, pAdapter->PortCfg.SharedKey[3].Key, KeyLen / 2);
16984 DBGPRINT(RT_DEBUG_TRACE, "Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex");
16986 - default: //Invalid argument
16987 + default: //Invalid argument
16988 DBGPRINT(RT_DEBUG_TRACE, "Set_Key4_Proc::Invalid argument (=%s)\n", arg);
16996 ==========================================================================
16999 @@ -3648,7 +3730,7 @@
17000 ==========================================================================
17002 INT Set_WPAPSK_Proc(
17003 - IN PRTMP_ADAPTER pAdapter,
17004 + IN PRTMP_ADAPTER pAdapter,
17007 UCHAR keyMaterial[40];
17008 @@ -3670,16 +3752,16 @@
17010 memcpy(&pAdapter->PortCfg.PskKey.Key, &keyMaterial, 32);
17014 // Use RaConfig as PSK agent.
17015 // Start STA supplicant state machine
17016 pAdapter->PortCfg.WpaState = SS_START;
17025 ==========================================================================
17028 @@ -3689,7 +3771,7 @@
17031 INT Set_WPANONE_Proc(
17032 - IN PRTMP_ADAPTER pAdapter,
17033 + IN PRTMP_ADAPTER pAdapter,
17036 UCHAR keyMaterial[40];
17037 @@ -3700,17 +3782,17 @@
17038 DBGPRINT(RT_DEBUG_TRACE, "Set failed!!(WPANONE=%s), WPANONE key-string required 8 ~ 64 characters \n", arg);
17043 if (strlen(arg) == 64)
17045 - AtoH(arg, pAdapter->PortCfg.PskKey.Key, 32);
17046 + AtoH(arg, keyMaterial, 32);
17050 PasswordHash((char *)arg, pAdapter->Mlme.CntlAux.Ssid, pAdapter->Mlme.CntlAux.SsidLen, keyMaterial);
17052 - memcpy(pAdapter->PortCfg.PskKey.Key, keyMaterial, 32);
17054 + memcpy(pAdapter->PortCfg.PskKey.Key, keyMaterial, 32);
17056 // Use RaConfig as PSK agent.
17057 // Start STA supplicant state machine
17058 pAdapter->PortCfg.WpaState = SS_START;
17059 @@ -3718,7 +3800,7 @@
17060 //-----------------------------------------------------------------------------
17061 // pasted from "RTMPWPAAddKeyProc(...)"
17062 // major on Group Key only.
17067 // 3. Set as default Tx Key if bTxKey is TRUE
17068 @@ -3733,10 +3815,10 @@
17070 // 6. Copy information into Group Key structure.
17071 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
17072 - pAdapter->PortCfg.GroupKey[0].KeyLen = 16;
17073 - memcpy(pAdapter->PortCfg.GroupKey[0].Key, (PUCHAR)(keyMaterial) + 0, 16);
17074 - memcpy(pAdapter->PortCfg.GroupKey[0].RxMic, (PUCHAR)(keyMaterial) + 16, 8);
17075 - memcpy(pAdapter->PortCfg.GroupKey[0].TxMic, (PUCHAR)(keyMaterial) + 16, 8);
17076 + pAdapter->PortCfg.GroupKey[0].KeyLen = 16;
17077 + memcpy(pAdapter->PortCfg.GroupKey[0].Key, &keyMaterial[0], 16);
17078 + memcpy(pAdapter->PortCfg.GroupKey[0].RxMic, &keyMaterial[16], 8);
17079 + memcpy(pAdapter->PortCfg.GroupKey[0].TxMic, &keyMaterial[16], 8);
17080 memcpy(pAdapter->PortCfg.GroupKey[0].BssId, &pAdapter->PortCfg.Bssid, 6);
17082 // Init TxTsc to one based on WiFi WPA specs
17083 @@ -3754,7 +3836,7 @@
17089 ==========================================================================
17092 @@ -3766,7 +3848,7 @@
17098 1.) iwpriv ra0 bbp ==> read all BBP
17099 2.) iwpriv ra0 bbp 1,2,10,32 ==> raed BBP where ID=1,2,10,32
17100 3.) iwpriv ra0 bbp 1=10,17=3E ==> write BBP R1=0x10, R17=0x3E
17101 @@ -3887,9 +3969,9 @@
17105 -int RTMPIoctlRFMONTX(
17106 +int RTMPIoctlSetRFMONTX(
17107 IN PRTMP_ADAPTER pAdapter,
17108 - IN OUT struct iwreq *wrq)
17109 + IN struct iwreq *wrq)
17113 @@ -3898,7 +3980,7 @@
17115 pvalue = wrq->u.data.pointer;
17121 pAdapter->PortCfg.MallowRFMONTx = TRUE;
17122 @@ -3912,18 +3994,19 @@
17123 else return -EINVAL;
17126 - /* Display the state. Use "value" to indicate it. */
17127 - value = pAdapter->PortCfg.MallowRFMONTx == TRUE ? '1'
17129 - wrq->u.data.length = sizeof (char);
17131 - if (copy_to_user (wrq->u.data.pointer, &value, wrq->u.data.length))
17132 - DBGPRINT (RT_DEBUG_ERROR, "RTMPIoctlRFMONTX - copy to user failure.\n");
17136 +int RTMPIoctlGetRFMONTX(
17137 + IN PRTMP_ADAPTER pAdapter,
17138 + OUT struct iwreq *wrq)
17140 + *(int *) wrq->u.name = pAdapter->PortCfg.MallowRFMONTx == TRUE ? 1 : 0;
17147 ==========================================================================
17150 @@ -3935,13 +4018,13 @@
17156 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
17157 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
17158 ==========================================================================
17161 - IN PRTMP_ADAPTER pAdapter,
17162 + IN PRTMP_ADAPTER pAdapter,
17163 IN struct iwreq *wrq)
17166 @@ -3996,7 +4079,7 @@
17168 this_char[4-k+j] = this_char[j];
17173 this_char[3-k++]='0';
17175 @@ -4061,7 +4144,7 @@
17177 temp2[8-k+j] = temp2[j];
17184 @@ -4074,7 +4157,7 @@
17185 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
17187 DBGPRINT(RT_DEBUG_TRACE, "macAddr=%02x, macValue=0x%x\n", macAddr, macValue);
17190 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
17191 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", macAddr, macValue);
17193 @@ -4093,7 +4176,7 @@
17194 wrq->u.data.length = strlen(msg);
17195 if(copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
17196 DBGPRINT(RT_DEBUG_ERROR, "RTMPIoctlMAC - copy to user failure.\n");
17199 DBGPRINT(RT_DEBUG_TRACE, "<==RTMPIoctlMAC\n");
17202 @@ -4102,7 +4185,7 @@
17208 ==========================================================================
17210 Read / Write E2PROM
17211 @@ -4114,13 +4197,13 @@
17217 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
17218 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
17219 ==========================================================================
17221 VOID RTMPIoctlE2PROM(
17222 - IN PRTMP_ADAPTER pAdapter,
17223 + IN PRTMP_ADAPTER pAdapter,
17224 IN struct iwreq *wrq)
17227 @@ -4136,7 +4219,7 @@
17229 msg = kmalloc(1024, GFP_KERNEL);
17230 arg = kmalloc(255, GFP_KERNEL);
17233 DBGPRINT(RT_DEBUG_TRACE, "==>RTMPIoctlE2PROM\n");
17234 memset(msg, 0x00, 1024);
17235 memset(arg, 0x00, 255);
17236 @@ -4178,7 +4261,7 @@
17238 this_char[4-k+j] = this_char[j];
17243 this_char[3-k++]='0';
17245 @@ -4186,7 +4269,7 @@
17246 if(strlen(this_char) == 4)
17248 AtoH(this_char, temp, 4);
17249 - eepAddr = *temp*256 + temp[1];
17250 + eepAddr = *temp*256 + temp[1];
17251 if (eepAddr < 0xFFFF)
17253 eepValue = RTMP_EEPROM_READ16(pAdapter, eepAddr);
17254 @@ -4243,7 +4326,7 @@
17256 temp2[4-k+j] = temp2[j];
17263 @@ -4255,7 +4338,7 @@
17264 eepValue = *temp*256 + temp[1];
17266 DBGPRINT(RT_DEBUG_TRACE, "eepAddr=%02x, eepValue=0x%x\n", eepAddr, eepValue);
17269 RTMP_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
17270 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
17272 @@ -4269,18 +4352,19 @@
17273 if(strlen(msg) == 1)
17274 sprintf(msg+strlen(msg), "===>Error command format!");
17276 - // Copy the information into the user buffer
17277 - DBGPRINT(RT_DEBUG_TRACE, "copy to user [msg=%s]\n", *msg);
17278 + // Copy the information into the user buffer
17279 + DBGPRINT(RT_DEBUG_TRACE, "copy to user [msg=%s]\n", *msg);
17280 wrq->u.data.length = strlen(msg);
17281 - copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
17283 + if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
17284 + DBGPRINT(RT_DEBUG_ERROR, "RTMPIoctlE2PROM - copy to user failure.\n");
17286 DBGPRINT(RT_DEBUG_TRACE, "<==RTMPIoctlE2PROM\n");
17292 -UCHAR TempletFrame[24] = {0x08,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
17293 +UCHAR TempletFrame[24] = {0x08,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
17296 ==========================================================================
17297 @@ -4297,7 +4381,7 @@
17298 ==========================================================================
17301 - IN PRTMP_ADAPTER pAdapter,
17302 + IN PRTMP_ADAPTER pAdapter,
17306 @@ -4305,7 +4389,7 @@
17312 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_Proc (arg = %s)\n", arg);
17315 @@ -4321,8 +4405,8 @@
17317 MacData &= 0xFBFFFFFF;
17319 - if (!strcmp(arg, "STASTOP"))
17321 + if (!strcmp(arg, "STASTOP"))
17323 DBGPRINT(RT_DEBUG_TRACE, "ATE: STASTOP\n");
17325 RTMP_IO_WRITE32(pAdapter, MACCSR1, MacData);
17326 @@ -4333,11 +4417,11 @@
17327 LinkDown(pAdapter);
17328 AsicEnableBssSync(pAdapter);
17329 netif_stop_queue(pAdapter->net_dev);
17330 - RTMPStationStop(pAdapter);
17331 + RTMPStationStop(pAdapter);
17332 RTMP_IO_WRITE32(pAdapter, RXCSR0, 0xffffffff); // Stop Rx
17334 - else if (!strcmp(arg, "STASTART"))
17336 + else if (!strcmp(arg, "STASTART"))
17338 DBGPRINT(RT_DEBUG_TRACE, "ATE: STASTART\n");
17340 RTMP_IO_WRITE32(pAdapter, MACCSR1, MacData);
17341 @@ -4350,9 +4434,9 @@
17342 RTMPStationStart(pAdapter);
17344 else if (!strcmp(arg, "TXCONT")) // Continuous Tx
17347 DBGPRINT(RT_DEBUG_TRACE, "ATE: TXCONT\n");
17350 pAdapter->ate.Mode = ATE_TXCONT;
17353 @@ -4427,7 +4511,7 @@
17354 RTMP_IO_WRITE32(pAdapter, SECCSR1, 0x1);
17356 else if (!strcmp(arg, "TXFRAME")) // Tx Frames --------------------------------------
17359 DBGPRINT(RT_DEBUG_TRACE, "ATE: TXFRAME(Count=%d)\n", pAdapter->ate.TxCount);
17360 pAdapter->ate.Mode = ATE_TXFRAME;
17362 @@ -4435,7 +4519,7 @@
17363 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter, 63, BbpData);
17365 pAdapter->ate.TxDoneCount = 0;
17368 for (i = 0; (i < TX_RING_SIZE) && (i < pAdapter->ate.TxCount); i++)
17370 pTxD = (PTXD_STRUC)pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
17371 @@ -4467,7 +4551,7 @@
17372 RTMP_IO_WRITE32(pAdapter, SECCSR1, 0x1);
17374 else if (!strcmp(arg, "RXFRAME")) // Rx Frames --------------------------------------
17377 DBGPRINT(RT_DEBUG_TRACE, "ATE: RXFRAME\n");
17379 RTMP_IO_WRITE32(pAdapter, MACCSR1, MacData);
17380 @@ -4475,23 +4559,23 @@
17382 pAdapter->ate.Mode = ATE_RXFRAME;
17383 pAdapter->ate.TxDoneCount = pAdapter->ate.TxCount;
17386 RTMP_IO_WRITE32(pAdapter, TXCSR0, 0x08); // Abort Tx
17387 RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x56); // Start Rx
17392 DBGPRINT(RT_DEBUG_TRACE, "ATE: Invalid arg!\n");
17399 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_Proc\n");
17405 ==========================================================================
17407 Set ATE ADDR1=DA for TxFrames Return:
17408 @@ -4499,21 +4583,21 @@
17409 ==========================================================================
17411 INT Set_ATE_DA_Proc(
17412 - IN PRTMP_ADAPTER pAdapter,
17413 + IN PRTMP_ADAPTER pAdapter,
17420 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_DA_Proc\n");
17421 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17424 if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
17427 - for (i=0, value = strtok(arg,":"); value; value = strtok(NULL,":"))
17428 + for (i=0, value = strtok(arg,":"); value; value = strtok(NULL,":"))
17430 - if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
17431 + if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
17432 return FALSE; //Invalid
17434 AtoH(value, &pAdapter->ate.Addr1[i++], 2);
17435 @@ -4521,14 +4605,14 @@
17438 return FALSE; //Invalid
17441 DBGPRINT(RT_DEBUG_TRACE, "DA=%2X:%2X:%2X:%2X:%2X:%2X\n", pAdapter->ate.Addr1[0], pAdapter->ate.Addr1[1], pAdapter->ate.Addr1[2], pAdapter->ate.Addr1[3], pAdapter->ate.Addr1[4], pAdapter->ate.Addr1[5]);
17442 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_DA_Proc\n");
17450 ==========================================================================
17452 Set ATE ADDR2=SA for TxFrames Return:
17453 @@ -4536,21 +4620,21 @@
17454 ==========================================================================
17456 INT Set_ATE_SA_Proc(
17457 - IN PRTMP_ADAPTER pAdapter,
17458 + IN PRTMP_ADAPTER pAdapter,
17465 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_SA_Proc\n");
17466 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17469 if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
17472 - for (i=0, value = strtok(arg,":"); value; value = strtok(NULL,":"))
17473 + for (i=0, value = strtok(arg,":"); value; value = strtok(NULL,":"))
17475 - if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
17476 + if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
17477 return FALSE; //Invalid
17479 AtoH(value, &pAdapter->ate.Addr2[i++], 2);
17480 @@ -4561,11 +4645,11 @@
17482 DBGPRINT(RT_DEBUG_TRACE, "DA=%2X:%2X:%2X:%2X:%2X:%2X\n", pAdapter->ate.Addr2[0], pAdapter->ate.Addr2[1], pAdapter->ate.Addr2[2], pAdapter->ate.Addr2[3], pAdapter->ate.Addr2[4], pAdapter->ate.Addr2[5]);
17483 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_SA_Proc\n");
17491 ==========================================================================
17493 Set ATE ADDR3=BSSID for TxFrames Return:
17494 @@ -4573,21 +4657,21 @@
17495 ==========================================================================
17497 INT Set_ATE_BSSID_Proc(
17498 - IN PRTMP_ADAPTER pAdapter,
17499 + IN PRTMP_ADAPTER pAdapter,
17506 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_BSSID_Proc\n");
17507 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17510 if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
17513 - for (i=0, value = strtok(arg,":"); value; value = strtok(NULL,":"))
17514 + for (i=0, value = strtok(arg,":"); value; value = strtok(NULL,":"))
17516 - if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
17517 + if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
17518 return FALSE; //Invalid
17520 AtoH(value, &pAdapter->ate.Addr3[i++], 2);
17521 @@ -4598,11 +4682,11 @@
17523 DBGPRINT(RT_DEBUG_TRACE, "DA=%2X:%2X:%2X:%2X:%2X:%2X\n", pAdapter->ate.Addr3[0], pAdapter->ate.Addr3[1], pAdapter->ate.Addr3[2], pAdapter->ate.Addr3[3], pAdapter->ate.Addr3[4], pAdapter->ate.Addr3[5]);
17524 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_BSSID_Proc\n");
17532 ==========================================================================
17534 Set ATE Channel Return:
17535 @@ -4610,11 +4694,11 @@
17536 ==========================================================================
17538 INT Set_ATE_CHANNEL_Proc(
17539 - IN PRTMP_ADAPTER pAdapter,
17540 + IN PRTMP_ADAPTER pAdapter,
17543 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_CHANNEL_Proc (arg = %s)\n", arg);
17546 pAdapter->ate.Channel = simple_strtol(arg, 0, 10);
17547 if((pAdapter->ate.Channel < 1) || (pAdapter->ate.Channel > 14))
17549 @@ -4623,11 +4707,11 @@
17552 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAdapter->ate.Channel);
17560 ==========================================================================
17562 Set ATE Tx Power Return:
17563 @@ -4635,14 +4719,14 @@
17564 ==========================================================================
17566 INT Set_ATE_TX_POWER_Proc(
17567 - IN PRTMP_ADAPTER pAdapter,
17568 + IN PRTMP_ADAPTER pAdapter,
17574 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_TX_POWER_Proc\n");
17575 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17578 pAdapter->ate.TxPower = simple_strtol(arg, 0, 10);
17580 if(pAdapter->ate.TxPower >= 32)
17581 @@ -4659,11 +4743,11 @@
17583 DBGPRINT(RT_DEBUG_TRACE, "TxPower = %d\n", pAdapter->ate.TxPower);
17584 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_TX_POWER_Proc\n");
17592 ==========================================================================
17594 Set ATE Tx Length Return:
17595 @@ -4671,12 +4755,12 @@
17596 ==========================================================================
17598 INT Set_ATE_TX_LENGTH_Proc(
17599 - IN PRTMP_ADAPTER pAdapter,
17600 + IN PRTMP_ADAPTER pAdapter,
17603 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_TX_LENGTH_Proc\n");
17604 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17607 pAdapter->ate.TxLength = simple_strtol(arg, 0, 10);
17609 if((pAdapter->ate.TxLength < 24) || (pAdapter->ate.TxLength > 1500))
17610 @@ -4687,11 +4771,11 @@
17612 DBGPRINT(RT_DEBUG_TRACE, "TxLength = %d\n", pAdapter->ate.TxLength);
17613 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_TX_LENGTH_Proc\n");
17621 ==========================================================================
17623 Set ATE Tx Count Return:
17624 @@ -4699,21 +4783,21 @@
17625 ==========================================================================
17627 INT Set_ATE_TX_COUNT_Proc(
17628 - IN PRTMP_ADAPTER pAdapter,
17629 + IN PRTMP_ADAPTER pAdapter,
17632 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_TX_COUNT_Proc\n");
17633 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17636 pAdapter->ate.TxCount = simple_strtol(arg, 0, 10);
17638 DBGPRINT(RT_DEBUG_TRACE, "TxCount = %d\n", pAdapter->ate.TxCount);
17639 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_TX_COUNT_Proc\n");
17647 ==========================================================================
17650 @@ -4722,12 +4806,12 @@
17651 ==========================================================================
17653 INT Set_ATE_TX_RATE_Proc(
17654 - IN PRTMP_ADAPTER pAdapter,
17655 + IN PRTMP_ADAPTER pAdapter,
17658 DBGPRINT(RT_DEBUG_TRACE, "==> Set_ATE_TX_RATE_Proc\n");
17659 DBGPRINT(RT_DEBUG_TRACE, "arg=%s\n", arg);
17662 pAdapter->ate.TxRate = simple_strtol(arg, 0, 10);
17664 if(pAdapter->ate.TxRate > RATE_54)
17665 @@ -4738,7 +4822,7 @@
17667 DBGPRINT(RT_DEBUG_TRACE, "TxRate = %d\n", pAdapter->ate.TxRate);
17668 DBGPRINT(RT_DEBUG_TRACE, "<== Set_ATE_TX_RATE_Proc\n");
17674 @@ -4758,7 +4842,7 @@
17675 RTMPCancelTimer(&pAd->PortCfg.RfTuningTimer);
17676 if (pAd->PortCfg.LedMode == LED_MODE_TXRX_ACTIVITY)
17677 RTMPCancelTimer(&pAd->PortCfg.LedCntl.BlinkTimer);
17678 - RTMPCancelTimer(&pAd->PortCfg.RxAnt.RxAntDiversityTimer);
17679 + RTMPCancelTimer(&pAd->PortCfg.RxAnt.RxAntDiversityTimer);
17680 DBGPRINT(RT_DEBUG_TRACE, "<== RTMPStationStop\n");
17683 diff -Nur rt2500-1.1.0-b4/Module/rtmp_init.c rt2500-cvs-2007061011/Module/rtmp_init.c
17684 --- rt2500-1.1.0-b4/Module/rtmp_init.c 2006-06-17 22:12:58.000000000 +0200
17685 +++ rt2500-cvs-2007061011/Module/rtmp_init.c 2007-05-06 11:13:43.000000000 +0200
17687 -/***************************************************************************
17688 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
17690 - * This program is free software; you can redistribute it and/or modify *
17691 - * it under the terms of the GNU General Public License as published by *
17692 - * the Free Software Foundation; either version 2 of the License, or *
17693 - * (at your option) any later version. *
17695 - * This program is distributed in the hope that it will be useful, *
17696 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17697 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17698 - * GNU General Public License for more details. *
17700 - * You should have received a copy of the GNU General Public License *
17701 - * along with this program; if not, write to the *
17702 - * Free Software Foundation, Inc., *
17703 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17705 - * Licensed under the GNU GPL *
17706 - * Original code supplied under license from RaLink Inc, 2004. *
17707 - ***************************************************************************/
17708 +/***************************************************************************
17709 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
17711 + * This program is free software; you can redistribute it and/or modify *
17712 + * it under the terms of the GNU General Public License as published by *
17713 + * the Free Software Foundation; either version 2 of the License, or *
17714 + * (at your option) any later version. *
17716 + * This program is distributed in the hope that it will be useful, *
17717 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17718 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17719 + * GNU General Public License for more details. *
17721 + * You should have received a copy of the GNU General Public License *
17722 + * along with this program; if not, write to the *
17723 + * Free Software Foundation, Inc., *
17724 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17726 + * Licensed under the GNU GPL *
17727 + * Original code supplied under license from RaLink Inc, 2004. *
17728 + ***************************************************************************/
17730 - /***************************************************************************
17731 + /***************************************************************************
17732 * Module Name: rtmp_init.c
17736 - * Revision History:
17738 - * -------- ----------- -----------------------------
17739 - * PaulL 1st Aug 02 Initial code
17740 - * MarkW 8th Dec 04 Baseline code
17744 + * Revision History:
17746 + * -------- ----------- -----------------------------
17747 + * PaulL 1st Aug 02 Initial code
17748 + * MarkW 8th Dec 04 Baseline code
17749 * MarkW (rt2400) 8th Dec 04 Promisc mode support
17750 * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
17751 * LuisCorreia 15th Feb 05 Added Yann's patch for radio hw
17752 * MarkW 12th Jul 05 Disabled all but CAM Power modes
17753 - ***************************************************************************/
17754 + ***************************************************************************/
17756 #include "rt_config.h"
17759 // {PSCSR2, 0x00023f20}, // 0xd0
17760 {PSCSR2, 0x00020002}, // 0xd0
17761 {PSCSR3, 0x00000002}, // 0xd4
17762 - {TIMECSR, 0x00003f21}, // 0xDC, to slower down our 1-us tick
17763 + {TIMECSR, 0x00003f21}, // 0xDC, to slower down our 1-us tick
17764 {CSR9, 0x00000780}, // 0x24
17765 - {CSR11, 0x07041483}, // 0x2C, lrc=7, src=4, slot=20us, CWmax=2^8, CWmax=2^3
17766 + {CSR11, 0x07041483}, // 0x2C, lrc=7, src=4, slot=20us, CWmax=2^8, CWmax=2^3
17767 {CSR18, 0x00140000}, // SIFS=10us - TR switch time, PIFS=SIFS+20us
17768 {CSR19, 0x016C0028}, // DIFS=SIFS+2*20us, EIFS=364us
17769 {CNT3, 0x00000000}, // Backoff_CCA_Th, RX_&_TX_CCA_Th
17770 @@ -105,17 +105,17 @@
17771 {ARTCSR1, 0x1d21252d}, // 0x150, alexsu : OFDM ACK/CTS payload consumed time for 18/12/9/6 mbps
17772 {ARTCSR2, 0x1919191d}, // 0x154, alexsu : OFDM ACK/CTS payload consumed time for 54/48/36/24 mbps
17774 - {RXCSR0, 0xffffffff}, // 0x80
17775 + {RXCSR0, 0xffffffff}, // 0x80
17776 {RXCSR3, 0xb3aab3af}, // 0x90. RT2530 BBP 51:RSSI, R42:OFDM rate, R47:CCK SIGNAL
17777 {PCICSR, 0x000003b8}, // 0x8c, alexsu : PCI control register
17778 {PWRCSR0, 0x3f3b3100}, // 0xC4
17779 {GPIOCSR, 0x0000ff00}, // 0x120, GPIO default value
17780 {TESTCSR, 0x000000f0}, // 0x138, Test CSR, make sure it's running at normal mode
17781 - {PWRCSR1, 0x000001ff}, // 0xd8
17782 + {PWRCSR1, 0x000001ff}, // 0xd8
17783 {MACCSR0, 0x00213223}, // 0xE0, Enable Tx dribble mode - 2003/10/22:Gary
17784 {MACCSR1, 0x00235518}, // 0xE4, Disable Rx Reset, tx dribble count, 2x30x16 = 960n,
17785 {MACCSR2, 0x00000040}, // 0x0134, 64*33ns = 2us
17786 - {RALINKCSR, 0x9a009a11}, // 0xE8
17787 + {RALINKCSR, 0x9a009a11}, // 0xE8
17788 {CSR7, 0xffffffff}, // 0x1C, Clear all pending interrupt source
17789 {LEDCSR, 0x00001E46}, // default both LEDs off
17790 {BBPCSR1, 0x82188200}, // for 2560+2522
17791 @@ -155,7 +155,7 @@
17793 DBGPRINT(RT_DEBUG_INFO, "--> RTMPAllocDMAMemory\n");
17795 - // 1. Allocate Tx Ring DMA descriptor and buffer memory
17796 + // 1. Allocate Tx Ring DMA descriptor and buffer memory
17797 // Allocate Ring descriptors DMA block
17798 ring = pci_alloc_consistent(pAd->pPci_Dev, (TX_RING_SIZE * RING_DESCRIPTOR_SIZE), &ring_dma);
17800 @@ -165,14 +165,14 @@
17802 // Zero init ring descriptors
17803 memset(ring, 0, (TX_RING_SIZE * RING_DESCRIPTOR_SIZE));
17806 // Allocate Ring data DMA blocks
17807 ring_data = pci_alloc_consistent(pAd->pPci_Dev, (TX_RING_SIZE * TX_BUFFER_SIZE), &ring_data_dma);
17810 // If failed, release ring descriptors DMA block & exit
17812 pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * RING_DESCRIPTOR_SIZE), ring, ring_dma);
17813 - printk(KERN_ERR DRV_NAME "Could not allocate DMA ring buffer memory.\n");
17814 + printk(KERN_ERR DRV_NAME "Could not allocate DMA ring buffer memory.\n");
17815 goto err_out_allocate_txring;
17818 @@ -185,7 +185,7 @@
17819 pAd->TxRing[index].pa_addr = ring_dma;
17820 ring += RING_DESCRIPTOR_SIZE;
17821 ring_dma += RING_DESCRIPTOR_SIZE;
17824 // Init Tx DMA buffer
17825 pAd->TxRing[index].data_size = TX_BUFFER_SIZE;
17826 pAd->TxRing[index].va_data_addr = ring_data;
17827 @@ -207,7 +207,7 @@
17828 index, (unsigned long)pAd->TxRing[index].va_data_addr, (UINT)pAd->TxRing[index].pa_data_addr, pAd->TxRing[index].data_size);
17831 - // 2. Allocate Prio Ring DMA descriptor and buffer memory
17832 + // 2. Allocate Prio Ring DMA descriptor and buffer memory
17833 // Allocate Ring descriptors DMA block
17834 ring = pci_alloc_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * RING_DESCRIPTOR_SIZE), &ring_dma);
17836 @@ -224,7 +224,7 @@
17837 // If failed, release ring descriptors DMA block & exit
17839 pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * RING_DESCRIPTOR_SIZE), ring, ring_dma);
17840 - DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17841 + DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17842 goto err_out_allocate_prioring;
17845 @@ -259,7 +259,7 @@
17846 index, (unsigned long)pAd->PrioRing[index].va_data_addr, (UINT)pAd->PrioRing[index].pa_data_addr, pAd->PrioRing[index].data_size);
17849 - // 3. Allocate Atim Ring DMA descriptor and buffer memory
17850 + // 3. Allocate Atim Ring DMA descriptor and buffer memory
17851 // Allocate Ring descriptors DMA block
17852 ring = pci_alloc_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * RING_DESCRIPTOR_SIZE), &ring_dma);
17854 @@ -276,7 +276,7 @@
17855 // If failed, release ring descriptors DMA block & exit
17857 pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * RING_DESCRIPTOR_SIZE), ring, ring_dma);
17858 - DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17859 + DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17860 goto err_out_allocate_atimring;
17863 @@ -328,7 +328,7 @@
17864 // If failed, release ring descriptors DMA block & exit
17866 pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RING_DESCRIPTOR_SIZE), ring, ring_dma);
17867 - DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17868 + DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17869 goto err_out_allocate_rxring;
17872 @@ -386,7 +386,7 @@
17873 // If failed, release ring descriptors DMA block & exit
17875 pci_free_consistent(pAd->pPci_Dev, RING_DESCRIPTOR_SIZE, ring, ring_dma);
17876 - DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17877 + DBGPRINT(RT_DEBUG_ERROR, "Could not allocate DMA ring buffer memory.\n");
17878 goto err_out_allocate_beaconring;
17881 @@ -418,28 +418,28 @@
17883 err_out_allocate_beaconring:
17884 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17885 - pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RX_BUFFER_SIZE),
17886 + pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RX_BUFFER_SIZE),
17887 pAd->RxRing[0].va_data_addr, pAd->RxRing[0].pa_data_addr);
17888 // Free ring descriptor second, the start address is the same as TxRing first elment
17889 pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RING_DESCRIPTOR_SIZE),
17890 pAd->RxRing[0].va_addr, pAd->RxRing[0].pa_addr);
17891 err_out_allocate_rxring:
17892 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17893 - pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * ATIM_BUFFER_SIZE),
17894 + pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * ATIM_BUFFER_SIZE),
17895 pAd->AtimRing[0].va_data_addr, pAd->AtimRing[0].pa_data_addr);
17896 // Free ring descriptor second, the start address is the same as TxRing first elment
17897 pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * RING_DESCRIPTOR_SIZE),
17898 pAd->AtimRing[0].va_addr, pAd->AtimRing[0].pa_addr);
17899 err_out_allocate_atimring:
17900 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17901 - pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * PRIO_BUFFER_SIZE),
17902 + pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * PRIO_BUFFER_SIZE),
17903 pAd->PrioRing[0].va_data_addr, pAd->PrioRing[0].pa_data_addr);
17904 // Free ring descriptor second, the start address is the same as TxRing first elment
17905 pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * RING_DESCRIPTOR_SIZE),
17906 pAd->PrioRing[0].va_addr, pAd->PrioRing[0].pa_addr);
17907 err_out_allocate_prioring:
17908 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17909 - pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * TX_BUFFER_SIZE),
17910 + pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * TX_BUFFER_SIZE),
17911 pAd->TxRing[0].va_data_addr, pAd->TxRing[0].pa_data_addr);
17912 // Free ring descriptor second, the start address is the same as TxRing first elment
17913 pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * RING_DESCRIPTOR_SIZE),
17914 @@ -472,35 +472,35 @@
17915 DBGPRINT(RT_DEBUG_INFO, "--> RTMPFreeDMAMemory\n");
17917 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17918 - pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * TX_BUFFER_SIZE),
17919 + pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * TX_BUFFER_SIZE),
17920 pAd->TxRing[0].va_data_addr, pAd->TxRing[0].pa_data_addr);
17921 // Free ring descriptor second, the start address is the same as TxRing first elment
17922 pci_free_consistent(pAd->pPci_Dev, (TX_RING_SIZE * RING_DESCRIPTOR_SIZE),
17923 pAd->TxRing[0].va_addr, pAd->TxRing[0].pa_addr);
17925 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17926 - pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * PRIO_BUFFER_SIZE),
17927 + pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * PRIO_BUFFER_SIZE),
17928 pAd->PrioRing[0].va_data_addr, pAd->PrioRing[0].pa_data_addr);
17929 // Free ring descriptor second, the start address is the same as TxRing first elment
17930 pci_free_consistent(pAd->pPci_Dev, (PRIO_RING_SIZE * RING_DESCRIPTOR_SIZE),
17931 pAd->PrioRing[0].va_addr, pAd->PrioRing[0].pa_addr);
17933 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17934 - pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * ATIM_BUFFER_SIZE),
17935 + pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * ATIM_BUFFER_SIZE),
17936 pAd->AtimRing[0].va_data_addr, pAd->AtimRing[0].pa_data_addr);
17937 // Free ring descriptor second, the start address is the same as TxRing first elment
17938 pci_free_consistent(pAd->pPci_Dev, (ATIM_RING_SIZE * RING_DESCRIPTOR_SIZE),
17939 pAd->AtimRing[0].va_addr, pAd->AtimRing[0].pa_addr);
17942 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17943 - pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RX_BUFFER_SIZE),
17944 + pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RX_BUFFER_SIZE),
17945 pAd->RxRing[0].va_data_addr, pAd->RxRing[0].pa_data_addr);
17946 // Free ring descriptor second, the start address is the same as TxRing first elment
17947 pci_free_consistent(pAd->pPci_Dev, (RX_RING_SIZE * RING_DESCRIPTOR_SIZE),
17948 pAd->RxRing[0].va_addr, pAd->RxRing[0].pa_addr);
17950 // Free data DMA blocks first, the start address is the same as TxRing first DMA data block
17951 - pci_free_consistent(pAd->pPci_Dev, (BEACON_RING_SIZE * BEACON_BUFFER_SIZE),
17952 + pci_free_consistent(pAd->pPci_Dev, (BEACON_RING_SIZE * BEACON_BUFFER_SIZE),
17953 pAd->BeaconRing.va_data_addr, pAd->BeaconRing.pa_data_addr);
17954 // Free ring descriptor second, the start address is the same as TxRing first elment
17955 pci_free_consistent(pAd->pPci_Dev, (BEACON_RING_SIZE * RING_DESCRIPTOR_SIZE),
17956 @@ -582,7 +582,7 @@
17957 CSR4_STRUC StaMacReg1;
17958 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
17962 // Read MAC address from CSR3 & CSR4, these CSRs reflects real value
17963 // stored with EEPROM.
17965 @@ -618,7 +618,7 @@
17971 ========================================================================
17973 VOID NICReadEEPROMParameters(
17974 @@ -637,7 +637,7 @@
17975 RTMP_IO_READ32(pAdapter, CSR21, &data);
17978 - pAdapter->EEPROMAddressNum = 6;
17979 + pAdapter->EEPROMAddressNum = 6;
17981 pAdapter->EEPROMAddressNum = 8;
17983 @@ -655,7 +655,7 @@
17984 for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++)
17986 value = RTMP_EEPROM_READ16(pAdapter, EEPROM_BBP_BASE_OFFSET + i*2);
17989 pAdapter->EEPROMDefaultValue[i] = value;
17992 @@ -707,13 +707,13 @@
17993 // Disable TxAgc if the value is not right
17994 if ((pAdapter->PortCfg.ChannelTssiRef[i * 2] == 0xff) ||
17995 (pAdapter->PortCfg.ChannelTssiRef[i * 2 + 1] == 0xff))
17996 - pAdapter->PortCfg.bAutoTxAgc = FALSE;
17997 + pAdapter->PortCfg.bAutoTxAgc = FALSE;
18001 // Tx Tssi delta offset 0x24
18002 Power.word = RTMP_EEPROM_READ16(pAdapter, EEPROM_TSSI_DELTA_OFFSET);
18003 pAdapter->PortCfg.ChannelTssiDelta = Power.field.Byte0;
18008 //CountryRegion byte offset = 0x35
18009 @@ -734,11 +734,11 @@
18010 pAdapter->PortCfg.RssiToDbm = 0x79;
18015 //pAdapter->PortCfg.R17Dec = 0x79 - Power.field.Byte0;
18016 pAdapter->PortCfg.RssiToDbm = Power.field.Byte0;
18021 DBGPRINT(RT_DEBUG_TRACE, "<-- NICReadEEPROMParameters\n");
18023 @@ -769,11 +769,11 @@
18024 EEPROM_NIC_CONFIG2_STRUC NicConfig2;
18026 DBGPRINT(RT_DEBUG_TRACE, "--> NICInitAsicFromEEPROM\n");
18029 for(i = 3; i < NUM_EEPROM_BBP_PARMS; i++)
18031 value = pAdapter->EEPROMDefaultValue[i];
18034 if((value != 0xFFFF) && (value != 0))
18036 data = value | 0x18000;
18037 @@ -802,12 +802,12 @@
18038 // Tx antenna select
18039 if(Antenna.field.TxDefaultAntenna == 1) // Antenna A
18041 - TxValue = (TxValue & 0xFC) | 0x00;
18042 + TxValue = (TxValue & 0xFC) | 0x00;
18043 BbpCsr1 = (BbpCsr1 & 0xFFFCFFFC) | 0x00000000;
18045 else if(Antenna.field.TxDefaultAntenna == 2) // Antenna B
18047 - TxValue = (TxValue & 0xFC) | 0x02;
18048 + TxValue = (TxValue & 0xFC) | 0x02;
18049 BbpCsr1 = (BbpCsr1 & 0xFFFCFFFC) | 0x00020002;
18051 else // diverity - start from Antenna B
18052 @@ -818,12 +818,12 @@
18054 // Rx antenna select
18055 if(Antenna.field.RxDefaultAntenna == 1) // Antenna A
18056 - RxValue = (RxValue & 0xFC) | 0x00;
18057 + RxValue = (RxValue & 0xFC) | 0x00;
18058 else if(Antenna.field.RxDefaultAntenna == 2) // Antenna B
18059 - RxValue = (RxValue & 0xFC) | 0x02;
18060 + RxValue = (RxValue & 0xFC) | 0x02;
18061 else // Antenna Diversity
18062 - RxValue = (RxValue & 0xFC) | 0x02;
18064 + RxValue = (RxValue & 0xFC) | 0x02;
18066 // RT5222 needs special treatment to swap TX I/Q
18067 if (pAdapter->PortCfg.RfType == RFIC_5222)
18069 @@ -831,13 +831,13 @@
18070 TxValue |= 0x04; // TX I/Q flip
18072 // RT2525E need to flip TX I/Q but not RX I/Q
18073 - else if (pAdapter->PortCfg.RfType == RFIC_2525E)
18074 + else if (pAdapter->PortCfg.RfType == RFIC_2525E)
18076 BbpCsr1 |= 0x00040004;
18077 TxValue |= 0x04; // TX I/Q flip
18078 RxValue &= 0xfb; // RX I/Q no flip
18082 // Change to match microsoft definition, 0xff: diversity, 0: A, 1: B
18083 pAdapter->PortCfg.CurrentTxAntenna--;
18084 pAdapter->PortCfg.CurrentRxAntenna--;
18085 @@ -845,7 +845,7 @@
18086 RTMP_IO_WRITE32(pAdapter, BBPCSR1, BbpCsr1);
18087 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter, BBP_Tx_Configure, TxValue);
18088 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter, BBP_Rx_Configure, RxValue);
18091 // 2003-12-16 software-based RX antenna diversity
18092 // pAdapter->PortCfg.CurrentRxAntenna = 0xff; // Diversity ON
18093 AsicSetRxAnt(pAdapter);
18094 @@ -869,7 +869,7 @@
18095 if (0 && Antenna.field.HardwareRadioControl == 1)
18097 pAdapter->PortCfg.bHardwareRadio = TRUE;
18100 // Read GPIO pin0 as Hardware controlled radio state
18101 RTMP_IO_READ32(pAdapter, GPIOCSR, &data);
18102 if ((data & 0x01) == 0)
18103 @@ -886,8 +886,8 @@
18107 - pAdapter->PortCfg.bHardwareRadio = FALSE;
18109 + pAdapter->PortCfg.bHardwareRadio = FALSE;
18111 NicConfig2.word = pAdapter->EEPROMDefaultValue[1];
18112 if (NicConfig2.word == 0xffff)
18113 NicConfig2.word = 0; // empty E2PROM, use default
18114 @@ -906,7 +906,7 @@
18115 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter, 17, r17);
18117 // 2004-2-2 per David's request, lower R17 low-bound for very good quality NIC
18118 - pAdapter->PortCfg.VgcLowerBound -= 6;
18119 + pAdapter->PortCfg.VgcLowerBound -= 6;
18120 DBGPRINT(RT_DEBUG_TRACE,"R17 tuning enable=%d, R17=0x%02x, range=<0x%02x, 0x%02x>\n",
18121 pAdapter->PortCfg.BbpTuningEnable, r17, pAdapter->PortCfg.VgcLowerBound, pAdapter->PortCfg.BbpTuning.VgcUpperBound);
18123 @@ -916,7 +916,6 @@
18124 DBGPRINT(RT_DEBUG_TRACE, "<-- NICInitAsicFromEEPROM\n");
18127 -extern VOID MlmeWork(void *vpAd);
18129 void NICInitializeAdapter(IN PRTMP_ADAPTER pAdapter)
18131 @@ -938,7 +937,7 @@
18132 TxCSR2.field.TxDSize = RING_DESCRIPTOR_SIZE;
18133 TxCSR2.field.NumTxD = TX_RING_SIZE;
18134 TxCSR2.field.NumAtimD = ATIM_RING_SIZE;
18135 - TxCSR2.field.NumPrioD = PRIO_RING_SIZE;
18136 + TxCSR2.field.NumPrioD = PRIO_RING_SIZE;
18137 RTMP_IO_WRITE32(pAdapter, TXCSR2, TxCSR2.word);
18139 // Write TXCSR3 register
18140 @@ -961,22 +960,19 @@
18141 RxCSR1.field.RxDSize = RING_DESCRIPTOR_SIZE;
18142 RxCSR1.field.NumRxD = RX_RING_SIZE;
18143 RTMP_IO_WRITE32(pAdapter, RXCSR1, RxCSR1.word);
18146 // Write RXCSR2 register
18147 Value = pAdapter->RxRing[0].pa_addr;
18148 RTMP_IO_WRITE32(pAdapter, RX_RING_BASE_REG, Value);
18150 // Write CSR1 for host ready
18151 - // Move Host reay to end of ASIC initialization
18152 + // Move Host reay to end of ASIC initialization
18153 // to ensure no Rx will perform before ASIC init
18154 // RTMP_IO_WRITE32(pAdapter, CSR1, 0x4);
18156 // Initialze ASIC for TX & Rx operation
18157 NICInitializeAsic(pAdapter);
18159 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
18160 - INIT_WORK(&pAdapter->mlme_work, MlmeWork, (void*)pAdapter);
18162 DBGPRINT(RT_DEBUG_TRACE, "<-- NICInitializeAdapter\n");
18165 @@ -1036,13 +1032,13 @@
18166 else if (pAdapter->bAcceptPromiscuous == TRUE)
18168 // Register bits with "drop unicast not to me disabled"
18169 - RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x6e);
18170 + RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x6e);
18174 // Standard default register bits.
18175 - RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x7e);
18177 + RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x7e);
18180 // Clear old FCS jitter before init ASIC
18181 RTMP_IO_READ32(pAdapter, CNT0, &Index);
18182 @@ -1172,10 +1168,10 @@
18183 // Init send data structures and related parameters
18184 NICInitTransmit(pAdapter);
18186 - NICInitializeAdapter(pAdapter);
18187 + NICInitializeAdapter(pAdapter);
18188 NICInitAsicFromEEPROM(pAdapter);
18190 - // Switch to current channel, since during reset process, the connection should remains on.
18191 + // Switch to current channel, since during reset process, the connection should remains on.
18192 AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel);
18193 AsicLockChannel(pAdapter, pAdapter->PortCfg.Channel);
18195 @@ -1200,7 +1196,7 @@
18199 - else if (ptr > buffer)
18200 + else if (ptr > buffer)
18202 while (ptr > buffer)
18204 @@ -1252,7 +1248,7 @@
18211 * strstr - Find the first substring in a %NUL terminated string
18212 * @s1: The string to be searched
18213 @@ -1261,7 +1257,7 @@
18214 char * rtstrstr(const char * s1,const char * s2)
18221 return (char *) s1;
18222 @@ -1283,7 +1279,7 @@
18224 section the key of the secion
18225 key Pointer to key string
18226 - dest Pointer to destination
18227 + dest Pointer to destination
18228 destsize The datasize of the destination
18229 buffer Pointer to the buffer to start find the key
18231 @@ -1298,7 +1294,7 @@
18232 INT RTMPGetKeyParameter(
18240 @@ -1354,7 +1350,7 @@
18244 - len = strlen(ptr);
18245 + len = strlen(ptr);
18246 memset(dest, 0x00, destsize);
18247 strncpy(dest, ptr, len >= destsize ? destsize: len);
18249 @@ -1409,7 +1405,7 @@
18250 src = PROFILE_PATH;
18252 // Save uid and gid used for filesystem access.
18253 - // Set user and group to 0 (root)
18254 + // Set user and group to 0 (root)
18255 orgfsuid = current->fsuid;
18256 orgfsgid = current->fsgid;
18257 current->fsuid=current->fsgid = 0;
18258 @@ -1426,7 +1422,7 @@
18261 /* The object must have a read method */
18262 - if (srcf->f_op && srcf->f_op->read)
18263 + if (srcf->f_op && srcf->f_op->read)
18265 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
18266 retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
18267 @@ -1502,7 +1498,7 @@
18268 if (ChannelSanity(pAd, Channel) == TRUE)
18270 pAd->PortCfg.Channel = Channel;
18271 - // If default profile in Registry is an ADHOC network, driver should use the specified channel
18272 + // If default profile in Registry is an ADHOC network, driver should use the specified channel
18273 // number when starting IBSS the first time, because RaConfig is passive and will not set this
18274 // via OID_802_11_CONFIGURATION upon driver bootup.
18275 pAd->PortCfg.IbssConfig.Channel = pAd->PortCfg.Channel;
18276 @@ -1571,7 +1567,7 @@
18278 if((ulInfo > 0) && (ulInfo <= MAX_RTS_THRESHOLD))
18279 pAd->PortCfg.RtsThreshold = (USHORT)ulInfo;
18282 pAd->PortCfg.RtsThreshold = MAX_RTS_THRESHOLD;
18284 DBGPRINT(RT_DEBUG_TRACE, "%s::(RTSThreshold=%d)\n", __FUNCTION__, pAd->PortCfg.RtsThreshold);
18285 @@ -1650,7 +1646,7 @@
18287 DBGPRINT(RT_DEBUG_INFO, "MAX_PSP power mode not available - defaulting to CAM\n");
18289 - else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
18290 + else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
18291 || (strcmp(tmpbuf, "FAST_PSP") == 0))
18293 DBGPRINT(RT_DEBUG_INFO, "FAST_PSP power mode not available - defaulting to CAM\n");
18294 @@ -1763,7 +1759,7 @@
18302 pAd->PortCfg.SharedKey[0].KeyLen = KeyLen / 2 ;
18303 @@ -1773,7 +1769,7 @@
18305 case 13: //wep 104 Ascii type
18306 pAd->PortCfg.SharedKey[0].KeyLen = KeyLen;
18307 - memcpy(pAd->PortCfg.SharedKey[0].Key, tmpbuf, KeyLen);
18308 + memcpy(pAd->PortCfg.SharedKey[0].Key, tmpbuf, KeyLen);
18309 DBGPRINT(RT_DEBUG_TRACE, "%s::(Key1=%s and type=%s)\n", __FUNCTION__, tmpbuf, "Ascii");
18311 case 26: //wep 104 Hex type
18312 @@ -1821,7 +1817,7 @@
18320 pAd->PortCfg.SharedKey[1].KeyLen = KeyLen / 2 ;
18321 @@ -1831,7 +1827,7 @@
18323 case 13: //wep 104 Ascii type
18324 pAd->PortCfg.SharedKey[1].KeyLen = KeyLen;
18325 - memcpy(pAd->PortCfg.SharedKey[1].Key, tmpbuf, KeyLen);
18326 + memcpy(pAd->PortCfg.SharedKey[1].Key, tmpbuf, KeyLen);
18327 DBGPRINT(RT_DEBUG_TRACE, "%s::(Key2=%s and type=%s)\n", __FUNCTION__, tmpbuf, "Ascii");
18329 case 26: //wep 104 Hex type
18330 @@ -1889,7 +1885,7 @@
18332 case 13: //wep 104 Ascii type
18333 pAd->PortCfg.SharedKey[2].KeyLen = KeyLen;
18334 - memcpy(pAd->PortCfg.SharedKey[2].Key, tmpbuf, KeyLen);
18335 + memcpy(pAd->PortCfg.SharedKey[2].Key, tmpbuf, KeyLen);
18336 DBGPRINT(RT_DEBUG_TRACE, "%s::(Key3=%s and type=%s)\n", __FUNCTION__, tmpbuf, "Ascii");
18338 case 26: //wep 104 Hex type
18339 @@ -1947,7 +1943,7 @@
18341 case 13: //wep 104 Ascii type
18342 pAd->PortCfg.SharedKey[3].KeyLen = KeyLen;
18343 - memcpy(pAd->PortCfg.SharedKey[3].Key, tmpbuf, KeyLen);
18344 + memcpy(pAd->PortCfg.SharedKey[3].Key, tmpbuf, KeyLen);
18345 DBGPRINT(RT_DEBUG_TRACE, "%s::(Key4=%s and type=%s)\n", __FUNCTION__, tmpbuf, "Ascii");
18347 case 26: //wep 104 Hex type
18348 @@ -2023,10 +2019,10 @@
18351 // We have to clean all descriptos in case some error happened with reset
18355 pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->NextTxDoneIndex].va_addr;
18358 pTxD->Owner = DESC_OWN_HOST;
18359 pTxD->Valid = FALSE;
18361 @@ -2036,7 +2032,7 @@
18363 pAdapter->NextTxDoneIndex = 0;
18367 } while (Count < TX_RING_SIZE); // We have to scan all TX ring
18369 // Check for packet in send tx wait waiting queue
18370 @@ -2047,7 +2043,7 @@
18373 // We have to clean all descriptos in case some error happened with reset
18377 pTxD = (PTXD_STRUC) pAdapter->PrioRing[pAdapter->NextPrioDoneIndex].va_addr;
18379 @@ -2085,7 +2081,7 @@
18382 // We have to clean all descriptos in case some error happened with reset
18386 pRxD = (PRXD_STRUC) pAdapter->RxRing[pAdapter->CurRxIndex].va_addr;
18388 @@ -2101,7 +2097,7 @@
18390 } while (Count < RX_RING_SIZE); // We have to scan all Rx Ring
18397 @@ -2172,10 +2168,10 @@
18401 - DBGPRINT(RT_DEBUG_TRACE, "--> PortCfgInit\n");
18402 + DBGPRINT(RT_DEBUG_TRACE, "--> PortCfgInit\n");
18404 pAdapter->PortCfg.UseBGProtection = 0; // 0: AUTO
18407 pAdapter->PortCfg.CapabilityInfo = 0x0000;
18408 pAdapter->PortCfg.Psm = PWR_ACTIVE;
18409 pAdapter->PortCfg.BeaconPeriod = 100; // in mSec
18410 @@ -2207,7 +2203,7 @@
18411 pAdapter->PortCfg.LastMicErrorTime = 0;
18412 pAdapter->PortCfg.MicErrCnt = 0;
18413 pAdapter->PortCfg.bBlockAssoc = FALSE;
18414 - pAdapter->PortCfg.WpaState = SS_NOTUSE;
18415 + pAdapter->PortCfg.WpaState = SS_NOTUSE;
18417 pAdapter->PortCfg.RtsThreshold = 2347;
18418 pAdapter->PortCfg.FragmentThreshold = 2346;
18419 @@ -2261,7 +2257,7 @@
18420 pAdapter->PortCfg.PhyMode = 0xff;
18421 // RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED); // default in 11BG mixed mode
18422 // pAdapter->PortCfg.Channel = FirstChannel(pAdapter);
18423 - pAdapter->PortCfg.Dsifs = 10; // in units of usec
18424 + pAdapter->PortCfg.Dsifs = 10; // in units of usec
18425 pAdapter->PortCfg.TxPreambleInUsed = Rt802_11PreambleLong; // use Long preamble on TX by defaut
18427 // user desired power mode
18428 @@ -2274,7 +2270,7 @@
18429 pAdapter->bAcceptMulticast = FALSE;
18430 pAdapter->bAcceptBroadcast = TRUE;
18431 pAdapter->bAcceptAllMulticast = TRUE;
18434 // parameters to be used when this STA starts a new ADHOC network
18435 pAdapter->PortCfg.IbssConfig.BeaconPeriod = 100;
18436 pAdapter->PortCfg.IbssConfig.AtimWin = 0;
18437 @@ -2363,8 +2359,8 @@
18442 - destTemp = (PUCHAR) dest;
18444 + destTemp = (PUCHAR) dest;
18448 @@ -2376,7 +2372,7 @@
18451 ========================================================================
18454 Routine Description:
18457 @@ -2390,7 +2386,7 @@
18463 ========================================================================
18465 VOID RTMPInitTimer(
18466 @@ -2406,7 +2402,7 @@
18469 ========================================================================
18472 Routine Description:
18475 @@ -2418,7 +2414,7 @@
18481 ========================================================================
18484 @@ -2434,7 +2430,7 @@
18487 ========================================================================
18490 Routine Description:
18491 Cancel timer objects
18493 @@ -2446,14 +2442,15 @@
18496 Reset NIC to initial state AS IS system boot up time.
18499 ========================================================================
18501 VOID RTMPCancelTimer(
18502 IN PRALINK_TIMER_STRUCT pTimer)
18504 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,27))
18505 - del_timer_sync(&pTimer->TimerObj);
18506 + if (timer_pending(&pTimer->TimerObj))
18507 + del_timer_sync(&pTimer->TimerObj);
18509 del_timer(&pTimer->TimerObj);
18511 diff -Nur rt2500-1.1.0-b4/Module/rtmp_main.c rt2500-cvs-2007061011/Module/rtmp_main.c
18512 --- rt2500-1.1.0-b4/Module/rtmp_main.c 2006-06-17 22:12:58.000000000 +0200
18513 +++ rt2500-cvs-2007061011/Module/rtmp_main.c 2007-05-29 05:49:17.000000000 +0200
18515 -/***************************************************************************
18516 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
18518 - * This program is free software; you can redistribute it and/or modify *
18519 - * it under the terms of the GNU General Public License as published by *
18520 - * the Free Software Foundation; either version 2 of the License, or *
18521 - * (at your option) any later version. *
18523 - * This program is distributed in the hope that it will be useful, *
18524 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18525 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18526 - * GNU General Public License for more details. *
18528 - * You should have received a copy of the GNU General Public License *
18529 - * along with this program; if not, write to the *
18530 - * Free Software Foundation, Inc., *
18531 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18533 - * Licensed under the GNU GPL *
18534 - * Original code supplied under license from RaLink Inc, 2004. *
18535 - ***************************************************************************/
18536 +/***************************************************************************
18537 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
18539 + * This program is free software; you can redistribute it and/or modify *
18540 + * it under the terms of the GNU General Public License as published by *
18541 + * the Free Software Foundation; either version 2 of the License, or *
18542 + * (at your option) any later version. *
18544 + * This program is distributed in the hope that it will be useful, *
18545 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18546 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18547 + * GNU General Public License for more details. *
18549 + * You should have received a copy of the GNU General Public License *
18550 + * along with this program; if not, write to the *
18551 + * Free Software Foundation, Inc., *
18552 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18554 + * Licensed under the GNU GPL *
18555 + * Original code supplied under license from RaLink Inc, 2004. *
18556 + ***************************************************************************/
18558 - /***************************************************************************
18559 + /***************************************************************************
18560 * Module Name: rtmp_main.c
18564 - * Revision History:
18566 - * -------- ----------- -----------------------------
18567 - * PaulL 25th Nov 02 Initial code
18568 - * MarkW 8th Dec 04 Baseline code
18572 + * Revision History:
18574 + * -------- ----------- -----------------------------
18575 + * PaulL 25th Nov 02 Initial code
18576 + * MarkW 8th Dec 04 Baseline code
18577 * MarkW (rt2400) 8th Dec 04 Promisc mode support
18578 * Flavio (rt2400) 8th Dec 04 Elegant irqreturn_t handling
18579 * Flavio (rt2400) 8th Dec 04 Remove local alloc_netdev
18580 @@ -45,26 +45,24 @@
18581 * Tor Petterson 19th Apr 05 Power management: Suspend and Resume
18582 * MarkW 15th Jul 05 Disable File Config under 4KSTACK
18583 * IvD 15th Jul 05 Support File Config with 4KSTACK
18584 - ***************************************************************************/
18585 + ***************************************************************************/
18587 #include "rt_config.h"
18589 -unsigned long IrqFlags;
18591 // Global static variable, Debug level flag
18592 // Don't hide this behind debug define. There should be as little difference between debug and no-debug as possible.
18593 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
18594 -int debug = 0; /* Default is off. */
18595 +static int debug = 0; /* Default is off. */
18596 MODULE_PARM(debug, "i");
18597 -MODULE_PARM_DESC(debug, "Enable level: accepted values: 1 to switch debug on, 0 to switch debug off.");
18598 +MODULE_PARM_DESC(debug, "Debug mask: n selects filter, 0 for none");
18600 static char *ifname = NULL ;
18601 MODULE_PARM(ifname, "s");
18602 MODULE_PARM_DESC(ifname, "Network device name (default ra%d)");
18604 -int debug = 0; /* Default is off. */
18605 +static int debug = 0; /* Default is off. */
18606 module_param(debug, int, 0);
18607 -MODULE_PARM_DESC(debug, "Enable level: accepted values: 1 to switch debug on, 0 to switch debug off.");
18608 +MODULE_PARM_DESC(debug, "Debug mask: n selects filter, 0 for none");
18610 static char *ifname = NULL ;
18611 module_param(ifname, charp, 0);
18612 @@ -79,78 +77,130 @@
18614 extern const struct iw_handler_def rt2500_iw_handler_def;
18617 +VOID rt2500_setdbg(long mask)
18621 +INT rt2500_dbgprint(int mask, const char *fmt, ...)
18623 + if(mask & debug) {
18627 + va_start(args, fmt);
18629 + //http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.9
18630 + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9))
18631 + i = vprintk(fmt, args);
18634 + // Stack is safe because data is buffered before control returns
18635 + char printk_buf[160]; // Longest observed line is 147 chars.
18637 + vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
18638 + i = printk(printk_buf);
18639 + #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9)) */
18648 +#ifdef RT2X00DEBUGFS
18650 * Register layout information.
18652 #define CSR_REG_BASE 0x0000
18653 #define CSR_REG_SIZE 0x0174
18654 #define EEPROM_BASE 0x0000
18655 -#define EEPROM_SIZE 0x01ff
18656 +#define EEPROM_SIZE 0x0200
18657 +#define BBP_SIZE 0x0040
18659 -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
18661 -rt2x00_get_drvinfo(struct net_device *net_dev,
18662 - struct ethtool_drvinfo *drvinfo)
18663 +static void rt2500pci_read_csr(void *dev, const unsigned long word,
18666 - PRTMP_ADAPTER pAd = net_dev->priv;
18667 + RTMP_ADAPTER *pAd = dev;
18669 - strcpy(drvinfo->driver, NIC_DEVICE_NAME);
18670 - strcpy(drvinfo->version, DRV_VERSION);
18671 - strcpy(drvinfo->bus_info, pci_name(pAd->pPci_Dev));
18672 + RTMP_IO_READ32(pAd, CSR_REG_BASE + (word * sizeof(u32)), (u32*)data);
18676 -rt2x00_get_regs_len(struct net_device *net_dev)
18677 +static void rt2500pci_write_csr(void *dev, const unsigned long word,
18680 - return CSR_REG_SIZE;
18681 + RTMP_ADAPTER *pAd = dev;
18683 + RTMP_IO_WRITE32(pAd, word, *((u32*)data));
18687 -rt2x00_get_regs(struct net_device *net_dev,
18688 - struct ethtool_regs *regs, void *data)
18689 +static void rt2500pci_read_eeprom(void *dev, const unsigned long word,
18692 - PRTMP_ADAPTER pAd = net_dev->priv;
18693 - unsigned int counter;
18694 + RTMP_ADAPTER *pAd = dev;
18696 - regs->len = CSR_REG_SIZE;
18697 + *((u16*)data) = RTMP_EEPROM_READ16(pAd, word * sizeof(u16));
18700 - for (counter = 0; counter < CSR_REG_SIZE; counter += sizeof(u32)) {
18701 - RTMP_IO_READ32(pAd, CSR_REG_BASE + counter, (u32*)data);
18702 - data += sizeof(u32);
18704 +static void rt2500pci_write_eeprom(void *dev, const unsigned long word,
18707 + /* DANGEROUS, DON'T DO THIS! */
18711 -rt2x00_get_eeprom_len(struct net_device *net_dev)
18712 +static void rt2500pci_read_bbp(void *dev, const unsigned long word,
18715 - return EEPROM_SIZE;
18716 + RTMP_ADAPTER *pAd = dev;
18718 + RTMP_BBP_IO_READ32_BY_REG_ID(pAd, word, ((u8*)data));
18722 -rt2x00_get_eeprom(struct net_device *net_dev,
18723 - struct ethtool_eeprom *eeprom, u8 *data)
18724 +static void rt2500pci_write_bbp(void *dev, const unsigned long word,
18727 - PRTMP_ADAPTER pAd = net_dev->priv;
18728 - unsigned int counter;
18729 + RTMP_ADAPTER *pAd = dev;
18731 - for (counter = eeprom->offset; counter < eeprom->len; counter += sizeof(u16)) {
18732 - u16 value = RTMP_EEPROM_READ16(pAd, CSR_REG_BASE + counter);
18733 - memcpy(data, &value, sizeof(u16));
18734 - data += sizeof(u16);
18736 + RTMP_BBP_IO_WRITE32_BY_REG_ID(pAd, word, *((u8*)data));
18740 +static void rt2500pci_open_debugfs(RTMP_ADAPTER *pAd)
18742 + struct rt2x00debug *debug = &pAd->debug;
18744 + debug->owner = THIS_MODULE;
18745 + debug->mod_name = DRV_NAME;
18746 + debug->mod_version = DRV_VERSION;
18747 + debug->reg_csr.read = rt2500pci_read_csr;
18748 + debug->reg_csr.write = rt2500pci_write_csr;
18749 + debug->reg_csr.word_size = sizeof(u32);
18750 + debug->reg_csr.length = CSR_REG_SIZE;
18751 + debug->reg_eeprom.read = rt2500pci_read_eeprom;
18752 + debug->reg_eeprom.write = rt2500pci_write_eeprom;
18753 + debug->reg_eeprom.word_size = sizeof(u16);
18754 + debug->reg_eeprom.length = EEPROM_SIZE;
18755 + debug->reg_bbp.read = rt2500pci_read_bbp;
18756 + debug->reg_bbp.write = rt2500pci_write_bbp;
18757 + debug->reg_bbp.word_size = sizeof(u8);
18758 + debug->reg_bbp.length = BBP_SIZE;
18759 + debug->dev = pAd;
18761 + snprintf(debug->intf_name, sizeof(debug->intf_name),
18762 + "%s", pAd->net_dev->name);
18764 + if (rt2x00debug_register(debug))
18765 + printk(KERN_ERR "Failed to register debug handler.\n");
18768 -static struct ethtool_ops rt2x00_ethtool_ops = {
18769 - .get_drvinfo = rt2x00_get_drvinfo,
18770 - .get_regs_len = rt2x00_get_regs_len,
18771 - .get_regs = rt2x00_get_regs,
18772 - .get_link = ethtool_op_get_link,
18773 - .get_eeprom_len = rt2x00_get_eeprom_len,
18774 - .get_eeprom = rt2x00_get_eeprom,
18777 +static void rt2500pci_close_debugfs(RTMP_ADAPTER *pAd)
18779 + rt2x00debug_deregister(&pAd->debug);
18781 +#else /* RT2X00DEBUGFS */
18782 +static inline void rt2500pci_open_debugfs(RTMP_ADAPTER *pAd){}
18783 +static inline void rt2500pci_close_debugfs(RTMP_ADAPTER *pAd){}
18784 +#endif /* RT2X00DEBUGFS */
18786 static INT __devinit RT2500_init_one (
18787 IN struct pci_dev *pPci_Dev,
18788 @@ -158,6 +208,7 @@
18792 + if (debug) {} // shuts up compiler when RT2500_DBG not defined
18793 // wake up and enable device
18794 if (pci_enable_device (pPci_Dev))
18796 @@ -176,7 +227,7 @@
18797 // PCI device probe & initialization function
18799 INT __devinit RT2500_probe(
18800 - IN struct pci_dev *pPci_Dev,
18801 + IN struct pci_dev *pPci_Dev,
18802 IN const struct pci_device_id *ent)
18804 struct net_device *net_dev;
18805 @@ -194,7 +245,7 @@
18807 // alloc_etherdev() will set net_dev->name
18808 net_dev = alloc_etherdev(sizeof(RTMP_ADAPTER));
18809 - if (net_dev == NULL)
18810 + if (net_dev == NULL)
18812 DBGPRINT(RT_DEBUG_TRACE, "init_ethernet failed\n");
18814 @@ -204,9 +255,8 @@
18816 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
18817 SET_NETDEV_DEV(net_dev, &(pPci_Dev->dev));
18818 - SET_ETHTOOL_OPS(net_dev, &rt2x00_ethtool_ops);
18822 if (pci_request_regions(pPci_Dev, print_name))
18823 goto err_out_free_netdev;
18825 @@ -215,10 +265,10 @@
18827 // map physical address to virtual address for accessing register
18828 csr_addr = (unsigned long) ioremap(pci_resource_start(pPci_Dev, 0), pci_resource_len(pPci_Dev, 0));
18832 - DBGPRINT(RT_DEBUG_TRACE, "ioremap failed for device %s, region 0x%X @ 0x%lX\n",
18833 - print_name, (ULONG)pci_resource_len(pPci_Dev, 0), pci_resource_start(pPci_Dev, 0));
18834 + DBGPRINT(RT_DEBUG_TRACE, "ioremap failed for device %s, region 0x%X @ 0x%X\n",
18835 + print_name, (ULONG)pci_resource_len(pPci_Dev, 0), (ULONG)pci_resource_start(pPci_Dev, 0));
18836 goto err_out_free_res;
18839 @@ -233,7 +283,7 @@
18841 // Read MAC address
18842 NICReadAdapterInfo(pAd);
18845 RTMP_IO_READ32(pAd, CSR3, &StaMacReg0.word);
18846 RTMP_IO_READ32(pAd, CSR4, &StaMacReg1.word);
18847 net_dev->dev_addr[0] = StaMacReg0.field.Byte0;
18848 @@ -256,13 +306,13 @@
18849 #if WIRELESS_EXT < 17
18850 net_dev->get_wireless_stats = RT2500_get_wireless_stats;
18852 - net_dev->wireless_handlers = (struct iw_handler_def *) &rt2500_iw_handler_def;
18853 + net_dev->wireless_handlers = (struct iw_handler_def *) &rt2500_iw_handler_def;
18856 net_dev->set_multicast_list = RT2500_set_rx_mode;
18857 net_dev->do_ioctl = RT2500_ioctl;
18858 net_dev->set_mac_address = rt2500_set_mac_address;
18862 // register_netdev() will call dev_alloc_name() for us
18863 // TODO: Remove the following line to keep the default eth%d name
18864 @@ -284,8 +334,8 @@
18865 if (Status != NDIS_STATUS_SUCCESS)
18866 goto err_out_unmap;
18868 - DBGPRINT(RT_DEBUG_TRACE, "%s: at 0x%lx, VA 0x%lx, IRQ %d. \n",
18869 - net_dev->name, pci_resource_start(pPci_Dev, 0), (unsigned long)csr_addr, pPci_Dev->irq);
18870 + DBGPRINT(RT_DEBUG_TRACE, "%s: at 0x%x, VA 0x%lx, IRQ %d. \n",
18871 + net_dev->name, (ULONG)pci_resource_start(pPci_Dev, 0), (unsigned long)csr_addr, pPci_Dev->irq);
18874 pci_set_drvdata(pPci_Dev, net_dev);
18875 @@ -295,15 +345,17 @@
18876 // All this occurs while the net iface is down
18877 // iwconfig can then be used to configure card BEFORE
18878 // ifconfig ra0 up is applied.
18879 - // Note the RT2500STA.dat file will still overwrite settings
18880 + // Note the RT2500STA.dat file will still overwrite settings
18881 // but it is useful for the settings iwconfig doesn't let you at
18882 - PortCfgInit(pAd);
18883 + PortCfgInit(pAd);
18885 MlmeQueueInit(&pAd->Mlme.Queue); // (never fails)
18887 // Build channel list for default physical mode
18888 BuildChannelList(pAd);
18890 + rt2500pci_open_debugfs(pAd);
18895 @@ -447,7 +499,7 @@
18897 if (pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx != TRUE)
18899 - dev_kfree_skb_irq(skb);
18900 + dev_kfree_skb_irq(skb);
18904 @@ -465,7 +517,7 @@
18905 // This function has to manage NdisSendComplete return call within its routine
18906 // NdisSendComplete will acknowledge upper layer in two steps.
18907 // 1. Within Packet Enqueue, set the NDIS_STATUS_PENDING
18908 - // 2. Within TxRingTxDone / PrioRingTxDone call NdisSendComplete with final status
18909 + // 2. Within TxRingTxDone / PrioRingTxDone call NdisSendComplete with final status
18910 // initial skb->data_len=0, we will use this variable to store data size when fragment(in TKIP)
18911 // and skb->len is actual data len
18912 skb->data_len = skb->len;
18913 @@ -482,7 +534,7 @@
18914 // There are two place calling dequeue for TX ring.
18915 // 1. Here, right after queueing the frame.
18916 // 2. At the end of TxRingTxDone service routine.
18917 - if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
18918 + if ((!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
18919 (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) &&
18920 (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS)))
18922 @@ -504,7 +556,7 @@
18925 dev_instance Pointer to net_device
18926 - rgs store process's context before entering ISR,
18927 + rgs store process's context before entering ISR,
18928 this parameter is just for debug purpose.
18931 @@ -514,10 +566,16 @@
18933 ========================================================================
18935 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
18936 irqreturn_t RTMPIsr(
18938 - IN VOID *dev_instance,
18940 + IN VOID *dev_instance,
18941 IN struct pt_regs *rgs)
18943 +irqreturn_t RTMPIsr(
18945 + IN VOID *dev_instance)
18948 struct net_device *net_dev = dev_instance;
18949 PRTMP_ADAPTER pAdapter = net_dev->priv;
18950 @@ -643,29 +701,29 @@
18951 if(!is_valid_ether_addr(&mac->sa_data[0]))
18954 -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
18955 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
18956 BUG_ON(net_dev->addr_len != ETH_ALEN);
18961 memcpy(net_dev->dev_addr, mac->sa_data, ETH_ALEN);
18962 memcpy(pAd->CurrentAddress, mac->sa_data, ETH_ALEN);
18965 memset(&set_mac, 0x00, sizeof(INT));
18966 set_mac = (net_dev->dev_addr[0]) |
18967 (net_dev->dev_addr[1] << 8) |
18968 (net_dev->dev_addr[2] << 16) |
18969 (net_dev->dev_addr[3] << 24);
18972 RTMP_IO_WRITE32(pAd, CSR3, set_mac);
18975 memset(&set_mac, 0x00, sizeof(INT));
18976 set_mac = (net_dev->dev_addr[4]) |
18977 (net_dev->dev_addr[5] << 8);
18980 RTMP_IO_WRITE32(pAd, CSR4, set_mac);
18983 printk(KERN_INFO "***rt2x00***: Info - Mac address changed to: %02x:%02x:%02x:%02x:%02x:%02x.\n", net_dev->dev_addr[0], net_dev->dev_addr[1], net_dev->dev_addr[2], net_dev->dev_addr[3], net_dev->dev_addr[4], net_dev->dev_addr[5]);
18989 @@ -697,11 +755,13 @@
18991 pAd->iw_stats.status = 0; // Status - device dependent for now
18993 - pAd->iw_stats.qual.qual = pAd->Mlme.ChannelQuality;//pAd->Mlme.RoamCqi; // link quality (%retries, SNR, %missed beacons or better...)
18994 - pAd->iw_stats.qual.level = pAd->PortCfg.LastRssi - RSSI_TO_DBM_OFFSET; // signal level (dBm)
18996 + pAd->iw_stats.qual.qual = pAd->Mlme.ChannelQuality;// link quality (%retries, SNR, %missed beacons or better...)
18997 + pAd->iw_stats.qual.level = abs(pAd->PortCfg.LastRssi); // signal level (dBm)
18998 + pAd->iw_stats.qual.level += 256 - RSSI_TO_DBM_OFFSET;
19000 pAd->iw_stats.qual.noise = (pAd->PortCfg.LastR17Value > BBP_R17_DYNAMIC_UP_BOUND) ? BBP_R17_DYNAMIC_UP_BOUND : ((ULONG) pAd->PortCfg.LastR17Value); // // noise level (dBm)
19001 - pAd->iw_stats.qual.updated = 3; // Flags to know if updated
19002 + pAd->iw_stats.qual.noise += 256 - 143;
19003 + pAd->iw_stats.qual.updated = 1; // Flags to know if updated
19005 pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
19006 pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
19007 @@ -791,7 +851,7 @@
19008 IN struct net_device *net_dev)
19011 - pAd = net_dev->priv;
19012 + pAd = net_dev->priv;
19013 if (pAd->PortCfg.BssType == BSS_MONITOR)
19015 RTMP_IO_WRITE32(pAd, RXCSR0, 0x46);
19016 @@ -808,7 +868,7 @@
19017 pAd->bAcceptPromiscuous = FALSE;
19018 RTMP_IO_WRITE32(pAd, RXCSR0, 0x7e);
19019 DBGPRINT(RT_DEBUG_TRACE, "rt2500 acknowledge MONITOR/PROMISC off\n");
19025 @@ -867,7 +927,9 @@
19026 IN struct pci_dev *pPci_Dev)
19028 struct net_device *net_dev = pci_get_drvdata(pPci_Dev);
19029 - // RTMP_ADAPTER *pAd = net_dev->priv;
19030 + RTMP_ADAPTER *pAd = netdev_priv(net_dev);
19032 + rt2500pci_close_debugfs(pAd);
19034 // Free Ring buffers
19035 RTMPFreeDMAMemory(net_dev->priv);
19036 @@ -915,7 +977,7 @@
19038 if(pAdapter->PortCfg.bRadio)
19039 MlmeRadioOff(pAdapter);
19042 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14))
19043 printk(KERN_NOTICE "%s: got suspend request (state %d)\n",
19045 @@ -944,7 +1006,11 @@
19046 PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
19049 - pci_enable_device(pdev);
19050 + // FIXME: code should process error case correctly
19051 + if (pci_enable_device(pdev)) {
19052 + printk(KERN_ERR "rt2500: could not resume from suspend");
19056 printk(KERN_NOTICE "%s: got resume request\n", dev->name);
19058 @@ -991,7 +1057,7 @@
19059 suspend: rt2500_suspend,
19060 resume: rt2500_resume,
19061 #endif /* CONFIG_PM */
19062 -#if LINUX_VERSION_CODE >= 0x20412 || BIG_ENDIAN == TRUE || RTMP_EMBEDDED == TRUE
19063 +#if LINUX_VERSION_CODE >= 0x20412 || BIG_ENDIAN == TRUE
19064 remove: __devexit_p(RT2500_remove_one),
19066 remove: __devexit(RT2500_remove_one),
19067 diff -Nur rt2500-1.1.0-b4/Module/rtmp_tkip.c rt2500-cvs-2007061011/Module/rtmp_tkip.c
19068 --- rt2500-1.1.0-b4/Module/rtmp_tkip.c 2006-06-17 22:12:58.000000000 +0200
19069 +++ rt2500-cvs-2007061011/Module/rtmp_tkip.c 2007-03-21 05:25:35.000000000 +0100
19070 @@ -1,125 +1,125 @@
19071 -/***************************************************************************
19072 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
19074 - * This program is free software; you can redistribute it and/or modify *
19075 - * it under the terms of the GNU General Public License as published by *
19076 - * the Free Software Foundation; either version 2 of the License, or *
19077 - * (at your option) any later version. *
19079 - * This program is distributed in the hope that it will be useful, *
19080 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19081 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19082 - * GNU General Public License for more details. *
19084 - * You should have received a copy of the GNU General Public License *
19085 - * along with this program; if not, write to the *
19086 - * Free Software Foundation, Inc., *
19087 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19089 - * Licensed under the GNU GPL *
19090 - * Original code supplied under license from RaLink Inc, 2004. *
19091 - ***************************************************************************/
19092 +/***************************************************************************
19093 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
19095 + * This program is free software; you can redistribute it and/or modify *
19096 + * it under the terms of the GNU General Public License as published by *
19097 + * the Free Software Foundation; either version 2 of the License, or *
19098 + * (at your option) any later version. *
19100 + * This program is distributed in the hope that it will be useful, *
19101 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19102 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19103 + * GNU General Public License for more details. *
19105 + * You should have received a copy of the GNU General Public License *
19106 + * along with this program; if not, write to the *
19107 + * Free Software Foundation, Inc., *
19108 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19110 + * Licensed under the GNU GPL *
19111 + * Original code supplied under license from RaLink Inc, 2004. *
19112 + ***************************************************************************/
19114 - /***************************************************************************
19115 + /***************************************************************************
19116 * Module Name: rtmp_tkip.c
19120 - * Revision History:
19122 - * -------- ----------- -----------------------------
19123 - * PaulW 25th Feb 02 Initial code
19124 - * MarkW 8th Dec 04 Baseline code
19125 - ***************************************************************************/
19129 + * Revision History:
19131 + * -------- ----------- -----------------------------
19132 + * PaulW 25th Feb 02 Initial code
19133 + * MarkW 8th Dec 04 Baseline code
19134 + ***************************************************************************/
19136 #include "rt_config.h"
19138 -// Rotation functions on 32 bit values
19139 +// Rotation functions on 32 bit values
19140 #define ROL32( A, n ) ( ((A) << (n)) | ( ((A)>>(32-(n))) ) )
19141 -#define ROR32( A, n ) ROL32( (A), 32-(n) )
19142 +#define ROR32( A, n ) ROL32( (A), 32-(n) )
19145 ========================================================================
19147 Routine Description:
19148 - Convert from UCHAR[] to ULONG in a portable way
19150 + Convert from UCHAR[] to ULONG in a portable way
19153 pMICKey pointer to MIC Key
19162 ========================================================================
19164 -ULONG RTMPTkipGetUInt32(
19165 +ULONG RTMPTkipGetUInt32(
19173 - for (i = 0; i < 4; i++)
19175 - res |= (*pMICKey++) << (8 * i);
19177 + for (i = 0; i < 4; i++)
19179 + res |= (*pMICKey++) << (8 * i);
19188 ========================================================================
19190 Routine Description:
19191 - Convert from ULONG to UCHAR[] in a portable way
19193 + Convert from ULONG to UCHAR[] in a portable way
19196 pDst pointer to destination for convert ULONG to UCHAR[]
19197 val the value for convert
19206 ========================================================================
19208 VOID RTMPTkipPutUInt32(
19209 IN OUT PUCHAR pDst,
19216 - for(i = 0; i < 4; i++)
19218 - *pDst++ = (UCHAR) val;
19223 + for(i = 0; i < 4; i++)
19225 + *pDst++ = (UCHAR) val;
19231 ========================================================================
19233 Routine Description:
19234 Calculate the MIC Value.
19238 pAdapter Pointer to our adapter
19239 pSrc Pointer to source data for Calculate MIC Value
19240 Len Indicate the length of the source data
19249 ========================================================================
19251 -VOID RTMPTkipAppend(
19252 - IN PTKIP_KEY_INFO pTkip,
19253 +VOID RTMPTkipAppend(
19254 + IN PTKIP_KEY_INFO pTkip,
19259 register ULONG M, L, R, nBytesInM;
19261 @@ -128,7 +128,7 @@
19263 nBytesInM = pTkip->nBytesInM;
19268 if((nBytesInM == 0) && ((((unsigned long)pSrc) & 0x3) == 0))
19270 @@ -141,7 +141,7 @@
19277 R ^= ROL32( L, 17 );
19279 @@ -154,7 +154,7 @@
19287 M |= (*pSrc << (8* nBytesInM));
19288 @@ -162,7 +162,7 @@
19294 if( nBytesInM >= 4 )
19297 @@ -186,10 +186,10 @@
19299 M |= (*pSrc << (8* nBytesInM));
19307 if( nBytesInM >= 4 )
19310 @@ -207,23 +207,23 @@
19316 // load data from register to memory
19318 pTkip->nBytesInM = nBytesInM;
19325 ========================================================================
19327 Routine Description:
19332 pAdapter Pointer to our adapter
19338 @@ -231,7 +231,7 @@
19339 the MIC Value is store in pAdapter->PrivateInfo.MIC
19340 ========================================================================
19342 -VOID RTMPTkipGetMIC(
19343 +VOID RTMPTkipGetMIC(
19344 IN PTKIP_KEY_INFO pTkip)
19346 static unsigned char Last[] = {"\x5a\x00\x00\x00\x00\x00\x00\x00"};
19347 @@ -242,14 +242,14 @@
19348 // The appendByte function has already computed the result.
19349 RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
19350 RTMPTkipPutUInt32(pTkip->MIC + 4, pTkip->R);
19355 ========================================================================
19357 Routine Description:
19358 Compare MIC value of received MSDU
19362 pAdapter Pointer to our adapter
19363 pSrc Pointer to the received Plain text data
19364 @@ -257,13 +257,13 @@
19365 pSA Pointer to SA address
19366 pMICKey pointer to MIC Key
19367 Len the length of the received plain text data exclude MIC value
19371 TRUE MIC value matched
19372 FALSE MIC value mismatched
19378 ========================================================================
19380 BOOLEAN RTMPTkipCompareMICValue(
19381 @@ -288,19 +288,19 @@
19382 RTMPTkipAppend(&pAdapter->PrivateInfo.Rx, pSA, 6);
19383 // Priority + 3 bytes of 0
19384 RTMPTkipAppend(&pAdapter->PrivateInfo.Rx, Priority, 4);
19387 // Calculate MIC value from plain text data
19388 RTMPTkipAppend(&pAdapter->PrivateInfo.Rx, pSrc, Len);
19390 // Get MIC value from decrypted plain data
19391 RTMPTkipGetMIC(&pAdapter->PrivateInfo.Rx);
19394 // Move MIC value from MSDU, this steps should move to data path.
19395 // Since the MIC value might cross MPDUs.
19396 if(!NdisEqualMemory(pAdapter->PrivateInfo.Rx.MIC, pSrc + Len, 8))
19401 DBGPRINT(RT_DEBUG_ERROR, "! TKIP MIC Error !\n"); //MIC error.
19402 DBGPRINT(RT_DEBUG_INFO, "Orig MIC value ="); //MIC error.
19403 for (i = 0; i < 8; i++)
19404 @@ -324,7 +324,7 @@
19406 Routine Description:
19407 Compare MIC value of received MSDU
19411 pAdapter Pointer to our adapter
19413 @@ -333,13 +333,13 @@
19414 pSA Pointer to SA address
19415 pMICKey pointer to MIC Key
19416 Len the length of the received plain text data exclude MIC value
19420 TRUE MIC value matched
19421 FALSE MIC value mismatched
19427 ========================================================================
19429 BOOLEAN RTMPTkipCompareMICValueWithLLC(
19430 @@ -352,13 +352,13 @@
19433 static UCHAR Priority[4] = {"\x00\x00\x00\x00"};
19436 // Init MIC value calculation and reset the message
19437 pAdapter->PrivateInfo.Rx.L = RTMPTkipGetUInt32(pMICKey);
19438 pAdapter->PrivateInfo.Rx.R = RTMPTkipGetUInt32(pMICKey + 4);
19439 pAdapter->PrivateInfo.Rx.nBytesInM = 0;
19440 pAdapter->PrivateInfo.Rx.M = 0;
19444 RTMPTkipAppend(&pAdapter->PrivateInfo.Rx, pDA, 6);
19446 @@ -405,20 +405,20 @@
19447 ========================================================================
19449 Routine Description:
19450 - Copy frame from waiting queue into relative ring buffer and set
19451 + Copy frame from waiting queue into relative ring buffer and set
19452 appropriate ASIC register to kick hardware transmit function
19456 pAdapter Pointer to our adapter
19457 PNDIS_PACKET Pointer to Ndis Packet for MIC calculation
19458 pEncap Pointer to LLC encap data
19459 LenEncap Total encap length, might be 0 which indicates no encap
19468 ========================================================================
19470 VOID RTMPCalculateMICValue(
19471 @@ -430,21 +430,21 @@
19474 static UCHAR Priority[4] = {"\x00\x00\x00\x00"};
19477 pSrc = (PUCHAR) skb->data;
19480 // Init MIC value calculation and reset the message
19481 pAdapter->PrivateInfo.Tx.L = RTMPTkipGetUInt32(pWpaKey->TxMic);
19482 pAdapter->PrivateInfo.Tx.R = RTMPTkipGetUInt32(pWpaKey->TxMic + 4);
19483 pAdapter->PrivateInfo.Tx.nBytesInM = 0;
19484 pAdapter->PrivateInfo.Tx.M = 0;
19488 RTMPTkipAppend(&pAdapter->PrivateInfo.Tx, pSrc, 12);
19491 // Priority + 3 bytes of 0
19492 RTMPTkipAppend(&pAdapter->PrivateInfo.Tx, Priority, 4);
19497 // LLC encapsulation
19498 @@ -454,7 +454,7 @@
19501 RTMPTkipAppend(&pAdapter->PrivateInfo.Tx, pSrc + 14, skb->len - 14);
19504 // Compute the final MIC Value
19505 RTMPTkipGetMIC(&pAdapter->PrivateInfo.Tx);
19507 diff -Nur rt2500-1.1.0-b4/Module/rtmp_type.h rt2500-cvs-2007061011/Module/rtmp_type.h
19508 --- rt2500-1.1.0-b4/Module/rtmp_type.h 2006-06-17 22:12:58.000000000 +0200
19509 +++ rt2500-cvs-2007061011/Module/rtmp_type.h 2007-03-21 05:25:35.000000000 +0100
19511 -/***************************************************************************
19512 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
19514 - * This program is free software; you can redistribute it and/or modify *
19515 - * it under the terms of the GNU General Public License as published by *
19516 - * the Free Software Foundation; either version 2 of the License, or *
19517 - * (at your option) any later version. *
19519 - * This program is distributed in the hope that it will be useful, *
19520 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19521 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19522 - * GNU General Public License for more details. *
19524 - * You should have received a copy of the GNU General Public License *
19525 - * along with this program; if not, write to the *
19526 - * Free Software Foundation, Inc., *
19527 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19529 - * Licensed under the GNU GPL *
19530 - * Original code supplied under license from RaLink Inc, 2004. *
19531 - ***************************************************************************/
19532 +/***************************************************************************
19533 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
19535 + * This program is free software; you can redistribute it and/or modify *
19536 + * it under the terms of the GNU General Public License as published by *
19537 + * the Free Software Foundation; either version 2 of the License, or *
19538 + * (at your option) any later version. *
19540 + * This program is distributed in the hope that it will be useful, *
19541 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19542 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19543 + * GNU General Public License for more details. *
19545 + * You should have received a copy of the GNU General Public License *
19546 + * along with this program; if not, write to the *
19547 + * Free Software Foundation, Inc., *
19548 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19550 + * Licensed under the GNU GPL *
19551 + * Original code supplied under license from RaLink Inc, 2004. *
19552 + ***************************************************************************/
19554 - /***************************************************************************
19555 + /***************************************************************************
19556 * Module Name: rtmp_type.h
19560 - * Revision History:
19562 - * -------- ----------- -----------------------------
19563 - * PaulL 2md Jan 03 Initial code
19564 - * MarkW 8th Dec 04 Baseline code
19565 - ***************************************************************************/
19569 + * Revision History:
19571 + * -------- ----------- -----------------------------
19572 + * PaulL 2md Jan 03 Initial code
19573 + * MarkW 8th Dec 04 Baseline code
19574 + ***************************************************************************/
19576 #ifndef __RTMP_TYPE_H__
19577 #define __RTMP_TYPE_H__
19578 diff -Nur rt2500-1.1.0-b4/Module/rtmp_wep.c rt2500-cvs-2007061011/Module/rtmp_wep.c
19579 --- rt2500-1.1.0-b4/Module/rtmp_wep.c 2006-06-17 22:12:58.000000000 +0200
19580 +++ rt2500-cvs-2007061011/Module/rtmp_wep.c 2007-03-21 05:25:35.000000000 +0100
19582 -/***************************************************************************
19583 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
19585 - * This program is free software; you can redistribute it and/or modify *
19586 - * it under the terms of the GNU General Public License as published by *
19587 - * the Free Software Foundation; either version 2 of the License, or *
19588 - * (at your option) any later version. *
19590 - * This program is distributed in the hope that it will be useful, *
19591 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19592 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19593 - * GNU General Public License for more details. *
19595 - * You should have received a copy of the GNU General Public License *
19596 - * along with this program; if not, write to the *
19597 - * Free Software Foundation, Inc., *
19598 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19600 - * Licensed under the GNU GPL *
19601 - * Original code supplied under license from RaLink Inc, 2004. *
19602 - ***************************************************************************/
19604 - /***************************************************************************
19605 - * Module Name: rtmp_wep.c
19609 - * Revision History:
19611 - * -------- ----------- -----------------------------
19612 - * PaulW 28th Sep 02 Initial code
19613 - * MarkW 8th Dec 04 Baseline code
19614 - ***************************************************************************/
19615 +/***************************************************************************
19616 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
19618 + * This program is free software; you can redistribute it and/or modify *
19619 + * it under the terms of the GNU General Public License as published by *
19620 + * the Free Software Foundation; either version 2 of the License, or *
19621 + * (at your option) any later version. *
19623 + * This program is distributed in the hope that it will be useful, *
19624 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19625 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19626 + * GNU General Public License for more details. *
19628 + * You should have received a copy of the GNU General Public License *
19629 + * along with this program; if not, write to the *
19630 + * Free Software Foundation, Inc., *
19631 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19633 + * Licensed under the GNU GPL *
19634 + * Original code supplied under license from RaLink Inc, 2004. *
19635 + ***************************************************************************/
19637 + /***************************************************************************
19638 + * Module Name: rtmp_wep.c
19642 + * Revision History:
19644 + * -------- ----------- -----------------------------
19645 + * PaulW 28th Sep 02 Initial code
19646 + * MarkW 8th Dec 04 Baseline code
19647 + ***************************************************************************/
19649 #include "rt_config.h"
19651 -ULONG FCSTAB_32[256] =
19652 +ULONG FCSTAB_32[256] =
19654 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
19655 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
19656 @@ -56,57 +56,57 @@
19657 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
19658 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
19659 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
19660 - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
19661 - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
19662 - 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
19663 - 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
19664 - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
19665 - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
19666 - 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
19667 - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
19668 - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
19669 - 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
19670 - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
19671 - 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
19672 - 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
19673 - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
19674 - 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
19675 - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
19676 - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
19677 - 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
19678 - 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
19679 - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
19680 - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
19681 - 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
19682 - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
19683 - 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
19684 - 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
19685 - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
19686 - 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
19687 - 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
19688 - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
19689 - 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
19690 - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
19691 - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
19692 - 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
19693 - 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
19694 - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
19695 - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
19696 - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
19697 - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
19698 - 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
19699 - 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
19700 - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
19701 - 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
19702 - 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
19703 - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
19705 + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
19706 + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
19707 + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
19708 + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
19709 + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
19710 + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
19711 + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
19712 + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
19713 + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
19714 + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
19715 + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
19716 + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
19717 + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
19718 + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
19719 + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
19720 + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
19721 + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
19722 + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
19723 + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
19724 + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
19725 + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
19726 + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
19727 + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
19728 + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
19729 + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
19730 + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
19731 + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
19732 + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
19733 + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
19734 + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
19735 + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
19736 + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
19737 + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
19738 + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
19739 + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
19740 + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
19741 + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
19742 + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
19743 + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
19744 + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
19745 + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
19746 + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
19747 + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
19748 + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
19753 - 0x00, 0x11, 0x22,
19754 + 0x00, 0x11, 0x22,
19756 - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
19757 + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
19761 @@ -114,27 +114,27 @@
19762 ========================================================================
19764 Routine Description:
19765 - Init WEP function.
19767 + Init WEP function.
19770 pAdapter Pointer to our adapter
19771 pKey Pointer to the WEP KEY
19773 KeyLen the length of WEP KEY
19774 pDest Pointer to the destination which Encryption data will store in.
19783 ========================================================================
19785 VOID RTMPInitWepEngine(
19786 - IN PRTMP_ADAPTER pAdapter,
19787 + IN PRTMP_ADAPTER pAdapter,
19792 IN OUT PUCHAR pDest)
19795 @@ -146,32 +146,32 @@
19796 WEPKEY[i] = RandomByte(pAdapter); //Call mlme RandomByte() function.
19797 ARCFOUR_INIT(&pAdapter->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); //INIT SBOX, KEYLEN+3(IV)
19799 - memcpy(pDest, WEPKEY, 3); //Append Init Vector
19800 - *(pDest+3) = (KeyId << 6); //Append KEYID
19802 + memcpy(pDest, WEPKEY, 3); //Append Init Vector
19803 + *(pDest+3) = (KeyId << 6); //Append KEYID
19808 ========================================================================
19810 Routine Description:
19811 - Encrypt transimitted data
19813 + Encrypt transimitted data
19816 pAdapter Pointer to our adapter
19817 pSrc Pointer to the transimitted source data that will be encrypt
19818 pDest Pointer to the destination where entryption data will be store in.
19819 Len Indicate the length of the source data
19829 ========================================================================
19831 VOID RTMPEncryptData(
19832 - IN PRTMP_ADAPTER pAdapter,
19833 + IN PRTMP_ADAPTER pAdapter,
19837 @@ -184,19 +184,19 @@
19838 ========================================================================
19840 Routine Description:
19841 - Decrypt received data
19843 + Decrypt received data
19846 pAdapter Pointer to our adapter
19847 pSrc Pointer to the received data
19848 Len the length of the received data
19852 TRUE Decrypt WEP data success
19853 FALSE Decrypt WEP data failed
19859 ========================================================================
19861 BOOLEAN RTMPDecryptData(
19862 @@ -209,12 +209,12 @@
19865 memcpy(WEPKEY, pSrc, 3); //Get WEP IV
19868 KeyIdx = (*(pSrc + 3) & 0xc0) >> 6;
19869 if (pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen == 0)
19872 - memcpy(WEPKEY + 3, pAdapter->PortCfg.SharedKey[KeyIdx].Key, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen);
19874 + memcpy(WEPKEY + 3, pAdapter->PortCfg.SharedKey[KeyIdx].Key, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen);
19875 ARCFOUR_INIT(&pAdapter->PrivateInfo.WEPCONTEXT, WEPKEY, pAdapter->PortCfg.SharedKey[KeyIdx].KeyLen + 3);
19876 ARCFOUR_DECRYPT(&pAdapter->PrivateInfo.WEPCONTEXT, pSrc, pSrc + 4, Len - 4);
19877 memcpy(&trailfcs, pSrc + Len - 8, 4);
19878 @@ -236,18 +236,18 @@
19879 ========================================================================
19881 Routine Description:
19882 - The Stream Cipher Encryption Algorithm "ARCFOUR" initialize
19884 + The Stream Cipher Encryption Algorithm "ARCFOUR" initialize
19887 Ctx Pointer to ARCFOUR CONTEXT (SBOX)
19888 pKey Pointer to the WEP KEY
19889 KeyLen Indicate the length fo the WEP KEY
19899 ========================================================================
19902 @@ -260,7 +260,7 @@
19908 state = Ctx->STATE;
19911 @@ -284,16 +284,16 @@
19912 ========================================================================
19914 Routine Description:
19915 - Get bytes from ARCFOUR CONTEXT (S-BOX)
19917 + Get bytes from ARCFOUR CONTEXT (S-BOX)
19920 Ctx Pointer to ARCFOUR CONTEXT (SBOX)
19924 - UCHAR - the value of the ARCFOUR CONTEXT (S-BOX)
19926 + UCHAR - the value of the ARCFOUR CONTEXT (S-BOX)
19931 ========================================================================
19933 UCHAR ARCFOUR_BYTE(
19934 @@ -303,7 +303,7 @@
19940 state = Ctx->STATE;
19941 x = (Ctx->X + 1) & 0xff;
19943 @@ -315,31 +315,31 @@
19946 return(state[(sx + sy) & 0xff]);
19952 ========================================================================
19954 Routine Description:
19955 - The Stream Cipher Decryption Algorithm
19957 + The Stream Cipher Decryption Algorithm
19960 Ctx Pointer to ARCFOUR CONTEXT (SBOX)
19961 - pDest Pointer to the Destination
19962 + pDest Pointer to the Destination
19963 pSrc Pointer to the Source data
19964 Len Indicate the length of the Source data
19974 ========================================================================
19976 VOID ARCFOUR_DECRYPT(
19977 IN PARCFOURCONTEXT Ctx,
19983 @@ -353,19 +353,19 @@
19984 ========================================================================
19986 Routine Description:
19987 - The Stream Cipher Encryption Algorithm
19989 + The Stream Cipher Encryption Algorithm
19992 Ctx Pointer to ARCFOUR CONTEXT (SBOX)
19993 - pDest Pointer to the Destination
19994 + pDest Pointer to the Destination
19995 pSrc Pointer to the Source data
19996 Len Indicate the length of the Source dta
20006 ========================================================================
20008 VOID ARCFOUR_ENCRYPT(
20009 @@ -385,17 +385,17 @@
20011 Routine Description:
20012 Calculate a new FCS given the current FCS and the new data.
20016 Fcs the original FCS value
20017 Cp pointer to the data which will be calculate the FCS
20018 Len the length of the data
20022 ULONG - FCS 32 bits
20028 ========================================================================
20030 ULONG RTMP_CALC_FCS32(
20031 @@ -406,24 +406,24 @@
20033 Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
20042 ========================================================================
20044 Routine Description:
20045 - Get last FCS and encrypt it to the destination
20047 + Get last FCS and encrypt it to the destination
20050 - pDest Pointer to the Destination
20052 + pDest Pointer to the Destination
20061 ========================================================================
20064 @@ -431,11 +431,11 @@
20067 pAdapter->PrivateInfo.FCSCRC32 ^= 0xffffffff; /* complement */
20071 pAdapter->PrivateInfo.FCSCRC32 = SWAP32(pAdapter->PrivateInfo.FCSCRC32);
20075 ARCFOUR_ENCRYPT(&pAdapter->PrivateInfo.WEPCONTEXT, pDest, (PUCHAR) &pAdapter->PrivateInfo.FCSCRC32, 4);
20078 diff -Nur rt2500-1.1.0-b4/Module/sanity.c rt2500-cvs-2007061011/Module/sanity.c
20079 --- rt2500-1.1.0-b4/Module/sanity.c 2006-06-17 22:12:58.000000000 +0200
20080 +++ rt2500-cvs-2007061011/Module/sanity.c 2007-03-21 05:25:35.000000000 +0100
20082 -/***************************************************************************
20083 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
20085 - * This program is free software; you can redistribute it and/or modify *
20086 - * it under the terms of the GNU General Public License as published by *
20087 - * the Free Software Foundation; either version 2 of the License, or *
20088 - * (at your option) any later version. *
20090 - * This program is distributed in the hope that it will be useful, *
20091 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20092 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20093 - * GNU General Public License for more details. *
20095 - * You should have received a copy of the GNU General Public License *
20096 - * along with this program; if not, write to the *
20097 - * Free Software Foundation, Inc., *
20098 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20100 - * Licensed under the GNU GPL *
20101 - * Original code supplied under license from RaLink Inc, 2004. *
20102 - ***************************************************************************/
20104 - /***************************************************************************
20105 - * Module Name: sanity.c
20109 - * Revision History:
20111 - * -------- ----------- -----------------------------
20112 - * MarkW 8th Dec 04 Baseline code
20113 - ***************************************************************************/
20114 +/***************************************************************************
20115 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
20117 + * This program is free software; you can redistribute it and/or modify *
20118 + * it under the terms of the GNU General Public License as published by *
20119 + * the Free Software Foundation; either version 2 of the License, or *
20120 + * (at your option) any later version. *
20122 + * This program is distributed in the hope that it will be useful, *
20123 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20124 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20125 + * GNU General Public License for more details. *
20127 + * You should have received a copy of the GNU General Public License *
20128 + * along with this program; if not, write to the *
20129 + * Free Software Foundation, Inc., *
20130 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20132 + * Licensed under the GNU GPL *
20133 + * Original code supplied under license from RaLink Inc, 2004. *
20134 + ***************************************************************************/
20136 + /***************************************************************************
20137 + * Module Name: sanity.c
20141 + * Revision History:
20143 + * -------- ----------- -----------------------------
20144 + * MarkW 8th Dec 04 Baseline code
20145 + ***************************************************************************/
20147 #include "rt_config.h"
20149 -UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
20150 +static const UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
20151 +static const ie_oui_t wpa2_oui = {0x00, 0x0f, 0xac}; // 802.11i pp. 28, 30
20155 ==========================================================================
20157 MLME message sanity check
20158 @@ -44,13 +45,13 @@
20159 ==========================================================================
20161 BOOLEAN MlmeScanReqSanity(
20162 - IN PRTMP_ADAPTER pAd,
20165 - OUT UCHAR *BssType,
20167 - OUT UCHAR *SsidLen,
20168 - OUT UCHAR *ScanType)
20169 + IN PRTMP_ADAPTER pAd,
20172 + OUT UCHAR *BssType,
20174 + OUT UCHAR *SsidLen,
20175 + OUT UCHAR *ScanType)
20177 MLME_SCAN_REQ_STRUCT *Info;
20179 @@ -61,16 +62,16 @@
20180 *ScanType = Info->ScanType;
20182 if ((*BssType == BSS_INFRA || *BssType == BSS_INDEP || *BssType == BSS_ANY) &&
20183 - (*ScanType == SCAN_ACTIVE || *ScanType == SCAN_PASSIVE))
20184 + (*ScanType == SCAN_ACTIVE || *ScanType == SCAN_PASSIVE))
20189 DBGPRINT(RT_DEBUG_TRACE, "MlmeScanReqSanity fail - wrong BssType or ScanType\n");
20196 ==========================================================================
20198 MLME message sanity check
20199 @@ -79,16 +80,16 @@
20200 ==========================================================================
20202 BOOLEAN MlmeStartReqSanity(
20203 - IN PRTMP_ADAPTER pAd,
20207 - OUT UCHAR *SsidLen)
20208 + IN PRTMP_ADAPTER pAd,
20212 + OUT UCHAR *SsidLen)
20214 MLME_START_REQ_STRUCT *Info;
20216 Info = (MLME_START_REQ_STRUCT *)(Msg);
20219 if (Info->SsidLen > MAX_LEN_OF_SSID)
20221 DBGPRINT(RT_DEBUG_TRACE, "MlmeStartReqSanity fail - wrong SSID length\n");
20222 @@ -101,7 +102,7 @@
20228 ==========================================================================
20230 MLME message sanity check
20231 @@ -110,13 +111,13 @@
20232 ==========================================================================
20234 BOOLEAN MlmeAssocReqSanity(
20235 - IN PRTMP_ADAPTER pAd,
20238 - OUT MACADDR *ApAddr,
20239 - OUT USHORT *CapabilityInfo,
20240 - OUT ULONG *Timeout,
20241 - OUT USHORT *ListenIntv)
20242 + IN PRTMP_ADAPTER pAd,
20245 + OUT MACADDR *ApAddr,
20246 + OUT USHORT *CapabilityInfo,
20247 + OUT ULONG *Timeout,
20248 + OUT USHORT *ListenIntv)
20250 MLME_ASSOC_REQ_STRUCT *Info;
20252 @@ -129,7 +130,7 @@
20258 ==========================================================================
20260 MLME message sanity check
20261 @@ -138,12 +139,12 @@
20262 ==========================================================================
20264 BOOLEAN MlmeAuthReqSanity(
20265 - IN PRTMP_ADAPTER pAd,
20268 - OUT MACADDR *Addr,
20269 - OUT ULONG *Timeout,
20271 + IN PRTMP_ADAPTER pAd,
20274 + OUT MACADDR *Addr,
20275 + OUT ULONG *Timeout,
20278 MLME_AUTH_REQ_STRUCT *Info;
20280 @@ -152,18 +153,18 @@
20281 *Timeout = Info->Timeout;
20284 - if ((*Alg == Ndis802_11AuthModeShared || *Alg == Ndis802_11AuthModeOpen) && !MAC_ADDR_IS_GROUP(*Addr))
20285 + if ((*Alg == Ndis802_11AuthModeShared || *Alg == Ndis802_11AuthModeOpen) && !MAC_ADDR_IS_GROUP(*Addr))
20293 DBGPRINT(RT_DEBUG_TRACE, "MlmeAuthReqSanity fail - wrong algorithm\n");
20300 ==========================================================================
20302 MLME message sanity check
20303 @@ -172,16 +173,16 @@
20304 ==========================================================================
20306 BOOLEAN PeerAssocRspSanity(
20307 - IN PRTMP_ADAPTER pAd,
20310 - OUT MACADDR *Addr2,
20311 - OUT USHORT *CapabilityInfo,
20312 - OUT USHORT *Status,
20314 - OUT UCHAR Rates[],
20315 + IN PRTMP_ADAPTER pAd,
20318 + OUT MACADDR *Addr2,
20319 + OUT USHORT *CapabilityInfo,
20320 + OUT USHORT *Status,
20322 + OUT UCHAR Rates[],
20323 OUT UCHAR *RatesLen,
20324 - OUT BOOLEAN *ExtendedRateIeExist)
20325 + OUT BOOLEAN *ExtendedRateIeExist)
20328 MACFRAME *Fr = (MACFRAME *)Msg;
20329 @@ -195,7 +196,7 @@
20330 // Mask out unnecessary capability information
20331 *CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
20333 - if (*Status == MLME_SUCCESS)
20334 + if (*Status == MLME_SUCCESS)
20336 memcpy(Aid, &Fr->Octet[4], 2);
20337 *Aid = (*Aid) & 0x3fff; // AID is low 14-bit
20338 @@ -207,8 +208,8 @@
20340 DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity fail - wrong SupportedRates IE\n");
20346 memcpy(Rates, &Fr->Octet[8], *RatesLen);
20348 // many AP implement proprietary IEs in non-standard order, we'd better
20349 @@ -235,7 +236,7 @@
20353 - DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity - ignore unrecognized EID = %d\n", eid_ptr->Eid);
20354 + DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity - ignore unrecognized EID=%d (Len=%d)\n", eid_ptr->Eid, eid_ptr->Len);
20358 @@ -247,7 +248,7 @@
20364 ==========================================================================
20366 MLME message sanity check
20367 @@ -256,11 +257,11 @@
20368 ==========================================================================
20370 BOOLEAN PeerDisassocSanity(
20371 - IN PRTMP_ADAPTER pAd,
20374 - OUT MACADDR *Addr2,
20375 - OUT USHORT *Reason)
20376 + IN PRTMP_ADAPTER pAd,
20379 + OUT MACADDR *Addr2,
20380 + OUT USHORT *Reason)
20382 MACFRAME *Fr = (MACFRAME *)Msg;
20384 @@ -270,7 +271,7 @@
20390 ==========================================================================
20392 MLME message sanity check
20393 @@ -279,11 +280,11 @@
20394 ==========================================================================
20396 BOOLEAN PeerDeauthSanity(
20397 - IN PRTMP_ADAPTER pAd,
20400 - OUT MACADDR *Addr2,
20401 - OUT USHORT *Reason)
20402 + IN PRTMP_ADAPTER pAd,
20405 + OUT MACADDR *Addr2,
20406 + OUT USHORT *Reason)
20408 MACFRAME *Fr = (MACFRAME *)Msg;
20410 @@ -293,7 +294,7 @@
20416 ==========================================================================
20418 MLME message sanity check
20419 @@ -302,14 +303,14 @@
20420 ==========================================================================
20422 BOOLEAN PeerAuthSanity(
20423 - IN PRTMP_ADAPTER pAd,
20426 - OUT MACADDR *Addr,
20429 - OUT USHORT *Status,
20431 + IN PRTMP_ADAPTER pAd,
20434 + OUT MACADDR *Addr,
20437 + OUT USHORT *Status,
20440 MACFRAME *Fr = (MACFRAME *)Msg;
20442 @@ -318,43 +319,43 @@
20443 memcpy(Seq, &Fr->Octet[2], 2);
20444 memcpy(Status, &Fr->Octet[4], 2);
20446 - if (*Alg == Ndis802_11AuthModeOpen)
20447 + if (*Alg == Ndis802_11AuthModeOpen)
20449 - if (*Seq == 1 || *Seq == 2)
20450 + if (*Seq == 1 || *Seq == 2)
20458 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");
20462 - else if (*Alg == Ndis802_11AuthModeShared)
20464 + else if (*Alg == Ndis802_11AuthModeShared)
20466 - if (*Seq == 1 || *Seq == 4)
20467 + if (*Seq == 1 || *Seq == 4)
20471 - else if (*Seq == 2 || *Seq == 3)
20473 + else if (*Seq == 2 || *Seq == 3)
20475 memcpy(ChlgText, &Fr->Octet[8], CIPHER_TEXT_LEN);
20482 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");
20490 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong algorithm\n");
20497 ==========================================================================
20499 MLME message sanity check
20500 @@ -363,14 +364,14 @@
20501 ==========================================================================
20503 BOOLEAN PeerProbeReqSanity(
20504 - IN PRTMP_ADAPTER pAd,
20507 + IN PRTMP_ADAPTER pAd,
20510 OUT MACADDR *Addr2,
20512 - OUT UCHAR *SsidLen)
20513 -// OUT UCHAR Rates[],
20514 -// OUT UCHAR *RatesLen)
20516 + OUT UCHAR *SsidLen)
20517 +// OUT UCHAR Rates[],
20518 +// OUT UCHAR *RatesLen)
20522 @@ -379,27 +380,27 @@
20524 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
20526 - if ((Fr->Octet[0] != IE_SSID) || (Fr->Octet[1] > MAX_LEN_OF_SSID))
20527 + if ((Fr->Octet[0] != IE_SSID) || (Fr->Octet[1] > MAX_LEN_OF_SSID))
20529 DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",Fr->Octet[0],Fr->Octet[1]);
20535 *SsidLen = Fr->Octet[1];
20536 memcpy(Ssid, &Fr->Octet[2], *SsidLen);
20540 Idx = *SsidLen + 2;
20542 // -- get supported rates from payload and advance the pointer
20543 IeType = Fr->Octet[Idx];
20544 RateLen = Fr->Octet[Idx + 1];
20545 - if (IeType != IE_SUPP_RATES)
20546 + if (IeType != IE_SUPP_RATES)
20548 DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",Fr->Octet[Idx],Fr->Octet[Idx+1]);
20554 if ((pAd->PortCfg.AdhocMode == 2) && (RateLen < 8))
20556 @@ -408,7 +409,95 @@
20561 +static inline void handle_country_ie(
20566 + DBGPRINT(RT_DEBUG_INFO,
20567 + " - IE_COUNTRY (ID=%d) (Len=%d) "
20568 + "(string=\"%c%c:%c\")\n",
20569 + p->eid, p->length, p->cs.co[0], p->cs.co[1], p->cs.env);
20571 + // drop malformed elements
20572 + if (p->length & 1 || p->length < 6) {
20573 + DBGPRINT(RT_DEBUG_ERROR,
20574 + " - IE_COUNTRY invalid length\n");
20577 + for (i = 0; i < offsetof(country_string_t, env); i++) {
20578 + if (p->cs.co[i] < 'A' || p->cs.co[i] > 'z') {
20579 + DBGPRINT(RT_DEBUG_ERROR,
20580 + " - IE_COUNTRY invalid co fld\n");
20584 + if (p->cs.env != ' ' && p->cs.env != 'O' && p->cs.env != 'I') {
20585 + DBGPRINT(RT_DEBUG_ERROR,
20586 + " - IE_COUNTRY invalid env field\n");
20589 + if (p->length % 3 && *(char *)((char *)p + p->length + 1) != 0) {
20590 + DBGPRINT(RT_DEBUG_ERROR,
20591 + " - IE_COUNTRY pad non-null\n");
20596 + int num_subelements = p->length/3 - 1;
20597 + country_subelement_p sep = p->chans;
20598 + for (i = 0; i < num_subelements; i++, sep++)
20600 + DBGPRINT(RT_DEBUG_INFO,
20601 + " - Band %d First chan=%d, Num chans=%d, Max Tx Pwr=%d\n",
20602 + i, sep->first_chan, sep->num_chans, sep->max_tx_pwr);
20605 +#endif /* RT2500_DBG */
20608 +} /* End handle_country_ie () */
20610 +static inline int handle_rsn_ie(
20612 + PNDIS_802_11_VARIABLE_IEs pVIE)
20614 + DBGPRINT(RT_DEBUG_INFO,
20615 + " - IE_RSN (ID=%d, Len=%d)\n",
20616 + p->eid, p->length);
20618 + // drop malformed elements
20619 + if (p->length < 2 || p->length & 1) {
20620 + DBGPRINT(RT_DEBUG_ERROR,
20621 + " - IE_RSN invalid length\n");
20624 + if (wtohs(p->version) != 1) {
20625 + DBGPRINT(RT_DEBUG_ERROR,
20626 + " - IE_RSN invalid version %d\n",
20630 + if (p->length >= 6) { // group cipher suite
20631 + if (!RTMPEqualMemory(&p->gcsuite.oui, wpa2_oui, sizeof(wpa2_oui)))
20633 + DBGPRINT(RT_DEBUG_ERROR,
20634 + " - IE_RSN invalid oui "
20635 + "%02x %02x %02x\n",
20636 + p->gcsuite.oui[0], p->gcsuite.oui[1], p->gcsuite.oui[2]);
20640 + // Copy to pVIE which will report to microsoft bssid list.
20641 + pVIE->ElementID = p->eid;
20642 + pVIE->Length = p->length;
20643 + memcpy(pVIE->data, &p->version, p->length);
20645 + return (p->length + 2);
20647 +} /* End handle_rsn_ie () */
20650 ==========================================================================
20652 MLME message sanity check
20653 @@ -417,47 +506,56 @@
20654 ==========================================================================
20656 BOOLEAN PeerBeaconAndProbeRspSanity(
20657 - IN PRTMP_ADAPTER pAd,
20660 - OUT MACADDR *Addr2,
20661 - OUT MACADDR *Bssid,
20663 - OUT UCHAR *SsidLen,
20664 - OUT UCHAR *BssType,
20665 - OUT USHORT *BeaconPeriod,
20666 - OUT UCHAR *Channel,
20667 - OUT LARGE_INTEGER *Timestamp,
20668 - OUT BOOLEAN *CfExist,
20669 - OUT CF_PARM *CfParm,
20670 - OUT USHORT *AtimWin,
20671 - OUT USHORT *CapabilityInfo,
20672 - OUT UCHAR Rate[],
20673 + IN PRTMP_ADAPTER pAd,
20676 + OUT MACADDR *Addr2,
20677 + OUT MACADDR *Bssid,
20679 + OUT UCHAR *SsidLen,
20680 + OUT UCHAR *BssType,
20681 + OUT USHORT *BeaconPeriod,
20682 + OUT UCHAR *Channel,
20683 + OUT LARGE_INTEGER *Timestamp,
20684 + OUT BOOLEAN *CfExist,
20685 + OUT CF_PARM *CfParm,
20686 + OUT USHORT *AtimWin,
20687 + OUT USHORT *CapabilityInfo,
20688 + OUT UCHAR Rate[],
20689 OUT UCHAR *RateLen,
20690 OUT BOOLEAN *ExtendedRateIeExist,
20692 - OUT UCHAR *DtimCount,
20693 - OUT UCHAR *DtimPeriod,
20694 - OUT UCHAR *BcastFlag,
20695 - OUT UCHAR *MessageToMe,
20696 + OUT UCHAR *DtimCount,
20697 + OUT UCHAR *DtimPeriod,
20698 + OUT UCHAR *BcastFlag,
20699 + OUT UCHAR *MessageToMe,
20701 OUT UCHAR SupRate[],
20702 OUT UCHAR *SupRateLen,
20703 OUT UCHAR ExtRate[],
20704 OUT UCHAR *ExtRateLen,
20705 - OUT PNDIS_802_11_VARIABLE_IEs pVIE)
20706 + OUT USHORT *VarIELen, // Length of all saved IEs.
20707 + OUT PNDIS_802_11_VARIABLE_IEs pVIE)
20711 PBEACON_EID_STRUCT eid_ptr;
20714 + UCHAR VarIE[MAX_VIE_LEN];
20716 + // armor against buffer overflow
20717 + UCHAR *vielim = &VarIE[MAX_VIE_LEN];
20718 + NDIS_802_11_VARIABLE_IEs *ptVIE = (PNDIS_802_11_VARIABLE_IEs)VarIE;
20720 + DBGPRINT(RT_DEBUG_TRACE,"===> %s\n", __FUNCTION__);
20722 // Add for 3 necessary EID field check
20725 *ExtendedRateIeExist = FALSE;
20729 Fr = (MACFRAME *)Msg;
20731 @@ -481,40 +579,48 @@
20732 // get capability info from payload and advance the pointer
20733 memcpy(CapabilityInfo, Ptr, 2);
20735 - if (CAP_IS_ESS_ON(*CapabilityInfo))
20736 + DBGPRINT(RT_DEBUG_INFO, " - CapabilityInfo=0x%.2x\n", *CapabilityInfo);
20737 + if (CAP_IS_ESS_ON(*CapabilityInfo))
20739 *BssType = BSS_INFRA;
20745 *BssType = BSS_INDEP;
20748 // Mask out unnecessary capability information
20749 *CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
20752 eid_ptr = (PBEACON_EID_STRUCT) Ptr;
20754 // get variable fields from payload and advance the pointer
20755 while(((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
20757 + DBGPRINT(RT_DEBUG_INFO, " - IE #%d len=%d\n",
20758 + eid_ptr->Eid, eid_ptr->Len);
20759 switch(eid_ptr->Eid)
20762 - // Already has one SSID EID in this beacon, ignore the second one
20763 + // Already have one SSID EID in this beacon, ignore second one
20766 if(eid_ptr->Len <= MAX_LEN_OF_SSID)
20768 memcpy(Ssid, eid_ptr->Octet, eid_ptr->Len);
20769 - memset(Ssid + eid_ptr->Len,0,1);
20770 + if (eid_ptr->Len < MAX_LEN_OF_SSID)
20771 + memset(Ssid + eid_ptr->Len,0,1);
20772 *SsidLen = eid_ptr->Len;
20774 - //DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - ESSID=%s Len=%d\n",Ssid,eid_ptr->Len);
20775 + DBGPRINT(RT_DEBUG_INFO, " - SSID=%s Len=%d\n",
20776 + Ssid, eid_ptr->Len);
20777 + DBGHEXSTR(RT_DEBUG_INFO, " - SSID(hex)=",
20778 + Ssid, eid_ptr->Len);
20782 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",eid_ptr->Len);
20783 + DBGPRINT(RT_DEBUG_TRACE, "<=== %s - bad IE_SSID len=%d\n",
20784 + __FUNCTION__, eid_ptr->Len);
20788 @@ -546,13 +652,15 @@
20792 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_SUPP_RATES (len=%d)\n",eid_ptr->Len);
20793 + DBGPRINT(RT_DEBUG_TRACE,
20794 + "<=== %s - wrong IE_SUPP_RATES (len=%d)\n",
20795 + __FUNCTION__, eid_ptr->Len);
20801 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n");
20802 + DBGPRINT(RT_DEBUG_INFO, " - (IE_FH_PARM) \n");
20806 @@ -561,14 +669,18 @@
20807 *Channel = *eid_ptr->Octet;
20808 if (ChannelSanity(pAd, *Channel) == 0)
20810 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (ch=%d)\n",*Channel);
20811 + DBGPRINT(RT_DEBUG_TRACE,
20812 + "<=== %s - wrong IE_DS_PARM (ch=%d)\n",
20813 + __FUNCTION__, *Channel);
20820 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (len=%d)\n",eid_ptr->Len);
20821 + DBGPRINT(RT_DEBUG_TRACE,
20822 + "<=== %s - wrong IE_DS_PARM (len=%d)\n",
20823 + __FUNCTION__, eid_ptr->Len);
20827 @@ -581,7 +693,8 @@
20831 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_CF_PARM\n");
20832 + DBGPRINT(RT_DEBUG_TRACE, "<=== %s - wrong IE_CF_PARM\n",
20837 @@ -593,7 +706,8 @@
20841 - DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_IBSS_PARM\n");
20842 + DBGPRINT(RT_DEBUG_TRACE, "<=== %s - wrong IE_IBSS_PARM\n",
20847 @@ -605,18 +719,45 @@
20852 + handle_country_ie((country_ie_p)eid_ptr);
20857 - // Check the OUI version, filter out non-standard usage
20858 - if (RTMPEqualMemory(eid_ptr->Octet, WPA_OUI, 4))
20860 - // Copy to pVIE which will report to microsoft bssid list.
20861 - pVIE->ElementID = eid_ptr->Eid;
20862 - pVIE->Length = eid_ptr->Len;
20863 - memcpy(pVIE->data, eid_ptr->Octet, eid_ptr->Len);
20865 - DBGPRINT(RT_DEBUG_INFO, "PeerBeaconAndProbeRspSanity - Receive IE_WPA\n");
20867 + if (vielim >= (UCHAR *)ptVIE + eid_ptr->Len + 2)
20869 + // ptVIE will report to microsoft bssid list.
20870 + ptVIE->ElementID = eid_ptr->Eid;
20871 + ptVIE->Length = eid_ptr->Len;
20872 + memcpy(ptVIE->data, eid_ptr->Octet, eid_ptr->Len);
20873 + ptVIE = (PNDIS_802_11_VARIABLE_IEs)((UCHAR *)ptVIE +
20874 + ptVIE->Length + 2);
20875 + DBGPRINT(RT_DEBUG_INFO, " - OUI (%02x:%02x:%02x:%02x)\n",
20876 + eid_ptr->Octet[0], eid_ptr->Octet[1],
20877 + eid_ptr->Octet[2], eid_ptr->Octet[3]);
20881 + DBGPRINT(RT_DEBUG_ERROR,
20882 + " - IE_WPA rcv area needs %d bytes: has %d left\n",
20883 + eid_ptr->Len + 2, vielim - (UCHAR *)ptVIE);
20888 + if (vielim >= (UCHAR *)ptVIE + eid_ptr->Len + 2)
20890 + ptVIE = (PNDIS_802_11_VARIABLE_IEs)((UCHAR *)ptVIE +
20891 + handle_rsn_ie((rsn_ie_p)eid_ptr, ptVIE));
20895 + DBGPRINT(RT_DEBUG_ERROR,
20896 + " - IE_RSN rcv area needs %d bytes: has %d left\n",
20897 + eid_ptr->Len + 2, vielim - (UCHAR *)ptVIE);
20901 case IE_EXT_SUPP_RATES:
20902 // concatenate all extended rates to Rates[] and RateLen
20903 @@ -654,15 +795,20 @@
20904 *Erp = (UCHAR)eid_ptr->Octet[0];
20910 - DBGPRINT(RT_DEBUG_INFO, "PeerBeaconAndProbeRspSanity - unrecognized EID = %d\n", eid_ptr->Eid);
20911 + DBGPRINT(RT_DEBUG_ERROR, " - EID=%d (Len=%d) unrecognized\n",
20912 + eid_ptr->Eid, eid_ptr->Len);
20917 eid_ptr = (PBEACON_EID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
20920 + if ((UCHAR *)ptVIE > VarIE) {
20921 + int vielen = (UCHAR *)ptVIE - VarIE;
20922 + *VarIELen = vielen;
20923 + memcpy(pVIE, VarIE, vielen);
20926 // in 802.11a band, AP may skip this DS IE in their BEACON
20927 if ((pAd->PortCfg.Channel > 14) && ((Sanity & 0x04)==0))
20928 @@ -670,7 +816,8 @@
20929 *Channel = pAd->PortCfg.Channel;
20934 + DBGPRINT(RT_DEBUG_TRACE, "<=== %s: Sanity=0x%02x\n", __FUNCTION__, Sanity);
20937 DBGPRINT(RT_DEBUG_WARN, "PeerBeaconAndProbeRspSanity - missing field, Sanity=0x%02x\n", Sanity);
20938 @@ -683,19 +830,19 @@
20944 ==========================================================================
20946 ==========================================================================
20951 - OUT UCHAR *TimLen,
20952 - OUT UCHAR *BcastFlag,
20953 - OUT UCHAR *DtimCount,
20956 + OUT UCHAR *TimLen,
20957 + OUT UCHAR *BcastFlag,
20958 + OUT UCHAR *DtimCount,
20959 OUT UCHAR *DtimPeriod,
20960 - OUT UCHAR *MessageToMe)
20961 + OUT UCHAR *MessageToMe)
20963 UCHAR BitCntl, N1, N2, MyByte, MyBit;
20965 @@ -717,11 +864,11 @@
20969 - if ((*DtimCount == 0) && (BitCntl & 0x01))
20970 + if ((*DtimCount == 0) && (BitCntl & 0x01))
20974 *BcastFlag = FALSE;
20978 // Parse Partial Virtual Bitmap from TIM element
20979 N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
20980 @@ -738,10 +885,10 @@
20983 // DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
20986 if (*IdxPtr & (0x01 << MyBit))
20987 *MessageToMe = TRUE;
20990 *MessageToMe = FALSE;
20993 @@ -760,15 +907,15 @@
20998 - OUT UCHAR *Legacy)
21000 + OUT UCHAR *Legacy)
21006 UCHAR ChannelSanity(
21007 - IN PRTMP_ADAPTER pAd,
21008 + IN PRTMP_ADAPTER pAd,
21012 @@ -780,52 +927,52 @@
21018 switch (pAd->PortCfg.CountryRegion)
21020 case REGION_FCC: // 1 - 11
21021 if ((channel > 0) && (channel < 12))
21026 case REGION_IC: // 1 -11
21027 if ((channel > 0) && (channel < 12))
21032 case REGION_ETSI: // 1 - 13
21033 if ((channel > 0) && (channel < 14))
21038 case REGION_SPAIN: // 10 - 11
21039 if ((channel > 9) && (channel < 12))
21044 case REGION_FRANCE: // 10 -13
21045 if ((channel > 9) && (channel < 14))
21050 case REGION_MKK: // 14
21051 - if (channel == 14)
21052 + if (channel == 14)
21057 case REGION_MKK1: // 1 - 14
21058 if ((channel > 0) && (channel < 15))
21063 case REGION_ISRAEL: // 3 - 9
21064 if ((channel > 2) && (channel < 10))
21078 diff -Nur rt2500-1.1.0-b4/Module/sync.c rt2500-cvs-2007061011/Module/sync.c
21079 --- rt2500-1.1.0-b4/Module/sync.c 2006-06-17 22:12:58.000000000 +0200
21080 +++ rt2500-cvs-2007061011/Module/sync.c 2007-05-15 21:41:35.000000000 +0200
21082 -/***************************************************************************
21083 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
21085 - * This program is free software; you can redistribute it and/or modify *
21086 - * it under the terms of the GNU General Public License as published by *
21087 - * the Free Software Foundation; either version 2 of the License, or *
21088 - * (at your option) any later version. *
21090 - * This program is distributed in the hope that it will be useful, *
21091 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21092 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21093 - * GNU General Public License for more details. *
21095 - * You should have received a copy of the GNU General Public License *
21096 - * along with this program; if not, write to the *
21097 - * Free Software Foundation, Inc., *
21098 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21100 - * Licensed under the GNU GPL *
21101 - * Original code supplied under license from RaLink Inc, 2004. *
21102 - ***************************************************************************/
21104 - /***************************************************************************
21105 - * Module Name: sync.c
21109 - * Revision History:
21111 - * -------- ----------- -----------------------------
21112 - * MarkW 8th Dec 04 Baseline code
21113 +/***************************************************************************
21114 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
21116 + * This program is free software; you can redistribute it and/or modify *
21117 + * it under the terms of the GNU General Public License as published by *
21118 + * the Free Software Foundation; either version 2 of the License, or *
21119 + * (at your option) any later version. *
21121 + * This program is distributed in the hope that it will be useful, *
21122 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21123 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21124 + * GNU General Public License for more details. *
21126 + * You should have received a copy of the GNU General Public License *
21127 + * along with this program; if not, write to the *
21128 + * Free Software Foundation, Inc., *
21129 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21131 + * Licensed under the GNU GPL *
21132 + * Original code supplied under license from RaLink Inc, 2004. *
21133 + ***************************************************************************/
21135 + /***************************************************************************
21136 + * Module Name: sync.c
21140 + * Revision History:
21142 + * -------- ----------- -----------------------------
21143 + * MarkW 8th Dec 04 Baseline code
21144 * MarkW 10th Dec 04 Rolled in Ralink 1.4.5.0
21145 * MarkW 5th Jun 05 Fix no-SSID broadcasting assoc.
21146 - ***************************************************************************/
21147 + ***************************************************************************/
21149 #include "rt_config.h"
21153 ==========================================================================
21155 - The sync state machine,
21156 + The sync state machine,
21158 Sm - pointer to the state machine
21161 ==========================================================================
21163 VOID SyncStateMachineInit(
21164 - IN PRTMP_ADAPTER pAd,
21165 - IN STATE_MACHINE *Sm,
21166 - OUT STATE_MACHINE_FUNC Trans[])
21167 + IN PRTMP_ADAPTER pAd,
21168 + IN STATE_MACHINE *Sm,
21169 + OUT STATE_MACHINE_FUNC Trans[])
21171 StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_SYNC_STATE, MAX_SYNC_MSG, (STATE_MACHINE_FUNC)Drop, SYNC_IDLE, SYNC_MACHINE_BASE);
21173 @@ -105,7 +105,7 @@
21174 StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)MlmeStartReqAction);
21175 StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeacon);
21176 // StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_RSP, (STATE_MACHINE_FUNC)PeerBeacon);
21177 - StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
21178 + StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
21181 StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
21182 @@ -127,14 +127,14 @@
21183 RTMPInitTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, ScanTimeout);
21188 ==========================================================================
21190 Becaon timeout handler, executed in timer thread
21191 ==========================================================================
21193 VOID BeaconTimeout(
21194 - IN unsigned long data)
21195 + IN unsigned long data)
21197 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
21199 @@ -143,30 +143,30 @@
21205 ==========================================================================
21207 ATIM timeout handler, executed in timer thread
21208 ==========================================================================
21211 - IN unsigned long data)
21212 + IN unsigned long data)
21214 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
21217 DBGPRINT(RT_DEBUG_TRACE,"SYNC - AtimTimeout \n");
21218 MlmeEnqueue(&pAd->Mlme.Queue, SYNC_STATE_MACHINE, MT2_ATIM_TIMEOUT, 0, NULL);
21224 ==========================================================================
21226 Scan timeout handler, executed in timer thread
21227 ==========================================================================
21230 - IN unsigned long data)
21231 + IN unsigned long data)
21233 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
21235 @@ -175,15 +175,15 @@
21241 ==========================================================================
21243 MLME SCAN req state machine procedure
21244 ==========================================================================
21246 VOID MlmeScanReqAction(
21247 - IN PRTMP_ADAPTER pAd,
21248 - IN MLME_QUEUE_ELEM *Elem)
21249 + IN PRTMP_ADAPTER pAd,
21250 + IN MLME_QUEUE_ELEM *Elem)
21252 UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType;
21254 @@ -192,13 +192,13 @@
21255 RTMPSuspendMsduTransmission(pAd);
21257 // first check the parameter sanity
21258 - if (MlmeScanReqSanity(pAd,
21265 + if (MlmeScanReqSanity(pAd,
21273 DBGPRINT(RT_DEBUG_TRACE, "SYNC - MlmeScanReqAction\n");
21275 @@ -212,12 +212,12 @@
21276 pAd->Mlme.SyncAux.ScanType = ScanType;
21277 pAd->Mlme.SyncAux.SsidLen = SsidLen;
21278 memcpy(pAd->Mlme.SyncAux.Ssid, Ssid, SsidLen);
21281 // start from the first channel
21282 pAd->Mlme.SyncAux.Channel = FirstChannel(pAd);
21283 ScanNextChannel(pAd);
21289 printk(KERN_ERR DRV_NAME "SYNC - MlmeScanReqAction() sanity check fail. BUG!!!\n");
21290 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
21291 @@ -225,15 +225,15 @@
21297 ==========================================================================
21299 MLME JOIN req state machine procedure
21300 ==========================================================================
21302 VOID MlmeJoinReqAction(
21303 - IN PRTMP_ADAPTER pAd,
21304 - IN MLME_QUEUE_ELEM *Elem)
21305 + IN PRTMP_ADAPTER pAd,
21306 + IN MLME_QUEUE_ELEM *Elem)
21309 MLME_JOIN_REQ_STRUCT *Info = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg);
21310 @@ -255,7 +255,7 @@
21311 AsicSwitchChannel(pAd, pBss->Channel);
21312 AsicLockChannel(pAd, pBss->Channel);
21313 DBGPRINT(RT_DEBUG_TRACE, "SYNC - Switch to channel %d, SSID %s \n", pBss->Channel, pAd->Mlme.SyncAux.Ssid);
21314 - DBGPRINT(RT_DEBUG_TRACE, "SYNC - Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x ...\n",
21315 + DBGPRINT(RT_DEBUG_TRACE, "SYNC - Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x ...\n",
21316 pAd->Mlme.SyncAux.Bssid.Octet[0], pAd->Mlme.SyncAux.Bssid.Octet[1],
21317 pAd->Mlme.SyncAux.Bssid.Octet[2], pAd->Mlme.SyncAux.Bssid.Octet[3],
21318 pAd->Mlme.SyncAux.Bssid.Octet[4], pAd->Mlme.SyncAux.Bssid.Octet[5]);
21319 @@ -264,17 +264,17 @@
21320 pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
21325 ==========================================================================
21327 MLME START Request state machine procedure, starting an IBSS
21328 ==========================================================================
21330 VOID MlmeStartReqAction(
21331 - IN PRTMP_ADAPTER pAd,
21332 - IN MLME_QUEUE_ELEM *Elem)
21333 + IN PRTMP_ADAPTER pAd,
21334 + IN MLME_QUEUE_ELEM *Elem)
21336 - UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
21337 + UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
21339 // New for WPA security suites
21340 UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21341 @@ -293,20 +293,20 @@
21342 TimeStamp.vv.LowPart = 0;
21343 TimeStamp.vv.HighPart = 0;
21345 - if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen))
21346 + if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen))
21348 // reset all the timers
21349 RTMPCancelTimer(&pAd->Mlme.SyncAux.ScanTimer);
21350 RTMPCancelTimer(&pAd->Mlme.SyncAux.BeaconTimer);
21352 - // PortCfg.PrivacyInvoked should have been set via OID_802_11_WEP_STATUS.
21353 + // PortCfg.PrivacyInvoked should have been set via OID_802_11_WEP_STATUS.
21354 // pAd->PortCfg.PrivacyInvoked = FALSE;
21356 - memcpy(pAd->PortCfg.Ssid, Ssid, SsidLen);
21357 + memcpy(pAd->PortCfg.Ssid, Ssid, SsidLen);
21358 pAd->PortCfg.SsidLen = SsidLen;
21359 pAd->PortCfg.BssType = BSS_INDEP;
21360 - Privacy = (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
21361 - (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
21362 + Privacy = (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
21363 + (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
21364 (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled);
21365 pAd->PortCfg.CapabilityInfo = CAP_GENERATE(0,1,0,0,Privacy, (pAd->PortCfg.WindowsTxPreamble == Rt802_11PreambleShort));
21366 pAd->PortCfg.BeaconPeriod = pAd->PortCfg.IbssConfig.BeaconPeriod;
21367 @@ -328,7 +328,7 @@
21369 // generate a radom number as BSSID
21370 MacAddrRandomBssid(pAd, &pAd->PortCfg.Bssid);
21371 - AsicSetBssid(pAd, &pAd->PortCfg.Bssid);
21372 + AsicSetBssid(pAd, &pAd->PortCfg.Bssid);
21373 AsicSwitchChannel(pAd, pAd->PortCfg.Channel);
21374 AsicLockChannel(pAd, pAd->PortCfg.Channel);
21376 @@ -341,17 +341,17 @@
21377 if (Bssidx == BSS_NOT_FOUND)
21379 Bssidx = BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &pAd->PortCfg.Bssid,
21380 - Ssid, SsidLen, pAd->PortCfg.BssType, pAd->PortCfg.BeaconPeriod,
21381 - CfExist, &CfParm, pAd->PortCfg.AtimWin, pAd->PortCfg.CapabilityInfo,
21382 + Ssid, SsidLen, pAd->PortCfg.BssType, pAd->PortCfg.BeaconPeriod,
21383 + CfExist, &CfParm, pAd->PortCfg.AtimWin, pAd->PortCfg.CapabilityInfo,
21384 pAd->PortCfg.SupportedRates, pAd->PortCfg.SupportedRatesLen, TRUE,
21385 - pAd->PortCfg.Channel, Elem->Rssi, TimeStamp, pVIE);
21386 + pAd->PortCfg.Channel, Elem->Rssi, TimeStamp, 0, pVIE);
21390 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
21391 MlmeCntlConfirm(pAd, MT2_START_CONF, (USHORT)MLME_SUCCESS);
21397 printk(KERN_ERR DRV_NAME "SYNC - MlmeStartReqAction() sanity check fail. BUG!!!\n");
21398 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
21399 @@ -359,18 +359,18 @@
21405 ==========================================================================
21407 peer sends beacon back when scanning
21408 ==========================================================================
21410 VOID PeerBeaconAtScanAction(
21411 - IN PRTMP_ADAPTER pAd,
21412 - IN MLME_QUEUE_ELEM *Elem)
21413 + IN PRTMP_ADAPTER pAd,
21414 + IN MLME_QUEUE_ELEM *Elem)
21416 MACADDR Bssid, Addr2;
21417 - UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, Rates[MAX_LEN_OF_SUPPORTED_RATES], RatesLen,
21418 + UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, Rates[MAX_LEN_OF_SUPPORTED_RATES], RatesLen,
21419 SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe, Legacy;
21421 USHORT BeaconPeriod, AtimWin, CapabilityInfo;
21422 @@ -383,54 +383,55 @@
21423 UCHAR SupRateLen, ExtRateLen;
21425 // New for WPA security suites
21426 - UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21427 + USHORT VarIELen; // Length of all saved IEs.
21428 + UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21429 NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
21431 // NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00);
21432 Fr = (MACFRAME *) Elem->Msg;
21433 // Init Variable IE structure
21434 pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
21435 - pVIE->Length = 0;
21436 - if (PeerBeaconAndProbeRspSanity(pAd,
21451 + if (PeerBeaconAndProbeRspSanity(pAd,
21467 &ExtendedRateIeExist,
21490 // This correct im-proper RSSI indication during SITE SURVEY issue.
21491 - // Always report bigger RSSI during SCANNING when receiving multiple BEACONs from the same AP.
21492 - // This case happens because BEACONs come from adjacent channels, so RSSI become weaker as we
21493 + // Always report bigger RSSI during SCANNING when receiving multiple BEACONs from the same AP.
21494 + // This case happens because BEACONs come from adjacent channels, so RSSI become weaker as we
21495 // switch to more far away channels.
21496 Idx = BssTableSearch(&pAd->PortCfg.BssTab, &Bssid);
21497 if (Idx != BSS_NOT_FOUND)
21500 Rssi = pAd->PortCfg.BssTab.BssEntry[Idx].Rssi;
21501 Noise = pAd->PortCfg.BssTab.BssEntry[Idx].Noise;
21503 @@ -445,25 +446,25 @@
21505 // Mask out unnecessary capability information
21506 CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
21507 - BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &Bssid, Ssid, SsidLen, BssType,
21508 - BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo, Rates,
21509 - RatesLen, ExtendedRateIeExist, Channel, Rssi, Noise, TimeStamp, pVIE);
21510 + BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &Bssid, Ssid, SsidLen, BssType,
21511 + BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo, Rates,
21512 + RatesLen, ExtendedRateIeExist, Channel, Rssi, Noise, TimeStamp, VarIELen, pVIE);
21514 // sanity check fail, ignored
21519 ==========================================================================
21521 When waiting joining the (I)BSS, beacon received from external
21522 ==========================================================================
21524 VOID PeerBeaconAtJoinAction(
21525 - IN PRTMP_ADAPTER pAd,
21526 - IN MLME_QUEUE_ELEM *Elem)
21527 + IN PRTMP_ADAPTER pAd,
21528 + IN MLME_QUEUE_ELEM *Elem)
21530 MACADDR Bssid, Addr2;
21531 - UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, RatesLen, MessageToMe,
21532 + UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, RatesLen, MessageToMe,
21533 Rates[MAX_LEN_OF_SUPPORTED_RATES], DtimCount, DtimPeriod, BcastFlag, Legacy;
21534 LARGE_INTEGER TimeStamp;
21535 USHORT BeaconPeriod, AtimWin, CapabilityInfo;
21536 @@ -474,46 +475,48 @@
21537 UCHAR SupRateLen, ExtRateLen;
21539 // New for WPA security suites
21540 - UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21541 + USHORT VarIELen; // Length of all saved IEs.
21542 + UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21543 NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
21545 // Init Variable IE structure
21546 pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
21548 - if (PeerBeaconAndProbeRspSanity(pAd,
21564 + if (PeerBeaconAndProbeRspSanity(pAd,
21581 &ExtendedRateIeExist,
21600 // Disqualify 11b only adhoc when we are in 11g only adhoc mode
21601 if ((BssType == BSS_INDEP) && (pAd->PortCfg.AdhocMode == 2) && (RatesLen < 12))
21605 if (MAC_ADDR_EQUAL(&pAd->Mlme.SyncAux.Bssid, &Bssid))
21607 DBGPRINT(RT_DEBUG_TRACE, "SYNC - receive desired BEACON at JoinWaitBeacon...\n");
21608 @@ -522,7 +525,7 @@
21609 // Update RSSI to prevent No signal display when cards first initialized
21610 pAd->PortCfg.LastRssi = Elem->Rssi;
21611 pAd->PortCfg.AvgRssi = Elem->Rssi;
21614 if (pAd->Mlme.SyncAux.SsidLen > 0)
21616 memcpy(pAd->PortCfg.Ssid, pAd->Mlme.SyncAux.Ssid, pAd->Mlme.SyncAux.SsidLen);
21617 @@ -533,7 +536,7 @@
21618 memcpy(pAd->PortCfg.Ssid, Ssid, SsidLen);
21619 pAd->PortCfg.SsidLen = SsidLen;
21623 COPY_MAC_ADDR(&pAd->PortCfg.Bssid, &Bssid);
21624 AsicSetBssid(pAd, &pAd->PortCfg.Bssid);
21626 @@ -620,22 +623,22 @@
21628 pAd->PortCfg.ExtRateLen = 0;
21631 - DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP's SupportedRatesLen=%d, set STA's SupportedRateLen=%d\n",
21633 + DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP's SupportedRatesLen=%d, set STA's SupportedRateLen=%d\n",
21634 RatesLen, pAd->PortCfg.SupportedRatesLen);
21637 // Mask out unnecessary capability information
21638 CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
21641 // Check for 802.11g information, if 802.11 b/g mixed mode.
21642 // We can't support its short preamble for now.
21643 pAd->PortCfg.CapabilityInfo = CapabilityInfo;
21645 - if ((BssType == BSS_INDEP) && (CAP_IS_IBSS_ON(CapabilityInfo)))
21646 + if ((BssType == BSS_INDEP) && (CAP_IS_IBSS_ON(CapabilityInfo)))
21648 pAd->PortCfg.AtimWin = AtimWin;
21650 - else if (BssType == BSS_INFRA)
21652 + else if (BssType == BSS_INFRA)
21654 pAd->PortCfg.CfpPeriod = Cf.CfpPeriod;
21655 pAd->PortCfg.CfpMaxDuration = Cf.CfpMaxDuration;
21656 @@ -650,19 +653,19 @@
21657 MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_SUCCESS);
21659 // not to me BEACON, ignored
21662 // sanity check fail, ignore this frame
21667 ==========================================================================
21669 receive BEACON from peer
21670 ==========================================================================
21673 - IN PRTMP_ADAPTER pAd,
21674 - IN MLME_QUEUE_ELEM *Elem)
21675 + IN PRTMP_ADAPTER pAd,
21676 + IN MLME_QUEUE_ELEM *Elem)
21678 MACADDR Bssid, Addr2;
21679 CHAR Ssid[MAX_LEN_OF_SSID];
21680 @@ -679,7 +682,8 @@
21681 UCHAR SupRateLen, ExtRateLen;
21683 // New for WPA security suites
21684 - UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21685 + USHORT VarIELen; // Length of all saved IEs.
21686 + UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
21687 NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
21689 if (!INFRA_ON(pAd) && !ADHOC_ON(pAd))
21690 @@ -688,35 +692,36 @@
21691 // Init Variable IE structure
21692 pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
21694 - if (PeerBeaconAndProbeRspSanity(pAd,
21710 + if (PeerBeaconAndProbeRspSanity(pAd,
21727 &ExtendedRateIeExist,
21746 BOOLEAN is_my_bssid, is_my_ssid;
21748 @@ -732,7 +737,7 @@
21752 - // Housekeeping "SsidBssTab" table for later-on ROAMing usage.
21753 + // Housekeeping "SsidBssTab" table for later-on ROAMing usage.
21755 Bssidx = BssTableSearch(&pAd->Mlme.CntlAux.SsidBssTab, &Bssid);
21756 if (Bssidx == BSS_NOT_FOUND)
21757 @@ -743,24 +748,24 @@
21759 if (!RTMPEqualMemory(pAd->PortCfg.Ssid, pAd->Mlme.CntlAux.Ssid, pAd->PortCfg.SsidLen))
21763 // discover new AP of this network, create BSS entry
21764 - Bssidx = BssTableSetEntry(pAd, &pAd->Mlme.CntlAux.SsidBssTab, &Bssid, Ssid, SsidLen,
21765 - BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo,
21766 - Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, Elem->Noise, TimeStamp, pVIE);
21767 + Bssidx = BssTableSetEntry(pAd, &pAd->Mlme.CntlAux.SsidBssTab, &Bssid, Ssid, SsidLen,
21768 + BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo,
21769 + Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, Elem->Noise, TimeStamp, VarIELen, pVIE);
21771 if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
21775 - DBGPRINT(RT_DEBUG_TRACE, "SYNC - New AP added to SsidBssTab[%d], RSSI=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
21776 - Bssidx, Elem->Rssi, Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2],
21777 + DBGPRINT(RT_DEBUG_TRACE, "SYNC - New AP added to SsidBssTab[%d], RSSI=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
21778 + Bssidx, Elem->Rssi, Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2],
21779 Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5]);
21782 // if the ssid matched & bssid unmatched, we should select the bssid with large value.
21783 // This might happened when two STA start at the same time
21784 - if (is_my_ssid && (! is_my_bssid) && ADHOC_ON(pAd))
21786 + if (is_my_ssid && (! is_my_bssid) && ADHOC_ON(pAd)
21787 + && (BssType == BSS_INDEP)) {
21789 // Add to safe guard adhoc wep status mismatch
21790 if (pAd->PortCfg.WepStatus != pAd->Mlme.CntlAux.SsidBssTab.BssEntry[Bssidx].WepStatus)
21791 @@ -773,7 +778,7 @@
21793 AsicDisableSync(pAd);
21794 memcpy(&pAd->PortCfg.Bssid, &Bssid, 6);
21795 - AsicSetBssid(pAd, &pAd->PortCfg.Bssid);
21796 + AsicSetBssid(pAd, &pAd->PortCfg.Bssid);
21797 MakeIbssBeacon(pAd);
21798 AsicEnableIbssSync(pAd);
21800 @@ -781,9 +786,9 @@
21804 - DBGPRINT(RT_DEBUG_INFO, "SYNC - PeerBeacon from %02x:%02x:%02x:%02x:%02x:%02x - Dtim=%d/%d, Rssi=%02x\n",
21805 - Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2],
21806 - Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5],
21807 + DBGPRINT(RT_DEBUG_INFO, "SYNC - PeerBeacon from %02x:%02x:%02x:%02x:%02x:%02x - Dtim=%d/%d, Rssi=%02x\n",
21808 + Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2],
21809 + Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5],
21810 DtimCount, DtimPeriod, Elem->Rssi);
21813 @@ -793,24 +798,24 @@
21816 // BEACON from my BSSID - either IBSS or INFRA network
21821 - // 2002/12/06 - patch Abocom AP bug, which forgets to set "Privacy" bit in
21822 - // AssocRsp even though this bit is ON in Beacon. So we update according
21823 + // 2002/12/06 - patch Abocom AP bug, which forgets to set "Privacy" bit in
21824 + // AssocRsp even though this bit is ON in Beacon. So we update according
21825 // to following Beacon frame.
21826 // pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(CapabilityInfo);
21829 pAd->PortCfg.LastBeaconRxTime = Now;
21831 // at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps
21832 // after last 11b peer left for several seconds, we'll auto switch back to 11G rate
21833 // in MlmePeriodicExec()
21834 - if (ADHOC_ON(pAd) && (RatesLen <= 4))
21835 + if (ADHOC_ON(pAd) && (RatesLen <= 4))
21837 // this timestamp is for MlmePeriodicExec() to check if all 11B peers have left
21838 pAd->PortCfg.Last11bBeaconRxTime = Now;
21841 if (pAd->PortCfg.MaxTxRate > RATE_11)
21843 DBGPRINT(RT_DEBUG_TRACE, "SYNC - 11b peer joined. down-grade to 11b TX rates \n");
21844 @@ -828,22 +833,22 @@
21845 (pAd->PortCfg.LastRssi < pAd->PortCfg.RssiTrigger))
21847 // NDIS_802_11_RSSI Dbm = pAd->PortCfg.LastRssi - RSSI_TO_DBM_OFFSET;
21848 - // DBGPRINT(RT_DEBUG_TRACE, "SYNC - NdisMIndicateStatus *** RSSI %d dBm, less than threshold %d dBm\n",
21849 + // DBGPRINT(RT_DEBUG_TRACE, "SYNC - NdisMIndicateStatus *** RSSI %d dBm, less than threshold %d dBm\n",
21850 // Dbm, pAd->PortCfg.RssiTrigger - RSSI_TO_DBM_OFFSET);
21852 else if ((pAd->PortCfg.RssiTriggerMode == RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD) &&
21853 (pAd->PortCfg.LastRssi > pAd->PortCfg.RssiTrigger))
21855 // NDIS_802_11_RSSI Dbm = pAd->PortCfg.LastRssi - RSSI_TO_DBM_OFFSET;
21856 - // DBGPRINT(RT_DEBUG_TRACE, "SYNC - NdisMIndicateStatus *** RSSI %d dBm, greater than threshold %d dBm\n",
21857 + // DBGPRINT(RT_DEBUG_TRACE, "SYNC - NdisMIndicateStatus *** RSSI %d dBm, greater than threshold %d dBm\n",
21858 // Dbm, pAd->PortCfg.RssiTrigger - RSSI_TO_DBM_OFFSET);
21861 if (INFRA_ON(pAd)) // && (pAd->PortCfg.PhyMode == PHY_11BG_MIXED))
21863 BOOLEAN bUseShortSlot, bUseBGProtection;
21865 - // decide to use/change to -
21867 + // decide to use/change to -
21868 // 1. long slot (20 us) or short slot (9 us) time
21869 // 2. turn on/off RTS/CTS and/or CTS-to-self protection
21870 // 3. short preamble
21871 @@ -867,7 +872,7 @@
21874 // only INFRASTRUCTURE mode support power-saving feature
21875 - if (INFRA_ON(pAd) && (pAd->PortCfg.Psm == PWR_SAVE))
21876 + if (INFRA_ON(pAd) && (pAd->PortCfg.Psm == PWR_SAVE))
21878 // 1. AP has backlogged unicast-to-me frame, stay AWAKE, send PSPOLL
21879 // 2. AP has backlogged broadcast/multicast frame and we want those frames, stay AWAKE
21880 @@ -882,17 +887,17 @@
21881 else if (BcastFlag && (DtimCount == 0) && pAd->PortCfg.RecvDtim)
21883 DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP backlog broadcast/multicast, stay AWAKE\n");
21886 else if ((RTMPFreeDescriptorRequest(pAd, TX_RING, TX_RING_SIZE) != NDIS_STATUS_SUCCESS) ||
21887 (RTMPFreeDescriptorRequest(pAd, PRIO_RING, PRIO_RING_SIZE) != NDIS_STATUS_SUCCESS))
21889 DBGPRINT(RT_DEBUG_TRACE, "SYNC - outgoing frame in TxRing/PrioRing, stay AWAKE\n");
21894 USHORT NextDtim = DtimCount;
21896 - if (NextDtim == 0)
21897 + if (NextDtim == 0)
21898 NextDtim = DtimPeriod;
21900 TbttNumToNextWakeUp = pAd->PortCfg.DefaultListenCount;
21901 @@ -906,20 +911,21 @@
21903 #ifndef SINGLE_ADHOC_LINKUP
21904 // At least another peer in this IBSS, declare MediaState as CONNECTED
21905 - if (ADHOC_ON(pAd) && (pAd->MediaState == NdisMediaStateDisconnected))
21907 + if (ADHOC_ON(pAd)
21908 + && (pAd->MediaState == NdisMediaStateDisconnected)
21909 + && (BssType == BSS_INDEP)) {
21910 pAd->MediaState = NdisMediaStateConnected;
21912 // 2003/03/12 - john
21913 // Make sure this entry in "PortCfg.BssTab" table, thus complies to Microsoft's policy that
21914 - // "site survey" result should always include the current connected network.
21915 + // "site survey" result should always include the current connected network.
21917 Bssidx = BssTableSearch(&pAd->PortCfg.BssTab, &Bssid);
21918 if (Bssidx == BSS_NOT_FOUND)
21920 - Bssidx = BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &Bssid, Ssid, SsidLen,
21921 - BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo,
21922 - Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, Elem->Noise, TimeStamp, pVIE);
21923 + Bssidx = BssTableSetEntry(pAd, &pAd->PortCfg.BssTab, &Bssid, Ssid, SsidLen,
21924 + BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo,
21925 + Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, Elem->Noise, TimeStamp, VarIELen, pVIE);
21929 @@ -929,15 +935,15 @@
21930 // sanity check fail, ignore this frame
21935 ==========================================================================
21937 Receive PROBE REQ from remote peer when operating in IBSS mode
21938 ==========================================================================
21940 VOID PeerProbeReqAction(
21941 - IN PRTMP_ADAPTER pAd,
21942 - IN MLME_QUEUE_ELEM *Elem)
21943 + IN PRTMP_ADAPTER pAd,
21944 + IN MLME_QUEUE_ELEM *Elem)
21947 CHAR Ssid[MAX_LEN_OF_SSID];
21948 @@ -947,13 +953,13 @@
21949 UCHAR *OutBuffer = NULL;
21950 ULONG FrameLen = 0;
21951 LARGE_INTEGER FakeTimestamp;
21952 - UCHAR SsidIe = IE_SSID, DsIe = IE_DS_PARM, IbssIe = IE_IBSS_PARM, SuppIe = IE_SUPP_RATES,
21953 + UCHAR SsidIe = IE_SSID, DsIe = IE_DS_PARM, IbssIe = IE_IBSS_PARM, SuppIe = IE_SUPP_RATES,
21954 DsLen = 1, IbssLen = 2;
21955 UCHAR SupportedRatesLen;
21956 UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
21957 UCHAR ExtRateIe = IE_EXT_SUPP_RATES, ExtRatesLen;
21958 UCHAR ErpIe[3] = {IE_ERP, 1, 0};
21961 if (! ADHOC_ON(pAd))
21964 @@ -962,8 +968,8 @@
21965 if ((SsidLen == 0) || RTMPEqualMemory(Ssid, pAd->PortCfg.Ssid, (ULONG) SsidLen))
21969 - // we should respond a ProbeRsp only when we're the last BEACON transmitter
21971 + // we should respond a ProbeRsp only when we're the last BEACON transmitter
21972 // in this ADHOC network.
21973 RTMP_IO_READ32(pAd, CSR15, &Csr15.word);
21974 if (Csr15.field.BeaconSent == 0)
21975 @@ -1016,28 +1022,28 @@
21978 pAd->PortCfg.AtimWin = 0; // ??????
21979 - DBGPRINT(RT_DEBUG_TRACE, "SYNC - Send PROBE_RSP to %02x:%02x:%02x:%02x:%02x:%02x...\n",
21980 + DBGPRINT(RT_DEBUG_TRACE, "SYNC - Send PROBE_RSP to %02x:%02x:%02x:%02x:%02x:%02x...\n",
21981 Addr2.Octet[0],Addr2.Octet[1],Addr2.Octet[2],Addr2.Octet[3],Addr2.Octet[4],Addr2.Octet[5] );
21982 MgtMacHeaderInit(pAd, &ProbeRspHdr, SUBTYPE_PROBE_RSP, 0, &Addr2, &pAd->PortCfg.Bssid);
21984 if (SupportedRatesLen <= 8)
21986 - MakeOutgoingFrame(OutBuffer, &FrameLen,
21987 - MAC_HDR_LEN, &ProbeRspHdr,
21988 + MakeOutgoingFrame(OutBuffer, &FrameLen,
21989 + MAC_HDR_LEN, &ProbeRspHdr,
21990 TIMESTAMP_LEN, &FakeTimestamp,
21991 2, &pAd->PortCfg.BeaconPeriod,
21992 2, &pAd->PortCfg.CapabilityInfo,
21994 - 1, &pAd->PortCfg.SsidLen,
21996 + 1, &pAd->PortCfg.SsidLen,
21997 pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
22000 1, &SupportedRatesLen,
22001 - SupportedRatesLen, SupportedRates,
22004 + SupportedRatesLen, SupportedRates,
22007 1, &pAd->PortCfg.Channel,
22012 2, &pAd->PortCfg.AtimWin,
22015 @@ -1045,22 +1051,22 @@
22017 ExtRatesLen = SupportedRatesLen - 8;
22018 SupportedRatesLen = 8;
22019 - MakeOutgoingFrame(OutBuffer, &FrameLen,
22020 - MAC_HDR_LEN, &ProbeRspHdr,
22021 + MakeOutgoingFrame(OutBuffer, &FrameLen,
22022 + MAC_HDR_LEN, &ProbeRspHdr,
22023 TIMESTAMP_LEN, &FakeTimestamp,
22024 2, &pAd->PortCfg.BeaconPeriod,
22025 2, &pAd->PortCfg.CapabilityInfo,
22027 - 1, &pAd->PortCfg.SsidLen,
22029 + 1, &pAd->PortCfg.SsidLen,
22030 pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
22033 1, &SupportedRatesLen,
22034 - SupportedRatesLen, SupportedRates,
22037 + SupportedRatesLen, SupportedRates,
22040 1, &pAd->PortCfg.Channel,
22045 2, &pAd->PortCfg.AtimWin,
22048 @@ -1073,7 +1079,7 @@
22051 UCHAR WpaIe = IE_WPA;
22054 if (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) // Tkip
22056 MakeOutgoingFrame(OutBuffer + FrameLen, &tmp,
22057 @@ -1092,43 +1098,43 @@
22063 MiniportMMRequest(pAd, OutBuffer, FrameLen);
22068 VOID BeaconTimeoutAtJoinAction(
22069 - IN PRTMP_ADAPTER pAd,
22070 - IN MLME_QUEUE_ELEM *Elem)
22071 + IN PRTMP_ADAPTER pAd,
22072 + IN MLME_QUEUE_ELEM *Elem)
22074 DBGPRINT(RT_DEBUG_TRACE, "SYNC - BeaconTimeoutAtJoinAction\n");
22075 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
22076 MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_REJ_TIMEOUT);
22081 ==========================================================================
22083 Scan timeout procedure. basically add channel index by 1 and rescan
22084 ==========================================================================
22086 VOID ScanTimeoutAction(
22087 - IN PRTMP_ADAPTER pAd,
22088 - IN MLME_QUEUE_ELEM *Elem)
22089 + IN PRTMP_ADAPTER pAd,
22090 + IN MLME_QUEUE_ELEM *Elem)
22092 pAd->Mlme.SyncAux.Channel = NextChannel(pAd, pAd->Mlme.SyncAux.Channel);
22093 ScanNextChannel(pAd);
22098 ==========================================================================
22101 ==========================================================================
22103 VOID ScanNextChannel(
22104 - IN PRTMP_ADAPTER pAd)
22105 + IN PRTMP_ADAPTER pAd)
22108 UCHAR SsidIe = IE_SSID, SuppRateIe = IE_SUPP_RATES;
22109 @@ -1138,36 +1144,36 @@
22110 ULONG FrameLen = 0;
22113 - if (pAd->Mlme.SyncAux.Channel == 0)
22114 + if (pAd->Mlme.SyncAux.Channel == 0)
22116 DBGPRINT(RT_DEBUG_INFO, "SYNC - End of SCAN, restore to channel %d\n",pAd->PortCfg.Channel);
22117 AsicSwitchChannel(pAd, pAd->PortCfg.Channel);
22118 AsicLockChannel(pAd, pAd->PortCfg.Channel);
22121 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
22122 MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_SUCCESS);
22128 AsicSwitchChannel(pAd, pAd->Mlme.SyncAux.Channel);
22130 - // Total SCAN time still limits within 3 sec (DDK constraint).
22131 + // Total SCAN time still limits within 3 sec (DDK constraint).
22132 // TODO: We need more intelligent rules here to further improve out-of-service issue.
22133 // e.g. temporary stop copying NDIS packet to TxRing until SCAN complete
22134 // if (INFRA_ON(pAd) || ADHOC_ON(pAd))
22136 // We need to shorten active scan time in order for WZC connect issue
22137 - if (pAd->Mlme.SyncAux.ScanType == SCAN_ACTIVE)
22138 - RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, ACTIVE_SCAN_TIME);
22139 + if (pAd->Mlme.SyncAux.ScanType == SCAN_ACTIVE)
22140 + RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, ACTIVE_SCAN_TIME);
22141 else if (pAd->PortCfg.PhyMode == PHY_11ABG_MIXED)
22142 - RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, MIN_CHANNEL_TIME);
22143 + RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, MIN_CHANNEL_TIME);
22145 RTMPSetTimer(pAd, &pAd->Mlme.SyncAux.ScanTimer, MAX_CHANNEL_TIME);
22147 MgtMacHeaderInit(pAd, &Hdr, SUBTYPE_PROBE_REQ, 0, &pAd->PortCfg.Broadcast, &pAd->PortCfg.Broadcast);
22148 // There is no need to send broadcast probe request if active scan is in effect.
22149 // The same rulr should apply to passive scan also.
22150 - if (pAd->Mlme.SyncAux.ScanType == SCAN_PASSIVE)
22151 + if (pAd->Mlme.SyncAux.ScanType == SCAN_PASSIVE)
22153 // Send the first probe request with empty SSID
22154 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
22155 @@ -1184,15 +1190,15 @@
22156 MakeOutgoingFrame(OutBuffer, &FrameLen,
22157 sizeof(MACHDR), (UCHAR*)&Hdr,
22162 1, &pAd->PortCfg.SupportedRatesLen,
22163 - pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
22164 + pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
22168 MiniportMMRequest(pAd, OutBuffer, FrameLen);
22170 - else if (pAd->Mlme.SyncAux.ScanType == SCAN_ACTIVE)
22171 + else if (pAd->Mlme.SyncAux.ScanType == SCAN_ACTIVE)
22173 // Allocate another for probe scan with SSID
22174 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer2); //Get an unused nonpaged memory
22175 @@ -1212,9 +1218,9 @@
22176 SsidLen, pAd->PortCfg.Ssid,
22178 1, &pAd->PortCfg.SupportedRatesLen,
22179 - pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
22180 + pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
22184 MiniportMMRequest(pAd, OutBuffer2, FrameLen);
22186 DBGPRINT(RT_DEBUG_INFO, "SYNC - send active ProbeReq @ channel=%d with essid=%s\n", pAd->Mlme.SyncAux.Channel, pAd->PortCfg.Ssid);
22187 @@ -1224,55 +1230,55 @@
22193 ==========================================================================
22195 ==========================================================================
22197 VOID InvalidStateWhenScan(
22198 - IN PRTMP_ADAPTER pAd,
22199 - IN MLME_QUEUE_ELEM *Elem)
22200 + IN PRTMP_ADAPTER pAd,
22201 + IN MLME_QUEUE_ELEM *Elem)
22203 DBGPRINT(RT_DEBUG_TRACE, "AYNC - InvalidStateWhenScan(state=%d). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState);
22204 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
22205 MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_STATE_MACHINE_REJECT);
22210 ==========================================================================
22212 ==========================================================================
22214 VOID InvalidStateWhenJoin(
22215 - IN PRTMP_ADAPTER pAd,
22216 - IN MLME_QUEUE_ELEM *Elem)
22217 + IN PRTMP_ADAPTER pAd,
22218 + IN MLME_QUEUE_ELEM *Elem)
22220 DBGPRINT(RT_DEBUG_TRACE, "InvalidStateWhenJoin(state=%d). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState);
22221 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
22222 MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_STATE_MACHINE_REJECT);
22227 ==========================================================================
22229 ==========================================================================
22231 VOID InvalidStateWhenStart(
22232 - IN PRTMP_ADAPTER pAd,
22233 - IN MLME_QUEUE_ELEM *Elem)
22234 + IN PRTMP_ADAPTER pAd,
22235 + IN MLME_QUEUE_ELEM *Elem)
22237 DBGPRINT(RT_DEBUG_TRACE, "InvalidStateWhenStart(state=%d). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState);
22238 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
22239 MlmeCntlConfirm(pAd, MT2_START_CONF, MLME_STATE_MACHINE_REJECT);
22244 ==========================================================================
22246 ==========================================================================
22248 VOID EnqueuePsPoll(
22249 - IN PRTMP_ADAPTER pAd)
22250 + IN PRTMP_ADAPTER pAd)
22252 NDIS_STATUS NState;
22253 PSPOLL_FRAME *PsFr;
22254 @@ -1291,10 +1297,10 @@
22255 // driver force send out a BEACON frame to cover ADHOC mode BEACON starving issue
22256 // that is, in ADHOC mode, driver guarantee itself can send out at least a BEACON
22257 // per a specified duration, even the peer's clock is faster than us and win all the
22258 -// hardware-based BEACON TX oppertunity.
22259 +// hardware-based BEACON TX oppertunity.
22260 // we may remove this software feature once 2560 IC fix this problem in ASIC.
22261 VOID EnqueueBeaconFrame(
22262 - IN PRTMP_ADAPTER pAd)
22263 + IN PRTMP_ADAPTER pAd)
22265 NDIS_STATUS NState;
22266 PTXD_STRUC pTxD = (PTXD_STRUC)pAd->BeaconRing.va_addr;
22267 @@ -1313,10 +1319,10 @@
22273 ==========================================================================
22275 - Send out a NULL frame to AP. The prpose is to inform AP this client
22276 + Send out a NULL frame to AP. The prpose is to inform AP this client
22279 This routine should only be used in infrastructure mode.
22280 @@ -1324,7 +1330,7 @@
22282 VOID EnqueueNullFrame(
22283 IN PRTMP_ADAPTER pAd,
22287 NDIS_STATUS NState;
22289 @@ -1339,7 +1345,7 @@
22295 ==========================================================================
22297 ==========================================================================
22298 @@ -1359,7 +1365,7 @@
22299 if (NState == NDIS_STATUS_SUCCESS)
22301 MgtMacHeaderInit(pAd, &Hdr, SUBTYPE_PROBE_REQ, 0, &pAd->PortCfg.Broadcast, &pAd->PortCfg.Broadcast);
22304 // this ProbeRequest explicitly specify SSID to reduce unwanted ProbeResponse
22305 MakeOutgoingFrame(OutBuffer, &FrameLen,
22306 sizeof(MACHDR), &Hdr,
22307 @@ -1368,13 +1374,13 @@
22308 pAd->PortCfg.SsidLen, pAd->PortCfg.Ssid,
22310 1, &pAd->PortCfg.SupportedRatesLen,
22311 - pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
22312 + pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
22314 MiniportMMRequest(pAd, OutBuffer, FrameLen);
22320 ==========================================================================
22322 Update PortCfg->ChannelList[] according to 1) Country Region 2) RF IC type,
22323 @@ -1464,7 +1470,7 @@
22326 pAd->PortCfg.ChannelListNum = index;
22327 - DBGPRINT(RT_DEBUG_TRACE,"country code=%d, RFIC=%d, PHY mode=%d, support %d channels\n",
22328 + DBGPRINT(RT_DEBUG_TRACE,"country code=%d, RFIC=%d, PHY mode=%d, support %d channels\n",
22329 pAd->PortCfg.CountryRegion, pAd->PortCfg.RfType, pAd->PortCfg.PhyMode, pAd->PortCfg.ChannelListNum);
22330 for (i=0;i<index;i++)
22332 @@ -1472,10 +1478,10 @@
22338 ==========================================================================
22340 - This routine return the first channel number according to the country
22341 + This routine return the first channel number according to the country
22342 code selection and RF IC selection (signal band or dual band). It is called
22343 whenever driver need to start a site survey of all supported channels.
22345 @@ -1488,7 +1494,7 @@
22346 return pAd->PortCfg.ChannelList[0];
22351 ==========================================================================
22353 This routine returns the next channel number. This routine is called
22354 @@ -1500,12 +1506,12 @@
22355 ==========================================================================
22358 - IN PRTMP_ADAPTER pAd,
22359 + IN PRTMP_ADAPTER pAd,
22363 UCHAR next_channel = 0;
22366 for (i = 0; i < (pAd->PortCfg.ChannelListNum - 1); i++)
22367 if (channel == pAd->PortCfg.ChannelList[i])
22369 diff -Nur rt2500-1.1.0-b4/Module/unload rt2500-cvs-2007061011/Module/unload
22370 --- rt2500-1.1.0-b4/Module/unload 2006-06-17 22:12:58.000000000 +0200
22371 +++ rt2500-cvs-2007061011/Module/unload 1970-01-01 01:00:00.000000000 +0100
22373 -/sbin/ifconfig ra0 down
22374 -/sbin/rmmod rt2500
22375 \ Kein Zeilenumbruch am Dateiende.
22376 diff -Nur rt2500-1.1.0-b4/Module/wpa.c rt2500-cvs-2007061011/Module/wpa.c
22377 --- rt2500-1.1.0-b4/Module/wpa.c 2006-06-17 22:12:58.000000000 +0200
22378 +++ rt2500-cvs-2007061011/Module/wpa.c 2007-05-15 21:41:35.000000000 +0200
22380 -/***************************************************************************
22381 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
22383 - * This program is free software; you can redistribute it and/or modify *
22384 - * it under the terms of the GNU General Public License as published by *
22385 - * the Free Software Foundation; either version 2 of the License, or *
22386 - * (at your option) any later version. *
22388 - * This program is distributed in the hope that it will be useful, *
22389 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22390 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22391 - * GNU General Public License for more details. *
22393 - * You should have received a copy of the GNU General Public License *
22394 - * along with this program; if not, write to the *
22395 - * Free Software Foundation, Inc., *
22396 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22398 - * Licensed under the GNU GPL *
22399 - * Original code supplied under license from RaLink Inc, 2004. *
22400 - ***************************************************************************/
22402 - /***************************************************************************
22403 - * Module Name: wpa.c
22407 - * Revision History:
22409 - * -------- ----------- -----------------------------
22410 - * JanL 22nd Jul 03 Initial code
22411 +/***************************************************************************
22412 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
22414 + * This program is free software; you can redistribute it and/or modify *
22415 + * it under the terms of the GNU General Public License as published by *
22416 + * the Free Software Foundation; either version 2 of the License, or *
22417 + * (at your option) any later version. *
22419 + * This program is distributed in the hope that it will be useful, *
22420 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22421 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22422 + * GNU General Public License for more details. *
22424 + * You should have received a copy of the GNU General Public License *
22425 + * along with this program; if not, write to the *
22426 + * Free Software Foundation, Inc., *
22427 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22429 + * Licensed under the GNU GPL *
22430 + * Original code supplied under license from RaLink Inc, 2004. *
22431 + ***************************************************************************/
22433 + /***************************************************************************
22434 + * Module Name: wpa.c
22438 + * Revision History:
22440 + * -------- ----------- -----------------------------
22441 + * JanL 22nd Jul 03 Initial code
22442 * PaulL 28th Nov 03 Modify for supplicant
22443 * MarkW 8th Dec 04 Baseline code
22444 - ***************************************************************************/
22445 + ***************************************************************************/
22447 #include "rt_config.h"
22451 UCHAR CipherWpaPskTkipLen = (sizeof(CipherWpaPskTkip) / sizeof(UCHAR));
22453 +// Needed for APs using WPA1 IEs (#221) to indicate CCMP encryption
22454 UCHAR CipherWpaPskAes[] = {
22455 0xDD, 0x16, // RSN IE
22456 0x00, 0x50, 0xf2, 0x01, // oui
22457 @@ -59,16 +60,19 @@
22459 UCHAR CipherWpaPskAesLen = (sizeof(CipherWpaPskAes) / sizeof(UCHAR));
22461 +static UCHAR MSOUI[] = {0x00, 0x50, 0xf2, 0x01}; // Microsoft OUI
22462 +static UCHAR WGOUI[] = {0x00, 0x0f, 0xac}; // 802.11i Working Group OUI
22465 ========================================================================
22468 Routine Description:
22469 Classify WPA EAP message type
22472 EAPType Value of EAP message type
22473 MsgType Internal Message definition for MLME state machine
22477 TRUE Found appropriate message type
22478 FALSE No appropriate message type
22479 @@ -76,12 +80,12 @@
22481 All these constants are defined in wpa.h
22482 For supplicant, there is only EAPOL Key message avaliable
22485 ========================================================================
22487 BOOLEAN WpaMsgTypeSubst(
22489 - OUT ULONG *MsgType)
22490 + OUT ULONG *MsgType)
22494 @@ -102,23 +106,23 @@
22497 DBGPRINT(RT_DEBUG_INFO, "WpaMsgTypeSubst : return FALSE; \n");
22507 ==========================================================================
22510 association state machine init, including state transition and timer init
22513 S - pointer to the association state machine
22514 ==========================================================================
22516 VOID WpaPskStateMachineInit(
22517 - IN PRTMP_ADAPTER pAd,
22518 - IN STATE_MACHINE *S,
22519 - OUT STATE_MACHINE_FUNC Trans[])
22520 + IN PRTMP_ADAPTER pAd,
22521 + IN STATE_MACHINE *S,
22522 + OUT STATE_MACHINE_FUNC Trans[])
22524 StateMachineInit(S, (STATE_MACHINE_FUNC*)Trans, MAX_WPA_PSK_STATE, MAX_WPA_PSK_MSG, (STATE_MACHINE_FUNC)Drop, WPA_PSK_IDLE, WPA_MACHINE_BASE);
22525 StateMachineSetAction(S, WPA_PSK_IDLE, EAP_MSG_TYPE_EAPOLKey, (STATE_MACHINE_FUNC)WpaEAPOLKeyAction);
22526 @@ -127,10 +131,10 @@
22528 ==========================================================================
22530 - This is state machine function.
22531 - When receiving EAPOL packets which is for 802.1x key management.
22532 - Use both in WPA, and WPAPSK case.
22533 - In this function, further dispatch to different functions according to the received packet. 3 categories are :
22534 + This is state machine function.
22535 + When receiving EAPOL packets which is for 802.1x key management.
22536 + Use both in WPA, and WPAPSK case.
22537 + In this function, further dispatch to different functions according to the received packet. 3 categories are :
22538 1. normal 4-way pairwisekey and 2-way groupkey handshake
22539 2. MIC error (Countermeasures attack) report packet from STA.
22540 3. Request for pairwise/group key update from STA
22541 @@ -138,13 +142,13 @@
22542 ==========================================================================
22544 VOID WpaEAPOLKeyAction(
22545 - IN PRTMP_ADAPTER pAdapter,
22546 - IN MLME_QUEUE_ELEM *Elem)
22547 + IN PRTMP_ADAPTER pAdapter,
22548 + IN MLME_QUEUE_ELEM *Elem)
22551 UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
22552 PKEY_DESCRIPTER pKeyDesc;
22555 DBGPRINT(RT_DEBUG_TRACE, "-----> WpaEAPOLKeyAction\n");
22556 // Get 802.11 header first
22557 pKeyDesc = (PKEY_DESCRIPTER) &Elem->Msg[(LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H)];
22558 @@ -153,9 +157,12 @@
22559 *(USHORT *)((UCHAR *)pKeyDesc+1) = SWAP16(*(USHORT *)((UCHAR *)pKeyDesc+1));
22561 // Sanity check, this should only happen in WPA-PSK mode
22562 - if (pAdapter->PortCfg.AuthMode != Ndis802_11AuthModeWPAPSK)
22563 + if (pAdapter->PortCfg.AuthMode != Ndis802_11AuthModeWPAPSK) {
22564 + DBGPRINT(RT_DEBUG_TRACE,
22565 + "<----- WpaEAPOLKeyAction - AuthMode (%d) != WPPSK\n",
22566 + pAdapter->PortCfg.AuthMode);
22570 // 0. Debug print all bit information
22571 DBGPRINT(RT_DEBUG_INFO, "KeyInfo Key Description Version %d\n", pKeyDesc->KeyInfo.KeyDescVer);
22572 DBGPRINT(RT_DEBUG_INFO, "KeyInfo Key Type %d\n", pKeyDesc->KeyInfo.KeyType);
22573 @@ -167,7 +174,7 @@
22574 DBGPRINT(RT_DEBUG_INFO, "KeyInfo Error %d\n", pKeyDesc->KeyInfo.Error);
22575 DBGPRINT(RT_DEBUG_INFO, "KeyInfo Request %d\n", pKeyDesc->KeyInfo.Request);
22576 DBGPRINT(RT_DEBUG_INFO, "KeyInfo DL %d\n", pKeyDesc->KeyInfo.DL);
22579 // 1. Check EAPOL frame version and type
22580 if ((Elem->Msg[LENGTH_802_11+LENGTH_802_1_H] != EAPOL_VER) || (pKeyDesc->Type != RSN_KEY_DESC))
22582 @@ -190,9 +197,18 @@
22583 // First validate replay counter, only accept message with larger replay counter
22584 // Let equal pass, some AP start with all zero replay counter
22585 memset(ZeroReplay, 0, LEN_KEY_DESC_REPLAY);
22586 - if ((RTMPCompareMemory(pKeyDesc->ReplayCounter, pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
22587 - (RTMPCompareMemory(pKeyDesc->ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
22588 + if ((RTMPCompareMemory(pKeyDesc->ReplayCounter,
22589 + pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
22590 + (RTMPCompareMemory(pKeyDesc->ReplayCounter,
22591 + ZeroReplay, LEN_KEY_DESC_REPLAY) != 0)) {
22592 + DBGPRINT(RT_DEBUG_TRACE, "<----- %s: Replay count error\n",
22594 + DBGHEXSTR(RT_DEBUG_TRACE, " AP replay = ",
22595 + pKeyDesc->ReplayCounter, LEN_KEY_DESC_REPLAY);
22596 + DBGHEXSTR(RT_DEBUG_TRACE, " our replay = ",
22597 + pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
22601 // Classify message Type, either pairwise message 1, 3, or group message 1 for supplicant
22602 MsgType = EAPOL_MSG_INVALID;
22603 @@ -228,12 +244,13 @@
22605 MsgType = EAPOL_GROUP_MSG_1;
22606 DBGPRINT(RT_DEBUG_TRACE, "Receive EAPOL Key Group Message 1\n");
22610 + DBGPRINT(RT_DEBUG_TRACE, "Receive INVALID EAPOL Key Message\n");
22613 *(USHORT *)((UCHAR *)pKeyDesc+1) = SWAP16(*(USHORT *)((UCHAR *)pKeyDesc+1));
22617 // We will assume link is up (assoc suceess and port not secured).
22618 // All state has to be able to process message from previous state
22619 switch (pAdapter->PortCfg.WpaState)
22620 @@ -245,7 +262,7 @@
22621 pAdapter->PortCfg.WpaState = SS_WAIT_MSG_3;
22626 case SS_WAIT_MSG_3:
22627 if (MsgType == EAPOL_PAIR_MSG_1)
22629 @@ -258,7 +275,7 @@
22630 pAdapter->PortCfg.WpaState = SS_WAIT_GROUP;
22635 case SS_WAIT_GROUP: // When doing group key exchange
22636 case SS_FINISH: // This happened when update group key
22637 if (MsgType == EAPOL_PAIR_MSG_1)
22638 @@ -281,34 +298,34 @@
22639 pAdapter->PortCfg.WpaState = SS_FINISH;
22650 DBGPRINT(RT_DEBUG_TRACE, "<----- WpaEAPOLKeyAction\n");
22654 ========================================================================
22657 Routine Description:
22658 Process Pairwise key 4-way handshaking
22661 pAdapter Pointer to our adapter
22672 ========================================================================
22674 VOID WpaPairMsg1Action(
22675 - IN PRTMP_ADAPTER pAdapter,
22676 - IN MLME_QUEUE_ELEM *Elem)
22677 + IN PRTMP_ADAPTER pAdapter,
22678 + IN MLME_QUEUE_ELEM *Elem)
22680 PHEADER_802_11 pHeader;
22682 @@ -321,39 +338,39 @@
22683 UCHAR EAPHEAD[8] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,0x88,0x8e};
22684 PEAPOL_PACKET pMsg1;
22685 EAPOL_PACKET Packet;
22690 DBGPRINT(RT_DEBUG_TRACE, "WpaPairMsg1Action ----->\n");
22693 pHeader = (PHEADER_802_11) Elem->Msg;
22696 // Save Data Length to pDesc for receiving packet, then put in outgoing frame Data Len fields.
22697 pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
22700 // Process message 1 from authenticator
22701 // Key must be Pairwise key, already verified at callee.
22702 // 1. Save Replay counter, it will use to verify message 3 and construct message 2
22703 - memcpy(pAdapter->PortCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
22704 + memcpy(pAdapter->PortCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
22707 memcpy(pAdapter->PortCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
22710 // TSNonce <--- SNonce
22711 // Generate random SNonce
22712 - GenRandom(pAdapter, pAdapter->PortCfg.SNonce);
22713 + GenRandom(pAdapter, pAdapter->PortCfg.SNonce);
22715 // TPTK <--- Calc PTK(ANonce, TSNonce)
22716 - WpaCountPTK(pAdapter->PortCfg.PskKey.Key,
22717 + WpaCountPTK(pAdapter->PortCfg.PskKey.Key,
22718 pAdapter->PortCfg.ANonce,
22719 - pAdapter->PortCfg.Bssid.Octet,
22720 - pAdapter->PortCfg.SNonce,
22721 - pAdapter->CurrentAddress,
22724 + pAdapter->PortCfg.Bssid.Octet,
22725 + pAdapter->PortCfg.SNonce,
22726 + pAdapter->CurrentAddress,
22730 // Save key to PTK entry
22731 memcpy(pAdapter->PortCfg.PTK, PTK, LEN_PTK);
22734 // =====================================
22735 // Use Priority Ring & MiniportMMRequest
22736 // =====================================
22737 @@ -364,7 +381,7 @@
22738 AckRate = pAdapter->PortCfg.ExpectedACKRate[pAdapter->PortCfg.TxRate];
22739 AckDuration = RTMPCalcDuration(pAdapter, AckRate, 14);
22740 Header_802_11.Controlhead.Duration = pAdapter->PortCfg.Dsifs + AckDuration;
22743 // Zero message 2 body
22744 memset(&Packet, 0, sizeof(Packet));
22745 Packet.Version = EAPOL_VER;
22746 @@ -399,17 +416,17 @@
22747 memcpy(Packet.KeyDesc.KeyNonce, pAdapter->PortCfg.SNonce, LEN_KEY_DESC_NONCE);
22749 // 5. Key Replay Count
22750 - memcpy(Packet.KeyDesc.ReplayCounter, pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
22752 + memcpy(Packet.KeyDesc.ReplayCounter, pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
22755 *(USHORT *)(&(Packet.KeyDesc.KeyInfo)) = SWAP16(*(USHORT *)(&(Packet.KeyDesc.KeyInfo)));
22759 // Send EAPOL(0, 1, 0, 0, 0, K, 0, TSNonce, 0, MIC(TPTK), 0)
22760 - // Out buffer for transmitting message 2
22761 + // Out buffer for transmitting message 2
22762 NStatus = MlmeAllocateMemory(pAdapter, (PVOID)&OutBuffer); //Get an unused nonpaged memory
22763 - if (NStatus != NDIS_STATUS_SUCCESS)
22765 + if (NStatus != NDIS_STATUS_SUCCESS)
22768 // Prepare EAPOL frame for MIC calculation
22769 // Be careful, only EAPOL frame is counted for MIC calculation
22770 @@ -423,7 +440,7 @@
22776 HMAC_SHA1(OutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
22777 memcpy(Mic, digest, LEN_KEY_DESC_MIC);
22779 @@ -433,12 +450,12 @@
22780 DBGPRINT(RT_DEBUG_INFO, " PMK = ");
22781 for (i = 0; i < 16; i++)
22782 DBGPRINT(RT_DEBUG_INFO, "%2x-", pAdapter->PortCfg.PskKey.Key[i]);
22785 DBGPRINT(RT_DEBUG_INFO, "\n PTK = ");
22786 for (i = 0; i < 64; i++)
22787 DBGPRINT(RT_DEBUG_INFO, "%2x-", pAdapter->PortCfg.PTK[i]);
22788 DBGPRINT(RT_DEBUG_INFO, "\n FrameLen = %d\n", FrameLen);
22791 hmac_md5(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, Mic);
22793 memcpy(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
22794 @@ -446,36 +463,202 @@
22796 // Make Transmitting frame
22797 MakeOutgoingFrame(OutBuffer, &FrameLen, sizeof(MACHDR), &Header_802_11,
22798 - sizeof(EAPHEAD), EAPHEAD,
22799 + sizeof(EAPHEAD), EAPHEAD,
22800 Packet.Len[1] + 4, &Packet,
22803 // Send using priority queue
22804 MiniportMMRequest(pAdapter, OutBuffer, FrameLen);
22807 DBGPRINT(RT_DEBUG_TRACE, "WpaPairMsg1Action <-----\n");
22811 + ========================================================================
22814 + Check the information element packaged in the KeyData field of the
22815 + EAPOL packet. At least one of the AP's offerings in each of
22817 + 1) the group cipher suite
22818 + 2) the pairwise master key cipher(s), and
22819 + 3) the authentication and key management suite
22821 + need to match the configuration for the corresponding attribute
22825 + pAd Pointer to our adapter
22826 + pie Pointer to the "logical" IE
22827 + pie_len Value of the real IE length field.
22828 + poui Pointer to the WPA1/WPA2 OUI
22831 + 0 -> OK: At least one of the offerings in each category
22832 + matches what is configured in the driver.
22835 + On entry, it is known that the length of the RSN IE is consistent
22836 + with the length specification of the EAPOL KeyData field, and that
22837 + the IE is at least long enough to contain one group cipher suite
22838 + selection, one PMK cipher suite selection,
22839 + and one AKM suite selection.
22840 + ========================================================================
22842 +static int checkEAPIE(
22843 + IN RTMP_ADAPTER *pAd,
22844 + IN rsn_ie_t *pie, // (not really, if we're WPA 1)
22845 + IN u8 pie_len, // ... so we provide the length separately.
22846 + IN ie_oui_t *poui)
22848 + suite_list_t *suite_list_p;
22849 + suite_sel_t *suite_sel_p;
22852 + suite_sel_t *limit = (suite_sel_t *)((void *)pie + pie_len + 2);
22854 + if (wtohs(pie->version) != 1) {
22855 + DBGPRINT(RT_DEBUG_ERROR, "Invalid ver %d (sb 1)\n",
22856 + wtohs(pie->version));
22859 + if (memcmp(pie->gcsuite.oui, poui, sizeof(ie_oui_t)) != 0) {
22860 + DBGPRINT(RT_DEBUG_ERROR, "Invalid Grp Cipher OUI %02x:%02x:%02x\n",
22861 + pie->gcsuite.oui[0], pie->gcsuite.oui[1], pie->gcsuite.oui[2]);
22864 + switch (pie->gcsuite.type) {
22865 + case CIPHER_TYPE_WEP40:
22866 + case CIPHER_TYPE_WEP104:
22867 + if (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled)
22870 + case CIPHER_TYPE_TKIP:
22871 + if (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled)
22874 + case CIPHER_TYPE_CCMP:
22875 + if (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled)
22879 + DBGPRINT(RT_DEBUG_ERROR, "Invalid Grp Cipher Type %d\n",
22880 + pie->gcsuite.type);
22882 + } /* End switch (group cipher suite type) */
22884 + suite_list_p = (suite_list_t *)((void *)&pie->gcsuite+sizeof(suite_sel_t));
22886 + // Search the PMK list
22887 + for (suite_sel_p = suite_list_p->suite,
22888 + i = 0, j = wtohs(suite_list_p->count);
22889 + suite_sel_p + 1 <= limit && i < j;
22890 + suite_sel_p++, i++) {
22891 + if (memcmp(suite_sel_p->oui, poui, sizeof(ie_oui_t)) != 0) {
22892 + DBGPRINT(RT_DEBUG_ERROR, "Invalid PMK Cipher OUI "
22893 + "%02x:%02x:%02x\n",
22894 + suite_sel_p->oui[0], suite_sel_p->oui[1],
22895 + suite_sel_p->oui[2]);
22896 + break; // Keep going. We may also have a valid one.
22898 + switch (suite_sel_p->type) {
22899 + case CIPHER_TYPE_WEP40:
22900 + case CIPHER_TYPE_WEP104:
22901 + if (pAd->PortCfg.WepStatus == Ndis802_11Encryption1Enabled)
22904 + case CIPHER_TYPE_TKIP:
22905 + if (pAd->PortCfg.WepStatus == Ndis802_11Encryption2Enabled)
22908 + case CIPHER_TYPE_CCMP:
22909 + if (pAd->PortCfg.WepStatus == Ndis802_11Encryption3Enabled)
22913 + DBGPRINT(RT_DEBUG_ERROR, "Invalid PMK Cipher Type %d\n",
22914 + suite_sel_p->type);
22915 + break; // Keep going. We may also have a valid one.
22916 + } /* End switch (PMK type) */
22917 + } /* End search PMK list */
22919 + if (suite_sel_p >= limit && i < j) {
22920 + DBGPRINT(RT_DEBUG_ERROR, "Too many PMK suites in EAPOL pkt "
22921 + "(have %d, room for %d) (need=%d)\n",
22926 + DBGPRINT(RT_DEBUG_ERROR, "Zero count PMK list in EAPOL pkt "
22927 + "(need=%d)\n", needs);
22931 + suite_list_p = (suite_list_t *)suite_sel_p;
22933 + //Search the Authentication and Key Management (AKM) list
22934 + for (suite_sel_p = suite_list_p->suite,
22935 + i = 0, j = wtohs(suite_list_p->count);
22936 + suite_sel_p + 1 <= limit && i < j;
22937 + suite_sel_p++, i++) {
22938 + if (memcmp(suite_sel_p->oui, poui, sizeof(ie_oui_t)) != 0) {
22939 + DBGPRINT(RT_DEBUG_ERROR, "Invalid AKM OUI %02x:%02x:%02x\n",
22940 + suite_sel_p->oui[0], suite_sel_p->oui[1],
22941 + suite_sel_p->oui[2]);
22942 + break; // Keep going. We may also have a valid one.
22944 + switch (suite_sel_p->type) {
22945 + case AKM_TYPE_802_1X:
22946 + if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA)
22949 + case AKM_TYPE_PSK:
22950 + if (pAd->PortCfg.AuthMode >= Ndis802_11AuthModeWPAPSK)
22954 + DBGPRINT(RT_DEBUG_ERROR, "Invalid PMK Cipher Type %d\n",
22955 + suite_sel_p->type);
22956 + break; // Keep going. We may also have a valid one.
22957 + } /* End switch (AKM type) */
22958 + } /* End search AKM list */
22960 + if (suite_sel_p >= limit && i < j) {
22961 + DBGPRINT(RT_DEBUG_ERROR, "Too many AKM suites in EAPOL pkt "
22962 + "(have %d, room for %d) (need=%d)\n",
22964 + return needs; // NB. May still have met all needs.
22967 + DBGPRINT(RT_DEBUG_ERROR, "Zero count AKM list in EAPOL pkt "
22968 + "(need=%d)\n", needs);
22974 +} /* End checkEAPIE () */
22977 ========================================================================
22980 Routine Description:
22981 Process Pairwise key 4-way handshaking
22984 pAdapter Pointer to our adapter
22995 ========================================================================
22997 VOID WpaPairMsg3Action(
22998 - IN PRTMP_ADAPTER pAdapter,
22999 - IN MLME_QUEUE_ELEM *Elem)
23000 + IN PRTMP_ADAPTER pAdapter,
23001 + IN MLME_QUEUE_ELEM *Elem)
23003 PHEADER_802_11 pHeader;
23004 UCHAR *OutBuffer = NULL;
23005 @@ -487,46 +670,74 @@
23006 UCHAR EAPHEAD[8] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,0x88,0x8e};
23007 EAPOL_PACKET Packet;
23008 PEAPOL_PACKET pMsg3;
23010 - UCHAR Mic[16], OldMic[16];
23011 + UCHAR Mic[16], OldMic[16];
23012 NDIS_802_11_KEY PeerKey;
23017 DBGPRINT(RT_DEBUG_TRACE, "WpaPairMsg3Action ----->\n");
23020 pHeader = (PHEADER_802_11) Elem->Msg;
23023 // Process message 3 frame.
23024 pMsg3 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
23027 *(USHORT *)(&(pMsg3->KeyDesc.KeyInfo)) = SWAP16(*(USHORT *)(&(pMsg3->KeyDesc.KeyInfo)));
23029 + #define pie ((rsn_ie_t *)(void *)pMsg3->KeyDesc.KeyData)
23030 + if (wtohs(pie->length) + 2 != pMsg3->KeyDesc.KeyDataLen[1]) {
23031 + DBGPRINT(RT_DEBUG_ERROR, "RSN IE len %d != KeyDataLen %d)\n",
23032 + pie->length + 2, pMsg3->KeyDesc.KeyDataLen[1]);
23036 + switch (pie->eid) {
23038 + if (wtohs(pie->length) < MIN_RSN_KEYDATA_LEN) {
23039 + DBGPRINT(RT_DEBUG_ERROR,
23040 + "RSN IE msg 3 too short (sb >= %d, is %d)\n",
23041 + MIN_RSN_KEYDATA_LEN, wtohs(pie->length));
23042 + DBGHEXSTR(RT_DEBUG_ERROR, "KeyData ",
23043 + pMsg3->KeyDesc.KeyData,
23044 + pMsg3->KeyDesc.KeyDataLen[1]);
23047 + if (checkEAPIE(pAdapter, pie, pie->length,
23048 + (ie_oui_t *)WGOUI) != 0) return;
23052 + #define pie ((RSN_EID_STRUCT *)(void *)pMsg3->KeyDesc.KeyData)
23053 + if (wtohs(pie->Length) < MIN_WPA_KEYDATA_LEN) {
23054 + DBGPRINT(RT_DEBUG_ERROR,
23055 + "WPA IE msg 3 too short (sb >= %d, is %d)\n",
23056 + MIN_WPA_KEYDATA_LEN, wtohs(pie->Length));
23057 + DBGHEXSTR(RT_DEBUG_ERROR, "KeyData ",
23058 + pMsg3->KeyDesc.KeyData,
23059 + pMsg3->KeyDesc.KeyDataLen[1]);
23062 + if (memcmp(pie->Oui, MSOUI, sizeof(pie->Oui)) != 0) {
23063 + DBGPRINT(RT_DEBUG_ERROR,
23064 + "Invalid WPA 1 OUI %02x:%02x:%02x:%02x\n",
23065 + pie->Oui[0], pie->Oui[1], pie->Oui[2], pie->Oui[3]);
23068 + if (checkEAPIE(pAdapter, (rsn_ie_t *)&pie->Oui[2], pie->Length,
23069 + (ie_oui_t *)MSOUI) != 0) return;
23072 + DBGPRINT(RT_DEBUG_ERROR, "RSN IE type %d invalid)\n",
23075 + } /* End switch (element ID) */
23076 + } /* End if (packet length sane) */
23079 + DBGPRINT(RT_DEBUG_TRACE, "RSN IE matched msg 3 of 4-way handshake "
23080 + "KeyDataLen=%d)\n",
23081 + pMsg3->KeyDesc.KeyDataLen[1]);
23083 - // 1. Verify RSN IE & cipher type match
23084 - if (pAdapter->PortCfg.WepStatus == Ndis802_11Encryption3Enabled)
23086 - if (pMsg3->KeyDesc.KeyInfo.KeyDescVer != 2)
23088 - pTmp = (PUCHAR) &CipherWpaPskAes;
23092 - if (pMsg3->KeyDesc.KeyInfo.KeyDescVer != 1)
23094 - pTmp = (PUCHAR) &CipherWpaPskTkip;
23097 - // Fix compatibility issue, when AP append nonsense data after auth mode with different size.
23098 - // We should qualify this kind of RSN as acceptable
23099 - if (!NdisEqualMemory((PUCHAR) &pMsg3->KeyDesc.KeyData[2], pTmp + 2, CipherWpaPskTkipLen - 2))
23101 - DBGPRINT(RT_DEBUG_ERROR, " RSN IE mismatched msg 3 of 4-way handshake!!!!!!!!!! \n");
23105 - DBGPRINT(RT_DEBUG_TRACE, " RSN IE matched in msg 3 of 4-way handshake!!!!!!!!!! \n");
23108 *(USHORT *)(&(pMsg3->KeyDesc.KeyInfo)) = SWAP16(*(USHORT *)(&(pMsg3->KeyDesc.KeyInfo)));
23110 @@ -539,7 +750,7 @@
23116 HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Len[1] + 4, pAdapter->PortCfg.PTK, LEN_EAP_MICK, digest);
23117 memcpy(Mic, digest, LEN_KEY_DESC_MIC);
23119 @@ -547,7 +758,7 @@
23121 hmac_md5(pAdapter->PortCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Len[1] + 4, Mic);
23125 if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
23127 DBGPRINT(RT_DEBUG_ERROR, " MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n");
23128 @@ -556,17 +767,32 @@
23130 DBGPRINT(RT_DEBUG_TRACE, " MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n");
23132 - // 3. Check Replay Counter, it has to be larger than last one. No need to be exact one larger
23133 - if (RTMPCompareMemory(pMsg3->KeyDesc.ReplayCounter, pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
23134 + // 3. Check Replay Counter, it has to be larger than last one.
23135 + // No need to be exact one larger
23136 + if (RTMPCompareMemory(pMsg3->KeyDesc.ReplayCounter,
23137 + pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) {
23138 + DBGPRINT(RT_DEBUG_TRACE, " Replay count error\n");
23139 + DBGHEXSTR(RT_DEBUG_TRACE, " AP replay = ",
23140 + pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23141 + DBGHEXSTR(RT_DEBUG_TRACE, " our replay = ",
23142 + pAdapter->PortCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
23146 // Update new replay counter
23147 - memcpy(pAdapter->PortCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23148 + memcpy(pAdapter->PortCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter,
23149 + LEN_KEY_DESC_REPLAY);
23151 // 4. Double check ANonce
23152 - if (!NdisEqualMemory(pAdapter->PortCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
23153 + if (!NdisEqualMemory(pAdapter->PortCfg.ANonce, pMsg3->KeyDesc.KeyNonce,
23154 + LEN_KEY_DESC_NONCE)) {
23155 + DBGPRINT(RT_DEBUG_TRACE, " Nonce error\n");
23156 + DBGHEXSTR(RT_DEBUG_TRACE, " AP Nonce = ",
23157 + pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
23158 + DBGHEXSTR(RT_DEBUG_TRACE, " our Nonce = ",
23159 + pAdapter->PortCfg.ANonce, LEN_KEY_DESC_NONCE);
23164 // 5. Construct Message 4
23165 // =====================================
23166 // Use Priority Ring & MiniportMMRequest
23167 @@ -578,22 +804,22 @@
23168 AckRate = pAdapter->PortCfg.ExpectedACKRate[pAdapter->PortCfg.TxRate];
23169 AckDuration = RTMPCalcDuration(pAdapter, AckRate, 14);
23170 Header_802_11.Controlhead.Duration = pAdapter->PortCfg.Dsifs + AckDuration;
23173 // Zero message 4 body
23174 memset(&Packet, 0, sizeof(Packet));
23175 Packet.Version = EAPOL_VER;
23176 Packet.Type = EAPOLKey;
23177 Packet.Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
23181 // Message 4 as EAPOL-Key(0,1,0,0,0,P,0,0,MIC,0)
23183 Packet.KeyDesc.Type = RSN_KEY_DESC;
23187 *(USHORT *)(&(pMsg3->KeyDesc.KeyInfo)) = SWAP16(*(USHORT *)(&(pMsg3->KeyDesc.KeyInfo)));
23191 // Key descriptor version and appropriate RSN IE
23192 Packet.KeyDesc.KeyInfo.KeyDescVer = pMsg3->KeyDesc.KeyInfo.KeyDescVer;
23194 @@ -603,16 +829,16 @@
23195 // KeyMic field presented
23196 Packet.KeyDesc.KeyInfo.KeyMic = 1;
23198 - // Key Replay count
23199 - memcpy(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23200 + // Key Replay count
23201 + memcpy(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23203 *(USHORT *)&Packet.KeyDesc.KeyInfo = SWAP16(*(USHORT *)&Packet.KeyDesc.KeyInfo);
23206 - // Out buffer for transmitting message 4
23207 + // Out buffer for transmitting message 4
23208 NStatus = MlmeAllocateMemory(pAdapter, (PVOID)&OutBuffer); //Get an unused nonpaged memory
23209 if (NStatus != NDIS_STATUS_SUCCESS)
23213 // Prepare EAPOL frame for MIC calculation
23214 // Be careful, only EAPOL frame is counted for MIC calculation
23215 @@ -626,7 +852,7 @@
23221 HMAC_SHA1(OutBuffer, FrameLen, pAdapter->PortCfg.PTK, LEN_EAP_MICK, digest);
23222 memcpy(Mic, digest, LEN_KEY_DESC_MIC);
23224 @@ -637,10 +863,10 @@
23225 memcpy(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
23230 // Make Transmitting frame
23231 MakeOutgoingFrame(OutBuffer, &FrameLen, sizeof(MACHDR), &Header_802_11,
23232 - sizeof(EAPHEAD), EAPHEAD,
23233 + sizeof(EAPHEAD), EAPHEAD,
23234 Packet.Len[1] + 4, &Packet,
23237 @@ -651,38 +877,38 @@
23239 memset(&PeerKey, 0, sizeof(PeerKey));
23240 PeerKey.Length = sizeof(PeerKey);
23241 - PeerKey.KeyIndex = 0xe0000000;
23242 + PeerKey.KeyIndex = 0xe0000000;
23243 PeerKey.KeyLength = 16;
23244 memcpy(PeerKey.BSSID, pAdapter->PortCfg.Bssid.Octet, 6);
23245 memcpy(&PeerKey.KeyRSC, pMsg3->KeyDesc.KeyRsc, LEN_KEY_DESC_RSC);
23246 memcpy(PeerKey.KeyMaterial, &pAdapter->PortCfg.PTK[32], 32);
23247 // Call Add peer key function
23248 RTMPWPAAddKeyProc(pAdapter, &PeerKey);
23251 DBGPRINT(RT_DEBUG_TRACE, "WpaPairMsg3Action <-----\n");
23256 ========================================================================
23259 Routine Description:
23260 Process Group key 2-way handshaking
23263 pAdapter Pointer to our adapter
23274 ========================================================================
23276 VOID WpaGroupMsg1Action(
23277 - IN PRTMP_ADAPTER pAdapter,
23278 - IN MLME_QUEUE_ELEM *Elem)
23279 + IN PRTMP_ADAPTER pAdapter,
23280 + IN MLME_QUEUE_ELEM *Elem)
23282 PHEADER_802_11 pHeader;
23283 UCHAR *OutBuffer = NULL;
23284 @@ -697,12 +923,12 @@
23285 UCHAR Mic[16], OldMic[16];
23286 UCHAR GTK[32], Key[32];
23287 NDIS_802_11_KEY GroupKey;
23292 DBGPRINT(RT_DEBUG_TRACE, "WpaGroupMsg1Action ----->\n");
23295 pHeader = (PHEADER_802_11) Elem->Msg;
23298 // Process Group message 1 frame.
23299 pGroup = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
23301 @@ -712,7 +938,7 @@
23304 // Update new replay counter
23305 - memcpy(pAdapter->PortCfg.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23306 + memcpy(pAdapter->PortCfg.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23308 // 2. Verify MIC is valid
23309 // Save the MIC and replace with zero
23310 @@ -722,7 +948,7 @@
23316 HMAC_SHA1((PUCHAR) pGroup, pGroup->Len[1] + 4, pAdapter->PortCfg.PTK, LEN_EAP_MICK, digest);
23317 memcpy(Mic, digest, LEN_KEY_DESC_MIC);
23319 @@ -730,7 +956,7 @@
23321 hmac_md5(pAdapter->PortCfg.PTK, LEN_EAP_MICK, (PUCHAR) pGroup, pGroup->Len[1] + 4, Mic);
23325 if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
23327 DBGPRINT(RT_DEBUG_ERROR, " MIC Different in group msg 1 of 2-way handshake!!!!!!!!!! \n");
23328 @@ -749,12 +975,12 @@
23329 if (pGroup->KeyDesc.KeyInfo.KeyDescVer != 2)
23332 - AES_GTK_KEY_UNWRAP(&pAdapter->PortCfg.PTK[16], GTK, pGroup->KeyDesc.KeyData);
23333 + AES_GTK_KEY_UNWRAP(&pAdapter->PortCfg.PTK[16], GTK, pGroup->KeyDesc.KeyData);
23340 if (pGroup->KeyDesc.KeyInfo.KeyDescVer != 1)
23342 // Decrypt TKIP GTK
23343 @@ -766,9 +992,9 @@
23344 for (i = 0; i < 256; i++)
23345 ARCFOUR_BYTE(&pAdapter->PrivateInfo.WEPCONTEXT);
23346 // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
23347 - ARCFOUR_DECRYPT(&pAdapter->PrivateInfo.WEPCONTEXT, GTK, pGroup->KeyDesc.KeyData, 32);
23348 + ARCFOUR_DECRYPT(&pAdapter->PrivateInfo.WEPCONTEXT, GTK, pGroup->KeyDesc.KeyData, 32);
23352 // 4. Construct Group Message 2
23353 pAdapter->Sequence = ((pAdapter->Sequence) + 1) & (MAX_SEQ_NUMBER);
23354 WpaMacHeaderInit(pAdapter, &Header_802_11, 1, &pAdapter->PortCfg.Bssid);
23355 @@ -777,18 +1003,18 @@
23356 AckRate = pAdapter->PortCfg.ExpectedACKRate[pAdapter->PortCfg.TxRate];
23357 AckDuration = RTMPCalcDuration(pAdapter, AckRate, 14);
23358 Header_802_11.Controlhead.Duration = pAdapter->PortCfg.Dsifs + AckDuration;
23361 // Zero Group message 1 body
23362 memset(&Packet, 0, sizeof(Packet));
23363 Packet.Version = EAPOL_VER;
23364 Packet.Type = EAPOLKey;
23365 Packet.Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
23369 // Group Message 2 as EAPOL-Key(1,0,0,0,G,0,0,MIC,0)
23371 Packet.KeyDesc.Type = RSN_KEY_DESC;
23374 // Key descriptor version and appropriate RSN IE
23375 Packet.KeyDesc.KeyInfo.KeyDescVer = pGroup->KeyDesc.KeyInfo.KeyDescVer;
23377 @@ -800,18 +1026,18 @@
23380 Packet.KeyDesc.KeyInfo.Secure = 1;
23382 - // Key Replay count
23383 - memcpy(Packet.KeyDesc.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23385 + // Key Replay count
23386 + memcpy(Packet.KeyDesc.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
23389 *(USHORT *)(&(Packet.KeyDesc.KeyInfo)) = SWAP16(*(USHORT *)(&(Packet.KeyDesc.KeyInfo)));
23392 - // Out buffer for transmitting group message 2
23393 + // Out buffer for transmitting group message 2
23394 NStatus = MlmeAllocateMemory(pAdapter, (PVOID)&OutBuffer); //Get an unused nonpaged memory
23395 if (NStatus != NDIS_STATUS_SUCCESS)
23399 // Prepare EAPOL frame for MIC calculation
23400 // Be careful, only EAPOL frame is counted for MIC calculation
23401 @@ -825,7 +1051,7 @@
23407 HMAC_SHA1(OutBuffer, FrameLen, pAdapter->PortCfg.PTK, LEN_EAP_MICK, digest);
23408 memcpy(Mic, digest, LEN_KEY_DESC_MIC);
23410 @@ -836,15 +1062,15 @@
23411 for (i = 0; i < 64; i++)
23412 DBGPRINT(RT_DEBUG_INFO, "%2x-", pAdapter->PortCfg.PTK[i]);
23413 DBGPRINT(RT_DEBUG_INFO, "\n FrameLen = %d\n", FrameLen);
23416 hmac_md5(pAdapter->PortCfg.PTK, LEN_EAP_MICK, OutBuffer, FrameLen, Mic);
23418 memcpy(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
23422 // Make Transmitting frame
23423 MakeOutgoingFrame(OutBuffer, &FrameLen, sizeof(MACHDR), &Header_802_11,
23424 - sizeof(EAPHEAD), EAPHEAD,
23425 + sizeof(EAPHEAD), EAPHEAD,
23426 Packet.Len[1] + 4, &Packet,
23429 @@ -853,72 +1079,72 @@
23431 // 6 Free allocated memory
23432 MlmeFreeMemory(pAdapter, OutBuffer);
23436 memset(&GroupKey, 0, sizeof(GroupKey));
23437 GroupKey.Length = sizeof(GroupKey);
23438 - GroupKey.KeyIndex = 0x20000000 | pGroup->KeyDesc.KeyInfo.KeyIndex;
23439 + GroupKey.KeyIndex = 0x20000000 | pGroup->KeyDesc.KeyInfo.KeyIndex;
23440 GroupKey.KeyLength = 16;
23441 memcpy(GroupKey.BSSID, pAdapter->PortCfg.Bssid.Octet, 6);
23442 memcpy(GroupKey.KeyMaterial, GTK, 32);
23443 // Call Add peer key function
23444 RTMPWPAAddKeyProc(pAdapter, &GroupKey);
23447 DBGPRINT(RT_DEBUG_TRACE, "WpaGroupMsg1Action <-----\n");
23450 ========================================================================
23453 Routine Description:
23454 Init WPA MAC header
23457 pAdapter Pointer to our adapter
23467 ========================================================================
23469 VOID WpaMacHeaderInit(
23470 - IN PRTMP_ADAPTER pAd,
23471 - IN OUT PHEADER_802_11 Hdr,
23473 - IN PMACADDR pAddr1)
23474 + IN PRTMP_ADAPTER pAd,
23475 + IN OUT PHEADER_802_11 Hdr,
23477 + IN PMACADDR pAddr1)
23479 memset(Hdr, 0, sizeof(HEADER_802_11));
23480 - Hdr->Controlhead.Frame.Type = BTYPE_DATA;
23481 + Hdr->Controlhead.Frame.Type = BTYPE_DATA;
23482 Hdr->Controlhead.Frame.ToDs = 1;
23484 Hdr->Controlhead.Frame.Wep = 1;
23487 // Addr1: DA, Addr2: BSSID, Addr3: SA
23488 COPY_MAC_ADDR(&Hdr->Controlhead.Addr1, pAddr1);
23489 COPY_MAC_ADDR(&Hdr->Controlhead.Addr2, &pAd->CurrentAddress);
23490 COPY_MAC_ADDR(&Hdr->Addr3, &pAd->PortCfg.Bssid);
23491 - Hdr->Sequence = pAd->Sequence;
23492 + Hdr->Sequence = pAd->Sequence;
23496 ========================================================================
23498 Routine Description:
23499 - Copy frame from waiting queue into relative ring buffer and set
23500 + Copy frame from waiting queue into relative ring buffer and set
23501 appropriate ASIC register to kick hardware encryption before really
23506 pAdapter Pointer to our adapter
23507 PNDIS_PACKET Pointer to outgoing Ndis frame
23508 NumberOfFrag Number of fragment required
23517 ========================================================================
23519 VOID WpaHardEncrypt(
23520 @@ -938,38 +1164,58 @@
23524 - PWPA_KEY pWpaKey;
23525 + PWPA_KEY pWpaKey = NULL;
23526 UCHAR RetryMode = SHORT_RETRY;
23527 static UCHAR Priority[4] = {"\x00\x00\x00\x00"};
23529 + PHEADER_802_11 pHeader;
23530 + unsigned long flags;
23532 // Make sure Tx ring resource won't be used by other threads
23533 - spin_lock_irq(&pAdapter->TxRingLock);
23534 + spin_lock_irqsave(&pAdapter->TxRingLock, flags);
23536 FrameGap = IFS_BACKOFF; // Default frame gap mode
23538 - // outgoing frame always wakeup PHY to prevent frame lost and
23540 + // outgoing frame always wakeup PHY to prevent frame lost and
23541 // turn off PSM bit to improve performance
23542 if (pAdapter->PortCfg.Psm == PWR_SAVE)
23544 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
23546 AsicForceWakeup(pAdapter);
23549 pAdapter->TxRing[pAdapter->CurEncryptIndex].FrameType = BTYPE_DATA;
23551 pSrc = pPacket; // Point to start of MSDU
23555 pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.PairwiseKey[0];
23556 pWpaKey->Type = PAIRWISE_KEY;
23558 + pHeader = (PHEADER_802_11) pSrc;
23560 + for (idx = 0; idx < PAIRWISE_KEY_NO; idx++) {
23561 + if ((memcmp(&pHeader->Controlhead.Addr1,
23562 + pAdapter->PortCfg.PairwiseKey[idx].BssId, 6) == 0)
23563 + && (pAdapter->PortCfg.PairwiseKey[idx].KeyLen != 0)) {
23564 + pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.PairwiseKey[idx];
23565 + pWpaKey->Type = PAIRWISE_KEY;
23566 + DBGPRINT(RT_DEBUG_TRACE,
23567 + "WpaHardEncrypt:(U) Tx Use Pairwise Key(%d)\n", idx);
23572 if (pWpaKey == NULL)
23574 // No pairwise key, this should not happen
23575 - spin_unlock_irq(&pAdapter->TxRingLock);
23576 + DBGPRINT(RT_DEBUG_ERROR, "WpaHardEncrypt: No pairwise key!!!!!\n");
23577 + spin_unlock_irqrestore(&pAdapter->TxRingLock, flags);
23582 // Get the Tx Ring descriptor & Dma Buffer address
23583 - pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
23584 + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr;
23586 pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr;
23588 @@ -979,14 +1225,16 @@
23590 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
23594 if ((pTxD->Owner == DESC_OWN_NIC) || (pTxD->CipherOwn == DESC_OWN_NIC))
23596 // Descriptor owned by NIC. No descriptor avaliable
23597 // This should not happen since caller guaranteed.
23598 // Make sure to release Tx ring resource
23599 + DBGPRINT(RT_DEBUG_ERROR,
23600 + "WpaHardEncrypt: Descriptor ownedby NIC. No descriptor available!!!!!!\n");
23601 pAdapter->RalinkCounters.TxRingErrCount++;
23602 - spin_unlock_irq(&pAdapter->TxRingLock);
23603 + spin_unlock_irqrestore(&pAdapter->TxRingLock, flags);
23606 if (pTxD->Valid == TRUE)
23607 @@ -995,17 +1243,19 @@
23608 // This should not happen since caller guaranteed.
23609 // Make sure to release Tx ring resource
23610 pTxD->Valid = FALSE;
23614 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
23618 + DBGPRINT(RT_DEBUG_ERROR,
23619 + "WpaHardEncrypt: Ndis packet of last round did not cleared!!!!!\n");
23620 pAdapter->RalinkCounters.TxRingErrCount++;
23621 - spin_unlock_irq(&pAdapter->TxRingLock);
23622 + spin_unlock_irqrestore(&pAdapter->TxRingLock, flags);
23627 // Copy whole frame to Tx ring buffer
23628 memcpy(pDest, pPacket, Len);
23630 @@ -1026,16 +1276,21 @@
23631 tkipIv.IV16.field.Rsvd = 0;
23632 tkipIv.IV16.field.ExtIV = 1;// 0: non-extended IV, 1: extended IV
23633 tkipIv.IV16.field.KeyID = 0;
23634 - tkipIv.IV32 = *(PULONG)(pWpaKey->TxTsc + 2);
23635 + //tkipIv.IV32 = *(PULONG)(pWpaKey->TxTsc + 2);
23636 + memcpy(&tkipIv.IV32, &pWpaKey->TxTsc[2], 4);
23639 + pTxD-Iv = SWAP32(tipIv.IV16.word);
23641 pTxD->Iv = tkipIv.IV16.word;
23644 *((PUCHAR) &pTxD->Eiv) = *((PUCHAR) &tkipIv.IV32 + 3);
23645 *((PUCHAR) &pTxD->Eiv + 1) = *((PUCHAR) &tkipIv.IV32 + 2);
23646 *((PUCHAR) &pTxD->Eiv + 2) = *((PUCHAR) &tkipIv.IV32 + 1);
23647 *((PUCHAR) &pTxD->Eiv + 3) = *((PUCHAR) &tkipIv.IV32);
23651 // Increase TxTsc value for next transmission
23652 while (++pWpaKey->TxTsc[i] == 0x0)
23654 @@ -1043,13 +1298,13 @@
23661 pTxD->IvOffset = LENGTH_802_11;
23664 memcpy(pTxD->Key, pWpaKey->Key, 16);
23667 // Set Cipher suite
23668 CipherAlg = CIPHER_TKIP;
23670 @@ -1059,10 +1314,10 @@
23671 pAdapter->PrivateInfo.Tx.R = RTMPTkipGetUInt32(pWpaKey->TxMic + 4);
23672 pAdapter->PrivateInfo.Tx.nBytesInM = 0;
23673 pAdapter->PrivateInfo.Tx.M = 0;
23677 RTMPTkipAppend(&pAdapter->PrivateInfo.Tx, pSrc + 4, 12);
23680 // Priority + 3 bytes of 0
23681 RTMPTkipAppend(&pAdapter->PrivateInfo.Tx, Priority, 4);
23683 @@ -1086,9 +1341,9 @@
23684 *(pTmp + 1) = pWpaKey->TxTsc[1];
23686 *(pTmp + 3) = 0x20;
23689 Iv32 = *(PULONG)(&pWpaKey->TxTsc[2]);
23692 // Increase TxTsc value for next transmission
23693 while (++pWpaKey->TxTsc[i] == 0x0)
23695 @@ -1096,13 +1351,13 @@
23702 memcpy(&pTxD->Iv, &Iv16, 4);
23706 memcpy(&pTxD->Eiv, &Iv32, 4);
23710 pTxD->IvOffset = LENGTH_802_11;
23712 @@ -1111,11 +1366,11 @@
23714 // Set Cipher suite
23715 CipherAlg = CIPHER_AES;
23718 // IV + EIV + HW MIC
23725 RTMPFrameEndianChange(pAdapter, pOriginDest, DIR_WRITE, FALSE);
23726 RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
23727 @@ -1123,7 +1378,7 @@
23731 - RTMPWriteTxDescriptor(pTxD, TRUE, CipherAlg, TRUE, FALSE, FALSE, RetryMode, FrameGap,
23732 + RTMPWriteTxDescriptor(pTxD, TRUE, CipherAlg, TRUE, FALSE, FALSE, RetryMode, FrameGap,
23733 pAdapter->PortCfg.TxRate, 4, Len, pAdapter->PortCfg.TxPreambleInUsed, 0);
23735 // Increase & maintain Tx Ring Index
23736 @@ -1131,28 +1386,28 @@
23737 if (pAdapter->CurEncryptIndex >= TX_RING_SIZE)
23739 pAdapter->CurEncryptIndex = 0;
23741 - pAdapter->RalinkCounters.EncryptCount++;
23744 + pAdapter->RalinkCounters.EncryptCount++;
23746 // Kick Encrypt Control Register at the end of all ring buffer preparation
23747 RTMP_IO_WRITE32(pAdapter, SECCSR1, 0x1);
23750 // Make sure to release Tx ring resource
23751 - spin_unlock_irq(&pAdapter->TxRingLock);
23752 + spin_unlock_irqrestore(&pAdapter->TxRingLock, flags);
23756 ========================================================================
23759 Routine Description:
23771 ========================================================================
23774 @@ -1167,8 +1422,8 @@
23775 UCHAR k_opad[65]; /* outer padding - key XORd with opad */
23778 - // if key is longer than 64 bytes reset it to key=SHA1(key)
23779 - if (key_len > 64)
23780 + // if key is longer than 64 bytes reset it to key=SHA1(key)
23781 + if (key_len > 64)
23785 @@ -1181,20 +1436,20 @@
23786 memcpy(k_ipad, key, key_len);
23787 memcpy(k_opad, key, key_len);
23789 - // XOR key with ipad and opad values
23790 - for (i = 0; i < 64; i++)
23792 + // XOR key with ipad and opad values
23793 + for (i = 0; i < 64; i++)
23799 - // perform inner SHA1
23800 + // perform inner SHA1
23801 SHAInit(&context); /* init context for 1st pass */
23802 SHAUpdate(&context, k_ipad, 64); /* start with inner pad */
23803 SHAUpdate(&context, text, text_len); /* then text of datagram */
23804 SHAFinal(&context, digest); /* finish up 1st pass */
23806 - //perform outer SHA1
23807 + //perform outer SHA1
23808 SHAInit(&context); /* init context for 2nd pass */
23809 SHAUpdate(&context, k_opad, 64); /* start with outer pad */
23810 SHAUpdate(&context, digest, 20); /* then results of 1st hash */
23811 @@ -1203,17 +1458,17 @@
23814 ========================================================================
23817 Routine Description:
23830 ========================================================================
23833 @@ -1230,7 +1485,7 @@
23835 INT currentindex = 0;
23839 memcpy(input, prefix, prefix_len);
23840 input[prefix_len] = 0;
23841 memcpy(&input[prefix_len + 1], data, data_len);
23842 @@ -1242,22 +1497,22 @@
23843 HMAC_SHA1(input, total_len, key, key_len, &output[currentindex]);
23844 currentindex += 20;
23845 input[total_len - 1]++;
23851 ========================================================================
23854 Routine Description:
23855 Count TPTK from PMK
23861 Output Store the TPTK
23866 ========================================================================
23869 @@ -1268,11 +1523,11 @@
23875 UCHAR concatenation[76];
23878 - UCHAR Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
23879 + UCHAR Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
23880 'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n'};
23882 memset(temp, 0, sizeof(temp));
23883 @@ -1281,52 +1536,52 @@
23884 if (RTMPCompareMemory(SA, AA, 6) == 1)
23885 memcpy(concatenation, AA, 6);
23887 - memcpy(concatenation, SA, 6);
23888 + memcpy(concatenation, SA, 6);
23891 // Get larger address
23892 if (RTMPCompareMemory(SA, AA, 6) == 1)
23893 memcpy(&concatenation[CurrPos], SA, 6);
23895 - memcpy(&concatenation[CurrPos], AA, 6);
23896 + memcpy(&concatenation[CurrPos], AA, 6);
23899 // Get smaller address
23900 - if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
23901 + if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
23902 memcpy(&concatenation[CurrPos], SNonce, 32);
23905 memcpy(&concatenation[CurrPos], ANonce, 32);
23908 // Get larger address
23909 - if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
23910 + if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
23911 memcpy(&concatenation[CurrPos], ANonce, 32);
23914 memcpy(&concatenation[CurrPos], SNonce, 32);
23918 PRF(PMK, LEN_MASTER_KEY, Prefix, 22, concatenation, 76 , output, len);
23922 ========================================================================
23925 Routine Description:
23926 Misc function to Generate random number
23937 ========================================================================
23940 - IN PRTMP_ADAPTER pAd,
23941 + IN PRTMP_ADAPTER pAd,
23946 UCHAR local[80], KeyCounter[32];
23948 @@ -1337,9 +1592,9 @@
23949 memset(local, 0, 80);
23950 memset(KeyCounter, 0, 32);
23951 memcpy(local, pAd->CurrentAddress, ETH_ALEN);
23954 for (i = 0; i < 32; i++)
23958 CurrentTime = jiffies;
23959 memcpy(local, pAd->CurrentAddress, ETH_ALEN);
23960 @@ -1348,29 +1603,29 @@
23961 curr += sizeof(CurrentTime);
23962 memcpy(&local[curr], result, 32);
23964 - memcpy(&local[curr], &i, 2);
23965 + memcpy(&local[curr], &i, 2);
23967 - PRF(KeyCounter, 32, prefix,12, local, curr, result, 32);
23968 + PRF(KeyCounter, 32, prefix,12, local, curr, result, 32);
23970 - memcpy(random, result, 32);
23971 + memcpy(random, result, 32);
23975 ========================================================================
23978 Routine Description:
23979 Misc function to decrypt AES body
23989 This function references to RFC 3394 for aes key unwrap algorithm.
23992 ========================================================================
23994 -VOID AES_GTK_KEY_UNWRAP(
23995 +VOID AES_GTK_KEY_UNWRAP(
23997 OUT UCHAR *plaintext,
23998 IN UCHAR *ciphertext)
23999 @@ -1381,7 +1636,7 @@
24000 INT num_blocks = 2;
24002 aes_context aesctx;
24007 memcpy(A, ciphertext, 8);
24008 @@ -1391,7 +1646,7 @@
24009 memcpy(R2, &ciphertext[16], 8);
24011 aes_set_key(&aesctx, key, 128);
24014 for (j = 5; j >= 0; j--)
24016 xor = num_blocks * j + 2;
24017 @@ -1401,7 +1656,7 @@
24018 aes_decrypt(&aesctx, BIN, BOUT);
24019 memcpy(A, &BOUT[0], 8);
24020 memcpy(R2, &BOUT[8], 8);
24023 xor = num_blocks * j + 1;
24025 BIN[7] = A[7] ^ xor;
24026 diff -Nur rt2500-1.1.0-b4/Module/wpa.h rt2500-cvs-2007061011/Module/wpa.h
24027 --- rt2500-1.1.0-b4/Module/wpa.h 2006-06-17 22:12:58.000000000 +0200
24028 +++ rt2500-cvs-2007061011/Module/wpa.h 2007-03-21 05:25:35.000000000 +0100
24030 -/***************************************************************************
24031 - * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
24033 - * This program is free software; you can redistribute it and/or modify *
24034 - * it under the terms of the GNU General Public License as published by *
24035 - * the Free Software Foundation; either version 2 of the License, or *
24036 - * (at your option) any later version. *
24038 - * This program is distributed in the hope that it will be useful, *
24039 - * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24040 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
24041 - * GNU General Public License for more details. *
24043 - * You should have received a copy of the GNU General Public License *
24044 - * along with this program; if not, write to the *
24045 - * Free Software Foundation, Inc., *
24046 - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24048 - * Licensed under the GNU GPL *
24049 - * Original code supplied under license from RaLink Inc, 2004. *
24050 - ***************************************************************************/
24052 - /***************************************************************************
24053 - * Module Name: wpa.h
24057 - * Revision History:
24059 - * -------- ----------- -----------------------------
24060 - * MarkW 8th Dec 04 Baseline code
24061 - ***************************************************************************/
24062 +/***************************************************************************
24063 + * RT2400/RT2500 SourceForge Project - http://rt2x00.serialmonkey.com *
24065 + * This program is free software; you can redistribute it and/or modify *
24066 + * it under the terms of the GNU General Public License as published by *
24067 + * the Free Software Foundation; either version 2 of the License, or *
24068 + * (at your option) any later version. *
24070 + * This program is distributed in the hope that it will be useful, *
24071 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24072 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
24073 + * GNU General Public License for more details. *
24075 + * You should have received a copy of the GNU General Public License *
24076 + * along with this program; if not, write to the *
24077 + * Free Software Foundation, Inc., *
24078 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24080 + * Licensed under the GNU GPL *
24081 + * Original code supplied under license from RaLink Inc, 2004. *
24082 + ***************************************************************************/
24084 + /***************************************************************************
24085 + * Module Name: wpa.h
24089 + * Revision History:
24091 + * -------- ----------- -----------------------------
24092 + * MarkW 8th Dec 04 Baseline code
24093 + ***************************************************************************/
24098 #define DESC_TYPE_AES 2
24099 #define RSN_KEY_DESC 0xfe
24101 -#define LEN_MASTER_KEY 32
24102 +#define LEN_MASTER_KEY 32
24105 #define LEN_EAP_EK 16
24106 @@ -131,7 +131,7 @@
24107 UCHAR KeyRsc[LEN_KEY_DESC_RSC];
24108 UCHAR KeyId[LEN_KEY_DESC_ID];
24109 UCHAR KeyMic[LEN_KEY_DESC_MIC];
24110 - UCHAR KeyDataLen[2];
24111 + UCHAR KeyDataLen[2];
24112 UCHAR KeyData[MAX_LEN_OF_RSNIE];
24113 } KEY_DESCRIPTER, *PKEY_DESCRIPTER;
24115 diff -Nur rt2500-1.1.0-b4/THANKS rt2500-cvs-2007061011/THANKS
24116 --- rt2500-1.1.0-b4/THANKS 2006-06-17 22:12:58.000000000 +0200
24117 +++ rt2500-cvs-2007061011/THANKS 2007-05-05 19:48:18.000000000 +0200
24119 * Mark Wallis - mwallis@serialmonkey.com
24120 * Robin Cornelius - robin@cornelius.demon.co.uk
24121 * Gertjan van Wingerde - gwingerde@users.sourceforge.net
24122 +* Olivier Cornu - o.cornu@gmail.com
24124 And Special thanks to those that have contributed to the project