Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
FFS Gluon
Commits
06d0c0f2
Unverified
Commit
06d0c0f2
authored
7 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
gluon-core: fix 200-wireless coding style
parent
2b9dd54f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless
+157
-169
157 additions, 169 deletions
package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless
with
157 additions
and
169 deletions
package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless
+
157
−
169
View file @
06d0c0f2
...
...
@@ -8,208 +8,196 @@ local uci = require('simple-uci').cursor()
-- Initial
if
not
sysconfig
.
gluon_version
then
uci
:
delete_all
(
'wireless'
,
'wifi-iface'
)
uci
:
delete_all
(
'wireless'
,
'wifi-iface'
)
end
local
function
get_channel
(
radio
,
config
)
if
uci
:
get_first
(
'gluon-core'
,
'wireless'
,
'preserve_channels'
)
then
return
uci
:
get
(
'wireless'
,
radio
,
'channel'
)
or
config
.
channel
else
return
config
.
channel
end
if
uci
:
get_first
(
'gluon-core'
,
'wireless'
,
'preserve_channels'
)
then
return
uci
:
get
(
'wireless'
,
radio
,
'channel'
)
or
config
.
channel
else
return
config
.
channel
end
end
local
function
is_disabled
(
name
)
if
uci
:
get
(
'wireless'
,
name
)
then
return
uci
:
get_bool
(
'wireless'
,
name
,
'disabled'
)
else
return
false
end
if
uci
:
get
(
'wireless'
,
name
)
then
return
uci
:
get_bool
(
'wireless'
,
name
,
'disabled'
)
else
return
false
end
end
-- Returns the first argument that is not nil; don't call without any non-nil arguments!
local
function
first_non_nil
(
first
,
...
)
if
first
~=
nil
then
return
first
else
return
first_non_nil
(
...
)
end
if
first
~=
nil
then
return
first
else
return
first_non_nil
(
...
)
end
end
local
function
configure_ibss
(
config
,
radio
,
index
,
suffix
,
disabled
)
local
name
=
'ibss_'
..
radio
uci
:
delete
(
'network'
,
name
)
uci
:
delete
(
'network'
,
name
..
'_vlan'
)
uci
:
delete
(
'wireless'
,
name
)
if
not
config
then
return
end
local
macaddr
=
util
.
get_wlan_mac
(
uci
,
radio
,
index
,
3
)
if
not
macaddr
then
return
end
if
config
.
vlan
then
uci
:
section
(
'network'
,
'interface'
,
name
,
{
proto
=
'none'
,
}
)
uci
:
section
(
'network'
,
'interface'
,
name
..
'_vlan'
,
{
ifname
=
'@'
..
name
..
'.'
..
config
.
vlan
,
proto
=
'gluon_mesh'
,
}
)
else
uci
:
section
(
'network'
,
'interface'
,
name
,
{
proto
=
'gluon_mesh'
,
}
)
end
uci
:
section
(
'wireless'
,
'wifi-iface'
,
name
,
{
device
=
radio
,
network
=
name
,
mode
=
'adhoc'
,
ssid
=
config
.
ssid
,
bssid
=
config
.
bssid
,
macaddr
=
macaddr
,
mcast_rate
=
config
.
mcast_rate
,
ifname
=
suffix
and
'ibss'
..
suffix
,
disabled
=
disabled
,
}
)
local
name
=
'ibss_'
..
radio
uci
:
delete
(
'network'
,
name
)
uci
:
delete
(
'network'
,
name
..
'_vlan'
)
uci
:
delete
(
'wireless'
,
name
)
if
not
config
then
return
end
local
macaddr
=
util
.
get_wlan_mac
(
uci
,
radio
,
index
,
3
)
if
not
macaddr
then
return
end
if
config
.
vlan
then
uci
:
section
(
'network'
,
'interface'
,
name
,
{
proto
=
'none'
,
})
uci
:
section
(
'network'
,
'interface'
,
name
..
'_vlan'
,
{
ifname
=
'@'
..
name
..
'.'
..
config
.
vlan
,
proto
=
'gluon_mesh'
,
})
else
uci
:
section
(
'network'
,
'interface'
,
name
,
{
proto
=
'gluon_mesh'
,
})
end
uci
:
section
(
'wireless'
,
'wifi-iface'
,
name
,
{
device
=
radio
,
network
=
name
,
mode
=
'adhoc'
,
ssid
=
config
.
ssid
,
bssid
=
config
.
bssid
,
macaddr
=
macaddr
,
mcast_rate
=
config
.
mcast_rate
,
ifname
=
suffix
and
'ibss'
..
suffix
,
disabled
=
disabled
,
})
end
local
function
configure_mesh
(
config
,
radio
,
index
,
suffix
,
disabled
)
local
name
=
'mesh_'
..
radio
local
macfilter
=
uci
:
get
(
'wireless'
,
name
,
'macfilter'
)
local
maclist
=
uci
:
get
(
'wireless'
,
name
,
'maclist'
)
uci
:
delete
(
'network'
,
name
)
uci
:
delete
(
'network'
,
name
..
'_vlan'
)
uci
:
delete
(
'wireless'
,
name
)
if
not
config
then
return
end
local
macaddr
=
util
.
get_wlan_mac
(
uci
,
radio
,
index
,
2
)
if
not
macaddr
then
return
end
uci
:
section
(
'network'
,
'interface'
,
name
,
{
proto
=
'gluon_mesh'
,
}
)
uci
:
section
(
'wireless'
,
'wifi-iface'
,
name
,
{
device
=
radio
,
network
=
name
,
mode
=
'mesh'
,
mesh_id
=
config
.
id
,
mesh_fwding
=
false
,
macaddr
=
macaddr
,
mcast_rate
=
config
.
mcast_rate
,
ifname
=
suffix
and
'mesh'
..
suffix
,
disabled
=
disabled
,
macfilter
=
macfilter
,
maclist
=
maclist
,
}
)
local
name
=
'mesh_'
..
radio
local
macfilter
=
uci
:
get
(
'wireless'
,
name
,
'macfilter'
)
local
maclist
=
uci
:
get
(
'wireless'
,
name
,
'maclist'
)
uci
:
delete
(
'network'
,
name
)
uci
:
delete
(
'network'
,
name
..
'_vlan'
)
uci
:
delete
(
'wireless'
,
name
)
if
not
config
then
return
end
local
macaddr
=
util
.
get_wlan_mac
(
uci
,
radio
,
index
,
2
)
if
not
macaddr
then
return
end
uci
:
section
(
'network'
,
'interface'
,
name
,
{
proto
=
'gluon_mesh'
,
})
uci
:
section
(
'wireless'
,
'wifi-iface'
,
name
,
{
device
=
radio
,
network
=
name
,
mode
=
'mesh'
,
mesh_id
=
config
.
id
,
mesh_fwding
=
false
,
macaddr
=
macaddr
,
mcast_rate
=
config
.
mcast_rate
,
ifname
=
suffix
and
'mesh'
..
suffix
,
disabled
=
disabled
,
macfilter
=
macfilter
,
maclist
=
maclist
,
})
end
local
function
fixup_wan
(
radio
,
index
)
local
name
=
'wan_'
..
radio
local
name
=
'wan_'
..
radio
if
not
uci
:
get
(
'wireless'
,
name
)
then
return
end
if
not
uci
:
get
(
'wireless'
,
name
)
then
return
end
local
macaddr
=
util
.
get_wlan_mac
(
uci
,
radio
,
index
,
4
)
if
not
macaddr
then
return
end
local
macaddr
=
util
.
get_wlan_mac
(
uci
,
radio
,
index
,
4
)
if
not
macaddr
then
return
end
uci
:
set
(
'wireless'
,
name
,
'macaddr'
,
macaddr
)
uci
:
set
(
'wireless'
,
name
,
'macaddr'
,
macaddr
)
end
local
function
configure_radio
(
radio
,
index
,
config
)
if
not
config
then
return
end
local
suffix
=
radio
:
match
(
'^radio(%d+)$'
)
if
not
suffix
then
return
end
local
channel
=
get_channel
(
radio
,
config
)
uci
:
delete
(
'wireless'
,
radio
,
'disabled'
)
uci
:
set
(
'wireless'
,
radio
,
'channel'
,
channel
)
uci
:
set
(
'wireless'
,
radio
,
'htmode'
,
'HT20'
)
uci
:
set
(
'wireless'
,
radio
,
'country'
,
site
.
regdom
)
if
config
.
supported_rates
then
uci
:
set_list
(
'wireless'
,
radio
,
'supported_rates'
,
config
.
supported_rates
)
else
uci
:
delete
(
'wireless'
,
radio
,
'supported_rates'
)
end
if
config
.
basic_rate
then
uci
:
set_list
(
'wireless'
,
radio
,
'basic_rate'
,
config
.
basic_rate
)
else
uci
:
delete
(
'wireless'
,
radio
,
'basic_rate'
)
end
local
ibss_disabled
=
is_disabled
(
'ibss_'
..
radio
)
local
mesh_disabled
=
is_disabled
(
'mesh_'
..
radio
)
configure_ibss
(
config
.
ibss
,
radio
,
index
,
suffix
,
first_non_nil
(
ibss_disabled
,
mesh_disabled
,
(
config
.
ibss
or
{}).
disabled
,
-- will be nil if config.ibss or config.ibss.disabled is unset
false
)
)
configure_mesh
(
config
.
mesh
,
radio
,
index
,
suffix
,
first_non_nil
(
mesh_disabled
,
ibss_disabled
,
(
config
.
mesh
or
{}).
disabled
,
-- will be nil if config.mesh or config.mesh.disabled is unset
false
)
)
fixup_wan
(
radio
,
index
)
if
not
config
then
return
end
local
suffix
=
radio
:
match
(
'^radio(%d+)$'
)
if
not
suffix
then
return
end
local
channel
=
get_channel
(
radio
,
config
)
uci
:
delete
(
'wireless'
,
radio
,
'disabled'
)
uci
:
set
(
'wireless'
,
radio
,
'channel'
,
channel
)
uci
:
set
(
'wireless'
,
radio
,
'htmode'
,
'HT20'
)
uci
:
set
(
'wireless'
,
radio
,
'country'
,
site
.
regdom
)
if
config
.
supported_rates
then
uci
:
set_list
(
'wireless'
,
radio
,
'supported_rates'
,
config
.
supported_rates
)
else
uci
:
delete
(
'wireless'
,
radio
,
'supported_rates'
)
end
if
config
.
basic_rate
then
uci
:
set_list
(
'wireless'
,
radio
,
'basic_rate'
,
config
.
basic_rate
)
else
uci
:
delete
(
'wireless'
,
radio
,
'basic_rate'
)
end
local
ibss_disabled
=
is_disabled
(
'ibss_'
..
radio
)
local
mesh_disabled
=
is_disabled
(
'mesh_'
..
radio
)
configure_ibss
(
config
.
ibss
,
radio
,
index
,
suffix
,
first_non_nil
(
ibss_disabled
,
mesh_disabled
,
(
config
.
ibss
or
{}).
disabled
,
-- will be nil if config.ibss or config.ibss.disabled is unset
false
)
)
configure_mesh
(
config
.
mesh
,
radio
,
index
,
suffix
,
first_non_nil
(
mesh_disabled
,
ibss_disabled
,
(
config
.
mesh
or
{}).
disabled
,
-- will be nil if config.mesh or config.mesh.disabled is unset
false
)
)
fixup_wan
(
radio
,
index
)
end
util
.
iterate_radios
(
uci
,
configure_radio
)
if
uci
:
get
(
'system'
,
'rssid_wlan0'
)
then
if
uci
:
get
(
'wireless'
,
'mesh_radio0'
)
then
uci
:
set
(
'system'
,
'rssid_wlan0'
,
'dev'
,
'mesh0'
)
else
uci
:
set
(
'system'
,
'rssid_wlan0'
,
'dev'
,
'ibss0'
)
end
if
uci
:
get
(
'wireless'
,
'mesh_radio0'
)
then
uci
:
set
(
'system'
,
'rssid_wlan0'
,
'dev'
,
'mesh0'
)
else
uci
:
set
(
'system'
,
'rssid_wlan0'
,
'dev'
,
'ibss0'
)
end
uci
:
save
(
'system'
)
uci
:
save
(
'system'
)
end
uci
:
save
(
'wireless'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment