struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr) { struct sta_info *sta; sta = ap_get_sta(hapd, addr); if (sta) return sta; HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, " New STA\n"); if (hapd->num_sta >= hapd->conf->max_num_sta) { /* FIX: might try to remove some old STAs first? */ printf(" no more room for new STAs (%d/%d)\n", hapd->num_sta, hapd->conf->max_num_sta); return NULL; } sta = wpa_zalloc(sizeof(struct sta_info)); if (sta == NULL) { printf(" malloc failed\n"); return NULL; } sta->acct_interim_interval = hapd->conf->radius->acct_interim_interval; /* initialize STA info data */ eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, ap_handle_timer, hapd, sta); memcpy(sta->addr, addr, ETH_ALEN); sta->next = hapd->sta_list; hapd->sta_list = sta; hapd->num_sta++; ap_sta_hash_add(hapd, sta); sta->ssid = &hapd->conf->ssid; return sta; }
struct radius_ms_mppe_keys * radius_msg_get_cisco_keys(struct radius_msg *msg, struct radius_msg *sent_msg, u8 *secret, size_t secret_len) { u8 *key; size_t keylen; struct radius_ms_mppe_keys *keys; if (msg == NULL || sent_msg == NULL) return NULL; keys = wpa_zalloc(sizeof(*keys)); if (keys == NULL) return NULL; key = radius_msg_get_vendor_attr(msg, RADIUS_VENDOR_ID_CISCO, RADIUS_CISCO_AV_PAIR, &keylen); if (key && keylen == 51 && os_memcmp(key, "leap:session-key=", 17) == 0) { keys->recv = decrypt_ms_key(key + 17, keylen - 17, sent_msg->hdr->authenticator, secret, secret_len, &keys->recv_len); } os_free(key); return keys; }
/** * eap_user_get - Fetch user information from the database * @sm: Pointer to EAP state machine allocated with eap_sm_init() * @identity: Identity (User-Name) of the user * @identity_len: Length of identity in bytes * @phase2: 0 = EAP phase1 user, 1 = EAP phase2 (tunneled) user * Returns: 0 on success, or -1 on failure * * This function is used to fetch user information for EAP. The user will be * selected based on the specified identity. sm->user and * sm->user_eap_method_index are updated for the new user when a matching user * is found. sm->user can be used to get user information (e.g., password). */ int eap_user_get(struct eap_sm *sm, const u8 *identity, size_t identity_len, int phase2) { struct eap_user *user; if (sm == NULL || sm->eapol_cb == NULL || sm->eapol_cb->get_eap_user == NULL) return -1; eap_user_free(sm->user); sm->user = NULL; user = wpa_zalloc(sizeof(*user)); if (user == NULL) return -1; if (sm->eapol_cb->get_eap_user(sm->eapol_ctx, identity, identity_len, phase2, user) != 0) { eap_user_free(user); return -1; } sm->user = user; sm->user_eap_method_index = 0; return 0; }
int radius_msg_initialize(struct radius_msg *msg, size_t init_len) { if (msg == NULL || init_len < sizeof(struct radius_hdr)) return -1; os_memset(msg, 0, sizeof(*msg)); msg->buf = wpa_zalloc(init_len); if (msg->buf == NULL) return -1; msg->buf_size = init_len; msg->hdr = (struct radius_hdr *) msg->buf; msg->buf_used = sizeof(*msg->hdr); msg->attrs = os_malloc(RADIUS_DEFAULT_ATTR_COUNT * sizeof(*msg->attrs)); if (msg->attrs == NULL) { os_free(msg->buf); msg->buf = NULL; msg->hdr = NULL; return -1; } msg->attr_size = RADIUS_DEFAULT_ATTR_COUNT; msg->attr_used = 0; return 0; }
static void * eap_tls_init(struct eap_sm *sm) { struct eap_tls_data *data; struct wpa_ssid *config = eap_get_config(sm); if (config == NULL || ((sm->init_phase2 ? config->private_key2 : config->private_key) == NULL && config->engine == 0)) { wpa_printf(MSG_INFO, "EAP-TLS: Private key not configured"); return NULL; } data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; if (eap_tls_ssl_init(sm, &data->ssl, config)) { wpa_printf(MSG_INFO, "EAP-TLS: Failed to initialize SSL."); eap_tls_deinit(sm, data); if (config->engine) { wpa_printf(MSG_DEBUG, "EAP-TLS: Requesting Smartcard " "PIN"); eap_sm_request_pin(sm); sm->ignore = TRUE; } else if (config->private_key && !config->private_key_passwd) { wpa_printf(MSG_DEBUG, "EAP-TLS: Requesting private " "key passphrase"); eap_sm_request_passphrase(sm); sm->ignore = TRUE; } return NULL; } return data; }
struct l2_packet_data * l2_packet_init( const char *ifname, const u8 *own_addr, unsigned short protocol, void (*rx_callback)(void *ctx, const u8 *src_addr, const u8 *buf, size_t len), void *rx_callback_ctx, int l2_hdr) { struct l2_packet_data *l2; l2 = wpa_zalloc(sizeof(struct l2_packet_data)); if (l2 == NULL) return NULL; strncpy(l2->ifname, ifname, sizeof(l2->ifname)); l2->rx_callback = rx_callback; l2->rx_callback_ctx = rx_callback_ctx; l2->l2_hdr = l2_hdr; #ifdef CONFIG_WINPCAP if (own_addr) memcpy(l2->own_addr, own_addr, ETH_ALEN); #else /* CONFIG_WINPCAP */ if (l2_packet_init_libdnet(l2)) return NULL; #endif /* CONFIG_WINPCAP */ if (l2_packet_init_libpcap(l2, protocol)) { #ifndef CONFIG_WINPCAP eth_close(l2->eth); #endif /* CONFIG_WINPCAP */ free(l2); return NULL; } return l2; }
struct radius_client_data * radius_client_init(void *ctx, struct hostapd_radius_servers *conf) { struct radius_client_data *radius; radius = wpa_zalloc(sizeof(struct radius_client_data)); if (radius == NULL) return NULL; radius->ctx = ctx; radius->conf = conf; radius->auth_serv_sock = radius->acct_serv_sock = radius->auth_serv_sock6 = radius->acct_serv_sock6 = radius->auth_sock = radius->acct_sock = -1; if (conf->auth_server && radius_client_init_auth(radius)) { radius_client_deinit(radius); return NULL; } if (conf->acct_server && radius_client_init_acct(radius)) { radius_client_deinit(radius); return NULL; } if (conf->retry_primary_interval) eloop_register_timeout(conf->retry_primary_interval, 0, radius_retry_primary_timer, radius, NULL); return radius; }
static void test_driver_mlme(struct test_driver_data *drv, struct sockaddr_un *from, socklen_t fromlen, u8 *data, size_t datalen) { struct ieee80211_hdr *hdr; u16 fc; hdr = (struct ieee80211_hdr *) data; if (test_driver_get_cli(drv, from, fromlen) == NULL && datalen >= 16) { struct test_client_socket *cli; cli = wpa_zalloc(sizeof(*cli)); if (cli == NULL) return; wpa_printf(MSG_DEBUG, "Adding client entry for " MACSTR, MAC2STR(hdr->addr2)); memcpy(cli->addr, hdr->addr2, ETH_ALEN); memcpy(&cli->un, from, sizeof(cli->un)); cli->unlen = fromlen; cli->next = drv->cli; drv->cli = cli; } wpa_hexdump(MSG_MSGDUMP, "test_driver_mlme: received frame", data, datalen); fc = le_to_host16(hdr->frame_control); if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT) { wpa_printf(MSG_ERROR, "%s: received non-mgmt frame", __func__); return; } ieee802_11_mgmt(drv->hapd, data, datalen, WLAN_FC_GET_STYPE(fc), NULL); }
static void * eap_sake_init(struct eap_sm *sm) { struct eap_sake_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = CHALLENGE; if (hostapd_get_rand(&data->session_id, 1)) { wpa_printf(MSG_ERROR, "EAP-SAKE: Failed to get random data"); os_free(data); return NULL; } wpa_printf(MSG_DEBUG, "EAP-SAKE: Initialized Session ID %d", data->session_id); /* TODO: add support for configuring SERVERID */ data->serverid = (u8 *) strdup("hostapd"); if (data->serverid) data->serverid_len = strlen((char *) data->serverid); (void)sm; return data; }
static struct radius_session * radius_server_new_session(struct radius_server_data *data, struct radius_client *client) { struct radius_session *sess; if (data->num_sess >= RADIUS_MAX_SESSION) { RADIUS_DEBUG("Maximum number of existing session - no room " "for a new session"); return NULL; } sess = wpa_zalloc(sizeof(*sess)); if (sess == NULL) return NULL; sess->server = data; sess->client = client; sess->sess_id = data->next_sess_id++; sess->next = client->sessions; client->sessions = sess; eloop_register_timeout(RADIUS_SESSION_TIMEOUT, 0, radius_server_session_timeout, data, sess); data->num_sess++; return sess; }
static void * eap_mschapv2_init(struct eap_sm *sm) { struct eap_mschapv2_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->full_key = sm->mschapv2_full_key; if (sm->peer_challenge) { data->full_key = 1; data->peer_challenge = malloc(16); if (data->peer_challenge == NULL) { eap_mschapv2_deinit(sm, data); return NULL; } memcpy(data->peer_challenge, sm->peer_challenge, 16); } if (sm->auth_challenge) { data->auth_challenge = malloc(16); if (data->auth_challenge == NULL) { eap_mschapv2_deinit(sm, data); return NULL; } memcpy(data->auth_challenge, sm->auth_challenge, 16); } data->phase2 = sm->init_phase2; return data; }
static dbus_bool_t _wpa_dbus_dict_entry_get_string_array( DBusMessageIter *iter, int array_type, struct wpa_dbus_dict_entry *entry) { dbus_uint32_t count = 0; dbus_bool_t success = FALSE; char **buffer; entry->strarray_value = NULL; entry->array_type = DBUS_TYPE_STRING; buffer = wpa_zalloc(STR_ARRAY_ITEM_SIZE * STR_ARRAY_CHUNK_SIZE); if (buffer == NULL) { perror("_wpa_dbus_dict_entry_get_string_array[dbus] out of " "memory trying to retrieve a string array"); goto done; } entry->strarray_value = buffer; entry->array_len = 0; while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) { const char *value; char *str; if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) { buffer = realloc(buffer, STR_ARRAY_ITEM_SIZE * (count + STR_ARRAY_CHUNK_SIZE)); if (buffer == NULL) { perror("_wpa_dbus_dict_entry_get_string_array[" "dbus] out of memory trying to " "retrieve the string array"); goto done; } } entry->strarray_value = buffer; dbus_message_iter_get_basic(iter, &value); str = strdup(value); if (str == NULL) { perror("_wpa_dbus_dict_entry_get_string_array[dbus] " "out of memory trying to duplicate the string " "array"); goto done; } entry->strarray_value[count] = str; entry->array_len = ++count; dbus_message_iter_next(iter); } /* Zero-length arrays are valid. */ if (entry->array_len == 0) { free(entry->strarray_value); entry->strarray_value = NULL; } success = TRUE; done: return success; }
static struct ap_info * ap_ap_add(struct hostapd_iface *iface, u8 *addr) { struct ap_info *ap; ap = wpa_zalloc(sizeof(struct ap_info)); if (ap == NULL) return NULL; /* initialize AP info data */ memcpy(ap->addr, addr, ETH_ALEN); ap_ap_list_add(iface, ap); iface->num_ap++; ap_ap_hash_add(iface, ap); ap_ap_iter_list_add(iface, ap); if (iface->num_ap > iface->conf->ap_table_max_size && ap != ap->prev) { wpa_printf(MSG_DEBUG, "Removing the least recently used AP " MACSTR " from AP table", MAC2STR(ap->prev->addr)); if (iface->conf->passive_scan_interval > 0) ap_list_expired_ap(iface, ap->prev); ap_free_ap(iface, ap->prev); } return ap; }
/** * eap_sim_db_init - Initialize EAP-SIM DB / authentication gateway interface * @config: Configuration data (e.g., file name) * @get_complete_cb: Callback function for reporting availability of triplets * @ctx: Context pointer for get_complete_cb * Returns: Pointer to a private data structure or %NULL on failure */ void * eap_sim_db_init(const char *config, void (*get_complete_cb)(void *ctx, void *session_ctx), void *ctx) { struct eap_sim_db_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->sock = -1; data->get_complete_cb = get_complete_cb; data->ctx = ctx; data->fname = VM_STRDUP(config); if (data->fname == NULL) goto fail; if (strncmp(data->fname, "unix:", 5) == 0) { if (eap_sim_db_open_socket(data)) goto fail; } return data; fail: eap_sim_db_close_socket(data); VM_FREE(data->fname); VM_FREE(data); return NULL; }
static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array( DBusMessageIter *iter, int array_len, int array_type, struct wpa_dbus_dict_entry *entry) { dbus_uint32_t i = 0; dbus_bool_t success = FALSE; char byte; /* Zero-length arrays are valid. */ if (array_len == 0) { entry->bytearray_value = NULL; entry->array_type = DBUS_TYPE_BYTE; success = TRUE; goto done; } entry->bytearray_value = wpa_zalloc(array_len * sizeof(char)); if (!entry->bytearray_value) { perror("_wpa_dbus_dict_entry_get_byte_array[dbus]: out of " "memory"); goto done; } entry->array_type = DBUS_TYPE_BYTE; entry->array_len = array_len; while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) { dbus_message_iter_get_basic(iter, &byte); entry->bytearray_value[i++] = byte; dbus_message_iter_next(iter); } success = TRUE; done: return success; }
static u8 * eap_sake_build_msg(struct eap_sake_data *data, u8 **payload, int id, size_t *length, u8 subtype) { struct eap_sake_hdr *req; u8 *msg; *length += sizeof(struct eap_sake_hdr); msg = wpa_zalloc(*length); if (msg == NULL) { wpa_printf(MSG_ERROR, "EAP-SAKE: Failed to allocate memory " "request"); return NULL; } req = (struct eap_sake_hdr *) msg; req->code = EAP_CODE_REQUEST; req->identifier = id; req->length = htons((u16) *length); req->type = EAP_TYPE_SAKE; req->version = EAP_SAKE_VERSION; req->session_id = data->session_id; req->subtype = subtype; *payload = (u8 *) (req + 1); return msg; }
static int rsn_preauth_iface_add(struct hostapd_data *hapd, const char *ifname) { struct rsn_preauth_interface *piface; HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "RSN pre-auth interface '%s'\n", ifname); piface = wpa_zalloc(sizeof(*piface)); if (piface == NULL) return -1; piface->hapd = hapd; piface->ifname = strdup(ifname); if (piface->ifname == NULL) { goto fail1; } piface->l2 = l2_packet_init(piface->ifname, NULL, ETH_P_PREAUTH, rsn_preauth_receive, piface, 1); if (piface->l2 == NULL) { printf("Failed to open register layer 2 access to " "ETH_P_PREAUTH\n"); goto fail2; } piface->next = hapd->preauth_iface; hapd->preauth_iface = piface; return 0; fail2: free(piface->ifname); fail1: free(piface); return -1; }
struct l2_packet_data * l2_packet_init( const char *ifname, const u8 *own_addr, unsigned short protocol, void (*rx_callback)(void *ctx, const u8 *src_addr, const u8 *buf, size_t len), void *rx_callback_ctx, int l2_hdr) { struct l2_packet_data *l2; struct ifreq ifr; struct sockaddr_ll ll; l2 = wpa_zalloc(sizeof(struct l2_packet_data)); if (l2 == NULL) return NULL; strncpy(l2->ifname, ifname, sizeof(l2->ifname)); l2->rx_callback = rx_callback; l2->rx_callback_ctx = rx_callback_ctx; l2->l2_hdr = l2_hdr; l2->fd = socket(PF_PACKET, l2_hdr ? SOCK_RAW : SOCK_DGRAM, htons(protocol)); if (l2->fd < 0) { perror("socket(PF_PACKET)"); free(l2); return NULL; } strncpy(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name)); if (ioctl(l2->fd, SIOCGIFINDEX, &ifr) < 0) { perror("ioctl[SIOCGIFINDEX]"); close(l2->fd); free(l2); return NULL; } l2->ifindex = ifr.ifr_ifindex; memset(&ll, 0, sizeof(ll)); ll.sll_family = PF_PACKET; ll.sll_ifindex = ifr.ifr_ifindex; ll.sll_protocol = htons(protocol); if (bind(l2->fd, (struct sockaddr *) &ll, sizeof(ll)) < 0) { perror("bind[PF_PACKET]"); close(l2->fd); free(l2); return NULL; } if (ioctl(l2->fd, SIOCGIFHWADDR, &ifr) < 0) { perror("ioctl[SIOCGIFHWADDR]"); close(l2->fd); free(l2); return NULL; } memcpy(l2->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN); eloop_register_read_sock(l2->fd, l2_packet_receive, l2, NULL); return l2; }
static void * eap_mschapv2_init(struct eap_sm *sm) { struct eap_mschapv2_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = CHALLENGE; return data; }
static void * eap_vendor_test_init(struct eap_sm *sm) { struct eap_vendor_test_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = INIT; return data; }
static void * eap_tlv_init(struct eap_sm *sm) { struct eap_tlv_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = CONTINUE; return data; }
static struct wps_config * wpa_config_read_wps_property(FILE *f, int *line) { struct wps_config *wps; int errors = 0, end = 0; char buf[256], *pos, *pos2; wpa_printf(MSG_MSGDUMP, "Line: %d - start of a wps_property block", *line); wps = wpa_zalloc(sizeof(*wps)); if (wps == NULL) return NULL; while (wpa_config_get_line(buf, sizeof(buf), f, line, &pos)) { if (strcmp(pos, "}") == 0) { end = 1; break; } pos2 = os_strchr(pos, '='); if (pos2 == NULL) { wpa_printf(MSG_ERROR, "Line %d: Invalid property line " "'%s'.", *line, pos); errors++; continue; } *pos2++ = '\0'; if (*pos2 == '"') { if (os_strchr(pos2 + 1, '"') == NULL) { wpa_printf(MSG_ERROR, "Line %d: invalid " "quotation '%s'.", *line, pos2); errors++; continue; } } if (wps_config_set(wps, pos, pos2, *line) < 0) errors++; } if (!end) { wpa_printf(MSG_ERROR, "Line %d: wps_property block was not " "terminated properly.", *line); errors++; } if (errors) { wpa_config_free_wps_config(wps); wps = NULL; } return wps; }
static void radius_client_list_add(struct radius_client_data *radius, struct radius_msg *msg, RadiusType msg_type, u8 *shared_secret, size_t shared_secret_len, const u8 *addr) { struct radius_msg_list *entry, *prev; if (eloop_terminated()) { /* No point in adding entries to retransmit queue since event * loop has already been terminated. */ radius_msg_free(msg); os_free(msg); return; } entry = wpa_zalloc(sizeof(*entry)); if (entry == NULL) { printf("Failed to add RADIUS packet into retransmit list\n"); radius_msg_free(msg); os_free(msg); return; } if (addr) os_memcpy(entry->addr, addr, ETH_ALEN); entry->msg = msg; entry->msg_type = msg_type; entry->shared_secret = shared_secret; entry->shared_secret_len = shared_secret_len; os_get_time(&entry->last_attempt); entry->first_try = entry->last_attempt.sec; entry->next_try = entry->first_try + RADIUS_CLIENT_FIRST_WAIT; entry->attempts = 1; entry->next_wait = RADIUS_CLIENT_FIRST_WAIT * 2; entry->next = radius->msgs; radius->msgs = entry; radius_client_update_timeout(radius); if (radius->num_msgs >= RADIUS_CLIENT_MAX_ENTRIES) { printf("Removing the oldest un-ACKed RADIUS packet due to " "retransmit list limits.\n"); prev = NULL; while (entry->next) { prev = entry; entry = entry->next; } if (prev) { prev->next = NULL; radius_client_msg_free(entry); } } else radius->num_msgs++; }
struct radius_server_data * radius_server_init(struct radius_server_conf *conf) { struct radius_server_data *data; #ifndef CONFIG_IPV6 if (conf->ipv6) { fprintf(stderr, "RADIUS server compiled without IPv6 " "support.\n"); return NULL; } #endif /* CONFIG_IPV6 */ data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; os_get_time(&data->start_time); data->hostapd_conf = conf->hostapd_conf; data->eap_sim_db_priv = conf->eap_sim_db_priv; data->ssl_ctx = conf->ssl_ctx; data->ipv6 = conf->ipv6; data->clients = radius_server_read_clients(conf->client_file, conf->ipv6); if (data->clients == NULL) { printf("No RADIUS clients configured.\n"); radius_server_deinit(data); return NULL; } #ifdef CONFIG_IPV6 if (conf->ipv6) data->auth_sock = radius_server_open_socket6(conf->auth_port); else #endif /* CONFIG_IPV6 */ data->auth_sock = radius_server_open_socket(conf->auth_port); if (data->auth_sock < 0) { printf("Failed to open UDP socket for RADIUS authentication " "server\n"); radius_server_deinit(data); return NULL; } if (eloop_register_read_sock(data->auth_sock, radius_server_receive_auth, data, NULL)) { radius_server_deinit(data); return NULL; } return data; }
static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array( DBusMessageIter *iter, int array_type, struct wpa_dbus_dict_entry *entry) { dbus_uint32_t count = 0; dbus_bool_t success = FALSE; char *buffer; entry->bytearray_value = NULL; entry->array_type = DBUS_TYPE_BYTE; buffer = wpa_zalloc(BYTE_ARRAY_ITEM_SIZE * BYTE_ARRAY_CHUNK_SIZE); if (!buffer) { perror("_wpa_dbus_dict_entry_get_byte_array[dbus]: out of " "memory"); goto done; } entry->bytearray_value = buffer; entry->array_len = 0; while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) { char byte; if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) { buffer = realloc(buffer, BYTE_ARRAY_ITEM_SIZE * (count + BYTE_ARRAY_CHUNK_SIZE)); if (buffer == NULL) { perror("_wpa_dbus_dict_entry_get_byte_array[" "dbus] out of memory trying to " "retrieve the string array"); goto done; } } entry->bytearray_value = buffer; dbus_message_iter_get_basic(iter, &byte); entry->bytearray_value[count] = byte; entry->array_len = ++count; dbus_message_iter_next(iter); } /* Zero-length arrays are valid. */ if (entry->array_len == 0) { free(entry->bytearray_value); entry->bytearray_value = NULL; } success = TRUE; done: return success; }
/** * eap_server_method_alloc - Allocate EAP server method structure * @version: Version of the EAP server method interface (set to * EAP_SERVER_METHOD_INTERFACE_VERSION) * @vendor: EAP Vendor-ID (EAP_VENDOR_*) (0 = IETF) * @method: EAP type number (EAP_TYPE_*) * name: Name of the method (e.g., "TLS") * Returns: Allocated EAP method structure or %NULL on failure * * The returned structure should be freed with eap_server_method_free() when it * is not needed anymore. */ struct eap_method * eap_server_method_alloc(int version, int vendor, EapType method, const char *name) { struct eap_method *eap; eap = wpa_zalloc(sizeof(*eap)); if (eap == NULL) return NULL; eap->version = version; eap->vendor = vendor; eap->method = method; eap->name = name; return eap; }
/** * pmksa_cache_init - Initialize PMKSA cache * @free_cb: Callback function to be called when a PMKSA cache entry is freed * @ctx: Context pointer for free_cb function * Returns: Pointer to PMKSA cache data or %NULL on failure */ struct rsn_pmksa_cache * pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx), void *ctx) { struct rsn_pmksa_cache *pmksa; pmksa = wpa_zalloc(sizeof(*pmksa)); if (pmksa) { pmksa->free_cb = free_cb; pmksa->ctx = ctx; } return pmksa; }
static void * eap_gtc_init(struct eap_sm *sm) { struct eap_gtc_data *data; data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; if (sm->m && sm->m->method == EAP_TYPE_FAST) { wpa_printf(MSG_DEBUG, "EAP-GTC: EAP-FAST tunnel - use prefix " "with challenge/response"); data->prefix = 1; } return data; }
static void * eap_sim_init(struct eap_sm *sm) { struct eap_sim_data *data; if (sm->eap_sim_db_priv == NULL) { wpa_printf(MSG_WARNING, "EAP-SIM: eap_sim_db not configured"); return NULL; } data = wpa_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = START; return data; }
/** * pmksa_cache_init - Initialize PMKSA cache * @free_cb: Callback function to be called when a PMKSA cache entry is freed * @ctx: Context pointer for free_cb function * @sm: Pointer to WPA state machine data from wpa_sm_init() * Returns: Pointer to PMKSA cache data or %NULL on failure */ struct rsn_pmksa_cache * pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx, int replace), void *ctx, struct wpa_sm *sm) { struct rsn_pmksa_cache *pmksa; pmksa = wpa_zalloc(sizeof(*pmksa)); if (pmksa) { pmksa->free_cb = free_cb; pmksa->ctx = ctx; pmksa->sm = sm; } return pmksa; }