高通QSDK wpa_supplicant启动流程

  1. qca/feeds/qca/net/qca-hostap/files/qca-wpa-supplicant.init

    START=13
    
    boot_supplicant() {
    	if [ -e "/var/run/wpa_supplicant-global.pid" ]
    	then
    		kill $(cat /var/run/wpa_supplicant-global.pid) &> /dev/null
    		rm /var/run/wpa_supplicant-global.pid &> /dev/null
    	fi
    	# 最重要的是该条命令,创建wpa全局
    	wpa_supplicant -g /var/run/wpa_supplicantglobal -B -P /var/run/wpa_supplicant-global.pid
    }
    
    boot() {
    	boot_supplicant &
    }
    
  2. qca/feeds/qca/net/qca-wifi/files/qcawificfg80211.sh

    enable_vifs_qcawificfg80211() {
    
    		wds|sta)
    			if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
    			   #wpa_supplicant_setup_vif 函数在qca/feeds/qca/net/qca-hostap/files/wpa_supplicant.sh中
    				wpa_supplicant_setup_vif "$vif" nl80211 || {
    					echo "start_qcawifi($device): Failed to set up wpa_supplicant for interface $ifname" >&2
    					ifconfig "$ifname" down
    					iw "$ifname" del
    					return
    				}
    			fi
    }
    
  3. qca/feeds/qca/net/qca-hostap/files/wpa_supplicant.sh

    • 生成配置文件

      cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
      ctrl_interface=$ctrl_interface
      $wps_config_methods
      pmf=$pmf
      $wps_cred
      $update_config
      $uuid_config
      wps_cross_band_overlap=$wps_cross_band_overlap
      $sae_groups
      $dot11RSNAConfigPMKLifetime
      $pwe
      wps_cred_add_sae=$wps_cred_add_sae
      $dpp_map
      $dpp_1905_connector
      $sta_mld_addr
      $mlo_links
      $pref_assoc_lk
      $allow_non_ml_assoc
      network={
      	$modestr
      	scan_ssid=1
      	ssid="$ssid"
      	$bssid
      	$preferred_ap_mld_addr
      	key_mgmt=$key_mgmt
      	$proto
      	$freq
      	$ieee80211w
      	$beacon_prot
      	$passphrase
      	$sae_pwd
      	$sae_password_id
      	$pairwise
      	$group
      	$eap_type
      	$ca_cert
      	$client_cert
      	$priv_key
      	$priv_key_pwd
      	$phase2
      	$identity
      	$password
      	$wep_key0
      	$wep_key1
      	$wep_key2
      	$wep_key3
      	$wep_tx_keyidx
      	$wep_auth_alg
      	$owe_only
      	$group_mgmt
      	$phase1
      	$owe_group
      	$dpp_connector
      	$dpp_csign
      	$dpp_pp_key
      	$dpp_netaccesskey
      	multi_ap_backhaul_sta=$multi_ap_backhaul_sta
      	multi_ap_profile=$map
      	$dpp_pfs
      }
      EOF
      
    • 创建接口

      wpa_cli -g /var/run/wpa_supplicantglobal interface_add  $ifname /var/run/wpa_supplicant-$ifname.conf $driver /var/run/wpa_supplicant-$ifname "" $bridge