batman-adv: Switch proto scripts to new prefixes
[feed/routing.git] / batman-adv / files / lib / netifd / proto / batadv.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_init_config() {
10 no_device=1
11 available=1
12
13 proto_config_add_boolean 'aggregated_ogms:bool'
14 proto_config_add_boolean 'ap_isolation:bool'
15 proto_config_add_boolean 'bonding:bool'
16 proto_config_add_boolean 'bridge_loop_avoidance:bool'
17 proto_config_add_boolean 'distributed_arp_table:bool'
18 proto_config_add_boolean 'fragmentation:bool'
19 proto_config_add_string 'gw_bandwidth'
20 proto_config_add_string 'gw_mode'
21 proto_config_add_int 'gw_sel_class'
22 proto_config_add_int 'hop_penalty'
23 proto_config_add_string 'isolation_mark'
24 proto_config_add_string 'log_level'
25 proto_config_add_int 'multicast_fanout'
26 proto_config_add_boolean 'multicast_mode:bool'
27 proto_config_add_boolean 'network_coding:bool'
28 proto_config_add_int 'orig_interval'
29 proto_config_add_string 'routing_algo'
30 }
31
32 proto_batadv_setup() {
33 local config="$1"
34 local iface="$config"
35
36 local aggregated_ogms
37 local ap_isolation
38 local bonding
39 local bridge_loop_avoidance
40 local distributed_arp_table
41 local fragmentation
42 local gw_bandwidth
43 local gw_mode
44 local gw_sel_class
45 local hop_penalty
46 local isolation_mark
47 local log_level
48 local multicast_fanout
49 local multicast_mode
50 local network_coding
51 local orig_interval
52 local routing_algo
53
54 json_get_vars aggregated_ogms
55 json_get_vars ap_isolation
56 json_get_vars bonding
57 json_get_vars bridge_loop_avoidance
58 json_get_vars distributed_arp_table
59 json_get_vars fragmentation
60 json_get_vars gw_bandwidth
61 json_get_vars gw_mode
62 json_get_vars gw_sel_class
63 json_get_vars hop_penalty
64 json_get_vars isolation_mark
65 json_get_vars log_level
66 json_get_vars multicast_fanout
67 json_get_vars multicast_mode
68 json_get_vars network_coding
69 json_get_vars orig_interval
70 json_get_vars routing_algo
71
72 set_default routing_algo 'BATMAN_IV'
73
74 batctl routing_algo "$routing_algo"
75 batctl meshif "$iface" interface create
76
77 [ -n "$aggregated_ogms" ] && batctl meshif "$iface" aggregation "$aggregated_ogms"
78 [ -n "$ap_isolation" ] && batctl meshif "$iface" ap_isolation "$ap_isolation"
79 [ -n "$bonding" ] && batctl meshif "$iface" bonding "$bonding"
80 [ -n "$bridge_loop_avoidance" ] && batctl meshif "$iface" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&-
81 [ -n "$distributed_arp_table" ] && batctl meshif "$iface" distributed_arp_table "$distributed_arp_table" 2>&-
82 [ -n "$fragmentation" ] && batctl meshif "$iface" fragmentation "$fragmentation"
83
84 case "$gw_mode" in
85 server)
86 if [ -n "$gw_bandwidth" ]; then
87 batctl meshif "$iface" gw_mode "server" "$gw_bandwidth"
88 else
89 batctl meshif "$iface" gw_mode "server"
90 fi
91 ;;
92 client)
93 if [ -n "$gw_sel_class" ]; then
94 batctl meshif "$iface" gw_mode "client" "$gw_sel_class"
95 else
96 batctl meshif "$iface" gw_mode "client"
97 fi
98 ;;
99 *)
100 batctl meshif "$iface" gw_mode "off"
101 ;;
102 esac
103
104 [ -n "$hop_penalty" ] && batctl meshif "$iface" hop_penalty "$hop_penalty"
105 [ -n "$isolation_mark" ] && batctl meshif "$iface" isolation_mark "$isolation_mark"
106 [ -n "$multicast_fanout" ] && batctl meshif "$iface" multicast_fanout "$multicast_fanout"
107 [ -n "$multicast_mode" ] && batctl meshif "$iface" multicast_mode "$multicast_mode" 2>&-
108 [ -n "$network_coding" ] && batctl meshif "$iface" network_coding "$network_coding" 2>&-
109 [ -n "$log_level" ] && batctl meshif "$iface" loglevel "$log_level" 2>&-
110 [ -n "$orig_interval" ] && batctl meshif "$iface" orig_interval "$orig_interval"
111
112 proto_init_update "$iface" 1
113 proto_send_update "$config"
114 }
115
116 proto_batadv_teardown() {
117 local config="$1"
118 local iface="$config"
119
120 batctl meshif "$iface" interface destroy
121 }
122
123 add_protocol batadv