confd: wifi: Update wpa_supplicant config when wifi setting change

For example changing SSID
This commit is contained in:
Mattias Walström
2026-01-26 23:35:38 +01:00
parent c0591773d4
commit a8dc889c7e
3 changed files with 19 additions and 15 deletions
+9 -12
View File
@@ -14,18 +14,15 @@
#define WPA_SUPPLICANT_CONF "/etc/wpa_supplicant-%s.conf"
/*
* Determine WiFi mode from YANG configuration
*/
typedef enum wifi_mode_t {
wifi_station,
wifi_ap,
wifi_unknown
} wifi_mode_t;
static wifi_mode_t wifi_get_mode(struct lyd_node *wifi)
wifi_mode_t wifi_get_mode(struct lyd_node *iface)
{
struct lyd_node *ap;
struct lyd_node *ap, *wifi;
wifi = lydx_get_child(iface, "wifi");
if (!wifi)
return wifi_unknown;
ap = lydx_get_child(wifi, "access-point");
if (ap) {
@@ -60,7 +57,7 @@ int wifi_mode_changed(struct lyd_node *wifi)
/*
* Generate wpa_supplicant config for station mode
*/
static int wifi_gen_station(struct lyd_node *cif)
int wifi_gen_station(struct lyd_node *cif)
{
const char *ifname, *ssid, *secret_name, *secret, *security_mode, *radio;
struct lyd_node *security, *secret_node, *radio_node, *station, *wifi;
@@ -213,7 +210,7 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net)
return SR_ERR_INTERNAL;
}
mode = wifi_get_mode(wifi);
mode = wifi_get_mode(cif);
probe_timeout = wifi_get_probe_timeout(net->session, radio);
fprintf(iw, "# Generated by Infix confd - WiFi Interface Creation\n");
+2 -3
View File
@@ -452,9 +452,8 @@ static int netdag_gen_afspec_set(sr_session_ctx_t *session, struct dagger *net,
case IFT_ETH:
return netdag_gen_ethtool(net, cif, dif);
case IFT_WIFI:
/* WiFi daemon config (hostapd/wpa_supplicant) is handled by
* hardware.c when the radio (phy) is configured. Interface
* creation/deletion is handled in netdag_gen_afspec_add(). */
if (wifi_get_mode(cif) == wifi_station)
return wifi_gen_station(cif);
return 0;
case IFT_DUMMY:
case IFT_GRE:
+8
View File
@@ -124,9 +124,17 @@ int bridge_mcd_gen(struct lyd_node *cifs);
int bridge_port_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip);
/* if-wifi.c */
typedef enum wifi_mode_t {
wifi_station,
wifi_ap,
wifi_unknown
} wifi_mode_t;
int wifi_add_iface(struct lyd_node *cif, struct dagger *net);
int wifi_del_iface(struct lyd_node *dif, struct dagger *net);
int wifi_mode_changed(struct lyd_node *wifi);
int wifi_gen_station(struct lyd_node *cif);
wifi_mode_t wifi_get_mode(struct lyd_node *wifi);
/* if-gre.c */
int gre_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip);