# [Wifi] Realtek 8187L & WPA

## markys

Hello everyone,

Here is a little puzzle for you, hope you'll like it  :Razz: 

I am trying to get my wireless netwrok card, a Realtek 8187L chipset integrated on a P5B-Deluxe/Wifi motherboard.

I decided to use ndiswrapper with Windows 98 drivers, as said on this page ( #48 ):

http://ndiswrapper.sourceforge.net/joomla/index.php?/component/option,com_openwiki/Itemid,33/id,list_a/

and also because I always have errors with the linux driver from realtek...

First, I emerged ndiswrapper with usb support since my card is USB (even if integrated)

```
USE="usb" emerge -va ndiswrapper
```

it compiled successfully

I loaded the driver into ndiswrapper

```
tux WIN98 # ls -lA

total 220

-rw-r--r-- 1 root root  11203 Feb  5 14:15 Netrtuw.inf

-rw-r--r-- 1 root root 194304 Jan 11  2007 RTL8187.sys

-rw-r--r-- 1 root root   8482 Sep 12  2006 netrtuw.cat

tux WIN98 # ndiswrapper -i Netrtuw.inf

installing netrtuw ...

tux WIN98 # ndiswrapper -l

netrtuw : driver installed

        device (0BDA:8187) present
```

I loaded the module

```
tux WIN98 # depmod -a

tux WIN98 # modprobe ndiswrapper

tux WIN98 # dmesg|tail

 usbdev1.2_ep81: ep_device_release called for usbdev1.2_ep81

 usbdev1.2_ep02: ep_device_release called for usbdev1.2_ep02

 usbdev1.2_ep03: ep_device_release called for usbdev1.2_ep03

ndiswrapper: driver netrtuw (Realtek Semiconductor Corp.,01/11/2007,5.1273.0111.2007) loaded

 usbdev1.2_ep81: ep_device_release called for usbdev1.2_ep81

 usbdev1.2_ep02: ep_device_release called for usbdev1.2_ep02

 usbdev1.2_ep03: ep_device_release called for usbdev1.2_ep03

wlan0: ethernet device 00:15:af:04:92:06 using NDIS driver: netrtuw, version: 0x1, NDIS version: 0x500, vendor: 'Realtek RTL8187 Wireless LAN USB NIC                                     ', 0BDA:8187.F.conf

[wlan0: encryption modes supported: WEP; TKIP with WPA, WPA2, WPA2PSK; AES/CCMP with WPA, WPA2, WPA2PSK

usbcore: registered new interface driver ndiswrapper
```

There's a little warning here, I don't think it is very important...

```
tux WIN98 # iwconfig

eth0      no wireless extensions.

lo        no wireless extensions.

sit0      no wireless extensions.

Warning: Driver for device wlan0 has been compiled with version 22

of Wireless Extension, while this program supports up to version 20.

Some things may be broken...

wlan0     IEEE 802.11g  ESSID:off/any

          Mode:Managed  Frequency:4294.97 GHz  Access Point: Not-Associated

          Bit Rate=54 Mb/s   Tx-Power:20 dBm   Sensitivity=0/3

          RTS thr=2432 B   Fragment thr=2432 B

          Encryption key:off

          Power Management:off

          Link Quality:0  Signal level:0  Noise level:0

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

```

At this moment I began following the Wireless networking guiide from the handbook. So I emerged wpa_supplicant, i put "modules=( "wpa_supplicant" )" in /etc/conf.d/net, as well as wpa_supplicant_wlan0="-Dndiswrapper".

Then, I wrote my wpa_supplicant.conf

```
tux linux # cat /etc/wpa_supplicant/wpa_supplicant.conf

# This is a network block that connects to any unsecured access point.

# We give it a low priority so any defined blocks are preferred.

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

network={

  ssid="marchi"

  scan_ssid=1

  psk="secret"

  priority=10

  proto=WPA

  key_mgmt=WPA-PSK

  pairwise=TKIP

  group=TKIP

}

network={

        key_mgmt=NONE

        priority=-9999999

}

```

At this point, everything seems correct. But here is a veryverbose output of the wpa_supplicant command:

```
tux linux # ifconfig wlan0 up

tux linux # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -dd

Initializing interface 'wlan0' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'

Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'

ctrl_interface='/var/run/wpa_supplicant'

ctrl_interface_group='0' (DEPRECATED)

ap_scan=1

Line: 7 - start of a new network block

ssid - hexdump_ascii(len=6):

     6d 61 72 63 68 69                                 marchi

scan_ssid=1 (0x1)

PSK (ASCII passphrase) - hexdump_ascii(len=20): [REMOVED]

priority=10 (0xa)

proto: 0x1

key_mgmt: 0x2

PSK (from passphrase) - hexdump(len=32): [REMOVED]

Line: 17 - start of a new network block

key_mgmt: 0x4

priority=-9999999 (0xff676981)

Priority group 10

   id=0 ssid='marchi'

Priority group -9999999

   id=1 ssid=''

Initializing interface (2) 'wlan0'

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: KEY_RX entering state NO_KEY_RECEIVE

EAPOL: SUPP_BE entering state INITIALIZE

EAP: EAP entering state DISABLED

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

SIOCGIWRANGE: WE(compiled)=22 WE(source)=18 enc_capa=0xf

  capabilities: key_mgmt 0xf enc 0xf

WEXT: Operstate: linkmode=1, operstate=5

Own MAC address: 00:15:af:04:92:06

wpa_driver_wext_set_wpa

wpa_driver_wext_set_key: alg=0 key_idx=0 set_tx=0 seq_len=0 key_len=0

wpa_driver_wext_set_key: alg=0 key_idx=1 set_tx=0 seq_len=0 key_len=0

wpa_driver_wext_set_key: alg=0 key_idx=2 set_tx=0 seq_len=0 key_len=0

wpa_driver_wext_set_key: alg=0 key_idx=3 set_tx=0 seq_len=0 key_len=0

wpa_driver_wext_set_countermeasures

wpa_driver_wext_set_drop_unencrypted

Setting scan request: 0 sec 100000 usec

ctrl_interface_group=0

Added interface wlan0

RTM_NEWLINK: operstate=0 ifi_flags=0x1002 ()

Wireless event: cmd=0x8b06 len=8

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

State: DISCONNECTED -> SCANNING

Starting AP scan (specific SSID)

Scan SSID - hexdump_ascii(len=6):

     6d 61 72 63 68 69                                 marchi

Trying to get current scan results first without requesting a new scan to speed up initial association

Received 0 bytes of scan results (0 BSSes)

Scan results: 0

Selecting BSS from priority group 10

Selecting BSS from priority group -9999999

No suitable AP found.

Setting scan request: 0 sec 0 usec

Starting AP scan (broadcast SSID)

Scan timeout - try to get results

ioctl[SIOCGIWSCAN]: Resource temporarily unavailable

Scan results: -1

Failed to get scan results

Failed to get scan results - try scanning again

Setting scan request: 1 sec 0 usec
```

What is weird is that once or twice, it wrote that it found a network which is actually my neighbor's network, followed by something like rejected because of a  ssid mismatch...

That's all I can tell you for now, I don't kwno anything else about this case..

Thanks for your precious help!

Simon Marchi

----------

## markys

Hey guys,

I just found a way to make it work... but that's a little bit strange:

When I tried Windows vista, a while ago, I couldn't make my card work on it either (even with the Vista driver from Realtek). I searched google and discovered that some people were using an old version of a Win98 driver to make it work (and it did for me too).

So I gave it a try with ndiswrapper, and the wpa_supplicant command worked, dhcpcd wlan0 succeeded on the first try... I don't know for you, but I think it is really weird... anyway

Simon Marchi

ps: this is the driver if anyone needs it 

http://www.majorgeeks.com/Realtek_RTL8187_USB_Wireless_LAN_ME2000XP_d5165.html

----------

## kernelOfTruth

nice, you figured it out & thanks for the address,

I've already encountered this "behavior" with several wlan-adaptors & ndiswrappers, don't know why but it is highly recommended to use win98 drivers instead of winxp or win2k [they often also don't work   :Laughing:  ]

cheers

----------

## peertje888

WOW SUPER TNX! I've been busy for days to try and get it working...wpa_supplicant just didn't came further than "Trying to associate." This was the output of wpa_supplicant -dd:

```
...

Removed BSSID 00:1a:92:cf:e5:a6 from blacklist (clear)

Selecting BSS from priority group 0

0: 00:1a:92:cf:e5:a6 ssid='sk1ppy' wpa_ie_len=26 rsn_ie_len=0 caps=0x11

   selected based on WPA IE

Trying to associate with 00:1a:92:cf:e5:a6 (SSID='sk1ppy' freq=2462 MHz)

Cancelling scan request

WPA: clearing own WPA/RSN IE

Automatic auth_alg selection: 0x1

wpa_driver_ipw_set_auth_alg: auth_alg=0x1

ioctl[IPW_IOCTL_WPA_SUPPLICANT]: Operation not supported

WPA: using IEEE 802.11i/D3.0

WPA: Selected cipher suites: group 8 pairwise 8 key_mgmt 2 proto 1

WPA: set AP WPA IE - hexdump(len=26): dd 18 00 50 f2 01 01 00 00 50 f2 02 01 00 00 50 f2 02 01 00 00 50 f2 02 00 00

WPA: clearing AP RSN IE

WPA: using GTK TKIP

WPA: using PTK TKIP

WPA: using KEY_MGMT WPA-PSK

WPA: Set own WPA IE default - hexdump(len=24): dd 16 00 50 f2 01 01 00 00 50 f2 02 01 00 00 50 f2 02 01 00 00 50 f2 02

No keys have been configured - skip key clearing

wpa_driver_ipw_set_drop_unencrypted: enabled=1

ioctl[IPW_IOCTL_WPA_SUPPLICANT]: Operation not supported

State: SCANNING -> ASSOCIATING

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

WEXT: Operstate: linkmode=-1, operstate=5

ioctl[IPW_IOCTL_WPA_SUPPLICANT]: Operation not supported

ioctl[IPW_IOCTL_WPA_SUPPLICANT]: Operation not supported

Setting authentication timeout: 10 sec 0 usec

EAPOL: External notification - EAP success=0

EAPOL: External notification - EAP fail=0

EAPOL: External notification - portControl=Auto

Authentication with 00:00:00:00:00:00 timed out.

Added BSSID 00:1a:92:cf:e5:a6 into blacklist

State: ASSOCIATING -> DISCONNECTED

...

```

With the ndiswrapped suggested win98 driver, and modprobe ndiswrapper it finally works! 

Here is my wpa_supplicant.conf (Hidden ESSID, WPA2):

```
ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

ap_scan=2

update_config=1

network={

   ssid="%networkname%"

   bssid=00:1a:92:cf:e5:a6

   scan_ssid=1

   psk=#generated with wpa_passphrase %networkname% %wpakey%

   proto=WPA

   key_mgmt=WPA-PSK

   pairwise=TKIP

   group=TKIP

}

```

Maybe we should make a lot of keywords somewhere here so people searching will sooner arrive here.

My RTL8187 works...finaly  :Very Happy:  thanks man!

----------

