# Intel 4965AGN WiFi Mini Wireless Card setup help pls?

## stardotstar

Hi All,

The original card in my MSI Wind was not at all well supported by all accounts around the web so I elected to void my warranty (arguably anyway) and add an extra Gig of ram and the Intel Mini PCI express 4965AGN card.

Now that I lspci I can see an intel network controller but not the full details that some of the other lspci's I see around the web provide to wit:

```
$ lspci -s 0c:00.0

0c:00.0 Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN Network Connection (rev 61)
```

vs what I get:

```

02:00.0 Network controller: Intel Corporation Device 4229 (rev 61)

   Subsystem: Intel Corporation Device 1100

   Flags: fast devsel, IRQ 17

   Memory at dfc00000 (64-bit, non-prefetchable) [size=8K]

   Capabilities: [c8] Power Management version 3

   Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-

   Capabilities: [e0] Express Endpoint, MSI 00

   Kernel driver in use: iwl4965

```

as you can see the iwl4965 kernel driver (from the 2.6.25 gentoo sources kernel itself - built in) is linked to it.

The interface seems to be created:

```

eddy init.d # iwconfig 

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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
```

and I have tried to setup my conf.d/net and wpa_supplicant.conf properly using net.wlan0 symlinked to eth0

```
eddy init.d # ls -l net.*

lrwxrwxrwx 1 root root     6 Nov  3 19:17 net.eth0 -> net.lo

-rwxr-xr-x 1 root root 30696 Feb 29  2008 net.lo

lrwxrwxrwx 1 root root    20 Nov 10 17:29 net.wlan0 -> /etc/init.d/net.eth0

...

.../etc/conf.d/net (extract)

modules=( "ifconfig" )

modules=( "wpa_supplicant" )

modules_eth0=( "dhcpcd" )

mac_eth0="00:08:74:94:78:45"

config_eth0=( "dhcp" ) 

wpa_supplicant_wlan0="-Dmadwifi"

config_wlan0=( "dhcp" )

...

.../etc/wpa_supplicant.conf (extract)

ctrl_interface=/var/run/wpa_suplicant

ctrl_interface_group=0

ap_scan=1

network={

        key_mgmt=NONE

        priority=-9999999

}

network={

        ssid="skink"

        key_mgmt=WPA-PSK

        psk="secret"

}

```

so I am not sure if -Dmadwifi is what I should have and am searching now.  Also this is the problem when I try to invoke the net.wlan0

```

eddy init.d # ./net.wlan0 start

 * Starting wlan0

SIOCSIFFLAGS: No such file or directory

SIOCSIFFLAGS: No such file or directory

 *   Starting wpa_supplicant on wlan0 ...

SIOCSIFFLAGS: No such file or directory

SIOCSIFFLAGS: No such file or directory

Could not set interface 'wlan0' UP

ioctl[IEEE80211_IOCTL_SETPARAM]: Operation not supported

Failed to initialize driver interface

/lib/rcscripts/sh/rc-daemon.sh: line 231: 10225 Segmentation fault      /sbin/start-stop-daemon '--start' '--exec' '/sbin/wpa_supplicant' '--pidfile' '/var/run/wpa_supplicant-wlan0.pid' '--' '-Dmadwifi' '-c/etc/wpa_supplicant/wpa_supplicant.conf' '-W' '-W' '-B' '-iwlan0' '-P/var/run/wpa_supplicant-wlan0.pid'     [ !! ]

eddy init.d # 

```

I have wireless tools and the wpa_supplicant with which I have some considerable experience with other cards - but never the mini pci or draft n cards...

With the wiki stuffed I am not able to turn to my usual sources of fresh ideas  :Smile: 

Any and all assistance sincerely sought.

Regards,

\\'

----------

## d2_racing

Hi, first you need to do this :

```

# rm /etc/init.d/net.wlan0

# rm /etc/init.d/net.eth0 

# ln -s net.lo net.wlan0

# ln -s net.lo net.eth0

```

Also, can you post this :

```

# equery list iwl

```

You need to have the iwl4954-ucode package.

After that, your /etc/conf.d/net should be like this :

```

mac_eth0="00:08:74:94:78:45" 

config_eth0=( "dhcp" ) 

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0_="-Dwext"

config_wlan0=( "dhcp" )

```

And you /etc/wpa_supplicant/wpa_supplicant.conf

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

ap_scan=0

#update_config=1

network={ 

        key_mgmt=NONE 

        priority=-9999999 

} 

network={ 

        ssid="skink" 

        key_mgmt=WPA-PSK 

        psk="secret"

        priority=5

} 

```

----------

## d2_racing

Also, for the record, can you post this :

```

# rmmod iwl4965

# modprobe iwl4965

# dmesg | tail

# iwconfig

# ifconfig -a

# /etc/init.d/net.wlan0 start

# iwconfig

# ifconfig -a

# wpa_cli status

```

----------

## stardotstar

Thank you I will do that as soon as I get to work!

----------

## stardotstar

First thing was to emerge the iwl4965-ucode

and do the relinking of the net scripts

then I changed the conf.d/net to let wpa_supp use the wext driver.

OK I had the drivers compiled into the kernel so I recompiled with iwl4965 modular and rebooted.

Then I saw this on boot messages:

```

eddy log # less dmesg | grep iwl

iwl4965: Intel(R) Wireless WiFi Link 4965AGN driver for Linux, 1.2.23kds

