问题描述
我正在尝试使用iwlib获取无线扩展的频率列表,但是函数iw_get_range_info
返回-1:
if((m_skfd = iw_sockets_open()) < 0)
{
printf("Error while opening socket.");
return;
}
if(iw_get_range_info(m_skfd,m_ifname,&m_range) < 0)
{
printf("No frequency information.");
return;
}
在iwlib.c
中,我看到正在调用的函数是iw_get_ext(skfd,ifname,SIocgIWRANGE,&wrq)
,所以我在iwlib.h
中修改了此函数以获取错误代码:
static inline int
iw_get_ext(int skfd,/* Socket to the kernel */
const char * ifname,/* Device name */
int request,/* WE ID */
struct iwreq * pwrq) /* Fixed part of the request */
{
/* Set device name */
strncpy(pwrq->ifr_name,IFNAMSIZ);
/* Do the request */
int result = ioctl(skfd,request,pwrq);
if (result < 0)
{
printf("ioctl Failed and returned errno %s \n",strerror(errno));
}
return(result);
}
返回的错误是“设备的不适当的ioctl”(错误0x19)。所以ioctl失败了。
无线扩展使用芯片组Qualcomm Atheros QCA9890。驱动程序版本为10.2.4.70.9-2(但与10.2.4-1.0-00045相同)。
除此之外,我能够正常使用扩展名并执行AP扫描。
要注意的重要一点是,具有相同硬件的相同代码在Ubuntu 16.04(内核4.15.0-118-通用)上可以正常工作,但在CentOS 8(内核4.18.0-193.19.1)上不能正常工作。 el8_2.x86_64)。
此外,命令dmesg | grep ath
返回:
[ 2.013673] systemd[1]: Started Hardware RNG Entropy Gatherer Daemon.
[ 10.052991] ath10k_pci 0000:06:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
[ 10.231675] ath10k_pci 0000:06:00.0: qca988x hw2.0 target 0x4100016c chip_id 0x043202ff sub 0000:0000
[ 10.233800] ath10k_pci 0000:06:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 0 testmode 0
[ 10.236144] ath10k_pci 0000:06:00.0: firmware ver 10.2.4.70.9-2 api 5 features no-p2p,raw-mode crc32 b8d50af5
[ 10.287676] ath10k_pci 0000:06:00.0: board_file api 1 bmi_id N/A crc32 bebc7c08
[ 11.501908] ath10k_pci 0000:06:00.0: unsupported HTC service id: 1536
[ 11.523523] ath10k_pci 0000:06:00.0: htt-ver 2.1 wmi-op 5 htt-op 2 cal otp max-sta 128 raw 0 hwcrypto 1
[ 11.597526] ath: EEPROM regdomain: 0x0
[ 11.597529] ath: EEPROM indicates default country code should be used
[ 11.597530] ath: doing EEPROM country->regdmn map search
[ 11.597532] ath: country maps to regdmn code: 0x3a
[ 11.597533] ath: Country alpha2 being used: US
[ 11.597534] ath: Regpair used: 0x3a
[ 11.644556] ath10k_pci 0000:06:00.0 wlp6s0: renamed from wlan0
什么可能导致此问题?
解决方法
我认为您遇到了这个问题,因为您正在使用无线扩展,这是与无线设备通信的旧方法。有关更多详细信息,请参见this answer。