summaryrefslogtreecommitdiff
path: root/recipes-kernel/rsi-91x/files/onebox_util.sh
blob: ce40a128696d5fac75b2ed5f3f19a926e7373c7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# The purpose of this script is to allow
# the rs9113 onebox_util functionality to
# be implemented seamlessly for the rsi
# driver.

rpine=$1
cmd=$2
interface=$3
type=$4

sta_ap=0

if [[ $cmd == delete_vap ]] ; then
    ip link set $interface down || exit 0
    exit 0
fi

if [[ $(lsmod) =~ [[:space:]]rsi_91x_sta_ap[[:space:]] ]] ; then
    sta_ap=1
fi

if [[ $cmd == create_vap ]] && [[ $type == ap ]] && ((sta_ap==1)) ; then
    ints=$(iw dev | grep Interface)
    if (( $(echo "$ints" | wc -l) == 1)) ; then
	[[ $ints =~ Interface[[:space:]]+([^[:space:]]*) ]]
	int1="${BASH_REMATCH[1]}"
        iw dev "$int1" interface add $interface type __ap || exit 0
        exit 0
    fi
fi

if [[ -L /sys/class/net/$interface ]] ; then
    exit 0
fi
cd /sys/class/net/
for d in wlan[0-9]* ; do
    if ip link set $d down ; then
        ip link set $d name $interface
        exit 0
    fi
done