iwl4965: Copyright(c) 2003-2007 Intel Corporation

iwl4965: Detected Intel Wireless WiFi Link 4965AGN

iwl4965: Tunable channels: 11 802.11bg, 13 802.11a channels

phy0: Selected rate control algorithm 'iwl-4965-rs'

```

and lo and behold the association with my work AP happened without my intervening but strangely the wpa_cli cannot contact the wpa_supp process./././

so I am not sure what is driving this thing!

```

eddy log # wpa_cli

wpa_cli v0.5.7

Copyright (c) 2004-2006, Jouni Malinen <jkmaline@cc.hut.fi> and contributors

This program is free software. You can distribute it and/or modify it

under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the

BSD license. See README and COPYING for more details.

Could not connect to wpa_supplicant - re-trying

```

trying your suggestions:

```

eddy log # rmmod iwl4965

eddy log # modprobe iwl4965

eddy log # dmesg | tail

wlan0: associated

wlan0: switched to short barker preamble (BSSID=00:1b:2f:db:34:de)

iwl4965: Error sending REPLY_RXON_ASSOC: Already sending a host command

iwl4965: Intel(R) Wireless WiFi Link 4965AGN driver for Linux, 1.2.23kds

iwl4965: Copyright(c) 2003-2007 Intel Corporation

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

PCI: Setting latency timer of device 0000:02:00.0 to 64

iwl4965: Detected Intel Wireless WiFi Link 4965AGN

iwl4965: Tunable channels: 11 802.11bg, 13 802.11a channels

phy2: Selected rate control algorithm 'iwl-4965-rs'

eddy log # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

          Mode:Managed  Channel:0  Access Point: Not-Associated   

          Tx-Power=0 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy log # iwconfig -a

-a        No such device

eddy log # ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:08:74:94:78:45  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:312 errors:0 dropped:3247155641 overruns:0 frame:0

          TX packets:187 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:35140 (34.3 KiB)  TX bytes:17140 (16.7 KiB)

          Interrupt:221 Base address:0xc000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wmaster0  Link encap:UNSPEC  HWaddr 00-1F-3B-69-FF-29-00-00-00-00-00-00-00-00-00-00  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy log # /etc/init.d/net.wlan0 start

 * WARNING:  net.wlan0 has already been started.

eddy log # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

          Mode:Managed  Channel:0  Access Point: Not-Associated   

          Tx-Power=0 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy log # ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:08:74:94:78:45  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:312 errors:0 dropped:3247155641 overruns:0 frame:0

          TX packets:187 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:35140 (34.3 KiB)  TX bytes:17140 (16.7 KiB)

          Interrupt:221 Base address:0xc000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wmaster0  Link encap:UNSPEC  HWaddr 00-1F-3B-69-FF-29-00-00-00-00-00-00-00-00-00-00  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy log # wpa_cli status

Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory

eddy log # 

```

so there are some unresolved things going on here.

I found that the association would not happen with the calling of the net script but doing this automatically created an association!

```
wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy log # /etc/init.d/net.wlan0 stop

 * Stopping wlan0

 *   Bringing down wlan0

 *     Shutting down wlan0 ...                                            [ ok ]

 *     Stopping wpa_cli on wlan0 ...                                      [ ok ]

 *     Stopping wpa_supplicant on wlan0 ...                               [ ok ]

eddy log # rmmod iwl4965

eddy log # modprobe iwl4965

eddy log # dmesg | tail

wlan0: associate with AP 00:1b:2f:db:34:de

wlan0: authentication frame received from 00:1b:2f:db:34:de, but not in authenticate state - ignored

wlan0: authentication frame received from 00:1b:2f:db:34:de, but not in authenticate state - ignored

wlan0: RX AssocResp from 00:1b:2f:db:34:de (capab=0x431 status=0 aid=3)

wlan0: associated

wlan0: switched to short barker preamble (BSSID=00:1b:2f:db:34:de)

wlan0: WMM queue=2 aci=0 acm=0 aifs=3 cWmin=15 cWmax=1023 burst=0

wlan0: WMM queue=3 aci=1 acm=0 aifs=7 cWmin=15 cWmax=1023 burst=0

wlan0: WMM queue=1 aci=2 acm=0 aifs=2 cWmin=7 cWmax=15 burst=30

wlan0: WMM queue=0 aci=3 acm=0 aifs=2 cWmin=3 cWmax=7 burst=15

eddy log # ifconfig

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:6 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:820 (820.0 B)  TX bytes:580 (580.0 B)

wmaster0  Link encap:UNSPEC  HWaddr 00-1F-3B-69-FF-29-00-00-00-00-00-00-00-00-00-00  

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy log # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:"aluminium"  

          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:1B:2F:DB:34:DE   

          Bit Rate=54 Mb/s   Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key:674F-1334-269F-E632-49B9-D40F-5E35-F3A2-EED7-5458-F844-FD2E-C9CB-2BE7-16C6-7C39 [3]

          Link Quality=100/100  Signal level=-32 dBm  Noise level=-96 dBm

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

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

eddy log # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          inet addr:172.17.23.69  Bcast:172.17.23.127  Mask:255.255.255.128

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:10 errors:0 dropped:0 overruns:0 frame:0

          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:1616 (1.5 KiB)  TX bytes:1620 (1.5 KiB)

eddy log # 

