2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2017 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_PORT_PATTERN
="${PORT_PATTERN_MESH}"
26 HOOK_SETTINGS
="HOOK ADDRESS MESH_ID CHANNEL PHY"
28 hook_check_settings
() {
36 hook_parse_cmdline
() {
37 while [ $# -gt 0 ]; do
40 ADDRESS
=$
(cli_get_val
"${1}")
43 CHANNEL
=$
(cli_get_val
"${1}")
46 MESH_ID
=$
(cli_get_val
"${1}")
49 PHY
=$
(cli_get_val
"${1}")
52 warning
"Ignoring unknown argument '${1}'"
58 if ! isset MESH_ID
; then
59 error
"Please pass a mesh ID"
63 # Save address of phy do identify it again
65 PHY
=$
(phy_get_address
${PHY})
67 # Generate a MAC address if none given
68 if ! isset ADDRESS
; then
69 ADDRESS
=$
(mac_generate
)
72 # XXX check if wireless channel is valid
80 port_settings_read
"${port}" ${HOOK_SETTINGS}
82 # Check if the PHY is present.
83 local phy
="$(phy_get "${PHY}")"
85 log DEBUG
"phy '${PHY}' is not present"
89 # Create the wireless device, if it does not exist, yet.
90 if ! device_exists
"${port}"; then
91 wireless_create
"${port}" \
92 --address="${ADDRESS}" \
93 --channel="${CHANNEL}" \
95 --type="mesh-point" ||
return $?
105 if device_exists
"${port}"; then
106 wireless_remove
"${port}"
116 port_settings_read
"${port}" ${HOOK_SETTINGS}
118 case "$(hotplug_action)" in
120 # Bring up the port when the phy is plugged in
121 if hotplug_event_port_uses_phy
"${port}"; then
122 hook_create
"${port}" ||
exit $?
127 exit ${EXIT_NOT_HANDLED}