Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android wpa_supplcant 之配置文件

Android wpa_supplcant 之配置文件

編輯:關於Android編程

1 配置文件
conf文件作為wpa_supplicant的配置文件,一般叫做 wpa_supplicant.conf 。其中存儲著wpa_supplicant的運行參數和以保存的網絡列表。
conf文件的路徑,通過啟動wpa_supplicant時的 –c 參數傳入,初始化過程中賦值到wpa_s->confname,然後將數據讀入wpa_s->conf中。

wpa_supplicant的所有參數都定義在struct wpa_config中

struct wpa_config {
    //config文件中,存儲所有network節點的鏈表
    struct wpa_ssid *ssid;
    //按照priority排列的network節點
    struct wpa_ssid **pssid;
    //*pssid的長度
    int num_prio;

    /**
     * cred - Head of the credential list
     *
     * This is the head for the list of all the configured credentials.
     */
    struct wpa_cred *cred;

    //EAP版本,WPAS支持到2
    int eapol_version;

    //1---wpas負責掃描和選擇網絡
    //0、2---驅動負責掃描和連接
    int ap_scan;

    //bgscan - Background scan and roaming parameters or %NULL if none
    char *bgscan;

    //disable_scan_offload - Disable automatic offloading of scan requests
    //驅動可以自行sche_scan,設置為1,disable驅動的功能
    int disable_scan_offload;

    // ctrl_interface - Parameters for the control interface
    //結構名稱例如wlan0
    char *ctrl_interface;

    //ctrl_interface_group - Control interface group (DEPRECATED)
    char *ctrl_interface_group;

    //fast_reauth - EAP fast re-authentication (session resumption)
    //默認是1 disable,設置為0 disable該功能,
    int fast_reauth;

    //opensc_engine_path - Path to the OpenSSL engine for opensc    
    char *opensc_engine_path;

    //pkcs11_engine_path - Path to the OpenSSL engine for PKCS#11
    char *pkcs11_engine_path;

    //pkcs11_module_path - Path to the OpenSSL OpenSC/PKCS#11 module
    char *pkcs11_module_path;

    //pcsc_reader - PC/SC reader name prefix
    char *pcsc_reader;

    // pcsc_pin - PIN for USIM, GSM SIM, and smartcards
    char *pcsc_pin;

    //external_sim - Use external processing for SIM/USIM operations
    int external_sim;

    //driver_param - Driver interface parameters
    //如果有的話,通過struct wpa_driver_ops::set_param()執行
    char *driver_param;

    //dot11RSNAConfigPMKLifetime - Maximum lifetime of a PMK
    unsigned int dot11RSNAConfigPMKLifetime;

    // dot11RSNAConfigPMKReauthThreshold - PMK re-authentication threshold
    unsigned int dot11RSNAConfigPMKReauthThreshold;

    //dot11RSNAConfigSATimeout - Security association timeout
    unsigned int dot11RSNAConfigSATimeout;

    //update_config - Is wpa_supplicant allowed to update configuration/
    int update_config;

    //blobs - Configuration blobs
    struct wpa_config_blob *blobs;

    // uuid - Universally Unique IDentifier (UUID; see RFC 4122) for WPS
    u8 uuid[16];

    //device_name - Device Name (WPS)
    char *device_name;

    //manufacturer - Manufacturer (WPS)
    //The manufacturer of the device (up to 64 ASCII characters)
    char *manufacturer;

    // model_name - Model Name (WPS)
    //Model of the device (up to 32 ASCII characters)
    char *model_name;

    //model_number - Model Number (WPS)
    //Additional device description (up to 32 ASCII characters)
    char *model_number;

    //serial_number - Serial Number (WPS)
    //Serial number of the device (up to 32 characters)
    char *serial_number;

    //device_type - Primary Device Type (WPS)
    u8 device_type[WPS_DEV_TYPE_LEN];

    //config_methods - Config Methods(WPS)
    char *config_methods;

    //os_version - OS Version (WPS)
    //4-octet operating system version number
    u8 os_version[4];

    //country - Country code(ISO/IEC alpha2)
    char country[2];

    /**
     * wps_cred_processing - Credential processing
     *
     *   0 = process received credentials internally
     *   1 = do not process received credentials; just pass them over
     *  ctrl_iface to external program(s)
     *   2 = process received credentials internally and pass them over
     *  ctrl_iface to external program(s)
     */
    int wps_cred_processing;

#define MAX_SEC_DEVICE_TYPES 5
    /**
     * sec_device_types - Secondary Device Types (P2P)
     */
    u8 sec_device_type[MAX_SEC_DEVICE_TYPES][WPS_DEV_TYPE_LEN];
    int num_sec_device_types;

    int p2p_listen_reg_class;
    int p2p_listen_channel;
    int p2p_oper_reg_class;
    int p2p_oper_channel;
    int p2p_go_intent;
    char *p2p_ssid_postfix;
    int persistent_reconnect;
    int p2p_intra_bss;
    unsigned int num_p2p_pref_chan;
    struct p2p_channel *p2p_pref_chan;
    struct wpa_freq_range_list p2p_no_go_freq;
    int p2p_add_cli_chan;
    int p2p_ignore_shared_freq;
    int p2p_optimize_listen_chan;

    struct wpabuf *wps_vendor_ext_m1;

    //wps_vendor_ext - Vendor extension attributes in WPS
    //MAX_WPS_VENDOR_EXT = 10
    struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXT];

    // p2p_group_idle - Maximum idle time in seconds for P2P group
    //超過該時間(秒),將關閉數據
    int p2p_group_idle;

    //p2p_passphrase_len - Passphrase length (8..63) for P2P GO
    //GO產生的隨機秘鑰的長度(8~63)
    unsigned int p2p_passphrase_len;

    //bss_max_count - Maximum number of BSS entries to keep in memory
    //存儲的bss最大個數
    unsigned int bss_max_count;

    //bss_expiration_age - BSS entry age after which it can be expired
    //bss超期時間秒(bss 被remnove後的時間),
    unsigned int bss_expiration_age;

    //bss_expiration_scan_count - Expire BSS after number of scans
    //bss經過幾次掃描不到,被remove
    unsigned int bss_expiration_scan_count;

    //filter_ssids - SSID-based scan result filtering
    //0--disable, 1--enable
    int filter_ssids;

    //filter_rssi - RSSI-based scan result filtering
    //0--disable, -n--去掉scan_res中<-ndb的bss
    int filter_rssi;

    //max_num_sta - Maximum number of STAs in an AP/P2P GO
    unsigned int max_num_sta;

    // freq_list - Array of allowed scan frequencies or %NULL for all
    //允許掃描的頻率列表
    int *freq_list;

    //scan_cur_freq - Whether to scan only the current channel,只掃描當前頻率
    int scan_cur_freq;

    //changed_parameters - Bitmap of changed parameters since last update
    unsigned int changed_parameters;

    //disassoc_low_ack - Disassocicate stations with massive packet loss
    //因丟包導致關聯失敗的station個數
    int disassoc_low_ack;

    //interworking - Whether Interworking (IEEE 802.11u) is enabled
    int interworking;

    //access_network_type - Access Network Type
    //interworking=1時,該項起作用,取值0~15
    int access_network_type;

    //hessid - Homogenous ESS identifier 80211u相關
    u8 hessid[ETH_ALEN];

    //hs20 - Hotspot 2.0
    int hs20;

    //pbc_in_m1 - AP mode WPS probing workaround for PBC with Windows 7
    int pbc_in_m1;

    //autoscan - Automatic scan parameters or %NULL if none,文檔中有介紹
    //:
    char *autoscan;

    //NFC相關
    int wps_nfc_pw_from_config;
    int wps_nfc_dev_pw_id;
    struct wpabuf *wps_nfc_dh_pubkey;
    struct wpabuf *wps_nfc_dh_privkey;
    struct wpabuf *wps_nfc_dev_pw;

    /**
     * ext_password_backend - External password backend or %NULL if none
     *
     * format: [:]
     */
    char *ext_password_backend;

    /*
     * p2p_go_max_inactivity - Timeout in seconds to detect STA inactivity
     *
     * This timeout value is used in P2P GO mode to clean up
     * inactive stations.
     * By default: 300 seconds.
     */
    int p2p_go_max_inactivity;

    struct hostapd_wmm_ac_params wmm_ac_params[4];

    // auto_interworking - Whether to use network selection automatically
    int auto_interworking;

    //p2p_go_ht40 - Default mode for HT40 enable when operating as GO.
    int p2p_go_ht40;

    // p2p_go_vht - Default mode for VHT enable when operating as GO
    int p2p_go_vht;

    int p2p_disabled;

    //p2p_no_group_iface - Whether group interfaces can be used
    int p2p_no_group_iface;

    //okc - Whether to enable opportunistic key caching by default
    int okc;

    //pmf - Whether to enable/require PMF by default。默認值為0
    //ieee80211w=1 or ieee80211w=2 parameter. pmf=1/2 can be used to change
    enum mfp_options pmf;

    //sae_groups - Preference list of enabled groups for SAE
    int *sae_groups;

    // dtim_period - Default DTIM period in Beacon intervals
    int dtim_period;

    // beacon_int - Default Beacon interval in TU
    int beacon_int;

    //ap_vendor_elements: Vendor specific elements for Beacon/ProbeResp
    struct wpabuf *ap_vendor_elements;

    //ignore_old_scan_res - Ignore scan results older than request
    int ignore_old_scan_res;

    //sched_scan_interval -  schedule scan interval
    unsigned int sched_scan_interval;

    //tdls_external_control - External control for TDLS setup requests
    int tdls_external_control;

    u8 ip_addr_go[4];
    u8 ip_addr_mask[4];
    u8 ip_addr_start[4];
    u8 ip_addr_end[4];

    //osu_dir - OSU provider information directory
    char *osu_dir;

    //wowlan_triggers - Wake-on-WLAN triggers
    char *wowlan_triggers;

    //p2p_search_delay - Extra delay between concurrent search iterations
    unsigned int p2p_search_delay;

    //key_mgmt_offload - Use key managment offload
    int key_mgmt_offload;
};
network節點

