平台、版本

bpi、v2.0.0

运行

wapp -d3 -v2 -cra0 -crai0

calltree

main()
	process_options()	// 参数处理,默认 ra0 ? 版本是 -v 传入的,有什么作用?
	wapp_cmm_init()
    	IAPP_PID_Kill()
    	mbo_init()	// 什么是 mbo ?
    	oce_init()	// 什么是 oce ?
    	anqp_init()	// 什么是 anqp ?
    	map_init()
			map_read_config_file()	// /etc/map/1905d.cfg
    		/* 	map_controller_alid=00:0c:43:26:60:30
    			map_agent=1
    			map_root=0
    			map_agent_alid=00:0c:43:26:60:30
    			bh_type=eth
    			radio_band=24G;5G;5G
    			br_inf=br-lan
    			map_ver=2
    		*/
    		disable_dhcp_client()
    		get_map_parameters()	// MapMode
    			kvc_get()			// libkvcutil.so
    		map_bss_table_init()
    		map_reset_conf_sm()
    		// /etc/map/mapd_cfg、/etc/map/mapd_user.cfg
    		setsid()	// 需要学习一下
    		fork()
    		Initialize socket
    		wapp_socket_and_ctrl_inf_init()
    			eloop_init()	// 需要学习一下
    			wapp_ctrl_iface_init()
    				socket(PF_UNIX, SOCK_DGRAM, 0);	// UNIX域(用户数据报)套接字 
					// https://blog.csdn.net/m0_37542524/article/details/84668406
					os_strncpy(addr.sun_path, "/tmp/wapp_ctrl", sizeof(addr.sun_path));
					bind(ctrl_iface->sock, (struct sockaddr *) &addr, sizeof(addr);
                    eloop_register_read_sock(ctrl_iface->sock, wapp_ctrl_iface_receive, wapp, ctrl_iface);
                         eloop_register_sock()
                         	eloop_get_sock_table()
                         	eloop_sock_table_add_sock()
                wapp_iface_init()
                    wapp_iface_open_sock(wapp, "/tmp/wapp_server");
                         // 和 mapd、1905 通信
                         eloop_register_read_sock(cli_ctrl->sock, wapp_iface_receive, wapp, NULL);
                wapp->drv_ops = &wapp_drv_wext_ops;
                    .drv_wapp_req = driver_wext_send_wapp_req,	// 发送消息给驱动
                wapp->drv_ops->drv_inf_init(wapp, opmode, drv_mode);	// driver_wext_init()
                     socket(PF_INET, SOCK_DGRAM, 0);
                     // Initialize ralink wext interface
                     cfg->newlink_cb = driver_wext_event_rtm_newlink;
                         driver_wext_event_wireless()
                         	 case IWEVCUSTOM:
                         		 case OID_802_11_HS_ANQP_REQ:
                         			 event_anqp_req(drv, buf);
                         		 case OID_802_11_HS_ONOFF:
									 event_hs_onoff(drv, buf);
                         		 ...
                         		 case OID_WAPP_EVENT:
								 	 event_wapp_event_handle(drv, buf);
                         			 	 wapp->event_ops->event_handle(wapp, event);
                         				 .event_handle = wapp_event_handle,
                         					 case WAPP_DEV_QUERY_RSP:
												 wdev_query_rsp_handle();
                         					 case WAPP_MISC_CAP_QUERY_RSP:
												 wdev_misc_cap_query_rsp_handle();
                         							 /* misc_cap (6):
	 												 		max_num_of_cli = 64
	 												 		max_num_of_bss = 16
	 												 		num_of_bss     = 1
	 												 		max_num_of_block_cli = 128
	 												 	*/

                         					 
                     netlink_init()
                     // 和驱动进行联系,设置驱动参数等
                     eloop_register_read_sock(netlink->sock, netlink_receive, netlink, NULL);
    		wapp_get_wireless_interfaces()	// 获取无线接口
				get_map_parameters()
					if(openwrt)
                         kvc_get()
                    else
                    	"/tmp/system_command_output"
                or
                fopen("/proc/net/dev", "r");
                get_mac_addr_by_ifname()
                wapp_dev_create()
                    wapp_drv_support_version_check()
                        driver_wext_wapp_support_version()
                        	=====
							WAPP DAEMON VER:v2.0.0
							=====
                        driver_wext_get_oid()

            get_map_parameters("Enable_WPS_toggle_5GL_5GH")
            get_map_parameters("MAP_QuickChChange")
                wapp_create_arp_socket()
                    get_if_info()
                        debug("get_if_info OK");
                        debug("Clean up temporary socket");
                    bind_arp()
            // Use default configuration file /etc/wapp_ap.conf
            wapp_init_all_config()
                wapp_init_ap_config()	// /etc/wapp_ap_ra0.conf 很多参数
                    wapp_set_interworking_enable()
                    wapp_init_param_setting()
                        wapp_cmm_param_setting()
                        	hotspot_init_param()
                         		hs_param_setting()
            hotspot_onoff_all()
                hotspot_validate_security_type()
                    hotspot_onoff()
            hotspot_run()
            hotspot_onoff_all()
			fork()	// 为啥 fork 了两次?
                // Initialize IAPP
                IAPP_Task()
    				IAPP_DSIfInfoGet()
                        // iapp> own address (192.168.1.1)
                        // iapp> network Mask address (255.255.255.0)
                        ioctl()
                 mt_iapp_set_daemon_information()
                      IAPP_IOCTL_TO_WLAN()
                          IAPP_IoctlToWLAN()
wapp_ctrl_iface_receive()	// 接收来自 wappctrl 的控制
	recvfrom()	// 接收
    wapp_ctrl_iface_event_register()
    or
    wapp_ctrl_iface_cmd_process()
    hs_versiononoffgetset...
wapp_iface_receive()
    recvfrom()
  	wapp_iface_attach()
    or
    wapp_iface_detach()
    or
    wapp_iface_process()
    	map_handler()
    		case WAPP_USER_SET_CHANNEL_SETTING:
			case WAPP_USER_SET_WIRELESS_SETTING:
			...
            case WAPP_USER_MAP_CONTROLLER_FOUND:	// 发现 controller
				wapp_send_1905_msg()
                eloop_cancel_timeout(map_config_state_check,wapp,NULL);
			case WAPP_USER_SET_RADIO_TEARED_DOWN:
				map_radio_tear_down()
                check_redio_conf_status()
            case WAPP_USER_SET_RADIO_RENEW:	// renew
				wapp_reset_backhaul_config();
		or
        register_event()

wappctrl

在代码里需要手动设置调试等级,没办法通过传入参数修改。

wapp_ctrl/wapp_cli.c

int RTDebugLevel = RT_DEBUG_TRACE;
root@LEDE:~/1_code_analyse# ./wappctrl ra0 hs_version
[wapp_cli_open_connection]wapp_cli_open_connection
[wapp_ctrl_open]wapp_ctrl_open
[wapp_ctrl_open]

ctrl_path: /tmp/wapp_ctrl
[wapp_cli_request]wapp_cli_request
[wapp_cli_cmd_version]wapp_cli_cmd_version
[_wapp_ctrl_command]_wapp_ctrl_command
[wapp_ctrl_command]wapp_ctrl_command
[wapp_cli_cmd_version]
cmd = {
interface=ra0
cmd=hs_version
}
rsp = {
2.0.0
}
[wapp_ctrl_close]wapp_ctrl_close