-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared-state mesh information packages async implmentation and reference state #1112
Changes from 32 commits
97c6e58
9221be5
5a36c2c
9ab43ff
6d1d112
8cceccc
1f72404
ccfd634
b53b37d
e686037
825e1a5
331e5f0
4f5c936
f9054bc
2495b39
991fa73
f4d2124
bea395b
49adce0
bf3dfbb
6ce5f04
8c2a7de
9c5e287
af48dd6
098de02
f6d4f11
8cd9ec5
c9084b9
c14ce5e
b95fed2
3f55caf
8034373
5312ac4
02bdc7f
a9224f9
bb44561
1eca555
0e45a85
f06d125
e85670d
b19b1ca
f46ea9a
cf4c38e
660b0ce
c27def8
e27ba12
8791409
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
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 +random-numgen shared-state-async | ||
+libubus-lua +random-numgen +shared-state-ref_state_commons shared-state-async | ||
PKGARCH:=all | ||
endef | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,16 @@ unique_append() | |
grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not used anymore should be removed ;) |
||
|
||
|
||
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 | ||
|
||
## Refference state data type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sobra una f ;-) |
||
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' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
|
@@ -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 | ||
|
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 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as packages/shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,17 @@ unique_append() | |
{ | ||
grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not used anymore should be removed, also the script should be renamed ;) |
||
|
||
## 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' | ||
uci commit shared-state | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line needs to be moved after the last |
||
|
||
## Refference state data type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sobra una f aqui tambien ;-) |
||
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' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
|
@@ -34,12 +23,13 @@ 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) | ||
|
||
local kv_fromlinks = {} | ||
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 | ||
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 | ||
|
@@ -50,8 +40,11 @@ function get_bat_links_info() | |
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 | ||
return bat_neighbors_obj | ||
return kv_fromlinks | ||
end | ||
|
||
local result = { [hostname] = get_bat_links_info() } | ||
|
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" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ define Package/$(PKG_NAME) | |
TITLE:=Node information module for shared-state | ||
MAINTAINER:= Javier <[email protected]> | ||
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \ | ||
+lime-system +ubus-lime-location shared-state | ||
+lime-system +ubus-lime-location +shared-state-ref_state_commons shared-state-async | ||
PKGARCH:=all | ||
endef | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as packages/shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
#!/bin/sh | ||
|
||
unique_append() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not used anymore should be removed, also the script should be renamed ;) |
||
{ | ||
grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
} | ||
|
||
unique_append \ | ||
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state sync node_info &> /dev/null)&)'\ | ||
/etc/crontabs/root | ||
uci set shared-state.node_info=dataType | ||
uci set shared-state.node_info.name='node_info' | ||
uci set shared-state.node_info.scope='community' | ||
uci set shared-state.node_info.ttl='2400' | ||
uci set shared-state.node_info.update_interval='33' | ||
uci commit shared-state | ||
|
||
## Refference state data type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sobra una f ;-) |
||
uci set shared-state.node_info_ref=dataType | ||
uci set shared-state.node_info_ref.name='node_info_ref' | ||
uci set shared-state.node_info_ref.scope='community' | ||
uci set shared-state.node_info_ref.ttl='2400' | ||
uci set shared-state.node_info_ref.update_interval='50' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a new line at the end of the file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an empty JSON file by default? In that case is more traditional to use an empty object
{}
instead of an empty string ;-) also we could use.json
extension to make things more explicit, if it doesn't make things much more complexThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ! that was the first attempt, but when jsonc parses the text and then transforms it back to text, it creates an empty array, not an empty json object. For me it can be a bug. ..
the documentation states that "Lua tables are converted into JSON arrays if they only contain integer keys, mixed tables are turned into JSON objects with any existing numeric keys converted into strings."