CentOS8 中 Atheros 的设备 SIOCGIWRANGE 的 ioctl 不合适

Inappropriate ioctl for device SIOCGIWRANGE with Atheros in CentOS8

我正在尝试使用 iwlib 获取无线扩展的频率列表,但是函数 iw_get_range_info returns -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, ifname, 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-generic)上运行良好,但在 CentOS 8(内核4.18.0-193.19.1.el8_2.x86_64).

另外,命令dmesg | grep ath returns:

[    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