运行

mapd -I /etc/map/mapd_cfg -O /etc/mapd_strng.conf

calltree

main()
    mapd_init()
		// DB NAME=./client_db.txt
		// Man Daemon XX version: v2.0.0
    	mapd_global_ctrl_iface_init()
    		mapd_global_ctrl_iface_open_sock()
    			socket(PF_UNIX, SOCK_DGRAM, 0);	// /tmp/mapd_ctrl ?
				addr.sun_path[0] = '\0';	// 学习一下 
				// https://blog.csdn.net/u013920085/article/details/51028541
				bind(priv->sock, (struct sockaddr *) &addr, sizeof(addr));
    			eloop_register_read_sock(mapd_global_ctrl_iface_receive);
    				mapd_global_ctrl_iface_receive()
    					mapd_global_ctrl_iface_process()
                        	// I got a commapd dump_topology_v1 1 /tmp/dump.txt
                        	// I got a commapd GET role
		// Succesfully connected to WAPPD
		wapp_open_connection("/tmp/wapp_ctrl", global);
			wapp_usr_intf_ctrl_open("mapd", ctrl_path);	// libwapp_usr_intf_client.a
				socket(PF_UNIX, SOCK_DGRAM, 0);	// Unix doman socket(数据报)
				bind(ctrl->s, (struct sockaddr *) &ctrl->local, path_len);
			eloop_register_read_sock(mapd_receive_from_wapp);
				mapd_receive_from_wapp()
					mapd_recv_pending_from_wapp()
						wlanif_process_wapp_events()	// Asyncronous events from WAPP daemon
							wapp_usr_intf_parse_event()
								case WAPP_ALL_ASSOC_STA_LINK_METRICS:
								case WAPP_OPERATING_CHANNEL_INFO:
									wlanif_handle_op_chan_info()
										mapd_radio_init()
								case WAPP_WIRELESS_INF_INFO:
									wlanif_handle_wireless_inf_info()
								case WAPP_SCAN_CAPAB:
									topo_srv_parse_wapp_scan_capab()
								case WAPP_CAC_CAPAB:
									topo_srv_parse_wapp_cac_capab()
										// MY device CAC Mode = 0
								case WAPP_MAP_BH_CONFIG:
									wlanif_handle_bh_config_event()
										****bh_state = BH_STATE_WIFI_BOOTUP******
		_1905_open_connection()
			map_1905_Init()
				_1905_Init()	// lib1905_interface.a
			eloop_register_read_sock(mapd_receive_from_1905);
				mapd_recv_pending_from_1905()
					map_1905_Receive()
					_1905_interface_parse_event()
						case _1905_SET_WIRELESS_SETTING_EVENT:
						case _1905_RECV_CH_SELECTION_RSP_EVENT:
						case _1905_RECV_TOPOLOGY_RSP_EVENT:
							topo_srv_handle_topology_event(global, buf);
								// recv TOPOLOGY_response from 00:0c:43:26:60:00
						...
		// Succesfully connected to 1905
		wapp_get_all_wifi_interface_status()
			wlanif_issue_wapp_command()
		mapd_init_own_1905_dev()
		mapd_init_steer_params()	// Steer Params
		mapd_client_db_read()	// Read DB file  ./client_db.txt
		topo_srv_init_own_info()
			create_1905_device()
				// one 1905 device created
			topo_srv_init_own_1905_info
		mapd_read_config_file()
			// device role is 2