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