mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-30 18:07:52 +00:00 
			
		
		
		
	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 <tanya_singh@accton.com>
This commit is contained in:
		| @@ -1,7 +1,8 @@ | |||||||
| let libubus = require("ubus"); | 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"; | 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); | let ubus = libubus.connect(null, 60); | ||||||
|  |  | ||||||
| hostapd.data.config = {}; | hostapd.data.config = {}; | ||||||
| @@ -1006,7 +1007,6 @@ let main_obj = { | |||||||
| hostapd.data.ubus = ubus; | hostapd.data.ubus = ubus; | ||||||
| hostapd.data.obj = ubus.publish("hostapd", main_obj); | hostapd.data.obj = ubus.publish("hostapd", main_obj); | ||||||
|  |  | ||||||
|  |  | ||||||
| let auth_obj = {}; | let auth_obj = {}; | ||||||
| hostapd.data.auth_obj = ubus.publish("hostapd-auth", auth_obj); | hostapd.data.auth_obj = ubus.publish("hostapd-auth", auth_obj); | ||||||
|  |  | ||||||
| @@ -1026,10 +1026,21 @@ return { | |||||||
| 		hostapd.ubus.disconnect(); | 		hostapd.ubus.disconnect(); | ||||||
| 	}, | 	}, | ||||||
| 	afc_request: function(iface, data) { | 	afc_request: function(iface, data) { | ||||||
| 		let ret = ubus.call("afc", "request", { data }); | 		let wireless_config = uci.get_all('wireless'); | ||||||
| 		if (type(ret) != "object") | 		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; | 					return; | ||||||
| 		return ret.data; | 			} | ||||||
|  | 		} | ||||||
| 	}, | 	}, | ||||||
| 	bss_create: function(phy, name, obj) { | 	bss_create: function(phy, name, obj) { | ||||||
| 		phy = hostapd.data.config[phy]; | 		phy = hostapd.data.config[phy]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tanya Singh
					Tanya Singh