/*

 

*By Neil Chiao (neilchiao at gmail.com)

*转载请注明出处:

neilengineer.cublog.cn

www.xinxingwan.com

*/

 
 
 
 

WIFI ioctl中SIOCSIWSCAN命令从应用程序到内核再到驱动
应用程序中:
ioctl(skfd, SIOCSIWSCAN , &wrq); 
其中,#define SIOCSIWSCAN 0x8B18
socket的ioctl先看net/socket.c的sock_ioctl
对于无线:
0x8B00 ~ 0x8BFF  调用net/core/dev.c --> dev_ioctl
dev_ioctl中执行到default中,最后调用了wireless_process_ioctl
对wireless_process_ioctl,又跑到了default中,如果有handler,最后到ioctl_standard_call中;
没有handler时,使用老的接口(dev->do_ioctl)。
   handler = get_handler(dev, cmd);
   if(handler != NULL) {
    /* Standard and private are not the same */
    if(cmd < SIOCIWFIRSTPRIV)
     return ioctl_standard_call(dev,
           ifr,
           cmd,
           handler);
    else
     return ioctl_private_call(dev,
          ifr,
          cmd,
          handler);
   }
   /* Old driver API : call driver ioctl handler */
   if (dev->do_ioctl) {
    return dev->do_ioctl(dev, ifr, cmd);
   }

有handler时,在具体WIFI驱动中,有类似如下实现:
netdev->wireless_handlers = (struct iw_handler_def *)&iwctl_handler_def;
const struct iw_handler_def iwctl_handler_def =
{
......
 .get_wireless_stats = &iwctl_get_wireless_stats, 
 .standard = (iw_handler *) iwctl_handler,
......
}
static const iw_handler  iwctl_handler[] =
{
 (iw_handler) iwctl_commit,      // SIOCSIWCOMMIT     
......
......
 (iw_handler) iwctl_giwrange,  // SIOCGIWRANGE 
......
......
#if WIRELESS_EXT > 13 
 (iw_handler) iwctl_siwscan,         // SIOCSIWSCAN  
 (iw_handler) iwctl_giwscan,         // SIOCGIWSCAN   
#else 
 (iw_handler) NULL,
 (iw_handler) NULL,
#endif 
......
};
 
rt_ioctl_siwessid