]>
git.ipfire.org Git - people/stevee/network.git/blob - functions.wireless
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
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 function wireless_create
() {
31 while [ $# -gt 0 ]; do
34 address
=$
(cli_get_val
${1})
37 phy
=$
(cli_get_val
${1})
41 type=$
(cli_get_val
${1})
44 [ "${type}" = "ap" ] && type="__ap"
47 error
"Unrecognized argument: ${1}"
54 assert isoneof
type managed __ap
55 assert phy_exists
${phy}
56 isset address || address
=$
(mac_generate
)
58 cmd_quiet iw phy
${phy} interface add ${device} type ${type}
61 if [ ${ret} -eq ${EXIT_OK} ]; then
62 log DEBUG
"created wireless device '${device}' (${type})"
64 if isset address
; then
65 device_set_address
${device} ${address}
68 log ERROR
"could not create wireless device '${device}' (${type}): ${ret}"
74 function wireless_remove
() {
78 if ! device_exists
${device}; then
82 # Tear down the device (if necessary).
83 device_set_down
${device}
86 cmd_quiet iw dev
${device} del
89 if [ ${ret} -eq ${EXIT_OK} ]; then
90 log DEBUG
"removed wireless device '${device}'"
92 log ERROR
"could not remove wireless device '${device}': ${ret}"
98 function wireless_set_channel
() {
105 device_exists
${device} ||
return ${EXIT_ERROR}
107 cmd_quiet iw dev
${device} set channel
${channel}