conf文件中每一個network節點都是一個保存的網絡,在android手機掃描結果界面中可以直接點擊連接該網絡,形式如下
network={
ssid=”ASUS”
psk=”**
key_mgmt=WPA-PSK
priority=6
}
上述節點中存儲了網絡的名稱(ssid),密碼(psk),加密方式(WPA_PSK),優先級(priority)
WIFI網絡有多種加密方式,每種加密方式(wpa_psk,wep,open,wapi,各種eap等)的節點書寫方式都不同,具體可以參考源代碼中wpa_supplicant.conf文件

每一個network節點解析後會生成一個struct wpa_ssid,結構體中頂一個多種字段,以滿足不同加密方式的需求。

//wpa_supplicant.conf中的網絡節點都會生成一個wps_ssid的結構體
struct wpa_ssid{
    //鏈表指針,鏈表頭存放在struct wpa_config->ssid
    struct wpa_ssid *next;

    //按照priority組成的鏈表,鏈表頭在struct wpa_config->pssid
    struct wpa_ssid *pnext;

    //每個網絡節點都會有一個id,當通過control interface創建時,通過config文件讀取時,都會賦予一個id
    int id;

    //每個network初始的priority的值是0,當select該bss時,priority會升高
    //收到掃描結果時,按照priority由高到低匹配,
    //當priority相同時,會按照安全協議,信號強度匹配
    //注意:AP采用scan_ssid=1 和 ap_scan=2 時,按照config文件中的順序(wpa_config->ssid)匹配
    int priority;

    //網絡標識,可以包含任何字符,
    u8 *ssid;
    size_t ssid_len;

    //如果有該值,是該bssid的AP關聯時會用到
    //如果disabled == 2,該值為GO的mac
    u8 bssid[ETH_ALEN];
    //對於該network,bssid是否被配置
    int bssid_set;

    //GO的mac地址
    u8 go_p2p_dev_addr[ETH_ALEN];

    //psk - WPA pre-shared key (256 bits)通過passphrase項的sha生成
    u8 psk[32];
    //Whether PSK field is configured
    int psk_set;
    //如果包含該項,那麼連接時采用ssid和passphrase,長度為8~63字符
    char *passphrase;

    //存儲PSK的文件路徑
    char *ext_psk;

    //pairwise_cipher - Bitfield of allowed pairwise ciphers, WPA_CIPHER_*
    int pairwise_cipher;

    //group_cipher - Bitfield of allowed group ciphers, WPA_CIPHER_*
    int group_cipher;

    //Bitfield of allowed key management protocols WPA_KEY_MGMT_*
    int key_mgmt;

    //背景掃描的間隔(秒),0----disable, -1----使用驅動中默認值
    int bg_scan_period;

    //Bitfield of allowed protocols, WPA_PROTO_*
    int proto;

    //Bitfield of allowed authentication algorithms(算法)WPA_AUTH_ALG_*
    int auth_alg;

    //放BSS設置為隱藏時,使用該項值寫入到Probe Requests,
    //當某些驅動不支持掃描隱藏網絡時,設置ap_mode=2
    int scan_ssid;


    **EAP相關
    //Bit field of IEEE 802.1X/EAPOL options (EAPOL_FLAG_*)
    int eapol_flags;
    //eap - EAP peer configuration for this network
    struct eap_peer_config eap;

    **WEP相關
    //wep密碼 NUM_WEP_KEYS=4 MAX_WEP_KEY_LEN=16
    u8 wep_key[NUM_WEP_KEYS][MAX_WEP_KEY_LEN];
    size_t wep_key_len[NUM_WEP_KEYS];

    //wep_tx_keyidx - Default key index for TX frames using WEP
    int wep_tx_keyidx;

    //什麼是proactive key caching?
    //1---使能, 0--禁用
    //與 PMK, PMKSA, RSN有關
    int proactive_key_caching;

    /**
     * mixed_cell - Whether mixed cells are allowed
     *
     * This option can be used to configure whether so called mixed cells,
     * i.e., networks that use both plaintext and encryption in the same
     * SSID, are allowed. This is disabled (0) by default. Enable by
     * setting this to 1.
     */
    int mixed_cell;

#ifdef IEEE8021X_EAPOL
    //leap - Number of EAP methods using LEAP
    //LEAP是一種EAP認證,android wifi界面不支持
    int leap;
    //non_leap - Number of EAP methods not using LEAP
    int non_leap;

    //eap_workaround - EAP workarounds enabled
    //跳過關聯失敗的eap server
    unsigned int eap_workaround;
#endif /* IEEE8021X_EAPOL */

    //WPAS模式
    enum wpas_mode {
        WPAS_MODE_INFRA = 0,                //征程station模式
        WPAS_MODE_IBSS = 1,                 //IBSS網絡,只用station不需要AP組成
        WPAS_MODE_AP = 2,                   //AP, softap
        WPAS_MODE_P2P_GO = 3,               //P2P GO
        WPAS_MODE_P2P_GROUP_FORMATION = 4,  //不能通過config文件設置
    } mode;

    //0---該network可用
    //1---該network不可用,可通過 ctrl_iface啟用
    //2---該network包含P2P參數
    int disabled;

    //WPS網絡連接之前,設置該值disable,連接完,取消,
    int disabled_for_connect;

    /**
     * peerkey -  Whether PeerKey handshake for direct links is allowed
     *
     * This is only used when both RSN/WPA2 and IEEE 802.11e (QoS) are
     * enabled.
     *
     * 0 = disabled (default)
     * 1 = enabled
     */
    int peerkey;


    //id_str - Network identifier string for external scripts
    char *id_str;

#ifdef CONFIG_IEEE80211W
    //ieee80211w - Whether management frame protection is enabled
    enum mfp_options ieee80211w;
    {
        NO_MGMT_FRAME_PROTECTION = 0,
        MGMT_FRAME_PROTECTION_OPTIONAL = 1,
        MGMT_FRAME_PROTECTION_REQUIRED = 2,
    };
#endif /* CONFIG_IEEE80211W */

    int frequency;
    int ht40;
    int vht;

    //wpa_ptk_rekey - Maximum lifetime for PTK in seconds
    //PSK生存時間
    int wpa_ptk_rekey;

    //該network的掃描頻率,如果設置了該值,對於該network,只掃描該頻率
    int *scan_freq;

    //bgscan 背景掃描設置,參數格式:
    //:
    char *bgscan;

    //wpas 在 AP模式時,設置隱藏SSID
    //0--disable, 1--beacon中ssid長度為0,不對probe request做回應, 2 beacon中ssid內容為‘0’,不對probe request做回應
    int ignore_broadcast_ssid;

    //如果設置了該項,當接收到掃描結果時,如果頻率列表不配皮,不在select該bss
    int *freq_list;

    //p2p_client_list - List of P2P Clients in a persistent group (GO)
    //GC的mac地址列表
    u8 *p2p_client_list;
    //num_p2p_clients - Number of entries in p2p_client_list
    size_t num_p2p_clients;

#define P2P_MAX_STORED_CLIENTS 100

    //struct psk_list_entry) 鏈表頭
    struct dl_list psk_list;
    struct psk_list_entry {
        struct dl_list list;
        u8 addr[ETH_ALEN];
        u8 psk[32];
        u8 p2p;
    };

    //p2p_group - Network generated as a P2P group (config文件不可配置)
    int p2p_group;

    //p2p_persistent_group - Whether this is a persistent group
    int p2p_persistent_group;

    //temporary - Whether this network is temporary and not to be saved
    int temporary;

    //export_keys - Whether keys may be exported
    int export_keys;

#ifdef CONFIG_HT_OVERRIDES
    //disable_ht - Disable HT (高吞吐率模式)(IEEE 802.11n) for this network
    int disable_ht;

    //disable_ht40 - Disable HT40 for this network
    int disable_ht40;

    //disable_sgi - Disable SGI(幀間隔) (Short Guard Interval) for this network
    int disable_sgi;

    //disable_ldpc - Disable LDPC(一種編碼方式) for this network
    int disable_ldpc;

    //ht40_intolerant(不容許) - Indicate 40 MHz intolerant for this network
    int ht40_intolerant;

    //disable_max_amsdu - Disable MAX A-MSDU
    //MSDU一個報文,disable該項,amsdu為3839B,enable則為7935B,
    //-1則不做任何設置
    int disable_max_amsdu;

    //ampdu_factor - Maximum A-MPDU Length Exponen
    //Value: 0-3, see 7.3.2.56.3 in IEEE Std 802.11n-2009.
    int ampdu_factor;

    /* ampdu_density - Minimum A-MPDU Start Spacing
     * Value: 0-7, see 7.3.2.56.3 in IEEE Std 802.11n-2009.*/
    int ampdu_density;

    /* ht_mcs - Allowed HT-MCS rates, in ASCII hex: ffff0000...
     * By default (empty string): Use whatever the OS has configured.*/
    char *ht_mcs;
#endif /* CONFIG_HT_OVERRIDES */

#ifdef CONFIG_VHT_OVERRIDES
    /* disable_vht - Disable VHT (束波成型)(IEEE 802.11ac) for this network*/
    int disable_vht;

    //vht_capa - VHT capabilities to use
    unsigned int vht_capa;

    //vht_capa_mask - mask for VHT capabilities
    unsigned int vht_capa_mask;

    int vht_rx_mcs_nss_1, vht_rx_mcs_nss_2,
        vht_rx_mcs_nss_3, vht_rx_mcs_nss_4,
        vht_rx_mcs_nss_5, vht_rx_mcs_nss_6,
        vht_rx_mcs_nss_7, vht_rx_mcs_nss_8;
    int vht_tx_mcs_nss_1, vht_tx_mcs_nss_2,
        vht_tx_mcs_nss_3, vht_tx_mcs_nss_4,
        vht_tx_mcs_nss_5, vht_tx_mcs_nss_6,
        vht_tx_mcs_nss_7, vht_tx_mcs_nss_8;
#endif /* CONFIG_VHT_OVERRIDES */

    /* ap_max_inactivity - Timeout in seconds to detect STA's inactivity
     * This timeout value is used in AP mode to clean up inactive stations.
     * By default: 300 seconds. */
    int ap_max_inactivity;

    AP模式
    /* dtim_period - DTIM period in Beacon intervals
     * dtim,間隔多個beacon幀中包含tim信息,tim用於通知station AP有其暫存幀
     * By default: 2 */
    int dtim_period;

    //beacon_int - Beacon interval (default: 100 TU)
    int beacon_int;

    //auth_failures - Number of consecutive authentication failures
    unsigned int auth_failures;

    // disabled_until - Network block disabled until this time if non-zero
    struct os_reltime disabled_until;

    void *parent_cred;

    int macsec_policy;
    //HS20相關,
    int update_identifier;
    unsigned int wps_run;
}
操作方法

在conf文件中,可以定義3種節點,
wpa_ssid 對應 network ={ }節點:
wpa_cred 對應 cred = { }節點
wpa_config_blob 對應參數blob-base64-,
主要介紹wpas_ssid(network ={ })的作用,其余兩個android還沒見過
在conf文件中,是按照 項=值 的對應關系對應的,
network ={ }中的項和值得對應關系存儲在全局變量數組ssid_fields中
其余的全局設置項存儲在global_fields中

