summaryrefslogtreecommitdiff
path: root/net.Linux
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-10 10:33:44 +0000
committerRoy Marples <roy@marples.name>2007-04-10 10:33:44 +0000
commit0c98067d57606c59866e9ff35f2a6aedaaedaf76 (patch)
tree6cb5a27b2e26d8c669770b3ff3b2516ff2e3db98 /net.Linux
parentc5ddc6ef74460f72ea56350c6ff002c9630f6552 (diff)
downloadopenrc-0c98067d57606c59866e9ff35f2a6aedaaedaf76.tar.gz
openrc-0c98067d57606c59866e9ff35f2a6aedaaedaf76.tar.bz2
openrc-0c98067d57606c59866e9ff35f2a6aedaaedaf76.tar.xz
Misc network fixes so we work on my stable server. Splash plugin removed as splashtuils-1.4 now ships with its own.
Diffstat (limited to 'net.Linux')
-rw-r--r--net.Linux/ifconfig.sh36
-rw-r--r--net.Linux/iproute2.sh38
-rw-r--r--net.Linux/iwconfig.sh55
-rw-r--r--net.Linux/macchanger.sh88
-rw-r--r--net.Linux/tuntap.sh6
5 files changed, 74 insertions, 149 deletions
diff --git a/net.Linux/ifconfig.sh b/net.Linux/ifconfig.sh
index 637c42f..0b0af97 100644
--- a/net.Linux/ifconfig.sh
+++ b/net.Linux/ifconfig.sh
@@ -6,22 +6,6 @@ ifconfig_depend() {
provide interface
}
-_get_mac_address() {
- local mac=$(LC_ALL=C ifconfig "${IFACE}" | \
- sed -n -e 's/.* HWaddr \(..:..:..:..:..:..\).*/\1/p')
-
-
- case "${mac}" in
- 00:00:00:00:00:00) ;;
- 44:44:44:44:44:44) ;;
- FF:FF:FF:FF:FF:FF) ;;
- "") ;;
- *) echo "${mac}"; return 0 ;;
- esac
-
- return 1
-}
-
_up() {
ifconfig "${IFACE}" up
}
@@ -54,6 +38,26 @@ _is_wireless() {
grep -Eq "^[[:space:]]*${IFACE}:[[:space:]]+" /proc/net/wireless
}
+_get_mac_address() {
+ local mac=$(LC_ALL=C ifconfig "${IFACE}" | \
+ sed -n -e 's/.* HWaddr \(..:..:..:..:..:..\).*/\1/p')
+
+
+ case "${mac}" in
+ 00:00:00:00:00:00) ;;
+ 44:44:44:44:44:44) ;;
+ FF:FF:FF:FF:FF:FF) ;;
+ "") ;;
+ *) echo "${mac}"; return 0 ;;
+ esac
+
+ return 1
+}
+
+_set_mac_address() {
+ ifconfig "${IFACE}" hw ether "$1"
+}
+
_get_inet_address() {
set -- $(LC_ALL=C ifconfig "${IFACE}" |
sed -n -e 's/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1 \2/p')
diff --git a/net.Linux/iproute2.sh b/net.Linux/iproute2.sh
index 1b1b70f..ccab1db 100644
--- a/net.Linux/iproute2.sh
+++ b/net.Linux/iproute2.sh
@@ -7,21 +7,6 @@ iproute2_depend() {
after ifconfig
}
-_get_mac_address() {
- local mac=$(LC_ALL=C ip link show "${IFACE}" | sed -n \
- -e 'y/abcdef/ABCDEF/' \
- -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
-
- case "${mac}" in
- 00:00:00:00:00:00) ;;
- 44:44:44:44:44:44) ;;
- FF:FF:FF:FF:FF:FF) ;;
- "") ;;
- *) echo "${mac}"; return 0 ;;
- esac
-
- return 1
-}
_up() {
ip link set up dev "${IFACE}"
@@ -55,6 +40,26 @@ _is_wireless() {
grep -Eq "^[[:space:]]*${IFACE}:[[:space:]]+" /proc/net/wireless
}
+_get_mac_address() {
+ local mac=$(LC_ALL=C ip link show "${IFACE}" | sed -n \
+ -e 'y/abcdef/ABCDEF/' \
+ -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
+
+ case "${mac}" in
+ 00:00:00:00:00:00) ;;
+ 44:44:44:44:44:44) ;;
+ FF:FF:FF:FF:FF:FF) ;;
+ "") ;;
+ *) echo "${mac}"; return 0 ;;
+ esac
+
+ return 1
+}
+
+_set_mac_address() {
+ ip link set address "$1" dev "${IFACE}"
+}
+
_get_inet_addresses() {
LC_ALL=C ip -family inet addr show "${IFACE}" | \
sed -n -e 's/.*inet \([^ ]*\).*/\1/p'
@@ -160,8 +165,9 @@ iproute2_pre_start() {
metric=1000
ebegin "Creating tunnel ${IFVAR}"
- ip tunnel add "${tunnel}"
+ ip tunnel add ${tunnel} name "${IFACE}"
eend $? || return 1
+ _up
fi
return 0
diff --git a/net.Linux/iwconfig.sh b/net.Linux/iwconfig.sh
index bed13a5..6dfbc98 100644
--- a/net.Linux/iwconfig.sh
+++ b/net.Linux/iwconfig.sh
@@ -3,7 +3,7 @@
# Many thanks to all the people in the Gentoo forums for their ideas and
# motivation for me to make this and keep on improving it
-_config_vars="$_config_vars essid mode associate_timeout sleep_scan preferred_aps blacklist_aps"
+_config_vars="$_config_vars ssid mode associate_timeout sleep_scan preferred_aps blacklist_aps"
iwconfig_depend() {
program /sbin/iwconfig
@@ -155,8 +155,8 @@ iwconfig_setup_specific() {
fi
# Then set the SSID
- if ! eval iwconfig "${IFACE}" essid "${SSID}" ; then
- eerror "${IFACE} does not support setting SSID to \"${ESSID}\""
+ if ! iwconfig "${IFACE}" essid "${SSID}" ; then
+ eerror "${IFACE} does not support setting SSID to \"${SSID}\""
return 1
fi
@@ -187,7 +187,7 @@ iwconfig_wait_for_association() {
# Use sysfs if we can
if [ -e /sys/class/net/"${IFACE}"/carrier ] ; then
if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ] ; then
- # Double check we have an essid. This is mainly for buggy
+ # Double check we have an ssid. This is mainly for buggy
# prism54 drivers that always set their carrier on :/
[ -n "$(iwgetid --raw "${IFACE}")" ] && return 0
fi
@@ -220,7 +220,7 @@ iwconfig_associate() {
if [ "${SSID}" = "any" ]; then
iwconfig "${IFACE}" ap any 2>/dev/null
- unset ESSIDVAR
+ unset SSIDVAR
else
SSIDVAR=$(_shell_var "${SSID}")
key="$(iwconfig_get_wep_key "${mac}")"
@@ -243,9 +243,9 @@ iwconfig_associate() {
[ "${key}" != "off" ] && w="$(iwconfig_get_wep_status "${iface}")"
fi
- if ! eval iwconfig "${IFACE}" essid "${SSID}" ; then
+ if ! iwconfig "${IFACE}" essid "${SSID}" ; then
if [ "${SSID}" != "any" ] ; then
- ewarn "${IFACE} does not support setting ESSID to \"${SSID}\""
+ ewarn "${IFACE} does not support setting SSID to \"${SSID}\""
fi
fi
@@ -315,7 +315,7 @@ iwconfig_scan() {
if [ -z "${scan}" ] ; then
ewarn "${iface} does not support scanning"
eoutdent
- eval x=\$adhoc_essid_${IFVAR}
+ eval x=\$adhoc_ssid_${IFVAR}
[ -n "${x}" ] && return 0
if [ -n "${preferred_aps}" ] ; then
[ "${associate_order}" = "forcepreferred" ] || \
@@ -328,9 +328,9 @@ iwconfig_scan() {
eerror "or hardcode the SSID to \"any\" and let the driver find an Access Point"
eerror " ssid_${IFVAR}=\"any\""
eerror "or configure defaulting to Ad-Hoc when Managed fails"
- eerror " adhoc_essid_${IFVAR}=\"WLAN\""
- eerror "or hardcode the ESSID against the interface (not recommended)"
- eerror " essid_${IFVAR}=\"ESSID\""
+ eerror " adhoc_ssid_${IFVAR}=\"WLAN\""
+ eerror "or hardcode the SSID against the interface (not recommended)"
+ eerror " ssid_${IFVAR}=\"SSID\""
return 1
fi
@@ -507,13 +507,13 @@ iwconfig_force_preferred() {
}
iwconfig_connect_preferred() {
- local essid= i=0 mode= mac= enc= freq= chan=
+ local ssid= i=0 mode= mac= enc= freq= chan=
eval "$(_get_array preferred_aps)"
- for essid in "$@"; do
+ for ssid in "$@"; do
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
- if [ "${e}" = "${essid}" ] ; then
+ if [ "${e}" = "${ssid}" ] ; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@@ -531,13 +531,13 @@ iwconfig_connect_preferred() {
}
iwconfig_connect_not_preferred() {
- local essid= i=0 mode= mac= enc= freq= chan= pref=false
+ local ssid= i=0 mode= mac= enc= freq= chan= pref=false
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
eval "$(_get_array preferred_aps)"
- for essid in "$@" ; do
- if [ "${e}" = "${essid}" ] ; then
+ for ssid in "$@" ; do
+ if [ "${e}" = "${ssid}" ] ; then
pref=true
break
fi
@@ -566,14 +566,17 @@ iwconfig_defaults() {
done
# Release the AP forced
- # Must do ap and then essid otherwise scanning borks
+ # Must do ap and then ssid otherwise scanning borks
iwconfig "${IFACE}" ap off 2>/dev/null
iwconfig "${IFACE}" essid off 2>/dev/null
}
iwconfig_configure() {
local x APS
- eval ESSID=\$ssid_${IFVAR}
+ eval SSID=\$ssid_${IFVAR}
+
+ # Support old variable
+ [ -z "${SSID}" ] && eval SSID=\$essid_${IFVAR}
# Setup ad-hoc mode?
eval x=\$mode_${IFVAR}
@@ -588,14 +591,14 @@ iwconfig_configure() {
return 1
fi
- # Has an ESSID been forced?
- if [ -n "${ESSID}" ]; then
+ # Has an SSID been forced?
+ if [ -n "${SSID}" ]; then
iwconfig_set_mode "${x}"
iwconfig_associate && return 0
- [ "${ESSID}" = "any" ] && iwconfig_force_preferred && return 0
+ [ "${SSID}" = "any" ] && iwconfig_force_preferred && return 0
- eval ESSID=\$adhoc_essid_${IFVAR}
- if [ -n "${ESSID}" ]; then
+ eval SSID=\$adhoc_ssid_${IFVAR}
+ if [ -n "${SSID}" ]; then
iwconfig_setup_specific ad-hoc
return $?
fi
@@ -688,14 +691,14 @@ iwconfig_pre_start() {
fi
if iwconfig_configure ; then
- save_options "ESSID" "${ESSID}"
+ save_options "SSID" "${SSID}"
return 0
fi
eerror "Failed to configure wireless for ${IFACE}"
iwconfig_defaults
iwconfig "${IFACE}" txpower off 2>/dev/null
- unset ESSID ESSIDVAR
+ unset SSID SSIDVAR
_down
return 1
}
diff --git a/net.Linux/macchanger.sh b/net.Linux/macchanger.sh
deleted file mode 100644
index 9d71513..0000000
--- a/net.Linux/macchanger.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2004-2007 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-macchanger_depend() {
- before macnet
-}
-
-_config_vars="$_config_vars mac"
-
-macchanger_pre_start() {
- # We don't change MAC addresses from background
- ${IN_BACKGROUND} && return 0
-
- local mac= opts=
-
- eval mac=\$mac_${IFVAR}
- [ -z "${mac}" ] && return 0
-
- _exists true || return 1
-
- ebegin "Changing MAC address of ${IFACE}"
-
- # The interface needs to be up for macchanger to work most of the time
- _down
-
- mac=$(echo "${mac}" | sed -e 'y/ABCDEF/abcdef')
- case "${mac}" in
- # specific mac-addr, i wish there were a shorter way to specify this
- [0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f])
- # We don't need macchanger to change to a specific mac address
- _set_mac_address "${mac}"
- if eend "$?" ; then
- mac=$(_get_mac_address)
- eindent
- einfo "changed to ${mac}"
- eoutdent
- return 0
- fi
- ;;
-
- # increment MAC address, default macchanger behavior
- increment) opts="${opts}" ;;
-
- # randomize just the ending bytes
- random-ending) opts="${opts} -e" ;;
-
- # keep the same kind of physical layer (eg fibre, copper)
- random-samekind) opts="${opts} -a" ;;
-
- # randomize to any known vendor of any physical layer type
- random-anykind) opts="${opts} -A" ;;
-
- # fully random bytes
- random-full|random) opts="${opts} -r" ;;
-
- # default case is just to pass on all the options
- *) opts="${opts} ${mac}" ;;
- esac
-
- if [ ! -x /sbin/macchanger ] ; then
- eerror "For changing MAC addresses, emerge net-analyzer/macchanger"
- return 1
- fi
-
- mac=$(LC_ALL=C macchanger ${opts} "${IFACE}" \
- | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\1/p' )
- _up
-
- # Sometimes the interface needs to be up ....
- if [ -z "${mac}" ] ; then
- mac=$(LC_ALL=C macchanger ${opts} "${IFACE}" \
- | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\1/p' )
- fi
-
- if [ -z "${mac}" ] ; then
- eend 1 "Failed to set MAC address"
- return 1
- fi
-
- eend 0
- eindent
- einfo "changed to" "${mac}"
- eoutdent
-
- return 0
-}
-
-# vim: set ts=4 :
diff --git a/net.Linux/tuntap.sh b/net.Linux/tuntap.sh
index 829bf13..ba9b2e8 100644
--- a/net.Linux/tuntap.sh
+++ b/net.Linux/tuntap.sh
@@ -17,9 +17,9 @@ tuntap_pre_start() {
[ -z "${tuntap}" ] && return 0
- if [ ! -a /dev/net/tun ] ; then
+ if [ ! -e /dev/net/tun ] ; then
modprobe tun && sleep 1
- if [ ! -a /dev/net/tun ] ; then
+ if [ ! -e /dev/net/tun ] ; then
eerror "TUN/TAP support is not present in this kernel"
return 1
fi
@@ -37,7 +37,7 @@ tuntap_pre_start() {
eval opts=\$tunctl_${IFVAR}
tunctl ${opts} -t "${IFACE}" >/dev/null
fi
- eend $? && save_options tuntap "${tuntap}"
+ eend $? && _up && save_options tuntap "${tuntap}"
}
tuntap_post_stop() {