contrib/hostapd/hostapd/hostapd.c
static struct hostapd_data *
hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
		       struct hostapd_config *conf,
		       struct hostapd_bss_config *bss)
{
	struct hostapd_data *hapd;

	hapd = os_zalloc(sizeof(*hapd));
	if (hapd == NULL)
		return NULL;

	hapd->iconf = conf;
	hapd->conf = bss;
	hapd->iface = hapd_iface;

	if (hapd->conf->individual_wep_key_len > 0) {
		/* use key0 in individual key and key1 in broadcast key */
		hapd->default_wep_key_idx = 1;
	}

#ifdef EAP_TLS_FUNCS
	if (hapd->conf->eap_server &&
	    (hapd->conf->ca_cert || hapd->conf->server_cert ||
	     hapd->conf->dh_file)) {
		struct tls_connection_params params;

		hapd->ssl_ctx = tls_init(NULL);
		if (hapd->ssl_ctx == NULL) {
			wpa_printf(MSG_ERROR, "Failed to initialize TLS");
			goto fail;
		}

		os_memset(&params, 0, sizeof(params));
		params.ca_cert = hapd->conf->ca_cert;
		params.client_cert = hapd->conf->server_cert;
		params.private_key = hapd->conf->private_key;
		params.private_key_passwd = hapd->conf->private_key_passwd;
		params.dh_file = hapd->conf->dh_file;

		if (tls_global_set_params(hapd->ssl_ctx, &params)) {
			wpa_printf(MSG_ERROR, "Failed to set TLS parameters");
			goto fail;
		}

		if (tls_global_set_verify(hapd->ssl_ctx,
					  hapd->conf->check_crl)) {
			wpa_printf(MSG_ERROR, "Failed to enable check_crl");
			goto fail;
		}
	}
#endif /* EAP_TLS_FUNCS */

#ifdef EAP_SERVER
	if (hapd->conf->eap_sim_db) {
		hapd->eap_sim_db_priv =
			eap_sim_db_init(hapd->conf->eap_sim_db,
					hostapd_sim_db_cb, hapd);
		if (hapd->eap_sim_db_priv == NULL) {
			wpa_printf(MSG_ERROR, "Failed to initialize EAP-SIM "
				   "database interface");
			goto fail;
		}
	}
#endif /* EAP_SERVER */

	hapd->driver = hapd->iconf->driver;

	return hapd;

#if defined(EAP_TLS_FUNCS) || defined(EAP_SERVER)
fail:
#endif
	/* TODO: cleanup allocated resources(?) */
	os_free(hapd);
	return NULL;
}
/**
 * hostapd_alloc_bss_data - Allocate and initialize per-BSS data
 * @hapd_iface: Pointer to interface data
 * @conf: Pointer to per-interface configuration
 * @bss: Pointer to per-BSS configuration for this BSS
 * Returns: Pointer to allocated BSS data
 *
 * This function is used to allocate per-BSS data structure. This data will be
 * freed after hostapd_cleanup() is called for it during interface
 * deinitialization.
 */
Allocate and initialize per-BSS data
@hapd_iface: Pointer to interface data
@conf: Pointer to per-interface configuration
@bss: Pointer to per-BSS configuration for this BSS
Returns: Pointer to allocated BSS data

This function is used to allocate per-BSS data structure. This data will be
freed after hostapd_cleanup() is called for it during interface
deinitialization.
Allocate and initialize per - BSS data @hapd_iface : Pointer to interface data @conf : Pointer to per - interface configuration @bss : Pointer to per - BSS configuration for this BSS Returns : Pointer to allocated BSS data This function is used to allocate per - BSS data structure . This data will be freed after hostapd_cleanup () is called for it during interface deinitialization .
static struct hostapd_data *
hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
		       struct hostapd_config *conf,
		       struct hostapd_bss_config *bss)
{
	struct hostapd_data *hapd;
	hapd = os_zalloc(sizeof(*hapd));
	if (hapd == NULL)
		return NULL;
	hapd->iconf = conf;
	hapd->conf = bss;
	hapd->iface = hapd_iface;
	if (hapd->conf->individual_wep_key_len > 0) {
		hapd->default_wep_key_idx = 1;
	}
#ifdef EAP_TLS_FUNCS
	if (hapd->conf->eap_server &&
	    (hapd->conf->ca_cert || hapd->conf->server_cert ||
	     hapd->conf->dh_file)) {
		struct tls_connection_params params;
		hapd->ssl_ctx = tls_init(NULL);
		if (hapd->ssl_ctx == NULL) {
			wpa_printf(MSG_ERROR, "Failed to initialize TLS");
			goto fail;
		}
		os_memset(&params, 0, sizeof(params));
		params.ca_cert = hapd->conf->ca_cert;
		params.client_cert = hapd->conf->server_cert;
		params.private_key = hapd->conf->private_key;
		params.private_key_passwd = hapd->conf->private_key_passwd;
		params.dh_file = hapd->conf->dh_file;
		if (tls_global_set_params(hapd->ssl_ctx, &params)) {
			wpa_printf(MSG_ERROR, "Failed to set TLS parameters");
			goto fail;
		}
		if (tls_global_set_verify(hapd->ssl_ctx,
					  hapd->conf->check_crl)) {
			wpa_printf(MSG_ERROR, "Failed to enable check_crl");
			goto fail;
		}
	}
#endif 
#ifdef EAP_SERVER
	if (hapd->conf->eap_sim_db) {
		hapd->eap_sim_db_priv =
			eap_sim_db_init(hapd->conf->eap_sim_db,
					hostapd_sim_db_cb, hapd);
		if (hapd->eap_sim_db_priv == NULL) {
			wpa_printf(MSG_ERROR, "Failed to initialize EAP-SIM "
				   "database interface");
			goto fail;
		}
	}
#endif 
	hapd->driver = hapd->iconf->driver;
	return hapd;
#if defined(EAP_TLS_FUNCS) || defined(EAP_SERVER)
fail:
#endif
	os_free(hapd);
	return NULL;
}
static struct hostapd_data * hostapd_alloc_bss_data ( struct hostapd_iface * hapd_iface , struct hostapd_config * conf , struct hostapd_bss_config * bss ) { struct hostapd_data * hapd ; hapd = os_zalloc ( sizeof ( * hapd ) ) ; if ( hapd == NULL ) return NULL ; hapd -> iconf = conf ; hapd -> conf = bss ; hapd -> iface = hapd_iface ; if ( hapd -> conf -> individual_wep_key_len > 0 ) { hapd -> default_wep_key_idx = 1 ; } #ifdef EAP_TLS_FUNCS if ( hapd -> conf -> eap_server && ( hapd -> conf -> ca_cert || hapd -> conf -> server_cert || hapd -> conf -> dh_file ) ) { struct tls_connection_params params ; hapd -> ssl_ctx = tls_init ( NULL ) ; if ( hapd -> ssl_ctx == NULL ) { wpa_printf ( MSG_ERROR , " " ) ; goto fail ; } os_memset ( & params , 0 , sizeof ( params ) ) ; params . ca_cert = hapd -> conf -> ca_cert ; params . client_cert = hapd -> conf -> server_cert ; params . private_key = hapd -> conf -> private_key ; params . private_key_passwd = hapd -> conf -> private_key_passwd ; params . dh_file = hapd -> conf -> dh_file ; if ( tls_global_set_params ( hapd -> ssl_ctx , & params ) ) { wpa_printf ( MSG_ERROR , " " ) ; goto fail ; } if ( tls_global_set_verify ( hapd -> ssl_ctx , hapd -> conf -> check_crl ) ) { wpa_printf ( MSG_ERROR , " " ) ; goto fail ; } } #endif #ifdef EAP_SERVER if ( hapd -> conf -> eap_sim_db ) { hapd -> eap_sim_db_priv = eap_sim_db_init ( hapd -> conf -> eap_sim_db , hostapd_sim_db_cb , hapd ) ; if ( hapd -> eap_sim_db_priv == NULL ) { wpa_printf ( MSG_ERROR , " " " " ) ; goto fail ; } } #endif hapd -> driver = hapd -> iconf -> driver ; return hapd ; #if defined ( EAP_TLS_FUNCS ) || defined ( EAP_SERVER ) fail : #endif os_free ( hapd ) ; return NULL ; }
hostapd_alloc_bss_data - Allocate and initialize per-BSS data
 @hapd_iface: Pointer to interface data
 @conf: Pointer to per-interface configuration
 @bss: Pointer to per-BSS configuration for this BSS
 Returns: Pointer to allocated BSS data
hostapd_alloc_bss_data - Allocate and initialize per - BSS data @hapd_iface : Pointer to interface data @conf : Pointer to per - interface configuration @bss : Pointer to per - BSS configuration for this BSS Returns : Pointer to allocated BSS data
/* use key0 in individual key and key1 in broadcast key */ /* EAP_TLS_FUNCS */ /* EAP_SERVER */ /* TODO: cleanup allocated resources(?) */