forked from libremesh/lime-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'libremesh:master' into feature/mesh-upgrade
- Loading branch information
Showing
42 changed files
with
686 additions
and
186 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
packages/lime-app/files/etc/uci-defaults/shared-state-reference_state_nodes_info_cron
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/lime-app/files/etc/uci-defaults/shared-state-reference_state_wifi_links_info_cron
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ define Package/$(PKG_NAME) | |
TITLE:=Babel links module for shared-state | ||
MAINTAINER:=Asociación Civil Altermundi <[email protected]> | ||
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \ | ||
+libubus-lua shared-state-async | ||
+libubus-lua +shared-state-ref_state_commons shared-state-async | ||
PKGARCH:=all | ||
endef | ||
|
||
|
1 change: 1 addition & 0 deletions
1
.../shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
16 changes: 9 additions & 7 deletions
16
packages/shared-state-babel_links_info/files/etc/uci-defaults/shared-state_babel_links_info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
#!/bin/sh | ||
unique_append() | ||
{ | ||
grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
} | ||
|
||
|
||
## information generator datatype | ||
uci set shared-state.babel_links_info=dataType | ||
uci set shared-state.babel_links_info.name='babel_links_info' | ||
uci set shared-state.babel_links_info.scope='community' | ||
uci set shared-state.babel_links_info.ttl='2400' | ||
uci set shared-state.babel_links_info.update_interval='30' | ||
uci commit shared-state | ||
|
||
## Reference state data type | ||
uci set shared-state.babel_links_info_ref=dataType | ||
uci set shared-state.babel_links_info_ref.name='babel_links_info_ref' | ||
uci set shared-state.babel_links_info_ref.scope='community' | ||
uci set shared-state.babel_links_info_ref.ttl='2400' | ||
uci set shared-state.babel_links_info_ref.update_interval='50' | ||
|
||
uci commit shared-state |
1 change: 1 addition & 0 deletions
1
...info/files/usr/share/shared-state/hooks/babel_links_info_ref/shared-state-update_refstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,11 @@ | |
-- ! 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') | ||
local ubus = require "ubus" | ||
local shared_state_links_info = require ("shared_state_links_info") | ||
|
||
local ifaceip = {} | ||
|
||
|
@@ -40,16 +29,16 @@ 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 | ||
end | ||
|
||
local hostname = io.input("/proc/sys/kernel/hostname"):read("*line") | ||
local result = { [hostname] = get_babel_links_info() } | ||
io.popen("shared-state-async insert babel_links_info", "w"):write(JSON.stringify(result)) | ||
shared_state_links_info.insert_in_ss_with_location(get_babel_links_info(),"babel_links_info") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ define Package/$(PKG_NAME) | |
TITLE:=Batman protocol links information module for shared-state | ||
MAINTAINER:= Javier <[email protected]> | ||
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \ | ||
+lime-system +batctl-default shared-state-async | ||
+lime-system +batctl-default +shared-state-ref_state_commons shared-state-async | ||
PKGARCH:=all | ||
endef | ||
|
||
|
1 change: 1 addition & 0 deletions
1
...ages/shared-state-bat_links_info/files/etc/shared-state/ref_state/bat_links_info_ref.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
16 changes: 16 additions & 0 deletions
16
packages/shared-state-bat_links_info/files/etc/uci-defaults/shared-state_bat_links_info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
## information generator datatype | ||
uci set shared-state.bat_links_info=dataType | ||
uci set shared-state.bat_links_info.name='bat_links_info' | ||
uci set shared-state.bat_links_info.scope='community' | ||
uci set shared-state.bat_links_info.ttl='2400' | ||
uci set shared-state.bat_links_info.update_interval='30' | ||
|
||
## Reference state data type | ||
uci set shared-state.bat_links_info_ref=dataType | ||
uci set shared-state.bat_links_info_ref.name='bat_links_info_ref' | ||
uci set shared-state.bat_links_info_ref.scope='community' | ||
uci set shared-state.bat_links_info_ref.ttl='2400' | ||
uci set shared-state.bat_links_info_ref.update_interval='50' | ||
|
||
uci commit shared-state |
13 changes: 0 additions & 13 deletions
13
packages/shared-state-bat_links_info/files/etc/uci-defaults/shared-state_bat_links_info_cron
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...s_info/files/usr/share/shared-state/hooks/bat_links_info_ref/shared-state-update_refstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,12 @@ | |
--! 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') | ||
local network = require ("lime.network") | ||
|
||
local hostname = utils.hostname() | ||
local shared_state_links_info = require ("shared_state_links_info") | ||
|
||
function get_bat_links_info() | ||
local bat_neighbors_obj={} | ||
|
@@ -34,25 +22,30 @@ function get_bat_links_info() | |
bat_neighbors = string.gsub(bat_neighbors,"neigh_address","dst_mac") | ||
bat_neighbors = string.gsub(bat_neighbors,"hard_ifname","iface") | ||
bat_neighbors_obj = JSON.parse(bat_neighbors) | ||
|
||
for key,neight_value in pairs (bat_neighbors_obj) do | ||
local macparts = network.get_mac(neight_value.iface) | ||
local src_macaddr = table.concat(macparts,":") | ||
neight_value.hard_ifindex=nil | ||
neight_value.src_mac=src_macaddr | ||
for key,originator_value in pairs (bat_originators_obj) do | ||
if originator_value.hard_ifname == neight_value.iface and | ||
originator_value.neigh_address== originator_value.orig_address and | ||
originator_value.neigh_address== neight_value.dst_mac then | ||
-- Batman "transmit link quality" (tq) is a byte that describes | ||
-- the probability of a successful transmission towards a | ||
-- neighbor node | ||
neight_value.tq = originator_value.tq | ||
local kv_fromlinks = {} | ||
if bat_neighbors_obj then | ||
for key,neight_value in pairs (bat_neighbors_obj) do | ||
local macparts = network.get_mac(neight_value.iface) | ||
local src_macaddr = table.concat(macparts,":") | ||
neight_value.hard_ifindex=nil | ||
neight_value.src_mac=string.lower(src_macaddr) | ||
neight_value.dst_mac=string.lower(neight_value.dst_mac) | ||
for key,originator_value in pairs (bat_originators_obj) do | ||
if originator_value.hard_ifname == neight_value.iface and | ||
originator_value.neigh_address== originator_value.orig_address and | ||
originator_value.neigh_address== neight_value.dst_mac then | ||
-- Batman "transmit link quality" (tq) is a byte that describes | ||
-- the probability of a successful transmission towards a | ||
-- neighbor node | ||
neight_value.tq = originator_value.tq | ||
end | ||
end | ||
local key_table = {(string.gsub(neight_value.src_mac,":","")),(string.gsub(neight_value.dst_mac,":",""))} | ||
table.sort(key_table) | ||
kv_fromlinks[table.concat(key_table)]=neight_value | ||
end | ||
end | ||
return bat_neighbors_obj | ||
return kv_fromlinks | ||
end | ||
|
||
local result = { [hostname] = get_bat_links_info() } | ||
io.popen("shared-state-async insert bat_links_info", "w"):write(JSON.stringify(result)) | ||
shared_state_links_info.insert_in_ss_with_location(get_bat_links_info(),"bat_links_info") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ | ||
"LiMe-430b0c": [ | ||
{ | ||
"dst_mac": "02:cc:4e:1f:73:aa", | ||
"last_seen_msecs": 1560, | ||
"tq": 255, | ||
"src_mac": "02:cc:4e:43:0b:0c", | ||
"iface": "wlan2-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:1f:73:aa", | ||
"last_seen_msecs": 1000, | ||
"tq": 255, | ||
"src_mac": "02:ab:46:43:0b:0c", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:dd:69:1c", | ||
"last_seen_msecs": 1670, | ||
"tq": 251, | ||
"src_mac": "02:ab:46:43:0b:0c", | ||
"iface": "wlan1-mesh_29" | ||
} | ||
], | ||
"cheche": [ | ||
{ | ||
"dst_mac": "02:ab:46:dd:69:1c", | ||
"last_seen_msecs": 20, | ||
"tq": 255, | ||
"src_mac": "02:ab:46:1f:73:aa", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:43:0b:0c", | ||
"last_seen_msecs": 1300, | ||
"tq": 251, | ||
"src_mac": "02:ab:46:1f:73:aa", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:cc:4e:43:0b:0c", | ||
"last_seen_msecs": 900, | ||
"tq": 242, | ||
"src_mac": "02:cc:4e:1f:73:aa", | ||
"iface": "wlan2-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:58:47:dd:69:1c", | ||
"last_seen_msecs": 1460, | ||
"tq": 255, | ||
"src_mac": "02:58:47:1f:73:aa", | ||
"iface": "wlan0-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:58:47:1f:73:f6", | ||
"last_seen_msecs": 520, | ||
"tq": 255, | ||
"src_mac": "02:58:47:1f:73:aa", | ||
"iface": "wlan0-mesh_29" | ||
} | ||
], | ||
"konB-11s": [ | ||
{ | ||
"dst_mac": "02:58:47:1f:73:aa", | ||
"last_seen_msecs": 1020, | ||
"tq": 255, | ||
"src_mac": "02:58:47:dd:69:1c", | ||
"iface": "wlan0-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:58:47:1f:73:f6", | ||
"last_seen_msecs": 1010, | ||
"tq": 255, | ||
"src_mac": "02:58:47:dd:69:1c", | ||
"iface": "wlan0-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:1f:73:aa", | ||
"last_seen_msecs": 540, | ||
"tq": 235, | ||
"src_mac": "02:ab:46:dd:69:1c", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:43:0b:0c", | ||
"last_seen_msecs": 1140, | ||
"tq": 255, | ||
"src_mac": "02:ab:46:dd:69:1c", | ||
"iface": "wlan1-mesh_29" | ||
} | ||
] | ||
} |
Oops, something went wrong.