diff options
author | Lukas Nykryn <lnykryn@redhat.com> | 2013-12-04 15:27:18 +0100 |
---|---|---|
committer | Lukas Nykryn <lnykryn@redhat.com> | 2013-12-04 15:27:40 +0100 |
commit | 66f2784ec8822e8c4f728e4529ea9028b3265a5f (patch) | |
tree | 894af261a7feb27db174c4aa3773139ddd511eb7 /sysconfig/network-scripts | |
parent | c9636c795492fc6654d65c631f1dc9ac7f9a04c3 (diff) | |
download | initscripts-66f2784ec8822e8c4f728e4529ea9028b3265a5f.tar initscripts-66f2784ec8822e8c4f728e4529ea9028b3265a5f.tar.gz initscripts-66f2784ec8822e8c4f728e4529ea9028b3265a5f.tar.bz2 initscripts-66f2784ec8822e8c4f728e4529ea9028b3265a5f.tar.xz initscripts-66f2784ec8822e8c4f728e4529ea9028b3265a5f.zip |
use iw instead of iwconfig and friends (#915343)
Diffstat (limited to 'sysconfig/network-scripts')
-rwxr-xr-x | sysconfig/network-scripts/ifup-wireless | 100 |
1 files changed, 21 insertions, 79 deletions
diff --git a/sysconfig/network-scripts/ifup-wireless b/sysconfig/network-scripts/ifup-wireless index 580725fa..3b248cca 100755 --- a/sysconfig/network-scripts/ifup-wireless +++ b/sysconfig/network-scripts/ifup-wireless @@ -17,93 +17,35 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# Configure wireless network device options. See iwconfig(8) for more info. +# Configure wireless network device options. See iw(8) for more info. # Valid variables: # MODE: Ad-Hoc, Managed, etc. # ESSID: Name of the wireless network -# NWID: Name of this machine on the network. Hostname is default # FREQ: Frequency to operate on. See CHANNEL -# CHANNEL: Numbered frequency to operate on. See FREQ -# SENS: Sensitivity threshold for packet rejection. -# RATE: Transfer rate. Usually one of Auto, 11, 5, 2, or 1. # KEY: Encryption key for WEP. -# RTS: Explicit RTS handshake. Usually not specified (auto) -# FRAG: Fragmentation threshold to split packets. Usually not specified. -# SPYIPS: List of IP addresses to "spy" on for link performance stats. -# IWCONFIG: Extra parameters to pass directly to IWCONFIG -# SECURITYMODE: Security mode, e.g: 'open' or 'restricted' -# IWPRIV: Extra parameters to pass directly to IWPRIV # Only meant to be called from ifup. -# Mode need to be first : some settings apply only in a specific mode ! -if [ -n "$MODE" ] ; then - iwconfig $DEVICE mode $MODE -fi +IW=iw -# Set link up (some cards require this.) -/sbin/ip link set dev ${DEVICE} up +[ "$DEVICE" -a "$MODE" ] || exit +[ "$KEY" ] && KEYS="key d:0:$KEY" -# This is a bit hackish, but should do the job right... -if [ -n "$ESSID" -o -n "$MODE" ] ; then - NICKNAME=$(/bin/hostname) - iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1 -fi -# Regular stuff... -if [ -n "$NWID" ] ; then - iwconfig $DEVICE nwid $NWID -fi -if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then - iwconfig $DEVICE freq $FREQ -elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then - iwconfig $DEVICE channel $CHANNEL -fi -if [ -n "$SENS" ] ; then - iwconfig $DEVICE sens $SENS -fi -if [ -n "$RATE" ] ; then - iwconfig $DEVICE rate "$RATE" -fi -if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then - [ -n "$KEY1" ] && iwconfig $DEVICE key "[1]" $KEY1 - [ -n "$KEY2" ] && iwconfig $DEVICE key "[2]" $KEY2 - [ -n "$KEY3" ] && iwconfig $DEVICE key "[3]" $KEY3 - [ -n "$KEY4" ] && iwconfig $DEVICE key "[4]" $KEY4 - [ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key "[${DEFAULTKEY}]" - [ -n "$KEY" ] && iwconfig $DEVICE key $KEY -else - iwconfig $DEVICE key off -fi -if [ -n "$SECURITYMODE" ]; then - iwconfig $DEVICE enc $SECURITYMODE -fi -if [ -n "$RTS" ] ; then - iwconfig $DEVICE rts $RTS -fi -if [ -n "$FRAG" ] ; then - iwconfig $DEVICE frag $FRAG -fi +shopt -s nocasematch -# More specific parameters passed directly to IWCONFIG -if [ -n "$IWCONFIG" ] ; then - iwconfig $DEVICE $IWCONFIG -fi - -if [ -n "$SPYIPS" ] ; then - for IP in $SPYIPS; do - iwspy $DEVICE + $IP - done -fi -if [ -n "$IWPRIV" ] ; then - iwpriv $DEVICE $IWPRIV -fi - -# ESSID need to be last : most device re-perform the scanning/discovery -# when this is set, and things like encryption keys are better be -# defined if we want to discover the right set of APs/nodes. -if [ -n "$ESSID" ] ; then - iwconfig $DEVICE essid "$ESSID" -else - # use any essid - iwconfig $DEVICE essid any >/dev/null 2>&1 -fi +case "$MODE" in +managed) + [ "$ESSID" ] || exit + $IW dev "$DEVICE" set type managed + $IW dev "$DEVICE" connect -w "$ESSID" $FREQ $KEYS + ;; +ad-hoc) + [ "$ESSID" && "$FREQ" ] || exit + $IW dev "$DEVICE" set type ibss + $IW dev "$DEVICE" ibss join "$ESSID" "$FREQ" $KEYS + ;; +monitor) + [ "$FREQ" ] || exit + $IW dev "$DEVICE" set type monitor + $IW dev "$DEVICE" set freq "$FREQ" +esac |