Skip to content

Commit

Permalink
ref_state: adds key index to links
Browse files Browse the repository at this point in the history
  • Loading branch information
javierajorge committed May 12, 2024
1 parent b53b37d commit e686037
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
-- ! Copyright (c) 2023 Instituto Nacional de Tecnología Industrial
-- ! Copyright (C) 2023 Asociación Civil Altermundi <[email protected]>
-- !
-- ! This program is free software: you can redistribute it and/or modify
-- ! it under the terms of the GNU Affero General Public License as
-- ! published by the Free Software Foundation, either version 3 of the
-- ! License, or (at your option) any later version.
-- !
-- ! This program is distributed in the hope that it will be useful,
-- ! but WITHOUT ANY WARRANTY; without even the implied warranty of
-- ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- ! GNU Affero General Public License for more details.
-- !
-- ! You should have received a copy of the GNU Affero General Public License
-- ! along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ! SPDX-License-Identifier: AGPL-3.0-only

local JSON = require("luci.jsonc")
local utils = require('lime.utils')
Expand All @@ -40,11 +29,13 @@ function get_babel_links_info()
babelneigt_obj = ubus.call(conn, "babeld", "get_neighbours", {})
if babelneigt_obj ~= nil then
for key, value in pairs(babelneigt_obj.IPv6) do
table.insert(links, {
local key_table = {(string.gsub(get_interface_ip(value.dev),":","")),(string.gsub(key,":",""))}
table.sort(key_table)
links[table.concat(key_table)]= {
src_ip = get_interface_ip(value.dev),
dst_ip = key,
iface = value.dev
})
}
end
end
return links
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ describe('Tests network_nodes #network_nodes', function()
require("shared-state-publish_babel_links_info")

babelinfo = get_babel_links_info()
assert.are.equal('fe80::16cc:20ff:feda:4eac', babelinfo[1].dst_ip)
assert.are.equal("wlan1-mesh_17",babelinfo[1].iface)
assert.are.equal("fe80::c24a:ff:fefc:3abd",babelinfo[1].src_ip)
assert.are.equal('fe80::16cc:20ff:feda:4eac', babelinfo["fe8016cc20fffeda4eacfe80c24afffefc3abd"].dst_ip)
assert.are.equal("wlan1-mesh_17",babelinfo["fe8016cc20fffeda4eacfe80c24afffefc3abd"].iface)
assert.are.equal("fe80::c24a:ff:fefc:3abd",babelinfo["fe8016cc20fffeda4eacfe80c24afffefc3abd"].src_ip)
end)
end)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
--! Copyright (C) 2023 Javier Jorge <[email protected]>
--! Copyright (C) 2023 Asociación Civil Altermundi <[email protected]>
--!
--! This program is free software: you can redistribute it and/or modify
--! it under the terms of the GNU Affero General Public License as
--! published by the Free Software Foundation, either version 3 of the
--! License, or (at your option) any later version.
--!
--! This program is distributed in the hope that it will be useful,
--! but WITHOUT ANY WARRANTY; without even the implied warranty of
--! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--! GNU Affero General Public License for more details.
--!
--! You should have received a copy of the GNU Affero General Public License
--! along with this program. If not, see <http://www.gnu.org/licenses/>.
--! SPDX-License-Identifier: AGPL-3.0-only

local JSON = require("luci.jsonc")
local utils = require('lime.utils')
Expand Down

0 comments on commit e686037

Please sign in to comment.