分享

hostapd 0.4.8 笔记

 cupid 2014-09-11

hostapd 0.4.8
----------------------------------------------------------------------
1、hostapd_init /* 每一个需要用到hostapd的vap(802.11i加密方式的vap)对应一套hostapd数据结构,并初始化一次。*/
1.1 hostapd_config_read 读取配置文件,并返回对应的数据结构
1.1.1 hostapd_config_defaults /* 默认配置 */
1.1.2 读取指定配置文件,并修改默认配置(包括eap_sim_db的配置)
1.1.3 hostapd_config_read_maclist 配置accept/deny mac列表
1.1.4 hostapd_config_read_eap_user 读取eap用户配置文件
1.1.5 hostapd_config_check 检查配置是否完善
1.2 EAP_TLS相关处理,略过
1.3 eap_sim_db_init 初始化EAP-SIM database
1.4 初始无线化驱动API函数表 atheros_driver_ops
----------------------------------------------------------------------
2、hostapd_setup_interface /*每个802.11i的vap对应都会调用一次 */
2.1 hostapd_driver_init 驱动初始化
2.2 获取ssid,配置文件or从驱动获取
2.3 hostapd_setup_wpa_psk wpa_psk的初始化
2.3.1 pbkdf2_sha1 根据预共享密钥推导出加密密钥
2.3.2 hostapd_config_read_wpa_psk 根据证书推导出加密密钥
2.4 调用驱动api设置ssid用于beacon and probe response frames
2.5 radius_client_init radius设置初始化
2.5.1 radius_client_init_auth
2.5.2 radius_client_init_acct
2.5.3 eloop_register_timeout
2.6 radius_server_init
2.7 hostapd_acl_init
2.8 ieee802_1x_init
2.8.1 hapd->driver->set_ieee8021x 调用驱动api使能无线驱动的8021x能力
2.8.1.1 ieee80211_ioctl_setparam /*最终调用到此驱动处理函数*/
2.8.1.1.1 加载IEEE80211_AUTH_8021X模块
2.8.1.1.2 给对应的vap打上标记IEEE80211_F_PRIVACY
2.8.2 ieee802_1x_receive_auth 挂接认证报文的处理函数
2.8.3 ieee802_1x_rekey 如果有配置wep_key_len_broadcast重新推导wep密钥
2.9 wpa_init
2.10 wsc_ie_init
2.11 accounting_init
2.11.1 accounting_receive 注册计费报文处理函数
2.11.2 accounting_report_state
2.11.2.1 accounting_msg 申请一个radius计费消息
2.11.2.2 radius_msg_add_attr_int32 添加消息内容
2.11.2.3 radius_client_send 发送报文
2.12 iapp_init  /*IEEE 802.11F 初始化*/
2.13 hostapd_wireless_event_init /*hapd->driver->wireless_event_init 驱动初始化事件*/
2.13.1 atheros_wireless_event_receive
2.14 hostapd_flush_old_stations  /*调用驱动清除状态 */
2.15 hostapd_ctrl_iface_init  /* 注册控制报文处理函数hostapd_ctrl_iface_receive*/
----------------------------------------------------------------------

----------------------------------------------------------------------
4、hostapd的读socket钩子函数总结
eloop_register_read_sock /*注册函数*/
4.1 hostapd_wireless_event_receive
4.1.1 atheros_wireless_event_rtm_newlink
4.1.1.1 atheros_wireless_event_wireless /* 分类处理 */
4.1.1.1.1 atheros_set_mib
4.1.1.1.2 atheros_del_sta
4.1.1.1.3 atheros_new_sta /* 处理hostapd_new_assoc_sta */
4.1.1.1.4 atheros_wireless_event_wireless_custom
4.2 handle_read
4.3 hostapd_ctrl_iface_receive
4.4 handle_802_3
4.5 test_driver_receive_unix
4.6 hostapd_preauth_receive
4.7 iapp_receive_udp
4.8 l2_packet_receive
4.9 radius_client_receive
4.10 radius_server_receive_auth
4.11 wsc_ie_read_callback
----------------------------------------------------------------------
5、atheros_init /* 安装和atheros驱动相关的钩子函数,和atheros驱动进行交互 */
5.1 创建驱动数据结构 atheros_driver_data,并初始化api函数表
5.2 创建对应的控制socket
5.3 l2_packet_init 创建发送 raw socket
5.3.1 创建ETH_P_EAPOL协议的socket,bind到接口,并将注册到读socket,处理函数为l2_packet_receive
5.3.1.1 socket收到报文后,调用l2_packet_receive处理,l2_packet_receive剥掉或保留2层头,此处保留2层头
5.3.1.1.1 调用钩子函数l2->rx_callback_ctx(为handle_read)进一步处理
5.3.1.1.1.1 ap_get_sta 查找报文是否来自已连接的station
5.3.1.1.1.2 ieee802_1x_receive /* Process the EAPOL frames from the Supplicant */

5.4 如果hostapd配置有桥 则创建接收 raw socket
5.5 atheros_set_iface_flags 将接口down
5.6 wsc_handle_frames 注册处理ETH_P_EAPOL报文
5.7 set80211priv IEEE80211_IOCTL_FILTERFRAME

----------------------------------------------------------------------
6、ieee802_1x_receive /* 处理802.1x协议报文 */
6.1 判断hostapd是否启用了802.1x
6.2 校验station是否在线
6.3 报文长度合法性校验
6.4 更新此sta相关的802.1x统计数据
6.5 如果是key方式且key类型为WPA或RSN,则调用函数 wpa_receive 处理
6.6 分类处理不同类型报文
6.6.1 IEEE802_1X_TYPE_EAP_PACKET handle_eap
6.6.2 IEEE802_1X_TYPE_EAPOL_START
6.6.3 IEEE802_1X_TYPE_EAPOL_LOGOFF
6.6.4 IEEE802_1X_TYPE_EAPOL_KEY
6.6.5 IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT
6.7 eapol_sm_step 运行状态机 最后调用eapol_sm_step_run 处理协议的复杂的状态机。
端口受限,放开等处理都在状态机中进行,例如:ieee802_1x_set_sta_authorized
802.1x转化为radius报文: ieee802_1x_encapsulate_radius 等先略过。
----------------------------------------------------------------------

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约