网上发现一个哥们对hostapd,已经进行了一些大代码已经进行了分析,可以去看看,写的很不错
http://blog.youkuaiyun.com/tmwiajd/article/details/41620933
hostapd作用介绍: http://blog.youkuaiyun.com/tmwiajd/article/details/42592053
hostapd主要负责管理工作站(station)认证和接入。因此,它只处理管理帧(Management Frame),并不处理数据帧。即业务数据流量什么的并不接受。
主要的核心函数为:
hostapd_driver_init(interfaces.iface[i])
hostapd_setup_interface(interfaces.iface[i])
hostapd_driver_init //hostapd配置初始化
hostapd_setup_interface // 初始化网卡,启动
无线数据接收部分:
创建monitor(类似有线的混杂模式)监听无线数据接收:
capwap_create_iface(drv, buf, NL80211_IFTYPE_MONITOR, NULL,0);
eloop_register_read_sock(drv->monitor_sock,
handle_monitor_read,drv, NULL);
handle_monitor_read主要进行管理帧的处理,
802.11的管理帧主要有信标帧(beacon)、探测请求帧(probe request)、探测回应帧(probe response)、请求认证帧(authentication request)、认证回应帧(authentication response)、请求关联帧(association request)和关联回应帧(association response)等
handle_monitor_read: 处理接收的管理帧,分为LOCAL_MAC 和 SPLIT_MAC 两种处理管理帧模式,但是协议并没有明确规定处理端,因此各厂商对这部分功能的实现也是各有不同。
接收到的数据会带有radiotap头
radiotap头部分析:
http://www.latelee.org/net-study/ieee802-11-radiotap.html
http://blog.youkuaiyun.com/subfate/article/details/53170546
处理具体管理帧
wpa_supplicant_event –> 这里是链接到 hostapd_wpa_event函数
管理帧处理
case EVENT_RX_MGMT:
if (!data->rx_mgmt.frame)
break;
#ifdef NEED_AP_MLME
if (hostapd_mgmt_rx(hapd, &data->rx_mgmt) > 0)
break;
#endif /* NEED_AP_MLME */
hostapd_action_rx(hapd, &data->rx_mgmt);
break;
–> ieee802_11_mgmt 处理各个种类帧
在ieee802_11_mgmt里可以看到相关路由器中的黑白名单之类的配置,具体操作时候可以调用到这里。
ap的接入过程分析:
http://www.cnblogs.com/santiaoa/p/5784306.html
里面还写了一些相关AP的一些基础知识。
ps : ap的作用就相当于交换机的功能,可以说它是无线交换机,实现无线数据的转发功能。
怎么将sta加入到ap中使用时库libnl提供的相关接口,具体实施过程,我也没去了解,具体可以看文档:
官方文档:http://www.infradead.org/~tgr/libnl/doc/core.html
中文文档:http://blog.guorongfei.com/2015/01/20/libnl-translation-part1/#introduction
官方提供的文档里,库函数的函数说明查找十分麻烦,建议直接去官网下个libnl的源码看,这样会比较直观比较快。
最后说下几个可能会使用到名字,例如ssid,bssid,bss,ess等等
http://blog.youkuaiyun.com/an_zhenwei/article/details/17107133
http://blog.sina.com.cn/s/blog_4c02ba150101pb9x.html
http://blog.youkuaiyun.com/kenny_wju/article/details/17435079