Merge pull request #478 from ecsv/batadv-for-19.07
[feed/routing.git] / batman-adv / files / lib / netifd / proto / batadv_hardif.sh
1 #!/bin/sh
2
3 [ -n "$INCLUDE_ONLY" ] || {
4 . /lib/functions.sh
5 . ../netifd-proto.sh
6 init_proto "$@"
7 }
8
9 proto_batadv_hardif_init_config() {
10 proto_config_add_int 'elp_interval'
11 proto_config_add_string "master"
12 proto_config_add_string 'throughput_override'
13 }
14
15 proto_batadv_hardif_setup() {
16 local config="$1"
17 local iface="$2"
18
19 local elp_interval
20 local master
21 local throughput_override
22
23 json_get_vars elp_interval
24 json_get_vars master
25 json_get_vars throughput_override
26
27 ( proto_add_host_dependency "$config" '' "$master" )
28
29 batctl -m "$master" interface -M add "$iface"
30
31 [ -n "$elp_interval" ] && batctl -m "$master" hardif "$iface" elp_interval "$elp_interval"
32 [ -n "$throughput_override" ] && batctl -m "$master" hardif "$iface" throughput_override "$throughput_override"
33
34 proto_init_update "$iface" 1
35 proto_send_update "$config"
36 }
37
38 proto_batadv_hardif_teardown() {
39 local config="$1"
40 local iface="$2"
41
42 local master
43
44 json_get_vars master
45
46 batctl -m "$master" interface -M del "$iface" || true
47 }
48
49 add_protocol batadv_hardif