to7str

   ::  ::  :: 联系 ::  :: 管理

.

adb shell tcpdump -i wlan0 -p -s 0 -w /sdcard/trout3.pcap

【#1】-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
echo 8 > /proc/sys/kernel/printk
adb pull /system/etc/wifi/2351_wifi_configure.ini .
adb push \\shexsrv\To_Internal\jinglong.chen\ittiam.ko /system/lib/modules
adb push \\shexsrv\To_Internal\jinglong.chen\2351_wifi_configure.ini  /productinfo/
insmod /system/lib/modules/ittiam.ko
ifconfig wlan0 up
iwnpi wlan0 start
iwnpi wlan0 set_channel 1
iwnpi wlan0 set_rate 54
iwnpi wlan0 tx_start
iwnpi wlan0 get_reg phy0 0x70 2
iwnpi wlan0 set_channel 1
iwnpi wlan0 tx_start
rmmod ittiam.ko
npi_start_cmd-->itm_wlan_mac_open_cmd
eng_vdiag_thread-->eng_diag-->eng_diag_parse-->is_ap_at_cmd_need_to_handle(解析出type)
eng_vdiag_thread-->eng_diag-->eng_diag_user_handle-->eng_diag_apcmd_hdlr-->eng_linuxcmd_hdlr-->eng_linuxcmd[cmd]-->eng_linuxcmd_wifieutmode-->eng_atdiag_euthdlr(通过eut_cmds[]解析出cmd)-->wifi_eutops[]                                                      


【#2】-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
packages/apps/Settings/src/com/android/settings/wifi
frameworks/base/wifi/java/android/net/wifi
frameworks/base/services/java/com/android/server
jni代码 android_net_wifi_Wifi.cpp wifi_itm.c
wpa_supplicant下行代码:driver_nl80211.c  driver_cmd_nl80211.c 
kernel wifi公共代码:nl80211.c  net/wireless/core.c itm_cfg80211.c

out/target/product/sp8830ec/obj/EXECUTABLES/wpa_supplicant_intermediates/

insmod /system/lib/modules/ittiam.ko
wpa_supplicant -Dnl80211 -dd  -iwlan0  -c/data/misc/wifi/wpa_supplicant.conf  -C/data/misc/wifi/wpa_supplicant &
wpa_cli -p/data/misc/wifi/wpa_supplicant -iwlan0
scan_results
set_network 0 ssid "1102"
set_network 0 key_mgmt NONE
enable_network 1

logcat -s WifiHW
logcat -s wpa_supplicant
wpa_printf(MSG_ERROR, "%s(), line:%d\n", __FUNCTION__,__LINE__);
int wpa_debug_level = MSG_INFO; //MSG_DEBUG

ADD_NETWORK
SET_NETWORK 3 ssid "testap-2"
SET_NETWORK 3 key_mgmt WPA-PSK
SET_NETWORK 3 psk "fgfffffffgffff"
SET_NETWORK 3 priority 0
ENABLE_NETWORK 3

【c/s建立链接】
main-->wpa_supplicant_add_iface-->wpa_supplicant_init_iface-->wpa_supplicant_ctrl_iface_init
wpa_supplicant_ctrl_iface_init-->socket(PF_UNIX, SOCK_DGRAM, 0);
                              -->fname = wpa_supplicant_ctrl_iface_path(wpa_s);//
                              -->bind
                              -->eloop_register_read_sock(priv->sock, wpa_supplicant_ctrl_iface_receive, wpa_s, priv);-->wpa_supplicant_ctrl_iface_process//!!!!!!控制接口
wifi_connect_on_socket_path-->wpa_ctrl_open-->bind/connect

【eloop】
eloop_register_sock
eloop_run-->eloop_sock_table_dispatch
wpa_supplicant_init_iface-->wpa_supplicant_init_eapol-->eapol_sm_init-->eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
wpa_supplicant_init-->eloop_init(global)

【接口绑定】
wpa_drivers
wpa_supplicant_add_iface-->wpa_supplicant_init_iface-->wpa_supplicant_set_driver-->select_driver-->wpa_drivers[i].global_init();

【netlink机制】
(1)kernel部分
genl_register_family_with_ops(&nl80211_fam, nl80211_ops, ARRAY_SIZE(nl80211_ops));

(2)wpa部分
wpa_driver_nl80211_ops.nl80211_global_init-->netlink_init-->socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
                                                         -->bind
                                                         -->eloop_register_read_sock(netlink->sock, netlink_receive, netlink,  NULL);-->netlink_receive-->wpa_driver_nl80211_event_rtm_newlink
                                                         
【scan过程】
(1)app部分
drv对app提供的接口定义在driver_i.h
wpa_supplicant_req_scan-->wpa_supplicant_scan-->wpa_supplicant_trigger_scan-->wpa_drv_scan-->wpa_driver_nl80211_ops.scan2 = wpa_driver_nl80211_scan-->nl80211_cmd(drv, msg, 0, NL80211_CMD_TRIGGER_SCAN);

(2)kernel部分
nl80211_ops.nl80211_trigger_scan-->rdev->ops->scan(&rdev->wiphy, dev, request);-->itm_cfg80211_ops.itm_wlan_cfg80211_scan
                                -->nl80211_send_scan_start

【open式认证】
_wpa_supplicant_event_scan_results-->wpa_supplicant_connect-->wpa_supplicant_associate-->wpa_driver_nl80211_connect

wpa_driver_nl80211_event_receive-->process_global_event-->do_process_drv_event-->mlme_event_connect-->wpa_supplicant_event-->wpa_supplicant_event_assoc
                        
【wpa-psk认证】
eapol_supp_sm.c
preauth.c

.set_operstate = wpa_driver_nl80211_set_operstate,
.set_supp_port = wpa_driver_nl80211_set_supp_port,

wpa_supplicant_ctrl_iface_add_network
wpa_supplicant_ctrl_iface_enable_network-->wpa_supplicant_enable_network-->wpa_supplicant_req_scan

process_global_event-->do_process_drv_event-->send_scan_event

send_scan_event-->wpa_supplicant_event-->wpa_supplicant_event_scan_results-->_wpa_supplicant_event_scan_results
                                                                          -->wpa_supplicant_rsn_preauth_scan_results
                                                                          -->wpa_supplicant_pick_network
                                                                          -->wpa_supplicant_connect-->wpa_supplicant_associate-->wpa_drv_associate-->wpa_driver_nl80211_associate-->wpa_driver_nl80211_connect
                                                                                                                              -->wpa_supplicant_initiate_eapol
wpa_driver_nl80211_associate(函数中!WPA_DRIVER_FLAGS_SME(wpa_driver_nl80211_capa获得),关联认证不分开,程序走到 wpa_driver_nl80211_connect,)    
nl80211_global_init-->wpa_driver_nl80211_init_nl_global-->wpa_driver_nl80211_event_receive
nl_cb_set(global->nl_cb, NL_CB_VALID, NL_CB_CUSTOM,process_global_event, global);                                                                                                                            
wpa_driver_nl80211_event_receive->process_global_event-->do_process_drv_event-->mlme_event_connect-->wpa_supplicant_event-->wpa_supplicant_event_assoc
l2_packet_receive-->wpa_supplicant_rx_eapol-->wpa_sm_rx_eapol
wpa_eapol_key_send-->wpa_sm_ether_send-->supp_ether_send-->l2_packet_send
wpa_supplicant_process_1_of_4
wpa_supplicant_send_2_of_4
                                                                                                                        
nl_send_auto_complete                                                                                                                                                                                                                                                        
wpa_driver_nl80211_set_mode-->nl80211_mgmt_subscribe_non_ap-->nl80211_register_action_frame
                                                                                                                            



src/rsn_supp/preauth.c
src/rsn_supp/wpa.c
src/rsn_supp/peerkey.c
src/commmon/wpa_common.c
wpa_supplicant/scan.c
wpa_supplicant/wpa_supplicant.c #
wpa_supplicant/ctrl_iface.c   #
wap_supplicant/events.c
wap_supplicant/scan.c
wap_supplicant/sme.c

src/l2_packet/l2_packet_linux.c
src/drivers/driver_nl80211.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/sme.c
                                        
通过 SIOCGIFHWADDR 获得 mac addr (记住在这里获得mac地址)
netlink_send_oper_ifla
/sys/class/net/wlan0/operstate

【driver】
printk("%s() \n",  __func__);
drivers/net/wireless/ittiam/itm_cfg80211.c
drivers/net/wireless/ittiam/itm_main.c
drivers/net/wireless/ittiam/itm_sipc.c
net/wireless/core.c
net/wireless/nl80211.c

nl80211_connect-->itm_wlan_cfg80211_connect
genlmsg_multicast_netns

【802.1x相关】
eapol_supp_sm.c
wpa_supplicant_init_eapol-->eapol_sm_init

