]> git.ipfire.org Git - people/ms/network.git/blob - src/functions/functions.batman-adv
batman-adv: Make sure kernel module is loaded
[people/ms/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 batman_adv_add() {
23 local device="${1}"
24 assert isset device
25
26 # Make sure the kernel module is loaded
27 module_load "batman-adv"
28
29 local cmd="ip link add name ${device} type batadv"
30 cmd_quiet "${cmd}"
31 local ret=$?
32
33 if [ ${ret} -eq ${EXIT_OK} ]; then
34 log DEBUG "batman-adv device '${device}' has been created"
35 else
36 log ERROR "batman-adv device '${device}' could not be created: ${ret}"
37 fi
38
39 return ${ret}
40 }
41
42 batman_adv_delete() {
43 local device="${1}"
44 assert isset device
45
46 device_delete "${device}"
47 }
48
49 batman_adv_attach() {
50 local device=${1}
51 assert isset device
52
53 local port=${2}
54 assert isset port
55
56 device_set_master "${port}" "${device}"
57 }
58
59 batman_adv_detach() {
60 local port=${1}
61 assert isset port
62
63 __device_set_file "${port}" "batman_adv/mesh_iface" "none"
64 }
65
66 batman_adv_get_aggregated_ogms() {
67 local device=${1}
68 assert isset device
69
70 local value="$(__device_get_file "${device}" "mesh/aggregated_ogms")"
71 case "${value}" in
72 enabled)
73 return ${EXIT_TRUE}
74 ;;
75 disabled)
76 return ${EXIT_FALSE}
77 ;;
78 esac
79
80 return ${EXIT_ERROR}
81 }
82
83 batman_adv_get_ap_isolation() {
84 local device=${1}
85 assert isset device
86
87 local value="$(__device_get_file "${device}" "mesh/ap_isolation")"
88 case "${value}" in
89 enabled)
90 return ${EXIT_TRUE}
91 ;;
92 disabled)
93 return ${EXIT_FALSE}
94 ;;
95 esac
96
97 return ${EXIT_ERROR}
98 }
99
100 batman_adv_get_bonding_mode() {
101 local device=${1}
102 assert isset device
103
104 local value="$(__device_get_file "${device}" "mesh/bonding")"
105 case "${value}" in
106 enabled)
107 return ${EXIT_TRUE}
108 ;;
109 disabled)
110 return ${EXIT_FALSE}
111 ;;
112 esac
113
114 return ${EXIT_ERROR}
115 }
116
117 batman_adv_get_distributed_arp_table() {
118 local device=${1}
119 assert isset device
120
121 local value="$(__device_get_file "${device}" "mesh/distributed_arp_table")"
122 case "${value}" in
123 enabled)
124 return ${EXIT_TRUE}
125 ;;
126 disabled)
127 return ${EXIT_FALSE}
128 ;;
129 esac
130
131 return ${EXIT_ERROR}
132 }
133
134 batman_adv_get_bridge_loop_avoidance() {
135 local device=${1}
136 assert isset device
137
138 local value="$(__device_get_file "${device}" "mesh/bridge_loop_avoidance")"
139 case "${value}" in
140 enabled)
141 return ${EXIT_TRUE}
142 ;;
143 disabled)
144 return ${EXIT_FALSE}
145 ;;
146 esac
147
148 return ${EXIT_ERROR}
149 }
150
151 batman_adv_get_fragmentation() {
152 local device=${1}
153 assert isset device
154
155 local value="$(__device_get_file "${device}" "mesh/fragmentation")"
156 case "${value}" in
157 enabled)
158 return ${EXIT_TRUE}
159 ;;
160 disabled)
161 return ${EXIT_FALSE}
162 ;;
163 esac
164
165 return ${EXIT_ERROR}
166 }
167
168 batman_adv_get_gateway_mode() {
169 local device=${1}
170 assert isset device
171
172 local value="$(__device_get_file "${device}" "mesh/gw_mode")"
173 case "${value}" in
174 on)
175 return ${EXIT_TRUE}
176 ;;
177 off)
178 return ${EXIT_FALSE}
179 ;;
180 esac
181
182 return ${EXIT_ERROR}
183 }
184
185 batman_adv_get_gateway_bandwidth() {
186 local device=${1}
187 assert isset device
188
189 __device_get_file "${device}" "mesh/gw_bandwidth"
190 }
191
192 batman_adv_get_gateway_selection_class() {
193 local device=${1}
194 assert isset device
195
196 __device_get_file "${device}" "mesh/gw_sel_class"
197 }
198
199 batman_adv_get_hop_penalty() {
200 local device=${1}
201 assert isset device
202
203 __device_get_file "${device}" "mesh/hop_penalty"
204 }
205
206 batman_adv_get_originator_interval() {
207 local device=${1}
208 assert isset device
209
210 __device_get_file "${device}" "mesh/orig_interval"
211 }
212
213 batman_adv_get_routing_algorithm() {
214 local device=${1}
215 assert isset device
216
217 __device_get_file "${device}" "mesh/routing_algo"
218 }