@@ -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+
352409int wifi_gen_del (struct lyd_node * iface , struct dagger * net )
353410{
354411 const char * ifname ;
0 commit comments