hostapd: add internal API for renaming AP interfaces
[openwrt/openwrt.git] / package / network / services / hostapd / src / src / ap / ucode.c
1 #include <sys/un.h>
2
3 #include "utils/includes.h"
4 #include "utils/common.h"
5 #include "utils/ucode.h"
6 #include "hostapd.h"
7 #include "beacon.h"
8 #include "hw_features.h"
9 #include "ap_drv_ops.h"
10 #include "dfs.h"
11 #include "acs.h"
12 #include <libubox/uloop.h>
13
14 static uc_resource_type_t *global_type, *bss_type, *iface_type;
15 static struct hapd_interfaces *interfaces;
16 static uc_value_t *global, *bss_registry, *iface_registry;
17 static uc_vm_t *vm;
18
19 static uc_value_t *
20 hostapd_ucode_bss_get_uval(struct hostapd_data *hapd)
21 {
22 uc_value_t *val;
23
24 if (hapd->ucode.idx)
25 return wpa_ucode_registry_get(bss_registry, hapd->ucode.idx);
26
27 val = uc_resource_new(bss_type, hapd);
28 hapd->ucode.idx = wpa_ucode_registry_add(bss_registry, val);
29
30 return val;
31 }
32
33 static uc_value_t *
34 hostapd_ucode_iface_get_uval(struct hostapd_iface *hapd)
35 {
36 uc_value_t *val;
37
38 if (hapd->ucode.idx)
39 return wpa_ucode_registry_get(iface_registry, hapd->ucode.idx);
40
41 val = uc_resource_new(iface_type, hapd);
42 hapd->ucode.idx = wpa_ucode_registry_add(iface_registry, val);
43
44 return val;
45 }
46
47 static void
48 hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *if_bss, uc_value_t *bss)
49 {
50 uc_value_t *list;
51 int i;
52
53 list = ucv_array_new(vm);
54 for (i = 0; i < iface->num_bss; i++) {
55 struct hostapd_data *hapd = iface->bss[i];
56 uc_value_t *val = hostapd_ucode_bss_get_uval(hapd);
57
58 ucv_array_set(list, i, ucv_get(ucv_string_new(hapd->conf->iface)));
59 ucv_object_add(bss, hapd->conf->iface, ucv_get(val));
60 }
61 ucv_object_add(if_bss, iface->phy, ucv_get(list));
62 }
63
64 static void
65 hostapd_ucode_update_interfaces(void)
66 {
67 uc_value_t *ifs = ucv_object_new(vm);
68 uc_value_t *if_bss = ucv_array_new(vm);
69 uc_value_t *bss = ucv_object_new(vm);
70 int i;
71
72 for (i = 0; i < interfaces->count; i++) {
73 struct hostapd_iface *iface = interfaces->iface[i];
74
75 ucv_object_add(ifs, iface->phy, ucv_get(hostapd_ucode_iface_get_uval(iface)));
76 hostapd_ucode_update_bss_list(iface, if_bss, bss);
77 }
78
79 ucv_object_add(ucv_prototype_get(global), "interfaces", ucv_get(ifs));
80 ucv_object_add(ucv_prototype_get(global), "interface_bss", ucv_get(if_bss));
81 ucv_object_add(ucv_prototype_get(global), "bss", ucv_get(bss));
82 ucv_gc(vm);
83 }
84
85 static uc_value_t *
86 uc_hostapd_add_iface(uc_vm_t *vm, size_t nargs)
87 {
88 uc_value_t *iface = uc_fn_arg(0);
89 int ret;
90
91 if (ucv_type(iface) != UC_STRING)
92 return ucv_int64_new(-1);
93
94 ret = hostapd_add_iface(interfaces, ucv_string_get(iface));
95 hostapd_ucode_update_interfaces();
96
97 return ucv_int64_new(ret);
98 }
99
100 static uc_value_t *
101 uc_hostapd_remove_iface(uc_vm_t *vm, size_t nargs)
102 {
103 uc_value_t *iface = uc_fn_arg(0);
104
105 if (ucv_type(iface) != UC_STRING)
106 return NULL;
107
108 hostapd_remove_iface(interfaces, ucv_string_get(iface));
109 hostapd_ucode_update_interfaces();
110
111 return NULL;
112 }
113
114 static uc_value_t *
115 uc_hostapd_bss_set_config(uc_vm_t *vm, size_t nargs)
116 {
117 struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
118 struct hostapd_bss_config *old_bss;
119 struct hostapd_iface *iface;
120 struct hostapd_config *conf;
121 uc_value_t *file = uc_fn_arg(0);
122 uc_value_t *index = uc_fn_arg(1);
123 uc_value_t *files_only = uc_fn_arg(2);
124 unsigned int i, idx = 0;
125 int ret = -1;
126
127 if (!hapd || ucv_type(file) != UC_STRING)
128 goto out;
129
130 if (ucv_type(index) == UC_INTEGER)
131 idx = ucv_int64_get(index);
132
133 iface = hapd->iface;
134 conf = interfaces->config_read_cb(ucv_string_get(file));
135 if (!conf)
136 goto out;
137
138 if (idx > conf->num_bss || !conf->bss[idx])
139 goto free;
140
141 if (ucv_boolean_get(files_only)) {
142 struct hostapd_bss_config *bss = conf->bss[idx];
143 struct hostapd_bss_config *old_bss = hapd->conf;
144
145 #define swap_field(name) \
146 do { \
147 void *ptr = old_bss->name; \
148 old_bss->name = bss->name; \
149 bss->name = ptr; \
150 } while (0)
151
152 swap_field(ssid.wpa_psk_file);
153 goto done;
154 }
155
156 hostapd_bss_deinit_no_free(hapd);
157 hostapd_drv_stop_ap(hapd);
158 hostapd_free_hapd_data(hapd);
159
160 old_bss = hapd->conf;
161 for (i = 0; i < iface->conf->num_bss; i++)
162 if (iface->conf->bss[i] == hapd->conf)
163 iface->conf->bss[i] = conf->bss[idx];
164 hapd->conf = conf->bss[idx];
165 conf->bss[idx] = old_bss;
166
167 hostapd_setup_bss(hapd, hapd == iface->bss[0], true);
168 hostapd_ucode_update_interfaces();
169
170 done:
171 ret = 0;
172 free:
173 hostapd_config_free(conf);
174 out:
175 return ucv_int64_new(ret);
176 }
177
178 static void
179 hostapd_remove_iface_bss_conf(struct hostapd_config *iconf,
180 struct hostapd_bss_config *conf)
181 {
182 int i;
183
184 for (i = 0; i < iconf->num_bss; i++)
185 if (iconf->bss[i] == conf)
186 break;
187
188 if (i == iconf->num_bss)
189 return;
190
191 for (i++; i < iconf->num_bss; i++)
192 iconf->bss[i - 1] = iconf->bss[i];
193 iconf->num_bss--;
194 }
195
196
197 static uc_value_t *
198 uc_hostapd_bss_delete(uc_vm_t *vm, size_t nargs)
199 {
200 struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
201 struct hostapd_iface *iface;
202 int i, idx;
203
204 if (!hapd)
205 return NULL;
206
207 iface = hapd->iface;
208 if (iface->num_bss == 1) {
209 wpa_printf(MSG_ERROR, "trying to delete last bss of an iface: %s\n", hapd->conf->iface);
210 return NULL;
211 }
212
213 for (idx = 0; idx < iface->num_bss; idx++)
214 if (iface->bss[idx] == hapd)
215 break;
216
217 if (idx == iface->num_bss)
218 return NULL;
219
220 for (i = idx + 1; i < iface->num_bss; i++)
221 iface->bss[i - 1] = iface->bss[i];
222
223 iface->num_bss--;
224
225 iface->bss[0]->interface_added = 0;
226 hostapd_drv_set_first_bss(iface->bss[0]);
227 hapd->interface_added = 1;
228
229 hostapd_drv_stop_ap(hapd);
230 hostapd_bss_deinit(hapd);
231 hostapd_remove_iface_bss_conf(iface->conf, hapd->conf);
232 hostapd_config_free_bss(hapd->conf);
233 os_free(hapd);
234
235 hostapd_ucode_update_interfaces();
236 ucv_gc(vm);
237
238 return NULL;
239 }
240
241 static uc_value_t *
242 uc_hostapd_iface_add_bss(uc_vm_t *vm, size_t nargs)
243 {
244 struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
245 struct hostapd_bss_config *bss;
246 struct hostapd_config *conf;
247 struct hostapd_data *hapd;
248 uc_value_t *file = uc_fn_arg(0);
249 uc_value_t *index = uc_fn_arg(1);
250 unsigned int idx = 0;
251 uc_value_t *ret = NULL;
252
253 if (!iface || ucv_type(file) != UC_STRING)
254 goto out;
255
256 if (ucv_type(index) == UC_INTEGER)
257 idx = ucv_int64_get(index);
258
259 conf = interfaces->config_read_cb(ucv_string_get(file));
260 if (!conf || idx > conf->num_bss || !conf->bss[idx])
261 goto out;
262
263 bss = conf->bss[idx];
264 hapd = hostapd_alloc_bss_data(iface, iface->conf, bss);
265 if (!hapd)
266 goto out;
267
268 hapd->driver = iface->bss[0]->driver;
269 hapd->drv_priv = iface->bss[0]->drv_priv;
270 if (interfaces->ctrl_iface_init &&
271 interfaces->ctrl_iface_init(hapd) < 0)
272 goto free_hapd;
273
274 if (iface->state == HAPD_IFACE_ENABLED &&
275 hostapd_setup_bss(hapd, -1, true))
276 goto deinit_ctrl;
277
278 iface->bss = os_realloc_array(iface->bss, iface->num_bss + 1,
279 sizeof(*iface->bss));
280 iface->bss[iface->num_bss++] = hapd;
281
282 iface->conf->bss = os_realloc_array(iface->conf->bss,
283 iface->conf->num_bss + 1,
284 sizeof(*iface->conf->bss));
285 iface->conf->bss[iface->conf->num_bss] = bss;
286 conf->bss[idx] = NULL;
287 ret = hostapd_ucode_bss_get_uval(hapd);
288 hostapd_ucode_update_interfaces();
289 goto out;
290
291 deinit_ctrl:
292 if (interfaces->ctrl_iface_deinit)
293 interfaces->ctrl_iface_deinit(hapd);
294 free_hapd:
295 hostapd_free_hapd_data(hapd);
296 os_free(hapd);
297 out:
298 hostapd_config_free(conf);
299 return ret;
300 }
301
302 static uc_value_t *
303 uc_hostapd_iface_set_bss_order(uc_vm_t *vm, size_t nargs)
304 {
305 struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
306 uc_value_t *bss_list = uc_fn_arg(0);
307 struct hostapd_data **new_bss;
308 struct hostapd_bss_config **new_conf;
309
310 if (!iface)
311 return NULL;
312
313 if (ucv_type(bss_list) != UC_ARRAY ||
314 ucv_array_length(bss_list) != iface->num_bss)
315 return NULL;
316
317 new_bss = calloc(iface->num_bss, sizeof(*new_bss));
318 new_conf = calloc(iface->num_bss, sizeof(*new_conf));
319 for (size_t i = 0; i < iface->num_bss; i++) {
320 struct hostapd_data *bss;
321
322 bss = ucv_resource_data(ucv_array_get(bss_list, i), "hostapd.bss");
323 if (bss->iface != iface)
324 goto free;
325
326 for (size_t k = 0; k < i; k++)
327 if (new_bss[k] == bss)
328 goto free;
329
330 new_bss[i] = bss;
331 new_conf[i] = bss->conf;
332 }
333
334 new_bss[0]->interface_added = 0;
335 for (size_t i = 1; i < iface->num_bss; i++)
336 new_bss[i]->interface_added = 1;
337
338 free(iface->bss);
339 iface->bss = new_bss;
340
341 free(iface->conf->bss);
342 iface->conf->bss = new_conf;
343 iface->conf->num_bss = iface->num_bss;
344 hostapd_drv_set_first_bss(iface->bss[0]);
345
346 return ucv_boolean_new(true);
347
348 free:
349 free(new_bss);
350 free(new_conf);
351 return NULL;
352 }
353
354 static uc_value_t *
355 uc_hostapd_bss_ctrl(uc_vm_t *vm, size_t nargs)
356 {
357 struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
358 uc_value_t *arg = uc_fn_arg(0);
359 struct sockaddr_storage from = {};
360 static char reply[4096];
361 int reply_len;
362
363 if (!hapd || !interfaces->ctrl_iface_recv ||
364 ucv_type(arg) != UC_STRING)
365 return NULL;
366
367 reply_len = interfaces->ctrl_iface_recv(hapd, ucv_string_get(arg),
368 reply, sizeof(reply),
369 &from, sizeof(from));
370 if (reply_len < 0)
371 return NULL;
372
373 if (reply_len && reply[reply_len - 1] == '\n')
374 reply_len--;
375
376 return ucv_string_new_length(reply, reply_len);
377 }
378
379 static uc_value_t *
380 uc_hostapd_iface_stop(uc_vm_t *vm, size_t nargs)
381 {
382 struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
383 int i;
384
385 #ifdef CONFIG_ACS
386 if (iface->state == HAPD_IFACE_ACS) {
387 acs_cleanup(iface);
388 iface->scan_cb = NULL;
389 hostapd_disable_iface(iface);
390 }
391 #endif
392
393 for (i = 0; i < iface->num_bss; i++) {
394 struct hostapd_data *hapd = iface->bss[i];
395
396 hostapd_drv_stop_ap(hapd);
397 hapd->started = 0;
398 }
399 }
400
401 static uc_value_t *
402 uc_hostapd_iface_start(uc_vm_t *vm, size_t nargs)
403 {
404 struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
405 uc_value_t *info = uc_fn_arg(0);
406 struct hostapd_config *conf;
407 uint64_t intval;
408 int i;
409
410 if (!iface)
411 return NULL;
412
413 iface->freq = 0;
414 if (!info)
415 goto out;
416
417 if (ucv_type(info) != UC_OBJECT)
418 return NULL;
419
420 conf = iface->conf;
421 if ((intval = ucv_int64_get(ucv_object_get(info, "op_class", NULL))) && !errno)
422 conf->op_class = intval;
423 if ((intval = ucv_int64_get(ucv_object_get(info, "hw_mode", NULL))) && !errno)
424 conf->hw_mode = intval;
425 if ((intval = ucv_int64_get(ucv_object_get(info, "channel", NULL))) && !errno)
426 conf->channel = intval;
427 if ((intval = ucv_int64_get(ucv_object_get(info, "sec_channel", NULL))) && !errno)
428 conf->secondary_channel = intval;
429
430 intval = ucv_int64_get(ucv_object_get(info, "center_seg0_idx", NULL));
431 if (!errno)
432 hostapd_set_oper_centr_freq_seg0_idx(conf, intval);
433
434 intval = ucv_int64_get(ucv_object_get(info, "center_seg1_idx", NULL));
435 if (!errno)
436 hostapd_set_oper_centr_freq_seg1_idx(conf, intval);
437
438 intval = ucv_int64_get(ucv_object_get(info, "oper_chwidth", NULL));
439 if (!errno)
440 hostapd_set_oper_chwidth(conf, intval);
441
442 intval = ucv_int64_get(ucv_object_get(info, "frequency", NULL));
443 if (!errno)
444 iface->freq = intval;
445 conf->acs = 0;
446
447 out:
448 switch (iface->state) {
449 case HAPD_IFACE_DISABLED:
450 break;
451 case HAPD_IFACE_ENABLED:
452 if (!hostapd_is_dfs_required(iface) ||
453 hostapd_is_dfs_chan_available(iface))
454 break;
455 wpa_printf(MSG_INFO, "DFS CAC required on new channel, restart interface");
456 /* fallthrough */
457 default:
458 hostapd_disable_iface(iface);
459 break;
460 }
461
462 if (conf->channel && !iface->freq)
463 iface->freq = hostapd_hw_get_freq(iface->bss[0], conf->channel);
464
465 if (iface->state != HAPD_IFACE_ENABLED) {
466 hostapd_enable_iface(iface);
467 return ucv_boolean_new(true);
468 }
469
470 for (i = 0; i < iface->num_bss; i++) {
471 struct hostapd_data *hapd = iface->bss[i];
472 int ret;
473
474 hapd->started = 1;
475 hapd->conf->start_disabled = 0;
476 hostapd_set_freq(hapd, conf->hw_mode, iface->freq,
477 conf->channel,
478 conf->enable_edmg,
479 conf->edmg_channel,
480 conf->ieee80211n,
481 conf->ieee80211ac,
482 conf->ieee80211ax,
483 conf->ieee80211be,
484 conf->secondary_channel,
485 hostapd_get_oper_chwidth(conf),
486 hostapd_get_oper_centr_freq_seg0_idx(conf),
487 hostapd_get_oper_centr_freq_seg1_idx(conf));
488
489 ieee802_11_set_beacon(hapd);
490 }
491
492 return ucv_boolean_new(true);
493 }
494
495 static uc_value_t *
496 uc_hostapd_iface_switch_channel(uc_vm_t *vm, size_t nargs)
497 {
498 struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
499 uc_value_t *info = uc_fn_arg(0);
500 struct hostapd_config *conf;
501 struct csa_settings csa = {};
502 uint64_t intval;
503 int i, ret = 0;
504
505 if (!iface || ucv_type(info) != UC_OBJECT)
506 return NULL;
507
508 conf = iface->conf;
509 if ((intval = ucv_int64_get(ucv_object_get(info, "csa_count", NULL))) && !errno)
510 csa.cs_count = intval;
511 if ((intval = ucv_int64_get(ucv_object_get(info, "sec_channel", NULL))) && !errno)
512 csa.freq_params.sec_channel_offset = intval;
513
514 csa.freq_params.ht_enabled = conf->ieee80211n;
515 csa.freq_params.vht_enabled = conf->ieee80211ac;
516 csa.freq_params.he_enabled = conf->ieee80211ax;
517 #ifdef CONFIG_IEEE80211BE
518 csa.freq_params.eht_enabled = conf->ieee80211be;
519 #endif
520 intval = ucv_int64_get(ucv_object_get(info, "oper_chwidth", NULL));
521 if (errno)
522 intval = hostapd_get_oper_chwidth(conf);
523 if (intval)
524 csa.freq_params.bandwidth = 40 << intval;
525 else
526 csa.freq_params.bandwidth = csa.freq_params.sec_channel_offset ? 40 : 20;
527
528 if ((intval = ucv_int64_get(ucv_object_get(info, "frequency", NULL))) && !errno)
529 csa.freq_params.freq = intval;
530 if ((intval = ucv_int64_get(ucv_object_get(info, "center_freq1", NULL))) && !errno)
531 csa.freq_params.center_freq1 = intval;
532 if ((intval = ucv_int64_get(ucv_object_get(info, "center_freq2", NULL))) && !errno)
533 csa.freq_params.center_freq2 = intval;
534
535 for (i = 0; i < iface->num_bss; i++)
536 ret = hostapd_switch_channel(iface->bss[i], &csa);
537
538 return ucv_boolean_new(!ret);
539 }
540
541 static uc_value_t *
542 uc_hostapd_bss_rename(uc_vm_t *vm, size_t nargs)
543 {
544 struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
545 uc_value_t *ifname_arg = uc_fn_arg(0);
546 char prev_ifname[IFNAMSIZ + 1];
547 struct sta_info *sta;
548 const char *ifname;
549 int ret;
550
551 if (!hapd || ucv_type(ifname_arg) != UC_STRING)
552 return NULL;
553
554 os_strlcpy(prev_ifname, hapd->conf->iface, sizeof(prev_ifname));
555 ifname = ucv_string_get(ifname_arg);
556
557 hostapd_ubus_free_bss(hapd);
558 if (interfaces->ctrl_iface_deinit)
559 interfaces->ctrl_iface_deinit(hapd);
560
561 ret = hostapd_drv_if_rename(hapd, WPA_IF_AP_BSS, NULL, ifname);
562 if (ret)
563 goto out;
564
565 for (sta = hapd->sta_list; sta; sta = sta->next) {
566 char cur_name[IFNAMSIZ + 1], new_name[IFNAMSIZ + 1];
567
568 if (!(sta->flags & WLAN_STA_WDS) || sta->pending_wds_enable)
569 continue;
570
571 snprintf(cur_name, sizeof(cur_name), "%s.sta%d", prev_ifname, sta->aid);
572 snprintf(new_name, sizeof(new_name), "%s.sta%d", ifname, sta->aid);
573 hostapd_drv_if_rename(hapd, WPA_IF_AP_VLAN, cur_name, new_name);
574 }
575
576 if (!strncmp(hapd->conf->ssid.vlan, hapd->conf->iface, sizeof(hapd->conf->ssid.vlan)))
577 os_strlcpy(hapd->conf->ssid.vlan, ifname, sizeof(hapd->conf->ssid.vlan));
578 os_strlcpy(hapd->conf->iface, ifname, sizeof(hapd->conf->iface));
579 hostapd_ubus_add_bss(hapd);
580
581 hostapd_ucode_update_interfaces();
582 out:
583 if (interfaces->ctrl_iface_init)
584 interfaces->ctrl_iface_init(hapd);
585
586 return ret ? NULL : ucv_boolean_new(true);
587 }
588
589
590 int hostapd_ucode_init(struct hapd_interfaces *ifaces)
591 {
592 static const uc_function_list_t global_fns[] = {
593 { "printf", uc_wpa_printf },
594 { "getpid", uc_wpa_getpid },
595 { "sha1", uc_wpa_sha1 },
596 { "freq_info", uc_wpa_freq_info },
597 { "add_iface", uc_hostapd_add_iface },
598 { "remove_iface", uc_hostapd_remove_iface },
599 };
600 static const uc_function_list_t bss_fns[] = {
601 { "ctrl", uc_hostapd_bss_ctrl },
602 { "set_config", uc_hostapd_bss_set_config },
603 { "rename", uc_hostapd_bss_rename },
604 { "delete", uc_hostapd_bss_delete },
605 };
606 static const uc_function_list_t iface_fns[] = {
607 { "set_bss_order", uc_hostapd_iface_set_bss_order },
608 { "add_bss", uc_hostapd_iface_add_bss },
609 { "stop", uc_hostapd_iface_stop },
610 { "start", uc_hostapd_iface_start },
611 { "switch_channel", uc_hostapd_iface_switch_channel },
612 };
613 uc_value_t *data, *proto;
614
615 interfaces = ifaces;
616 vm = wpa_ucode_create_vm();
617
618 global_type = uc_type_declare(vm, "hostapd.global", global_fns, NULL);
619 bss_type = uc_type_declare(vm, "hostapd.bss", bss_fns, NULL);
620 iface_type = uc_type_declare(vm, "hostapd.iface", iface_fns, NULL);
621
622 bss_registry = ucv_array_new(vm);
623 uc_vm_registry_set(vm, "hostap.bss_registry", bss_registry);
624
625 iface_registry = ucv_array_new(vm);
626 uc_vm_registry_set(vm, "hostap.iface_registry", iface_registry);
627
628 global = wpa_ucode_global_init("hostapd", global_type);
629
630 if (wpa_ucode_run(HOSTAPD_UC_PATH "hostapd.uc"))
631 goto free_vm;
632 ucv_gc(vm);
633
634 return 0;
635
636 free_vm:
637 wpa_ucode_free_vm();
638 return -1;
639 }
640
641 void hostapd_ucode_free(void)
642 {
643 if (wpa_ucode_call_prepare("shutdown") == 0)
644 ucv_put(wpa_ucode_call(0));
645 wpa_ucode_free_vm();
646 }
647
648 void hostapd_ucode_free_iface(struct hostapd_iface *iface)
649 {
650 wpa_ucode_registry_remove(iface_registry, iface->ucode.idx);
651 }
652
653 void hostapd_ucode_add_bss(struct hostapd_data *hapd)
654 {
655 uc_value_t *val;
656
657 if (wpa_ucode_call_prepare("bss_add"))
658 return;
659
660 val = hostapd_ucode_bss_get_uval(hapd);
661 uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
662 uc_value_push(ucv_get(val));
663 ucv_put(wpa_ucode_call(2));
664 ucv_gc(vm);
665 }
666
667 void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
668 {
669 uc_value_t *val;
670
671 if (wpa_ucode_call_prepare("bss_reload"))
672 return;
673
674 val = hostapd_ucode_bss_get_uval(hapd);
675 uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
676 uc_value_push(ucv_get(val));
677 ucv_put(wpa_ucode_call(2));
678 ucv_gc(vm);
679 }
680
681 void hostapd_ucode_free_bss(struct hostapd_data *hapd)
682 {
683 uc_value_t *val;
684
685 val = wpa_ucode_registry_remove(bss_registry, hapd->ucode.idx);
686 if (!val)
687 return;
688
689 hapd->ucode.idx = 0;
690 if (wpa_ucode_call_prepare("bss_remove"))
691 return;
692
693 uc_value_push(ucv_string_new(hapd->conf->iface));
694 uc_value_push(ucv_get(val));
695 ucv_put(wpa_ucode_call(2));
696 ucv_gc(vm);
697 }