]> git.ipfire.org Git - people/stevee/network.git/blob - src/functions/functions.batman-adv
hotplug: Must not stop after first port has been hit
[people/stevee/network.git] / src / functions / functions.batman-adv
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 IPFire Network Development Team #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 function batman_adv_start() {
23 # Load the batman kernel module.
24 module_load "batman-adv"
25 }
26
27 function batman_adv_interface_add() {
28 local device=${1}
29 assert isset device
30
31 local port=${2}
32 assert isset port
33
34 # Make sure, batman is running.
35 batman_adv_start
36
37 fwrite "${SYS_CLASS_NET}/${port}/batman_adv/mesh_iface" "${device}"
38 }
39
40 function batman_adv_interface_del() {
41 local port=${1}
42 assert isset port
43
44 fwrite "${SYS_CLASS_NET}/${port}/batman_adv/mesh_iface" "none"
45 }
46
47 function batman_adv_get_aggregated_ogms() {
48 local device=${1}
49 assert isset device
50
51 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/aggregated_ogms)"
52 case "${value}" in
53 enabled)
54 return ${EXIT_TRUE}
55 ;;
56 disabled)
57 return ${EXIT_FALSE}
58 ;;
59 esac
60
61 return ${EXIT_ERROR}
62 }
63
64 function batman_adv_get_ap_isolation() {
65 local device=${1}
66 assert isset device
67
68 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/ap_isolation)"
69 case "${value}" in
70 enabled)
71 return ${EXIT_TRUE}
72 ;;
73 disabled)
74 return ${EXIT_FALSE}
75 ;;
76 esac
77
78 return ${EXIT_ERROR}
79 }
80
81 function batman_adv_get_bonding_mode() {
82 local device=${1}
83 assert isset device
84
85 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/bonding)"
86 case "${value}" in
87 enabled)
88 return ${EXIT_TRUE}
89 ;;
90 disabled)
91 return ${EXIT_FALSE}
92 ;;
93 esac
94
95 return ${EXIT_ERROR}
96 }
97
98 function batman_adv_get_distributed_arp_table() {
99 local device=${1}
100 assert isset device
101
102 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/distributed_arp_table)"
103 case "${value}" in
104 enabled)
105 return ${EXIT_TRUE}
106 ;;
107 disabled)
108 return ${EXIT_FALSE}
109 ;;
110 esac
111
112 return ${EXIT_ERROR}
113 }
114
115 function batman_adv_get_bridge_loop_avoidance() {
116 local device=${1}
117 assert isset device
118
119 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/bridge_loop_avoidance)"
120 case "${value}" in
121 enabled)
122 return ${EXIT_TRUE}
123 ;;
124 disabled)
125 return ${EXIT_FALSE}
126 ;;
127 esac
128
129 return ${EXIT_ERROR}
130 }
131
132 function batman_adv_get_fragmentation() {
133 local device=${1}
134 assert isset device
135
136 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/fragmentation)"
137 case "${value}" in
138 enabled)
139 return ${EXIT_TRUE}
140 ;;
141 disabled)
142 return ${EXIT_FALSE}
143 ;;
144 esac
145
146 return ${EXIT_ERROR}
147 }
148
149 function batman_adv_get_gateway_mode() {
150 local device=${1}
151 assert isset device
152
153 local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/gw_mode)"
154 case "${value}" in
155 on)
156 return ${EXIT_TRUE}
157 ;;
158 off)
159 return ${EXIT_FALSE}
160 ;;
161 esac
162
163 return ${EXIT_ERROR}
164 }
165
166 function batman_adv_get_gateway_bandwidth() {
167 local device=${1}
168 assert isset device
169
170 fread "${SYS_CLASS_NET}/${device}/mesh/gw_bandwidth"
171 }
172
173 function batman_adv_get_gateway_selection_class() {
174 local device=${1}
175 assert isset device
176
177 fread "${SYS_CLASS_NET}/${device}/mesh/gw_sel_class"
178 }
179
180 function batman_adv_get_hop_penalty() {
181 local device=${1}
182 assert isset device
183
184 fread "${SYS_CLASS_NET}/${device}/mesh/hop_penalty"
185 }
186
187 function batman_adv_get_originator_interval() {
188 local device=${1}
189 assert isset device
190
191 fread "${SYS_CLASS_NET}/${device}/mesh/orig_interval"
192 }
193
194 function batman_adv_get_routing_algorithm() {
195 local device=${1}
196 assert isset device
197
198 fread "${SYS_CLASS_NET}/${device}/mesh/routing_algo"
199 }