From 3a8fc316f22fd44ed040b72c25928cba962ad341 Mon Sep 17 00:00:00 2001 From: Tanya Singh Date: Wed, 30 Jul 2025 15:18:58 +0800 Subject: [PATCH] qca-wifi-7/afc: Use curl instead of uclient to send/receive AFC request/response using hostapd Fixes: WIFI-14427 Signed-off-by: Tanya Singh --- feeds/qca-wifi-7/hostapd/files/hostapd.uc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/feeds/qca-wifi-7/hostapd/files/hostapd.uc b/feeds/qca-wifi-7/hostapd/files/hostapd.uc index 47006a6fb..7c3cb56aa 100644 --- a/feeds/qca-wifi-7/hostapd/files/hostapd.uc +++ b/feeds/qca-wifi-7/hostapd/files/hostapd.uc @@ -1,7 +1,8 @@ let libubus = require("ubus"); -import { open, readfile } from "fs"; +import { open, readfile, writefile } from "fs"; import { wdev_remove, is_equal, vlist_new, phy_is_fullmac, phy_open, wdev_set_radio_mask } from "common"; +let uci = require('uci').cursor(); let ubus = libubus.connect(null, 60); hostapd.data.config = {}; @@ -1006,7 +1007,6 @@ let main_obj = { hostapd.data.ubus = ubus; hostapd.data.obj = ubus.publish("hostapd", main_obj); - let auth_obj = {}; hostapd.data.auth_obj = ubus.publish("hostapd-auth", auth_obj); @@ -1026,10 +1026,21 @@ return { hostapd.ubus.disconnect(); }, afc_request: function(iface, data) { - let ret = ubus.call("afc", "request", { data }); - if (type(ret) != "object") - return; - return ret.data; + let wireless_config = uci.get_all('wireless'); + for (let l, afc_server in wireless_config) { + if (afc_server['.type'] == 'afc-server' && afc_server.url && data) { + hostapd.printf(`Sending AFC request: ${data}`); + writefile("/tmp/afc-request.json", data); + + system(`curl -s -X POST ${afc_server.url} -H \'accept: \*\/\*\' -H \'Authorization: Bearer ${afc_server.access_token}\' -H \'Content-Type: application/json\' -d \'${data}\' --output /tmp/afc-response.json`); + + let afc_response = (readfile("/tmp/afc-response.json")); + if (afc_response) + return afc_response; + else + return; + } + } }, bss_create: function(phy, name, obj) { phy = hostapd.data.config[phy];