summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-02-26 10:42:04 +0100
committerJames Rayner <james@archlinux.org>2009-02-26 10:42:04 +0100
commit9997a323581c7152e67830690d80d213d7c0d2e2 (patch)
tree80cf66634917464880ef78abd22a216b2d67f808
parentc2838593ab2cc04cb702042066d912f1bcbcc201 (diff)
downloadnetctl-9997a323581c7152e67830690d80d213d7c0d2e2.tar.gz
netctl-9997a323581c7152e67830690d80d213d7c0d2e2.tar.xz
Update and re-arrange examples, update wireless quirk options, stop
using deprecated sys interface
-rw-r--r--examples/deprecated/ethernet-static.example8
-rw-r--r--examples/deprecated/ethernet.example5
-rw-r--r--examples/deprecated/wep-static.example12
-rw-r--r--examples/deprecated/wpa.example8
-rw-r--r--examples/ethernet-dhcp4
-rw-r--r--examples/ethernet-dhcp.example3
-rwxr-xr-xexamples/ethernet-iproute (renamed from examples/ethernet-iproute.example)1
-rw-r--r--examples/ethernet-static (renamed from examples/ethernet-static.example)1
-rw-r--r--examples/loopback.example5
-rw-r--r--examples/ppp (renamed from examples/ppp.example)0
-rw-r--r--examples/wireless-dbus7
-rw-r--r--examples/wireless-wep (renamed from examples/deprecated/wep.example)3
-rw-r--r--examples/wireless-wep-string-key (renamed from examples/deprecated/wep-string-key.example)5
-rw-r--r--examples/wireless-wpa7
-rw-r--r--examples/wireless.example7
-rw-r--r--src/connections/ethernet10
-rw-r--r--src/connections/wireless75
-rw-r--r--src/wireless1
18 files changed, 66 insertions, 96 deletions
diff --git a/examples/deprecated/ethernet-static.example b/examples/deprecated/ethernet-static.example
deleted file mode 100644
index b50cf36..0000000
--- a/examples/deprecated/ethernet-static.example
+++ /dev/null
@@ -1,8 +0,0 @@
-CONNECTION="ethernet"
-DESCRIPTION="A less basic ethernet profile, using static configuration"
-INTERFACE=eth0
-IP="static"
-IFOPTS="192.168.1.23 netmask 255.255.255.0 broadcast 192.168.1.255"
-GATEWAY="192.168.1.1"
-DNS1=192.168.1.1
-DNS2=dns1.dreamhost.com
diff --git a/examples/deprecated/ethernet.example b/examples/deprecated/ethernet.example
deleted file mode 100644
index 2db6072..0000000
--- a/examples/deprecated/ethernet.example
+++ /dev/null
@@ -1,5 +0,0 @@
-CONNECTION="ethernet"
-DESCRIPTION="A very basic ethernet profile, using dhcp"
-INTERFACE=eth0
-IP="dhcp"
-DHCP_TIMEOUT=10
diff --git a/examples/deprecated/wep-static.example b/examples/deprecated/wep-static.example
deleted file mode 100644
index 4474ba7..0000000
--- a/examples/deprecated/wep-static.example
+++ /dev/null
@@ -1,12 +0,0 @@
-CONNECTION="wireless"
-DESCRIPTION="A wep encrypted wireless connection using static ip"
-INTERFACE=wlan0
-SCAN="yes"
-SECURITY="wep"
-ESSID="MyNetwork"
-KEY="1234567890"
-IP="static"
-IFOPTS="192.168.1.23 netmask 255.255.255.0 broadcast 192.168.1.255"
-GATEWAY="192.168.1.1"
-DNS1=192.168.1.1
-DNS2=dns1.dreamhost.com
diff --git a/examples/deprecated/wpa.example b/examples/deprecated/wpa.example
deleted file mode 100644
index f165945..0000000
--- a/examples/deprecated/wpa.example
+++ /dev/null
@@ -1,8 +0,0 @@
-CONNECTION="wireless"
-INTERFACE=wlan0
-SCAN="yes"
-SECURITY="wpa"
-ESSID="mynetwork"
-KEY="SomePasskey"
-IP="dhcp"
-TIMEOUT=20
diff --git a/examples/ethernet-dhcp b/examples/ethernet-dhcp
new file mode 100644
index 0000000..78edfc4
--- /dev/null
+++ b/examples/ethernet-dhcp
@@ -0,0 +1,4 @@
+CONNECTION="ethernet-iproute"
+DESCRIPTION="A basic dhcp ethernet connection using iproute"
+INTERFACE="eth0"
+IP="dhcp"
diff --git a/examples/ethernet-dhcp.example b/examples/ethernet-dhcp.example
deleted file mode 100644
index 6f80a9e..0000000
--- a/examples/ethernet-dhcp.example
+++ /dev/null
@@ -1,3 +0,0 @@
-CONNECTION="ethernet-iproute"
-INTERFACE="eth0"
-IP="dhcp"
diff --git a/examples/ethernet-iproute.example b/examples/ethernet-iproute
index a368707..6ac20e1 100755
--- a/examples/ethernet-iproute.example
+++ b/examples/ethernet-iproute
@@ -1,4 +1,5 @@
CONNECTION="ethernet-iproute"
+DESCRIPTION="A more versatile static ethernet connection using iproute"
INTERFACE="eth0"
IP="static"
# Any valid iproute command can be placed in this array
diff --git a/examples/ethernet-static.example b/examples/ethernet-static
index ad0c9b4..50756bc 100644
--- a/examples/ethernet-static.example
+++ b/examples/ethernet-static
@@ -1,4 +1,5 @@
CONNECTION="ethernet-iproute"
+DESCRIPTION="A basic static ethernet connection using iproute"
INTERFACE="eth0"
IP="static"
ADDR="192.168.1.23"
diff --git a/examples/loopback.example b/examples/loopback.example
deleted file mode 100644
index e9dcca9..0000000
--- a/examples/loopback.example
+++ /dev/null
@@ -1,5 +0,0 @@
-CONNECTION="ethernet"
-DESCRIPTION="A very basic ethernet profile, using dhcp"
-INTERFACE=lo
-IP="static"
-IFOPTS="127.0.0.1"
diff --git a/examples/ppp.example b/examples/ppp
index ca8d167..ca8d167 100644
--- a/examples/ppp.example
+++ b/examples/ppp
diff --git a/examples/wireless-dbus b/examples/wireless-dbus
new file mode 100644
index 0000000..7c00349
--- /dev/null
+++ b/examples/wireless-dbus
@@ -0,0 +1,7 @@
+CONNECTION="wireless-dbus"
+DESCRIPTION="A simple WPA connection using wpa_supplicant via dbus"
+INTERFACE="wlan0"
+SECURITY="wpa"
+ESSID="MyNetwork"
+KEY="Wireless Key"
+IP="dhcp"
diff --git a/examples/deprecated/wep.example b/examples/wireless-wep
index 4dad0e1..ed670d0 100644
--- a/examples/deprecated/wep.example
+++ b/examples/wireless-wep
@@ -1,7 +1,6 @@
CONNECTION="wireless"
DESCRIPTION="A simple WEP encrypted wireless connection"
-INTERFACE=wlan0
-SCAN="yes"
+INTERFACE="wlan0"
SECURITY="wep"
ESSID="MyNetwork"
KEY="1234567890"
diff --git a/examples/deprecated/wep-string-key.example b/examples/wireless-wep-string-key
index 3118658..42c3210 100644
--- a/examples/deprecated/wep-string-key.example
+++ b/examples/wireless-wep-string-key
@@ -1,8 +1,7 @@
CONNECTION="wireless"
DESCRIPTION="A simple WEP encrypted wireless connection"
-INTERFACE=wlan0
-SCAN="yes"
+INTERFACE="wlan0"
SECURITY="wep"
ESSID="MyNetwork"
-KEY="s:Some string key"
+KEY="s:Wireless Key"
IP="dhcp"
diff --git a/examples/wireless-wpa b/examples/wireless-wpa
new file mode 100644
index 0000000..0f5016d
--- /dev/null
+++ b/examples/wireless-wpa
@@ -0,0 +1,7 @@
+CONNECTION="wireless"
+DESCRIPTION="A simple WPA encrypted wireless connection"
+INTERFACE="wlan0"
+SECURITY="wpa"
+ESSID="MyNetwork"
+KEY="WirelessKey"
+IP="dhcp"
diff --git a/examples/wireless.example b/examples/wireless.example
deleted file mode 100644
index 077d9df..0000000
--- a/examples/wireless.example
+++ /dev/null
@@ -1,7 +0,0 @@
-CONNECTION="wireless-dbus"
-INTERFACE=ipw0
-SECURITY="yes"
-ESSID="Your ESSID"
-KEY="Your Key"
-# Below can be any valid ethernet option. See ethernet-*.example
-IP="dhcp"
diff --git a/src/connections/ethernet b/src/connections/ethernet
index ad9e870..9ec27fb 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -11,13 +11,19 @@ ethernet_up() {
fi
fi
+ # Connection check
if ip link show "$INTERFACE"|grep -q "NO-CARRIER"; then
err_append "no connection available"
return 1
fi
ifconfig "$INTERFACE" up
-
+
+ # Some hardware is not immediately ready after ifconfig up
+ while ip link show $INTERFACE|grep -q "state UNKNOWN"; do
+ sleep 0.5
+ done
+
if checkyesno "${AUTH8021X:-no}"; then
. "${SUBR_DIR}"/8021x
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
@@ -116,7 +122,7 @@ ethernet_down() {
esac
ifconfig $INTERFACE 0.0.0.0
- case "$CONNECTION" in
+ case "$CONNECTION" in # Keep interface up for wireless
ethernet|ethernet-old)
quirk "nodown" || ifconfig $INTERFACE down
;;
diff --git a/src/connections/wireless b/src/connections/wireless
index 27df7ca..c614c6f 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -7,28 +7,33 @@ wireless_up() {
. ${SUBR_DIR}/wireless
- if [[ ! -d /sys/class/net/$INTERFACE/wireless ]]; then
+ if [[ ! -d /sys/class/net/$INTERFACE/phy80211 ]]; then
err_append "$INTERFACE is not a valid wireless interface."
return 1
fi
-
- # Required by atheros and others (mac80211?) to enable device
- ifconfig $INTERFACE up
-
- # Hack that has been required by some broadcom
- quirk "prescan" && iwlist $INTERFACE scan &> /dev/null
-
- # Required by ipw3945 to properly re-associate
- quirk "preessid" && eval "iwconfig $INTERFACE mode managed essid \"$ESSID\""
# Kill any lingering wpa_supplicants.
if [[ -f /var/run/wpa_supplicant_$INTERFACE.pid ]]; then
kill $(cat /var/run/wpa_supplicant_$INTERFACE.pid)
fi
- # Default scan off as it won't see hidden networks and some hardware's scanning is dodgy
- [[ ! "$SCAN" ]] && SCAN="no"
- if checkyesno $SCAN; then
+ # Most drivers (mac80211) need mode set before device is brought up
+ # Drivers generally default to managed, but set this to be sure.
+ if [[ "$(iwgetid -sm $INTERFACE)" -ne "Managed" ]]; then
+ iwconfig $INTERFACE mode managed
+ fi
+
+ ifconfig $INTERFACE up
+
+ # Some hardware is not immediately ready after ifconfig up
+ while ip link show $INTERFACE|grep -q "state UNKNOWN"; do
+ sleep 0.5
+ done
+
+ quirk "prescan" && iwlist $INTERFACE scan &> /dev/null # bcm43xx
+ quirk "preessid" && eval "iwconfig $INTERFACE mode managed essid \"$ESSID\"" # ipw3945
+
+ if checkyesno ${SCAN-no}; then
if ! find_essid $INTERFACE "$ESSID"; then
err_append "Network not present."
return 1
@@ -36,44 +41,33 @@ wireless_up() {
fi
# Manually set iwconfig options
- if [[ "$IWCONFIG" ]]; then
- iwconfig $INTERFACE $IWCONFIG
- fi
+ [[ "$IWCONFIG" ]] && iwconfig $INTERFACE $IWCONFIG
case $SECURITY in
wep|none)
- # 'none' security uses iwconfig, like wep, so use same code, minus keysetting.
- # Use sane default if no alternative is specified
- if [[ "$SECURITY" = "wep" && "$WEP_OPTS" = "" ]]; then
- WEP_OPTS="mode managed essid \"$ESSID\" key $KEY"
- elif [[ "$SECURITY" = "none" && "$WEP_OPTS" = "" ]]; then
- WEP_OPTS="mode managed essid \"$ESSID\""
+ # 'none' uses iwconfig like wep. Use sane default if WEP_OPTS=""
+ if [[ "$SECURITY" = "wep" ]]; then
+ WEP_OPTS="essid \"$ESSID\" key $KEY"
+ elif [[ "$SECURITY" = "none" ]]; then
+ WEP_OPTS="essid \"$ESSID\""
fi
-
- # Add wierd quirk for some Atheros in response to FS#10585
- quirk "predown" && ifconfig $INTERFACE down
+
+ quirk "predown" && ifconfig $INTERFACE down # madwifi FS#10585
if ! eval iwconfig $INTERFACE $WEP_OPTS; then
err_append "Could not set wireless configuration."
return 1
fi
- quirk "postsleep" && sleep 1
- quirk "postscan" && sleep 1 && iwlist $INTERFACE scan &>/dev/null
- quirk "predown" && ifconfig $INTERFACE up
-
- # Many devices appear to not associate until DHCP is run.
- if quirk "acheck"; then
- wep_check $INTERFACE $TIMEOUT|| return 1
- else
- sleep ${TIMEOUT:-15}
- fi
+ quirk "predown" && ifconfig $INTERFACE up # madwifi FS#10585
+
+ wep_check $INTERFACE $TIMEOUT||return 1
;;
wpa)
. ${SUBR_DIR}/8021x
# Quirk for broken drivers... http://bbs.archlinux.org/viewtopic.php?id=36384
- quirk "wpaessid" && eval iwconfig $INTERFACE mode managed essid "\"$ESSID\""
+ quirk "wpaessid" && eval iwconfig $INTERFACE essid "\"$ESSID\""
local WPA_CONF="/tmp/wpa.${1// /}" # substitute spaces out
echo "ctrl_interface=/var/run/wpa_supplicant" >> $WPA_CONF
@@ -89,15 +83,14 @@ wireless_up() {
fi
# Connect!
- [[ "$WPA_OPTS" == "" ]] && WPA_OPTS="-Dwext"
+ [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1
wpa_check $INTERFACE $TIMEOUT || return 1
;;
wpa-config)
- . ${SUBR_DIR}/8021x
- # If user hasnt defined one, use stock config.
- [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
- [[ "$WPA_OPTS" == "" ]] && WPA_OPTS="-Dwext"
+ . ${SUBR_DIR}/8021x
+ [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults
+ [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1
wpa_check $INTERFACE $TIMEOUT || return 1
;;
diff --git a/src/wireless b/src/wireless
index 405b86b..62454e4 100644
--- a/src/wireless
+++ b/src/wireless
@@ -59,3 +59,4 @@ list_networks()
echo $essids
return 0
}
+# vim: set ts=4 et sw=4 ft=sh: