]> git.ipfire.org Git - people/stevee/network.git/blame - src/functions/functions.batman-adv
wireless: Allow setting the channel when creating a device
[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_add() {
b8026986
MT
23 local device="${1}"
24 assert isset device
25
6f741def
MT
26 # Make sure the kernel module is loaded
27 module_load "batman-adv"
28
b8026986
MT
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
1c6a4e30 42batman_adv_delete() {
b8026986
MT
43 local device="${1}"
44 assert isset device
45
46 device_delete "${device}"
47}
48
1c6a4e30 49batman_adv_attach() {
91987cc5
MT
50 local device=${1}
51 assert isset device
52
e6993835
MT
53 local port=${2}
54 assert isset port
55
0e523702 56 device_set_master "${port}" "${device}"
91987cc5
MT
57}
58
1c6a4e30 59batman_adv_detach() {
e6993835
MT
60 local port=${1}
61 assert isset port
62
d3d13297 63 device_remove_master "${port}"
e6993835
MT
64}
65
1c6a4e30 66batman_adv_get_aggregated_ogms() {
e6993835
MT
67 local device=${1}
68 assert isset device
69
abdeb3ce 70 local value="$(__device_get_file "${device}" "mesh/aggregated_ogms")"
e6993835
MT
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
1c6a4e30 83batman_adv_get_ap_isolation() {
e6993835
MT
84 local device=${1}
85 assert isset device
86
abdeb3ce 87 local value="$(__device_get_file "${device}" "mesh/ap_isolation")"
e6993835
MT
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
1c6a4e30 100batman_adv_get_bonding_mode() {
e6993835
MT
101 local device=${1}
102 assert isset device
103
abdeb3ce 104 local value="$(__device_get_file "${device}" "mesh/bonding")"
e6993835
MT
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
1c6a4e30 117batman_adv_get_distributed_arp_table() {
e6993835
MT
118 local device=${1}
119 assert isset device
120
abdeb3ce 121 local value="$(__device_get_file "${device}" "mesh/distributed_arp_table")"
e6993835
MT
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
1c6a4e30 134batman_adv_get_bridge_loop_avoidance() {
e6993835
MT
135 local device=${1}
136 assert isset device
137
abdeb3ce 138 local value="$(__device_get_file "${device}" "mesh/bridge_loop_avoidance")"
e6993835
MT
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
1c6a4e30 151batman_adv_get_fragmentation() {
e6993835
MT
152 local device=${1}
153 assert isset device
154
abdeb3ce 155 local value="$(__device_get_file "${device}" "mesh/fragmentation")"
e6993835
MT
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
1c6a4e30 168batman_adv_get_gateway_mode() {
e6993835
MT
169 local device=${1}
170 assert isset device
171
abdeb3ce 172 local value="$(__device_get_file "${device}" "mesh/gw_mode")"
e6993835
MT
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
1c6a4e30 185batman_adv_get_gateway_bandwidth() {
e6993835
MT
186 local device=${1}
187 assert isset device
188
abdeb3ce 189 __device_get_file "${device}" "mesh/gw_bandwidth"
e6993835
MT
190}
191
1c6a4e30 192batman_adv_get_gateway_selection_class() {
e6993835
MT
193 local device=${1}
194 assert isset device
195
abdeb3ce 196 __device_get_file "${device}" "mesh/gw_sel_class"
e6993835
MT
197}
198
1c6a4e30 199batman_adv_get_hop_penalty() {
e6993835
MT
200 local device=${1}
201 assert isset device
202
abdeb3ce 203 __device_get_file "${device}" "mesh/hop_penalty"
e6993835
MT
204}
205
1c6a4e30 206batman_adv_get_originator_interval() {
e6993835
MT
207 local device=${1}
208 assert isset device
209
abdeb3ce 210 __device_get_file "${device}" "mesh/orig_interval"
e6993835
MT
211}
212
1c6a4e30 213batman_adv_get_routing_algorithm() {
91987cc5
MT
214 local device=${1}
215 assert isset device
216
abdeb3ce 217 __device_get_file "${device}" "mesh/routing_algo"
91987cc5 218}