]>
Commit | Line | Data |
---|---|---|
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 | assert device_is_batman_adv_port "${port}" | |
38 | ||
39 | fwrite "${SYS_CLASS_NET}/${port}/batman_adv/mesh_iface" "${device}" | |
40 | } | |
41 | ||
42 | function batman_adv_interface_del() { | |
43 | local port=${1} | |
44 | assert isset port | |
45 | ||
46 | fwrite "${SYS_CLASS_NET}/${port}/batman_adv/mesh_iface" "none" | |
47 | } | |
48 | ||
49 | function batman_adv_get_aggregated_ogms() { | |
50 | local device=${1} | |
51 | assert isset device | |
52 | ||
53 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/aggregated_ogms)" | |
54 | case "${value}" in | |
55 | enabled) | |
56 | return ${EXIT_TRUE} | |
57 | ;; | |
58 | disabled) | |
59 | return ${EXIT_FALSE} | |
60 | ;; | |
61 | esac | |
62 | ||
63 | return ${EXIT_ERROR} | |
64 | } | |
65 | ||
66 | function batman_adv_get_ap_isolation() { | |
67 | local device=${1} | |
68 | assert isset device | |
69 | ||
70 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/ap_isolation)" | |
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 | function batman_adv_get_bonding_mode() { | |
84 | local device=${1} | |
85 | assert isset device | |
86 | ||
87 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/bonding)" | |
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 | function batman_adv_get_distributed_arp_table() { | |
101 | local device=${1} | |
102 | assert isset device | |
103 | ||
104 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/distributed_arp_table)" | |
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 | function batman_adv_get_bridge_loop_avoidance() { | |
118 | local device=${1} | |
119 | assert isset device | |
120 | ||
121 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/bridge_loop_avoidance)" | |
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 | function batman_adv_get_fragmentation() { | |
135 | local device=${1} | |
136 | assert isset device | |
137 | ||
138 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/fragmentation)" | |
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 | function batman_adv_get_gateway_mode() { | |
152 | local device=${1} | |
153 | assert isset device | |
154 | ||
155 | local value="$(fread ${SYS_CLASS_NET}/${device}/mesh/gw_mode)" | |
156 | case "${value}" in | |
157 | on) | |
158 | return ${EXIT_TRUE} | |
159 | ;; | |
160 | off) | |
161 | return ${EXIT_FALSE} | |
162 | ;; | |
163 | esac | |
164 | ||
165 | return ${EXIT_ERROR} | |
166 | } | |
167 | ||
168 | function batman_adv_get_gateway_bandwidth() { | |
169 | local device=${1} | |
170 | assert isset device | |
171 | ||
172 | fread "${SYS_CLASS_NET}/${device}/mesh/gw_bandwidth" | |
173 | } | |
174 | ||
175 | function batman_adv_get_gateway_selection_class() { | |
176 | local device=${1} | |
177 | assert isset device | |
178 | ||
179 | fread "${SYS_CLASS_NET}/${device}/mesh/gw_sel_class" | |
180 | } | |
181 | ||
182 | function batman_adv_get_hop_penalty() { | |
183 | local device=${1} | |
184 | assert isset device | |
185 | ||
186 | fread "${SYS_CLASS_NET}/${device}/mesh/hop_penalty" | |
187 | } | |
188 | ||
189 | function batman_adv_get_originator_interval() { | |
190 | local device=${1} | |
191 | assert isset device | |
192 | ||
193 | fread "${SYS_CLASS_NET}/${device}/mesh/orig_interval" | |
194 | } | |
195 | ||
196 | function batman_adv_get_routing_algorithm() { | |
197 | local device=${1} | |
198 | assert isset device | |
199 | ||
200 | fread "${SYS_CLASS_NET}/${device}/mesh/routing_algo" | |
201 | } |