This commit is contained in:
Mattias Walström
2026-06-03 11:18:49 +02:00
parent ee11f90499
commit cd54a4608c
5 changed files with 41 additions and 44 deletions
@@ -1,7 +1,9 @@
# This service is required since it applies the mesh settings, this must be done
# AFTER the mesh has joined
service name:wpa_cli :%i pid:/run/wpa_cli-%i.pid \
[2345] wpa_cli -P /run/wpa_cli-%i.pid -i %i -a /usr/libexec/mesh-action.sh -r \
-- Wi-Fi Mesh action @%i
-- Wi-Fi Mesh Settings @%i
service name:wpa_supplicant :%i <pid/wpa_cli:%i> \
service name:wpa_supplicant :%i <!pid/wpa_cli:%i> \
[2345] wpa_supplicant -s -i %i -c /etc/wpa_supplicant-%i.conf -P/var/run/wpa_supplicant-%i.pid \
-- Wi-Fi Mesh @%i
+3 -7
View File
@@ -257,22 +257,18 @@ def parse_interface_info(ifname):
for line in output.splitlines():
stripped = line.strip()
# Interface type
# Interface type (can be multi-word, e.g. "mesh point")
if stripped.startswith('type '):
result['iftype'] = stripped.split()[1]
result['iftype'] = ' '.join(stripped.split()[1:])
# MAC address
elif stripped.startswith('addr '):
result['mac'] = stripped.split()[1]
# SSID (AP mode)
# SSID (AP mode) or mesh-id (mesh point mode) — kernel uses same attr
elif stripped.startswith('ssid '):
result['ssid'] = decode_iw_ssid(' '.join(stripped.split()[1:]))
# Mesh ID (mesh point mode)
elif stripped.startswith('mesh_id '):
result['mesh_id'] = decode_iw_ssid(' '.join(stripped.split()[1:]))
# Channel/frequency
elif stripped.startswith('channel '):
parts = stripped.split()
+6 -5
View File
@@ -302,13 +302,13 @@ int wifi_gen_mesh(struct lyd_node *cif)
{
const char *ifname, *mesh_id, *secret_name, *radio;
struct lyd_node *mesh, *security, *secret_node, *radio_node, *wifi;
unsigned char *secret = NULL;
FILE *wpa_supplicant = NULL;
const char *country, *band, *width;
FILE *wpa_supplicant = NULL, *params;
unsigned char *secret = NULL;
int rc = SR_ERR_OK;
int channel, freq;
bool forwarding, gate;
mode_t oldmask;
bool forwarding;
ifname = lydx_get_cattr(cif, "name");
wifi = lydx_get_child(cif, "wifi");
@@ -417,9 +417,9 @@ int wifi_gen_mesh(struct lyd_node *cif)
fprintf(wpa_supplicant, "}\n");
/* Generate mesh params file, sourced by mesh-action.sh on MESH-GROUP-STARTED */
if (lydx_is_enabled(mesh, "gate-announcements")) {
FILE *params;
gate = lydx_is_enabled(mesh, "gate-announcements");
if (gate) {
params = fopenf("w", MESH_PARAMS_CONF, ifname);
if (params) {
fprintf(params, "iw dev %s set mesh_param mesh_gate_announcements 1\n", ifname);
@@ -538,6 +538,7 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net)
rc = SR_ERR_INVAL_ARG;
goto out;
}
out:
fclose(iw);
return rc;
+21 -24
View File
@@ -1436,33 +1436,31 @@ class Iface:
mode = None
if self.wifi:
# Detect mode: AP has "stations", Station has "signal-strength" or "scan-results"
ap=self.wifi.get("access-point", {})
if ap:
if "access-point" in self.wifi:
ap = self.wifi["access-point"]
ssid = ap.get("ssid", "------")
mode = "AP"
stations_data = ap.get("stations", {})
stations = stations_data.get("station", [])
station_count = len(stations)
data_str = f"{mode}, ssid: {ssid}, stations: {station_count}"
elif "mesh-point" in self.wifi:
mesh = self.wifi["mesh-point"]
mesh_id = mesh.get("mesh-id", "------")
mode = "Mesh"
peers_data = mesh.get("peers", {})
peers = peers_data.get("peer", [])
data_str = f"{mode}, mesh-id: {mesh_id}, peers: {len(peers)}"
else:
mesh = self.wifi.get("mesh-point", {})
if mesh:
mesh_id = mesh.get("mesh-id", "------")
mode = "Mesh"
peers_data = mesh.get("peers", {})
peers = peers_data.get("peer", [])
data_str = f"{mode}, mesh-id: {mesh_id}, peers: {len(peers)}"
station=self.wifi.get("station", {})
ssid = station.get("ssid", "------")
signal = station.get("signal-strength")
mode = "Station"
if signal is not None:
signal_str = signal_to_status(signal)
data_str = f"{mode}, ssid: {ssid}, signal: {signal_str}"
else:
station=self.wifi.get("station", {})
ssid = station.get("ssid", "------")
signal = station.get("signal-strength")
mode = "Station"
if signal is not None:
signal_str = signal_to_status(signal)
data_str = f"{mode}, ssid: {ssid}, signal: {signal_str}"
else:
data_str = f"{mode}, ssid: {ssid}"
data_str = f"{mode}, ssid: {ssid}"
else:
data_str = "ssid: ------"
@@ -1734,9 +1732,8 @@ class Iface:
print(f"{'out-octets':<{19}}: {self.out_octets}")
if self.wifi:
# Detect mode: AP has "stations", Station has "signal-strength" or "scan-results"
ap = self.wifi.get('access-point')
if ap:
if "access-point" in self.wifi:
ap = self.wifi['access-point']
mode = "access-point"
ssid = ap.get('ssid', "----")
stations_data = ap.get("stations", {})
@@ -1745,8 +1742,8 @@ class Iface:
print(f"{'ssid':<{19}}: {ssid}")
print(f"{'connected stations':<{19}}: {len(stations)}")
self.pr_wifi_stations()
elif self.wifi.get('mesh-point'):
mesh = self.wifi.get('mesh-point')
elif "mesh-point" in self.wifi:
mesh = self.wifi['mesh-point']
mode = "mesh-point"
mesh_id = mesh.get('mesh-id', "----")
peers_data = mesh.get("peers", {})
@@ -58,19 +58,20 @@ def wifi_ap(ifname):
return {'access-point': ap_data} if ap_data else {}
def wifi_mesh(ifname):
def wifi_mesh(ifname, info=None):
"""Get operational data for mesh point mode using iw"""
mesh_data = {}
info = get_iw_info(ifname)
if info.get('mesh_id'):
mesh_data['mesh-id'] = info['mesh_id']
if info is None:
info = get_iw_info(ifname)
if info.get('ssid'):
mesh_data['mesh-id'] = info['ssid']
peers = get_iw_stations(ifname)
if peers:
mesh_data['peers'] = {'peer': peers}
return {'mesh-point': mesh_data} if mesh_data else {}
return {'mesh-point': mesh_data}
def wifi_station(ifname):
"""Get operational data for Station mode using iw + wpa_cli for scanning"""
@@ -115,7 +116,7 @@ def wifi(ifname):
if mode == 'ap':
result.update(wifi_ap(ifname))
elif mode == 'mesh point':
result.update(wifi_mesh(ifname))
result.update(wifi_mesh(ifname, info))
else:
result.update(wifi_station(ifname))