added log Timestamps #42

Merged
Koda merged 1 commits from added-logs into main 2026-08-07 14:55:39 +01:00
12 changed files with 110 additions and 83 deletions
Showing only changes of commit 581cfb90bd - Show all commits
+4 -3
View File
@@ -27,6 +27,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
@@ -37,7 +38,7 @@
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
#include <stdio.h> #include <stdio.h>
extern FILE *log_fp; extern FILE *log_fp;
#define LOG(fmt, ...) do { if (log_fp) { fprintf(log_fp, "[%s] " fmt "\n", __func__, ##__VA_ARGS__); fflush(log_fp); } } while(0) #define LOG(fmt, ...) do { if (log_fp) openuf_log_emit(log_fp, __func__, fmt, ##__VA_ARGS__); } while(0)
#else #else
#define LOG(fmt, ...) do {} while(0) #define LOG(fmt, ...) do {} while(0)
#endif #endif
@@ -199,7 +200,7 @@ int announce_init(announce_ctx_t *ctx,
/* ── Socket for broadcast 255.255.255.255 ─────────────────── */ /* ── Socket for broadcast 255.255.255.255 ─────────────────── */
ctx->sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); ctx->sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (ctx->sockfd < 0) { if (ctx->sockfd < 0) {
perror("[openuf] announce socket"); LOGF(stderr, "announce socket: %s", strerror(errno));
return -1; return -1;
} }
int on = 1; int on = 1;
@@ -249,7 +250,7 @@ int announce_send(announce_ctx_t *ctx)
}; };
if (sendto(ctx->sockfd, ctx->pkt, ctx->pkt_len, 0, if (sendto(ctx->sockfd, ctx->pkt, ctx->pkt_len, 0,
(struct sockaddr *)&dest_bcast, sizeof(dest_bcast)) < 0) { (struct sockaddr *)&dest_bcast, sizeof(dest_bcast)) < 0) {
perror("[openuf] announce sendto broadcast"); LOGF(stderr, "announce sendto broadcast: %s", strerror(errno));
ret = -1; ret = -1;
} }
+28 -1
View File
@@ -21,10 +21,37 @@
#if ENABLE_LOGGING #if ENABLE_LOGGING
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
#include <time.h>
extern FILE *log_fp; extern FILE *log_fp;
#define LOG(fmt, ...) do { if (log_fp) { fprintf(log_fp, "[%s] " fmt "\n", __func__, ##__VA_ARGS__); fflush(log_fp); } } while(0)
static inline void openuf_log_emit(FILE *stream, const char *prefix,
const char *fmt, ...)
{
char ts[32];
time_t now = time(NULL);
struct tm tm;
localtime_r(&now, &tm);
strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", &tm);
fprintf(stream, "[%s]", ts);
if (prefix && prefix[0])
fprintf(stream, " [%s]", prefix);
fputc(' ', stream);
va_list ap;
va_start(ap, fmt);
vfprintf(stream, fmt, ap);
va_end(ap);
fputc('\n', stream);
fflush(stream);
}
#define LOG(fmt, ...) do { if (log_fp) openuf_log_emit(log_fp, __func__, fmt, ##__VA_ARGS__); } while(0)
#define LOGF(stream, fmt, ...) openuf_log_emit(stream, "openuf", fmt, ##__VA_ARGS__)
#else #else
#define LOG(fmt, ...) do {} while(0) #define LOG(fmt, ...) do {} while(0)
#define LOGF(stream, fmt, ...) do { (void)(stream); } while(0)
#endif #endif
typedef struct { typedef struct {
+1 -1
View File
@@ -158,7 +158,7 @@ int inform_send(openuf_state_t *st,
LOG("Response action: %s", action); LOG("Response action: %s", action);
if (strcmp(action, "noop") != 0) if (strcmp(action, "noop") != 0)
printf("[openuf] Action: %s\n", action); LOGF(stdout, "Action: %s", action);
return 0; return 0;
} }
+1 -1
View File
@@ -338,7 +338,7 @@ void inform_handle_response(openuf_state_t *st,
json_object_object_get_ex(resp, "vap_table", &vt); json_object_object_get_ex(resp, "vap_table", &vt);
int apply_ok = 0; int apply_ok = 0;
if (rt || vt) { if (rt || vt) {
printf("[openuf] Applying controller WiFi configuration...\n"); LOGF(stdout, "Applying controller WiFi configuration...");
apply_ok = wlan_apply_config(resp, model) == 0; apply_ok = wlan_apply_config(resp, model) == 0;
} else { } else {
LOG("setstate contained neither radio_table nor vap_table"); LOG("setstate contained neither radio_table nor vap_table");
+8 -10
View File
@@ -174,20 +174,19 @@ int main(int argc, char *argv[])
controller_ip); controller_ip);
} else { } else {
state.inform_url[0] = '\0'; state.inform_url[0] = '\0';
fprintf(stderr, LOGF(stderr,
"[openuf] No controller configured and no IPv4 default " "No controller configured and no IPv4 default "
"gateway found\n"); "gateway found");
} }
} }
state_save(&state); state_save(&state);
printf("[openuf] Starting version=%s model=%-8s MAC=%s IP=%s\n", LOGF(stdout, "Starting version=%s model=%-8s MAC=%s IP=%s",
OPENUF_VERSION, model->model, mac_str, ip_str); OPENUF_VERSION, model->model, mac_str, ip_str);
printf("[openuf] Controller: %s\n", state.inform_url); LOGF(stdout, "Controller: %s", state.inform_url);
printf("[openuf] Adopted: %s\n", state.adopted ? "yes" : "no"); LOGF(stdout, "Adopted: %s", state.adopted ? "yes" : "no");
printf("[openuf] LLDP available: %s\n", LOGF(stdout, "LLDP available: %s",
lldp_available() ? "yes (lldpd)" : "no (transmit only)"); lldp_available() ? "yes (lldpd)" : "no (transmit only)");
fflush(stdout);
LOG("Daemon started"); LOG("Daemon started");
@@ -212,8 +211,7 @@ int main(int argc, char *argv[])
time_t last_inform = 0; time_t last_inform = 0;
time_t last_lldp = 0; time_t last_lldp = 0;
printf("[openuf] Main loop started\n"); LOGF(stdout, "Main loop started");
fflush(stdout);
while (1) { while (1) {
time_t now = time(NULL); time_t now = time(NULL);
+1 -1
View File
@@ -8,7 +8,7 @@
#if ENABLE_LOGGING #if ENABLE_LOGGING
#include <stdio.h> #include <stdio.h>
extern FILE *log_fp; extern FILE *log_fp;
#define LOG(fmt, ...) do { if (log_fp) { fprintf(log_fp, "[%s] " fmt "\n", __func__, ##__VA_ARGS__); fflush(log_fp); } } while(0) #define LOG(fmt, ...) do { if (log_fp) openuf_log_emit(log_fp, __func__, fmt, ##__VA_ARGS__); } while(0)
#else #else
#define LOG(fmt, ...) do {} while(0) #define LOG(fmt, ...) do {} while(0)
#endif #endif
+2 -2
View File
@@ -134,13 +134,13 @@ int wlan_ensure_vap_ids(struct json_object *vaps)
char generated[25]; char generated[25];
if (!id) { if (!id) {
if (crypto_random_hex((unsigned char *)generated, 12) != 0) { if (crypto_random_hex((unsigned char *)generated, 12) != 0) {
printf("[openuf] Failed to generate a VAP ID for '%s'\n", ssid); LOGF(stdout, "Failed to generate a VAP ID for '%s'", ssid);
if (pkg) uci_unload(ctx, pkg); if (pkg) uci_unload(ctx, pkg);
if (ctx) uci_free_context(ctx); if (ctx) uci_free_context(ctx);
return -1; return -1;
} }
id = generated; id = generated;
printf("[openuf] Generated persistent VAP ID %s for '%s'\n", LOGF(stdout, "Generated persistent VAP ID %s for '%s'",
id, ssid); id, ssid);
} }
+1 -1
View File
@@ -262,7 +262,7 @@ int wlan_apply_system_cfg(const char *system_cfg,
json_object_object_add(root, "radio_table", radios); json_object_object_add(root, "radio_table", radios);
json_object_object_add(root, "vap_table", vaps); json_object_object_add(root, "vap_table", vaps);
printf("[openuf] Parsed legacy system_cfg: %zu radios, %zu VAPs\n", LOGF(stdout, "Parsed legacy system_cfg: %zu radios, %zu VAPs",
json_object_array_length(radios), json_object_array_length(vaps)); json_object_array_length(radios), json_object_array_length(vaps));
int result = wlan_apply_config(root, model); int result = wlan_apply_config(root, model);
json_object_put(root); json_object_put(root);
+33 -33
View File
@@ -63,7 +63,7 @@ static int apply_vap(struct uci_context *ctx,
vid = json_object_get_int(v); vid = json_object_get_int(v);
if (vid > 0) { if (vid > 0) {
if (wlan_ensure_vlan_network(vid) != 0) { if (wlan_ensure_vlan_network(vid) != 0) {
printf("[openuf] Failed to configure VLAN network %d\n", vid); LOGF(stdout, "Failed to configure VLAN network %d", vid);
return -1; return -1;
} }
snprintf(target_network, sizeof(target_network), "vlan%d", vid); snprintf(target_network, sizeof(target_network), "vlan%d", vid);
@@ -76,7 +76,7 @@ static int apply_vap(struct uci_context *ctx,
snprintf(sec_name, sizeof(sec_name), "openuf_%d_%s", vap_idx, safe); snprintf(sec_name, sizeof(sec_name), "openuf_%d_%s", vap_idx, safe);
if (wlan_uci_ensure_section(ctx, pkg, sec_name, "wifi-iface") != 0) { if (wlan_uci_ensure_section(ctx, pkg, sec_name, "wifi-iface") != 0) {
printf("[openuf] Failed to create VAP section '%s'\n", sec_name); LOGF(stdout, "Failed to create VAP section '%s'", sec_name);
return -1; return -1;
} }
@@ -112,8 +112,8 @@ static int apply_vap(struct uci_context *ctx,
if (enterprise) { if (enterprise) {
if (!auth_server || !auth_server[0] || if (!auth_server || !auth_server[0] ||
!auth_secret || !auth_secret[0]) { !auth_secret || !auth_secret[0]) {
printf("[openuf] Refusing Enterprise VAP '%s': missing RADIUS " LOGF(stdout, "Refusing Enterprise VAP '%s': missing RADIUS "
"authentication server or secret\n", essid); "authentication server or secret", essid);
return -1; return -1;
} }
@@ -125,15 +125,15 @@ static int apply_vap(struct uci_context *ctx,
wlan_uci_set_required(ctx, pkg, sec_name, "auth_port", port) != 0 || wlan_uci_set_required(ctx, pkg, sec_name, "auth_port", port) != 0 ||
wlan_uci_set_required(ctx, pkg, sec_name, "auth_secret", wlan_uci_set_required(ctx, pkg, sec_name, "auth_secret",
auth_secret) != 0) { auth_secret) != 0) {
printf("[openuf] Failed to store RADIUS authentication for " LOGF(stdout, "Failed to store RADIUS authentication for "
"VAP '%s'\n", essid); "VAP '%s'", essid);
return -1; return -1;
} }
if (acct_server && acct_server[0]) { if (acct_server && acct_server[0]) {
if (!acct_secret || !acct_secret[0]) { if (!acct_secret || !acct_secret[0]) {
printf("[openuf] Refusing Enterprise VAP '%s': accounting " LOGF(stdout, "Refusing Enterprise VAP '%s': accounting "
"server has no secret\n", essid); "server has no secret", essid);
return -1; return -1;
} }
snprintf(path, sizeof(path), "wireless.%s.acct_server", sec_name); snprintf(path, sizeof(path), "wireless.%s.acct_server", sec_name);
@@ -143,8 +143,8 @@ static int apply_vap(struct uci_context *ctx,
wlan_uci_set_required(ctx, pkg, sec_name, "acct_port", port) != 0 || wlan_uci_set_required(ctx, pkg, sec_name, "acct_port", port) != 0 ||
wlan_uci_set_required(ctx, pkg, sec_name, "acct_secret", wlan_uci_set_required(ctx, pkg, sec_name, "acct_secret",
acct_secret) != 0) { acct_secret) != 0) {
printf("[openuf] Failed to store RADIUS accounting for " LOGF(stdout, "Failed to store RADIUS accounting for "
"VAP '%s'\n", essid); "VAP '%s'", essid);
return -1; return -1;
} }
} }
@@ -202,7 +202,7 @@ static int apply_vap(struct uci_context *ctx,
wlan_radio_uses_ath9k(device_name)) { wlan_radio_uses_ath9k(device_name)) {
WLAN_UCI_SET_INT(ctx, "wireless", sec_name, "openuf_ft_requested", 1); WLAN_UCI_SET_INT(ctx, "wireless", sec_name, "openuf_ft_requested", 1);
ft = 0; ft = 0;
printf("[openuf] Disabled FT on unsupported 2.4 GHz ath9k radio %s\n", LOGF(stdout, "Disabled FT on unsupported 2.4 GHz ath9k radio %s",
device_name); device_name);
} }
@@ -256,7 +256,7 @@ static int apply_vap(struct uci_context *ctx,
/* Reassert and validate every option required to start a secure AP. */ /* Reassert and validate every option required to start a secure AP. */
if (wlan_uci_set_required(ctx, pkg, sec_name, "device", device_name) != 0) { if (wlan_uci_set_required(ctx, pkg, sec_name, "device", device_name) != 0) {
printf("[openuf] Failed to bind VAP '%s' to %s\n", LOGF(stdout, "Failed to bind VAP '%s' to %s",
essid, device_name); essid, device_name);
return -1; return -1;
} }
@@ -264,24 +264,24 @@ static int apply_vap(struct uci_context *ctx,
wlan_uci_set_required(ctx, pkg, sec_name, "ssid", essid) != 0 || wlan_uci_set_required(ctx, pkg, sec_name, "ssid", essid) != 0 ||
wlan_uci_set_required(ctx, pkg, sec_name, "encryption", wlan_uci_set_required(ctx, pkg, sec_name, "encryption",
wlan_security_to_uci(security)) != 0) { wlan_security_to_uci(security)) != 0) {
printf("[openuf] Refusing incomplete VAP '%s': core AP options " LOGF(stdout, "Refusing incomplete VAP '%s': core AP options "
"could not be stored\n", essid); "could not be stored", essid);
return -1; return -1;
} }
if (!enterprise && pass && pass[0] && strcmp(security, "open") != 0 && if (!enterprise && pass && pass[0] && strcmp(security, "open") != 0 &&
wlan_uci_set_required(ctx, pkg, sec_name, "key", pass) != 0) { wlan_uci_set_required(ctx, pkg, sec_name, "key", pass) != 0) {
printf("[openuf] Refusing unsecured VAP '%s': key could not be stored\n", LOGF(stdout, "Refusing unsecured VAP '%s': key could not be stored",
essid); essid);
return -1; return -1;
} }
if (wlan_uci_set_required(ctx, pkg, sec_name, "network", target_network) != 0) { if (wlan_uci_set_required(ctx, pkg, sec_name, "network", target_network) != 0) {
printf("[openuf] Refusing unsafe VAP '%s': cannot bind to %s\n", LOGF(stdout, "Refusing unsafe VAP '%s': cannot bind to %s",
essid, target_network); essid, target_network);
return -1; return -1;
} }
printf("[openuf] VAP '%s' -> %s device=%s network=%s enc=%s " LOGF(stdout, "VAP '%s' -> %s device=%s network=%s enc=%s "
"ft=%d bs=%d handoff=%d pmf=%d\n", "ft=%d bs=%d handoff=%d pmf=%d",
essid, sec_name, device_name, target_network, wlan_security_to_uci(security), essid, sec_name, device_name, target_network, wlan_security_to_uci(security),
ft, band_steer, handoff, pmf); ft, band_steer, handoff, pmf);
return 0; return 0;
@@ -353,7 +353,7 @@ int wlan_apply_config(struct json_object *config_json,
} }
/* Stop hostapd so a deleted BSS cannot survive a netifd reload race. */ /* Stop hostapd so a deleted BSS cannot survive a netifd reload race. */
printf("[openuf] Stopping Wi-Fi before controller provisioning...\n"); LOGF(stdout, "Stopping Wi-Fi before controller provisioning...");
system("wifi down >/dev/null 2>&1"); system("wifi down >/dev/null 2>&1");
/* Replace prior openuf_ VAPs while preserving unrelated UCI sections. */ /* Replace prior openuf_ VAPs while preserving unrelated UCI sections. */
@@ -371,7 +371,7 @@ int wlan_apply_config(struct json_object *config_json,
radio_band = json_object_get_string(v); radio_band = json_object_get_string(v);
const char *device_name = wlan_device_for_band(model, radio_band); const char *device_name = wlan_device_for_band(model, radio_band);
if (!device_name) { if (!device_name) {
printf("[openuf] Ignoring settings for unknown radio '%s'\n", LOGF(stdout, "Ignoring settings for unknown radio '%s'",
radio_band); radio_band);
continue; continue;
} }
@@ -386,14 +386,14 @@ int wlan_apply_config(struct json_object *config_json,
*/ */
struct uci_context *ctx = uci_alloc_context(); struct uci_context *ctx = uci_alloc_context();
if (!ctx) { if (!ctx) {
printf("[openuf] Failed to allocate UCI context\n"); LOGF(stdout, "Failed to allocate UCI context");
return -1; return -1;
} }
struct uci_package *pkg = NULL; struct uci_package *pkg = NULL;
if (uci_load(ctx, "wireless", &pkg) != UCI_OK) { if (uci_load(ctx, "wireless", &pkg) != UCI_OK) {
char *uci_error = NULL; char *uci_error = NULL;
uci_get_errorstr(ctx, &uci_error, "wireless"); uci_get_errorstr(ctx, &uci_error, "wireless");
printf("[openuf] Failed to load UCI wireless configuration: %s\n", LOGF(stdout, "Failed to load UCI wireless configuration: %s",
uci_error ? uci_error : "unknown UCI error"); uci_error ? uci_error : "unknown UCI error");
free(uci_error); free(uci_error);
uci_free_context(ctx); uci_free_context(ctx);
@@ -416,7 +416,7 @@ int wlan_apply_config(struct json_object *config_json,
} }
} }
if (disabled_defaults) if (disabled_defaults)
printf("[openuf] Disabled %d default OpenWrt VAPs\n", LOGF(stdout, "Disabled %d default OpenWrt VAPs",
disabled_defaults); disabled_defaults);
/* 3. Create VAPs and determine whether any WLAN requests steering. */ /* 3. Create VAPs and determine whether any WLAN requests steering. */
@@ -472,7 +472,7 @@ int wlan_apply_config(struct json_object *config_json,
applied++; applied++;
} }
if (!applied) { if (!applied) {
printf("[openuf] Ignoring VAP with unknown radio '%s'\n", LOGF(stdout, "Ignoring VAP with unknown radio '%s'",
radio_band ? radio_band : ""); radio_band ? radio_band : "");
uci_unload(ctx, pkg); uci_unload(ctx, pkg);
uci_free_context(ctx); uci_free_context(ctx);
@@ -485,7 +485,7 @@ int wlan_apply_config(struct json_object *config_json,
if (uci_commit(ctx, &pkg, false) != UCI_OK) { if (uci_commit(ctx, &pkg, false) != UCI_OK) {
char *uci_error = NULL; char *uci_error = NULL;
uci_get_errorstr(ctx, &uci_error, "wireless"); uci_get_errorstr(ctx, &uci_error, "wireless");
printf("[openuf] Failed to commit UCI wireless configuration: %s\n", LOGF(stdout, "Failed to commit UCI wireless configuration: %s",
uci_error ? uci_error : "unknown UCI error"); uci_error ? uci_error : "unknown UCI error");
free(uci_error); free(uci_error);
uci_unload(ctx, pkg); uci_unload(ctx, pkg);
@@ -496,7 +496,7 @@ int wlan_apply_config(struct json_object *config_json,
uci_free_context(ctx); uci_free_context(ctx);
if (wlan_configure_band_steering(steering_policy_enabled) != 0) if (wlan_configure_band_steering(steering_policy_enabled) != 0)
printf("[openuf] Failed to configure the band steering policy\n"); LOGF(stdout, "Failed to configure the band steering policy");
/* /*
* Reload netifd for generated VLAN devices, then bring the radios up one * Reload netifd for generated VLAN devices, then bring the radios up one
@@ -504,7 +504,7 @@ int wlan_apply_config(struct json_object *config_json,
* setup after ACS. Start and verify each PHY independently, retrying a failed radio so * setup after ACS. Start and verify each PHY independently, retrying a failed radio so
* provisioning cannot leave one band visible but unusable. * provisioning cannot leave one band visible but unusable.
*/ */
printf("[openuf] Starting controller-managed Wi-Fi sequentially...\n"); LOGF(stdout, "Starting controller-managed Wi-Fi sequentially...");
system("ubus call network reload >/dev/null 2>&1"); system("ubus call network reload >/dev/null 2>&1");
for (int i = 0; i < model->radio_map_len; i++) { for (int i = 0; i < model->radio_map_len; i++) {
char command[256]; char command[256];
@@ -516,13 +516,13 @@ int wlan_apply_config(struct json_object *config_json,
strspn(device, strspn(device,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-") != "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-") !=
strlen(device)) { strlen(device)) {
printf("[openuf] Refusing invalid radio name\n"); LOGF(stdout, "Refusing invalid radio name");
continue; continue;
} }
int radio_up = 0; int radio_up = 0;
for (int attempt = 1; attempt <= 2 && !radio_up; attempt++) { for (int attempt = 1; attempt <= 2 && !radio_up; attempt++) {
printf("[openuf] Starting %s (%s), attempt %d...\n", LOGF(stdout, "Starting %s (%s), attempt %d...",
device, model->radio_map[i].band, attempt); device, model->radio_map[i].band, attempt);
snprintf(command, sizeof(command), snprintf(command, sizeof(command),
"wifi up %s >/dev/null 2>&1", device); "wifi up %s >/dev/null 2>&1", device);
@@ -547,12 +547,12 @@ int wlan_apply_config(struct json_object *config_json,
} }
if (!radio_up) if (!radio_up)
printf("[openuf] %s did not reach the up state; retrying\n", LOGF(stdout, "%s did not reach the up state; retrying",
device); device);
} }
if (!radio_up) if (!radio_up)
printf("[openuf] %s failed after 2 start attempts\n", device); LOGF(stdout, "%s failed after 2 start attempts", device);
} }
/* Enable management features only after hostapd has registered each BSS. /* Enable management features only after hostapd has registered each BSS.
@@ -573,8 +573,8 @@ int wlan_apply_config(struct json_object *config_json,
"\"bss_transition\": true }%c >/dev/null 2>&1", "\"bss_transition\": true }%c >/dev/null 2>&1",
phy_index, 39, 39); phy_index, 39, 39);
if (system(command) != 0) if (system(command) != 0)
printf("[openuf] hostapd on phy%d lacks runtime 802.11v " LOGF(stdout, "hostapd on phy%d lacks runtime 802.11v "
"support; continuing without BSS Transition\n", "support; continuing without BSS Transition",
phy_index); phy_index);
} }
} }
+2 -2
View File
@@ -126,7 +126,7 @@ static void resolve_radio_map(const uf_model_t *model)
model->radio_map[i].device); model->radio_map[i].device);
} }
printf("[openuf] Radio mapping: %s -> %s%s\n", LOGF(stdout, "Radio mapping: %s -> %s%s",
model->radio_map[i].band, resolved_devices[i], model->radio_map[i].band, resolved_devices[i],
best >= 0 ? " (detected)" : " (model fallback)"); best >= 0 ? " (detected)" : " (model fallback)");
} }
@@ -279,7 +279,7 @@ void wlan_apply_radio(struct json_object *radio_json,
struct uci_ptr ptr; struct uci_ptr ptr;
if (uci_lookup_ptr(ctx, &ptr, path, true) == UCI_OK) if (uci_lookup_ptr(ctx, &ptr, path, true) == UCI_OK)
uci_set(ctx, &ptr); uci_set(ctx, &ptr);
printf("[openuf] Radio %s standard: %s%s\n", device_name, htmode, LOGF(stdout, "Radio %s standard: %s%s", device_name, htmode,
force_wifi4 ? " (Force WiFi 4)" : " (newest supported)"); force_wifi4 ? " (Force WiFi 4)" : " (newest supported)");
} }
+4 -4
View File
@@ -195,7 +195,7 @@ int wlan_ensure_vlan_network(int vid)
uci_unload(ctx, pkg); uci_unload(ctx, pkg);
uci_free_context(ctx); uci_free_context(ctx);
if (ok) if (ok)
printf("[openuf] Configured VLAN %d on uplink %s as network '%s'\n", LOGF(stdout, "Configured VLAN %d on uplink %s as network '%s'",
vid, vlan_uplink, interface_section); vid, vlan_uplink, interface_section);
return ok ? 0 : -1; return ok ? 0 : -1;
} }
@@ -213,7 +213,7 @@ int wlan_configure_band_steering(int enabled)
struct uci_package *pkg = NULL; struct uci_package *pkg = NULL;
if (uci_load(ctx, "usteer", &pkg) != UCI_OK) { if (uci_load(ctx, "usteer", &pkg) != UCI_OK) {
printf("[openuf] Cannot load /etc/config/usteer\n"); LOGF(stdout, "Cannot load /etc/config/usteer");
uci_free_context(ctx); uci_free_context(ctx);
return -1; return -1;
} }
@@ -257,7 +257,7 @@ int wlan_configure_band_steering(int enabled)
int ok = uci_commit(ctx, &pkg, false) == UCI_OK; int ok = uci_commit(ctx, &pkg, false) == UCI_OK;
uci_unload(ctx, pkg); uci_unload(ctx, pkg);
uci_free_context(ctx); uci_free_context(ctx);
printf("[openuf] Band steering policy %s (usteer)\n", LOGF(stdout, "Band steering policy %s (usteer)",
enabled ? "enabled" : "disabled"); enabled ? "enabled" : "disabled");
return ok ? 0 : -1; return ok ? 0 : -1;
} }
@@ -299,7 +299,7 @@ void wlan_clear(void)
if (delete_count > 0) { if (delete_count > 0) {
uci_commit(ctx, &pkg, false); uci_commit(ctx, &pkg, false);
printf("[openuf] wlan_clear: removed %d managed VAPs\n", LOGF(stdout, "wlan_clear: removed %d managed VAPs",
delete_count); delete_count);
} }
+1
View File
@@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <json-c/json.h> #include <json-c/json.h>
#include <uci.h> #include <uci.h>
#include "config.h"
enum wifi_standard { enum wifi_standard {
WIFI_STANDARD_UNKNOWN = 0, WIFI_STANDARD_UNKNOWN = 0,