linux 无线层代码分析
来源:互联网 发布:笑气淘宝 编辑:程序博客网 时间:2024/06/10 05:58
LINUX无线层组成结构如下:
1, 大致框架
2, 几个主要流程
a) malloc & init(softmac)
内存分布
structwiphy
structieee80211_local
Driverprivate class
结构体关系
初始化顺序
- module_init,注册xxxx_driver_ops
- xxxx_probe,各种资源初始化。
- ieee80211_alloc_hw,两个参数分别为mac80211_config_ops和private class的size
- wiphy_new分配整块内存,wiphy_new里面初始化cfg80211_registered_device的一些成员
- 初始化ieee80211_local各个成员,并将wiphy.priv指向ieee80211_local
- ieee80211_local偏移到末尾,指针指向private class,并且保留在ieee80211_local.hw.priv
- 初始化private class
- ieee80211_register_hw,实现mac80211硬件的注册
- wiphy_register添加dev(device_add),以及一些sanity检测
- 并且初始化channel,iface以及wep等。
- 调用ieee80211_if_add添加一个wlan0,类型为sta的net_device,并且给该net_device分配一块私有数据区:ieee80211_sub_if_data,已经实现了一套net_device_ops
b) beacon frame
接收流程
对于管理帧,通常是ieee80211_rx_handlers调用ieee80211_rx_h_mgmt,然后用wq的方式调用ieee80211_iface_work进一步调用ieee80211_sta_rx_queued_mgmt去处理。
beacon响应流程
TIM IE:
E-id | length | DTIM count | DTIM period | Bitmap control | PVM(1-256byte)
remain to investigate:
how passive scan is implemented by beacon?c) scan
d) auth and associate
wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME- true): sme_authenticate->wpa_driver_nl80211_authenticate...->cfg80211_mlme_auth
- false): wpa_drv_associate->wpa_driver_nl80211_connect...->cfg80211_mlme_auth
assoc成功之后会调用driver的set_key函数update key, 一般是放到wifi芯片某个管脚对应的缓存区域,从而实现硬件加密(与xmit skb缓存区进行与或,eg)。
具体函数栈流程如下:
点击(此处)折叠或打开
- nl80211_connect
- cfg80211_connect(after scan and have bbs)
- cfg80211_conn_do_work
- __cfg80211_mlme_auth
- rdev->ops->auth(&rdev->wiphy, dev, &req);
- CallBack by rx irq:
- ieee80211_rx_irqsafe
- ieee80211_tasklet_handler
- ieee80211_rx
- __ieee80211_rx_handle_packet
- ieee80211_prepare_and_rx_handle
- ieee80211_invoke_rx_handlers
- ieee80211_rx_handlers
- ieee80211_rx_h_mgmt
- Queuework:
- ieee80211_iface_work(iface.c)
- ieee80211_sta_rx_queued_mgmt
- ieee80211_rx_mgmt_auth
- cfg80211_send_rx_auth
- nl80211_send_rx_auth(告诉用户空间)
- cfg80211_sme_rx_auth
- schedule_work(&rdev->conn_work)
- Queuework:
- cfg80211_conn_work
- __cfg80211_mlme_assoc
- rdev->ops->assoc
- CallBack by rx irq
- ....
- ieee80211_sta_rx_queued_mgmt
- ieee80211_rx_mgmt_assoc_resp
- ieee80211_assoc_success
- ieee80211_sta_rx_notify
- 通过timer定时触发 ieee80211_mgd_probe_ap_send
- 发送nullfunction或者probe_req
- cfg80211_send_rx_assoc
- nl80211_send_rx_assoc(告诉用户空间)
- __cfg80211_connect_result
- nl80211_send_connect_result
- cfg80211_upload_connect_keys
- rdev->ops->add_key
e) rx/tx data
rx:
xmit:
e) csa
1)beacon 2)action帧没连上,正在scan,不用管
手头有任务,先把手头任务做完,然后断开连接
手头没任务,调用driver的channel_switch(回调实现后面的改chan值)或者hw_config函数,然后把local的chan值改一下
f) missing
some details: off channel,
3, wifi driver部分之bcmdhd
a) init(施工ing)b) fireware load(施工ing)
0 0
- linux 无线层代码分析
- Linux网络层 ip_rcv()函数代码分析
- Linux网络层 ip_rcv()函数代码分析
- 无线入网分析代码一
- Rild层代码分析
- 通信层代码分析
- Linux网络层 ip_rcv()函数代码分析(__pskb_pull_tail)
- Linux网络层 ip_rcv()函数代码分析(__pskb_pull_tail)
- Linux网络层 ip_rcv()函数代码分析(__pskb_pull_tail)
- linux usb gadget代码分析--- gadget功能驱动层
- Linux netfilter 学习笔记 之九 ip层netfilter的连接跟踪模块代码分析
- Linux netfilter 学习笔记 之十二 ip层netfilter的NAT模块代码分析
- Linux netfilter 学习笔记 之十二 ip层netfilter的NAT模块代码分析
- Linux netfilter 学习笔记 之九 ip层netfilter的连接跟踪模块代码分析
- ril层的所有代码分析
- <三>--RIL层代码分析---RIL_register()
- ril层的所有代码分析
- <三>--RIL层代码分析---RIL_register()
- 关于Asp中代码与页面的分离
- ASP项目中的公共翻页模块
- HTTP 500 - 内部服务器错误解决方法
- 正则表达式
- flash源文件小,导出后变大的问题
- linux 无线层代码分析
- Flash调用外部文件集合
- 从零单排caffe
- 在Flash中利用Actionscript在动态文本框中加载HTML格式的文本
- int *p=malloc(100); 求 sizeof(p)
- 彻底消化 Ajax技术原理深层解析
- asp模板解析类模块(支持if,function,loop及解析缓存)
- LAMP网站架构方案分析
- XAMPP更改Apache的网站根目录