Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John Crispin <john@phrozen.org>
- Loading branch information
Showing
18 changed files
with
1,075 additions
and
3 deletions.
There are no files selected for viewing
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
89 changes: 89 additions & 0 deletions
89
feeds/ucentral/ucentral-schema/files/etc/ucentral/examples/quality-threshold.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,89 @@ | ||
{ | ||
"uuid": 2, | ||
"radios": [ | ||
{ | ||
"band": "2G", | ||
"country": "CA", | ||
"channel-mode": "HE", | ||
"channel-width": 80, | ||
"channel": 32 | ||
} | ||
], | ||
|
||
"interfaces": [ | ||
{ | ||
"name": "WAN", | ||
"role": "upstream", | ||
"services": [ "lldp" ], | ||
"ethernet": [ | ||
{ | ||
"select-ports": [ | ||
"WAN*" | ||
] | ||
} | ||
], | ||
"ipv4": { | ||
"addressing": "dynamic" | ||
}, | ||
"ssids": [ | ||
{ | ||
"name": "OpenWifi", | ||
"wifi-bands": [ | ||
"2G" | ||
], | ||
"bss-mode": "ap", | ||
"encryption": { | ||
"proto": "psk2", | ||
"key": "OpenWifi", | ||
"ieee80211w": "optional" | ||
}, | ||
"quality-thresholds" : { | ||
"probe-request-rssi": -60, | ||
"assoctiation-request-rssi": -60, | ||
"client-kick-rssi": -65, | ||
"client-kick-ban-time": 60 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "LAN", | ||
"role": "downstream", | ||
"services": [ "ssh", "lldp" ], | ||
"ethernet": [ | ||
{ | ||
"select-ports": [ | ||
"LAN*" | ||
] | ||
} | ||
], | ||
"ipv4": { | ||
"addressing": "static", | ||
"subnet": "192.168.1.1/24", | ||
"dhcp": { | ||
"lease-first": 10, | ||
"lease-count": 100, | ||
"lease-time": "6h" | ||
} | ||
} | ||
} | ||
], | ||
"metrics": { | ||
"statistics": { | ||
"interval": 120, | ||
"types": [ "ssids", "lldp", "clients" ] | ||
}, | ||
"health": { | ||
"interval": 120 | ||
} | ||
}, | ||
"services": { | ||
"lldp": { | ||
"describe": "uCentral", | ||
"location": "universe" | ||
}, | ||
"ssh": { | ||
"port": 22 | ||
} | ||
} | ||
} |
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,34 @@ | ||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=ucrun | ||
PKG_RELEASE:=1 | ||
|
||
PKG_SOURCE_PROTO:=git | ||
PKG_SOURCE_URL=https://github.com/ucentral-io/ucrun.git | ||
PKG_MIRROR_HASH:=52aeece27348611197ae5f4b96b3bdf1b5d028ae4ae284806b216d502300d07a | ||
PKG_SOURCE_DATE:=2022-02-19 | ||
PKG_SOURCE_VERSION:=5be6abebc4ae6057b47a5b3f0799d5ff01bc60c3 | ||
CMAKE_INSTALL:=1 | ||
|
||
PKG_LICENSE:=GPL-2.0-only | ||
PKG_LICENSE_FILES:=GPL | ||
|
||
PKG_MAINTAINER:=John Crispin <john@phrozen.org> | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
include $(INCLUDE_DIR)/cmake.mk | ||
|
||
define Package/ucrun | ||
SECTION:=utils | ||
CATEGORY:=Utilities | ||
DEPENDS:=+libubox +ucode +ucode-mod-uci +ucode-mod-ubus +ucode-mod-fs | ||
TITLE:=uCode main-loop daemon | ||
endef | ||
|
||
define Package/ucrun/install | ||
$(INSTALL_DIR) $(1)/usr/bin | ||
|
||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ucrun $(1)/usr/bin | ||
endef | ||
|
||
$(eval $(call BuildPackage,ucrun)) |
138 changes: 138 additions & 0 deletions
138
feeds/ucentral/ucrun/patches/0001-ulog-add-ringbuffer-and-log_event-notification.patch
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,138 @@ | ||
From b24a5a890ccd19b0f1b50340c79c5087f08d9447 Mon Sep 17 00:00:00 2001 | ||
From: John Crispin <john@phrozen.org> | ||
Date: Fri, 4 Mar 2022 15:56:30 +0100 | ||
Subject: [PATCH] ulog: add ringbuffer and log_event notification | ||
|
||
Signed-off-by: John Crispin <john@phrozen.org> | ||
--- | ||
ucode.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- | ||
1 file changed, 73 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/ucode.c b/ucode.c | ||
index cef50e2..9e0373a 100644 | ||
--- a/ucode.c | ||
+++ b/ucode.c | ||
@@ -31,6 +31,17 @@ static const char *exception_types[] = { | ||
[EXCEPTION_EXIT] = "Exit" | ||
}; | ||
|
||
+struct log_buffer { | ||
+ struct list_head list; | ||
+ int severity; | ||
+ char entry[]; | ||
+}; | ||
+ | ||
+static LIST_HEAD(log_buffer); | ||
+static int log_count; | ||
+static int log_max = 100; | ||
+static uc_value_t *log_event; | ||
+ | ||
static void | ||
ucode_handle_exception(uc_vm_t *vm, uc_exception_t *ex) | ||
{ | ||
@@ -287,6 +298,7 @@ static uc_value_t * | ||
uc_ulog(uc_vm_t *vm, size_t nargs, int severity) | ||
{ | ||
uc_value_t *res; | ||
+ char *entry; | ||
|
||
if (!fmtfn) { | ||
fmtfn = (uc_cfunction_t *)ucv_object_get(uc_vm_scope_get(vm), "sprintf", NULL); | ||
@@ -300,7 +312,37 @@ uc_ulog(uc_vm_t *vm, size_t nargs, int severity) | ||
if (!res) | ||
return ucv_int64_new(-1); | ||
|
||
- ulog(severity, "%s", ucv_string_get(res)); | ||
+ entry = ucv_string_get(res); | ||
+ | ||
+ if (log_max) { | ||
+ struct log_buffer *log = calloc(1, sizeof(*log) + strlen(entry) + 1); | ||
+ | ||
+ strcpy(log->entry, entry); | ||
+ log->severity = severity; | ||
+ list_add_tail(&log->list, &log_buffer); | ||
+ | ||
+ if (log_event) { | ||
+ uc_value_t *event = ucv_array_new(vm); | ||
+ | ||
+ ucv_array_push(event, ucv_int64_new(severity)); | ||
+ ucv_array_push(event, ucv_string_new(entry)); | ||
+ | ||
+ uc_vm_stack_push(vm, ucv_get(log_event)); | ||
+ uc_vm_stack_push(vm, ucv_get(event)); | ||
+ uc_vm_call(vm, false, 1); | ||
+ } | ||
+ | ||
+ if (log_count == log_max) { | ||
+ struct log_buffer *first = list_first_entry(&log_buffer, struct log_buffer, list); | ||
+ | ||
+ list_del(&first->list); | ||
+ free(first); | ||
+ } else { | ||
+ log_count++; | ||
+ } | ||
+ } | ||
+ | ||
+ ulog(severity, "%s", entry); | ||
ucv_put(res); | ||
|
||
return ucv_int64_new(0); | ||
@@ -330,11 +372,27 @@ uc_ulog_err(uc_vm_t *vm, size_t nargs) | ||
return uc_ulog(vm, nargs, LOG_ERR); | ||
} | ||
|
||
+static uc_value_t * | ||
+uc_ulog_dump(uc_vm_t *vm, size_t nargs) | ||
+{ | ||
+ uc_value_t *log = ucv_array_new(vm); | ||
+ struct log_buffer *iter; | ||
+ | ||
+ list_for_each_entry(iter, &log_buffer, list) { | ||
+ uc_value_t *entry = ucv_array_new(vm); | ||
+ ucv_array_push(entry, ucv_int64_new(iter->severity)); | ||
+ ucv_array_push(entry, ucv_string_new(iter->entry)); | ||
+ ucv_array_push(log, entry); | ||
+ } | ||
+ | ||
+ return log; | ||
+} | ||
+ | ||
static void | ||
ucode_init_ulog(ucrun_ctx_t *ucrun) | ||
{ | ||
uc_value_t *ulog = ucv_object_get(ucrun->scope, "ulog", NULL); | ||
- uc_value_t *identity, *channels; | ||
+ uc_value_t *identity, *channels, *logsize; | ||
int flags = 0, channel; | ||
|
||
/* make sure the declartion is complete */ | ||
@@ -365,6 +423,18 @@ ucode_init_ulog(ucrun_ctx_t *ucrun) | ||
flags |= ULOG_STDIO; | ||
} | ||
|
||
+ /* set the internal ring buffer size */ | ||
+ logsize = ucv_object_get(ulog, "channels", NULL); | ||
+ if (ucv_type(logsize) == UC_INTEGER && ucv_int64_get(logsize)) | ||
+ log_max = ucv_int64_get(logsize); | ||
+ | ||
+ /* find out if ucrun wants a notification when a new log entry is generated */ | ||
+ log_event = ucv_object_get(ulog, "event", NULL); | ||
+ if (ucv_is_callable(log_event)) | ||
+ ucv_get(log_event); | ||
+ else | ||
+ log_event = NULL; | ||
+ | ||
/* open the log */ | ||
ucrun->ulog_identity = strdup(ucv_string_get(identity)); | ||
ulog_open(flags, LOG_DAEMON, ucrun->ulog_identity); | ||
@@ -404,6 +474,7 @@ ucode_init(ucrun_ctx_t *ucrun, int argc, const char **argv, int *rc) | ||
uc_function_register(ucrun->scope, "ulog_note", uc_ulog_note); | ||
uc_function_register(ucrun->scope, "ulog_warn", uc_ulog_warn); | ||
uc_function_register(ucrun->scope, "ulog_err", uc_ulog_err); | ||
+ uc_function_register(ucrun->scope, "ulog_dump", uc_ulog_dump); | ||
|
||
/* add commandline parameters */ | ||
ARGV = ucv_array_new(&ucrun->vm); | ||
-- | ||
2.25.1 | ||
|
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,27 @@ | ||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=usteer2 | ||
PKG_RELEASE:=1 | ||
PKG_LICENSE:=ISC | ||
|
||
PKG_MAINTAINER:=John Crispin <john@phrozen.org> | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/usteer2 | ||
SECTION:=utils | ||
CATEGORY:=Utilities | ||
DEPENDS:=+ucrun | ||
TITLE:=wifi client steering | ||
endef | ||
|
||
define Build/Compile/Default | ||
|
||
endef | ||
Build/Compile = $(Build/Compile/Default) | ||
|
||
define Package/usteer2/install | ||
$(CP) ./files/* $(1)/ | ||
endef | ||
|
||
$(eval $(call BuildPackage,usteer2)) |
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,9 @@ | ||
config base | ||
option station_update 1000 | ||
option station_expiry 120 | ||
|
||
config policy | ||
option name snr | ||
option min_snr_kick_delay 5 | ||
option kick_reason 5 | ||
option interval 1000 |
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,13 @@ | ||
#!/bin/sh /etc/rc.common | ||
|
||
START=99 | ||
STOP=01 | ||
|
||
USE_PROCD=1 | ||
|
||
start_service() { | ||
procd_open_instance | ||
procd_set_param command /usr/bin/usteer.uc | ||
procd_set_param respawn 3600 5 0 | ||
procd_close_instance | ||
} |
Oops, something went wrong.