Merge branch 'v1.4' into v1.5
[librecmc/librecmc.git] / package / network / services / authsae / files / lib / wifi / authsae.sh
1 authsae_start_interface() {
2         local mcast_rate
3         local mesh_htmode
4         local mesh_band
5         local authsae_conf_file="/var/run/authsae-$ifname.cfg"
6         local ret=1
7
8         json_get_vars mcast_rate mesh_id
9         set_default mcast_rate "12000"
10
11         case "$htmode" in
12                 HT20|HT40+|HT40-) mesh_htmode="$htmode";;
13                 *) mesh_htmode="none";;
14         esac
15
16         case "$hwmode" in
17                 *g*) mesh_band=11g;;
18                 *a*) mesh_band=11a;;
19         esac
20
21         if [ "$mcast_rate" -gt 1000 ]; then
22                 # authsae only allows integers as rates and not things like 5.5
23                 mcval=$(($mcast_rate / 1000))
24         else
25                 # compat: to still support mbit/s rates
26                 mcval="$mcast_rate"
27         fi
28
29         cat > "$authsae_conf_file" <<EOF
30 authsae:
31 {
32  sae:
33   {
34     debug = 0;
35     password = "$key";
36     group = [19, 26, 21, 25, 20];
37     blacklist = 5;
38     thresh = 5;
39     lifetime = 3600;
40   };
41  meshd:
42   {
43     meshid = "$mesh_id";
44     interface = "$ifname";
45     passive = 0;
46     debug = 0;
47     mediaopt = 1;
48     band = "$mesh_band";
49     channel = $channel;
50     htmode = "$mesh_htmode";
51     mcast-rate = $mcval;
52   };
53 };
54 EOF
55
56         /usr/bin/meshd-nl80211 -i "$ifname" -s "$mesh_id" -c "$authsae_conf_file" </dev/null >/dev/null 2>/dev/null &
57         authsae_pid="$!"
58         ret="$?"
59
60         echo $authsae_pid > /var/run/authsae-$ifname.pid
61         wireless_add_process "$authsae_pid" "/usr/bin/meshd-nl80211" 1
62
63         [ "$ret" != 0 ] && wireless_setup_vif_failed AUTHSAE_FAILED
64         return $ret
65 }