wpa_config_read讀取參數
//name----conf文件的路徑
//cfgp----之前的config數據
//有兩個全局數組比較重要, ssid_fields存放network節點的所有可設置值, global_fields存放搜有conf中全局的可設置項
struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
{   
    //buf存放conf中一行的數據,最長不能超過512
    char buf[512], *pos;
    //生成一個空的config結構體,裡面有一些參數提前設置好默認值
    struct wpa_config *config = wpa_config_alloc_empty(NULL, NULL);
    //打開文件
    FILE *f = fopen(name, "r");

    //循環獲取文件中一行
    while (wpa_config_get_line(buf, sizeof(buf), f, &line, &pos)) {
        //network={
        if (os_strcmp(pos, "network={") == 0) {
            //檢測到"network={",進一步讀取網絡節點的內容
            struct wpa_ssid *ssid = wpa_config_read_network(f, &line, id++);
                {
                    //設置網絡節點中一些參數的默認值
                    wpa_config_set_network_defaults(ssid);
                    //獲取每一行的內容,通過‘=’匹配,前面是項名稱,後是值
                    while (wpa_config_get_line(buf, sizeof(buf), f, line, &pos)) {
                        //int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value, int line)
                        //ssid中對應項的值,ssid_fields全局數組中,定義了每一項的name,獲取值方式
                        wpa_config_set(ssid, pos, pos2, *line)
                    }
                    //獲取完一個network,對內部的信息進行升級
                    //1.如果設置了passphrase和psk_set,利用sha1生成wpa psk
                     wpa_config_validate_network(ssid, *line);
                }           
            //將生成的ssid加入到conf->pssid鏈表中
            wpa_config_add_prio_network(config, ssid)
        } 
        //cred={
        else if (os_strcmp(pos, "cred={") == 0) {
            cred = wpa_config_read_cred(f, &line, cred_id++);
        }
        //blob-base64-
        else if (os_strncmp(pos, "blob-base64-", 12) == 0) {
            if (wpa_config_process_blob(config, f, &line, pos + 12)
        }
        //獲取conf中的全局參數,存儲在全局數組global_fields
        else if (wpa_config_process_global(config, pos, line) < 0) {
        }
    }
}
wpa_config_write寫入參數
int wpa_config_write(const char *name, struct wpa_config *config)
{
    FILE *f;
    //寫入全局項
    wpa_config_write_global(f, config);
    //寫入cred節點
    for (cred = config->cred; cred; cred = cred->next) {
        wpa_config_write_cred(f, cred);
    }
    //存儲network節點
    for (ssid = config->ssid; ssid; ssid = ssid->next) {
        if (ssid->key_mgmt == WPA_KEY_MGMT_WPS || ssid->temporary)
            continue; /* do not save temporary networks */
        if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt) && !ssid->psk_set && !ssid->passphrase)
            continue; /* do not save invalid network */
        wpa_config_write_network(f, ssid);
    }
    //寫入blob值
    for (blob = config->blobs; blob; blob = blob->next) {
        ret = wpa_config_write_blob(f, blob);
    }
}
wpa_config_add_network添加網絡
調用該函數後,會返回一個預先設置好id的ssid指針
struct wpa_ssid * wpa_config_add_network(struct wpa_config *config)
{
    //遍歷得到config->ssid中最大的id + 1
    //生成一個空的ssid節點,並添加到config->ssid鏈表中
    ssid->id = id;
    //更新pssid鏈表
    wpa_config_update_prio_list(config);
    return ssid;
}
wpa_config_get_network獲取一個network節點

通過id值獲取conf->ssid鏈表的中network元素

struct wpa_ssid * wpa_config_get_network(struct wpa_config *config, int id)
{   struct wpa_ssid *ssid = config->ssid;
    while (ssid) {
        if (id == ssid->id)
            break;
}
wpa_config_remove_network刪除一個network節點

通過id值刪除network

int wpa_config_remove_network(struct wpa_config *config, int id)
{
    //通過獲取config->ssid鏈表中id值匹配的ssid元素
    struct wpa_ssid *ssid = config->ssid;
    while (ssid) {
        if (id == ssid->id)
            break;
    }

    //從鏈表中刪除
    //更新pssid列表
    wpa_config_update_prio_list(config);
    //釋放空間
    wpa_config_free_ssid(ssid);
}
wpa_config_set設置network中項的值
//由外部控制 framework或者wpa_cli
int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value, int line);
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved