2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Michael Tremer #
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. #
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. #
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/>. #
20 ###############################################################################
22 .
/usr
/lib
/network
/header-port
24 HOOK_SETTINGS
="HOOK ADDRESS SLAVES"
26 PORT_CHILDREN_VAR
="SLAVES"
28 ADDRESS
=$
(mac_generate
)
31 function hook_check
() {
36 function hook_create
() {
37 while [ $# -gt 0 ]; do
40 ADDRESS
="$(cli_get_val ${1})"
43 SLAVES
="$(cli_get_val ${1})"
46 warning
"Ignoring unknown argument '${1}'"
52 local port
=$
(port_find_free
${PORT_PATTERN_BATMAN_ADV})
55 port_settings_write
"${port}" ${HOOK_SETTINGS}
60 function hook_edit
() {
65 port_settings_read
"${port}"
67 while [ $# -gt 0 ]; do
70 ADDRESS
="$(cli_get_val ${1})"
73 SLAVES
="${SLAVES} $(cli_get_val ${1})"
76 local slave
="$(cli_get_val ${1})"
79 for s
in ${SLAVES}; do
80 [ "${slave}" = "${s}" ] && continue
81 slaves
="${slaves} ${s}"
86 warning
"Unknown argument '${1}'"
92 port_settings_write
"${port}" ${HOOK_SETTINGS}
101 port_settings_read
"${port}" ${HOOK_SETTINGS}
103 # This cannot be started manually, but is created automatically
104 # when a slave device is brought up and set up by _hotplug.
107 for slave
in ${SLAVES}; do
111 # If the port has been created (does not happen, when there are
112 # no slaves), we bring it up.
113 if device_exists
"${port}"; then
115 device_set_address
"${port}" "${ADDRESS}"
117 device_set_up
"${port}"
123 function hook_down
() {
127 port_settings_read
"${port}"
130 for slave
in ${SLAVES}; do
137 #function hook_hotplug() {
144 # # Bring up the device.
150 function hook_status
() {
154 cli_device_headline
"${port}" --long
156 cli_headline
2 "B.A.T.M.A.N."
159 cli_print_fmt1
2 "Routing Algorithm" \
160 "$(batman_adv_get_routing_algorithm "${port}")"
165 # Originator interval
166 cli_print_fmt1
2 "Originator Interval" \
167 "$(batman_adv_get_originator_interval "${port}") ms"
169 # Aggregated originator messages
170 batman_adv_get_aggregated_ogms
"${port}"
171 cli_print_fmt1
2 "Aggregated Originator Messages" "$(cli_print_bool $?)"
174 batman_adv_get_ap_isolation
"${port}"
175 cli_print_fmt1
2 "Access Point Isolation" "$(cli_print_bool $?)"
178 batman_adv_get_bonding_mode
"${port}"
179 cli_print_fmt1
2 "Bonding Mode" "$(cli_print_bool $?)"
181 # Bridge loop avoidance
182 batman_adv_get_bridge_loop_avoidance
"${port}"
183 cli_print_fmt1
2 "Bridge Loop Avoidance" "$(cli_print_bool $?)"
185 # Distributed ARP table
186 batman_adv_get_distributed_arp_table
"${port}"
187 cli_print_fmt1
2 "Distributed ARP Table" "$(cli_print_bool $?)"
190 batman_adv_get_fragmentation
"${port}"
191 cli_print_fmt1
2 "Fragmentation" "$(cli_print_bool $?)"
194 cli_print_fmt1
2 "Hop Penalty" \
195 "$(batman_adv_get_hop_penalty "${port}")"
199 cli_headline
3 "Gateway"
202 batman_adv_get_gateway_mode
"${port}"
205 cli_print_fmt1
3 "Enabled" "$(cli_print_bool ${gw_enabled})"
207 if [ ${gw_enabled} -eq ${EXIT_TRUE} ]; then
208 cli_print_fmt1
3 "Bandwidth" \
209 "$(batman_adv_get_gateway_bandwidth "${port}")"
210 cli_print_fmt1
3 "Selection Class" \
211 "$(batman_adv_get_gateway_selection_class "${port}")"