Merge pull request #591 from neheb/p
[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_int 'hop_penalty'
12 proto_config_add_string "master"
13 proto_config_add_string 'throughput_override'
14 }
15
16 proto_batadv_hardif_setup() {
17 local config="$1"
18 local iface="$2"
19
20 local elp_interval
21 local hop_penalty
22 local master
23 local throughput_override
24
25 json_get_vars elp_interval
26 json_get_vars hop_penalty
27 json_get_vars master
28 json_get_vars throughput_override
29
30 ( proto_add_host_dependency "$config" '' "$master" )
31
32 batctl meshif "$master" interface -M add "$iface"
33
34 [ -n "$elp_interval" ] && batctl hardif "$iface" elp_interval "$elp_interval"
35 [ -n "$hop_penalty" ] && batctl hardif "$iface" hop_penalty "$hop_penalty"
36 [ -n "$throughput_override" ] && batctl hardif "$iface" throughput_override "$throughput_override"
37
38 proto_init_update "$iface" 1
39 proto_send_update "$config"
40 }
41
42 proto_batadv_hardif_teardown() {
43 local config="$1"
44 local iface="$2"
45
46 local master
47
48 json_get_vars master
49
50 batctl meshif "$master" interface -M del "$iface" || true
51 }
52
53 add_protocol batadv_hardif