Skip to content

Commit e95f06e

Browse files
committed
code dump
1 parent b9485e4 commit e95f06e

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

src/confd/src/ietf-interfaces.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,18 @@ static int netdag_gen_afspec_set(sr_session_ctx_t *session, struct dagger *net,
457457
return netdag_gen_ethtool(net, cif, dif);
458458
case IFT_WIFI:
459459
return wifi_gen(dif, cif, net);
460-
case IFT_WIFI_AP:
460+
case IFT_WIFI_AP: {
461+
struct lyd_node *wifi = lydx_get_child(cif, "wifi");
462+
if (wifi) {
463+
const char *radio = lydx_get_cattr(wifi, "radio");
464+
if (radio) {
465+
struct lyd_node *radio_if = lydx_get_xpathf(cif, "../interface[name='%s']", radio);
466+
if (radio_if)
467+
return wifi_ap_gen(radio_if, net);
468+
}
469+
}
470+
return 0;
471+
}
461472
case IFT_DUMMY:
462473
case IFT_GRE:
463474
case IFT_GRETAP:

src/confd/src/infix-if-wifi.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int wifi_gen_station_config(const char *ifname, const char *ssid, const c
4545
"autoscan=periodic:10\n"
4646
"ap_scan=1\n");
4747
} else {
48-
if (!encryption) {
48+
if (!strcmp(encryption, "disabled")) {
4949
asprintf(&encryption_str, "key_mgmt=NONE");
5050
} else {
5151
asprintf(&encryption_str, "key_mgmt=SAE WPA-PSK\npsk=\"%s\"", secret);
@@ -177,7 +177,7 @@ int wifi_station_gen(struct lyd_node *cif, struct dagger *net)
177177
ssid_name = lydx_get_cattr(wifi, "ssid");
178178
secret_name = lydx_get_cattr(wifi, "secret");
179179
encryption = lydx_get_cattr(wifi, "encryption");
180-
if (encryption && secret_name) {
180+
if (secret_name) {
181181
secret_node = lydx_get_xpathf(cif, "../../keystore/symmetric-keys/symmetric-key[name='%s']", secret_name);
182182
secret = lydx_get_cattr(secret_node, "cleartext-key");
183183
}
@@ -253,9 +253,6 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
253253
fprintf(hostapd_conf, "# Generated by Infix confd\n");
254254

255255
country = lydx_get_cattr(wifi, "country-code");
256-
if (!country)
257-
country = "00";
258-
259256
band = lydx_get_cattr(wifi, "band");
260257
channel = lydx_get_cattr(wifi, "channel");
261258
freq_24GHz = !strcmp(band, "2.4GHz");
@@ -267,15 +264,19 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
267264
"interface=%s\n"
268265
"driver=nl80211\n"
269266
"hw_mode=%c\n"
270-
"country_code=%s\n"
271267
"wmm_enabled=1\n" /* QoS */
272268
"channel=%s\n"
273269
"logger_syslog=-1\n"
274270
"logger_syslog_level=0\n"
275271
"logger_stdout=0\n"
276272
"ctrl_interface=/var/run/hostapd\n"
277273
"ctrl_interface_group=0\n\n",
278-
ifname, freq_24GHz ? 'g' : 'a', country, channel);
274+
ifname, freq_24GHz ? 'g' : 'a', channel);
275+
276+
277+
ERROR("Country: %s", country);
278+
if (strcmp(country, "00"))
279+
fprintf(hostapd_conf, "country_code=%s\n", country);
279280

280281
if (freq_24GHz)
281282
fprintf(hostapd_conf, "ieee80211n=1\n");
@@ -350,7 +351,7 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
350351
fprintf(hostapd_conf, "bss=%s\n", ap_ifname);
351352
fprintf(hostapd_conf, "# SSID: %s\n", ssid);
352353
fprintf(hostapd_conf, "ssid=%s\n", ssid);
353-
if (encryption) {
354+
if (!strcmp(encryption, "mixed-wpa2-wpa3")) {
354355
fprintf(hostapd_conf, "wpa_key_mgmt=WPA-PSK SAE\n");
355356
fprintf(hostapd_conf, "wpa_passphrase=%s\n", secret);
356357
fprintf(hostapd_conf, "sae_password=%s\n", secret);
@@ -362,7 +363,7 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
362363
fputs("ignore_broadcast_ssid=0\n", hostapd_conf);
363364
}
364365
ly_set_free(ap_interfaces, NULL);
365-
366+
fclose(hostapd_conf);
366367
hostapd_finit = dagger_fopen_net_init(net, ifname, NETDAG_INIT_POST, "hostapd.sh");
367368
if (!hostapd_finit)
368369
return SR_ERR_INTERNAL;
@@ -381,6 +382,7 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
381382

382383
bool wifi_ap_must_delete(struct lyd_node *dif)
383384
{
385+
384386
struct lyd_node *cwifi;
385387
const char *radio_name;
386388
struct lyd_node *radio_dif;

src/confd/yang/confd/infix-if-wifi.yang

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ submodule infix-if-wifi {
6161
}
6262
typedef encryption {
6363
type enumeration {
64-
enum auto {
64+
enum mixed-wpa2-wpa3 {
6565
description
66-
"Enables WPA/WPA2/WPA3 encryption with automatic protocol
66+
"Enables WPA2/WPA3 mixed mode encryption with automatic protocol
6767
negotiation. The system uses the strongest supported variant supported by Access Point.";
6868
}
6969
enum disabled {
@@ -77,7 +77,7 @@ submodule infix-if-wifi {
7777
description
7878
"Encryption modes available for WiFi connections.
7979
80-
- auto: Secure connection using WPA3/WPA2/WPA (auto-selected)
80+
- mixed-wpa2-wpa3: Secure connection using WPA2/WPA3 (auto-selected)
8181
- disabled: Open network (unencrypted)";
8282
}
8383

@@ -189,7 +189,7 @@ submodule infix-if-wifi {
189189
}
190190

191191
leaf encryption {
192-
default auto;
192+
default mixed-wpa2-wpa3;
193193
type encryption;
194194
when "(derived-from-or-self(../../if:type, 'infixift:wifi') and ../mode = 'station') or derived-from-or-self(../../if:type, 'infixift:wifi-ap')" {
195195
description "Available for wifi interfaces in station mode or wifi-ap interfaces.";
@@ -198,11 +198,11 @@ submodule infix-if-wifi {
198198
"WiFi encryption method.
199199
200200
For station interfaces:
201-
- auto (default): Enables WPA2/WPA3 auto-negotiation
201+
- mixed-wpa2-wpa3 (default): Enables WPA2/WPA3 auto-negotiation
202202
- disabled: Disables encryption (open network)
203203
204204
For AP interfaces:
205-
- auto: Enables WPA2/WPA3 encryption
205+
- mixed-wpa2-wpa3: Enables WPA2/WPA3 encryption
206206
- disabled: Disables encryption (open network)";
207207
}
208208

0 commit comments

Comments
 (0)