# madwifi, wpa_supplicant problem

## madnbri

Hello,

I browsed internet a lot to set up my wireless connection, but nothing is fixed.

```
# lspci|grep Wireless

02:00.0 Ethernet controller: Atheros Communications Inc. AR5001 Wireless Network Adapter (rev 01)

# lspci -v -s 02:00.0

02:00.0 Ethernet controller: Atheros Communications Inc. AR5001 Wireless Network Adapter (rev 01)

   Subsystem: Device 1a3b:1026

   Flags: bus master, fast devsel, latency 0, IRQ 16

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

   Capabilities: [40] Power Management version 2

   Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit-

   Capabilities: [60] Express Legacy Endpoint, MSI 00

   Capabilities: [90] MSI-X: Enable- Count=1 Masked-

   Capabilities: [100] Advanced Error Reporting

   Capabilities: [140] Virtual Channel

   Kernel driver in use: ath5k
```

I've already installed wpa_supplicant and tried to install madwifi-ng, but failed to compile

```
...

>>> Failed to emerge net-wireless/madwifi-ng-0.9.4.4165.20110816, Log file:

>>>  '/var/tmp/portage/net-wireless/madwifi-ng-0.9.4.4165.20110816/temp/build.log'

 * Messages for package net-wireless/madwifi-ng-0.9.4.4165.20110816:

 * ERROR: net-wireless/madwifi-ng-0.9.4.4165.20110816 failed (compile phase):

 *   Unable to emake HOSTCC=i686-pc-linux-gnu-gcc CROSS_COMPILE=i686-pc-linux-gnu- LDFLAGS=  KERNELPATH=/lib/modules/3.2.1-gentoo-r2/build all

 * 

 * Call stack:

 *     ebuild.sh, line   85:  Called src_compile

 *   environment, line 2917:  Called linux-mod_src_compile

 *   environment, line 2155:  Called die

 * The specific snippet of code:

 *               eval "emake HOSTCC=\"$(tc-getBUILD_CC)\"          CROSS_COMPILE=${CHOST}-                   LDFLAGS=\"$(get_abi_LDFLAGS)\"                   ${BUILD_FIXES}       ${BUILD_PARAMS}                   ${BUILD_TARGETS} " || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}";

 * 

...
```

I tried to understand setup in this document http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4, but failed.

My AP config is:

```
Security Type: WPA-PSK/WPA2-PSK

Security Option: Automatic (WPA-PSK or WPA2-PSK)

Encription: Automatic (TKIP or AES)

PSK Passphrase: myverysecretpass
```

If you need more info, please ask. Guide is chaotic, therefore I do not know which setting is good, incorrect, isn't exist, nothing... I've got confused.  :Sad: 

----------

## Gusar

madwifi is completely outdated, you don't need it, you already have the correct driver - ath5k. And wpa_supplicant should be using either -Dwext or -Dnl80211. Then, you have a simple WPA-PSK network.

----------

## madnbri

 *Gusar wrote:*   

> madwifi is completely outdated, you don't need it, you already have the correct driver - ath5k. And wpa_supplicant should be using either -Dwext or -Dnl80211. Then, you have a simple WPA-PSK network.

 

OK. I changed my configs.

/etc/conf.d/net:

```
# cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /usr/share/doc/openrc*/net.example* and save your configuration

# in /etc/conf.d/net (this file :]!).

dns_domain_lo="stor3"

config_eth0="dhcp"

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dwext"
```

My /etc/wpa_supplicant/wpa_supplicant.conf:

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

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

fast_reauth=1

network={

   ssid="MYSSID"

   scan_ssid=1

   proto=WPA2

   key_mgmt=WPA-PSK

   psk="myverysecretpass"

   priority=2

}
```

I do not know how to add it to bootup, but at first:

```
# wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf

Trying to associate with 00:21:27:db:f1:20 (SSID='MYSSID' freq=2437 MHz)

Associated with 00:21:27:db:f1:20

WPA: Key negotiation completed with 00:21:27:db:f1:20 [PTK=CCMP GTK=TKIP]

CTRL-EVENT-CONNECTED - Connection to 00:21:27:db:f1:20 completed (auth) [id=0 id_str=]

WPA: Group rekeying completed with 00:21:27:db:f1:20 [GTK=TKIP]

^CCTRL-EVENT-TERMINATING - signal 2 received
```

 It doesn't work. I still do not understand documentation.  :Sad: Last edited by madnbri on Wed Mar 07, 2012 7:36 am; edited 1 time in total

----------

## Gusar

It does work, you were connected. All you then need to do is start a dhcp client.

If you want the network to start automatically at boot, just make a symlink /etc/init.d/net.wlan0 -> /etc/init.d/net.lo

----------

## madnbri

 *Gusar wrote:*   

> It does work, you were connected. All you then need to do is start a dhcp client.
> 
> If you want the network to start automatically at boot, just make a symlink /etc/init.d/net.wlan0 -> /etc/init.d/net.lo

 

```
echo "config_wlan0=\"dhcp\"" >> /etc/conf.d/net
```

Yes! It works, but not so good as I want. It was the first step only.

This is a laptop and has got two network devices. The first one is a wired ethernet card and the second one is a wireless.

I usually use the wireless card to connect to the network.

What I need?

```
If my wired card doesn't connected:

  do

     wired do not try to connect

     instead of I wrote before

       if it is possible: try to connect to my own WPA-PSK authorized network

       else if: other (not closed or ask pass) netwok is detected, try to connect to that

       else: give up

  done

else: try to connect with wired card
```

----------

## BillWho

madnbri,

I don't know if this will help or not, but I have something close where if I have my wired card plugged in and no wifi dongle eth0 starts otherwise if there's no hard wire and the wifi dongle is plugged in the wifi starts.  This probably isn't the best method, but it's working for me so far. I tried using preup() as explained in /usr/share/doc/openrc-0.9.9.2/net.example.bz2, but it didn't seem to work.

metric_wlan0="0"

metric_eth0="1"

sleep_scan_wlan0="6"

#

modules="wpa_supplicant"

wpa_supplicant_wlan0="-Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf"

wpa_timeout_wlan0=60

config_wlan0="192.168.1.101/24 brd 192.168.1.255"

routes_wlan0="default via 192.168.1.1"

#

config_eth0="192.168.1.101/24 brd 192.168.1.255"

routes_eth0="default via 192.168.1.1"

dns_servers="167.206.212.129 167.206.212.130

Also emerge sys-apps/ifplugd and set rc_depend_strict="NO" in /etc/rc.conf. There's no configuration necessary for ifplugd. 

Good luck    :Cool: 

----------

## madnbri

 *BillWho wrote:*   

> madnbri,
> 
> I don't know if this will help or not, but I have something close where if I have my wired card plugged in and no wifi dongle eth0 starts otherwise if there's no hard wire and the wifi dongle is plugged in the wifi starts.  This probably isn't the best method, but it's working for me so far. I tried using preup() as explained in /usr/share/doc/openrc-0.9.9.2/net.example.bz2, but it didn't seem to work.
> 
> metric_wlan0="0"
> ...

 

I merged sys-apps/ifplugd and kept my config and it works, but not fine. There is no scanninng option.  :Sad: 

----------