#define SM_STATE(machine, state) static void sm_ ## machine ## _ ## state ## _Enter(STATE_MACHINE_DATA *sm, int global)
#define SM_ENTER(machine, state) sm_ ## machine ## _ ## state ## _Enter(sm, 0)
#define SM_STEP(machine)  static void sm_ ## machine ## _Step(STATE_MACHINE_DATA *sm)
#define SM_STEP_RUN(machine) sm_ ## machine ## _Step(sm)

【反馈扫描结果】
(1)kernel  
itm_cfg80211_report_scan_done-->cfg80211_inform_bss_frame-->cfg80211_bss_update-->(list_add_tail(&res->list, &dev->bss_list);) 
                             -->cfg80211_scan_done-->nl80211_send_scan_done(NL80211_CMD_NEW_SCAN_RESULTS) 
(2)wpa_supplicant 
do_process_drv_event-->send_scan_event-->wpa_supplicant_event(EVENT_SCAN_RESULTS)-->wpa_supplicant_event_scan_results-->_wpa_supplicant_event_scan_results-->wpa_supplicant_get_scan_results-->wpa_driver_nl80211_get_scan_results-->nl80211_get_scan_results-->nl80211_cmd(NL80211_CMD_GET_SCAN);send_and_recv_msgs(drv, msg, bss_info_handler, &arg); 
(3)kernel 
NL80211_CMD_GET_SCAN.nl80211_dump_scan-->list_for_each_entry(scan, &rdev->bss_list, list)-->nl80211_send_bss 
(4)wpa_supplicant 
bss_info_handler 



wpa_supplicant_ctrl_iface_scan_results

【定时扫描】
scan_interval SCAN_INTERVAL
_wpa_supplicant_event_scan_results --> {int timeout_sec = wpa_s->scan_interval;}
-------------------P2P kernel--------------------------------
nl80211_ops.NL80211_CMD_REMAIN_ON_CHANNEL-->nl80211_remain_on_channel
nl80211_tx_mgmt(NL80211_CMD_FRAME)-->cfg80211_mlme_mgmt_tx-->(rdev->ops->mgmt_tx)
------------------------------------P2P wpa_supplicant----------------------------------
p2p_find()-->(p2p->cfg->p2p_scan)==wpas_p2p_scan()-->p2p_scan_ie
p2p_listen
                                                  
p2p_ctrl_listen-->wpas_p2p_listen-->p2p_listen-->wpas_start_listen-->wpa_drv_remain_on_channel-->wpa_driver_nl80211_remain_on_channel
nl80211_send_frame-->nl80211_send_frame_cmd(NL80211_CMD_FRAME)


【管理帧处理】
wpa_supplicant_event(EVENT_RX_MGMT)-->wpas_p2p_rx_action-->p2p_process_presence_resp


【p2p功能的支持】
wiphy_info_handler-->(capa->flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;) 

【设置模式】
wpa_supplicant
wpa_driver_nl80211_set_mode-->nl80211_set_mode(NL80211_CMD_SET_INTERFACE)
kernel
NL80211_CMD_SET_INTERFACE.nl80211_set_interface-->cfg80211_change_iface-->(rdev->ops->change_virtual_intf).itm_wlan_cfg80211_change_iface-->itm_wlan_change_mode

【p2p启动】
wpa_supplicant -iwlan0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf  -puse_p2p_group_interface=1 -C/data/misc/wifi/wpa_supplicant &
wpa_cli -p/data/misc/wifi/wpa_supplicant -iwlan0

wpa_printf(MSG_ERROR, "%s(), line:%d\n", __FUNCTION__,__LINE__);
wpa_printf(MSG_ERROR, "%s() \n", __FUNCTION__);

【p2p_find】
p2p_find-->wpas_p2p_scan-->wpa_driver_nl80211_scan

do_process_drv_event(NL80211_CMD_NEW_SCAN_RESULTS)-->send_scan_event-->wpa_supplicant_event(EVENT_SCAN_RESULTS)-->wpa_supplicant_event_scan_results-->_wpa_supplicant_event_scan_results-->wpas_p2p_scan_res_handler-->p2p_scan_res_handler-->p2p_add_device

p2p_add_device-->p2p_parse_ies-->p2p_parse_wps_ie



wpa_supplicant_event(EVENT_P2P_DEV_FOUND)
p2p_connect f6:05:35:a9:3f:ff pbc auth go_intent=7

 

 

 

 

 

 

 

posted on 2013-06-21 05:38  to7str  阅读(1482)  评论(17编辑  收藏  举报