0%

iwpriv 命令

iwpriv 工具通过 ioctl 动态获取相应无线网卡驱动的 private_args 所有扩展参数

iwpriv -> main -> set_private -> iw_get_priv_info -> iw_get_ext(skfd, ifname, SIOCGIWPRIV, &wrq) -> ioctl

wifi 驱动NETIF/os/linux/sta_ioctl.c

case SIOCGIWPRIV:
    if (wrqin->u.data.pointer)
    {
        if ( access_ok(VERIFY_WRITE, wrqin->u.data.pointer, sizeof(privtab)) != TRUE)
            break;
        if ((sizeof(privtab) / sizeof(privtab[0])) <= wrq->u.data.length)
        {
            wrqin->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
            if (copy_to_user(wrqin->u.data.pointer, privtab, sizeof(privtab)))
                Status = -EFAULT;
        }
        else
            Status = -E2BIG;
    }
    break;

其中 privtab 及为支持列表

struct iw_priv_args privtab[] = {
{ RTPRIV_IOCTL_SET,
  IW_PRIV_TYPE_CHAR | 1024, 0,
  "set"},

{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
  ""},
/* --- sub-ioctls definitions --- */
#ifdef MAT_SUPPORT
    { SHOW_IPV4_MAT_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "ipv4_matinfo" },
    { SHOW_IPV6_MAT_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "ipv6_matinfo" },
    { SHOW_ETH_CLONE_MAC,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "cloneMAC" },
#endif /* MAT_SUPPORT */
    { SHOW_CONN_STATUS,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
    { SHOW_DRVIER_VERION,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
    { SHOW_BA_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
    { SHOW_DESC_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
    { RAIO_OFF,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
    { RAIO_ON,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
#ifdef QOS_DLS_SUPPORT
    { SHOW_DLS_ENTRY_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
#endif /* QOS_DLS_SUPPORT */
    { SHOW_CFG_VALUE,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
    { SHOW_ADHOC_ENTRY_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
#ifdef DOT11Z_TDLS_SUPPORT
    { SHOW_TDLS_ENTRY_INFO,
      IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "tdlsentryinfo" },
#endif /* DOT11Z_TDLS_SUPPORT */
    {SHOW_DEV_INFO,
    IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "devinfo"},
    {SHOW_STA_INFO,
    IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "stainfo"},
/* --- sub-ioctls relations --- */

#ifdef DBG
{ RTPRIV_IOCTL_BBP,
  IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
  "bbp"},
{ RTPRIV_IOCTL_MAC,
  IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
  "mac"},
#if defined(RLT_RF) || defined(RTMP_RF_RW_SUPPORT)
{ RTPRIV_IOCTL_RF,
  IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
  "rf"},
#endif /* RTMP_RF_RW_SUPPORT */
{ RTPRIV_IOCTL_E2P,
  IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
  "e2p"},
#endif  /* DBG */

{ RTPRIV_IOCTL_STATISTICS,
  0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
  "stat"},
{ RTPRIV_IOCTL_GSITESURVEY,
  0, IW_PRIV_TYPE_CHAR | 1024,
  "get_site_survey"},

#ifdef WSC_STA_SUPPORT
{ RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM,
  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
{ RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM,
  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "" },
{ RTPRIV_IOCTL_SET_WSC_PROFILE_STRING_ITEM,
  IW_PRIV_TYPE_CHAR | 128, 0, "" },
/* --- sub-ioctls definitions --- */
    { WSC_CREDENTIAL_COUNT,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wsc_cred_count" },
    { WSC_CREDENTIAL_SSID,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_cred_ssid" },
    { WSC_CREDENTIAL_AUTH_MODE,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_cred_auth" },
    { WSC_CREDENTIAL_ENCR_TYPE,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_cred_encr" },
    { WSC_CREDENTIAL_KEY_INDEX,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_cred_keyIdx" },
    { WSC_CREDENTIAL_KEY,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_cred_key" },
    { WSC_CREDENTIAL_MAC,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_cred_mac" },
    { WSC_SET_DRIVER_CONNECT_BY_CREDENTIAL_IDX,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wsc_conn_by_idx" },
    { WSC_SET_DRIVER_AUTO_CONNECT,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wsc_auto_conn" },
    { WSC_SET_CONF_MODE,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wsc_conf_mode" },
    { WSC_SET_MODE,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wsc_mode" },
    { WSC_SET_PIN,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_pin" },
    { WSC_SET_SSID,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_ssid" },
    { WSC_SET_BSSID,
      IW_PRIV_TYPE_CHAR | 128, 0, "wsc_bssid" },
    { WSC_START,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "wsc_start" },
    { WSC_STOP,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "wsc_stop" },
    { WSC_GEN_PIN_CODE,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "wsc_gen_pincode" },
    { WSC_AP_BAND,
      IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wsc_ap_band" },
/* --- sub-ioctls relations --- */
#endif /* WSC_STA_SUPPORT */
};

另外内核相关

const struct iw_handler_def rt28xx_iw_handler_def =
{
#define    N(a)    (sizeof (a) / sizeof (a[0]))
    .standard    = (iw_handler *) rt_handler,
    .num_standard    = sizeof(rt_handler) / sizeof(iw_handler),
    .private    = (iw_handler *) rt_priv_handlers,
    .num_private        = N(rt_priv_handlers),
    .private_args    = (struct iw_priv_args *) privtab,
    .num_private_args    = N(privtab),
#if IW_HANDLER_VERSION >= 7
    .get_wireless_stats = rt28xx_get_wireless_stats,
#endif
};

在打开设备时会进行注册 rt28xx_open