batman-adv: use batctl for configuration of hop_penalty
[feed/routing.git] / batman-adv / files / lib / batman-adv / config.sh
1 #!/bin/sh
2
3 bat_load_module()
4 {
5 [ -d "/sys/module/batman_adv/" ] && return
6
7 . /lib/functions.sh
8 load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv*
9 }
10
11 bat_config()
12 {
13 local mesh="$1"
14 local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation
15 local gw_bandwidth gw_mode gw_sel_class isolation_mark hop_penalty multicast_mode network_coding log_level
16 local orig_interval
17
18 config_get aggregated_ogms "$mesh" aggregated_ogms
19 config_get ap_isolation "$mesh" ap_isolation
20 config_get bonding "$mesh" bonding
21 config_get bridge_loop_avoidance "$mesh" bridge_loop_avoidance
22 config_get distributed_arp_table "$mesh" distributed_arp_table
23 config_get fragmentation "$mesh" fragmentation
24 config_get gw_bandwidth "$mesh" gw_bandwidth
25 config_get gw_mode "$mesh" gw_mode
26 config_get gw_sel_class "$mesh" gw_sel_class
27 config_get hop_penalty "$mesh" hop_penalty
28 config_get isolation_mark "$mesh" isolation_mark
29 config_get multicast_mode "$mesh" multicast_mode
30 config_get network_coding "$mesh" network_coding
31 config_get log_level "$mesh" log_level
32 config_get orig_interval "$mesh" orig_interval
33
34 [ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1
35
36 [ -n "$aggregated_ogms" ] && batctl -m "$mesh" aggregation "$aggregated_ogms"
37 [ -n "$ap_isolation" ] && batctl -m "$mesh" ap_isolation "$ap_isolation"
38 [ -n "$bonding" ] && batctl -m "$mesh" bonding "$bonding"
39 [ -n "$bridge_loop_avoidance" ] && batctl -m "$mesh" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&-
40 [ -n "$distributed_arp_table" ] && batctl -m "$mesh" distributed_arp_table "$distributed_arp_table" 2>&-
41 [ -n "$fragmentation" ] && batctl -m "$mesh" fragmentation "$fragmentation"
42
43 case "$gw_mode" in
44 server)
45 if [ -n "$gw_bandwidth" ]; then
46 batctl -m "$mesh" gw_mode "server" "$gw_bandwidth"
47 else
48 batctl -m "$mesh" gw_mode "server"
49 fi
50 ;;
51 client)
52 if [ -n "$gw_sel_class" ]; then
53 batctl -m "$mesh" gw_mode "client" "$gw_sel_class"
54 else
55 batctl -m "$mesh" gw_mode "client"
56 fi
57 ;;
58 *)
59 batctl -m "$mesh" gw_mode "off"
60 ;;
61 esac
62
63 [ -n "$hop_penalty" ] && batctl -m "$mesh" hop_penalty "$hop_penalty"
64 [ -n "$isolation_mark" ] && batctl -m "$mesh" isolation_mark "$isolation_mark"
65 [ -n "$multicast_mode" ] && batctl -m "$mesh" multicast_mode "$multicast_mode" 2>&-
66 [ -n "$network_coding" ] && batctl -m "$mesh" network_coding "$network_coding" 2>&-
67 [ -n "$log_level" ] && batctl -m "$mesh" loglevel "$log_level" 2>&-
68 [ -n "$orig_interval" ] && batctl -m "$mesh" orig_interval "$orig_interval"
69 }