hostapd: add AFC support
[openwrt/staging/nbd.git] / package / network / services / hostapd / src / src / ap / ucode.c
index d3441902086ebcaeb196c0096a54db981221f4a0..c2876ebd8999237f1345364b4ed53e13cbf67d80 100644 (file)
@@ -766,6 +766,34 @@ void hostapd_ucode_free_iface(struct hostapd_iface *iface)
        wpa_ucode_registry_remove(iface_registry, iface->ucode.idx);
 }
 
+int hostapd_ucode_afc_request(struct hostapd_iface *iface, const char *request,
+                             char *buf, size_t len)
+{
+       uc_value_t *val;
+       size_t ret_len;
+       int ret = -1;
+
+       if (wpa_ucode_call_prepare("afc_request"))
+               return -1;
+
+       uc_value_push(ucv_get(ucv_string_new(iface->phy)));
+       uc_value_push(ucv_get(ucv_string_new(request)));
+       val = wpa_ucode_call(2);
+       if (ucv_type(val) != UC_STRING)
+               goto out;
+
+       ret_len = ucv_string_length(val);
+       if (ret_len >= len)
+               goto out;
+
+       memcpy(buf, ucv_string_get(val), ret_len + 1);
+       ret = (int)ret_len;
+
+out:
+       ucv_put(val);
+       return ret;
+}
+
 void hostapd_ucode_add_bss(struct hostapd_data *hapd)
 {
        uc_value_t *val;