Skip to content

Commit b9485e4

Browse files
committed
codedump: more work on AP
1 parent 0bfc03f commit b9485e4

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

src/confd/src/ietf-interfaces.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,10 @@ static bool netdag_must_del(struct lyd_node *dif, struct lyd_node *cif)
484484
break;
485485

486486
case IFT_WIFI:
487-
case IFT_WIFI_AP:
488487
case IFT_ETH:
489488
return lydx_get_child(dif, "custom-phys-address");
489+
case IFT_WIFI_AP:
490+
return lydx_get_child(dif, "custom-phys-address") || wifi_ap_must_delete(dif);
490491

491492
case IFT_GRE:
492493
case IFT_GRETAP:

src/confd/src/ietf-interfaces.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ int wifi_ap_add_iface(struct lyd_node *cif,struct dagger *net);
128128
int wifi_ap_del_iface(struct lyd_node *cif,struct dagger *net);
129129
int wifi_ap_gen(struct lyd_node *cif, struct dagger *net);
130130
int wifi_gen_del(struct lyd_node *iface, struct dagger *net);
131+
bool wifi_ap_must_delete(struct lyd_node *dif);
131132

132133
/* infix-if-gre.c */
133134
int gre_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip);

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

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int wifi_station_gen(struct lyd_node *cif, struct dagger *net)
163163

164164
/* Clean up any existing station configuration */
165165
erasef(WPA_SUPPLICANT_CONF, ifname);
166-
166+
167167
country = lydx_get_cattr(wifi, "country-code");
168168
if (!country)
169169
country = "00";
@@ -221,6 +221,7 @@ int wifi_ap_add_iface(struct lyd_node *cif,struct dagger *net)
221221
return SR_ERR_INVAL_ARG;
222222
}
223223

224+
dagger_add_dep(&confd.netdag, ifname, radio);
224225
iw = dagger_fopen_net_init(net, ifname, NETDAG_INIT_PRE, "init-iw.sh");
225226
fprintf(iw, "iw dev %s interface add %s type __ap\n", radio, ifname);
226227
fclose(iw);
@@ -254,7 +255,7 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
254255
country = lydx_get_cattr(wifi, "country-code");
255256
if (!country)
256257
country = "00";
257-
258+
258259
band = lydx_get_cattr(wifi, "band");
259260
channel = lydx_get_cattr(wifi, "channel");
260261
freq_24GHz = !strcmp(band, "2.4GHz");
@@ -283,10 +284,39 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
283284

284285

285286
/* Find all wifi-ap interfaces that reference this radio */
286-
rc = lyd_find_xpath(cif, "../../interface[type='infix-if-type:wifi-ap' and wifi/radio = current()/name]", &ap_interfaces);
287+
ERROR("Searching for wifi-ap interfaces referencing radio: %s", ifname);
288+
289+
/* First, let's see what interfaces exist at all */
290+
rc = lyd_find_xpath(cif, "../interface", &ap_interfaces);
291+
if (rc == LY_SUCCESS && ap_interfaces && ap_interfaces->count > 0) {
292+
ERROR("Found %d total interfaces", ap_interfaces->count);
293+
for (uint32_t i = 0; i < ap_interfaces->count; i++) {
294+
struct lyd_node *iface = ap_interfaces->dnodes[i];
295+
const char *iface_name = lydx_get_cattr(iface, "name");
296+
const char *iface_type = lydx_get_cattr(iface, "type");
297+
ERROR(" Interface: %s, type: %s", iface_name ? iface_name : "NULL", iface_type ? iface_type : "NULL");
298+
}
299+
ly_set_free(ap_interfaces, NULL);
300+
}
301+
302+
rc = lyd_find_xpath(cif, "../interface[derived-from-or-self(type, 'infix-if-type:wifi-ap')]", &ap_interfaces);
303+
if (rc == LY_SUCCESS && ap_interfaces && ap_interfaces->count > 0) {
304+
ERROR("Found %d wifi-ap interfaces", ap_interfaces->count);
305+
for (uint32_t i = 0; i < ap_interfaces->count; i++) {
306+
struct lyd_node *ap_if = ap_interfaces->dnodes[i];
307+
const char *ap_name = lydx_get_cattr(ap_if, "name");
308+
struct lyd_node *ap_wifi = lydx_get_child(ap_if, "wifi");
309+
const char *ap_radio = ap_wifi ? lydx_get_cattr(ap_wifi, "radio") : "NULL";
310+
ERROR(" AP interface: %s, radio reference: %s", ap_name ? ap_name : "NULL", ap_radio);
311+
}
312+
ly_set_free(ap_interfaces, NULL);
313+
}
314+
315+
rc = lyd_find_xpath(cif, "../interface[derived-from-or-self(type, 'infix-if-type:wifi-ap') and wifi/radio = current()/name]", &ap_interfaces);
287316
if (rc != LY_SUCCESS || !ap_interfaces || ap_interfaces->count == 0) {
288317
/* No AP interfaces found referencing this radio */
289-
ERROR("No wifi-ap refence this radio device (%s)", ifname);
318+
ERROR("No wifi-ap reference this radio device (%s)", ifname);
319+
fclose(hostapd_conf);
290320
return SR_ERR_OK;
291321
}
292322

@@ -349,6 +379,33 @@ int wifi_ap_gen(struct lyd_node *cif, struct dagger *net)
349379
return rc;
350380
}
351381

382+
bool wifi_ap_must_delete(struct lyd_node *dif)
383+
{
384+
struct lyd_node *cwifi;
385+
const char *radio_name;
386+
struct lyd_node *radio_dif;
387+
388+
389+
/* Get the wifi container from the current interface */
390+
cwifi = lydx_get_child(dif, "wifi");
391+
if (!cwifi)
392+
return false;
393+
394+
/* Get the radio reference */
395+
radio_name = lydx_get_cattr(cwifi, "radio");
396+
if (!radio_name)
397+
return false;
398+
399+
/* Look for the radio interface in dif to see if it's being deleted */
400+
radio_dif = lydx_get_xpathf(dif, "../interface[name='%s']", radio_name);
401+
if (radio_dif) {
402+
ERROR("%s must delete, radio change", lydx_get_cattr(dif, "name"));
403+
return true;
404+
}
405+
406+
return false;
407+
}
408+
352409
int wifi_gen_del(struct lyd_node *iface, struct dagger *net)
353410
{
354411
const char *ifname;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ submodule infix-if-wifi {
112112
description
113113
"Applies to interfaces of type 'wifi' or 'wifi-ap'.";
114114
}
115+
116+
description
117+
"WiFi interface extensions with MAC address validation for AP interfaces.";
115118

116119
container wifi {
117120
if-feature wifi;

src/confd/yang/confd/infix-interfaces.yang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ module infix-interfaces {
134134
base infix-ift:infix-interface-type;
135135
}
136136
}
137+
deviate add {
138+
must "not(derived-from-or-self(., 'infix-ift:wifi-ap')) or (../infix-if:custom-phys-address/infix-if:static or ../infix-if:custom-phys-address/infix-if:chassis)" {
139+
error-message "WiFi AP interfaces must have a custom physical address configured.";
140+
}
141+
}
137142
}
138143

139144
deviation "/if:interfaces/if:interface/if:name" {

0 commit comments

Comments
 (0)