hostapd生成beacon_ie

beacon ie由两部分组成,一部分是通过hostapd.conf,一部分通过读取驱动注册的wiphy获取硬件能力。

生成beacon ie入口函数

在准备好所有内容后AP启动调用ieee802_11_build_ap_params()函数生成空口完整beacon ie

配置文件部分

配置文件:/data/vendor/wifi/hostapd/hostapd_wlan0.conf
配置参数说明:https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf

配置参数

AP启动过程:
1.生成配置文件内容CreateHostapdConfig()->WriteHostapdConfig()
2.生成默认配置hostapd_config_defaults()
3.先读取默认配置hostapd_config_defaults()
4.然后加载配置文件hostapd_config_fill()//如果默认配置和文件冲突,以配置文件为主
将所有内容赋值struct hostapd_config;

//创建配置文件
1.CreateHostapdConfig--创建参数
2.WriteHostapdConfig--写配置文件hostapd.conf
3.hostapd_add_iface--
-->hostapd_config_alloc
   -->hostapd_config_defaults  ---- 设置一些默认配置
    struct hostapd_config *conf; ---- 保存对网络接口的配置
	struct hostapd_bss_config *bss; ---- 保存BSS 的配置信息
	conf->bss
-->hostapd_interface_init_bss
   -->interfaces->config_read_cb====hostapd_config_read()

//存储数据关键结构体
struct hostapd_data {
	struct hostapd_config *iconf;
	struct hostapd_bss_config *conf;
}	
	
//读取配置文件	
hostapd_config_read
-->hostapd_config_defaults ---- 读取默认配置
-->hostapd_config_fill ---- 解析.conf,保存到struct hostapd_configstruct hostapd_bss_config

参数举例

.conf都是读取配置文件
修改配置文件ht_capab字段
函数hostapd_config_ht_capab()

/* HT Capabilities Info field within HT Capabilities element */
#define HT_CAP_INFO_LDPC_CODING_CAP		((u16) BIT(0))
#define HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET	((u16) BIT(1))
#define HT_CAP_INFO_SMPS_MASK			((u16) (BIT(2) | BIT(3)))
#define HT_CAP_INFO_SMPS_STATIC			((u16) 0)
#define HT_CAP_INFO_SMPS_DYNAMIC		((u16) BIT(2))
#define HT_CAP_INFO_SMPS_DISABLED		((u16) (BIT(2) | BIT(3)))
#define HT_CAP_INFO_GREEN_FIELD			((u16) BIT(4))
#define HT_CAP_INFO_SHORT_GI20MHZ		((u16) BIT(5))
#define HT_CAP_INFO_SHORT_GI40MHZ		((u16) BIT(6))
#define HT_CAP_INFO_TX_STBC			((u16) BIT(7))
#define HT_CAP_INFO_RX_STBC_MASK		((u16) (BIT(8) | BIT(9)))
#define HT_CAP_INFO_RX_STBC_1			((u16) BIT(8))
#define HT_CAP_INFO_RX_STBC_12			((u16) BIT(9))
#define HT_CAP_INFO_RX_STBC_123			((u16) (BIT(8) | BIT(9)))
#define HT_CAP_INFO_DELAYED_BA			((u16) BIT(10))
#define HT_CAP_INFO_MAX_AMSDU_SIZE		((u16) BIT(11))
#define HT_CAP_INFO_DSSS_CCK40MHZ		((u16) BIT(12))
/* B13 - Reserved (was PSMP support
#define HT_CAP_INFO_40MHZ_INTOLERANT		((u16) BIT(14))
#define HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT	((u16) BIT(15))


static int hostapd_config_ht_capab(struct hostapd_config *conf,
				   const char *capab)
{
    ......
	if (os_strstr(capab, "[HT40+]")) {
		conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
		conf->secondary_channel = 1;
	}

在这里插入图片描述
在这里插入图片描述

硬件能力部分

nl80211_get_hw_feature_data()获取wiphy能力赋值struct hostapd_hw_modes

硬件能力注册到系统流程
芯片驱动注册wiphy和操纵设备的回到函数struct wiphy=wiphy_new(&cfg80211_ops, sizeof(wiphy_priv(wiphy)))
赋值wiphy->bands硬件信息;如struct ieee80211_supported_band
wiphy_register()注册网络设备

kernel无线部分访问设备
应用层通过发送NL80211_CMD_GET_WIPHY给内核获取设备能力信息
nl80211_get_wiphy() //net/wireless/nl80211.c

//结构体
struct wiphy {
    struct ieee80211_supported_band {
        struct ieee80211_channel
    }
}

应用层通过nl80211获取硬件能力
NL80211_ATTR_WIPHY_BANDS对应sband = rdev->wiphy.bands[band]
NL80211_BAND_ATTR_FREQS对应sband->channels[i]

//注册网卡时获取
hostapd_get_hw_feature_data	--->hapd->driver->get_hw_feature_data	  
nl80211_get_hw_feature_data(NL80211_CMD_GET_WIPHY)	 发送消息给内核 
nl80211_get_wiphy() /kernel /net/wireless/nl80211.c
-->nl80211_send_wiphy(NL80211_CMD_NEW_WIPHY)--->//cfg80211模块 /net/wireless/core.c 关键函数
   -->sband = rdev->wiphy.bands[band];//cfg802111.h **struct cfg80211_registered_device *rdev->struct wiphy *wiphy(硬件功能描述结构体,cfg80211.h)->struct ieee80211_supported_band**
   -->nl80211_send_band_rateinfo()//将获取到的信息存储到nla,向上层传输
       ht_cap.mcs
	   ht_cap.cap
	   ht_cap.ampdu_factor
	   ht_cap.ampdu_density
   -->NL80211_BAND_ATTR_FREQS,chan = &sband->channels[i];---->struct ieee80211_supported_band->struct ieee80211_channel

参数举例

HE cap
在这里插入图片描述

6字节 MAC information:mode->he_capab[opmode].mac_cap //opmode=IEEE80211_MODE_AP
1字节 PHY information:mode->he_capab[opmode].phy_cap
4字节 MCS set:mode->he_capab[opmode].mcs

应用层发送消息

NL80211_CMD_GET_WIPHY
1.wiphy_info_handler()
获取struct wpa_driver_capa *capa = info->capa
根据不同的NL80211_ATTR_*配置capa->flags

2.phy_info_handler()
phy_info_iftype()-->phy_info_iftype_copy()  //拷贝he内容,根据iftype类型(sta\ap\mesh\ibss)获取
       tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]
	   tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]
	   tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]
	   tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]

kernel返回内容

nl80211_send_iftype_data()-->
struct ieee80211_supported_band {
    struct ieee80211_sband_iftype_data {
        struct he_cap
    }
}
he_cap->he_cap_elem.mac_cap_info
he_cap->he_cap_elem.phy_cap_info
he_cap->he_mcs_nss_sup
he_cap->ppe_thres

芯片驱动配置硬件能力

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值