II. Key functions of wpa_supplicant Initialization

Source: Internet
Author: User
  • Struct wpa_global * wpa_supplicant_init (struct wpa_params * Params)
  • Struct wpa_supplicant * wpa_supplicant_add_iface (struct wpa_global * Global, struct wpa_interface * iface)
1. wpa_supplicant_init ()

 

 

/** * wpa_supplicant_init - Initialize %wpa_supplicant * @params: Parameters for %wpa_supplicant * Returns: Pointer to global %wpa_supplicant data, or %NULL on failure * * This function is used to initialize %wpa_supplicant. After successful * initialization, the returned data pointer can be used to add and remove * network interfaces, and eventually, to deinitialize %wpa_supplicant. */struct wpa_global * wpa_supplicant_init(struct wpa_params *params){    struct wpa_global *global;    int ret, i;    if (params == NULL)        return NULL;#ifdef CONFIG_DRIVER_NDIS    {        void driver_ndis_init_ops(void);        driver_ndis_init_ops();    }#endif /* CONFIG_DRIVER_NDIS */#ifndef CONFIG_NO_WPA_MSG    wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);#endif /* CONFIG_NO_WPA_MSG */    wpa_debug_open_file(params->wpa_debug_file_path);    if (params->wpa_debug_syslog)        wpa_debug_open_syslog();    if (params->wpa_debug_tracing) {        ret = wpa_debug_open_linux_tracing();        if (ret) {            wpa_printf(MSG_ERROR,                   "Failed to enable trace logging");            return NULL;        }    }    ret = eap_register_methods();    if (ret) {        wpa_printf(MSG_ERROR, "Failed to register EAP methods");        if (ret == -2)            wpa_printf(MSG_ERROR, "Two or more EAP methods used "                   "the same EAP type.");        return NULL;    }    global = os_zalloc(sizeof(*global));    if (global == NULL)        return NULL;    dl_list_init(&global->p2p_srv_bonjour);    dl_list_init(&global->p2p_srv_upnp);    global->params.daemonize = params->daemonize;    global->params.wait_for_monitor = params->wait_for_monitor;    global->params.dbus_ctrl_interface = params->dbus_ctrl_interface;    if (params->pid_file)        global->params.pid_file = os_strdup(params->pid_file);    if (params->ctrl_interface)        global->params.ctrl_interface =            os_strdup(params->ctrl_interface);    if (params->override_driver)        global->params.override_driver =            os_strdup(params->override_driver);    if (params->override_ctrl_interface)        global->params.override_ctrl_interface =            os_strdup(params->override_ctrl_interface);    wpa_debug_level = global->params.wpa_debug_level =        params->wpa_debug_level;    wpa_debug_show_keys = global->params.wpa_debug_show_keys =        params->wpa_debug_show_keys;    wpa_debug_timestamp = global->params.wpa_debug_timestamp =        params->wpa_debug_timestamp;    wpa_printf(MSG_DEBUG, "wpa_supplicant v" VERSION_STR);    if (eloop_init()) {        wpa_printf(MSG_ERROR, "Failed to initialize event loop");        wpa_supplicant_deinit(global);        return NULL;    }    random_init(params->entropy_file);    global->ctrl_iface = wpa_supplicant_global_ctrl_iface_init(global);    if (global->ctrl_iface == NULL) {        wpa_supplicant_deinit(global);        return NULL;    }    if (wpas_notify_supplicant_initialized(global)) {        wpa_supplicant_deinit(global);        return NULL;    }    for (i = 0; wpa_drivers[i]; i++)        global->drv_count++;    if (global->drv_count == 0) {        wpa_printf(MSG_ERROR, "No drivers enabled");        wpa_supplicant_deinit(global);        return NULL;    }    global->drv_priv = os_zalloc(global->drv_count * sizeof(void *));    if (global->drv_priv == NULL) {        wpa_supplicant_deinit(global);        return NULL;    }#ifdef CONFIG_WIFI_DISPLAY    if (wifi_display_init(global) < 0) {        wpa_printf(MSG_ERROR, "Failed to initialize Wi-Fi Display");        wpa_supplicant_deinit(global);        return NULL;    }#endif /* CONFIG_WIFI_DISPLAY */    return global;}
2. wpa_supplicant_add_iface ()

In the comment of the wpa_interface struct, wpa_interface serves as the parameter of this function.

/*** Struct wpa_interface-parameters for wpa_supplicant_add_iface ()*

/Struct wpa_interface {...... }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.