diff --git a/board/common/rootfs/etc/finit.d/available/mesh@.conf b/board/common/rootfs/etc/finit.d/available/mesh@.conf index dcc08e4e..92b162dc 100644 --- a/board/common/rootfs/etc/finit.d/available/mesh@.conf +++ b/board/common/rootfs/etc/finit.d/available/mesh@.conf @@ -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 \ +service name:wpa_supplicant :%i \ [2345] wpa_supplicant -s -i %i -c /etc/wpa_supplicant-%i.conf -P/var/run/wpa_supplicant-%i.pid \ -- Wi-Fi Mesh @%i diff --git a/board/common/rootfs/usr/libexec/infix/iw.py b/board/common/rootfs/usr/libexec/infix/iw.py index 66827438..78f9a8b2 100755 --- a/board/common/rootfs/usr/libexec/infix/iw.py +++ b/board/common/rootfs/usr/libexec/infix/iw.py @@ -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() diff --git a/src/confd/src/if-wifi.c b/src/confd/src/if-wifi.c index bb50de01..cae7e3fe 100644 --- a/src/confd/src/if-wifi.c +++ b/src/confd/src/if-wifi.c @@ -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; diff --git a/src/statd/python/cli_pretty/cli_pretty.py b/src/statd/python/cli_pretty/cli_pretty.py index 92919474..a686e8db 100755 --- a/src/statd/python/cli_pretty/cli_pretty.py +++ b/src/statd/python/cli_pretty/cli_pretty.py @@ -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", {}) diff --git a/src/statd/python/yanger/ietf_interfaces/wifi.py b/src/statd/python/yanger/ietf_interfaces/wifi.py index 6365029c..e4d80942 100644 --- a/src/statd/python/yanger/ietf_interfaces/wifi.py +++ b/src/statd/python/yanger/ietf_interfaces/wifi.py @@ -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))