```

From what I can see here the process of modprobing the iwl4965 driver invoked the association immediately after calling a net.wlan0 STOP!

So...

```
eddy log # iwconfig 

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:"aluminium"  

          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:1B:2F:DB:34:DE   

          Bit Rate=54 Mb/s   Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key:674F-1334-269F-E632-49B9-D40F-5E35-F3A2-EED7-5458-F844-FD2E-C9CB-2BE7-16C6-7C39 [3]

          Link Quality=100/100  Signal level=-42 dBm  Noise level=-96 dBm

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

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

```

this is a live connection resulting from the last set of instructions.  Let me see if I can reproduce the behaviour that has me confused!

First of all here is the current set of conf.d/net instructions:

```

modules=( "ifconfig" )

modules=( "wpa_supplicant" )

modules=( "!iwconfig" )

modules_eth0=( "dhcpcd" )

mac_eth0="00:08:74:94:78:45"

config_eth0=( "dhcp" ) 

wpa_supplicant_wlan0="-Dwext"

config_wlan0=( "dhcp" )

```

and wpa_supplicant configured with my desired (and only my desired) current AP enabled:

```

# 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_suplicant

ctrl_interface_group=wheel

ap_scan=0

#network={

#       key_mgmt=NONE

#       priority=-9999999

#}

network={

        ssid="skink"

        key_mgmt=WPA-PSK

        psk="secret"

        disabled=1

}

network={

        ssid="aluminium"

        key_mgmt=WPA-PSK

        psk="secret"

        disabled=0

```

You will note the changes here that you suggested - group = wheel and scan ap is set to 0

now I'll start by shutting everything down - note the machine is on battery and not plugged into an ethernet port at all.

I can see that - wait a minute why is some of the spelling wpa_suplicant and some wpa_supplicant:

```

eddy run # ls /var/run/wpa*

/var/run/wpa_cli-wlan0.pid  /var/run/wpa_supplicant-wlan0.pid

/var/run/wpa_suplicant:

wlan0

eddy run # 

```

the wpa_supplicant configs call /var/run/wpa_suplicant

but that is what the directory in var/run is called.

Why this inconsistency consistently applied - maybe not so easy to have fixed????

All networking stopped and module removed:

```

eddy run # /etc/init.d/net.eth0 stop

 * Caching service dependencies ...                                       [ ok ]

 * WARNING:  net.eth0 has not yet been started.

eddy run # /etc/init.d/net.wlan0 stop

 * Stopping wlan0

 *   Bringing down wlan0

 *     Stopping dhcpcd on wlan0 ...                                       [ ok ]

 *     Shutting down wlan0 ...                                            [ ok ]

 *     Stopping wpa_cli on wlan0 ...                                      [ ok ]

 *     Stopping wpa_supplicant on wlan0 ...                               [ ok ]

eddy run # rmmod iwl4965

```

dmesg/iwconfig/ifconfig reporting:

```

wlan0: Initial auth_alg=0

wlan0: authenticate with AP 00:1b:2f:db:34:de

wlan0: Initial auth_alg=0

wlan0: authenticate with AP 00:1b:2f:db:34:de

wlan0: RX authentication from 00:1b:2f:db:34:de (alg=0 transaction=2 status=0)

wlan0: authenticated

wlan0: associate with AP 00:1b:2f:db:34:de

wlan0: authentication frame received from 00:1b:2f:db:34:de, but not in authenticate state - ignored

wlan0: authentication frame received from 00:1b:2f:db:34:de, but not in authenticate state - ignored

wlan0: RX AssocResp from 00:1b:2f:db:34:de (capab=0x431 status=0 aid=3)

wlan0: associated

wlan0: switched to short barker preamble (BSSID=00:1b:2f:db:34:de)

wlan0: WMM queue=2 aci=0 acm=0 aifs=3 cWmin=15 cWmax=1023 burst=0

wlan0: WMM queue=3 aci=1 acm=0 aifs=7 cWmin=15 cWmax=1023 burst=0

wlan0: WMM queue=1 aci=2 acm=0 aifs=2 cWmin=7 cWmax=15 burst=30

wlan0: WMM queue=0 aci=3 acm=0 aifs=2 cWmin=3 cWmax=7 burst=15

wlan0: deauthenticate(reason=3)

eddy run # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

eddy run # ifconfig

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy run # lsmod

Module                  Size  Used by

vboxdrv                56344  0 

snd_seq                43888  0 

snd_seq_device          9740  1 snd_seq

snd_pcm_oss            36640  0 

snd_mixer_oss          16128  1 snd_pcm_oss

snd_hda_intel         307352  2 

snd_pcm                59524  2 snd_pcm_oss,snd_hda_intel

snd_timer              20232  2 snd_seq,snd_pcm

snd                    42276  11 snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_hda_intel,snd_pcm,snd_timer

soundcore               9184  1 snd

snd_page_alloc         11016  2 snd_hda_intel,snd_pcm

```

OK so load the iwl4965 module:

```

iwl4965: Intel(R) Wireless WiFi Link 4965AGN driver for Linux, 1.2.23kds

iwl4965: Copyright(c) 2003-2007 Intel Corporation

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

PCI: Setting latency timer of device 0000:02:00.0 to 64

iwl4965: Detected Intel Wireless WiFi Link 4965AGN

iwl4965: Tunable channels: 11 802.11bg, 13 802.11a channels

phy4: Selected rate control algorithm 'iwl-4965-rs'

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

```

now ifconfig and iwconfig report immediate association with the local AP!

what is initialising all this without calling a net script??

For now I am happy that the association is working but I am very puzzled indeed.

```
eddy run # ps aux |grep wpa

root     16634  0.0  0.0   3920   936 ?        S<s  09:35   0:00 /sbin/wpa_supplicant -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf -W -W -B -iwlan0 -P/var/run/wpa_supplicant-wlan0.pid

root     16645  0.0  0.0   2068   416 ?        S<s  09:35   0:00 /bin/wpa_cli -a/etc/wpa_supplicant/wpa_cli.sh -p/var/run/wpa_suplicant -iwlan0 -P/var/run/wpa_cli-wlan0.pid -B

root     17256  0.0  0.0   1740   492 pts/0    R+   09:37   0:00 grep --colour=auto wpa

eddy run # 

```

Looking at the above it seems that the wpa_supplicant driver has created the /var/run/wpa_supplicant-wlan0.pid that we saw earlier in the /var/run ls but note that the wpa_cli pid is pointed to a different process! /var/run/wpa_suplicant -iwlan0 and /var/run/wpa_cli-wlan0.pid

both of which (the wpa_cli) pids are using wpa_suplicant spelling...

A typo somewhere??

Looking forward to some further investigations...

Thanks for the help getting me going!

Best Regards,

Will

----------

## dmpogo

From your very last long message, I did not get what is your problem as it stands now ?

Does wireless work ?

----------

## fuzzykiller

You need to specify a location for the control interface folder in the wpa_supplicant config.

If your system is relatively secure, I recommend using the following:

```
ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel
```

This of course needs users to be in the wheel group to connect to the socket. root can connect anyway.

I also use the wpa_gui utility for managing WLAN access from the desktop. This way, I don't have to use the strange NetworkManager.

----------

## stardotstar

OK I seem to have found a my_very_bad with respect to the spellling issue above - from the very beginning I have single 'p' in supplicant of my own accord.

OOPS

So now I can use the wpa_cli to see what is happening but I am still stuck:

what appears to be happening is to do with a couple of things:

1) restarting net.wlan0 does not really kick things off properly.

2) the only way I can associate/reassociate with an AP in the wpa_supplicant.conf is by 

rmmod iwl4965

modprobe iwl4965

this seems to call the wpa_supplicant and do an association from wpa_supplicant.conf and the net.wlan0 script ends up in  state of started.

3) I generate an error everytime I restart the net.wlan0 script:

```

eddy linux # /etc/init.d/net.wlan0 stop

 * Stopping wlan0

 *   Bringing down wlan0

 *     Shutting down wlan0 ...                                            [ ok ]

 *     Stopping wpa_cli on wlan0 ...                                      [ ok ]

 *     Stopping wpa_supplicant on wlan0 ...                               [ ok ]

eddy linux # /etc/init.d/net.wlan0 start

 * Starting wlan0

 *   Starting wpa_supplicant on wlan0 ...

ioctl[SIOCSIWAUTH]: Operation not supported                                      [ ok ]th param 4 value 0x0 - 

 *   Starting wpa_cli on wlan0 ...                                        [ ok ]

 *     Backgrounding ...

eddy linux # 

```

Having googled this io error I find lots of comment but no real explanation.

4) I find that probably due to this in wpa_supp man page:

 *man wpa_supplicant wrote:*   

> Linux wireless extensions
> 
>               In theory, any driver that supports Linux wireless extensions can be used with IEEE 802.1X (i.e., not  WPA) when using ap_scan=0 option in configuration file.
> 
> ...
> ...

 

So I expect to find that I cannot use WPA association with ap_scan=1 ??

Does this having anything to do with being unable to associate with invisible SSIDs even if the BSSID is specified??

5) have I missed something critical in configuring this combination of iwl4965 and wpa_supp -Dwext??

Thanks all

\\'

----------

## dmpogo

I use iwl4965, wpa_supplicant, WPA sites and ap_scan=1  just fine.

What I noticed is 

a) card does not always associate with the correct AP right away. In most cases it reassociates itself correctly

after ~ 30 sec. Other times wpa_cli command 'reassociate' helps. But once a spent a night on the neighbours AP,

with the card refusing to associate with my AP next room and 100% signal. Until the morning when it suddenly did 

after hibernation.

b) starting/stopping interface haphazardly (which I did a lot while trying to get configuration right) sometimes get

the driver stuck, and I have to reload iwl4965.   When this happens, "/etc/init.d/net.wlan0 status" gives 'inactive'

(which it also gives if there are no access points around, but that is never the case when I'm getting my network up).

It is useful to check if you have issues with association and an almost sure sign that the driver needs to be reloaded.

when driver is stuck,  the log gives some messages about 'trying to do something while rfkill is in progress' or so (don't remember exactly).

I have /etc/init.d/net.wlan0   start/stop launched at Fn-F6  (without reloading the module) ,  with default off on boot

and service down at hibernate.  And check for inactive, having big red message 'Please reload the driver'  when

it happens.    It seems happening a bit more often with the new iwlagn and version 2 ucode, that with

the old iwl4965 and version 1 ucode.   Usually after hibernate, seems when I press Fn-F6  too soon.Last edited by dmpogo on Tue Nov 11, 2008 6:37 am; edited 2 times in total

----------

## stardotstar

Well that is very interesting.

I am now at my home AP and association has happened without drama and I find the following:

```

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:"skink"  

          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:13:46:BD:49:16   

          Bit Rate=24 Mb/s   Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key:088C-86B4-632A-5C93-AAE3-9D7F-48F2-B069-0C13-9558-666B-20AC-4D39-EA6C-FC8F-4BAB [2]

          Link Quality=40/100  Signal level=-81 dBm  Noise level=-97 dBm

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

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

eddy stardotstar # eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:4562 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2695 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:5966798 (5.6 MiB)  TX bytes:373207 (364.4 KiB)

```

]

let's bring everything down the normal way

```

eddy stardotstar # /etc/init.d/net.wlan0 stop

 * Stopping wlan0

 *   Bringing down wlan0

 *     Stopping dhcpcd on wlan0 ...                                       [ ok ]

 *     Shutting down wlan0 ...                                            [ ok ]

 *     Stopping wpa_cli on wlan0 ...                                      [ ok ]

 *     Stopping wpa_supplicant on wlan0 ...                               [ ok ]

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=off   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:4587 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2695 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:5975116 (5.6 MiB)  TX bytes:373207 (364.4 KiB)

```

and attempt to bring it back up the normal "gentoo" way:

```

eddy stardotstar # /etc/init.d/net.wlan0 start

 * Starting wlan0

 *   Starting wpa_supplicant on wlan0 ...

ioctl[SIOCSIWAUTH]: Operation not supported                                      [ ok ]th param 4 value 0x0 - 

 *   Starting wpa_cli on wlan0 ...                                        [ ok ]

 *     Backgrounding ...

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:4587 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2695 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:5975116 (5.6 MiB)  TX bytes:373207 (364.4 KiB)

eddy stardotstar # dmesg | tail

wlan0: Initial auth_alg=0

wlan0: authenticate with AP 00:13:46:bd:49:16

wlan0: RX authentication from 00:13:46:bd:49:16 (alg=0 transaction=2 status=0)

wlan0: authenticated

wlan0: associate with AP 00:13:46:bd:49:16

wlan0: RX AssocResp from 00:13:46:bd:49:16 (capab=0x431 status=0 aid=2)

wlan0: associated

wlan0: switched to short barker preamble (BSSID=00:13:46:bd:49:16)

wlan0: deauthenticate(reason=3)

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

```

I notice that nothing has happened - the Rx/Tx values remain at 0 and invoking the net script has led to an interface in a "started" state but without any activity.

```
eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  inactive

```

switching the radio off with Fn-F11 does nothing initially but on attempting to remodprobe the module the dmesg tells us that the kill switch is active:

```

eddy stardotstar # rmmod iwl4965

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

eddy stardotstar # dmesg | tail

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

atkbd.c: Unknown key pressed (translated set 2, code 0xf6 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

atkbd.c: Unknown key released (translated set 2, code 0xf6 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

atkbd.c: Unknown key pressed (translated set 2, code 0xe2 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e062 <keycode>' to make it known.

atkbd.c: Unknown key released (translated set 2, code 0xe2 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e062 <keycode>' to make it known.

usb 5-1: USB disconnect, address 5

eddy stardotstar # modprobe iwl4965

eddy stardotstar # dmesg | tail

iwl4965: Tunable channels: 11 802.11bg, 13 802.11a channels

phy13: Selected rate control algorithm 'iwl-4965-rs'

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

iwl4965: Radio disabled by HW RF Kill switch

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

iwl4965: Radio disabled by HW RF Kill switch

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

iwl4965: Radio disabled by HW RF Kill switch

ACPI: PCI Interrupt 0000:02:00.0[A] -> GSI 17 (level, low) -> IRQ 17

iwl4965: Radio disabled by HW RF Kill switch

```

So activate the radio and go about starting the wifi

```

eddy stardotstar # rmmod iwl4965

eddy stardotstar # modprobe iwl4965

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy stardotstar # wpa_cli

wpa_cli v0.5.7

Copyright (c) 2004-2006, Jouni Malinen <jkmaline@cc.hut.fi> and contributors

This program is free software. You can distribute it and/or modify it

under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the

BSD license. See README and COPYING for more details.

Selected interface 'wlan0'

Interactive mode

> status

bssid=00:13:46:bd:49:16

ssid=skink

id=0

pairwise_cipher=TKIP

group_cipher=TKIP

key_mgmt=WPA-PSK

wpa_state=COMPLETED

ip_address=192.168.0.104

> quite

Unknown command 'quite'

> quit

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:"skink"  

          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:13:46:BD:49:16   

          Bit Rate=24 Mb/s   Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key:088C-86B4-632A-5C93-AAE3-9D7F-48F2-B069-0C13-9558-666B-20AC-4D39-EA6C-FC8F-4BAB [2]

          Link Quality=55/100  Signal level=-74 dBm  Noise level=-96 dBm

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

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

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:24 errors:0 dropped:0 overruns:0 frame:0

          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:5052 (4.9 KiB)  TX bytes:2331 (2.2 KiB)

```

All this happens without any need to call the net scripts.

```
eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  started

```

So I don't really know what to do about my setup.

Can I expect the modprobe process to call the necessary net script? Or do I need to do something else to control all this more properly?

Thanks all

\\'

----------

## dmpogo

Yes, association is done on the firnware/radio level, it has little to do with /etc/init.d/net.wlan0 script.

Except that in my case /etc/init.d/net.wlan0 stop    also switches off the radio.  

(Because of that I did not learn how to use RFKILL (unless it is used implicitly)).

Does it in your case ?

Otherwise your symptom that if there is no association reinserting the module helps is similar to mine.

Remember, iwl4965 on reinsert reloads the firmware onto the card (which is perhaps is responsible for association).

BTW, what version of ucode are you using ?

----------

## stardotstar

OK, thanks for your information and following this thread.

Here we go with some more info:

the firmware (ucode?) is:

```
eddy stardotstar # equery which iwl4965-ucode

/usr/portage/net-wireless/iwl4965-ucode/iwl4965-ucode-4.44.1.20.ebuild

```

Not sure if this is the information that allows you to see exactly which it is - I understand there is a difference between v1 and v2 - I assume since I have only just added this card I have 2...

Since it is the only one for 4965 in portage...

Ahhhhh, wait a minute :

```

eddy stardotstar # equery files iwl4965-ucode

[ Searching for packages matching iwl4965-ucode... ]

* Contents of net-wireless/iwl4965-ucode-4.44.1.20:

/lib

/lib/firmware

/lib/firmware/iwlwifi-4965-1.ucode

/usr

/usr/share

/usr/share/doc

/usr/share/doc/iwl4965-ucode-4.44.1.20

/usr/share/doc/iwl4965-ucode-4.44.1.20/README.iwlwifi-4965-ucode.bz2

```

Looks like -1 - so I must read the docs there...

I havn't come across the rfkill aspect of all this yet.  Is this something to do with the hardware switch which activates and deactivates the radio?

If you can make some more suggestions of tests that would help me nail down the situ I would appreciate it.

On a positive note I am having flawless wireless connectivity from this system whilst on the current WPA AP.

Must turn on the scan_ap feature and see if it has any effect.  I still don't understand the relationship mentioned in the man page about that

(quoted above)

Cheers,

Will

----------

## d2_racing

So your wireless is working  :Razz: 

----------

## dmpogo

 *stardotstar wrote:*   

> OK, thanks for your information and following this thread.
> 
> Here we go with some more info:
> 
> the firmware (ucode?) is:
> ...

 

it is the version 1 as it should be, the only one which will work with your driver since you are using not the latest driver (iwlagn  that comes with 2.6.27 instead of iwl4965). The version one is seen in   '1' before the 20.

However, this is not the latest version in portage. There is an update in ~amd64, its version is

iwl4965-ucode-228.57.1.21

it is somewhat hidden because emerge will show you in ~amd64 iwl4965-ucode-228.57.2.21 as the latest, which is a version 2 (see 2.21 in place of 1.21)

and will not work with your driver. So you have to manually put into package.keywords

=iwl4965-ucode-228.57.1.21  ~amd64,   

or as not recommended by prefered by me

```

ACCEPT_KEYWORDS='~amd64' emerge =iwl4965-ucode-228.57.1.21

```

----------

## dmpogo

 *stardotstar wrote:*   

> 
> 
> I havn't come across the rfkill aspect of all this yet.  Is this something to do with the hardware switch which activates and deactivates the radio?
> 
> If you can make some more suggestions of tests that would help me nail down the situ I would appreciate it.
> ...

 

RFKILL is is kernel module and capabilities in the driver for that, but I don't know how is it used. My hardware radio switch just generates ACPI event

that I handle in a script as others.  But some logs about RFKILL appear sometimes (as I said, usually when driver hangs). I'd like to understand it sometimes.

scan_ap is =1 for me now, but indeed, I did not notice much difference with scan_ap=0.  Supposedely with scan_ap=1 wpa_supplicant takes more control

over what AP is associated with, while scan_ap=0 leaves it all to the card fimware,  but the difference sometimes eludes me, since even under wpa_supplicant control association sometimes go to AP I would not expect neither from priority in configuration file, nor from the strength of the signal.

With a bit judicial settings of priorities in wpa_supplicant.conf I now have 90-95% success of a correct association right away both in the office and at home,

but hiccupps happen.  But I can say that behaviour under windows is not that much different

----------

## stardotstar

 *d2_racing wrote:*   

> So your wireless is working 

 

 *stardotstar wrote:*   

> 
> 
> On a positive note I am having flawless wireless connectivity from this system whilst on the current WPA AP.

 

All this has become more or less academic and of an interesting rather than frustrating nature due to the fact that the wireless is working - I just still can't get my head around the why and how - and am struggling to control the card when approaching new APs.  Nonetheless it has beenm a relief to be able to associate and use my work and home APs without anything more dramatic than a script that removes and reloads the module.

```

eddy stardotstar # cat /usr/local/bin/wifibounce.sh 

#!/bin/bash

# wireless bouncer for msi wind u100 with intel 4965 mini pci agn card

/etc/init.d/net.wlan0 stop

rmmod iwl4965

modprobe iwl4965

echo "Wireless restarted - module reloaded"

iwconfig

ifconfig wlan0

```

Hopefully this works and I can slave it to my wireless Fn-F11 key.

\\'

----------

## dmpogo

 *stardotstar wrote:*   

> [
> 
> ```
> 
> eddy stardotstar # cat /usr/local/bin/wifibounce.sh 
> ...

 

why would not you just do

```

/etc/init.d/net.wlan0 stop

rmmode iwl4965

modprobe iwl4965

/etc/init.d/net.wlan0 start

```

? (well, with echo if you like, I use osd_cat from xosd to flash a message across the screen)

This way it will pick up all the configuration, including wpa_supplicant or whatever

----------

## d2_racing

Why not this :

```

#!/bin/bash

if [ "$(/etc/init.d/net.wlan0 status | grep started)" ]; then

        echo "Arrêt de l’interface wlan0"

        /etc/init.d/net.wlan0 stop

        sleep 2

        echo "Déchargement du module Iwl4965"

        sleep 2

        rmmod iwl4965

        echo "Le wifi est totalement désactivé"

else

        echo "Chargement du module Iwl4965"

        modprobe iwl4965

        sleep 2

        /etc/init.d/net.wlan0 start

        echo "Wifi activé"

fi

```

----------

## dmpogo

 *d2_racing wrote:*   

> Why not this :
> 
> ```
> 
> #!/bin/bash
> ...

 

iwl4965 status can be in 3 stable states - started, stopped and inactive. You want to reload module if it is inactive as well.

So make grep on stopped, and reload the module on else.

----------

## dmpogo

I myself have Fn-F6 to toggle wireless on/off   (I prefer not to start wireless on boot automatically).

I currently do not reload the module, however

So I have among acpi handlers

```

      # Fn-F6 starts-stops wireless services (NON-standard)

      # In my network config wlan stop comes with disabling radio (don't know why)

      status=`/etc/init.d/net.wlan0 status` 

      status=${status#* status:}

      if   [ $status == started ] ; then

         /etc/init.d/net.wlan0 stop   

      elif [ $status == stopped ] ; then

           if [ `cat ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 1 ] ; then

         /etc/init.d/net.wlan0 start   

           fi

      elif [ $status == inactive ] ; then

           # This perhaps can arise if there are no AP's

           # this is why I do not restart automatically

           # May do it when understand wpa_supplicant better

           message="No AP's or WLAN may have hanged. Restart manually,

 perhaps reinserting iwl4965"

           x_info "$message" red

           logger "$message"

      fi

```

----------

## stardotstar

Fantastic dialogue guys.

First thing I note is that the reason I don't do the first suggestion you mention dmpogo:

```
/etc/init.d/net.wlan0 stop

rmmode iwl4965

modprobe iwl4965

/etc/init.d/net.wlan0 start 
```

is that the module seems to invoke the net script so I find that Ihave no need to call init.d after modprobing the driver.

The driver ends up in a started state anyway.

I like the idea of slaving it all to the Fn key and dropping it from the runlevels.

I am a little in the dark about some of the intricacies of this since the FnF11 key on my MSI U100 is able to toggle the wireless/bluetooth and the LED indicator concurs.  Because it is a dual function toggle it confuses the issue further for me otherwise perhaps I should just script the Fn key to do an rmmod/modprobe as appropriate but it switches thus:

(From an off state)

Fn-F11 lights WiFi

Fn-F11 lights BlueTooth

Fn-F11 lights both

Fn-F11 Off state

So I would have to understand how to detect the state that the machine is put into by the switch rather than the switch key activation itself?

I will try some of the other script suggestions too - thank you d2_racing

This is indeed a valuable lesson - made all the more enjoyable by the radio working while I perfect its handling.

\\'

----------

## dmpogo

 *stardotstar wrote:*   

> Fantastic dialogue guys.
> 
> First thing I note is that the reason I don't do the first suggestion you mention dmpogo:
> 
> ```
> ...

 

OK, this is because udev reacts on module hotplugging.  I have forbid udev to start net services by having

RC_PLUG_SERVICES="!*"

in /etc/conf.d/rc

so that udev does not start wireless services on boot.  (Actually it does not start any, since I like to have control

over services, but decision was triggered by desire to have full control over wireless)

 *Quote:*   

> 
> 
> I like the idea of slaving it all to the Fn key and dropping it from the runlevels.
> 
> I am a little in the dark about some of the intricacies of this since the FnF11 key on my MSI U100 is able to toggle the wireless/bluetooth and the LED indicator concurs.  Because it is a dual function toggle it confuses the issue further for me otherwise perhaps I should just script the Fn key to do an rmmod/modprobe as appropriate but it switches thus:
> ...

 

I have bluetooth on Fn-F5 (which seems standard on Thinkpads, it has that key carrying wireless icon) but wlan separately on Fn-F6.

I did this separtation  since I have no bluetooth devices right now (more over I did not even yet configured bluetooth service properly),

 so it is always off, while wireless is being up and down frequently.

As sort of understood that Fn-F11 you have is not a hardware switch (since you are speaking about some script ), but just sends ACPI events ?   In this case you could program it the way you wish with the help of, say, acpid.   If it is governed by hardware (bios) then you can still put your wireless handling on another Fn combination with acpid, and leave Fn-F11 for hardcore hardware switching.[/quote]

----------

## stardotstar

Hi,

No I believe that what I mean is that the FnF11 is a hardware switch since there is no acpi event or such when it is activated:

```
wlan0: Initial auth_alg=0

wlan0: authenticate with AP 00:13:46:bd:49:16

wlan0: RX authentication from 00:13:46:bd:49:16 (alg=0 transaction=2 status=0)

wlan0: authenticated

wlan0: associate with AP 00:13:46:bd:49:16

wlan0: RX AssocResp from 00:13:46:bd:49:16 (capab=0x431 status=0 aid=2)

wlan0: associated

wlan0: switched to short barker preamble (BSSID=00:13:46:bd:49:16)

iwl4965: Radio Frequency Kill Switch is On:

Kill switch must be turned off for wireless networking to work.

atkbd.c: Unknown key pressed (translated set 2, code 0xf6 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

atkbd.c: Unknown key released (translated set 2, code 0xf6 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

atkbd.c: Unknown key pressed (translated set 2, code 0xe2 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e062 <keycode>' to make it known.

atkbd.c: Unknown key released (translated set 2, code 0xe2 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e062 <keycode>' to make it known.

hub 1-0:1.0: unable to enumerate USB device on port 7

usb 5-1: new full speed USB device using uhci_hcd and address 2

usb 5-1: configuration #1 chosen from 1 choice

usb 5-1: New USB device found, idVendor=0db0, idProduct=a97a

usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0

```

above we can see the wlan0 in the up and associated state and then I pressed the FnF11 switching the LEDs on the machine to indicate Bluetooth only mode (Wifi Unlights) and therefore we learn that:

atkbd.c is reacting to a series of key presses even though only one was physically initiated.  

The USB bluetooth device is brought online as the radio is killed.

a subsequent pressing gives:

```

wlan0: No ProbeResp from current AP 00:13:46:bd:49:16 - assume out of range

iwl4965: Error sending REPLY_RXON_ASSOC: iwl4965_enqueue_hcmd failed: -5

iwl4965: Error sending REPLY_RXON_ASSOC: iwl4965_enqueue_hcmd failed: -5

hci_cmd_task: hci0 command tx timeout

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

iwl4965: Error sending REPLY_STATISTICS_CMD: iwl4965_enqueue_hcmd failed: -5

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

wlan0: disassociate(reason=3)

atkbd.c: Unknown key pressed (translated set 2, code 0xf6 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

atkbd.c: Unknown key released (translated set 2, code 0xf6 on isa0060/serio0).

atkbd.c: Use 'setkeycodes e076 <keycode>' to make it known.

wlan0: disassociate(reason=3)

```

at which point the Bluetooth and wifi LEDs are lit.

The state of the wifi has not returned to normal however:

```

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:22473 errors:0 dropped:0 overruns:0 frame:0

          TX packets:9143 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:24000104 (22.8 MiB)  TX bytes:960576 (938.0 KiB)

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:"skink"  

          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:13:46:BD:49:16   

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:22473 errors:0 dropped:0 overruns:0 frame:0

          TX packets:9143 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:24000104 (22.8 MiB)  TX bytes:960576 (938.0 KiB)

```

The previous association with my Skink AP is still present but the net script has not been invoked to give wlan0 an IP address again?

Reinvoking the net.script does not help - it is somewhere in firmware so we need to reload the driver.

(To simplify this I have changed my wifiscript above to be only rmmod and modprobe...

```

eddy stardotstar # vi /usr/local/bin/wifibounce.sh 

eddy stardotstar # /usr/local/bin/wifibounce.sh 

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  inactive

eddy stardotstar # /etc/init.d/net.wlan0 restart

 * Stopping wlan0

 *   Bringing down wlan0

 *     Shutting down wlan0 ...                                            [ ok ]

 *     Stopping wpa_cli on wlan0 ...                                      [ ok ]

 *     Stopping wpa_supplicant on wlan0 ...                               [ ok ]

 * Starting wlan0

 *   Starting wpa_supplicant on wlan0 ...

ioctl[SIOCSIWAUTH]: Operation not supported                                      [ ok ]th param 4 value 0x0 - 

 *   Starting wpa_cli on wlan0 ...                                        [ ok ]

 *     Backgrounding ...

eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  inactive

eddy stardotstar # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  

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

          Tx-Power=27 dBm   

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   

          Encryption key: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

eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  inactive

eddy stardotstar # vi /usr/local/bin/wifibounce.sh 

eddy stardotstar # /usr/local/bin/wifibounce.sh 

 * Stopping wlan0

 *   Bringing down wlan0

 *     Shutting down wlan0 ...                                            [ ok ]

 *     Stopping wpa_cli on wlan0 ...                                      [ ok ]

 *     Stopping wpa_supplicant on wlan0 ...                               [ ok ]

eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  inactive

eddy stardotstar # wpa_cli

wpa_cli v0.5.7

Copyright (c) 2004-2006, Jouni Malinen <jkmaline@cc.hut.fi> and contributors

This program is free software. You can distribute it and/or modify it

under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the

BSD license. See README and COPYING for more details.

Selected interface 'wlan0'

Interactive mode

> status

bssid=00:13:46:bd:49:16

ssid=skink

id=0

pairwise_cipher=TKIP

group_cipher=TKIP

key_mgmt=WPA-PSK

wpa_state=COMPLETED

> quit

eddy stardotstar # /etc/init.d/net.wlan0 status

 * status:  starting

eddy stardotstar # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1f:3b:69:ff:29  

          inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:48 errors:0 dropped:0 overruns:0 frame:0

          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:8123 (7.9 KiB)  TX bytes:2691 (2.6 KiB)

```

it does not work until I make my wifibounce.sh STOP the net.script first then unprobe and probe the driver.

Clearly I need to invoke this script when the wifi key is pressed.  Therefore it will always unplug and plug the driver and only if the kill switch is disabled will it work ...

\\'

----------

## dmpogo

Well, different hardware is different. On my thinkpad even hard (also to toggle) switch on the back of the laptop kills radio even temeprarily (it comes back in 5-10 sec) but generates ACPI event  :Smile: 

----------

