Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Quick Mesh Project
qMp packages
Commits
0fbd5610
Commit
0fbd5610
authored
Sep 28, 2012
by
Simó Albert i Beltran
Browse files
sed -i -e 's/\s\+$//g' packages/bmx6-luci/files/usr/lib/lua/luci/controller/bmx6.lua
parent
fd5537c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
packages/bmx6-luci/files/usr/lib/lua/luci/controller/bmx6.lua
View file @
0fbd5610
...
...
@@ -23,40 +23,40 @@
local
bmx6json
=
require
(
"luci.model.bmx6json"
)
module
(
"luci.controller.bmx6"
,
package
.
seeall
)
function
index
()
local
place
=
{}
local
place
=
{}
local
ucim
=
require
"luci.model.uci"
local
uci
=
ucim
.
cursor
()
-- checking if ignore is on
if
uci
:
get
(
"luci-bmx6"
,
"luci"
,
"ignore"
)
==
"1"
then
return
nil
end
-- getting value from uci database
local
uci_place
=
uci
:
get
(
"luci-bmx6"
,
"luci"
,
"place"
)
-- default values
if
uci_place
==
nil
then
place
=
{
"bmx6"
}
else
if
uci_place
==
nil
then
place
=
{
"bmx6"
}
else
local
util
=
require
"luci.util"
place
=
util
.
split
(
uci_place
,
" "
)
end
---------------------------
-- Starting with the pages
---------------------------
--- neighbours/descriptions (default)
entry
(
place
,
call
(
"action_neighbours_j"
),
place
[
#
place
])
table.insert
(
place
,
"neighbours_nojs"
)
entry
(
place
,
call
(
"action_neighbours_j"
),
place
[
#
place
])
table.insert
(
place
,
"neighbours_nojs"
)
entry
(
place
,
call
(
"action_neighbours"
),
nil
)
table.remove
(
place
)
--- status (this is default one)
table.insert
(
place
,
"Status"
)
entry
(
place
,
call
(
"action_status"
),
"Status"
)
entry
(
place
,
call
(
"action_status"
),
"Status"
)
table.remove
(
place
)
--- links
...
...
@@ -66,54 +66,54 @@ function index()
--- chat
table.insert
(
place
,
"Chat"
)
entry
(
place
,
call
(
"action_chat"
),
"Chat"
)
entry
(
place
,
call
(
"action_chat"
),
"Chat"
)
table.remove
(
place
)
--- Graph
table.insert
(
place
,
"Graph"
)
table.insert
(
place
,
"Graph"
)
entry
(
place
,
template
(
"bmx6/graph"
),
"Graph"
)
table.remove
(
place
)
--- Topology (hidden)
table.insert
(
place
,
"topology"
)
table.insert
(
place
,
"topology"
)
entry
(
place
,
call
(
"action_topology"
),
nil
)
table.remove
(
place
)
--- configuration (CBI)
table.insert
(
place
,
"Configuration"
)
entry
(
place
,
cbi
(
"bmx6/main"
),
"Configuration"
).
dependent
=
false
table.insert
(
place
,
"Advanced"
)
table.insert
(
place
,
"Advanced"
)
entry
(
place
,
cbi
(
"bmx6/advanced"
),
"Advanced"
)
table.remove
(
place
)
table.insert
(
place
,
"Interfaces"
)
table.insert
(
place
,
"Interfaces"
)
entry
(
place
,
cbi
(
"bmx6/interfaces"
),
"Interfaces"
)
table.remove
(
place
)
table.insert
(
place
,
"Plugins"
)
table.insert
(
place
,
"Plugins"
)
entry
(
place
,
cbi
(
"bmx6/plugins"
),
"Plugins"
)
table.remove
(
place
)
table.insert
(
place
,
"HNA"
)
table.insert
(
place
,
"HNA"
)
entry
(
place
,
cbi
(
"bmx6/hna"
),
"HNA"
)
table.remove
(
place
)
table.remove
(
place
)
table.remove
(
place
)
end
function
action_status
()
local
status
=
bmx6json
.
get
(
"status"
).
status
or
nil
local
interfaces
=
bmx6json
.
get
(
"interfaces"
).
interfaces
or
nil
if
status
==
nil
or
interfaces
==
nil
then
luci
.
template
.
render
(
"bmx6/error"
,
{
txt
=
"Cannot fetch data from bmx6 json"
})
luci
.
template
.
render
(
"bmx6/error"
,
{
txt
=
"Cannot fetch data from bmx6 json"
})
else
luci
.
template
.
render
(
"bmx6/status"
,
{
status
=
status
,
interfaces
=
interfaces
})
end
end
function
action_neighbours
()
local
orig_list
=
bmx6json
.
get
(
"originators"
).
originators
or
nil
...
...
@@ -127,32 +127,32 @@ function action_neighbours()
local
orig
=
nil
local
name
=
""
local
ipv4
=
""
for
_
,
o
in
ipairs
(
orig_list
)
do
orig
=
bmx6json
.
get
(
"originators/"
..
o
.
name
)
or
{}
desc
=
bmx6json
.
get
(
"descriptions/"
..
o
.
name
)
or
{}
if
string.find
(
o
.
name
,
'.'
)
then
name
=
luci
.
util
.
split
(
o
.
name
,
'.'
)[
1
]
else
name
=
o
.
name
end
--Not sure about that, but trying to find main ipv4 from HNA6 published by each node
--Not sure about that, but trying to find main ipv4 from HNA6 published by each node
if
desc
.
DESC_ADV
~=
nil
then
for
_
,
h
in
ipairs
(
desc
.
DESC_ADV
.
extensions
[
2
].
HNA6_EXTENSION
)
do
if
h
~=
nil
and
string.find
(
h
.
address
,
"::ffff:"
)
then
ipv4
=
string.gsub
(
h
.
address
,
"::ffff:"
,
""
)
break
end
end
end
end
if
ipv4
==
""
then
if
ipv4
==
""
then
ipv4
=
"0.0.0.0"
end
table.insert
(
originators
,{
name
=
name
,
ipv4
=
ipv4
,
orig
=
orig
,
desc
=
desc
})
end
...
...
@@ -178,11 +178,11 @@ function action_links(host)
end
for
_
,
l
in
ipairs
(
links
)
do
l
.
globalId
=
luci
.
util
.
split
(
l
.
globalId
,
'.'
)[
1
]
table.insert
(
devlinks
[
l
.
viaDev
],
l
)
table.insert
(
devlinks
[
l
.
viaDev
],
l
)
end
end
luci
.
template
.
render
(
"bmx6/links"
,
{
links
=
devlinks
})
luci
.
template
.
render
(
"bmx6/links"
,
{
links
=
devlinks
})
end
function
action_topology
()
...
...
@@ -202,7 +202,7 @@ function action_topology()
end
luci
.
http
.
write
(
'{ "globalId": "%s", "links": ['
%
o
.
globalId
:
match
(
"^[^%.]+"
))
local
first2
=
true
for
i2
,
l
in
ipairs
(
links
.
links
)
do
...
...
@@ -211,12 +211,12 @@ function action_topology()
else
luci
.
http
.
write
(
', '
)
end
luci
.
http
.
write
(
'{ "globalId": "%s", "rxRate": %s, "txRate": %s }'
%
{
l
.
globalId
:
match
(
"^[^%.]+"
),
l
.
rxRate
,
l
.
txRate
})
end
luci
.
http
.
write
(
']}'
)
end
...
...
@@ -257,11 +257,11 @@ function action_chat()
fd
=
io.open
(
sms_path
,
"r"
)
chat
[
sender
]
=
fd
:
read
()
fd
:
close
()
fd
:
close
()
end
end
to_send
=
luci
.
http
.
formvalue
(
"toSend"
)
to_send
=
luci
.
http
.
formvalue
(
"toSend"
)
if
to_send
~=
nil
and
#
to_send
>
1
then
fd
=
io.open
(
send_file
,
"w"
)
fd
:
write
(
to_send
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment