authsae: adapt uci scripts to use authsae
[openwrt/openwrt.git] / package / network / services / authsae / files / lib / wifi / authsae.sh
1 authsae_start_interface() {
2 local device="$1" # to use the correct channel
3 local vif="$2"
4 local band
5
6 cfgfile="/var/run/authsae-$vif.cfg"
7 config_get channel "$device" channel
8 config_get hwmode "$device" hwmode
9 config_get htmode "$device" htmode
10 config_get ifname "$vif" ifname
11 config_get key "$vif" key
12 config_get mesh_id "$vif" mesh_id
13 config_get mcast_rate "$vif" mcast_rate "12"
14
15 case "$htmode" in
16 HT20|HT40+|HT40-) htmode="$htmode";;
17 NOHT|none|*) htmode="none";;
18 esac
19
20 case "$hwmode" in
21 *g*) band=11g;;
22 *a*) band=11a;;
23 esac
24
25 cat > "$cfgfile" <<EOF
26 authsae:
27 {
28 sae:
29 {
30 debug = 0;
31 password = "$key";
32 group = [19, 26, 21, 25, 20];
33 blacklist = 5;
34 thresh = 5;
35 lifetime = 3600;
36 };
37 meshd:
38 {
39 meshid = "$mesh_id";
40 interface = "$ifname";
41 passive = 0;
42 debug = 0;
43 mediaopt = 1;
44 band = "$band";
45 channel = $channel;
46 htmode = "$htmode";
47 mcast-rate = $mcast_rate;
48 };
49 };
50 EOF
51 ifconfig "$ifname" up
52 meshd-nl80211 -i "$ifname" -s "$mesh_id" -c "$cfgfile" -B
53 }