Translated all files to ENG (#5)

Reviewed-on: #5
Co-authored-by: Finn <fwaggoner@nmfpgt.de>
Co-committed-by: Finn <fwaggoner@nmfpgt.de>
This commit was merged in pull request #5.
This commit is contained in:
2026-07-12 01:45:38 +01:00
committed by Koda
parent fb542777ca
commit 59274da4e5
14 changed files with 317 additions and 307 deletions
+25 -22
View File
@@ -1,11 +1,13 @@
/*
* openuf - clients.c
*
* Enumera clientes para el payload inform → sta_table.
*
* Enumerates clients for the inform payload → sta_table.
*
* ── Parseo de iw dev station dump ───────────────────────────────────
* ── Parsing `iw dev station dump` Output ────────────────────────────
*
* The output is organized into one block per client:
*
* La salida tiene bloques por cliente:
*
* Station aa:bb:cc:dd:ee:ff (on wlan0)
* inactive time: 120 ms
@@ -18,16 +20,16 @@
* rx bitrate: 108.0 MBit/s
* connected time: 1800 seconds
*
* Detectamos el inicio de cada cliente con "Station XX:XX:..." y
* rellenamos los campos hasta encontrar el siguiente cliente.
* We detect the start of each client by looking for "Station XX:XX:..."
* and populate its fields until the next client entry is encountered.
*
* ── ARP: /proc/net/arp ─────────────────────────────────────────────
*
* IP HW type Flags HW addr Mask Device
* 192.168.1.x 0x1 0x2 aa:bb:cc:dd:ee:ff * br-lan
*
* Flags 0x2 = entrada completa (reachable).
* Flags 0x0 = incompleta (no responde ARP), ignorar.
* Flags 0x2 = complete entry (reachable).
* Flags 0x0 = incomplete (no ARP responce), ignore.
*/
#define _GNU_SOURCE
@@ -39,7 +41,7 @@
#include "clients.h"
/* ─── Normalizar MAC a minúsculas ─────────────────────────────────── */
/* ─── Convert MAC address to lowercase ─────────────────────────────────── */
static void mac_lower(const char *src, char *dst, size_t sz)
{
for (size_t i = 0; src[i] && i < sz-1; i++)
@@ -114,7 +116,7 @@ int clients_mac_to_hostname(const char *mac, char *out, size_t sz)
return -1;
}
/* ─── Parsear tasa de bits "144.4 MBit/s ..." → kbps ───────────── */
/* ─── Parse bitrate "144.4 MBit/s ..." → kbps ───────────── */
static long parse_rate_kbps(const char *s)
{
float r = 0;
@@ -144,7 +146,7 @@ int clients_read_wifi(const char *wlan_iface,
while (fgets(line, sizeof(line), p)) {
line[strcspn(line, "\r\n")] = '\0';
/* ── Nueva estación ──────────────────────────────────────── */
/* ── New station ──────────────────────────────────────── */
char mac[32], on_iface[32];
if (sscanf(line, "Station %31s (on %31[^)])", mac, on_iface) == 2) {
if (count >= max_out) break;
@@ -159,14 +161,14 @@ int clients_read_wifi(const char *wlan_iface,
}
if (!cur) continue;
/* ── Contadores ──────────────────────────────────────────── */
/* ── Counters ──────────────────────────────────────────── */
long long llv;
if (sscanf(line, " rx bytes: %lld", &llv) == 1) { cur->rx_bytes = llv; continue; }
if (sscanf(line, " tx bytes: %lld", &llv) == 1) { cur->tx_bytes = llv; continue; }
if (sscanf(line, " rx packets: %lld", &llv) == 1) { cur->rx_packets = llv; continue; }
if (sscanf(line, " tx packets: %lld", &llv) == 1) { cur->tx_packets = llv; continue; }
/* ── Sal ───────────────────────────────────────────────── */
/* ── Signal ───────────────────────────────────────────────── */
int sig;
if (sscanf(line, " signal: %d", &sig) == 1) { cur->signal = sig; continue; }
@@ -179,7 +181,7 @@ int clients_read_wifi(const char *wlan_iface,
cur->rx_rate = parse_rate_kbps(rest); continue;
}
/* ── Tiempo conectado ────────────────────────────────────── */
/* ── Connection time ────────────────────────────────────── */
int upt;
if (sscanf(line, " connected time: %d seconds", &upt) == 1) {
cur->uptime = upt; continue;
@@ -187,7 +189,7 @@ int clients_read_wifi(const char *wlan_iface,
}
pclose(p);
/* ── Enriquecer: IP, hostname, rssi, CCQ ─────────────────────── */
/* ── Enrich with IP address, hostname, RSSI, and CCQ.─────────────────────── */
for (int i = 0; i < count; i++) {
sta_info_t *s = &out[i];
clients_mac_to_ip(s->mac, s->ip, sizeof(s->ip));
@@ -195,14 +197,15 @@ int clients_read_wifi(const char *wlan_iface,
if (!s->hostname[0])
strncpy(s->hostname, s->mac, sizeof(s->hostname)-1);
/* RSN = SNR estimado (signal - noise) */
/* Estimated SNR (signal - noise). */
s->rssi = s->signal - s->noise;
if (s->rssi < 0) s->rssi = 0;
/* CCQ: métrica 0-1000
* -50 dBm → 1000 (excelente)
* -90 dBm → 0 (muy malo)
* fórmula lineal: (signal + 90) * 25, limitado 0-1000 */
/* CCQ: 0-1000 quality metric
* -50 dBm → 1000 (excellent)
* -90 dBm → 0 (very poor)
* Linear mapping: (signal + 90) * 25, clamped to the range 0-1000.
*/
int ccq = (s->signal + 90) * 25;
s->ccq = (ccq < 0) ? 0 : (ccq > 1000) ? 1000 : ccq;
}
@@ -210,11 +213,11 @@ int clients_read_wifi(const char *wlan_iface,
}
/* ═══════════════════════════════════════════════════════════════════
Construir JSON sta_table para un VAP
Build the sta_table JSON array for a VAP.
═══════════════════════════════════════════════════════════════════
El JSON array resultante se anida dentro de vap_table[i].sta_table
en el payload inform. Ejemplo de entrada:
The resulting JSON array is embedded in vap_table[i].sta_table
within the inform payload. Example input:
{
"mac": "aa:bb:cc:dd:ee:ff",
"ip": "192.168.1.100",