The Iwpriv tool dynamically acquires all the extended parameters of the corresponding wireless card driver via the IOCTL Private_args
Iwpriv is the implementation of all the extensions that handle the following Wlan_private_args, Iwpriv, and so on,
=>main
=>set_private
=>iw_get_priv_info gets all the Wlan_private_args types that the wireless NIC can handle.
Dev_ioctl
=>wext_handle_ioctl
=>wireless_process_ioctl
if (cmd = = Siocgiwpriv && dev->wireless_handlers)
Return Ioctl_standard_call (Dev, IFR, CMD,
&iw_handler_get_private);
static int Ioctl_standard_call (struct net_device * Dev,
struct Ifreq * IFR,
unsigned int cmd,
Iw_handler handler)
{
...
/* Call the handler * *
ret = handler (dev, &info, & (Iwr->u), extra);
if (User_length < iwr->u.data.length) {
Kfree (extra);
Return-e2big;
Notice Iwpriv, this wifi network card corresponding to the private command is not finished, and so Iwpriv will continue to
Maxpriv default is 16, will be a group of 16, a group of a group from the WiFi network card driver to read the network card can support all the Private_args parameters
Newpriv = ReAlloc (priv, Maxpriv * sizeof (priv[0])); Continue to apply, continue to copy, know all the Wlan_private_args parameters to customize the WiFi NIC
Outgoing to Iwpriv.
}
...
}
/* New driver Api:try to find the handler * *
Handler = Get_handler (dev, cmd);//Get
if (handler) {
/* Standard and private is not the same */
if (Cmd < SIOCIWFIRSTPRIV)
Return Ioctl_standard_call (Dev, IFR, CMD, handler);
Else
If there is a corresponding handler, then the processing Iwpriv command, can our iwpriv is done by the Dev->do_ioctl.
Return Ioctl_private_call (Dev, IFR, CMD, handler);
}
/* Old driver Api:call driver IOCTL handler */
if (DEV->DO_IOCTL)
If both Dev->wireless_handlers->standard and Dev->wireless_handlers->private[index do not handle the cmd, then the
Dev->do_ioctl = Wlan_do_ioctl; We drive the last processing function wlan_do_ioctl processing.
Return Dev->do_ioctl (Dev, IFR, cmd);
Static Iw_handler Get_handler (struct net_device *dev, unsigned int cmd)
{
/* Don ' t "optimise" the following variable, it'll crash */
unsigned int index; /* *must* be unsigned */
/* Check If we have some wireless handlers defined */
if (dev->wireless_handlers = = NULL)
return NULL;
/* Try as a standard command */
index = Cmd-siociwfirst;
if (Index < Dev->wireless_handlers->num_standard)
Return dev->wireless_handlers->standard[index];
/* Try as a private command */
index = cmd-siociwfirstpriv;//
if (Index < dev->wireless_handlers->num_private)
Return dev->wireless_handlers->private[index];//The handler of the private command.
/* Not found */
return NULL;
}
下面wlan_private_args为本wifi网卡驱动的所能支持的所有命令,也就是iwpriv命令所能支持的所有命令
struct iw_handler_def wlan_handler_def = {
num_standard:sizeof(wlan_handler) / sizeof(iw_handler),
num_private:sizeof(wlan_private_handler) / sizeof(iw_handler),
num_private_args:sizeof(wlan_private_args) / sizeof(struct iw_priv_args),
standard:(iw_handler *) wlan_handler,
private:(iw_handler *) wlan_private_handler,
private_args:(struct iw_priv_args *) wlan_private_args,
#if WIRELESS_EXT > 20
get_wireless_stats:wlan_get_wireless_stats,
#endif
};
以下为示意代码,我们的wifi网卡驱动支持如下iwpriv命令.
static const struct Iw_priv_args wlan_private_args[] = {
"Extscan"
"Hostcmd"
"Arpfilter"
"Regrdwr"
"SDCMD52RW"
"SDCMD53RW"
"Setgetconf"
"Getcis"
"ScanType"
"Deauth"
"GETNF"
"Getrssi"
"Bgscan"
"ENABLE11D"
"Adhocgrate"
"Sdioclock"
"WMM"
"Uapsdnullgen"
"Setcoalescing"
"Adhocgprot"
"Setpowercons"
"Wmm_qosinfo"
"Lolisteninter"
"Fwwakeupmethod"
"Psnullinterval"
"Bcnmisto"
"ADHOCAWAKEPD"
"Moduletype"
"Autodeepsleep"
"Enhanceps"
"WAKEUPMT"
"Setrxant"
"Settxant"
"Authalgs"
"Encryptionmode"
"Setregioncode"
"Setlisteninter"
"Setmultipledtim"
"Setbcnavg"
"Setdataavg
"Associate"
"Getregioncode"
"Getlisteninter"
"Getmultipledtim"
"Gettxrate"
"Getbcnavg"
"Getdataavg"
"Getrxant"
"Gettxant"
"GETTSF"
"Wpssession"
"DeepSleep"
"Adhocstop"
"Radioon"
"Radiooff"
"Rmaeskey"
"Crypto_test"
"Reasso-on"
"Reasso-off"
"Wlanidle-on"
"Wlanidle-off"
"Sleepparams"
"Requesttpc"
"Powercap"
"Measreq"
"Bca-ts"
"Scanmode"
"Getadhocstatus"
"Setgenie"
"Getgenie"
"Qstatus"
"Ts_status"
"Setaeskey"
"Getaeskey"
"Version"
"Verext"
"Setwpaie"
"Setband"
"Setadhocch"
"Chanswann"
"Getband"
"Getadhocch"
"Getlog"
"Tpccfg"
"Scanprobes"
"Ledgpio"
"SLEEPPD"
"Rateadapt"
"Getsnr"
"Getrate"
"Getrxinfo"
"Atimwindow"
"Bcninterval"
"Sdiopullctrl"
"Scantime"
"Sysclock"
"Txcontrol"
"Hscfg"
"Hssetpara"
"Inactoext"
"Dbgscfg"
"Drvdbg"
"Drvdelaymax"
"Intfctrl"
"Setquietie"
""
"Setuserscan"
"Getscantable"
"SETMRVLTLV"
"GETASSOCRSP"
"Addts"
"Delts"
"Qconfig"
"Qstats"
"Txpktstats"
"Getcfptable"
"Mefcfg"
"Getmem"
};
The Iwpriv tool dynamically acquires all the extended parameters of the corresponding wireless card driver via the IOCTL Private_args