hostapd中的一部分代码,实在看不懂了,

nana_aoe_2013 2010-09-20 11:36:51
最近做802.1x,从hostapd中开始研究的,现在有些监听的代码,看不懂了,已经看了一周多了。没有什么进展,希望各位能给些帮助。
先贴一部分代码,然后附上完整代码包
static void eapol_sm_step_run(struct eapol_state_machine *sm)
{
struct eapol_authenticator *eapol = sm->eapol;
u8 addr[ETH_ALEN];
unsigned int prev_auth_pae, prev_be_auth, prev_reauth_timer,
prev_auth_key_tx, prev_key_rx, prev_ctrl_dir;
int max_steps = 100;

os_memcpy(addr, sm->addr, ETH_ALEN);

/*
* Allow EAPOL state machines to run as long as there are state
* changes, but exit and return here through event loop if more than
* 100 steps is needed as a precaution against infinite loops inside
* eloop callback.
*/
restart:
prev_auth_pae = sm->auth_pae_state;
prev_be_auth = sm->be_auth_state;
prev_reauth_timer = sm->reauth_timer_state;
prev_auth_key_tx = sm->auth_key_tx_state;
prev_key_rx = sm->key_rx_state;
prev_ctrl_dir = sm->ctrl_dir_state;

SM_STEP_RUN(AUTH_PAE);
if (sm->initializing || eapol_sm_sta_entry_alive(eapol, addr))
SM_STEP_RUN(BE_AUTH);
if (sm->initializing || eapol_sm_sta_entry_alive(eapol, addr))
SM_STEP_RUN(REAUTH_TIMER);
if (sm->initializing || eapol_sm_sta_entry_alive(eapol, addr))
SM_STEP_RUN(AUTH_KEY_TX);
if (sm->initializing || eapol_sm_sta_entry_alive(eapol, addr))
SM_STEP_RUN(KEY_RX);
if (sm->initializing || eapol_sm_sta_entry_alive(eapol, addr))
SM_STEP_RUN(CTRL_DIR);

if (prev_auth_pae != sm->auth_pae_state ||
prev_be_auth != sm->be_auth_state ||
prev_reauth_timer != sm->reauth_timer_state ||
prev_auth_key_tx != sm->auth_key_tx_state ||
prev_key_rx != sm->key_rx_state ||
prev_ctrl_dir != sm->ctrl_dir_state) {
if (--max_steps > 0)
goto restart;
/* Re-run from eloop timeout */
eapol_auth_step(sm);
return;
}

if (eapol_sm_sta_entry_alive(eapol, addr) && sm->eap) {
if (eap_server_sm_step(sm->eap)) {
if (--max_steps > 0)
goto restart;
/* Re-run from eloop timeout */
eapol_auth_step(sm);
return;
}

/* TODO: find a better location for this */
if (sm->eap_if->aaaEapResp) {
sm->eap_if->aaaEapResp = FALSE;
if (sm->eap_if->aaaEapRespData == NULL) {
wpa_printf(MSG_DEBUG, "EAPOL: aaaEapResp set, "
"but no aaaEapRespData available");
return;
}
sm->eapol->cb.aaa_send(
sm->hapd, sm->sta,
wpabuf_head(sm->eap_if->aaaEapRespData),
wpabuf_len(sm->eap_if->aaaEapRespData));
}
}

if (eapol_sm_sta_entry_alive(eapol, addr))
wpa_auth_sm_notify(sm->sta->wpa_sm);
}

这似乎没有办法上传代码包,
把代码的地址贴上吧。
http://hostap.epitest.fi/releases/hostapd-0.6.10.tar.gz
...全文
971 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
nana_aoe_2013 2010-09-21
  • 打赏
  • 举报
回复
我在补充一下问题 (详细化)
一些数据结构有问题,
就是eapol_state_machine及其他状态机
当对数据处理后,将结果记录在eapol_state_machine
当收到eapol_start报文时, 做 eapol_sm -> eapol_Start = TURE 处理
当收到RADIUS返回的认证成功报文时 做 sm->eap_if->aaaSuccess = TRUE; 处理
当收到RADUIS返回的认证失败报文时 做 sm->eap_if->aaaFail = TRUE; 处理
当收到RADUIS返回的挑战字时 做 sm->eap_if->aaaEapReq = TRUE; 处理

此时根据发生情况,将eapol_state_machine设置成功,
然后调用eapol_auth_step(sm);来监听eapol_state_machine的状态改变

现在做到eapol_auth_step() 做不下去了
下面是我的理解
eapol_auth_step(sm)
call eapol_sm_step_cb()
call eapol_sm_step_run(struct eapol_state_machine *sm)
看到这个函数直接傻眼了,和我想象中的对eapol_sm状态机各状态监听并处理完全不一样,我想的是通过对布尔变量的判断方法监听,也就是通过while(状态)的方法监听,下面是处理方法。但是这里又出现了PAE状态机,并且是怎么调用的发包函数,也看不到了,

希望能帮助一下。
wwwunix 2010-09-20
  • 打赏
  • 举报
回复
从注释看是在这里运行EAPOL状态机,建议你先了解一下EAPOL状态机。

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